@azure-rest/maps-search 2.0.0-beta.1 → 2.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/LICENSE +4 -4
- package/README.md +113 -123
- package/dist/browser/MapsSearch.d.ts +53 -0
- package/dist/browser/MapsSearch.d.ts.map +1 -0
- package/{dist-esm/src → dist/browser}/MapsSearch.js +5 -5
- package/dist/browser/MapsSearch.js.map +1 -0
- package/dist/browser/generated/clientDefinitions.d.ts +137 -0
- package/dist/browser/generated/clientDefinitions.d.ts.map +1 -0
- package/dist/browser/generated/clientDefinitions.js +4 -0
- package/dist/browser/generated/clientDefinitions.js.map +1 -0
- package/dist/browser/generated/index.d.ts +10 -0
- package/dist/browser/generated/index.d.ts.map +1 -0
- package/dist/browser/generated/index.js +12 -0
- package/dist/browser/generated/index.js.map +1 -0
- package/dist/browser/generated/isUnexpected.d.ts +7 -0
- package/dist/browser/generated/isUnexpected.d.ts.map +1 -0
- package/{dist-esm/src → dist/browser}/generated/isUnexpected.js +8 -7
- package/dist/browser/generated/isUnexpected.js.map +1 -0
- package/dist/browser/generated/logger.d.ts +2 -0
- package/dist/browser/generated/logger.d.ts.map +1 -0
- package/{dist-esm/src → dist/browser/generated}/logger.js +1 -1
- package/dist/browser/generated/logger.js.map +1 -0
- package/dist/browser/generated/mapsSearchClient.d.ts +15 -0
- package/dist/browser/generated/mapsSearchClient.d.ts.map +1 -0
- package/dist/browser/generated/mapsSearchClient.js +42 -0
- package/dist/browser/generated/mapsSearchClient.js.map +1 -0
- package/dist/browser/generated/models.d.ts +97 -0
- package/dist/browser/generated/models.d.ts.map +1 -0
- package/dist/browser/generated/models.js +4 -0
- package/dist/browser/generated/models.js.map +1 -0
- package/dist/browser/generated/outputModels.d.ts +298 -0
- package/dist/browser/generated/outputModels.d.ts.map +1 -0
- package/dist/browser/generated/outputModels.js +4 -0
- package/{dist-esm/src → dist/browser}/generated/outputModels.js.map +1 -1
- package/dist/browser/generated/parameters.d.ts +135 -0
- package/dist/browser/generated/parameters.d.ts.map +1 -0
- package/dist/browser/generated/parameters.js +4 -0
- package/dist/browser/generated/parameters.js.map +1 -0
- package/dist/browser/generated/responses.d.ts +255 -0
- package/dist/browser/generated/responses.d.ts.map +1 -0
- package/dist/browser/generated/responses.js +4 -0
- package/dist/browser/generated/responses.js.map +1 -0
- package/dist/browser/index.d.ts +4 -0
- package/dist/browser/index.d.ts.map +1 -0
- package/dist/browser/index.js +6 -0
- package/dist/browser/index.js.map +1 -0
- package/dist/browser/logger.d.ts +2 -0
- package/dist/browser/logger.d.ts.map +1 -0
- package/dist/browser/logger.js +5 -0
- package/{dist-esm/src → dist/browser}/logger.js.map +1 -1
- package/dist/browser/package.json +3 -0
- package/dist/commonjs/MapsSearch.d.ts +53 -0
- package/dist/commonjs/MapsSearch.d.ts.map +1 -0
- package/dist/commonjs/MapsSearch.js +44 -0
- package/dist/commonjs/MapsSearch.js.map +1 -0
- package/dist/commonjs/generated/clientDefinitions.d.ts +137 -0
- package/dist/commonjs/generated/clientDefinitions.d.ts.map +1 -0
- package/dist/commonjs/generated/clientDefinitions.js +5 -0
- package/dist/commonjs/generated/clientDefinitions.js.map +1 -0
- package/dist/commonjs/generated/index.d.ts +10 -0
- package/dist/commonjs/generated/index.d.ts.map +1 -0
- package/dist/commonjs/generated/index.js +15 -0
- package/dist/commonjs/generated/index.js.map +1 -0
- package/dist/commonjs/generated/isUnexpected.d.ts +7 -0
- package/dist/commonjs/generated/isUnexpected.d.ts.map +1 -0
- package/dist/commonjs/generated/isUnexpected.js +78 -0
- package/dist/commonjs/generated/isUnexpected.js.map +1 -0
- package/dist/commonjs/generated/logger.d.ts +2 -0
- package/dist/commonjs/generated/logger.d.ts.map +1 -0
- package/dist/commonjs/generated/logger.js +8 -0
- package/dist/commonjs/generated/logger.js.map +1 -0
- package/dist/commonjs/generated/mapsSearchClient.d.ts +15 -0
- package/dist/commonjs/generated/mapsSearchClient.d.ts.map +1 -0
- package/dist/commonjs/generated/mapsSearchClient.js +45 -0
- package/dist/commonjs/generated/mapsSearchClient.js.map +1 -0
- package/dist/commonjs/generated/models.d.ts +97 -0
- package/dist/commonjs/generated/models.d.ts.map +1 -0
- package/dist/commonjs/generated/models.js +5 -0
- package/dist/commonjs/generated/models.js.map +1 -0
- package/dist/commonjs/generated/outputModels.d.ts +298 -0
- package/dist/commonjs/generated/outputModels.d.ts.map +1 -0
- package/dist/commonjs/generated/outputModels.js +5 -0
- package/dist/commonjs/generated/outputModels.js.map +1 -0
- package/dist/commonjs/generated/parameters.d.ts +135 -0
- package/dist/commonjs/generated/parameters.d.ts.map +1 -0
- package/dist/commonjs/generated/parameters.js +5 -0
- package/dist/commonjs/generated/parameters.js.map +1 -0
- package/dist/commonjs/generated/responses.d.ts +255 -0
- package/dist/commonjs/generated/responses.d.ts.map +1 -0
- package/dist/commonjs/generated/responses.js +5 -0
- package/dist/commonjs/generated/responses.js.map +1 -0
- package/dist/commonjs/index.d.ts +4 -0
- package/dist/commonjs/index.d.ts.map +1 -0
- package/dist/commonjs/index.js +9 -0
- package/dist/commonjs/index.js.map +1 -0
- package/dist/commonjs/logger.d.ts +2 -0
- package/dist/commonjs/logger.d.ts.map +1 -0
- package/dist/commonjs/logger.js +8 -0
- package/dist/commonjs/logger.js.map +1 -0
- package/dist/commonjs/package.json +3 -0
- package/dist/commonjs/tsdoc-metadata.json +11 -0
- package/dist/esm/MapsSearch.d.ts +53 -0
- package/dist/esm/MapsSearch.d.ts.map +1 -0
- package/dist/esm/MapsSearch.js +40 -0
- package/dist/esm/MapsSearch.js.map +1 -0
- package/dist/esm/generated/clientDefinitions.d.ts +137 -0
- package/dist/esm/generated/clientDefinitions.d.ts.map +1 -0
- package/dist/esm/generated/clientDefinitions.js +4 -0
- package/dist/esm/generated/clientDefinitions.js.map +1 -0
- package/dist/esm/generated/index.d.ts +10 -0
- package/dist/esm/generated/index.d.ts.map +1 -0
- package/dist/esm/generated/index.js +12 -0
- package/dist/esm/generated/index.js.map +1 -0
- package/dist/esm/generated/isUnexpected.d.ts +7 -0
- package/dist/esm/generated/isUnexpected.d.ts.map +1 -0
- package/dist/esm/generated/isUnexpected.js +75 -0
- package/dist/esm/generated/isUnexpected.js.map +1 -0
- package/dist/esm/generated/logger.d.ts +2 -0
- package/dist/esm/generated/logger.d.ts.map +1 -0
- package/dist/esm/generated/logger.js +5 -0
- package/dist/esm/generated/logger.js.map +1 -0
- package/dist/esm/generated/mapsSearchClient.d.ts +15 -0
- package/dist/esm/generated/mapsSearchClient.d.ts.map +1 -0
- package/dist/esm/generated/mapsSearchClient.js +42 -0
- package/dist/esm/generated/mapsSearchClient.js.map +1 -0
- package/dist/esm/generated/models.d.ts +97 -0
- package/dist/esm/generated/models.d.ts.map +1 -0
- package/dist/esm/generated/models.js +4 -0
- package/dist/esm/generated/models.js.map +1 -0
- package/dist/esm/generated/outputModels.d.ts +298 -0
- package/dist/esm/generated/outputModels.d.ts.map +1 -0
- package/dist/esm/generated/outputModels.js +4 -0
- package/dist/esm/generated/outputModels.js.map +1 -0
- package/dist/esm/generated/parameters.d.ts +135 -0
- package/dist/esm/generated/parameters.d.ts.map +1 -0
- package/dist/esm/generated/parameters.js +4 -0
- package/dist/esm/generated/parameters.js.map +1 -0
- package/dist/esm/generated/responses.d.ts +255 -0
- package/dist/esm/generated/responses.d.ts.map +1 -0
- package/dist/esm/generated/responses.js +4 -0
- package/dist/esm/generated/responses.js.map +1 -0
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +6 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/logger.d.ts +2 -0
- package/dist/esm/logger.d.ts.map +1 -0
- package/dist/esm/logger.js +5 -0
- package/dist/esm/logger.js.map +1 -0
- package/dist/esm/package.json +3 -0
- package/dist/react-native/MapsSearch.d.ts +53 -0
- package/dist/react-native/MapsSearch.d.ts.map +1 -0
- package/dist/react-native/MapsSearch.js +40 -0
- package/dist/react-native/MapsSearch.js.map +1 -0
- package/dist/react-native/generated/clientDefinitions.d.ts +137 -0
- package/dist/react-native/generated/clientDefinitions.d.ts.map +1 -0
- package/dist/react-native/generated/clientDefinitions.js +4 -0
- package/dist/react-native/generated/clientDefinitions.js.map +1 -0
- package/dist/react-native/generated/index.d.ts +10 -0
- package/dist/react-native/generated/index.d.ts.map +1 -0
- package/dist/react-native/generated/index.js +12 -0
- package/dist/react-native/generated/index.js.map +1 -0
- package/dist/react-native/generated/isUnexpected.d.ts +7 -0
- package/dist/react-native/generated/isUnexpected.d.ts.map +1 -0
- package/dist/react-native/generated/isUnexpected.js +75 -0
- package/dist/react-native/generated/isUnexpected.js.map +1 -0
- package/dist/react-native/generated/logger.d.ts +2 -0
- package/dist/react-native/generated/logger.d.ts.map +1 -0
- package/dist/react-native/generated/logger.js +5 -0
- package/dist/react-native/generated/logger.js.map +1 -0
- package/dist/react-native/generated/mapsSearchClient.d.ts +15 -0
- package/dist/react-native/generated/mapsSearchClient.d.ts.map +1 -0
- package/dist/react-native/generated/mapsSearchClient.js +42 -0
- package/dist/react-native/generated/mapsSearchClient.js.map +1 -0
- package/dist/react-native/generated/models.d.ts +97 -0
- package/dist/react-native/generated/models.d.ts.map +1 -0
- package/dist/react-native/generated/models.js +4 -0
- package/dist/react-native/generated/models.js.map +1 -0
- package/dist/react-native/generated/outputModels.d.ts +298 -0
- package/dist/react-native/generated/outputModels.d.ts.map +1 -0
- package/dist/react-native/generated/outputModels.js +4 -0
- package/dist/react-native/generated/outputModels.js.map +1 -0
- package/dist/react-native/generated/parameters.d.ts +135 -0
- package/dist/react-native/generated/parameters.d.ts.map +1 -0
- package/dist/react-native/generated/parameters.js +4 -0
- package/dist/react-native/generated/parameters.js.map +1 -0
- package/dist/react-native/generated/responses.d.ts +255 -0
- package/dist/react-native/generated/responses.d.ts.map +1 -0
- package/dist/react-native/generated/responses.js +4 -0
- package/dist/react-native/generated/responses.js.map +1 -0
- package/dist/react-native/index.d.ts +4 -0
- package/dist/react-native/index.d.ts.map +1 -0
- package/dist/react-native/index.js +6 -0
- package/dist/react-native/index.js.map +1 -0
- package/dist/react-native/logger.d.ts +2 -0
- package/dist/react-native/logger.d.ts.map +1 -0
- package/dist/react-native/logger.js +5 -0
- package/dist/react-native/logger.js.map +1 -0
- package/dist/react-native/package.json +3 -0
- package/package.json +83 -66
- package/dist/index.js +0 -160
- package/dist/index.js.map +0 -1
- package/dist-esm/src/MapsSearch.js.map +0 -1
- package/dist-esm/src/generated/clientDefinitions.js +0 -4
- package/dist-esm/src/generated/clientDefinitions.js.map +0 -1
- package/dist-esm/src/generated/index.js +0 -12
- package/dist-esm/src/generated/index.js.map +0 -1
- package/dist-esm/src/generated/isUnexpected.js.map +0 -1
- package/dist-esm/src/generated/mapsSearchClient.js +0 -32
- package/dist-esm/src/generated/mapsSearchClient.js.map +0 -1
- package/dist-esm/src/generated/models.js +0 -4
- package/dist-esm/src/generated/models.js.map +0 -1
- package/dist-esm/src/generated/outputModels.js +0 -4
- package/dist-esm/src/generated/parameters.js +0 -4
- package/dist-esm/src/generated/parameters.js.map +0 -1
- package/dist-esm/src/generated/pollingHelper.js +0 -55
- package/dist-esm/src/generated/pollingHelper.js.map +0 -1
- package/dist-esm/src/generated/responses.js +0 -4
- package/dist-esm/src/generated/responses.js.map +0 -1
- package/dist-esm/src/index.js +0 -6
- package/dist-esm/src/index.js.map +0 -1
- package/review/maps-search.api.md +0 -544
- package/types/maps-search-rest.d.ts +0 -1117
package/dist/index.js
DELETED
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var coreAuth = require('@azure/core-auth');
|
|
6
|
-
var mapsCommon = require('@azure/maps-common');
|
|
7
|
-
var coreClient = require('@azure-rest/core-client');
|
|
8
|
-
var logger$1 = require('@azure/logger');
|
|
9
|
-
var coreRestPipeline = require('@azure/core-rest-pipeline');
|
|
10
|
-
|
|
11
|
-
// Copyright (c) Microsoft Corporation.
|
|
12
|
-
// Licensed under the MIT license.
|
|
13
|
-
const logger = logger$1.createClientLogger("maps-search");
|
|
14
|
-
|
|
15
|
-
// Copyright (c) Microsoft Corporation.
|
|
16
|
-
// Licensed under the MIT license.
|
|
17
|
-
/**
|
|
18
|
-
* Initialize a new instance of `MapsSearchClient`
|
|
19
|
-
* @param credentials - uniquely identify client credential
|
|
20
|
-
* @param options - the parameter for all optional parameters
|
|
21
|
-
*/
|
|
22
|
-
function createClient(credentials, options = {}) {
|
|
23
|
-
const baseUrl = options.baseUrl ?? `https://atlas.microsoft.com`;
|
|
24
|
-
options.apiVersion = options.apiVersion ?? "2023-06-01";
|
|
25
|
-
const userAgentInfo = `azsdk-js-maps-search-rest/2.0.0-beta.1`;
|
|
26
|
-
const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
|
|
27
|
-
? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`
|
|
28
|
-
: `${userAgentInfo}`;
|
|
29
|
-
options = {
|
|
30
|
-
...options,
|
|
31
|
-
userAgentOptions: {
|
|
32
|
-
userAgentPrefix
|
|
33
|
-
},
|
|
34
|
-
loggingOptions: {
|
|
35
|
-
logger: options.loggingOptions?.logger ?? logger.info
|
|
36
|
-
},
|
|
37
|
-
credentials: {
|
|
38
|
-
apiKeyHeaderName: options.credentials?.apiKeyHeaderName ?? "subscription-key"
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
const client = coreClient.getClient(baseUrl, credentials, options);
|
|
42
|
-
return client;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// Copyright (c) Microsoft Corporation.
|
|
46
|
-
// Licensed under the MIT license.
|
|
47
|
-
const responseMap = {
|
|
48
|
-
"GET /geocode": ["200"],
|
|
49
|
-
"POST /geocode:batch": ["200"],
|
|
50
|
-
"GET /search/polygon": ["200"],
|
|
51
|
-
"GET /reverseGeocode": ["200"],
|
|
52
|
-
"POST /reverseGeocode:batch": ["200"]
|
|
53
|
-
};
|
|
54
|
-
function isUnexpected(response) {
|
|
55
|
-
const lroOriginal = response.headers["x-ms-original-url"];
|
|
56
|
-
const url = new URL(lroOriginal ?? response.request.url);
|
|
57
|
-
const method = response.request.method;
|
|
58
|
-
let pathDetails = responseMap[`${method} ${url.pathname}`];
|
|
59
|
-
if (!pathDetails) {
|
|
60
|
-
pathDetails = getParametrizedPathSuccess(method, url.pathname);
|
|
61
|
-
}
|
|
62
|
-
return !pathDetails.includes(response.status);
|
|
63
|
-
}
|
|
64
|
-
function getParametrizedPathSuccess(method, path) {
|
|
65
|
-
const pathParts = path.split("/");
|
|
66
|
-
// Traverse list to match the longest candidate
|
|
67
|
-
// matchedLen: the length of candidate path
|
|
68
|
-
// matchedValue: the matched status code array
|
|
69
|
-
let matchedLen = -1, matchedValue = [];
|
|
70
|
-
// Iterate the responseMap to find a match
|
|
71
|
-
for (const [key, value] of Object.entries(responseMap)) {
|
|
72
|
-
// Extracting the path from the map key which is in format
|
|
73
|
-
// GET /path/foo
|
|
74
|
-
if (!key.startsWith(method)) {
|
|
75
|
-
continue;
|
|
76
|
-
}
|
|
77
|
-
const candidatePath = getPathFromMapKey(key);
|
|
78
|
-
// Get each part of the url path
|
|
79
|
-
const candidateParts = candidatePath.split("/");
|
|
80
|
-
// track if we have found a match to return the values found.
|
|
81
|
-
let found = true;
|
|
82
|
-
for (let i = candidateParts.length - 1, j = pathParts.length - 1; i >= 1 && j >= 1; i--, j--) {
|
|
83
|
-
if (candidateParts[i]?.startsWith("{") &&
|
|
84
|
-
candidateParts[i]?.indexOf("}") !== -1) {
|
|
85
|
-
const start = candidateParts[i].indexOf("}") + 1, end = candidateParts[i]?.length;
|
|
86
|
-
// If the current part of the candidate is a "template" part
|
|
87
|
-
// Try to use the suffix of pattern to match the path
|
|
88
|
-
// {guid} ==> $
|
|
89
|
-
// {guid}:export ==> :export$
|
|
90
|
-
const isMatched = new RegExp(`${candidateParts[i]?.slice(start, end)}`).test(pathParts[j] || "");
|
|
91
|
-
if (!isMatched) {
|
|
92
|
-
found = false;
|
|
93
|
-
break;
|
|
94
|
-
}
|
|
95
|
-
continue;
|
|
96
|
-
}
|
|
97
|
-
// If the candidate part is not a template and
|
|
98
|
-
// the parts don't match mark the candidate as not found
|
|
99
|
-
// to move on with the next candidate path.
|
|
100
|
-
if (candidateParts[i] !== pathParts[j]) {
|
|
101
|
-
found = false;
|
|
102
|
-
break;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
// We finished evaluating the current candidate parts
|
|
106
|
-
// Update the matched value if and only if we found the longer pattern
|
|
107
|
-
if (found && candidatePath.length > matchedLen) {
|
|
108
|
-
matchedLen = candidatePath.length;
|
|
109
|
-
matchedValue = value;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
return matchedValue;
|
|
113
|
-
}
|
|
114
|
-
function getPathFromMapKey(mapKey) {
|
|
115
|
-
const pathStart = mapKey.indexOf("/");
|
|
116
|
-
return mapKey.slice(pathStart);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
// Copyright (c) Microsoft Corporation.
|
|
120
|
-
// Licensed under the MIT license.
|
|
121
|
-
function MapsSearch(credential, clientIdOrOptions = {}, maybeOptions = {}) {
|
|
122
|
-
const options = typeof clientIdOrOptions === "string" ? maybeOptions : clientIdOrOptions;
|
|
123
|
-
/**
|
|
124
|
-
* maps service requires a header "ms-x-client-id", which is different from the standard AAD.
|
|
125
|
-
* So we need to do our own implementation.
|
|
126
|
-
* This customized authentication is following by this guide: https://github.com/Azure/azure-sdk-for-js/blob/main/documentation/RLC-customization.md#custom-authentication
|
|
127
|
-
*/
|
|
128
|
-
if (coreAuth.isTokenCredential(credential)) {
|
|
129
|
-
const clientId = typeof clientIdOrOptions === "string" ? clientIdOrOptions : "";
|
|
130
|
-
if (!clientId) {
|
|
131
|
-
throw Error("Client id is needed for TokenCredential");
|
|
132
|
-
}
|
|
133
|
-
const client = createClient(undefined, options);
|
|
134
|
-
client.pipeline.addPolicy(coreRestPipeline.bearerTokenAuthenticationPolicy({
|
|
135
|
-
credential,
|
|
136
|
-
scopes: `${options.baseUrl || "https://atlas.microsoft.com"}/.default`,
|
|
137
|
-
}));
|
|
138
|
-
client.pipeline.addPolicy(mapsCommon.createMapsClientIdPolicy(clientId));
|
|
139
|
-
return client;
|
|
140
|
-
}
|
|
141
|
-
if (coreAuth.isSASCredential(credential)) {
|
|
142
|
-
const client = createClient(undefined, options);
|
|
143
|
-
client.pipeline.addPolicy({
|
|
144
|
-
name: "mapsSASCredentialPolicy",
|
|
145
|
-
async sendRequest(request, next) {
|
|
146
|
-
request.headers.set("Authorization", `jwt-sas ${credential.signature}`);
|
|
147
|
-
return next(request);
|
|
148
|
-
},
|
|
149
|
-
});
|
|
150
|
-
return client;
|
|
151
|
-
}
|
|
152
|
-
return createClient(credential, options);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
// Copyright (c) Microsoft Corporation.
|
|
156
|
-
// Licensed under the MIT license.
|
|
157
|
-
|
|
158
|
-
exports.default = MapsSearch;
|
|
159
|
-
exports.isUnexpected = isUnexpected;
|
|
160
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/logger.ts","../src/generated/mapsSearchClient.ts","../src/generated/isUnexpected.ts","../src/MapsSearch.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-search\");\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 { MapsSearchClient } from \"./clientDefinitions\";\n\n/**\n * Initialize a new instance of `MapsSearchClient`\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 options: ClientOptions = {}\n): MapsSearchClient {\n const baseUrl = options.baseUrl ?? `https://atlas.microsoft.com`;\n options.apiVersion = options.apiVersion ?? \"2023-06-01\";\n const userAgentInfo = `azsdk-js-maps-search-rest/2.0.0-beta.1`;\n const userAgentPrefix =\n options.userAgentOptions && options.userAgentOptions.userAgentPrefix\n ? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`\n : `${userAgentInfo}`;\n options = {\n ...options,\n userAgentOptions: {\n userAgentPrefix\n },\n loggingOptions: {\n logger: options.loggingOptions?.logger ?? logger.info\n },\n credentials: {\n apiKeyHeaderName:\n options.credentials?.apiKeyHeaderName ?? \"subscription-key\"\n }\n };\n\n const client = getClient(baseUrl, credentials, options) as MapsSearchClient;\n\n return client;\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n SearchGetGeocoding200Response,\n SearchGetGeocodingDefaultResponse,\n SearchGetGeocodingBatch200Response,\n SearchGetGeocodingBatchDefaultResponse,\n SearchGetPolygon200Response,\n SearchGetPolygonDefaultResponse,\n SearchGetReverseGeocoding200Response,\n SearchGetReverseGeocodingDefaultResponse,\n SearchGetReverseGeocodingBatch200Response,\n SearchGetReverseGeocodingBatchDefaultResponse\n} from \"./responses\";\n\nconst responseMap: Record<string, string[]> = {\n \"GET /geocode\": [\"200\"],\n \"POST /geocode:batch\": [\"200\"],\n \"GET /search/polygon\": [\"200\"],\n \"GET /reverseGeocode\": [\"200\"],\n \"POST /reverseGeocode:batch\": [\"200\"]\n};\n\nexport function isUnexpected(\n response: SearchGetGeocoding200Response | SearchGetGeocodingDefaultResponse\n): response is SearchGetGeocodingDefaultResponse;\nexport function isUnexpected(\n response:\n | SearchGetGeocodingBatch200Response\n | SearchGetGeocodingBatchDefaultResponse\n): response is SearchGetGeocodingBatchDefaultResponse;\nexport function isUnexpected(\n response: SearchGetPolygon200Response | SearchGetPolygonDefaultResponse\n): response is SearchGetPolygonDefaultResponse;\nexport function isUnexpected(\n response:\n | SearchGetReverseGeocoding200Response\n | SearchGetReverseGeocodingDefaultResponse\n): response is SearchGetReverseGeocodingDefaultResponse;\nexport function isUnexpected(\n response:\n | SearchGetReverseGeocodingBatch200Response\n | SearchGetReverseGeocodingBatchDefaultResponse\n): response is SearchGetReverseGeocodingBatchDefaultResponse;\nexport function isUnexpected(\n response:\n | SearchGetGeocoding200Response\n | SearchGetGeocodingDefaultResponse\n | SearchGetGeocodingBatch200Response\n | SearchGetGeocodingBatchDefaultResponse\n | SearchGetPolygon200Response\n | SearchGetPolygonDefaultResponse\n | SearchGetReverseGeocoding200Response\n | SearchGetReverseGeocodingDefaultResponse\n | SearchGetReverseGeocodingBatch200Response\n | SearchGetReverseGeocodingBatchDefaultResponse\n): response is\n | SearchGetGeocodingDefaultResponse\n | SearchGetGeocodingBatchDefaultResponse\n | SearchGetPolygonDefaultResponse\n | SearchGetReverseGeocodingDefaultResponse\n | SearchGetReverseGeocodingBatchDefaultResponse {\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 { 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 { MapsSearchClient } from \"./generated\";\nimport createClient from \"./generated\";\nimport { bearerTokenAuthenticationPolicy } from \"@azure/core-rest-pipeline\";\n\n/**\n * Creates an instance of MapsSearchClient from a subscription key.\n *\n * @example\n * ```ts\n * import MapsSearch from \"@azure-rest/maps-search\";\n * import { AzureKeyCredential } from \"@azure/core-auth\";\n *\n * const credential = new AzureKeyCredential(\"<subscription-key>\");\n * const client = MapsSearch(credential);\n *```\n *\n * @param credential - An AzureKeyCredential instance used to authenticate requests to the service\n * @param options - Options used to configure the Search Client\n */\nexport default function MapsSearch(\n credential: AzureKeyCredential,\n options?: ClientOptions,\n): MapsSearchClient;\n/**\n * Creates an instance of MapsSearch from an Azure Identity `TokenCredential`.\n *\n * @example\n * ```ts\n * import MapsSearch from \"@azure-rest/maps-search\";\n * import { DefaultAzureCredential } from \"@azure/identity\";\n *\n * const credential = new DefaultAzureCredential();\n * const client = MapsSearch(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 Search Client\n */\nexport default function MapsSearch(\n credential: TokenCredential,\n mapsAccountClientId: string,\n options?: ClientOptions,\n): MapsSearchClient;\n/**\n * Creates an instance of MapsSearch from an Azure Identity `AzureSASCredential`.\n *\n * @example\n * ```ts\n * import MapsSearch from \"@azure-rest/maps-search\";\n * import { AzureSASCredential } from \"@azure/core-auth\";\n *\n * const credential = new AzureSASCredential(\"<SAS Token>\");\n * const client = MapsSearch(credential);\n * ```\n *\n * @param credential - An AzureSASCredential instance used to authenticate requests to the service\n * @param options - Options used to configure the Search Client\n */\nexport default function MapsSearch(\n credential: AzureSASCredential,\n options?: ClientOptions,\n): MapsSearchClient;\nexport default function MapsSearch(\n credential: TokenCredential | AzureKeyCredential | AzureSASCredential,\n clientIdOrOptions: string | ClientOptions = {},\n maybeOptions: ClientOptions = {},\n): MapsSearchClient {\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.\nimport MapsSearch from \"./MapsSearch\";\n\nexport * from \"./generated\";\nexport default MapsSearch;\n"],"names":["createClientLogger","getClient","isTokenCredential","bearerTokenAuthenticationPolicy","createMapsClientIdPolicy","isSASCredential"],"mappings":";;;;;;;;;;AAAA;AACA;AAGO,MAAM,MAAM,GAAGA,2BAAkB,CAAC,aAAa,CAAC;;ACJvD;AACA;AAOA;;;;AAIG;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,YAAY,CAAC;IACxD,MAAM,aAAa,GAAG,CAAA,sCAAA,CAAwC,CAAC;IAC/D,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;AACD,QAAA,cAAc,EAAE;YACd,MAAM,EAAE,OAAO,CAAC,cAAc,EAAE,MAAM,IAAI,MAAM,CAAC,IAAI;AACtD,SAAA;AACD,QAAA,WAAW,EAAE;AACX,YAAA,gBAA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;;;;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 { MapsSearchClient } from \"./generated\";\nimport createClient from \"./generated\";\nimport { bearerTokenAuthenticationPolicy } from \"@azure/core-rest-pipeline\";\n\n/**\n * Creates an instance of MapsSearchClient from a subscription key.\n *\n * @example\n * ```ts\n * import MapsSearch from \"@azure-rest/maps-search\";\n * import { AzureKeyCredential } from \"@azure/core-auth\";\n *\n * const credential = new AzureKeyCredential(\"<subscription-key>\");\n * const client = MapsSearch(credential);\n *```\n *\n * @param credential - An AzureKeyCredential instance used to authenticate requests to the service\n * @param options - Options used to configure the Search Client\n */\nexport default function MapsSearch(\n credential: AzureKeyCredential,\n options?: ClientOptions,\n): MapsSearchClient;\n/**\n * Creates an instance of MapsSearch from an Azure Identity `TokenCredential`.\n *\n * @example\n * ```ts\n * import MapsSearch from \"@azure-rest/maps-search\";\n * import { DefaultAzureCredential } from \"@azure/identity\";\n *\n * const credential = new DefaultAzureCredential();\n * const client = MapsSearch(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 Search Client\n */\nexport default function MapsSearch(\n credential: TokenCredential,\n mapsAccountClientId: string,\n options?: ClientOptions,\n): MapsSearchClient;\n/**\n * Creates an instance of MapsSearch from an Azure Identity `AzureSASCredential`.\n *\n * @example\n * ```ts\n * import MapsSearch from \"@azure-rest/maps-search\";\n * import { AzureSASCredential } from \"@azure/core-auth\";\n *\n * const credential = new AzureSASCredential(\"<SAS Token>\");\n * const client = MapsSearch(credential);\n * ```\n *\n * @param credential - An AzureSASCredential instance used to authenticate requests to the service\n * @param options - Options used to configure the Search Client\n */\nexport default function MapsSearch(\n credential: AzureSASCredential,\n options?: ClientOptions,\n): MapsSearchClient;\nexport default function MapsSearch(\n credential: TokenCredential | AzureKeyCredential | AzureSASCredential,\n clientIdOrOptions: string | ClientOptions = {},\n maybeOptions: ClientOptions = {},\n): MapsSearchClient {\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 +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 {\n SearchGetGeocodingParameters,\n SearchGetGeocodingBatchParameters,\n SearchGetPolygonParameters,\n SearchGetReverseGeocodingParameters,\n SearchGetReverseGeocodingBatchParameters\n} from \"./parameters\";\nimport {\n SearchGetGeocoding200Response,\n SearchGetGeocodingDefaultResponse,\n SearchGetGeocodingBatch200Response,\n SearchGetGeocodingBatchDefaultResponse,\n SearchGetPolygon200Response,\n SearchGetPolygonDefaultResponse,\n SearchGetReverseGeocoding200Response,\n SearchGetReverseGeocodingDefaultResponse,\n SearchGetReverseGeocodingBatch200Response,\n SearchGetReverseGeocodingBatchDefaultResponse\n} from \"./responses\";\nimport { Client, StreamableMethod } from \"@azure-rest/core-client\";\n\nexport interface GetGeocoding {\n /**\n * **Geocoding**\n *\n * **Applies to:** see pricing [tiers](https://aka.ms/AzureMapsPricingTier).\n *\n * In many cases, the complete search service might be too much, for instance if you are only interested in traditional geocoding. Search can also be accessed for address look up exclusively. The geocoding is performed by hitting the geocoding endpoint with just the address or partial address in question. The geocoding search index will be queried for everything above the street level data. No Point of Interest (POIs) will be returned. Note that the geocoder is very tolerant of typos and incomplete addresses. It will also handle everything from exact street addresses or street or intersections as well as higher level geographies such as city centers, counties, states etc.\n */\n get(\n options?: SearchGetGeocodingParameters\n ): StreamableMethod<\n SearchGetGeocoding200Response | SearchGetGeocodingDefaultResponse\n >;\n}\n\nexport interface GetGeocodingBatch {\n /**\n * **Geocoding Batch API**\n *\n *\n * **Applies to**: see pricing [tiers](https://aka.ms/AzureMapsPricingTier).\n *\n *\n *\n * The Geocoding Batch API sends batches of queries to [Geocoding API](https://docs.microsoft.com/rest/api/maps/search-v2/get-geocoding) using just a single API call. The API allows caller to batch up to **100** queries.\n *\n * ### Submit Synchronous Batch Request\n * The Synchronous API is recommended for lightweight batch requests. When the service receives a request, it will respond as soon as the batch items are calculated and there will be no possibility to retrieve the results later. The Synchronous API will return a timeout error (a 408 response) if the request takes longer than 60 seconds. The number of batch items is limited to **100** for this API.\n * ```\n * POST https://atlas.microsoft.com/geocode:batch?api-version=2023-06-01\n * ```\n * ### POST Body for Batch Request\n * To send the _geocoding_ queries you will use a `POST` request where the request body will contain the `batchItems` array in `json` format and the `Content-Type` header will be set to `application/json`. Here's a sample request body containing 2 _geocoding_ queries:\n *\n *\n * ```\n * {\n * \"batchItems\": [\n * {\n * \"addressLine\": \"One, Microsoft Way, Redmond, WA 98052\",\n * \"top\": 2\n * },\n * {\n * \"addressLine\": \"Pike Pl\",\n * \"adminDistrict\": \"WA\",\n * \"locality\": \"Seattle\",\n * \"top\": 3\n * }\n * ]\n * }\n * ```\n *\n * A _geocoding_ batchItem object can accept any of the supported _geocoding_ [URI parameters](https://docs.microsoft.com/rest/api/maps/search-v2/get-geocoding#uri-parameters).\n *\n *\n * The batch should contain at least **1** query.\n *\n *\n * ### Batch Response Model\n * The batch response contains a `summary` component that indicates the `totalRequests` that were part of the original batch request and `successfulRequests` i.e. queries which were executed successfully. The batch response also includes a `batchItems` array which contains a response for each and every query in the batch request. The `batchItems` will contain the results in the exact same order the original queries were sent in the batch request. Each item is of one of the following types:\n *\n * - [`GeocodingResponse`](https://docs.microsoft.com/rest/api/maps/search-v2/get-geocoding#geocodingresponse) - If the query completed successfully.\n *\n * - `Error` - If the query failed. The response will contain a `code` and a `message` in this case.\n *\n *\n *\n */\n post(\n options: SearchGetGeocodingBatchParameters\n ): StreamableMethod<\n SearchGetGeocodingBatch200Response | SearchGetGeocodingBatchDefaultResponse\n >;\n}\n\nexport interface GetPolygon {\n /**\n * **Get Polygon**\n *\n * **Applies to:** see pricing [tiers](https://aka.ms/AzureMapsPricingTier).\n *\n * Supplies polygon data of a geographical area outline such as a city or a country region.\n */\n get(\n options: SearchGetPolygonParameters\n ): StreamableMethod<\n SearchGetPolygon200Response | SearchGetPolygonDefaultResponse\n >;\n}\n\nexport interface GetReverseGeocoding {\n /**\n * **Reverse Geocoding**\n *\n * **Applies to:** see pricing [tiers](https://aka.ms/AzureMapsPricingTier).\n *\n * Translate a coordinate (example: 37.786505, -122.3862) into a human understandable street address. Most often this is needed in tracking applications where you receive a GPS feed from the device or asset and wish to know what address where the coordinate is located. This endpoint will return address information for a given coordinate.\n */\n get(\n options: SearchGetReverseGeocodingParameters\n ): StreamableMethod<\n | SearchGetReverseGeocoding200Response\n | SearchGetReverseGeocodingDefaultResponse\n >;\n}\n\nexport interface GetReverseGeocodingBatch {\n /**\n * **Reverse Geocoding Batch API**\n *\n *\n * **Applies to**: see pricing [tiers](https://aka.ms/AzureMapsPricingTier).\n *\n *\n *\n * The Reverse Geocoding Batch API sends batches of queries to [Reverse Geocoding API](https://docs.microsoft.com/rest/api/maps/search-v2/get-reverse-geocoding) using just a single API call. The API allows caller to batch up to **100** queries.\n *\n * ### Submit Synchronous Batch Request\n * The Synchronous API is recommended for lightweight batch requests. When the service receives a request, it will respond as soon as the batch items are calculated and there will be no possibility to retrieve the results later. The Synchronous API will return a timeout error (a 408 response) if the request takes longer than 60 seconds. The number of batch items is limited to **100** for this API.\n * ```\n * POST https://atlas.microsoft.com/reverseGeocode:batch?api-version=2023-06-01\n * ```\n * ### POST Body for Batch Request\n * To send the _reverse geocoding_ queries you will use a `POST` request where the request body will contain the `batchItems` array in `json` format and the `Content-Type` header will be set to `application/json`. Here's a sample request body containing 2 _reverse geocoding_ queries:\n *\n *\n * ```\n * {\n * \"batchItems\": [\n * {\n * \"coordinates\": [-122.128275, 47.639429],\n * \"resultTypes\": [\"Address\", \"PopulatedPlace\"]\n * },\n * {\n * \"coordinates\": [-122.341979399674, 47.6095253501216]\n * }\n * ]\n * }\n * ```\n *\n * A _reverse geocoding_ batchItem object can accept any of the supported _reverse geocoding_ [URI parameters](https://docs.microsoft.com/rest/api/maps/search-v2/get-reverse-geocoding#uri-parameters).\n *\n *\n * The batch should contain at least **1** query.\n *\n *\n * ### Batch Response Model\n * The batch response contains a `summary` component that indicates the `totalRequests` that were part of the original batch request and `successfulRequests` i.e. queries which were executed successfully. The batch response also includes a `batchItems` array which contains a response for each and every query in the batch request. The `batchItems` will contain the results in the exact same order the original queries were sent in the batch request. Each item is of one of the following types:\n *\n * - [`GeocodingResponse`](https://docs.microsoft.com/rest/api/maps/search-v2/get-reverse-geocoding#geocodingresponse) - If the query completed successfully.\n *\n * - `Error` - If the query failed. The response will contain a `code` and a `message` in this case.\n *\n *\n *\n */\n post(\n options: SearchGetReverseGeocodingBatchParameters\n ): StreamableMethod<\n | SearchGetReverseGeocodingBatch200Response\n | SearchGetReverseGeocodingBatchDefaultResponse\n >;\n}\n\nexport interface Routes {\n /** Resource for '/geocode' has methods for the following verbs: get */\n (path: \"/geocode\"): GetGeocoding;\n /** Resource for '/geocode:batch' has methods for the following verbs: post */\n (path: \"/geocode:batch\"): GetGeocodingBatch;\n /** Resource for '/search/polygon' has methods for the following verbs: get */\n (path: \"/search/polygon\"): GetPolygon;\n /** Resource for '/reverseGeocode' has methods for the following verbs: get */\n (path: \"/reverseGeocode\"): GetReverseGeocoding;\n /** Resource for '/reverseGeocode:batch' has methods for the following verbs: post */\n (path: \"/reverseGeocode:batch\"): GetReverseGeocodingBatch;\n}\n\nexport type MapsSearchClient = Client & {\n path: Routes;\n};\n"]}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Microsoft Corporation.
|
|
2
|
-
// Licensed under the MIT license.
|
|
3
|
-
import MapsSearchClient from "./mapsSearchClient";
|
|
4
|
-
export * from "./mapsSearchClient";
|
|
5
|
-
export * from "./parameters";
|
|
6
|
-
export * from "./responses";
|
|
7
|
-
export * from "./clientDefinitions";
|
|
8
|
-
export * from "./isUnexpected";
|
|
9
|
-
export * from "./models";
|
|
10
|
-
export * from "./outputModels";
|
|
11
|
-
export default MapsSearchClient;
|
|
12
|
-
//# 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,gBAAgB,MAAM,oBAAoB,CAAC;AAElD,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAE/B,eAAe,gBAAgB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport MapsSearchClient from \"./mapsSearchClient\";\n\nexport * from \"./mapsSearchClient\";\nexport * from \"./parameters\";\nexport * from \"./responses\";\nexport * from \"./clientDefinitions\";\nexport * from \"./isUnexpected\";\nexport * from \"./models\";\nexport * from \"./outputModels\";\n\nexport default MapsSearchClient;\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"isUnexpected.js","sourceRoot":"","sources":["../../../src/generated/isUnexpected.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAelC,MAAM,WAAW,GAA6B;IAC5C,cAAc,EAAE,CAAC,KAAK,CAAC;IACvB,qBAAqB,EAAE,CAAC,KAAK,CAAC;IAC9B,qBAAqB,EAAE,CAAC,KAAK,CAAC;IAC9B,qBAAqB,EAAE,CAAC,KAAK,CAAC;IAC9B,4BAA4B,EAAE,CAAC,KAAK,CAAC;CACtC,CAAC;AAuBF,MAAM,UAAU,YAAY,CAC1B,QAUiD;IAOjD,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,0BAA0B,CAAC,MAAM,EAAE,GAAG,CAAC,QAAQ,CAAC,CAAC;KAChE;IACD,OAAO,CAAC,WAAW,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AAChD,CAAC;AAED,SAAS,0BAA0B,CAAC,MAAc,EAAE,IAAY;IAC9D,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAElC,+CAA+C;IAC/C,2CAA2C;IAC3C,8CAA8C;IAC9C,IAAI,UAAU,G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C,SAAS,EAAE;oBACd,KAAK,GAAG,KAAK,CAAC;oBACd,MAAM;iBACP;gBACD,SAAS;aACV;YAED,8CAA8C;YAC9C,wDAAwD;YACxD,2CAA2C;YAC3C,IAAI,cAAc,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE;gBACtC,KAAK,GAAG,KAAK,CAAC;gBACd,MAAM;aACP;SACF;QAED,qDAAqD;QACrD,sEAAsE;QACtE,IAAI,KAAK,IAAI,aAAa,CAAC,MAAM,GAAG,UAAU,EAAE;YAC9C,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC;YAClC,YAAY,GAAG,KAAK,CAAC;SACtB;KACF;IAED,OAAO,YAAY,CAAC;AACtB,CAAC;AAED,SAAS,iBAAiB,CAAC,MAAc;IACvC,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACtC,OAAO,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;AACjC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n SearchGetGeocoding200Response,\n SearchGetGeocodingDefaultResponse,\n SearchGetGeocodingBatch200Response,\n SearchGetGeocodingBatchDefaultResponse,\n SearchGetPolygon200Response,\n SearchGetPolygonDefaultResponse,\n SearchGetReverseGeocoding200Response,\n SearchGetReverseGeocodingDefaultResponse,\n SearchGetReverseGeocodingBatch200Response,\n SearchGetReverseGeocodingBatchDefaultResponse\n} from \"./responses\";\n\nconst responseMap: Record<string, string[]> = {\n \"GET /geocode\": [\"200\"],\n \"POST /geocode:batch\": [\"200\"],\n \"GET /search/polygon\": [\"200\"],\n \"GET /reverseGeocode\": [\"200\"],\n \"POST /reverseGeocode:batch\": [\"200\"]\n};\n\nexport function isUnexpected(\n response: SearchGetGeocoding200Response | SearchGetGeocodingDefaultResponse\n): response is SearchGetGeocodingDefaultResponse;\nexport function isUnexpected(\n response:\n | SearchGetGeocodingBatch200Response\n | SearchGetGeocodingBatchDefaultResponse\n): response is SearchGetGeocodingBatchDefaultResponse;\nexport function isUnexpected(\n response: SearchGetPolygon200Response | SearchGetPolygonDefaultResponse\n): response is SearchGetPolygonDefaultResponse;\nexport function isUnexpected(\n response:\n | SearchGetReverseGeocoding200Response\n | SearchGetReverseGeocodingDefaultResponse\n): response is SearchGetReverseGeocodingDefaultResponse;\nexport function isUnexpected(\n response:\n | SearchGetReverseGeocodingBatch200Response\n | SearchGetReverseGeocodingBatchDefaultResponse\n): response is SearchGetReverseGeocodingBatchDefaultResponse;\nexport function isUnexpected(\n response:\n | SearchGetGeocoding200Response\n | SearchGetGeocodingDefaultResponse\n | SearchGetGeocodingBatch200Response\n | SearchGetGeocodingBatchDefaultResponse\n | SearchGetPolygon200Response\n | SearchGetPolygonDefaultResponse\n | SearchGetReverseGeocoding200Response\n | SearchGetReverseGeocodingDefaultResponse\n | SearchGetReverseGeocodingBatch200Response\n | SearchGetReverseGeocodingBatchDefaultResponse\n): response is\n | SearchGetGeocodingDefaultResponse\n | SearchGetGeocodingBatchDefaultResponse\n | SearchGetPolygonDefaultResponse\n | SearchGetReverseGeocodingDefaultResponse\n | SearchGetReverseGeocodingBatchDefaultResponse {\n const lroOriginal = response.headers[\"x-ms-original-url\"];\n const url = new URL(lroOriginal ?? response.request.url);\n const method = response.request.method;\n let pathDetails = responseMap[`${method} ${url.pathname}`];\n if (!pathDetails) {\n pathDetails = getParametrizedPathSuccess(method, url.pathname);\n }\n return !pathDetails.includes(response.status);\n}\n\nfunction getParametrizedPathSuccess(method: string, path: string): string[] {\n const pathParts = path.split(\"/\");\n\n // Traverse list to match the longest candidate\n // matchedLen: the length of candidate path\n // matchedValue: the matched status code array\n let matchedLen = -1,\n matchedValue: string[] = [];\n\n // Iterate the responseMap to find a match\n for (const [key, value] of Object.entries(responseMap)) {\n // Extracting the path from the map key which is in format\n // GET /path/foo\n if (!key.startsWith(method)) {\n continue;\n }\n const candidatePath = getPathFromMapKey(key);\n // Get each part of the url path\n const candidateParts = candidatePath.split(\"/\");\n\n // track if we have found a match to return the values found.\n let found = true;\n for (\n let i = candidateParts.length - 1, j = pathParts.length - 1;\n i >= 1 && j >= 1;\n i--, j--\n ) {\n if (\n candidateParts[i]?.startsWith(\"{\") &&\n candidateParts[i]?.indexOf(\"}\") !== -1\n ) {\n const start = candidateParts[i]!.indexOf(\"}\") + 1,\n end = candidateParts[i]?.length;\n // If the current part of the candidate is a \"template\" part\n // Try to use the suffix of pattern to match the path\n // {guid} ==> $\n // {guid}:export ==> :export$\n const isMatched = new RegExp(\n `${candidateParts[i]?.slice(start, end)}`\n ).test(pathParts[j] || \"\");\n\n if (!isMatched) {\n found = false;\n break;\n }\n continue;\n }\n\n // If the candidate part is not a template and\n // the parts don't match mark the candidate as not found\n // to move on with the next candidate path.\n if (candidateParts[i] !== pathParts[j]) {\n found = false;\n break;\n }\n }\n\n // We finished evaluating the current candidate parts\n // Update the matched value if and only if we found the longer pattern\n if (found && candidatePath.length > matchedLen) {\n matchedLen = candidatePath.length;\n matchedValue = value;\n }\n }\n\n return matchedValue;\n}\n\nfunction getPathFromMapKey(mapKey: string): string {\n const pathStart = mapKey.indexOf(\"/\");\n return mapKey.slice(pathStart);\n}\n"]}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Microsoft Corporation.
|
|
2
|
-
// Licensed under the MIT license.
|
|
3
|
-
import { getClient } from "@azure-rest/core-client";
|
|
4
|
-
import { logger } from "../logger";
|
|
5
|
-
/**
|
|
6
|
-
* Initialize a new instance of `MapsSearchClient`
|
|
7
|
-
* @param credentials - uniquely identify client credential
|
|
8
|
-
* @param options - the parameter for all optional parameters
|
|
9
|
-
*/
|
|
10
|
-
export default function createClient(credentials, options = {}) {
|
|
11
|
-
const baseUrl = options.baseUrl ?? `https://atlas.microsoft.com`;
|
|
12
|
-
options.apiVersion = options.apiVersion ?? "2023-06-01";
|
|
13
|
-
const userAgentInfo = `azsdk-js-maps-search-rest/2.0.0-beta.1`;
|
|
14
|
-
const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
|
|
15
|
-
? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`
|
|
16
|
-
: `${userAgentInfo}`;
|
|
17
|
-
options = {
|
|
18
|
-
...options,
|
|
19
|
-
userAgentOptions: {
|
|
20
|
-
userAgentPrefix
|
|
21
|
-
},
|
|
22
|
-
loggingOptions: {
|
|
23
|
-
logger: options.loggingOptions?.logger ?? logger.info
|
|
24
|
-
},
|
|
25
|
-
credentials: {
|
|
26
|
-
apiKeyHeaderName: options.credentials?.apiKeyHeaderName ?? "subscription-key"
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
const client = getClient(baseUrl, credentials, options);
|
|
30
|
-
return client;
|
|
31
|
-
}
|
|
32
|
-
//# sourceMappingURL=mapsSearchClient.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mapsSearchClient.js","sourceRoot":"","sources":["../../../src/generated/mapsSearchClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,SAAS,EAAiB,MAAM,yBAAyB,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAInC;;;;GAIG;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,YAAY,CAAC;IACxD,MAAM,aAAa,GAAG,wCAAwC,CAAC;IAC/D,MAAM,eAAe,GACnB,OAAO,CAAC,gBAAgB,IAAI,OAAO,CAAC,gBAAgB,CAAC,eAAe;QAClE,CAAC,CAAC,GAAG,OAAO,CAAC,gBAAgB,CAAC,eAAe,IAAI,aAAa,EAAE;QAChE,CAAC,CAAC,GAAG,aAAa,EAAE,CAAC;IACzB,OAAO,GAAG;QACR,GAAG,OAAO;QACV,gBAAgB,EAAE;YAChB,eAAe;SAChB;QACD,cAAc,EAAE;YACd,MAAM,EAAE,OAAO,CAAC,cAAc,EAAE,MAAM,IAAI,MAAM,CAAC,IAAI;SACtD;QACD,WAAW,EAAE;YACX,gBAAgB,EACd,OAAO,CAAC,WAAW,EAAE,gBAAgB,IAAI,kBAAkB;SAC9D;KACF,CAAC;IAEF,MAAM,MAAM,GAAG,SAAS,CAAC,OAAO,EAAE,WAAW,EAAE,OAAO,CAAqB,CAAC;IAE5E,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { getClient, ClientOptions } from \"@azure-rest/core-client\";\nimport { logger } from \"../logger\";\nimport { KeyCredential } from \"@azure/core-auth\";\nimport { MapsSearchClient } from \"./clientDefinitions\";\n\n/**\n * Initialize a new instance of `MapsSearchClient`\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 options: ClientOptions = {}\n): MapsSearchClient {\n const baseUrl = options.baseUrl ?? `https://atlas.microsoft.com`;\n options.apiVersion = options.apiVersion ?? \"2023-06-01\";\n const userAgentInfo = `azsdk-js-maps-search-rest/2.0.0-beta.1`;\n const userAgentPrefix =\n options.userAgentOptions && options.userAgentOptions.userAgentPrefix\n ? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`\n : `${userAgentInfo}`;\n options = {\n ...options,\n userAgentOptions: {\n userAgentPrefix\n },\n loggingOptions: {\n logger: options.loggingOptions?.logger ?? logger.info\n },\n credentials: {\n apiKeyHeaderName:\n options.credentials?.apiKeyHeaderName ?? \"subscription-key\"\n }\n };\n\n const client = getClient(baseUrl, credentials, options) as MapsSearchClient;\n\n return client;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"models.js","sourceRoot":"","sources":["../../../src/generated/models.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/** The list of address geocoding queries/requests to process. The list can contain a max of 100 queries and must contain at least 1 query. */\nexport interface GeocodingBatchRequestBody {\n /** The list of queries to process. */\n batchItems?: Array<GeocodingBatchRequestItem>;\n}\n\n/** Batch Query object */\nexport interface GeocodingBatchRequestItem {\n /** id of the request which would show in corresponding batchItem */\n optionalId?: string;\n /** Maximum number of responses that will be returned. Default: 5, minimum: 1 and maximum: 20. */\n top?: number;\n /** A string that contains information about a location, such as an address or landmark name. */\n query?: string;\n /**\n * The official street line of an address relative to the area, as specified by the locality, or postalCode, properties. Typical use of this element would be to provide a street address or any official address.\n *\n * **If query is given, should not use this parameter.**\n */\n addressLine?: string;\n /**\n * Restrict the geocoding result to an [ISO 3166-1 Alpha-2 region/country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) that is specified e.g. FR. This will limit the search to the specified region.\n *\n * **If query is given, should not use this parameter.**\n */\n countryRegion?: string;\n /**\n * A rectangular area on the earth defined as a bounding box object. The sides of the rectangles are defined by longitude and latitude values. For more information, see Location and Area Types. When you specify this parameter, the geographical area is taken into account when computing the results of a location query.\n *\n * Example: [lon1, lat1, lon2, lat2]\n */\n bbox?: Array<number>;\n /** A string that specifies an [ISO 3166-1 Alpha-2 region/country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2). This will alter Geopolitical disputed borders and labels to align with the specified user region. */\n view?: string;\n /** A point on the earth specified as a longitude and latitude. When you specify this parameter, the user’s location is taken into account and the results returned may be more relevant to the user. Example: [lon, lat] */\n coordinates?: Array<number>;\n /**\n * The country subdivision portion of an address, such as WA.\n *\n * **If query is given, should not use this parameter.**\n */\n adminDistrict?: string;\n /**\n * The county for the structured address, such as King.\n *\n * **If query is given, should not use this parameter.**\n */\n adminDistrict2?: string;\n /**\n * The named area for the structured address.\n *\n * **If query is given, should not use this parameter.**\n */\n adminDistrict3?: string;\n /**\n * The locality portion of an address, such as Seattle.\n *\n * **If query is given, should not use this parameter.**\n */\n locality?: string;\n /**\n * The postal code portion of an address.\n *\n * **If query is given, should not use this parameter.**\n */\n postalCode?: string;\n}\n\n/** The list of reverse geocoding queries/requests to process. The list can contain a max of 100 queries and must contain at least 1 query. */\nexport interface ReverseGeocodingBatchRequestBody {\n /** The list of queries to process. */\n batchItems?: Array<ReverseGeocodingBatchRequestItem>;\n}\n\n/** Batch Query object */\nexport interface ReverseGeocodingBatchRequestItem {\n /** id of the request which would show in corresponding batchItem */\n optionalId?: string;\n /** The coordinates of the location that you want to reverse geocode. Example: [lon,lat] */\n coordinates?: Array<number>;\n /**\n * Specify entity types that you want in the response. Only the types you specify will be returned. If the point cannot be mapped to the entity types you specify, no location information is returned in the response.\n * Default value is all possible entities.\n * A comma separated list of entity types selected from the following options.\n *\n * - Address\n * - Neighborhood\n * - PopulatedPlace\n * - Postcode1\n * - AdminDivision1\n * - AdminDivision2\n * - CountryRegion\n *\n * These entity types are ordered from the most specific entity to the least specific entity. When entities of more than one entity type are found, only the most specific entity is returned. For example, if you specify Address and AdminDistrict1 as entity types and entities were found for both types, only the Address entity information is returned in the response.\n */\n resultTypes?: Array<\n | \"Address\"\n | \"Neighborhood\"\n | \"PopulatedPlace\"\n | \"Postcode1\"\n | \"AdminDivision1\"\n | \"AdminDivision2\"\n | \"CountryRegion\"\n >;\n /** A string that specifies an [ISO 3166-1 Alpha-2 region/country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2). This will alter Geopolitical disputed borders and labels to align with the specified user region. */\n view?: string;\n}\n"]}
|
|
@@ -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\";\nimport {\n GeocodingBatchRequestBody,\n ReverseGeocodingBatchRequestBody\n} from \"./models\";\n\nexport interface SearchGetGeocodingQueryParamProperties {\n /** Maximum number of responses that will be returned. Default: 5, minimum: 1 and maximum: 20. */\n top?: number;\n /** A string that contains information about a location, such as an address or landmark name. */\n query?: string;\n /**\n * The official street line of an address relative to the area, as specified by the locality, or postalCode, properties. Typical use of this element would be to provide a street address or any official address.\n *\n * **If query is given, should not use this parameter.**\n */\n addressLine?: string;\n /**\n * Restrict the geocoding result to an [ISO 3166-1 Alpha-2 region/country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) that is specified e.g. FR. This will limit the search to the specified region.\n *\n * **If query is given, should not use this parameter.**\n */\n countryRegion?: string;\n /**\n * A rectangular area on the earth defined as a bounding box object. The sides of the rectangles are defined by longitude and latitude values. When you specify this parameter, the geographical area is taken into account when computing the results of a location query.\n *\n * Example: lon1,lat1,lon2,lat2\n */\n bbox?: Array<number>;\n /**\n * A string that represents an [ISO 3166-1 Alpha-2 region/country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2). This will alter Geopolitical disputed borders and labels to align with the specified user region. By default, the View parameter is set to “Auto” even if you haven’t defined it in the request.\n *\n * Please refer to [Supported Views](https://aka.ms/AzureMapsLocalizationViews) for details and to see the available Views.\n */\n view?: string;\n /** A point on the earth specified as a longitude and latitude. When you specify this parameter, the user’s location is taken into account and the results returned may be more relevant to the user. Example: &coordinates=lon,lat */\n coordinates?: Array<number>;\n /**\n * The country subdivision portion of an address, such as WA.\n *\n * **If query is given, should not use this parameter.**\n */\n adminDistrict?: string;\n /**\n * The county for the structured address, such as King.\n *\n * **If query is given, should not use this parameter.**\n */\n adminDistrict2?: string;\n /**\n * The named area for the structured address.\n *\n * **If query is given, should not use this parameter.**\n */\n adminDistrict3?: string;\n /**\n * The locality portion of an address, such as Seattle.\n *\n * **If query is given, should not use this parameter.**\n */\n locality?: string;\n /**\n * The postal code portion of an address.\n *\n * **If query is given, should not use this parameter.**\n */\n postalCode?: string;\n}\n\nexport interface SearchGetGeocodingQueryParam {\n queryParameters?: SearchGetGeocodingQueryParamProperties;\n}\n\nexport type SearchGetGeocodingParameters = SearchGetGeocodingQueryParam &\n RequestParameters;\n\nexport interface SearchGetGeocodingBatchBodyParam {\n /** The list of address geocoding queries/requests to process. The list can contain a max of 100 queries and must contain at least 1 query. */\n body: GeocodingBatchRequestBody;\n}\n\nexport interface SearchGetGeocodingBatchMediaTypesParam {\n /** Request content type */\n contentType?: \"application/json\";\n}\n\nexport type SearchGetGeocodingBatchParameters = SearchGetGeocodingBatchMediaTypesParam &\n SearchGetGeocodingBatchBodyParam &\n RequestParameters;\n\nexport interface SearchGetPolygonQueryParamProperties {\n /** A point on the earth specified as a longitude and latitude. Example: &coordinates=lon,lat */\n coordinates: Array<number>;\n /**\n * A string that represents an [ISO 3166-1 Alpha-2 region/country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2). This will alter Geopolitical disputed borders and labels to align with the specified user region. By default, the View parameter is set to “Auto” even if you haven’t defined it in the request.\n *\n * Please refer to [Supported Views](https://aka.ms/AzureMapsLocalizationViews) for details and to see the available Views.\n */\n view?: string;\n /** The geopolitical concept to return a boundary for. */\n resultType?:\n | \"countryRegion\"\n | \"adminDistrict\"\n | \"adminDistrict2\"\n | \"postalCode\"\n | \"postalCode2\"\n | \"postalCode3\"\n | \"postalCode4\"\n | \"neighborhood\"\n | \"locality\";\n /** Resolution determines the amount of points to send back. */\n resolution?: \"small\" | \"medium\" | \"large\" | \"huge\";\n}\n\nexport interface SearchGetPolygonQueryParam {\n queryParameters: SearchGetPolygonQueryParamProperties;\n}\n\nexport type SearchGetPolygonParameters = SearchGetPolygonQueryParam &\n RequestParameters;\n\nexport interface SearchGetReverseGeocodingQueryParamProperties {\n /** The coordinates of the location that you want to reverse geocode. Example: &coordinates=lon,lat */\n coordinates: Array<number>;\n /**\n * Specify entity types that you want in the response. Only the types you specify will be returned. If the point cannot be mapped to the entity types you specify, no location information is returned in the response.\n * Default value is all possible entities.\n * A comma separated list of entity types selected from the following options.\n *\n * - Address\n * - Neighborhood\n * - PopulatedPlace\n * - Postcode1\n * - AdminDivision1\n * - AdminDivision2\n * - CountryRegion\n *\n * These entity types are ordered from the most specific entity to the least specific entity. When entities of more than one entity type are found, only the most specific entity is returned. For example, if you specify Address and AdminDistrict1 as entity types and entities were found for both types, only the Address entity information is returned in the response.\n */\n resultTypes?: Array<\n | \"Address\"\n | \"Neighborhood\"\n | \"PopulatedPlace\"\n | \"Postcode1\"\n | \"AdminDivision1\"\n | \"AdminDivision2\"\n | \"CountryRegion\"\n >;\n /**\n * A string that represents an [ISO 3166-1 Alpha-2 region/country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2). This will alter Geopolitical disputed borders and labels to align with the specified user region. By default, the View parameter is set to “Auto” even if you haven’t defined it in the request.\n *\n * Please refer to [Supported Views](https://aka.ms/AzureMapsLocalizationViews) for details and to see the available Views.\n */\n view?: string;\n}\n\nexport interface SearchGetReverseGeocodingQueryParam {\n queryParameters: SearchGetReverseGeocodingQueryParamProperties;\n}\n\nexport type SearchGetReverseGeocodingParameters = SearchGetReverseGeocodingQueryParam &\n RequestParameters;\n\nexport interface SearchGetReverseGeocodingBatchBodyParam {\n /** The list of reverse geocoding queries/requests to process. The list can contain a max of 100 queries and must contain at least 1 query. */\n body: ReverseGeocodingBatchRequestBody;\n}\n\nexport interface SearchGetReverseGeocodingBatchMediaTypesParam {\n /** Request content type */\n contentType?: \"application/json\";\n}\n\nexport type SearchGetReverseGeocodingBatchParameters = SearchGetReverseGeocodingBatchMediaTypesParam &\n SearchGetReverseGeocodingBatchBodyParam &\n RequestParameters;\n"]}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Microsoft Corporation.
|
|
2
|
-
// Licensed under the MIT license.
|
|
3
|
-
import { LroEngine } from "@azure/core-lro";
|
|
4
|
-
/**
|
|
5
|
-
* Helper function that builds a Poller object to help polling a long running operation.
|
|
6
|
-
* @param client - Client to use for sending the request to get additional pages.
|
|
7
|
-
* @param initialResponse - The initial response.
|
|
8
|
-
* @param options - Options to set a resume state or custom polling interval.
|
|
9
|
-
* @returns - A poller object to poll for operation state updates and eventually get the final response.
|
|
10
|
-
*/
|
|
11
|
-
export function getLongRunningPoller(client, initialResponse, options = {}) {
|
|
12
|
-
const poller = {
|
|
13
|
-
requestMethod: initialResponse.request.method,
|
|
14
|
-
requestPath: initialResponse.request.url,
|
|
15
|
-
sendInitialRequest: async () => {
|
|
16
|
-
// In the case of Rest Clients we are building the LRO poller object from a response that's the reason
|
|
17
|
-
// we are not triggering the initial request here, just extracting the information from the
|
|
18
|
-
// response we were provided.
|
|
19
|
-
return getLroResponse(initialResponse);
|
|
20
|
-
},
|
|
21
|
-
sendPollRequest: async (path) => {
|
|
22
|
-
// This is the callback that is going to be called to poll the service
|
|
23
|
-
// to get the latest status. We use the client provided and the polling path
|
|
24
|
-
// which is an opaque URL provided by caller, the service sends this in one of the following headers: operation-location, azure-asyncoperation or location
|
|
25
|
-
// depending on the lro pattern that the service implements. If non is provided we default to the initial path.
|
|
26
|
-
const response = await client
|
|
27
|
-
.pathUnchecked(path ?? initialResponse.request.url)
|
|
28
|
-
.get();
|
|
29
|
-
const lroResponse = getLroResponse(response);
|
|
30
|
-
lroResponse.rawResponse.headers["x-ms-original-url"] =
|
|
31
|
-
initialResponse.request.url;
|
|
32
|
-
return lroResponse;
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
return new LroEngine(poller, options);
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Converts a Rest Client response to a response that the LRO engine knows about
|
|
39
|
-
* @param response - a rest client http response
|
|
40
|
-
* @returns - An LRO response that the LRO engine can work with
|
|
41
|
-
*/
|
|
42
|
-
function getLroResponse(response) {
|
|
43
|
-
if (Number.isNaN(response.status)) {
|
|
44
|
-
throw new TypeError(`Status code of the response is not a number. Value: ${response.status}`);
|
|
45
|
-
}
|
|
46
|
-
return {
|
|
47
|
-
flatResponse: response,
|
|
48
|
-
rawResponse: {
|
|
49
|
-
...response,
|
|
50
|
-
statusCode: Number.parseInt(response.status),
|
|
51
|
-
body: response.body
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
//# sourceMappingURL=pollingHelper.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pollingHelper.js","sourceRoot":"","sources":["../../../src/generated/pollingHelper.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAEL,SAAS,EAKV,MAAM,iBAAiB,CAAC;AAEzB;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB,CAClC,MAAc,EACd,eAAwB,EACxB,UAAkE,EAAE;IAEpE,MAAM,MAAM,GAAkC;QAC5C,aAAa,EAAE,eAAe,CAAC,OAAO,CAAC,MAAM;QAC7C,WAAW,EAAE,eAAe,CAAC,OAAO,CAAC,GAAG;QACxC,kBAAkB,EAAE,KAAK,IAAI,EAAE;YAC7B,sGAAsG;YACtG,2FAA2F;YAC3F,6BAA6B;YAC7B,OAAO,cAAc,CAAC,eAAe,CAAC,CAAC;QACzC,CAAC;QACD,eAAe,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;YAC9B,sEAAsE;YACtE,4EAA4E;YAC5E,0JAA0J;YAC1J,+GAA+G;YAC/G,MAAM,QAAQ,GAAG,MAAM,MAAM;iBAC1B,aAAa,CAAC,IAAI,IAAI,eAAe,CAAC,OAAO,CAAC,GAAG,CAAC;iBAClD,GAAG,EAAE,CAAC;YACT,MAAM,WAAW,GAAG,cAAc,CAAC,QAAmB,CAAC,CAAC;YACxD,WAAW,CAAC,WAAW,CAAC,OAAO,CAAC,mBAAmB,CAAC;gBAClD,eAAe,CAAC,OAAO,CAAC,GAAG,CAAC;YAC9B,OAAO,WAAW,CAAC;QACrB,CAAC;KACF,CAAC;IAEF,OAAO,IAAI,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AACxC,CAAC;AAED;;;;GAIG;AACH,SAAS,cAAc,CACrB,QAAiB;IAEjB,IAAI,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;QACjC,MAAM,IAAI,SAAS,CACjB,uDAAuD,QAAQ,CAAC,MAAM,EAAE,CACzE,CAAC;KACH;IAED,OAAO;QACL,YAAY,EAAE,QAAQ;QACtB,WAAW,EAAE;YACX,GAAG,QAAQ;YACX,UAAU,EAAE,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC;YAC5C,IAAI,EAAE,QAAQ,CAAC,IAAI;SACpB;KACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { Client, HttpResponse } from \"@azure-rest/core-client\";\nimport {\n LongRunningOperation,\n LroEngine,\n LroEngineOptions,\n LroResponse,\n PollerLike,\n PollOperationState\n} from \"@azure/core-lro\";\n\n/**\n * Helper function that builds a Poller object to help polling a long running operation.\n * @param client - Client to use for sending the request to get additional pages.\n * @param initialResponse - The initial response.\n * @param options - Options to set a resume state or custom polling interval.\n * @returns - A poller object to poll for operation state updates and eventually get the final response.\n */\nexport function getLongRunningPoller<TResult extends HttpResponse>(\n client: Client,\n initialResponse: TResult,\n options: LroEngineOptions<TResult, PollOperationState<TResult>> = {}\n): PollerLike<PollOperationState<TResult>, TResult> {\n const poller: LongRunningOperation<TResult> = {\n requestMethod: initialResponse.request.method,\n requestPath: initialResponse.request.url,\n sendInitialRequest: async () => {\n // In the case of Rest Clients we are building the LRO poller object from a response that's the reason\n // we are not triggering the initial request here, just extracting the information from the\n // response we were provided.\n return getLroResponse(initialResponse);\n },\n sendPollRequest: async (path) => {\n // This is the callback that is going to be called to poll the service\n // to get the latest status. We use the client provided and the polling path\n // which is an opaque URL provided by caller, the service sends this in one of the following headers: operation-location, azure-asyncoperation or location\n // depending on the lro pattern that the service implements. If non is provided we default to the initial path.\n const response = await client\n .pathUnchecked(path ?? initialResponse.request.url)\n .get();\n const lroResponse = getLroResponse(response as TResult);\n lroResponse.rawResponse.headers[\"x-ms-original-url\"] =\n initialResponse.request.url;\n return lroResponse;\n }\n };\n\n return new LroEngine(poller, options);\n}\n\n/**\n * Converts a Rest Client response to a response that the LRO engine knows about\n * @param response - a rest client http response\n * @returns - An LRO response that the LRO engine can work with\n */\nfunction getLroResponse<TResult extends HttpResponse>(\n response: TResult\n): LroResponse<TResult> {\n if (Number.isNaN(response.status)) {\n throw new TypeError(\n `Status code of the response is not a number. Value: ${response.status}`\n );\n }\n\n return {\n flatResponse: response,\n rawResponse: {\n ...response,\n statusCode: Number.parseInt(response.status),\n body: response.body\n }\n };\n}\n"]}
|
|
@@ -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 { RawHttpHeaders } from \"@azure/core-rest-pipeline\";\nimport { HttpResponse } from \"@azure-rest/core-client\";\nimport {\n GeocodingResponseOutput,\n ErrorResponseOutput,\n GeocodingBatchResponseOutput,\n BoundaryOutput\n} from \"./outputModels\";\n\nexport interface SearchGetGeocoding200Headers {\n /** request id. */\n \"x-ms-request-id\"?: string;\n}\n\n/**\n * **Geocoding**\n *\n * **Applies to:** see pricing [tiers](https://aka.ms/AzureMapsPricingTier).\n *\n * In many cases, the complete search service might be too much, for instance if you are only interested in traditional geocoding. Search can also be accessed for address look up exclusively. The geocoding is performed by hitting the geocoding endpoint with just the address or partial address in question. The geocoding search index will be queried for everything above the street level data. No Point of Interest (POIs) will be returned. Note that the geocoder is very tolerant of typos and incomplete addresses. It will also handle everything from exact street addresses or street or intersections as well as higher level geographies such as city centers, counties, states etc.\n */\nexport interface SearchGetGeocoding200Response extends HttpResponse {\n status: \"200\";\n body: GeocodingResponseOutput;\n headers: RawHttpHeaders & SearchGetGeocoding200Headers;\n}\n\n/**\n * **Geocoding**\n *\n * **Applies to:** see pricing [tiers](https://aka.ms/AzureMapsPricingTier).\n *\n * In many cases, the complete search service might be too much, for instance if you are only interested in traditional geocoding. Search can also be accessed for address look up exclusively. The geocoding is performed by hitting the geocoding endpoint with just the address or partial address in question. The geocoding search index will be queried for everything above the street level data. No Point of Interest (POIs) will be returned. Note that the geocoder is very tolerant of typos and incomplete addresses. It will also handle everything from exact street addresses or street or intersections as well as higher level geographies such as city centers, counties, states etc.\n */\nexport interface SearchGetGeocodingDefaultResponse extends HttpResponse {\n status: string;\n body: ErrorResponseOutput;\n}\n\n/**\n * **Geocoding Batch API**\n *\n *\n * **Applies to**: see pricing [tiers](https://aka.ms/AzureMapsPricingTier).\n *\n *\n *\n * The Geocoding Batch API sends batches of queries to [Geocoding API](https://docs.microsoft.com/rest/api/maps/search-v2/get-geocoding) using just a single API call. The API allows caller to batch up to **100** queries.\n *\n * ### Submit Synchronous Batch Request\n * The Synchronous API is recommended for lightweight batch requests. When the service receives a request, it will respond as soon as the batch items are calculated and there will be no possibility to retrieve the results later. The Synchronous API will return a timeout error (a 408 response) if the request takes longer than 60 seconds. The number of batch items is limited to **100** for this API.\n * ```\n * POST https://atlas.microsoft.com/geocode:batch?api-version=2023-06-01\n * ```\n * ### POST Body for Batch Request\n * To send the _geocoding_ queries you will use a `POST` request where the request body will contain the `batchItems` array in `json` format and the `Content-Type` header will be set to `application/json`. Here's a sample request body containing 2 _geocoding_ queries:\n *\n *\n * ```\n * {\n * \"batchItems\": [\n * {\n * \"addressLine\": \"One, Microsoft Way, Redmond, WA 98052\",\n * \"top\": 2\n * },\n * {\n * \"addressLine\": \"Pike Pl\",\n * \"adminDistrict\": \"WA\",\n * \"locality\": \"Seattle\",\n * \"top\": 3\n * }\n * ]\n * }\n * ```\n *\n * A _geocoding_ batchItem object can accept any of the supported _geocoding_ [URI parameters](https://docs.microsoft.com/rest/api/maps/search-v2/get-geocoding#uri-parameters).\n *\n *\n * The batch should contain at least **1** query.\n *\n *\n * ### Batch Response Model\n * The batch response contains a `summary` component that indicates the `totalRequests` that were part of the original batch request and `successfulRequests` i.e. queries which were executed successfully. The batch response also includes a `batchItems` array which contains a response for each and every query in the batch request. The `batchItems` will contain the results in the exact same order the original queries were sent in the batch request. Each item is of one of the following types:\n *\n * - [`GeocodingResponse`](https://docs.microsoft.com/rest/api/maps/search-v2/get-geocoding#geocodingresponse) - If the query completed successfully.\n *\n * - `Error` - If the query failed. The response will contain a `code` and a `message` in this case.\n *\n *\n *\n */\nexport interface SearchGetGeocodingBatch200Response extends HttpResponse {\n status: \"200\";\n body: GeocodingBatchResponseOutput;\n}\n\n/**\n * **Geocoding Batch API**\n *\n *\n * **Applies to**: see pricing [tiers](https://aka.ms/AzureMapsPricingTier).\n *\n *\n *\n * The Geocoding Batch API sends batches of queries to [Geocoding API](https://docs.microsoft.com/rest/api/maps/search-v2/get-geocoding) using just a single API call. The API allows caller to batch up to **100** queries.\n *\n * ### Submit Synchronous Batch Request\n * The Synchronous API is recommended for lightweight batch requests. When the service receives a request, it will respond as soon as the batch items are calculated and there will be no possibility to retrieve the results later. The Synchronous API will return a timeout error (a 408 response) if the request takes longer than 60 seconds. The number of batch items is limited to **100** for this API.\n * ```\n * POST https://atlas.microsoft.com/geocode:batch?api-version=2023-06-01\n * ```\n * ### POST Body for Batch Request\n * To send the _geocoding_ queries you will use a `POST` request where the request body will contain the `batchItems` array in `json` format and the `Content-Type` header will be set to `application/json`. Here's a sample request body containing 2 _geocoding_ queries:\n *\n *\n * ```\n * {\n * \"batchItems\": [\n * {\n * \"addressLine\": \"One, Microsoft Way, Redmond, WA 98052\",\n * \"top\": 2\n * },\n * {\n * \"addressLine\": \"Pike Pl\",\n * \"adminDistrict\": \"WA\",\n * \"locality\": \"Seattle\",\n * \"top\": 3\n * }\n * ]\n * }\n * ```\n *\n * A _geocoding_ batchItem object can accept any of the supported _geocoding_ [URI parameters](https://docs.microsoft.com/rest/api/maps/search-v2/get-geocoding#uri-parameters).\n *\n *\n * The batch should contain at least **1** query.\n *\n *\n * ### Batch Response Model\n * The batch response contains a `summary` component that indicates the `totalRequests` that were part of the original batch request and `successfulRequests` i.e. queries which were executed successfully. The batch response also includes a `batchItems` array which contains a response for each and every query in the batch request. The `batchItems` will contain the results in the exact same order the original queries were sent in the batch request. Each item is of one of the following types:\n *\n * - [`GeocodingResponse`](https://docs.microsoft.com/rest/api/maps/search-v2/get-geocoding#geocodingresponse) - If the query completed successfully.\n *\n * - `Error` - If the query failed. The response will contain a `code` and a `message` in this case.\n *\n *\n *\n */\nexport interface SearchGetGeocodingBatchDefaultResponse extends HttpResponse {\n status: string;\n body: ErrorResponseOutput;\n}\n\n/**\n * **Get Polygon**\n *\n * **Applies to:** see pricing [tiers](https://aka.ms/AzureMapsPricingTier).\n *\n * Supplies polygon data of a geographical area outline such as a city or a country region.\n */\nexport interface SearchGetPolygon200Response extends HttpResponse {\n status: \"200\";\n body: BoundaryOutput;\n}\n\n/**\n * **Get Polygon**\n *\n * **Applies to:** see pricing [tiers](https://aka.ms/AzureMapsPricingTier).\n *\n * Supplies polygon data of a geographical area outline such as a city or a country region.\n */\nexport interface SearchGetPolygonDefaultResponse extends HttpResponse {\n status: string;\n body: ErrorResponseOutput;\n}\n\n/**\n * **Reverse Geocoding**\n *\n * **Applies to:** see pricing [tiers](https://aka.ms/AzureMapsPricingTier).\n *\n * Translate a coordinate (example: 37.786505, -122.3862) into a human understandable street address. Most often this is needed in tracking applications where you receive a GPS feed from the device or asset and wish to know what address where the coordinate is located. This endpoint will return address information for a given coordinate.\n */\nexport interface SearchGetReverseGeocoding200Response extends HttpResponse {\n status: \"200\";\n body: GeocodingResponseOutput;\n}\n\n/**\n * **Reverse Geocoding**\n *\n * **Applies to:** see pricing [tiers](https://aka.ms/AzureMapsPricingTier).\n *\n * Translate a coordinate (example: 37.786505, -122.3862) into a human understandable street address. Most often this is needed in tracking applications where you receive a GPS feed from the device or asset and wish to know what address where the coordinate is located. This endpoint will return address information for a given coordinate.\n */\nexport interface SearchGetReverseGeocodingDefaultResponse extends HttpResponse {\n status: string;\n body: ErrorResponseOutput;\n}\n\n/**\n * **Reverse Geocoding Batch API**\n *\n *\n * **Applies to**: see pricing [tiers](https://aka.ms/AzureMapsPricingTier).\n *\n *\n *\n * The Reverse Geocoding Batch API sends batches of queries to [Reverse Geocoding API](https://docs.microsoft.com/rest/api/maps/search-v2/get-reverse-geocoding) using just a single API call. The API allows caller to batch up to **100** queries.\n *\n * ### Submit Synchronous Batch Request\n * The Synchronous API is recommended for lightweight batch requests. When the service receives a request, it will respond as soon as the batch items are calculated and there will be no possibility to retrieve the results later. The Synchronous API will return a timeout error (a 408 response) if the request takes longer than 60 seconds. The number of batch items is limited to **100** for this API.\n * ```\n * POST https://atlas.microsoft.com/reverseGeocode:batch?api-version=2023-06-01\n * ```\n * ### POST Body for Batch Request\n * To send the _reverse geocoding_ queries you will use a `POST` request where the request body will contain the `batchItems` array in `json` format and the `Content-Type` header will be set to `application/json`. Here's a sample request body containing 2 _reverse geocoding_ queries:\n *\n *\n * ```\n * {\n * \"batchItems\": [\n * {\n * \"coordinates\": [-122.128275, 47.639429],\n * \"resultTypes\": [\"Address\", \"PopulatedPlace\"]\n * },\n * {\n * \"coordinates\": [-122.341979399674, 47.6095253501216]\n * }\n * ]\n * }\n * ```\n *\n * A _reverse geocoding_ batchItem object can accept any of the supported _reverse geocoding_ [URI parameters](https://docs.microsoft.com/rest/api/maps/search-v2/get-reverse-geocoding#uri-parameters).\n *\n *\n * The batch should contain at least **1** query.\n *\n *\n * ### Batch Response Model\n * The batch response contains a `summary` component that indicates the `totalRequests` that were part of the original batch request and `successfulRequests` i.e. queries which were executed successfully. The batch response also includes a `batchItems` array which contains a response for each and every query in the batch request. The `batchItems` will contain the results in the exact same order the original queries were sent in the batch request. Each item is of one of the following types:\n *\n * - [`GeocodingResponse`](https://docs.microsoft.com/rest/api/maps/search-v2/get-reverse-geocoding#geocodingresponse) - If the query completed successfully.\n *\n * - `Error` - If the query failed. The response will contain a `code` and a `message` in this case.\n *\n *\n *\n */\nexport interface SearchGetReverseGeocodingBatch200Response\n extends HttpResponse {\n status: \"200\";\n body: GeocodingBatchResponseOutput;\n}\n\n/**\n * **Reverse Geocoding Batch API**\n *\n *\n * **Applies to**: see pricing [tiers](https://aka.ms/AzureMapsPricingTier).\n *\n *\n *\n * The Reverse Geocoding Batch API sends batches of queries to [Reverse Geocoding API](https://docs.microsoft.com/rest/api/maps/search-v2/get-reverse-geocoding) using just a single API call. The API allows caller to batch up to **100** queries.\n *\n * ### Submit Synchronous Batch Request\n * The Synchronous API is recommended for lightweight batch requests. When the service receives a request, it will respond as soon as the batch items are calculated and there will be no possibility to retrieve the results later. The Synchronous API will return a timeout error (a 408 response) if the request takes longer than 60 seconds. The number of batch items is limited to **100** for this API.\n * ```\n * POST https://atlas.microsoft.com/reverseGeocode:batch?api-version=2023-06-01\n * ```\n * ### POST Body for Batch Request\n * To send the _reverse geocoding_ queries you will use a `POST` request where the request body will contain the `batchItems` array in `json` format and the `Content-Type` header will be set to `application/json`. Here's a sample request body containing 2 _reverse geocoding_ queries:\n *\n *\n * ```\n * {\n * \"batchItems\": [\n * {\n * \"coordinates\": [-122.128275, 47.639429],\n * \"resultTypes\": [\"Address\", \"PopulatedPlace\"]\n * },\n * {\n * \"coordinates\": [-122.341979399674, 47.6095253501216]\n * }\n * ]\n * }\n * ```\n *\n * A _reverse geocoding_ batchItem object can accept any of the supported _reverse geocoding_ [URI parameters](https://docs.microsoft.com/rest/api/maps/search-v2/get-reverse-geocoding#uri-parameters).\n *\n *\n * The batch should contain at least **1** query.\n *\n *\n * ### Batch Response Model\n * The batch response contains a `summary` component that indicates the `totalRequests` that were part of the original batch request and `successfulRequests` i.e. queries which were executed successfully. The batch response also includes a `batchItems` array which contains a response for each and every query in the batch request. The `batchItems` will contain the results in the exact same order the original queries were sent in the batch request. Each item is of one of the following types:\n *\n * - [`GeocodingResponse`](https://docs.microsoft.com/rest/api/maps/search-v2/get-reverse-geocoding#geocodingresponse) - If the query completed successfully.\n *\n * - `Error` - If the query failed. The response will contain a `code` and a `message` in this case.\n *\n *\n *\n */\nexport interface SearchGetReverseGeocodingBatchDefaultResponse\n extends HttpResponse {\n status: string;\n body: ErrorResponseOutput;\n}\n"]}
|
package/dist-esm/src/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OAAO,UAAU,MAAM,cAAc,CAAC;AAEtC,cAAc,aAAa,CAAC;AAC5B,eAAe,UAAU,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport MapsSearch from \"./MapsSearch\";\n\nexport * from \"./generated\";\nexport default MapsSearch;\n"]}
|