@aws-amplify/geo 2.1.4-api-v6.25 → 2.1.4-api-v6.29
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/internals/package.json +8 -0
- package/lib/Geo.d.ts +3 -41
- package/lib/Geo.js +20 -230
- package/lib/Geo.js.map +1 -1
- package/lib/Providers/AmazonLocationServiceProvider.d.ts +15 -8
- package/lib/Providers/AmazonLocationServiceProvider.js +26 -20
- package/lib/Providers/AmazonLocationServiceProvider.js.map +1 -1
- package/lib/internals/InternalGeo.d.ts +119 -0
- package/lib/internals/InternalGeo.js +354 -0
- package/lib/internals/InternalGeo.js.map +1 -0
- package/lib/internals/index.d.ts +1 -0
- package/lib/internals/index.js +7 -0
- package/lib/internals/index.js.map +1 -0
- package/lib/internals/utils.d.ts +2 -0
- package/lib/internals/utils.js +10 -0
- package/lib/internals/utils.js.map +1 -0
- package/lib/types/Provider.d.ts +9 -8
- package/lib-esm/Geo.d.ts +3 -41
- package/lib-esm/Geo.js +22 -232
- package/lib-esm/Geo.js.map +1 -1
- package/lib-esm/Providers/AmazonLocationServiceProvider.d.ts +15 -8
- package/lib-esm/Providers/AmazonLocationServiceProvider.js +26 -20
- package/lib-esm/Providers/AmazonLocationServiceProvider.js.map +1 -1
- package/lib-esm/internals/InternalGeo.d.ts +119 -0
- package/lib-esm/internals/InternalGeo.js +352 -0
- package/lib-esm/internals/InternalGeo.js.map +1 -0
- package/lib-esm/internals/index.d.ts +1 -0
- package/lib-esm/internals/index.js +4 -0
- package/lib-esm/internals/index.js.map +1 -0
- package/lib-esm/internals/utils.d.ts +2 -0
- package/lib-esm/internals/utils.js +8 -0
- package/lib-esm/internals/utils.js.map +1 -0
- package/lib-esm/types/Provider.d.ts +9 -8
- package/package.json +6 -5
- package/src/Geo.ts +11 -203
- package/src/Providers/AmazonLocationServiceProvider.ts +39 -20
- package/src/internals/InternalGeo.ts +393 -0
- package/src/internals/index.ts +3 -0
- package/src/internals/utils.ts +15 -0
- package/src/types/Provider.ts +22 -8
package/lib-esm/Geo.js
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
import { __awaiter,
|
|
1
|
+
import { __awaiter, __extends, __generator } from "tslib";
|
|
2
2
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
import { Amplify
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var DEFAULT_PROVIDER = 'AmazonLocationService';
|
|
9
|
-
var GeoClass = /** @class */ (function () {
|
|
4
|
+
import { Amplify } from '@aws-amplify/core';
|
|
5
|
+
import { InternalGeoClass } from './internals/InternalGeo';
|
|
6
|
+
var GeoClass = /** @class */ (function (_super) {
|
|
7
|
+
__extends(GeoClass, _super);
|
|
10
8
|
function GeoClass() {
|
|
11
|
-
this
|
|
12
|
-
this._pluggables = [];
|
|
13
|
-
logger.debug('Geo Options', this._config);
|
|
9
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
14
10
|
}
|
|
15
11
|
/**
|
|
16
12
|
* get the name of the module category
|
|
@@ -19,78 +15,6 @@ var GeoClass = /** @class */ (function () {
|
|
|
19
15
|
GeoClass.prototype.getModuleName = function () {
|
|
20
16
|
return GeoClass.MODULE;
|
|
21
17
|
};
|
|
22
|
-
/**
|
|
23
|
-
* add plugin into Geo category
|
|
24
|
-
* @param {Object} pluggable - an instance of the plugin
|
|
25
|
-
*/
|
|
26
|
-
GeoClass.prototype.addPluggable = function (pluggable) {
|
|
27
|
-
if (pluggable && pluggable.getCategory() === 'Geo') {
|
|
28
|
-
this._pluggables.push(pluggable);
|
|
29
|
-
var config = pluggable.configure(this._config[pluggable.getProviderName()]);
|
|
30
|
-
return config;
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
/**
|
|
34
|
-
* Get the plugin object
|
|
35
|
-
* @param providerName - the name of the plugin
|
|
36
|
-
*/
|
|
37
|
-
GeoClass.prototype.getPluggable = function (providerName) {
|
|
38
|
-
var pluggable = this._pluggables.find(function (pluggable) { return pluggable.getProviderName() === providerName; });
|
|
39
|
-
if (pluggable === undefined) {
|
|
40
|
-
logger.debug('No plugin found with providerName', providerName);
|
|
41
|
-
throw new Error('No plugin found in Geo for the provider');
|
|
42
|
-
}
|
|
43
|
-
else
|
|
44
|
-
return pluggable;
|
|
45
|
-
};
|
|
46
|
-
/**
|
|
47
|
-
* Remove the plugin object
|
|
48
|
-
* @param providerName - the name of the plugin
|
|
49
|
-
*/
|
|
50
|
-
GeoClass.prototype.removePluggable = function (providerName) {
|
|
51
|
-
this._pluggables = this._pluggables.filter(function (pluggable) { return pluggable.getProviderName() !== providerName; });
|
|
52
|
-
return;
|
|
53
|
-
};
|
|
54
|
-
/**
|
|
55
|
-
* Configure Geo
|
|
56
|
-
* @param {Object} config - Configuration object for Geo
|
|
57
|
-
* @return {Object} - Current configuration
|
|
58
|
-
*/
|
|
59
|
-
GeoClass.prototype.configure = function (config) {
|
|
60
|
-
var _this = this;
|
|
61
|
-
logger.debug('configure Geo');
|
|
62
|
-
if (!config)
|
|
63
|
-
return this._config;
|
|
64
|
-
var amplifyConfig = parseAWSExports(config);
|
|
65
|
-
this._config = Object.assign({}, this._config, amplifyConfig.Geo, config);
|
|
66
|
-
this._pluggables.forEach(function (pluggable) {
|
|
67
|
-
pluggable.configure(_this._config[pluggable.getProviderName()]);
|
|
68
|
-
});
|
|
69
|
-
if (this._pluggables.length === 0) {
|
|
70
|
-
this.addPluggable(new AmazonLocationServiceProvider());
|
|
71
|
-
}
|
|
72
|
-
return this._config;
|
|
73
|
-
};
|
|
74
|
-
/**
|
|
75
|
-
* Get the map resources that are currently available through the provider
|
|
76
|
-
* @param {string} provider
|
|
77
|
-
* @returns - Array of available map resources
|
|
78
|
-
*/
|
|
79
|
-
GeoClass.prototype.getAvailableMaps = function (provider) {
|
|
80
|
-
if (provider === void 0) { provider = DEFAULT_PROVIDER; }
|
|
81
|
-
var prov = this.getPluggable(provider);
|
|
82
|
-
return prov.getAvailableMaps();
|
|
83
|
-
};
|
|
84
|
-
/**
|
|
85
|
-
* Get the map resource set as default in amplify config
|
|
86
|
-
* @param {string} provider
|
|
87
|
-
* @returns - Map resource set as the default in amplify config
|
|
88
|
-
*/
|
|
89
|
-
GeoClass.prototype.getDefaultMap = function (provider) {
|
|
90
|
-
if (provider === void 0) { provider = DEFAULT_PROVIDER; }
|
|
91
|
-
var prov = this.getPluggable(provider);
|
|
92
|
-
return prov.getDefaultMap();
|
|
93
|
-
};
|
|
94
18
|
/**
|
|
95
19
|
* Search by text input with optional parameters
|
|
96
20
|
* @param {string} text - The text string that is to be searched for
|
|
@@ -99,23 +23,8 @@ var GeoClass = /** @class */ (function () {
|
|
|
99
23
|
*/
|
|
100
24
|
GeoClass.prototype.searchByText = function (text, options) {
|
|
101
25
|
return __awaiter(this, void 0, void 0, function () {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
switch (_b.label) {
|
|
105
|
-
case 0:
|
|
106
|
-
_a = (options || {}).providerName, providerName = _a === void 0 ? DEFAULT_PROVIDER : _a;
|
|
107
|
-
prov = this.getPluggable(providerName);
|
|
108
|
-
_b.label = 1;
|
|
109
|
-
case 1:
|
|
110
|
-
_b.trys.push([1, 3, , 4]);
|
|
111
|
-
return [4 /*yield*/, prov.searchByText(text, options)];
|
|
112
|
-
case 2: return [2 /*return*/, _b.sent()];
|
|
113
|
-
case 3:
|
|
114
|
-
error_1 = _b.sent();
|
|
115
|
-
logger.debug(error_1);
|
|
116
|
-
throw error_1;
|
|
117
|
-
case 4: return [2 /*return*/];
|
|
118
|
-
}
|
|
26
|
+
return __generator(this, function (_a) {
|
|
27
|
+
return [2 /*return*/, _super.prototype.searchByText.call(this, text, options)];
|
|
119
28
|
});
|
|
120
29
|
});
|
|
121
30
|
};
|
|
@@ -127,23 +36,8 @@ var GeoClass = /** @class */ (function () {
|
|
|
127
36
|
*/
|
|
128
37
|
GeoClass.prototype.searchForSuggestions = function (text, options) {
|
|
129
38
|
return __awaiter(this, void 0, void 0, function () {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
switch (_b.label) {
|
|
133
|
-
case 0:
|
|
134
|
-
_a = (options || {}).providerName, providerName = _a === void 0 ? DEFAULT_PROVIDER : _a;
|
|
135
|
-
prov = this.getPluggable(providerName);
|
|
136
|
-
_b.label = 1;
|
|
137
|
-
case 1:
|
|
138
|
-
_b.trys.push([1, 3, , 4]);
|
|
139
|
-
return [4 /*yield*/, prov.searchForSuggestions(text, options)];
|
|
140
|
-
case 2: return [2 /*return*/, _b.sent()];
|
|
141
|
-
case 3:
|
|
142
|
-
error_2 = _b.sent();
|
|
143
|
-
logger.debug(error_2);
|
|
144
|
-
throw error_2;
|
|
145
|
-
case 4: return [2 /*return*/];
|
|
146
|
-
}
|
|
39
|
+
return __generator(this, function (_a) {
|
|
40
|
+
return [2 /*return*/, _super.prototype.searchForSuggestions.call(this, text, options)];
|
|
147
41
|
});
|
|
148
42
|
});
|
|
149
43
|
};
|
|
@@ -155,23 +49,8 @@ var GeoClass = /** @class */ (function () {
|
|
|
155
49
|
*/
|
|
156
50
|
GeoClass.prototype.searchByPlaceId = function (placeId, options) {
|
|
157
51
|
return __awaiter(this, void 0, void 0, function () {
|
|
158
|
-
var providerName, prov, error_3;
|
|
159
52
|
return __generator(this, function (_a) {
|
|
160
|
-
|
|
161
|
-
case 0:
|
|
162
|
-
providerName = DEFAULT_PROVIDER;
|
|
163
|
-
prov = this.getPluggable(providerName);
|
|
164
|
-
_a.label = 1;
|
|
165
|
-
case 1:
|
|
166
|
-
_a.trys.push([1, 3, , 4]);
|
|
167
|
-
return [4 /*yield*/, prov.searchByPlaceId(placeId, options)];
|
|
168
|
-
case 2: return [2 /*return*/, _a.sent()];
|
|
169
|
-
case 3:
|
|
170
|
-
error_3 = _a.sent();
|
|
171
|
-
logger.debug(error_3);
|
|
172
|
-
throw error_3;
|
|
173
|
-
case 4: return [2 /*return*/];
|
|
174
|
-
}
|
|
53
|
+
return [2 /*return*/, _super.prototype.searchByPlaceId.call(this, placeId, options)];
|
|
175
54
|
});
|
|
176
55
|
});
|
|
177
56
|
};
|
|
@@ -183,25 +62,8 @@ var GeoClass = /** @class */ (function () {
|
|
|
183
62
|
*/
|
|
184
63
|
GeoClass.prototype.searchByCoordinates = function (coordinates, options) {
|
|
185
64
|
return __awaiter(this, void 0, void 0, function () {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
switch (_c.label) {
|
|
189
|
-
case 0:
|
|
190
|
-
_a = (options || {}).providerName, providerName = _a === void 0 ? DEFAULT_PROVIDER : _a;
|
|
191
|
-
prov = this.getPluggable(providerName);
|
|
192
|
-
_b = __read(coordinates, 2), lng = _b[0], lat = _b[1];
|
|
193
|
-
_c.label = 1;
|
|
194
|
-
case 1:
|
|
195
|
-
_c.trys.push([1, 3, , 4]);
|
|
196
|
-
validateCoordinates(lng, lat);
|
|
197
|
-
return [4 /*yield*/, prov.searchByCoordinates(coordinates, options)];
|
|
198
|
-
case 2: return [2 /*return*/, _c.sent()];
|
|
199
|
-
case 3:
|
|
200
|
-
error_4 = _c.sent();
|
|
201
|
-
logger.debug(error_4);
|
|
202
|
-
throw error_4;
|
|
203
|
-
case 4: return [2 /*return*/];
|
|
204
|
-
}
|
|
65
|
+
return __generator(this, function (_a) {
|
|
66
|
+
return [2 /*return*/, _super.prototype.searchByCoordinates.call(this, coordinates, options)];
|
|
205
67
|
});
|
|
206
68
|
});
|
|
207
69
|
};
|
|
@@ -215,29 +77,8 @@ var GeoClass = /** @class */ (function () {
|
|
|
215
77
|
*/
|
|
216
78
|
GeoClass.prototype.saveGeofences = function (geofences, options) {
|
|
217
79
|
return __awaiter(this, void 0, void 0, function () {
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
switch (_b.label) {
|
|
221
|
-
case 0:
|
|
222
|
-
_a = (options || {}).providerName, providerName = _a === void 0 ? DEFAULT_PROVIDER : _a;
|
|
223
|
-
prov = this.getPluggable(providerName);
|
|
224
|
-
if (!Array.isArray(geofences)) {
|
|
225
|
-
geofenceInputArray = [geofences];
|
|
226
|
-
}
|
|
227
|
-
else {
|
|
228
|
-
geofenceInputArray = geofences;
|
|
229
|
-
}
|
|
230
|
-
_b.label = 1;
|
|
231
|
-
case 1:
|
|
232
|
-
_b.trys.push([1, 3, , 4]);
|
|
233
|
-
return [4 /*yield*/, prov.saveGeofences(geofenceInputArray, options)];
|
|
234
|
-
case 2: return [2 /*return*/, _b.sent()];
|
|
235
|
-
case 3:
|
|
236
|
-
error_5 = _b.sent();
|
|
237
|
-
logger.debug(error_5);
|
|
238
|
-
throw error_5;
|
|
239
|
-
case 4: return [2 /*return*/];
|
|
240
|
-
}
|
|
80
|
+
return __generator(this, function (_a) {
|
|
81
|
+
return [2 /*return*/, _super.prototype.saveGeofences.call(this, geofences, options)];
|
|
241
82
|
});
|
|
242
83
|
});
|
|
243
84
|
};
|
|
@@ -249,23 +90,8 @@ var GeoClass = /** @class */ (function () {
|
|
|
249
90
|
*/
|
|
250
91
|
GeoClass.prototype.getGeofence = function (geofenceId, options) {
|
|
251
92
|
return __awaiter(this, void 0, void 0, function () {
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
switch (_b.label) {
|
|
255
|
-
case 0:
|
|
256
|
-
_a = (options || {}).providerName, providerName = _a === void 0 ? DEFAULT_PROVIDER : _a;
|
|
257
|
-
prov = this.getPluggable(providerName);
|
|
258
|
-
_b.label = 1;
|
|
259
|
-
case 1:
|
|
260
|
-
_b.trys.push([1, 3, , 4]);
|
|
261
|
-
return [4 /*yield*/, prov.getGeofence(geofenceId, options)];
|
|
262
|
-
case 2: return [2 /*return*/, _b.sent()];
|
|
263
|
-
case 3:
|
|
264
|
-
error_6 = _b.sent();
|
|
265
|
-
logger.debug(error_6);
|
|
266
|
-
throw error_6;
|
|
267
|
-
case 4: return [2 /*return*/];
|
|
268
|
-
}
|
|
93
|
+
return __generator(this, function (_a) {
|
|
94
|
+
return [2 /*return*/, _super.prototype.getGeofence.call(this, geofenceId, options)];
|
|
269
95
|
});
|
|
270
96
|
});
|
|
271
97
|
};
|
|
@@ -278,23 +104,8 @@ var GeoClass = /** @class */ (function () {
|
|
|
278
104
|
*/
|
|
279
105
|
GeoClass.prototype.listGeofences = function (options) {
|
|
280
106
|
return __awaiter(this, void 0, void 0, function () {
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
switch (_b.label) {
|
|
284
|
-
case 0:
|
|
285
|
-
_a = (options || {}).providerName, providerName = _a === void 0 ? DEFAULT_PROVIDER : _a;
|
|
286
|
-
prov = this.getPluggable(providerName);
|
|
287
|
-
_b.label = 1;
|
|
288
|
-
case 1:
|
|
289
|
-
_b.trys.push([1, 3, , 4]);
|
|
290
|
-
return [4 /*yield*/, prov.listGeofences(options)];
|
|
291
|
-
case 2: return [2 /*return*/, _b.sent()];
|
|
292
|
-
case 3:
|
|
293
|
-
error_7 = _b.sent();
|
|
294
|
-
logger.debug(error_7);
|
|
295
|
-
throw error_7;
|
|
296
|
-
case 4: return [2 /*return*/];
|
|
297
|
-
}
|
|
107
|
+
return __generator(this, function (_a) {
|
|
108
|
+
return [2 /*return*/, _super.prototype.listGeofences.call(this, options)];
|
|
298
109
|
});
|
|
299
110
|
});
|
|
300
111
|
};
|
|
@@ -308,35 +119,14 @@ var GeoClass = /** @class */ (function () {
|
|
|
308
119
|
*/
|
|
309
120
|
GeoClass.prototype.deleteGeofences = function (geofenceIds, options) {
|
|
310
121
|
return __awaiter(this, void 0, void 0, function () {
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
switch (_b.label) {
|
|
314
|
-
case 0:
|
|
315
|
-
_a = (options || {}).providerName, providerName = _a === void 0 ? DEFAULT_PROVIDER : _a;
|
|
316
|
-
prov = this.getPluggable(providerName);
|
|
317
|
-
if (!Array.isArray(geofenceIds)) {
|
|
318
|
-
geofenceIdsInputArray = [geofenceIds];
|
|
319
|
-
}
|
|
320
|
-
else {
|
|
321
|
-
geofenceIdsInputArray = geofenceIds;
|
|
322
|
-
}
|
|
323
|
-
_b.label = 1;
|
|
324
|
-
case 1:
|
|
325
|
-
_b.trys.push([1, 3, , 4]);
|
|
326
|
-
return [4 /*yield*/, prov.deleteGeofences(geofenceIdsInputArray, options)];
|
|
327
|
-
case 2: return [2 /*return*/, _b.sent()];
|
|
328
|
-
case 3:
|
|
329
|
-
error_8 = _b.sent();
|
|
330
|
-
logger.debug(error_8);
|
|
331
|
-
throw error_8;
|
|
332
|
-
case 4: return [2 /*return*/];
|
|
333
|
-
}
|
|
122
|
+
return __generator(this, function (_a) {
|
|
123
|
+
return [2 /*return*/, _super.prototype.deleteGeofences.call(this, geofenceIds, options)];
|
|
334
124
|
});
|
|
335
125
|
});
|
|
336
126
|
};
|
|
337
127
|
GeoClass.MODULE = 'Geo';
|
|
338
128
|
return GeoClass;
|
|
339
|
-
}());
|
|
129
|
+
}(InternalGeoClass));
|
|
340
130
|
export { GeoClass };
|
|
341
131
|
export var Geo = new GeoClass();
|
|
342
132
|
Amplify.register(Geo);
|
package/lib-esm/Geo.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Geo.js","sourceRoot":"","sources":["../src/Geo.ts"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,
|
|
1
|
+
{"version":3,"file":"Geo.js","sourceRoot":"","sources":["../src/Geo.ts"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,OAAO,EAA2B,MAAM,mBAAmB,CAAC;AAgBrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D;IAA8B,4BAAgB;IAA9C;;IAsHA,CAAC;IAnHA;;;OAGG;IACI,gCAAa,GAApB;QACC,OAAO,QAAQ,CAAC,MAAM,CAAC;IACxB,CAAC;IAED;;;;;OAKG;IACU,+BAAY,GAAzB,UACC,IAAY,EACZ,OAA6B;;;gBAE7B,sBAAO,iBAAM,YAAY,YAAC,IAAI,EAAE,OAAO,CAAC,EAAC;;;KACzC;IAED;;;;;OAKG;IACU,uCAAoB,GAAjC,UACC,IAAY,EACZ,OAA6B;;;gBAE7B,sBAAO,iBAAM,oBAAoB,YAAC,IAAI,EAAE,OAAO,CAAC,EAAC;;;KACjD;IAED;;;;;OAKG;IACU,kCAAe,GAA5B,UACC,OAAe,EACf,OAAgC;;;gBAEhC,sBAAO,iBAAM,eAAe,YAAC,OAAO,EAAE,OAAO,CAAC,EAAC;;;KAC/C;IAED;;;;;OAKG;IACU,sCAAmB,GAAhC,UACC,WAAwB,EACxB,OAAoC;;;gBAEpC,sBAAO,iBAAM,mBAAmB,YAAC,WAAW,EAAE,OAAO,CAAC,EAAC;;;KACvD;IAED;;;;;;;OAOG;IACU,gCAAa,GAA1B,UACC,SAA0C,EAC1C,OAAyB;;;gBAEzB,sBAAO,iBAAM,aAAa,YAAC,SAAS,EAAE,OAAO,CAAC,EAAC;;;KAC/C;IAED;;;;;OAKG;IACU,8BAAW,GAAxB,UACC,UAAsB,EACtB,OAAyB;;;gBAEzB,sBAAO,iBAAM,WAAW,YAAC,UAAU,EAAE,OAAO,CAAC,EAAC;;;KAC9C;IAED;;;;;;OAMG;IACU,gCAAa,GAA1B,UACC,OAA6B;;;gBAE7B,sBAAO,iBAAM,aAAa,YAAC,OAAO,CAAC,EAAC;;;KACpC;IAED;;;;;;;OAOG;IACU,kCAAe,GAA5B,UACC,WAA8B,EAC9B,OAAyB;;;gBAEzB,sBAAO,iBAAM,eAAe,YAAC,WAAW,EAAE,OAAO,CAAC,EAAC;;;KACnD;IApHM,eAAM,GAAG,KAAK,CAAC;IAqHvB,eAAC;CAAA,AAtHD,CAA8B,gBAAgB,GAsH7C;SAtHY,QAAQ;AAwHrB,MAAM,CAAC,IAAM,GAAG,GAAG,IAAI,QAAQ,EAAE,CAAC;AAClC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CustomUserAgentDetails } from '@aws-amplify/core';
|
|
1
2
|
import { GeoConfig, SearchByTextOptions, SearchByCoordinatesOptions, GeoProvider, Place, AmazonLocationServiceMapStyle, Coordinates, SearchForSuggestionsResults, GeofenceId, GeofenceInput, AmazonLocationServiceGeofenceOptions, AmazonLocationServiceListGeofenceOptions, ListGeofenceResults, SaveGeofencesResults, AmazonLocationServiceGeofence, AmazonLocationServiceDeleteGeofencesResults, searchByPlaceIdOptions } from '../types';
|
|
2
3
|
export declare class AmazonLocationServiceProvider implements GeoProvider {
|
|
3
4
|
static CATEGORY: string;
|
|
@@ -41,58 +42,64 @@ export declare class AmazonLocationServiceProvider implements GeoProvider {
|
|
|
41
42
|
* Search by text input with optional parameters
|
|
42
43
|
* @param {string} text - The text string that is to be searched for
|
|
43
44
|
* @param {SearchByTextOptions} options? - Optional parameters to the search
|
|
45
|
+
* @param {CustomUserAgentDetails} customUserAgentDetails - Optional parameter to send user agent details
|
|
44
46
|
* @returns {Promise<Place[]>} - Promise resolves to a list of Places that match search parameters
|
|
45
47
|
*/
|
|
46
|
-
searchByText(text: string, options?: SearchByTextOptions): Promise<Place[]>;
|
|
48
|
+
searchByText(text: string, options?: SearchByTextOptions, customUserAgentDetails?: CustomUserAgentDetails): Promise<Place[]>;
|
|
47
49
|
/**
|
|
48
50
|
* Search for suggestions based on the input text
|
|
49
51
|
* @param {string} text - The text string that is to be searched for
|
|
50
52
|
* @param {SearchByTextOptions} options? - Optional parameters to the search
|
|
53
|
+
* @param {CustomUserAgentDetails} customUserAgentDetails - Optional parameter to send user agent details
|
|
51
54
|
* @returns {Promise<SearchForSuggestionsResults>} - Resolves to an array of search suggestion strings
|
|
52
55
|
*/
|
|
53
|
-
searchForSuggestions(text: string, options?: SearchByTextOptions): Promise<SearchForSuggestionsResults>;
|
|
56
|
+
searchForSuggestions(text: string, options?: SearchByTextOptions, customUserAgentDetails?: CustomUserAgentDetails): Promise<SearchForSuggestionsResults>;
|
|
54
57
|
private _verifyPlaceId;
|
|
55
|
-
searchByPlaceId(placeId: string, options?: searchByPlaceIdOptions): Promise<Place | undefined>;
|
|
58
|
+
searchByPlaceId(placeId: string, options?: searchByPlaceIdOptions, customUserAgentDetails?: CustomUserAgentDetails): Promise<Place | undefined>;
|
|
56
59
|
/**
|
|
57
60
|
* Reverse geocoding search via a coordinate point on the map
|
|
58
61
|
* @param coordinates - Coordinates array for the search input
|
|
59
62
|
* @param options - Options parameters for the search
|
|
60
63
|
* @returns {Promise<Place>} - Promise that resolves to a place matching search coordinates
|
|
61
64
|
*/
|
|
62
|
-
searchByCoordinates(coordinates: Coordinates, options?: SearchByCoordinatesOptions): Promise<Place>;
|
|
65
|
+
searchByCoordinates(coordinates: Coordinates, options?: SearchByCoordinatesOptions, customUserAgentDetails?: CustomUserAgentDetails): Promise<Place>;
|
|
63
66
|
/**
|
|
64
67
|
* Create geofences inside of a geofence collection
|
|
65
68
|
* @param geofences - Array of geofence objects to create
|
|
66
69
|
* @param options? - Optional parameters for creating geofences
|
|
70
|
+
* @param {CustomUserAgentDetails} customUserAgentDetails - Optional parameter to send user agent details
|
|
67
71
|
* @returns {Promise<AmazonLocationServiceSaveGeofencesResults>} - Promise that resolves to an object with:
|
|
68
72
|
* successes: list of geofences successfully created
|
|
69
73
|
* errors: list of geofences that failed to create
|
|
70
74
|
*/
|
|
71
|
-
saveGeofences(geofences: GeofenceInput[], options?: AmazonLocationServiceGeofenceOptions): Promise<SaveGeofencesResults>;
|
|
75
|
+
saveGeofences(geofences: GeofenceInput[], options?: AmazonLocationServiceGeofenceOptions, customUserAgentDetails?: CustomUserAgentDetails): Promise<SaveGeofencesResults>;
|
|
72
76
|
/**
|
|
73
77
|
* Get geofence from a geofence collection
|
|
74
78
|
* @param geofenceId:string
|
|
75
79
|
* @param options?: Optional parameters for getGeofence
|
|
80
|
+
* @param {CustomUserAgentDetails} customUserAgentDetails - Optional parameter to send user agent details
|
|
76
81
|
* @returns {Promise<AmazonLocationServiceGeofence>} - Promise that resolves to a geofence object
|
|
77
82
|
*/
|
|
78
|
-
getGeofence(geofenceId: GeofenceId, options?: AmazonLocationServiceGeofenceOptions): Promise<AmazonLocationServiceGeofence>;
|
|
83
|
+
getGeofence(geofenceId: GeofenceId, options?: AmazonLocationServiceGeofenceOptions, customUserAgentDetails?: CustomUserAgentDetails): Promise<AmazonLocationServiceGeofence>;
|
|
79
84
|
/**
|
|
80
85
|
* List geofences from a geofence collection
|
|
81
86
|
* @param options?: ListGeofenceOptions
|
|
87
|
+
* @param {CustomUserAgentDetails} customUserAgentDetails - Optional parameter to send user agent details
|
|
82
88
|
* @returns {Promise<ListGeofencesResults>} - Promise that resolves to an object with:
|
|
83
89
|
* entries: list of geofences - 100 geofences are listed per page
|
|
84
90
|
* nextToken: token for next page of geofences
|
|
85
91
|
*/
|
|
86
|
-
listGeofences(options?: AmazonLocationServiceListGeofenceOptions): Promise<ListGeofenceResults>;
|
|
92
|
+
listGeofences(options?: AmazonLocationServiceListGeofenceOptions, customUserAgentDetails?: CustomUserAgentDetails): Promise<ListGeofenceResults>;
|
|
87
93
|
/**
|
|
88
94
|
* Delete geofences from a geofence collection
|
|
89
95
|
* @param geofenceIds: string|string[]
|
|
90
96
|
* @param options?: GeofenceOptions
|
|
97
|
+
* @param {CustomUserAgentDetails} customUserAgentDetails - Optional parameter to send user agent details
|
|
91
98
|
* @returns {Promise<DeleteGeofencesResults>} - Promise that resolves to an object with:
|
|
92
99
|
* successes: list of geofences successfully deleted
|
|
93
100
|
* errors: list of geofences that failed to delete
|
|
94
101
|
*/
|
|
95
|
-
deleteGeofences(geofenceIds: string[], options?: AmazonLocationServiceGeofenceOptions): Promise<AmazonLocationServiceDeleteGeofencesResults>;
|
|
102
|
+
deleteGeofences(geofenceIds: string[], options?: AmazonLocationServiceGeofenceOptions, customUserAgentDetails?: CustomUserAgentDetails): Promise<AmazonLocationServiceDeleteGeofencesResults>;
|
|
96
103
|
/**
|
|
97
104
|
* @private
|
|
98
105
|
*/
|
|
@@ -71,9 +71,10 @@ var AmazonLocationServiceProvider = /** @class */ (function () {
|
|
|
71
71
|
* Search by text input with optional parameters
|
|
72
72
|
* @param {string} text - The text string that is to be searched for
|
|
73
73
|
* @param {SearchByTextOptions} options? - Optional parameters to the search
|
|
74
|
+
* @param {CustomUserAgentDetails} customUserAgentDetails - Optional parameter to send user agent details
|
|
74
75
|
* @returns {Promise<Place[]>} - Promise resolves to a list of Places that match search parameters
|
|
75
76
|
*/
|
|
76
|
-
AmazonLocationServiceProvider.prototype.searchByText = function (text, options) {
|
|
77
|
+
AmazonLocationServiceProvider.prototype.searchByText = function (text, options, customUserAgentDetails) {
|
|
77
78
|
return __awaiter(this, void 0, void 0, function () {
|
|
78
79
|
var credentialsOK, locationServiceInput, client, command, response, error_1, PascalResults, results;
|
|
79
80
|
return __generator(this, function (_a) {
|
|
@@ -98,7 +99,7 @@ var AmazonLocationServiceProvider = /** @class */ (function () {
|
|
|
98
99
|
client = new LocationClient({
|
|
99
100
|
credentials: this._config.credentials,
|
|
100
101
|
region: this._config.region,
|
|
101
|
-
customUserAgent: getAmplifyUserAgentObject(),
|
|
102
|
+
customUserAgent: getAmplifyUserAgentObject(customUserAgentDetails),
|
|
102
103
|
});
|
|
103
104
|
command = new SearchPlaceIndexForTextCommand(locationServiceInput);
|
|
104
105
|
_a.label = 2;
|
|
@@ -126,9 +127,10 @@ var AmazonLocationServiceProvider = /** @class */ (function () {
|
|
|
126
127
|
* Search for suggestions based on the input text
|
|
127
128
|
* @param {string} text - The text string that is to be searched for
|
|
128
129
|
* @param {SearchByTextOptions} options? - Optional parameters to the search
|
|
130
|
+
* @param {CustomUserAgentDetails} customUserAgentDetails - Optional parameter to send user agent details
|
|
129
131
|
* @returns {Promise<SearchForSuggestionsResults>} - Resolves to an array of search suggestion strings
|
|
130
132
|
*/
|
|
131
|
-
AmazonLocationServiceProvider.prototype.searchForSuggestions = function (text, options) {
|
|
133
|
+
AmazonLocationServiceProvider.prototype.searchForSuggestions = function (text, options, customUserAgentDetails) {
|
|
132
134
|
return __awaiter(this, void 0, void 0, function () {
|
|
133
135
|
var credentialsOK, locationServiceInput, client, command, response, error_2, results;
|
|
134
136
|
return __generator(this, function (_a) {
|
|
@@ -153,7 +155,7 @@ var AmazonLocationServiceProvider = /** @class */ (function () {
|
|
|
153
155
|
client = new LocationClient({
|
|
154
156
|
credentials: this._config.credentials,
|
|
155
157
|
region: this._config.region,
|
|
156
|
-
customUserAgent: getAmplifyUserAgentObject(),
|
|
158
|
+
customUserAgent: getAmplifyUserAgentObject(customUserAgentDetails),
|
|
157
159
|
});
|
|
158
160
|
command = new SearchPlaceIndexForSuggestionsCommand(locationServiceInput);
|
|
159
161
|
_a.label = 2;
|
|
@@ -184,7 +186,7 @@ var AmazonLocationServiceProvider = /** @class */ (function () {
|
|
|
184
186
|
throw new Error(errorString);
|
|
185
187
|
}
|
|
186
188
|
};
|
|
187
|
-
AmazonLocationServiceProvider.prototype.searchByPlaceId = function (placeId, options) {
|
|
189
|
+
AmazonLocationServiceProvider.prototype.searchByPlaceId = function (placeId, options, customUserAgentDetails) {
|
|
188
190
|
return __awaiter(this, void 0, void 0, function () {
|
|
189
191
|
var credentialsOK, client, searchByPlaceIdInput, command, response, error_3, place;
|
|
190
192
|
return __generator(this, function (_a) {
|
|
@@ -200,7 +202,7 @@ var AmazonLocationServiceProvider = /** @class */ (function () {
|
|
|
200
202
|
client = new LocationClient({
|
|
201
203
|
credentials: this._config.credentials,
|
|
202
204
|
region: this._config.region,
|
|
203
|
-
customUserAgent: getAmplifyUserAgentObject(),
|
|
205
|
+
customUserAgent: getAmplifyUserAgentObject(customUserAgentDetails),
|
|
204
206
|
});
|
|
205
207
|
searchByPlaceIdInput = {
|
|
206
208
|
PlaceId: placeId,
|
|
@@ -234,7 +236,7 @@ var AmazonLocationServiceProvider = /** @class */ (function () {
|
|
|
234
236
|
* @param options - Options parameters for the search
|
|
235
237
|
* @returns {Promise<Place>} - Promise that resolves to a place matching search coordinates
|
|
236
238
|
*/
|
|
237
|
-
AmazonLocationServiceProvider.prototype.searchByCoordinates = function (coordinates, options) {
|
|
239
|
+
AmazonLocationServiceProvider.prototype.searchByCoordinates = function (coordinates, options, customUserAgentDetails) {
|
|
238
240
|
return __awaiter(this, void 0, void 0, function () {
|
|
239
241
|
var credentialsOK, locationServiceInput, client, command, response, error_4, PascalResults, results;
|
|
240
242
|
return __generator(this, function (_a) {
|
|
@@ -259,7 +261,7 @@ var AmazonLocationServiceProvider = /** @class */ (function () {
|
|
|
259
261
|
client = new LocationClient({
|
|
260
262
|
credentials: this._config.credentials,
|
|
261
263
|
region: this._config.region,
|
|
262
|
-
customUserAgent: getAmplifyUserAgentObject(),
|
|
264
|
+
customUserAgent: getAmplifyUserAgentObject(customUserAgentDetails),
|
|
263
265
|
});
|
|
264
266
|
command = new SearchPlaceIndexForPositionCommand(locationServiceInput);
|
|
265
267
|
_a.label = 2;
|
|
@@ -287,11 +289,12 @@ var AmazonLocationServiceProvider = /** @class */ (function () {
|
|
|
287
289
|
* Create geofences inside of a geofence collection
|
|
288
290
|
* @param geofences - Array of geofence objects to create
|
|
289
291
|
* @param options? - Optional parameters for creating geofences
|
|
292
|
+
* @param {CustomUserAgentDetails} customUserAgentDetails - Optional parameter to send user agent details
|
|
290
293
|
* @returns {Promise<AmazonLocationServiceSaveGeofencesResults>} - Promise that resolves to an object with:
|
|
291
294
|
* successes: list of geofences successfully created
|
|
292
295
|
* errors: list of geofences that failed to create
|
|
293
296
|
*/
|
|
294
|
-
AmazonLocationServiceProvider.prototype.saveGeofences = function (geofences, options) {
|
|
297
|
+
AmazonLocationServiceProvider.prototype.saveGeofences = function (geofences, options, customUserAgentDetails) {
|
|
295
298
|
return __awaiter(this, void 0, void 0, function () {
|
|
296
299
|
var credentialsOK, PascalGeofences, results, geofenceBatches, apiLimit;
|
|
297
300
|
var _this = this;
|
|
@@ -340,7 +343,7 @@ var AmazonLocationServiceProvider = /** @class */ (function () {
|
|
|
340
343
|
switch (_a.label) {
|
|
341
344
|
case 0:
|
|
342
345
|
_a.trys.push([0, 2, , 3]);
|
|
343
|
-
return [4 /*yield*/, this._AmazonLocationServiceBatchPutGeofenceCall(batch, (options === null || options === void 0 ? void 0 : options.collectionName) || this._config.geofenceCollections.default)];
|
|
346
|
+
return [4 /*yield*/, this._AmazonLocationServiceBatchPutGeofenceCall(batch, (options === null || options === void 0 ? void 0 : options.collectionName) || this._config.geofenceCollections.default, customUserAgentDetails)];
|
|
344
347
|
case 1:
|
|
345
348
|
response = _a.sent();
|
|
346
349
|
return [3 /*break*/, 3];
|
|
@@ -393,9 +396,10 @@ var AmazonLocationServiceProvider = /** @class */ (function () {
|
|
|
393
396
|
* Get geofence from a geofence collection
|
|
394
397
|
* @param geofenceId:string
|
|
395
398
|
* @param options?: Optional parameters for getGeofence
|
|
399
|
+
* @param {CustomUserAgentDetails} customUserAgentDetails - Optional parameter to send user agent details
|
|
396
400
|
* @returns {Promise<AmazonLocationServiceGeofence>} - Promise that resolves to a geofence object
|
|
397
401
|
*/
|
|
398
|
-
AmazonLocationServiceProvider.prototype.getGeofence = function (geofenceId, options) {
|
|
402
|
+
AmazonLocationServiceProvider.prototype.getGeofence = function (geofenceId, options, customUserAgentDetails) {
|
|
399
403
|
return __awaiter(this, void 0, void 0, function () {
|
|
400
404
|
var credentialsOK, client, commandInput, command, response, error_6, GeofenceId, CreateTime, UpdateTime, Status, Geometry, geofence;
|
|
401
405
|
return __generator(this, function (_a) {
|
|
@@ -418,7 +422,7 @@ var AmazonLocationServiceProvider = /** @class */ (function () {
|
|
|
418
422
|
client = new LocationClient({
|
|
419
423
|
credentials: this._config.credentials,
|
|
420
424
|
region: this._config.region,
|
|
421
|
-
customUserAgent: getAmplifyUserAgentObject(),
|
|
425
|
+
customUserAgent: getAmplifyUserAgentObject(customUserAgentDetails),
|
|
422
426
|
});
|
|
423
427
|
commandInput = {
|
|
424
428
|
GeofenceId: geofenceId,
|
|
@@ -455,11 +459,12 @@ var AmazonLocationServiceProvider = /** @class */ (function () {
|
|
|
455
459
|
/**
|
|
456
460
|
* List geofences from a geofence collection
|
|
457
461
|
* @param options?: ListGeofenceOptions
|
|
462
|
+
* @param {CustomUserAgentDetails} customUserAgentDetails - Optional parameter to send user agent details
|
|
458
463
|
* @returns {Promise<ListGeofencesResults>} - Promise that resolves to an object with:
|
|
459
464
|
* entries: list of geofences - 100 geofences are listed per page
|
|
460
465
|
* nextToken: token for next page of geofences
|
|
461
466
|
*/
|
|
462
|
-
AmazonLocationServiceProvider.prototype.listGeofences = function (options) {
|
|
467
|
+
AmazonLocationServiceProvider.prototype.listGeofences = function (options, customUserAgentDetails) {
|
|
463
468
|
return __awaiter(this, void 0, void 0, function () {
|
|
464
469
|
var credentialsOK, client, listGeofencesInput, command, response, error_7, NextToken, Entries, results;
|
|
465
470
|
return __generator(this, function (_a) {
|
|
@@ -481,7 +486,7 @@ var AmazonLocationServiceProvider = /** @class */ (function () {
|
|
|
481
486
|
client = new LocationClient({
|
|
482
487
|
credentials: this._config.credentials,
|
|
483
488
|
region: this._config.region,
|
|
484
|
-
customUserAgent: getAmplifyUserAgentObject(),
|
|
489
|
+
customUserAgent: getAmplifyUserAgentObject(customUserAgentDetails),
|
|
485
490
|
});
|
|
486
491
|
listGeofencesInput = {
|
|
487
492
|
NextToken: options === null || options === void 0 ? void 0 : options.nextToken,
|
|
@@ -525,11 +530,12 @@ var AmazonLocationServiceProvider = /** @class */ (function () {
|
|
|
525
530
|
* Delete geofences from a geofence collection
|
|
526
531
|
* @param geofenceIds: string|string[]
|
|
527
532
|
* @param options?: GeofenceOptions
|
|
533
|
+
* @param {CustomUserAgentDetails} customUserAgentDetails - Optional parameter to send user agent details
|
|
528
534
|
* @returns {Promise<DeleteGeofencesResults>} - Promise that resolves to an object with:
|
|
529
535
|
* successes: list of geofences successfully deleted
|
|
530
536
|
* errors: list of geofences that failed to delete
|
|
531
537
|
*/
|
|
532
|
-
AmazonLocationServiceProvider.prototype.deleteGeofences = function (geofenceIds, options) {
|
|
538
|
+
AmazonLocationServiceProvider.prototype.deleteGeofences = function (geofenceIds, options, customUserAgentDetails) {
|
|
533
539
|
return __awaiter(this, void 0, void 0, function () {
|
|
534
540
|
var credentialsOK, badGeofenceIds, results, geofenceIdBatches, count;
|
|
535
541
|
var _this = this;
|
|
@@ -573,7 +579,7 @@ var AmazonLocationServiceProvider = /** @class */ (function () {
|
|
|
573
579
|
switch (_b.label) {
|
|
574
580
|
case 0:
|
|
575
581
|
_b.trys.push([0, 2, , 3]);
|
|
576
|
-
return [4 /*yield*/, this._AmazonLocationServiceBatchDeleteGeofenceCall(batch, (options === null || options === void 0 ? void 0 : options.collectionName) || this._config.geofenceCollections.default)];
|
|
582
|
+
return [4 /*yield*/, this._AmazonLocationServiceBatchDeleteGeofenceCall(batch, (options === null || options === void 0 ? void 0 : options.collectionName) || this._config.geofenceCollections.default, customUserAgentDetails)];
|
|
577
583
|
case 1:
|
|
578
584
|
response = _b.sent();
|
|
579
585
|
return [3 /*break*/, 3];
|
|
@@ -665,7 +671,7 @@ var AmazonLocationServiceProvider = /** @class */ (function () {
|
|
|
665
671
|
throw new Error(errorString);
|
|
666
672
|
}
|
|
667
673
|
};
|
|
668
|
-
AmazonLocationServiceProvider.prototype._AmazonLocationServiceBatchPutGeofenceCall = function (PascalGeofences, collectionName) {
|
|
674
|
+
AmazonLocationServiceProvider.prototype._AmazonLocationServiceBatchPutGeofenceCall = function (PascalGeofences, collectionName, customUserAgentDetails) {
|
|
669
675
|
return __awaiter(this, void 0, void 0, function () {
|
|
670
676
|
var geofenceInput, client, command, response, error_10;
|
|
671
677
|
return __generator(this, function (_a) {
|
|
@@ -678,7 +684,7 @@ var AmazonLocationServiceProvider = /** @class */ (function () {
|
|
|
678
684
|
client = new LocationClient({
|
|
679
685
|
credentials: this._config.credentials,
|
|
680
686
|
region: this._config.region,
|
|
681
|
-
customUserAgent: getAmplifyUserAgentObject(),
|
|
687
|
+
customUserAgent: getAmplifyUserAgentObject(customUserAgentDetails),
|
|
682
688
|
});
|
|
683
689
|
command = new BatchPutGeofenceCommand(geofenceInput);
|
|
684
690
|
_a.label = 1;
|
|
@@ -696,7 +702,7 @@ var AmazonLocationServiceProvider = /** @class */ (function () {
|
|
|
696
702
|
});
|
|
697
703
|
});
|
|
698
704
|
};
|
|
699
|
-
AmazonLocationServiceProvider.prototype._AmazonLocationServiceBatchDeleteGeofenceCall = function (geofenceIds, collectionName) {
|
|
705
|
+
AmazonLocationServiceProvider.prototype._AmazonLocationServiceBatchDeleteGeofenceCall = function (geofenceIds, collectionName, customUserAgentDetails) {
|
|
700
706
|
return __awaiter(this, void 0, void 0, function () {
|
|
701
707
|
var deleteGeofencesInput, client, command, response, error_11;
|
|
702
708
|
return __generator(this, function (_a) {
|
|
@@ -709,7 +715,7 @@ var AmazonLocationServiceProvider = /** @class */ (function () {
|
|
|
709
715
|
client = new LocationClient({
|
|
710
716
|
credentials: this._config.credentials,
|
|
711
717
|
region: this._config.region,
|
|
712
|
-
customUserAgent: getAmplifyUserAgentObject(),
|
|
718
|
+
customUserAgent: getAmplifyUserAgentObject(customUserAgentDetails),
|
|
713
719
|
});
|
|
714
720
|
command = new BatchDeleteGeofenceCommand(deleteGeofencesInput);
|
|
715
721
|
_a.label = 1;
|