@azure-rest/maps-geolocation 1.0.0-beta.2 → 1.0.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +48 -2
- package/dist/index.js +30 -12
- package/dist/index.js.map +1 -1
- package/dist-esm/src/MapsGeolocation.js +12 -1
- package/dist-esm/src/MapsGeolocation.js.map +1 -1
- package/dist-esm/src/generated/isUnexpected.js +3 -4
- package/dist-esm/src/generated/isUnexpected.js.map +1 -1
- package/dist-esm/src/generated/mapsGeolocationClient.js +12 -7
- package/dist-esm/src/generated/mapsGeolocationClient.js.map +1 -1
- package/package.json +16 -16
- package/review/maps-geolocation.api.md +4 -0
- package/types/maps-geolocation-rest.d.ts +19 -1
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@ Key links:
|
|
|
16
16
|
|
|
17
17
|
### Currently supported environments
|
|
18
18
|
|
|
19
|
-
- [LTS versions of Node.js](https://
|
|
19
|
+
- [LTS versions of Node.js](https://github.com/nodejs/release#release-schedule)
|
|
20
20
|
- Latest versions of Safari, Chrome, Edge and Firefox.
|
|
21
21
|
|
|
22
22
|
### Prerequisites
|
|
@@ -69,7 +69,7 @@ const client = MapsGeolocation(credential, "<maps-account-client-id>");
|
|
|
69
69
|
|
|
70
70
|
#### Using a Subscription Key Credential
|
|
71
71
|
|
|
72
|
-
You can authenticate with your Azure Maps Subscription Key. Please install the
|
|
72
|
+
You can authenticate with your Azure Maps Subscription Key. Please install the["@azure/core-auth"](https://www.npmjs.com/package/@azure/core-auth)package:
|
|
73
73
|
|
|
74
74
|
```bash
|
|
75
75
|
npm install @azure/core-auth
|
|
@@ -82,6 +82,52 @@ const credential = new AzureKeyCredential("<subscription-key>");
|
|
|
82
82
|
const client = MapsGeolocation(credential);
|
|
83
83
|
```
|
|
84
84
|
|
|
85
|
+
#### Using a Shared Access Signature (SAS) Token Credential
|
|
86
|
+
|
|
87
|
+
Shared access signature (SAS) tokens are authentication tokens created using the JSON Web token (JWT) format and are cryptographically signed to prove authentication for an application to the Azure Maps REST API.
|
|
88
|
+
|
|
89
|
+
You can get the SAS token using [`AzureMapsManagementClient.accounts.listSas`](https://learn.microsoft.com/javascript/api/%40azure/arm-maps/accounts?view=azure-node-latest#@azure-arm-maps-accounts-listsas) from ["@azure/arm-maps"](https://www.npmjs.com/package/@azure/arm-maps) package. Please follow the section [Create and authenticate a `AzureMapsManagementClient`](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/maps/arm-maps#create-and-authenticate-a-azuremapsmanagementclient) to setup first.
|
|
90
|
+
|
|
91
|
+
Second, follow [Managed identities for Azure Maps](https://techcommunity.microsoft.com/t5/azure-maps-blog/managed-identities-for-azure-maps/ba-p/3666312) to create a managed identity for your Azure Maps account. Copy the principal ID (object ID) of the managed identity.
|
|
92
|
+
|
|
93
|
+
Third, you will need to install["@azure/core-auth"](https://www.npmjs.com/package/@azure/core-auth)package to use `AzureSASCredential`:
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
npm install @azure/core-auth
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Finally, you can use the SAS token to authenticate the client:
|
|
100
|
+
|
|
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);
|
|
129
|
+
```
|
|
130
|
+
|
|
85
131
|
## Key concepts
|
|
86
132
|
|
|
87
133
|
### MapsGeolocationClient
|
package/dist/index.js
CHANGED
|
@@ -8,24 +8,30 @@ var coreClient = require('@azure-rest/core-client');
|
|
|
8
8
|
var coreRestPipeline = require('@azure/core-rest-pipeline');
|
|
9
9
|
|
|
10
10
|
// Copyright (c) Microsoft Corporation.
|
|
11
|
+
// Licensed under the MIT license.
|
|
11
12
|
/**
|
|
12
13
|
* Initialize a new instance of the class MapsGeolocationClient class.
|
|
13
14
|
* @param credentials type: KeyCredential
|
|
14
15
|
*/
|
|
15
16
|
function createClient(credentials, options = {}) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
options
|
|
19
|
-
|
|
17
|
+
const baseUrl = options.baseUrl ?? `https://atlas.microsoft.com`;
|
|
18
|
+
options.apiVersion = options.apiVersion ?? "1.0";
|
|
19
|
+
options = {
|
|
20
|
+
...options,
|
|
21
|
+
credentials: {
|
|
20
22
|
apiKeyHeaderName: "subscription-key"
|
|
21
|
-
}
|
|
23
|
+
}
|
|
24
|
+
};
|
|
22
25
|
const userAgentInfo = `azsdk-js-maps-geolocation-rest/1.0.0-beta.1`;
|
|
23
26
|
const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
|
|
24
27
|
? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`
|
|
25
28
|
: `${userAgentInfo}`;
|
|
26
|
-
options =
|
|
29
|
+
options = {
|
|
30
|
+
...options,
|
|
31
|
+
userAgentOptions: {
|
|
27
32
|
userAgentPrefix
|
|
28
|
-
}
|
|
33
|
+
}
|
|
34
|
+
};
|
|
29
35
|
const client = coreClient.getClient(baseUrl, credentials, options);
|
|
30
36
|
return client;
|
|
31
37
|
}
|
|
@@ -37,7 +43,7 @@ const responseMap = {
|
|
|
37
43
|
};
|
|
38
44
|
function isUnexpected(response) {
|
|
39
45
|
const lroOriginal = response.headers["x-ms-original-url"];
|
|
40
|
-
const url = new URL(lroOriginal
|
|
46
|
+
const url = new URL(lroOriginal ?? response.request.url);
|
|
41
47
|
const method = response.request.method;
|
|
42
48
|
let pathDetails = responseMap[`${method} ${url.pathname}`];
|
|
43
49
|
if (!pathDetails) {
|
|
@@ -46,7 +52,6 @@ function isUnexpected(response) {
|
|
|
46
52
|
return !pathDetails.includes(response.status);
|
|
47
53
|
}
|
|
48
54
|
function geParametrizedPathSuccess(method, path) {
|
|
49
|
-
var _a, _b;
|
|
50
55
|
const pathParts = path.split("/");
|
|
51
56
|
// Iterate the responseMap to find a match
|
|
52
57
|
for (const [key, value] of Object.entries(responseMap)) {
|
|
@@ -65,8 +70,8 @@ function geParametrizedPathSuccess(method, path) {
|
|
|
65
70
|
// track if we have found a match to return the values found.
|
|
66
71
|
let found = true;
|
|
67
72
|
for (let i = 0; i < candidateParts.length; i++) {
|
|
68
|
-
if (
|
|
69
|
-
|
|
73
|
+
if (candidateParts[i]?.startsWith("{") &&
|
|
74
|
+
candidateParts[i]?.endsWith("}")) {
|
|
70
75
|
// If the current part of the candidate is a "template" part
|
|
71
76
|
// it is a match with the actual path part on hand
|
|
72
77
|
// skip as the parameterized part can match anything
|
|
@@ -100,6 +105,7 @@ function getPathFromMapKey(mapKey) {
|
|
|
100
105
|
}
|
|
101
106
|
|
|
102
107
|
// Copyright (c) Microsoft Corporation.
|
|
108
|
+
// Licensed under the MIT license.
|
|
103
109
|
function MapsGeolocation(credential, clientIdOrOptions = {}, maybeOptions = {}) {
|
|
104
110
|
const options = typeof clientIdOrOptions === "string" ? maybeOptions : clientIdOrOptions;
|
|
105
111
|
/**
|
|
@@ -120,11 +126,23 @@ function MapsGeolocation(credential, clientIdOrOptions = {}, maybeOptions = {})
|
|
|
120
126
|
client.pipeline.addPolicy(mapsCommon.createMapsClientIdPolicy(clientId));
|
|
121
127
|
return client;
|
|
122
128
|
}
|
|
129
|
+
if (coreAuth.isSASCredential(credential)) {
|
|
130
|
+
const client = createClient(undefined, options);
|
|
131
|
+
client.pipeline.addPolicy({
|
|
132
|
+
name: "mapsSASCredentialPolicy",
|
|
133
|
+
async sendRequest(request, next) {
|
|
134
|
+
request.headers.set("Authorization", `jwt-sas ${credential.signature}`);
|
|
135
|
+
return next(request);
|
|
136
|
+
},
|
|
137
|
+
});
|
|
138
|
+
return client;
|
|
139
|
+
}
|
|
123
140
|
return createClient(credential, options);
|
|
124
141
|
}
|
|
125
142
|
|
|
126
143
|
// Copyright (c) Microsoft Corporation.
|
|
144
|
+
// Licensed under the MIT license.
|
|
127
145
|
|
|
128
|
-
exports
|
|
146
|
+
exports.default = MapsGeolocation;
|
|
129
147
|
exports.isUnexpected = isUnexpected;
|
|
130
148
|
//# sourceMappingURL=index.js.map
|
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 { AzureKeyCredential, TokenCredential, isTokenCredential } 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/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;\nexport default function MapsGeolocation(\n credential: TokenCredential | AzureKeyCredential,\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 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"],"mappings":";;;;;;;;;AAAA;AAOA;;;AAGG;AACqB,SAAA,YAAY,CAClC,WAA0B,EAC1B,UAAyB,EAAE,EAAA;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EAAE,CAAC;QAChF,IAAI,CAAC,QAAQ,EAAE;AACb,YAAA,MAAM,KAAK,CAAC,yCAAyC,CAAC,CAAC;AACxD,SAAA;QACD,MAAM,MAAM,GAAG,YAAY,CAAC,SAAgB,EAAE,OAAO,CAAC,CAAC;AACvD,QAAA,MAAM,CAAC,QAAQ,CAAC,SAAS,CACvBC,gDAA+B,CAAC;YAC9B,UAAU;AACV,YAAA,MAAM,EAAE,CAAG,EAAA,OAAO,CAAC,OAAO,IAAI,6BAA6B,CAAW,SAAA,CAAA;AACvE,SAAA,CAAC,CACH,CAAC;QACF,MAAM,CAAC,QAAQ,CAAC,SAAS,CAACC,mCAAwB,CAAC,QAAQ,CAAC,CAAC,CAAC;AAC9D,QAAA,OAAO,MAAM,CAAC;AACf,KAAA;AACD,IAAA,OAAO,YAAY,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;AAC3C;;AC9EA;;;;;"}
|
|
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;AAChE,UAAE,CAAA,EAAG,aAAa,CAAA,CAAE,CAAC;AACzB,IAAA,OAAO,GAAG;AACR,QAAA,GAAG,OAAO;AACV,QAAA,gBAAgB,EAAE;YAChB,eAAe;AAChB,SAAA;KACF,CAAC;IAEF,MAAM,MAAM,GAAGA,oBAAS,CACtB,OAAO,EACP,WAAW,EACX,OAAO,CACiB,CAAC;AAE3B,IAAA,OAAO,MAAM,CAAC;AAChB;;AC3CA;AACA;AAOA,MAAM,WAAW,GAA6B;IAC5C,8BAA8B,EAAE,CAAC,KAAK,CAAC;CACxC,CAAC;AAOI,SAAU,YAAY,CAC1B,QAEyC,EAAA;IAEzC,MAAM,WAAW,GAAG,QAAQ,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC;AAC1D,IAAA,MAAM,GAAG,GAAG,IAAI,GAAG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U;AACV,YAAA,MAAM,EAAE,CAAG,EAAA,OAAO,CAAC,OAAO,IAAI,6BAA6B,CAAW,SAAA,CAAA;AACvE,SAAA,CAAC,CACH,CAAC;QACF,MAAM,CAAC,QAAQ,CAAC,SAAS,CAACC,mCAAwB,CAAC,QAAQ,CAAC,CAAC,CAAC;AAC9D,QAAA,OAAO,MAAM,CAAC;AACf,KAAA;AAED,IAAA,IAAIC,wBAAe,CAAC,UAAU,CAAC,EAAE;QAC/B,MAAM,MAAM,GAAG,YAAY,CAAC,SAAgB,EAAE,OAAO,CAAC,CAAC;AACvD,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,CAAC;AACxE,gBAAA,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;aACtB;AACF,SAAA,CAAC,CAAC;AACH,QAAA,OAAO,MAAM,CAAC;AACf,KAAA;AAED,IAAA,OAAO,YAAY,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;AAC3C;;ACpHA;AACA;;;;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Copyright (c) Microsoft Corporation.
|
|
2
2
|
// Licensed under the MIT license.
|
|
3
|
-
import { isTokenCredential } from "@azure/core-auth";
|
|
3
|
+
import { isSASCredential, isTokenCredential, } from "@azure/core-auth";
|
|
4
4
|
import { createMapsClientIdPolicy } from "@azure/maps-common";
|
|
5
5
|
import createClient from "./generated";
|
|
6
6
|
import { bearerTokenAuthenticationPolicy } from "@azure/core-rest-pipeline";
|
|
@@ -24,6 +24,17 @@ export default function MapsGeolocation(credential, clientIdOrOptions = {}, mayb
|
|
|
24
24
|
client.pipeline.addPolicy(createMapsClientIdPolicy(clientId));
|
|
25
25
|
return client;
|
|
26
26
|
}
|
|
27
|
+
if (isSASCredential(credential)) {
|
|
28
|
+
const client = createClient(undefined, options);
|
|
29
|
+
client.pipeline.addPolicy({
|
|
30
|
+
name: "mapsSASCredentialPolicy",
|
|
31
|
+
async sendRequest(request, next) {
|
|
32
|
+
request.headers.set("Authorization", `jwt-sas ${credential.signature}`);
|
|
33
|
+
return next(request);
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
return client;
|
|
37
|
+
}
|
|
27
38
|
return createClient(credential, options);
|
|
28
39
|
}
|
|
29
40
|
//# sourceMappingURL=MapsGeolocation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MapsGeolocation.js","sourceRoot":"","sources":["../../src/MapsGeolocation.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,
|
|
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"]}
|
|
@@ -5,7 +5,7 @@ const responseMap = {
|
|
|
5
5
|
};
|
|
6
6
|
export function isUnexpected(response) {
|
|
7
7
|
const lroOriginal = response.headers["x-ms-original-url"];
|
|
8
|
-
const url = new URL(lroOriginal
|
|
8
|
+
const url = new URL(lroOriginal ?? response.request.url);
|
|
9
9
|
const method = response.request.method;
|
|
10
10
|
let pathDetails = responseMap[`${method} ${url.pathname}`];
|
|
11
11
|
if (!pathDetails) {
|
|
@@ -14,7 +14,6 @@ export function isUnexpected(response) {
|
|
|
14
14
|
return !pathDetails.includes(response.status);
|
|
15
15
|
}
|
|
16
16
|
function geParametrizedPathSuccess(method, path) {
|
|
17
|
-
var _a, _b;
|
|
18
17
|
const pathParts = path.split("/");
|
|
19
18
|
// Iterate the responseMap to find a match
|
|
20
19
|
for (const [key, value] of Object.entries(responseMap)) {
|
|
@@ -33,8 +32,8 @@ function geParametrizedPathSuccess(method, path) {
|
|
|
33
32
|
// track if we have found a match to return the values found.
|
|
34
33
|
let found = true;
|
|
35
34
|
for (let i = 0; i < candidateParts.length; i++) {
|
|
36
|
-
if (
|
|
37
|
-
|
|
35
|
+
if (candidateParts[i]?.startsWith("{") &&
|
|
36
|
+
candidateParts[i]?.endsWith("}")) {
|
|
38
37
|
// If the current part of the candidate is a "template" part
|
|
39
38
|
// it is a match with the actual path part on hand
|
|
40
39
|
// skip as the parameterized part can match anything
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isUnexpected.js","sourceRoot":"","sources":["../../../src/generated/isUnexpected.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAOlC,MAAM,WAAW,GAA6B;IAC5C,8BAA8B,EAAE,CAAC,KAAK,CAAC;CACxC,CAAC;AAOF,MAAM,UAAU,YAAY,CAC1B,QAEyC;IAEzC,MAAM,WAAW,GAAG,QAAQ,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAC1D,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,WAAW,
|
|
1
|
+
{"version":3,"file":"isUnexpected.js","sourceRoot":"","sources":["../../../src/generated/isUnexpected.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAOlC,MAAM,WAAW,GAA6B;IAC5C,8BAA8B,EAAE,CAAC,KAAK,CAAC;CACxC,CAAC;AAOF,MAAM,UAAU,YAAY,CAC1B,QAEyC;IAEzC,MAAM,WAAW,GAAG,QAAQ,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAC1D,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,WAAW,IAAI,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACzD,MAAM,MAAM,GAAG,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC;IACvC,IAAI,WAAW,GAAG,WAAW,CAAC,GAAG,MAAM,IAAI,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC3D,IAAI,CAAC,WAAW,EAAE;QAChB,WAAW,GAAG,yBAAyB,CAAC,MAAM,EA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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"]}
|
|
@@ -6,19 +6,24 @@ import { getClient } from "@azure-rest/core-client";
|
|
|
6
6
|
* @param credentials type: KeyCredential
|
|
7
7
|
*/
|
|
8
8
|
export default function createClient(credentials, options = {}) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
options
|
|
12
|
-
|
|
9
|
+
const baseUrl = options.baseUrl ?? `https://atlas.microsoft.com`;
|
|
10
|
+
options.apiVersion = options.apiVersion ?? "1.0";
|
|
11
|
+
options = {
|
|
12
|
+
...options,
|
|
13
|
+
credentials: {
|
|
13
14
|
apiKeyHeaderName: "subscription-key"
|
|
14
|
-
}
|
|
15
|
+
}
|
|
16
|
+
};
|
|
15
17
|
const userAgentInfo = `azsdk-js-maps-geolocation-rest/1.0.0-beta.1`;
|
|
16
18
|
const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
|
|
17
19
|
? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`
|
|
18
20
|
: `${userAgentInfo}`;
|
|
19
|
-
options =
|
|
21
|
+
options = {
|
|
22
|
+
...options,
|
|
23
|
+
userAgentOptions: {
|
|
20
24
|
userAgentPrefix
|
|
21
|
-
}
|
|
25
|
+
}
|
|
26
|
+
};
|
|
22
27
|
const client = getClient(baseUrl, credentials, options);
|
|
23
28
|
return client;
|
|
24
29
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"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
|
|
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"]}
|
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.
|
|
5
|
+
"version": "1.0.0-beta.3",
|
|
6
6
|
"description": "A generated SDK for MapsGeolocationClient.",
|
|
7
7
|
"keywords": [
|
|
8
8
|
"node",
|
|
@@ -29,20 +29,20 @@
|
|
|
29
29
|
"review/*"
|
|
30
30
|
],
|
|
31
31
|
"engines": {
|
|
32
|
-
"node": ">=
|
|
32
|
+
"node": ">=18.0.0"
|
|
33
33
|
},
|
|
34
34
|
"scripts": {
|
|
35
35
|
"audit": "node ../../../common/scripts/rush-audit.js && rimraf node_modules package-lock.json && npm i --package-lock-only 2>&1 && npm audit",
|
|
36
|
-
"build:browser": "tsc -p . &&
|
|
37
|
-
"build:node": "tsc -p . &&
|
|
36
|
+
"build:browser": "tsc -p . && dev-tool run bundle",
|
|
37
|
+
"build:node": "tsc -p . && dev-tool run bundle --browser-test false",
|
|
38
38
|
"build:samples": "dev-tool samples publish --force",
|
|
39
39
|
"build:test": "tsc -p . && dev-tool run bundle",
|
|
40
40
|
"build:debug": "tsc -p . && dev-tool run bundle && api-extractor run --local",
|
|
41
|
-
"check-format": "prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"",
|
|
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
42
|
"clean": "rimraf dist dist-browser dist-esm test-dist temp types *.tgz *.log",
|
|
43
43
|
"execute:samples": "dev-tool samples run samples-dev",
|
|
44
44
|
"extract-api": "rimraf review && mkdirp ./review && api-extractor run --local",
|
|
45
|
-
"format": "prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"",
|
|
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
47
|
"integration-test:browser": "dev-tool run test:browser",
|
|
48
48
|
"integration-test:node": "dev-tool run test:node-js-input -- --timeout 5000000 'dist-esm/test/**/*.spec.js'",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"autoPublish": false,
|
|
63
63
|
"dependencies": {
|
|
64
64
|
"@azure/core-auth": "^1.3.0",
|
|
65
|
-
"@azure-rest/core-client": "1.0.0
|
|
65
|
+
"@azure-rest/core-client": "^1.0.0",
|
|
66
66
|
"@azure/core-rest-pipeline": "^1.8.0",
|
|
67
67
|
"@azure/maps-common": "1.0.0-beta.2",
|
|
68
68
|
"tslib": "^2.2.0"
|
|
@@ -70,22 +70,20 @@
|
|
|
70
70
|
"devDependencies": {
|
|
71
71
|
"@microsoft/api-extractor": "^7.31.1",
|
|
72
72
|
"autorest": "latest",
|
|
73
|
-
"@types/node": "^
|
|
73
|
+
"@types/node": "^18.0.0",
|
|
74
74
|
"dotenv": "^16.0.0",
|
|
75
75
|
"eslint": "^8.0.0",
|
|
76
76
|
"mkdirp": "^1.0.4",
|
|
77
|
-
"prettier": "^2.5.1",
|
|
78
77
|
"rimraf": "^3.0.0",
|
|
79
78
|
"source-map-support": "^0.5.9",
|
|
80
|
-
"typescript": "~5.
|
|
79
|
+
"typescript": "~5.2.0",
|
|
81
80
|
"@azure/dev-tool": "^1.0.0",
|
|
82
81
|
"@azure/eslint-plugin-azure-sdk": "^3.0.0",
|
|
83
82
|
"@azure-tools/test-credential": "^1.0.0",
|
|
84
|
-
"@azure/identity": "^
|
|
83
|
+
"@azure/identity": "^3.3.0",
|
|
85
84
|
"@azure-tools/test-recorder": "^3.0.0",
|
|
86
|
-
"mocha": "^
|
|
87
|
-
"@types/mocha": "^
|
|
88
|
-
"mocha-junit-reporter": "^1.18.0",
|
|
85
|
+
"mocha": "^10.0.0",
|
|
86
|
+
"@types/mocha": "^10.0.0",
|
|
89
87
|
"cross-env": "^7.0.2",
|
|
90
88
|
"@types/chai": "^4.2.8",
|
|
91
89
|
"chai": "^4.2.0",
|
|
@@ -99,8 +97,10 @@
|
|
|
99
97
|
"karma-source-map-support": "~1.4.0",
|
|
100
98
|
"karma-sourcemap-loader": "^0.3.8",
|
|
101
99
|
"karma": "^6.2.0",
|
|
102
|
-
"
|
|
103
|
-
"@azure/test-utils": "~1.0.0"
|
|
100
|
+
"c8": "^8.0.0",
|
|
101
|
+
"@azure/test-utils": "~1.0.0",
|
|
102
|
+
"ts-node": "^10.0.0",
|
|
103
|
+
"esm": "^3.2.18"
|
|
104
104
|
},
|
|
105
105
|
"homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/maps/maps-geolocation-rest/README.md",
|
|
106
106
|
"//metadata": {
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
```ts
|
|
6
6
|
|
|
7
7
|
import { AzureKeyCredential } from '@azure/core-auth';
|
|
8
|
+
import { AzureSASCredential } from '@azure/core-auth';
|
|
8
9
|
import { Client } from '@azure-rest/core-client';
|
|
9
10
|
import { ClientOptions } from '@azure-rest/core-client';
|
|
10
11
|
import { HttpResponse } from '@azure-rest/core-client';
|
|
@@ -86,6 +87,9 @@ function MapsGeolocation(credential: AzureKeyCredential, options?: ClientOptions
|
|
|
86
87
|
|
|
87
88
|
// @public
|
|
88
89
|
function MapsGeolocation(credential: TokenCredential, mapsAccountClientId: string, options?: ClientOptions): MapsGeolocationClient;
|
|
90
|
+
|
|
91
|
+
// @public
|
|
92
|
+
function MapsGeolocation(credential: AzureSASCredential, options?: ClientOptions): MapsGeolocationClient;
|
|
89
93
|
export default MapsGeolocation;
|
|
90
94
|
|
|
91
95
|
// @public (undocumented)
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AzureKeyCredential } from '@azure/core-auth';
|
|
2
|
+
import { AzureSASCredential } from '@azure/core-auth';
|
|
2
3
|
import { Client } from '@azure-rest/core-client';
|
|
3
4
|
import { ClientOptions } from '@azure-rest/core-client';
|
|
4
5
|
import { HttpResponse } from '@azure-rest/core-client';
|
|
@@ -115,7 +116,7 @@ declare function MapsGeolocation(credential: AzureKeyCredential, options?: Clien
|
|
|
115
116
|
*
|
|
116
117
|
* @example
|
|
117
118
|
* ```ts
|
|
118
|
-
* import MapsGeolocation from "@azure/maps-geo-location";
|
|
119
|
+
* import MapsGeolocation from "@azure-rest/maps-geo-location";
|
|
119
120
|
* import { DefaultAzureCredential } from "@azure/identity";
|
|
120
121
|
*
|
|
121
122
|
* const credential = new DefaultAzureCredential();
|
|
@@ -127,6 +128,23 @@ declare function MapsGeolocation(credential: AzureKeyCredential, options?: Clien
|
|
|
127
128
|
* @param options - Options used to configure the Route Client
|
|
128
129
|
*/
|
|
129
130
|
declare function MapsGeolocation(credential: TokenCredential, mapsAccountClientId: string, options?: ClientOptions): MapsGeolocationClient;
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Creates an instance of MapsGeolocation from an Azure Identity `AzureSASCredential`.
|
|
134
|
+
*
|
|
135
|
+
* @example
|
|
136
|
+
* ```ts
|
|
137
|
+
* import MapsGeolocation from "@azure-rest/maps-geo-location";
|
|
138
|
+
* import { AzureSASCredential } from "@azure/core-auth";
|
|
139
|
+
*
|
|
140
|
+
* const credential = new AzureSASCredential("<SAS Token>");
|
|
141
|
+
* const client = MapsGeolocation(credential);
|
|
142
|
+
* ```
|
|
143
|
+
*
|
|
144
|
+
* @param credential - An AzureSASCredential instance used to authenticate requests to the service
|
|
145
|
+
* @param options - Options used to configure the Geolocation Client
|
|
146
|
+
*/
|
|
147
|
+
declare function MapsGeolocation(credential: AzureSASCredential, options?: ClientOptions): MapsGeolocationClient;
|
|
130
148
|
export default MapsGeolocation;
|
|
131
149
|
|
|
132
150
|
export declare type MapsGeolocationClient = Client & {
|