@aws-amplify/geo 2.3.5-unstable.fda7a25.0 → 3.0.1-console-preview.67f944e.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/lib/Geo.d.ts +3 -9
- package/lib/Geo.js +33 -44
- package/lib/index.js +4 -2
- package/{lib-esm/Providers → lib/providers/location-service}/AmazonLocationServiceProvider.d.ts +3 -7
- package/lib/{Providers → providers/location-service}/AmazonLocationServiceProvider.js +66 -62
- package/lib/tsconfig.tsbuildinfo +1 -0
- package/lib/types/AmazonLocationServiceProvider.d.ts +7 -7
- package/lib/types/AmazonLocationServiceProvider.js +0 -1
- package/lib/types/Geo.d.ts +28 -45
- package/lib/types/Geo.js +0 -1
- package/lib/types/Provider.d.ts +0 -1
- package/lib/types/Provider.js +0 -1
- package/lib/types/index.js +6 -1
- package/lib/util.js +19 -19
- package/lib-esm/Geo.d.ts +3 -9
- package/lib-esm/Geo.js +31 -43
- package/lib-esm/index.js +1 -1
- package/{lib/Providers → lib-esm/providers/location-service}/AmazonLocationServiceProvider.d.ts +3 -7
- package/lib-esm/{Providers → providers/location-service}/AmazonLocationServiceProvider.js +50 -47
- package/lib-esm/tsconfig.tsbuildinfo +1 -0
- package/lib-esm/types/AmazonLocationServiceProvider.d.ts +7 -7
- package/lib-esm/types/AmazonLocationServiceProvider.js +1 -1
- package/lib-esm/types/Geo.d.ts +28 -45
- package/lib-esm/types/Geo.js +1 -1
- package/lib-esm/types/Provider.d.ts +0 -1
- package/lib-esm/types/Provider.js +1 -1
- package/lib-esm/types/index.js +5 -1
- package/lib-esm/util.js +17 -18
- package/package.json +132 -115
- package/src/Geo.ts +12 -35
- package/src/{Providers → providers/location-service}/AmazonLocationServiceProvider.ts +55 -56
- package/src/types/Geo.ts +1 -17
- package/src/types/Provider.ts +0 -3
- package/src/util.ts +3 -3
- package/lib/.tsbuildinfo +0 -3
- package/lib/Geo.js.map +0 -1
- package/lib/Providers/AmazonLocationServiceProvider.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/types/AmazonLocationServiceProvider.js.map +0 -1
- package/lib/types/Geo.js.map +0 -1
- package/lib/types/Provider.js.map +0 -1
- package/lib/types/index.js.map +0 -1
- package/lib/util.js.map +0 -1
- package/lib-esm/.tsbuildinfo +0 -3
- package/lib-esm/Geo.js.map +0 -1
- package/lib-esm/Providers/AmazonLocationServiceProvider.js.map +0 -1
- package/lib-esm/index.js.map +0 -1
- package/lib-esm/types/AmazonLocationServiceProvider.js.map +0 -1
- package/lib-esm/types/Geo.js.map +0 -1
- package/lib-esm/types/Provider.js.map +0 -1
- package/lib-esm/types/index.js.map +0 -1
- package/lib-esm/util.js.map +0 -1
package/README.md
ADDED
package/lib/Geo.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Place,
|
|
1
|
+
import { Place, Coordinates, SearchByTextOptions, SearchByCoordinatesOptions, GeoProvider, MapStyle, GeofenceId, GeofenceInput, GeofenceOptions, SaveGeofencesResults, Geofence, ListGeofenceOptions, ListGeofenceResults, DeleteGeofencesResults, searchByPlaceIdOptions } from './types';
|
|
2
2
|
export declare class GeoClass {
|
|
3
3
|
static MODULE: string;
|
|
4
4
|
/**
|
|
@@ -16,7 +16,7 @@ export declare class GeoClass {
|
|
|
16
16
|
* add plugin into Geo category
|
|
17
17
|
* @param {Object} pluggable - an instance of the plugin
|
|
18
18
|
*/
|
|
19
|
-
addPluggable(pluggable: GeoProvider):
|
|
19
|
+
addPluggable(pluggable: GeoProvider): void;
|
|
20
20
|
/**
|
|
21
21
|
* Get the plugin object
|
|
22
22
|
* @param providerName - the name of the plugin
|
|
@@ -27,12 +27,6 @@ export declare class GeoClass {
|
|
|
27
27
|
* @param providerName - the name of the plugin
|
|
28
28
|
*/
|
|
29
29
|
removePluggable(providerName: string): void;
|
|
30
|
-
/**
|
|
31
|
-
* Configure Geo
|
|
32
|
-
* @param {Object} config - Configuration object for Geo
|
|
33
|
-
* @return {Object} - Current configuration
|
|
34
|
-
*/
|
|
35
|
-
configure(config?: any): GeoConfig;
|
|
36
30
|
/**
|
|
37
31
|
* Get the map resources that are currently available through the provider
|
|
38
32
|
* @param {string} provider
|
|
@@ -65,7 +59,7 @@ export declare class GeoClass {
|
|
|
65
59
|
* @param {searchByPlaceIdOptions} options? - Optional parameters to the search
|
|
66
60
|
* @returns {Promise<Place>} - Resolves to a place with the given placeId
|
|
67
61
|
*/
|
|
68
|
-
searchByPlaceId(placeId: string, options?: searchByPlaceIdOptions): Promise<Place>;
|
|
62
|
+
searchByPlaceId(placeId: string, options?: searchByPlaceIdOptions): Promise<Place | undefined>;
|
|
69
63
|
/**
|
|
70
64
|
* Reverse geocoding search via a coordinate point on the map
|
|
71
65
|
* @param coordinates - Coordinates array for the search input
|
package/lib/Geo.js
CHANGED
|
@@ -1,17 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Geo = exports.GeoClass = void 0;
|
|
3
4
|
var tslib_1 = require("tslib");
|
|
4
5
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
5
6
|
// SPDX-License-Identifier: Apache-2.0
|
|
6
7
|
var core_1 = require("@aws-amplify/core");
|
|
7
|
-
var
|
|
8
|
+
var utils_1 = require("@aws-amplify/core/internals/utils");
|
|
9
|
+
var AmazonLocationServiceProvider_1 = require("./providers/location-service/AmazonLocationServiceProvider");
|
|
8
10
|
var util_1 = require("./util");
|
|
9
|
-
var logger = new
|
|
11
|
+
var logger = new utils_1.ConsoleLogger('Geo');
|
|
10
12
|
var DEFAULT_PROVIDER = 'AmazonLocationService';
|
|
11
|
-
var GeoClass = /** @class */ (function () {
|
|
13
|
+
var GeoClass = exports.GeoClass = /** @class */ (function () {
|
|
12
14
|
function GeoClass() {
|
|
15
|
+
var _a;
|
|
13
16
|
this._config = {};
|
|
14
17
|
this._pluggables = [];
|
|
18
|
+
var amplifyConfig = (_a = core_1.Amplify.getConfig()) !== null && _a !== void 0 ? _a : {};
|
|
19
|
+
this._config = Object.assign({}, this._config, amplifyConfig.Geo);
|
|
20
|
+
var locationProvider = new AmazonLocationServiceProvider_1.AmazonLocationServiceProvider(amplifyConfig.Geo);
|
|
21
|
+
this._pluggables.push(locationProvider);
|
|
15
22
|
logger.debug('Geo Options', this._config);
|
|
16
23
|
}
|
|
17
24
|
/**
|
|
@@ -28,8 +35,6 @@ var GeoClass = /** @class */ (function () {
|
|
|
28
35
|
GeoClass.prototype.addPluggable = function (pluggable) {
|
|
29
36
|
if (pluggable && pluggable.getCategory() === 'Geo') {
|
|
30
37
|
this._pluggables.push(pluggable);
|
|
31
|
-
var config = pluggable.configure(this._config[pluggable.getProviderName()]);
|
|
32
|
-
return config;
|
|
33
38
|
}
|
|
34
39
|
};
|
|
35
40
|
/**
|
|
@@ -53,26 +58,6 @@ var GeoClass = /** @class */ (function () {
|
|
|
53
58
|
this._pluggables = this._pluggables.filter(function (pluggable) { return pluggable.getProviderName() !== providerName; });
|
|
54
59
|
return;
|
|
55
60
|
};
|
|
56
|
-
/**
|
|
57
|
-
* Configure Geo
|
|
58
|
-
* @param {Object} config - Configuration object for Geo
|
|
59
|
-
* @return {Object} - Current configuration
|
|
60
|
-
*/
|
|
61
|
-
GeoClass.prototype.configure = function (config) {
|
|
62
|
-
var _this = this;
|
|
63
|
-
logger.debug('configure Geo');
|
|
64
|
-
if (!config)
|
|
65
|
-
return this._config;
|
|
66
|
-
var amplifyConfig = core_1.parseAWSExports(config);
|
|
67
|
-
this._config = Object.assign({}, this._config, amplifyConfig.Geo, config);
|
|
68
|
-
this._pluggables.forEach(function (pluggable) {
|
|
69
|
-
pluggable.configure(_this._config[pluggable.getProviderName()]);
|
|
70
|
-
});
|
|
71
|
-
if (this._pluggables.length === 0) {
|
|
72
|
-
this.addPluggable(new AmazonLocationServiceProvider_1.AmazonLocationServiceProvider());
|
|
73
|
-
}
|
|
74
|
-
return this._config;
|
|
75
|
-
};
|
|
76
61
|
/**
|
|
77
62
|
* Get the map resources that are currently available through the provider
|
|
78
63
|
* @param {string} provider
|
|
@@ -101,11 +86,12 @@ var GeoClass = /** @class */ (function () {
|
|
|
101
86
|
*/
|
|
102
87
|
GeoClass.prototype.searchByText = function (text, options) {
|
|
103
88
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
104
|
-
var
|
|
89
|
+
var providerName, prov, error_1;
|
|
90
|
+
var _a;
|
|
105
91
|
return tslib_1.__generator(this, function (_b) {
|
|
106
92
|
switch (_b.label) {
|
|
107
93
|
case 0:
|
|
108
|
-
_a = (options || {}).providerName,
|
|
94
|
+
providerName = (_a = (options || {}).providerName, _a === void 0 ? DEFAULT_PROVIDER : _a);
|
|
109
95
|
prov = this.getPluggable(providerName);
|
|
110
96
|
_b.label = 1;
|
|
111
97
|
case 1:
|
|
@@ -129,11 +115,12 @@ var GeoClass = /** @class */ (function () {
|
|
|
129
115
|
*/
|
|
130
116
|
GeoClass.prototype.searchForSuggestions = function (text, options) {
|
|
131
117
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
132
|
-
var
|
|
118
|
+
var providerName, prov, error_2;
|
|
119
|
+
var _a;
|
|
133
120
|
return tslib_1.__generator(this, function (_b) {
|
|
134
121
|
switch (_b.label) {
|
|
135
122
|
case 0:
|
|
136
|
-
_a = (options || {}).providerName,
|
|
123
|
+
providerName = (_a = (options || {}).providerName, _a === void 0 ? DEFAULT_PROVIDER : _a);
|
|
137
124
|
prov = this.getPluggable(providerName);
|
|
138
125
|
_b.label = 1;
|
|
139
126
|
case 1:
|
|
@@ -185,17 +172,18 @@ var GeoClass = /** @class */ (function () {
|
|
|
185
172
|
*/
|
|
186
173
|
GeoClass.prototype.searchByCoordinates = function (coordinates, options) {
|
|
187
174
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
188
|
-
var
|
|
175
|
+
var providerName, prov, lng, lat, error_4;
|
|
176
|
+
var _a, _b;
|
|
189
177
|
return tslib_1.__generator(this, function (_c) {
|
|
190
178
|
switch (_c.label) {
|
|
191
179
|
case 0:
|
|
192
|
-
_a = (options || {}).providerName,
|
|
180
|
+
providerName = (_a = (options || {}).providerName, _a === void 0 ? DEFAULT_PROVIDER : _a);
|
|
193
181
|
prov = this.getPluggable(providerName);
|
|
194
|
-
_b = tslib_1.__read(coordinates, 2),
|
|
182
|
+
lng = (_b = tslib_1.__read(coordinates, 2), _b[0]), lat = _b[1];
|
|
195
183
|
_c.label = 1;
|
|
196
184
|
case 1:
|
|
197
185
|
_c.trys.push([1, 3, , 4]);
|
|
198
|
-
util_1.validateCoordinates(lng, lat);
|
|
186
|
+
(0, util_1.validateCoordinates)(lng, lat);
|
|
199
187
|
return [4 /*yield*/, prov.searchByCoordinates(coordinates, options)];
|
|
200
188
|
case 2: return [2 /*return*/, _c.sent()];
|
|
201
189
|
case 3:
|
|
@@ -217,11 +205,12 @@ var GeoClass = /** @class */ (function () {
|
|
|
217
205
|
*/
|
|
218
206
|
GeoClass.prototype.saveGeofences = function (geofences, options) {
|
|
219
207
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
220
|
-
var
|
|
208
|
+
var providerName, prov, geofenceInputArray, error_5;
|
|
209
|
+
var _a;
|
|
221
210
|
return tslib_1.__generator(this, function (_b) {
|
|
222
211
|
switch (_b.label) {
|
|
223
212
|
case 0:
|
|
224
|
-
_a = (options || {}).providerName,
|
|
213
|
+
providerName = (_a = (options || {}).providerName, _a === void 0 ? DEFAULT_PROVIDER : _a);
|
|
225
214
|
prov = this.getPluggable(providerName);
|
|
226
215
|
if (!Array.isArray(geofences)) {
|
|
227
216
|
geofenceInputArray = [geofences];
|
|
@@ -251,11 +240,12 @@ var GeoClass = /** @class */ (function () {
|
|
|
251
240
|
*/
|
|
252
241
|
GeoClass.prototype.getGeofence = function (geofenceId, options) {
|
|
253
242
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
254
|
-
var
|
|
243
|
+
var providerName, prov, error_6;
|
|
244
|
+
var _a;
|
|
255
245
|
return tslib_1.__generator(this, function (_b) {
|
|
256
246
|
switch (_b.label) {
|
|
257
247
|
case 0:
|
|
258
|
-
_a = (options || {}).providerName,
|
|
248
|
+
providerName = (_a = (options || {}).providerName, _a === void 0 ? DEFAULT_PROVIDER : _a);
|
|
259
249
|
prov = this.getPluggable(providerName);
|
|
260
250
|
_b.label = 1;
|
|
261
251
|
case 1:
|
|
@@ -280,11 +270,12 @@ var GeoClass = /** @class */ (function () {
|
|
|
280
270
|
*/
|
|
281
271
|
GeoClass.prototype.listGeofences = function (options) {
|
|
282
272
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
283
|
-
var
|
|
273
|
+
var providerName, prov, error_7;
|
|
274
|
+
var _a;
|
|
284
275
|
return tslib_1.__generator(this, function (_b) {
|
|
285
276
|
switch (_b.label) {
|
|
286
277
|
case 0:
|
|
287
|
-
_a = (options || {}).providerName,
|
|
278
|
+
providerName = (_a = (options || {}).providerName, _a === void 0 ? DEFAULT_PROVIDER : _a);
|
|
288
279
|
prov = this.getPluggable(providerName);
|
|
289
280
|
_b.label = 1;
|
|
290
281
|
case 1:
|
|
@@ -310,11 +301,12 @@ var GeoClass = /** @class */ (function () {
|
|
|
310
301
|
*/
|
|
311
302
|
GeoClass.prototype.deleteGeofences = function (geofenceIds, options) {
|
|
312
303
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
313
|
-
var
|
|
304
|
+
var providerName, prov, geofenceIdsInputArray, error_8;
|
|
305
|
+
var _a;
|
|
314
306
|
return tslib_1.__generator(this, function (_b) {
|
|
315
307
|
switch (_b.label) {
|
|
316
308
|
case 0:
|
|
317
|
-
_a = (options || {}).providerName,
|
|
309
|
+
providerName = (_a = (options || {}).providerName, _a === void 0 ? DEFAULT_PROVIDER : _a);
|
|
318
310
|
prov = this.getPluggable(providerName);
|
|
319
311
|
if (!Array.isArray(geofenceIds)) {
|
|
320
312
|
geofenceIdsInputArray = [geofenceIds];
|
|
@@ -339,7 +331,4 @@ var GeoClass = /** @class */ (function () {
|
|
|
339
331
|
GeoClass.MODULE = 'Geo';
|
|
340
332
|
return GeoClass;
|
|
341
333
|
}());
|
|
342
|
-
exports.GeoClass = GeoClass;
|
|
343
334
|
exports.Geo = new GeoClass();
|
|
344
|
-
core_1.Amplify.register(exports.Geo);
|
|
345
|
-
//# sourceMappingURL=Geo.js.map
|
package/lib/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Geo = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
3
5
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
4
6
|
// SPDX-License-Identifier: Apache-2.0
|
|
5
7
|
var Geo_1 = require("./Geo");
|
|
6
|
-
exports
|
|
7
|
-
|
|
8
|
+
Object.defineProperty(exports, "Geo", { enumerable: true, get: function () { return Geo_1.Geo; } });
|
|
9
|
+
tslib_1.__exportStar(require("./types"), exports);
|
package/{lib-esm/Providers → lib/providers/location-service}/AmazonLocationServiceProvider.d.ts
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GeoConfig, SearchByTextOptions, SearchByCoordinatesOptions, GeoProvider, Place, AmazonLocationServiceMapStyle, Coordinates, SearchForSuggestionsResults, GeofenceId, GeofenceInput, AmazonLocationServiceGeofenceOptions, AmazonLocationServiceListGeofenceOptions, ListGeofenceResults, SaveGeofencesResults, AmazonLocationServiceGeofence, AmazonLocationServiceDeleteGeofencesResults, searchByPlaceIdOptions } from '
|
|
1
|
+
import { GeoConfig, SearchByTextOptions, SearchByCoordinatesOptions, GeoProvider, Place, AmazonLocationServiceMapStyle, Coordinates, SearchForSuggestionsResults, GeofenceId, GeofenceInput, AmazonLocationServiceGeofenceOptions, AmazonLocationServiceListGeofenceOptions, ListGeofenceResults, SaveGeofencesResults, AmazonLocationServiceGeofence, AmazonLocationServiceDeleteGeofencesResults, searchByPlaceIdOptions } from '../../types';
|
|
2
2
|
export declare class AmazonLocationServiceProvider implements GeoProvider {
|
|
3
3
|
static CATEGORY: string;
|
|
4
4
|
static PROVIDER_NAME: string;
|
|
@@ -6,6 +6,7 @@ export declare class AmazonLocationServiceProvider implements GeoProvider {
|
|
|
6
6
|
* @private
|
|
7
7
|
*/
|
|
8
8
|
private _config;
|
|
9
|
+
private _credentials;
|
|
9
10
|
/**
|
|
10
11
|
* Initialize Geo with AWS configurations
|
|
11
12
|
* @param {Object} config - Configuration object for Geo
|
|
@@ -21,12 +22,6 @@ export declare class AmazonLocationServiceProvider implements GeoProvider {
|
|
|
21
22
|
* @returns {string} name of the provider
|
|
22
23
|
*/
|
|
23
24
|
getProviderName(): string;
|
|
24
|
-
/**
|
|
25
|
-
* Configure Geo part with aws configuration
|
|
26
|
-
* @param {Object} config - Configuration of the Geo
|
|
27
|
-
* @return {Object} - Current configuration
|
|
28
|
-
*/
|
|
29
|
-
configure(config?: any): object;
|
|
30
25
|
/**
|
|
31
26
|
* Get the map resources that are currently available through the provider
|
|
32
27
|
* @returns {AmazonLocationServiceMapStyle[]}- Array of available map resources
|
|
@@ -97,6 +92,7 @@ export declare class AmazonLocationServiceProvider implements GeoProvider {
|
|
|
97
92
|
* @private
|
|
98
93
|
*/
|
|
99
94
|
private _ensureCredentials;
|
|
95
|
+
private _refreshConfig;
|
|
100
96
|
private _verifyMapResources;
|
|
101
97
|
private _verifySearchIndex;
|
|
102
98
|
private _verifyGeofenceCollections;
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AmazonLocationServiceProvider = void 0;
|
|
3
4
|
var tslib_1 = require("tslib");
|
|
4
5
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
5
6
|
// SPDX-License-Identifier: Apache-2.0
|
|
6
7
|
var camelcase_keys_1 = tslib_1.__importDefault(require("camelcase-keys"));
|
|
7
8
|
var core_1 = require("@aws-amplify/core");
|
|
9
|
+
var utils_1 = require("@aws-amplify/core/internals/utils");
|
|
8
10
|
var client_location_1 = require("@aws-sdk/client-location");
|
|
9
|
-
var util_1 = require("
|
|
10
|
-
var logger = new
|
|
11
|
-
var AmazonLocationServiceProvider = /** @class */ (function () {
|
|
11
|
+
var util_1 = require("../../util");
|
|
12
|
+
var logger = new utils_1.ConsoleLogger('AmazonLocationServiceProvider');
|
|
13
|
+
var AmazonLocationServiceProvider = exports.AmazonLocationServiceProvider = /** @class */ (function () {
|
|
12
14
|
/**
|
|
13
15
|
* Initialize Geo with AWS configurations
|
|
14
16
|
* @param {Object} config - Configuration object for Geo
|
|
@@ -31,18 +33,6 @@ var AmazonLocationServiceProvider = /** @class */ (function () {
|
|
|
31
33
|
AmazonLocationServiceProvider.prototype.getProviderName = function () {
|
|
32
34
|
return AmazonLocationServiceProvider.PROVIDER_NAME;
|
|
33
35
|
};
|
|
34
|
-
/**
|
|
35
|
-
* Configure Geo part with aws configuration
|
|
36
|
-
* @param {Object} config - Configuration of the Geo
|
|
37
|
-
* @return {Object} - Current configuration
|
|
38
|
-
*/
|
|
39
|
-
AmazonLocationServiceProvider.prototype.configure = function (config) {
|
|
40
|
-
logger.debug('configure Amazon Location Service Provider', config);
|
|
41
|
-
if (!config)
|
|
42
|
-
return this._config;
|
|
43
|
-
this._config = Object.assign({}, this._config, config);
|
|
44
|
-
return this._config;
|
|
45
|
-
};
|
|
46
36
|
/**
|
|
47
37
|
* Get the map resources that are currently available through the provider
|
|
48
38
|
* @returns {AmazonLocationServiceMapStyle[]}- Array of available map resources
|
|
@@ -95,12 +85,12 @@ var AmazonLocationServiceProvider = /** @class */ (function () {
|
|
|
95
85
|
* Map search options to Amazon Location Service input object
|
|
96
86
|
*/
|
|
97
87
|
if (options) {
|
|
98
|
-
locationServiceInput = tslib_1.__assign(tslib_1.__assign({}, locationServiceInput), util_1.mapSearchOptions(options, locationServiceInput));
|
|
88
|
+
locationServiceInput = tslib_1.__assign(tslib_1.__assign({}, locationServiceInput), (0, util_1.mapSearchOptions)(options, locationServiceInput));
|
|
99
89
|
}
|
|
100
90
|
client = new client_location_1.LocationClient({
|
|
101
|
-
credentials: this.
|
|
91
|
+
credentials: this._credentials,
|
|
102
92
|
region: this._config.region,
|
|
103
|
-
customUserAgent:
|
|
93
|
+
customUserAgent: (0, utils_1.getAmplifyUserAgentObject)(),
|
|
104
94
|
});
|
|
105
95
|
command = new client_location_1.SearchPlaceIndexForTextCommand(locationServiceInput);
|
|
106
96
|
_a.label = 2;
|
|
@@ -116,7 +106,7 @@ var AmazonLocationServiceProvider = /** @class */ (function () {
|
|
|
116
106
|
throw error_1;
|
|
117
107
|
case 5:
|
|
118
108
|
PascalResults = response.Results.map(function (result) { return result.Place; });
|
|
119
|
-
results = camelcase_keys_1.default(PascalResults, {
|
|
109
|
+
results = (0, camelcase_keys_1.default)(PascalResults, {
|
|
120
110
|
deep: true,
|
|
121
111
|
});
|
|
122
112
|
return [2 /*return*/, results];
|
|
@@ -150,12 +140,12 @@ var AmazonLocationServiceProvider = /** @class */ (function () {
|
|
|
150
140
|
* Map search options to Amazon Location Service input object
|
|
151
141
|
*/
|
|
152
142
|
if (options) {
|
|
153
|
-
locationServiceInput = tslib_1.__assign(tslib_1.__assign({}, locationServiceInput), util_1.mapSearchOptions(options, locationServiceInput));
|
|
143
|
+
locationServiceInput = tslib_1.__assign(tslib_1.__assign({}, locationServiceInput), (0, util_1.mapSearchOptions)(options, locationServiceInput));
|
|
154
144
|
}
|
|
155
145
|
client = new client_location_1.LocationClient({
|
|
156
|
-
credentials: this.
|
|
146
|
+
credentials: this._credentials,
|
|
157
147
|
region: this._config.region,
|
|
158
|
-
customUserAgent:
|
|
148
|
+
customUserAgent: (0, utils_1.getAmplifyUserAgentObject)(),
|
|
159
149
|
});
|
|
160
150
|
command = new client_location_1.SearchPlaceIndexForSuggestionsCommand(locationServiceInput);
|
|
161
151
|
_a.label = 2;
|
|
@@ -200,9 +190,9 @@ var AmazonLocationServiceProvider = /** @class */ (function () {
|
|
|
200
190
|
this._verifySearchIndex(options === null || options === void 0 ? void 0 : options.searchIndexName);
|
|
201
191
|
this._verifyPlaceId(placeId);
|
|
202
192
|
client = new client_location_1.LocationClient({
|
|
203
|
-
credentials: this.
|
|
193
|
+
credentials: this._credentials,
|
|
204
194
|
region: this._config.region,
|
|
205
|
-
customUserAgent:
|
|
195
|
+
customUserAgent: (0, utils_1.getAmplifyUserAgentObject)(),
|
|
206
196
|
});
|
|
207
197
|
searchByPlaceIdInput = {
|
|
208
198
|
PlaceId: placeId,
|
|
@@ -223,7 +213,7 @@ var AmazonLocationServiceProvider = /** @class */ (function () {
|
|
|
223
213
|
case 5:
|
|
224
214
|
place = response.Place;
|
|
225
215
|
if (place) {
|
|
226
|
-
return [2 /*return*/, camelcase_keys_1.default(place, { deep: true })];
|
|
216
|
+
return [2 /*return*/, (0, camelcase_keys_1.default)(place, { deep: true })];
|
|
227
217
|
}
|
|
228
218
|
return [2 /*return*/];
|
|
229
219
|
}
|
|
@@ -259,9 +249,9 @@ var AmazonLocationServiceProvider = /** @class */ (function () {
|
|
|
259
249
|
locationServiceInput.MaxResults = options.maxResults;
|
|
260
250
|
}
|
|
261
251
|
client = new client_location_1.LocationClient({
|
|
262
|
-
credentials: this.
|
|
252
|
+
credentials: this._credentials,
|
|
263
253
|
region: this._config.region,
|
|
264
|
-
customUserAgent:
|
|
254
|
+
customUserAgent: (0, utils_1.getAmplifyUserAgentObject)(),
|
|
265
255
|
});
|
|
266
256
|
command = new client_location_1.SearchPlaceIndexForPositionCommand(locationServiceInput);
|
|
267
257
|
_a.label = 2;
|
|
@@ -277,7 +267,7 @@ var AmazonLocationServiceProvider = /** @class */ (function () {
|
|
|
277
267
|
throw error_4;
|
|
278
268
|
case 5:
|
|
279
269
|
PascalResults = response.Results.map(function (result) { return result.Place; });
|
|
280
|
-
results = camelcase_keys_1.default(PascalResults[0], {
|
|
270
|
+
results = (0, camelcase_keys_1.default)(PascalResults[0], {
|
|
281
271
|
deep: true,
|
|
282
272
|
});
|
|
283
273
|
return [2 /*return*/, results];
|
|
@@ -317,7 +307,7 @@ var AmazonLocationServiceProvider = /** @class */ (function () {
|
|
|
317
307
|
logger.debug(error);
|
|
318
308
|
throw error;
|
|
319
309
|
}
|
|
320
|
-
util_1.validateGeofencesInput(geofences);
|
|
310
|
+
(0, util_1.validateGeofencesInput)(geofences);
|
|
321
311
|
PascalGeofences = geofences.map(function (_a) {
|
|
322
312
|
var geofenceId = _a.geofenceId, polygon = _a.geometry.polygon;
|
|
323
313
|
return {
|
|
@@ -338,16 +328,17 @@ var AmazonLocationServiceProvider = /** @class */ (function () {
|
|
|
338
328
|
}
|
|
339
329
|
return [4 /*yield*/, Promise.all(geofenceBatches.map(function (batch) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
340
330
|
var response, error_5;
|
|
341
|
-
|
|
342
|
-
|
|
331
|
+
var _a, _b;
|
|
332
|
+
return tslib_1.__generator(this, function (_c) {
|
|
333
|
+
switch (_c.label) {
|
|
343
334
|
case 0:
|
|
344
|
-
|
|
335
|
+
_c.trys.push([0, 2, , 3]);
|
|
345
336
|
return [4 /*yield*/, this._AmazonLocationServiceBatchPutGeofenceCall(batch, (options === null || options === void 0 ? void 0 : options.collectionName) || this._config.geofenceCollections.default)];
|
|
346
337
|
case 1:
|
|
347
|
-
response =
|
|
338
|
+
response = _c.sent();
|
|
348
339
|
return [3 /*break*/, 3];
|
|
349
340
|
case 2:
|
|
350
|
-
error_5 =
|
|
341
|
+
error_5 = _c.sent();
|
|
351
342
|
// If the API call fails, add the geofences to the errors array and move to next batch
|
|
352
343
|
batch.forEach(function (geofence) {
|
|
353
344
|
results.errors.push({
|
|
@@ -361,7 +352,7 @@ var AmazonLocationServiceProvider = /** @class */ (function () {
|
|
|
361
352
|
return [2 /*return*/];
|
|
362
353
|
case 3:
|
|
363
354
|
// Push all successes to results
|
|
364
|
-
response.Successes.forEach(function (success) {
|
|
355
|
+
(_a = response.Successes) === null || _a === void 0 ? void 0 : _a.forEach(function (success) {
|
|
365
356
|
var GeofenceId = success.GeofenceId, CreateTime = success.CreateTime, UpdateTime = success.UpdateTime;
|
|
366
357
|
results.successes.push({
|
|
367
358
|
geofenceId: GeofenceId,
|
|
@@ -370,8 +361,10 @@ var AmazonLocationServiceProvider = /** @class */ (function () {
|
|
|
370
361
|
});
|
|
371
362
|
});
|
|
372
363
|
// Push all errors to results
|
|
373
|
-
response.Errors.forEach(function (error) {
|
|
374
|
-
var _a
|
|
364
|
+
(_b = response.Errors) === null || _b === void 0 ? void 0 : _b.forEach(function (error) {
|
|
365
|
+
var _a;
|
|
366
|
+
var Error = error.Error, GeofenceId = error.GeofenceId;
|
|
367
|
+
var Code = (_a = Error, _a.Code), Message = _a.Message;
|
|
375
368
|
results.errors.push({
|
|
376
369
|
error: {
|
|
377
370
|
code: Code,
|
|
@@ -416,11 +409,11 @@ var AmazonLocationServiceProvider = /** @class */ (function () {
|
|
|
416
409
|
logger.debug(error);
|
|
417
410
|
throw error;
|
|
418
411
|
}
|
|
419
|
-
util_1.validateGeofenceId(geofenceId);
|
|
412
|
+
(0, util_1.validateGeofenceId)(geofenceId);
|
|
420
413
|
client = new client_location_1.LocationClient({
|
|
421
|
-
credentials: this.
|
|
414
|
+
credentials: this._credentials,
|
|
422
415
|
region: this._config.region,
|
|
423
|
-
customUserAgent:
|
|
416
|
+
customUserAgent: (0, utils_1.getAmplifyUserAgentObject)(),
|
|
424
417
|
});
|
|
425
418
|
commandInput = {
|
|
426
419
|
GeofenceId: geofenceId,
|
|
@@ -481,9 +474,9 @@ var AmazonLocationServiceProvider = /** @class */ (function () {
|
|
|
481
474
|
throw error;
|
|
482
475
|
}
|
|
483
476
|
client = new client_location_1.LocationClient({
|
|
484
|
-
credentials: this.
|
|
477
|
+
credentials: this._credentials,
|
|
485
478
|
region: this._config.region,
|
|
486
|
-
customUserAgent:
|
|
479
|
+
customUserAgent: (0, utils_1.getAmplifyUserAgentObject)(),
|
|
487
480
|
});
|
|
488
481
|
listGeofencesInput = {
|
|
489
482
|
NextToken: options === null || options === void 0 ? void 0 : options.nextToken,
|
|
@@ -505,14 +498,14 @@ var AmazonLocationServiceProvider = /** @class */ (function () {
|
|
|
505
498
|
NextToken = response.NextToken, Entries = response.Entries;
|
|
506
499
|
results = {
|
|
507
500
|
entries: Entries.map(function (_a) {
|
|
508
|
-
var GeofenceId = _a.GeofenceId, CreateTime = _a.CreateTime, UpdateTime = _a.UpdateTime, Status = _a.Status,
|
|
501
|
+
var GeofenceId = _a.GeofenceId, CreateTime = _a.CreateTime, UpdateTime = _a.UpdateTime, Status = _a.Status, Geometry = _a.Geometry;
|
|
509
502
|
return {
|
|
510
503
|
geofenceId: GeofenceId,
|
|
511
504
|
createTime: CreateTime,
|
|
512
505
|
updateTime: UpdateTime,
|
|
513
506
|
status: Status,
|
|
514
507
|
geometry: {
|
|
515
|
-
polygon: Polygon,
|
|
508
|
+
polygon: Geometry.Polygon,
|
|
516
509
|
},
|
|
517
510
|
};
|
|
518
511
|
}),
|
|
@@ -550,14 +543,14 @@ var AmazonLocationServiceProvider = /** @class */ (function () {
|
|
|
550
543
|
this._verifyGeofenceCollections(options === null || options === void 0 ? void 0 : options.collectionName);
|
|
551
544
|
badGeofenceIds = geofenceIds.filter(function (geofenceId) {
|
|
552
545
|
try {
|
|
553
|
-
util_1.validateGeofenceId(geofenceId);
|
|
546
|
+
(0, util_1.validateGeofenceId)(geofenceId);
|
|
554
547
|
}
|
|
555
548
|
catch (error) {
|
|
556
549
|
return true;
|
|
557
550
|
}
|
|
558
551
|
});
|
|
559
552
|
if (badGeofenceIds.length > 0) {
|
|
560
|
-
throw new Error("Invalid geofence ids: "
|
|
553
|
+
throw new Error("Invalid geofence ids: ".concat(badGeofenceIds.join(', ')));
|
|
561
554
|
}
|
|
562
555
|
results = {
|
|
563
556
|
successes: [],
|
|
@@ -586,8 +579,10 @@ var AmazonLocationServiceProvider = /** @class */ (function () {
|
|
|
586
579
|
var errorObject = {
|
|
587
580
|
geofenceId: geofenceId,
|
|
588
581
|
error: {
|
|
589
|
-
code: error_8
|
|
590
|
-
|
|
582
|
+
code: error_8
|
|
583
|
+
.message,
|
|
584
|
+
message: error_8
|
|
585
|
+
.message,
|
|
591
586
|
},
|
|
592
587
|
};
|
|
593
588
|
results.errors.push(errorObject);
|
|
@@ -598,7 +593,7 @@ var AmazonLocationServiceProvider = /** @class */ (function () {
|
|
|
598
593
|
var geofenceId = _a.geofenceId;
|
|
599
594
|
return geofenceId;
|
|
600
595
|
});
|
|
601
|
-
(_a = results.successes).push.apply(_a, tslib_1.
|
|
596
|
+
(_a = results.successes).push.apply(_a, tslib_1.__spreadArray([], tslib_1.__read(batch.filter(function (Id) { return !badGeofenceIds.includes(Id); })), false));
|
|
602
597
|
return [2 /*return*/];
|
|
603
598
|
}
|
|
604
599
|
});
|
|
@@ -615,19 +610,18 @@ var AmazonLocationServiceProvider = /** @class */ (function () {
|
|
|
615
610
|
*/
|
|
616
611
|
AmazonLocationServiceProvider.prototype._ensureCredentials = function () {
|
|
617
612
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
618
|
-
var credentials,
|
|
613
|
+
var credentials, error_9;
|
|
619
614
|
return tslib_1.__generator(this, function (_a) {
|
|
620
615
|
switch (_a.label) {
|
|
621
616
|
case 0:
|
|
622
617
|
_a.trys.push([0, 2, , 3]);
|
|
623
|
-
return [4 /*yield*/, core_1.
|
|
618
|
+
return [4 /*yield*/, (0, core_1.fetchAuthSession)()];
|
|
624
619
|
case 1:
|
|
625
|
-
credentials = _a.sent();
|
|
620
|
+
credentials = (_a.sent()).credentials;
|
|
626
621
|
if (!credentials)
|
|
627
622
|
return [2 /*return*/, false];
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
this._config.credentials = cred;
|
|
623
|
+
logger.debug('Set credentials for storage. Credentials are:', credentials);
|
|
624
|
+
this._credentials = credentials;
|
|
631
625
|
return [2 /*return*/, true];
|
|
632
626
|
case 2:
|
|
633
627
|
error_9 = _a.sent();
|
|
@@ -638,7 +632,17 @@ var AmazonLocationServiceProvider = /** @class */ (function () {
|
|
|
638
632
|
});
|
|
639
633
|
});
|
|
640
634
|
};
|
|
635
|
+
AmazonLocationServiceProvider.prototype._refreshConfig = function () {
|
|
636
|
+
var _a;
|
|
637
|
+
this._config = (_a = core_1.Amplify.getConfig().Geo) === null || _a === void 0 ? void 0 : _a.LocationService;
|
|
638
|
+
if (!this._config) {
|
|
639
|
+
var errorString = "No Geo configuration found in amplify config, run 'amplify add geo' to create one and run `amplify push` after";
|
|
640
|
+
logger.debug(errorString);
|
|
641
|
+
throw new Error(errorString);
|
|
642
|
+
}
|
|
643
|
+
};
|
|
641
644
|
AmazonLocationServiceProvider.prototype._verifyMapResources = function () {
|
|
645
|
+
this._refreshConfig();
|
|
642
646
|
if (!this._config.maps) {
|
|
643
647
|
var errorString = "No map resources found in amplify config, run 'amplify add geo' to create one and run `amplify push` after";
|
|
644
648
|
logger.debug(errorString);
|
|
@@ -651,7 +655,8 @@ var AmazonLocationServiceProvider = /** @class */ (function () {
|
|
|
651
655
|
}
|
|
652
656
|
};
|
|
653
657
|
AmazonLocationServiceProvider.prototype._verifySearchIndex = function (optionalSearchIndex) {
|
|
654
|
-
|
|
658
|
+
this._refreshConfig();
|
|
659
|
+
if ((!this._config.searchIndices || !this._config.searchIndices.default) &&
|
|
655
660
|
!optionalSearchIndex) {
|
|
656
661
|
var errorString = 'No Search Index found in amplify config, please run `amplify add geo` to create one and run `amplify push` after.';
|
|
657
662
|
logger.debug(errorString);
|
|
@@ -659,6 +664,7 @@ var AmazonLocationServiceProvider = /** @class */ (function () {
|
|
|
659
664
|
}
|
|
660
665
|
};
|
|
661
666
|
AmazonLocationServiceProvider.prototype._verifyGeofenceCollections = function (optionalGeofenceCollectionName) {
|
|
667
|
+
this._refreshConfig();
|
|
662
668
|
if ((!this._config.geofenceCollections ||
|
|
663
669
|
!this._config.geofenceCollections.default) &&
|
|
664
670
|
!optionalGeofenceCollectionName) {
|
|
@@ -678,9 +684,9 @@ var AmazonLocationServiceProvider = /** @class */ (function () {
|
|
|
678
684
|
CollectionName: collectionName || this._config.geofenceCollections.default,
|
|
679
685
|
};
|
|
680
686
|
client = new client_location_1.LocationClient({
|
|
681
|
-
credentials: this.
|
|
687
|
+
credentials: this._credentials,
|
|
682
688
|
region: this._config.region,
|
|
683
|
-
customUserAgent:
|
|
689
|
+
customUserAgent: (0, utils_1.getAmplifyUserAgentObject)(),
|
|
684
690
|
});
|
|
685
691
|
command = new client_location_1.BatchPutGeofenceCommand(geofenceInput);
|
|
686
692
|
_a.label = 1;
|
|
@@ -709,9 +715,9 @@ var AmazonLocationServiceProvider = /** @class */ (function () {
|
|
|
709
715
|
CollectionName: collectionName || this._config.geofenceCollections.default,
|
|
710
716
|
};
|
|
711
717
|
client = new client_location_1.LocationClient({
|
|
712
|
-
credentials: this.
|
|
718
|
+
credentials: this._credentials,
|
|
713
719
|
region: this._config.region,
|
|
714
|
-
customUserAgent:
|
|
720
|
+
customUserAgent: (0, utils_1.getAmplifyUserAgentObject)(),
|
|
715
721
|
});
|
|
716
722
|
command = new client_location_1.BatchDeleteGeofenceCommand(deleteGeofencesInput);
|
|
717
723
|
_a.label = 1;
|
|
@@ -733,5 +739,3 @@ var AmazonLocationServiceProvider = /** @class */ (function () {
|
|
|
733
739
|
AmazonLocationServiceProvider.PROVIDER_NAME = 'AmazonLocationService';
|
|
734
740
|
return AmazonLocationServiceProvider;
|
|
735
741
|
}());
|
|
736
|
-
exports.AmazonLocationServiceProvider = AmazonLocationServiceProvider;
|
|
737
|
-
//# sourceMappingURL=AmazonLocationServiceProvider.js.map
|