@aws-amplify/geo 3.0.17 → 3.0.18-experimental-lerna-test.d2b0b08.55
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 +1 -0
- package/dist/cjs/Geo.js +23 -24
- package/dist/cjs/Geo.js.map +1 -1
- package/dist/cjs/providers/location-service/AmazonLocationServiceProvider.js +35 -49
- package/dist/cjs/providers/location-service/AmazonLocationServiceProvider.js.map +1 -1
- package/dist/cjs/util.js +7 -7
- package/dist/cjs/util.js.map +1 -1
- package/dist/esm/Geo.d.ts +22 -22
- package/dist/esm/Geo.mjs +23 -24
- package/dist/esm/Geo.mjs.map +1 -1
- package/dist/esm/providers/location-service/AmazonLocationServiceProvider.d.ts +17 -17
- package/dist/esm/providers/location-service/AmazonLocationServiceProvider.mjs +35 -49
- package/dist/esm/providers/location-service/AmazonLocationServiceProvider.mjs.map +1 -1
- package/dist/esm/types/AmazonLocationServiceProvider.d.ts +1 -1
- package/dist/esm/types/Geo.d.ts +24 -24
- package/dist/esm/types/Provider.d.ts +1 -1
- package/dist/esm/util.d.ts +1 -1
- package/dist/esm/util.mjs +7 -7
- package/dist/esm/util.mjs.map +1 -1
- package/package.json +89 -88
- package/src/Geo.ts +34 -34
- package/src/providers/location-service/AmazonLocationServiceProvider.ts +82 -78
- package/src/types/AmazonLocationServiceProvider.ts +4 -4
- package/src/types/Geo.ts +24 -24
- package/src/types/Provider.ts +6 -6
- package/src/util.ts +10 -9
package/dist/cjs/util.js
CHANGED
|
@@ -11,10 +11,10 @@ function validateCoordinates(lng, lat) {
|
|
|
11
11
|
if (!Number.isFinite(lng) || !Number.isFinite(lat)) {
|
|
12
12
|
throw new Error(`Invalid coordinates: [${lng},${lat}]`);
|
|
13
13
|
}
|
|
14
|
-
if (lat < -90 ||
|
|
14
|
+
if (lat < -90 || lat > 90) {
|
|
15
15
|
throw new Error('Latitude must be between -90 and 90 degrees inclusive.');
|
|
16
16
|
}
|
|
17
|
-
else if (lng < -180 ||
|
|
17
|
+
else if (lng < -180 || lng > 180) {
|
|
18
18
|
throw new Error('Longitude must be between -180 and 180 degrees inclusive.');
|
|
19
19
|
}
|
|
20
20
|
}
|
|
@@ -127,14 +127,14 @@ function mapSearchOptions(options, locationServiceInput) {
|
|
|
127
127
|
if (options.searchIndexName) {
|
|
128
128
|
locationServiceModifiedInput.IndexName = options.searchIndexName;
|
|
129
129
|
}
|
|
130
|
-
if (options
|
|
130
|
+
if (options.biasPosition && options.searchAreaConstraints) {
|
|
131
131
|
throw new Error('BiasPosition and SearchAreaConstraints are mutually exclusive, please remove one or the other from the options object');
|
|
132
132
|
}
|
|
133
|
-
if (options
|
|
134
|
-
locationServiceModifiedInput.BiasPosition = options
|
|
133
|
+
if (options.biasPosition) {
|
|
134
|
+
locationServiceModifiedInput.BiasPosition = options.biasPosition;
|
|
135
135
|
}
|
|
136
|
-
if (options
|
|
137
|
-
locationServiceModifiedInput.FilterBBox = options
|
|
136
|
+
if (options.searchAreaConstraints) {
|
|
137
|
+
locationServiceModifiedInput.FilterBBox = options.searchAreaConstraints;
|
|
138
138
|
}
|
|
139
139
|
return locationServiceModifiedInput;
|
|
140
140
|
}
|
package/dist/cjs/util.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.js","sources":["../../src/util.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.getGeoUserAgentString = exports.getGeoUserAgent = exports.mapSearchOptions = exports.validateGeofencesInput = exports.validatePolygon = exports.validateLinearRing = exports.validateGeofenceId = exports.validateCoordinates = void 0;\nconst tslib_1 = require(\"tslib\");\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nconst boolean_clockwise_1 = tslib_1.__importDefault(require(\"@turf/boolean-clockwise\"));\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nfunction validateCoordinates(lng, lat) {\n if (!Number.isFinite(lng) || !Number.isFinite(lat)) {\n throw new Error(`Invalid coordinates: [${lng},${lat}]`);\n }\n if (lat < -90 || 90 < lat) {\n throw new Error('Latitude must be between -90 and 90 degrees inclusive.');\n }\n else if (lng < -180 || 180 < lng) {\n throw new Error('Longitude must be between -180 and 180 degrees inclusive.');\n }\n}\nexports.validateCoordinates = validateCoordinates;\nfunction validateGeofenceId(geofenceId) {\n const geofenceIdRegex = /^[-._\\p{L}\\p{N}]+$/iu;\n // Check if geofenceId is valid\n if (!geofenceIdRegex.test(geofenceId)) {\n throw new Error(`Invalid geofenceId: '${geofenceId}' - IDs can only contain alphanumeric characters, hyphens, underscores and periods.`);\n }\n}\nexports.validateGeofenceId = validateGeofenceId;\nfunction validateLinearRing(linearRing, geofenceId) {\n const errorPrefix = geofenceId ? `${geofenceId}: ` : '';\n // Validate LinearRing size, must be at least 4 points\n if (linearRing.length < 4) {\n throw new Error(`${errorPrefix}LinearRing must contain 4 or more coordinates.`);\n }\n // Validate all coordinates are valid, error with which ones are bad\n const badCoordinates = [];\n linearRing.forEach(coordinates => {\n try {\n validateCoordinates(coordinates[0], coordinates[1]);\n }\n catch (error) {\n badCoordinates.push({ coordinates, error: error.message });\n }\n });\n if (badCoordinates.length > 0) {\n throw new Error(`${errorPrefix}One or more of the coordinates in the Polygon LinearRing are not valid: ${JSON.stringify(badCoordinates)}`);\n }\n // Validate first and last coordinates are the same\n const [lngA, latA] = linearRing[0];\n const [lngB, latB] = linearRing[linearRing.length - 1];\n if (lngA !== lngB || latA !== latB) {\n throw new Error(`${errorPrefix}LinearRing's first and last coordinates are not the same`);\n }\n if ((0, boolean_clockwise_1.default)(linearRing)) {\n throw new Error(`${errorPrefix}LinearRing coordinates must be wound counterclockwise`);\n }\n}\nexports.validateLinearRing = validateLinearRing;\nfunction validatePolygon(polygon, geofenceId) {\n const errorPrefix = geofenceId ? `${geofenceId}: ` : '';\n if (!Array.isArray(polygon)) {\n throw new Error(`${errorPrefix}Polygon is of incorrect structure. It should be an array of LinearRings`);\n }\n if (polygon.length < 1) {\n throw new Error(`${errorPrefix}Polygon must have a single LinearRing array.`);\n }\n if (polygon.length > 1) {\n throw new Error(`${errorPrefix}Polygon must have a single LinearRing array. Note: We do not currently support polygons with holes, multipolygons, polygons that are wound clockwise, or that cross the antimeridian.`);\n }\n const verticesCount = polygon.reduce((prev, linearRing) => prev + linearRing.length, 0);\n if (verticesCount > 1000) {\n throw new Error(`${errorPrefix}Polygon has more than the maximum 1000 vertices.`);\n }\n polygon.forEach(linearRing => {\n validateLinearRing(linearRing, geofenceId);\n });\n}\nexports.validatePolygon = validatePolygon;\nfunction validateGeofencesInput(geofences) {\n const geofenceIds = {};\n geofences.forEach((geofence) => {\n // verify all required properties are present\n // Validate geofenceId exists\n if (!geofence.geofenceId) {\n throw new Error(`Geofence '${geofence}' is missing geofenceId`);\n }\n const { geofenceId } = geofence;\n validateGeofenceId(geofenceId);\n // Validate geofenceId is unique\n if (geofenceIds[geofenceId]) {\n throw new Error(`Duplicate geofenceId: ${geofenceId}`);\n }\n else {\n geofenceIds[geofenceId] = true;\n }\n // Validate geometry exists\n if (!geofence.geometry) {\n throw new Error(`Geofence '${geofenceId}' is missing geometry`);\n }\n const { geometry } = geofence;\n // Validate polygon exists\n if (!geometry.polygon) {\n throw new Error(`Geofence '${geofenceId}' is missing geometry.polygon`);\n }\n const { polygon } = geometry;\n // Validate polygon length and structure\n try {\n validatePolygon(polygon, geofenceId);\n }\n catch (error) {\n if (error.message.includes('Polygon has more than the maximum 1000 vertices.')) {\n throw new Error(`Geofence '${geofenceId}' has more than the maximum of 1000 vertices`);\n }\n }\n // Validate LinearRing length, structure, and coordinates\n const [linearRing] = polygon;\n validateLinearRing(linearRing, geofenceId);\n });\n}\nexports.validateGeofencesInput = validateGeofencesInput;\nfunction mapSearchOptions(options, locationServiceInput) {\n const locationServiceModifiedInput = { ...locationServiceInput };\n locationServiceModifiedInput.FilterCountries = options.countries;\n locationServiceModifiedInput.MaxResults = options.maxResults;\n locationServiceModifiedInput.Language = options.language;\n if (options.searchIndexName) {\n locationServiceModifiedInput.IndexName = options.searchIndexName;\n }\n if (options['biasPosition'] && options['searchAreaConstraints']) {\n throw new Error('BiasPosition and SearchAreaConstraints are mutually exclusive, please remove one or the other from the options object');\n }\n if (options['biasPosition']) {\n locationServiceModifiedInput.BiasPosition = options['biasPosition'];\n }\n if (options['searchAreaConstraints']) {\n locationServiceModifiedInput.FilterBBox = options['searchAreaConstraints'];\n }\n return locationServiceModifiedInput;\n}\nexports.mapSearchOptions = mapSearchOptions;\nfunction getGeoUserAgent(action) {\n return (0, utils_1.getAmplifyUserAgentObject)({\n category: utils_1.Category.Geo,\n action,\n });\n}\nexports.getGeoUserAgent = getGeoUserAgent;\nfunction getGeoUserAgentString(action) {\n return (0, utils_1.getAmplifyUserAgent)({\n category: utils_1.Category.Geo,\n action,\n });\n}\nexports.getGeoUserAgentString = getGeoUserAgentString;\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,qBAAqB,GAAG,OAAO,CAAC,eAAe,GAAG,OAAO,CAAC,gBAAgB,GAAG,OAAO,CAAC,sBAAsB,GAAG,OAAO,CAAC,eAAe,GAAG,OAAO,CAAC,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,GAAG,OAAO,CAAC,mBAAmB,GAAG,KAAK,CAAC,CAAC;AAC/O,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AACjC;AACA;AACA,MAAM,mBAAmB,GAAG,OAAO,CAAC,eAAe,CAAC,OAAO,CAAC,yBAAyB,CAAC,CAAC,CAAC;AACxF,MAAM,OAAO,GAAG,OAAO,CAAC,mCAAmC,CAAC,CAAC;AAC7D,SAAS,mBAAmB,CAAC,GAAG,EAAE,GAAG,EAAE;AACvC,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,GAA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,GAAG,eAAe,CAAC;AAC1C,SAAS,qBAAqB,CAAC,MAAM,EAAE;AACvC,IAAI,OAAO,IAAI,OAAO,CAAC,mBAAmB,EAAE;AAC5C,QAAQ,QAAQ,EAAE,OAAO,CAAC,QAAQ,CAAC,GAAG;AACtC,QAAQ,MAAM;AACd,KAAK,CAAC,CAAC;AACP,CAAC;AACD,OAAO,CAAC,qBAAqB,GAAG,qBAAqB;;"}
|
|
1
|
+
{"version":3,"file":"util.js","sources":["../../src/util.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.getGeoUserAgentString = exports.getGeoUserAgent = exports.mapSearchOptions = exports.validateGeofencesInput = exports.validatePolygon = exports.validateLinearRing = exports.validateGeofenceId = exports.validateCoordinates = void 0;\nconst tslib_1 = require(\"tslib\");\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nconst boolean_clockwise_1 = tslib_1.__importDefault(require(\"@turf/boolean-clockwise\"));\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nfunction validateCoordinates(lng, lat) {\n if (!Number.isFinite(lng) || !Number.isFinite(lat)) {\n throw new Error(`Invalid coordinates: [${lng},${lat}]`);\n }\n if (lat < -90 || lat > 90) {\n throw new Error('Latitude must be between -90 and 90 degrees inclusive.');\n }\n else if (lng < -180 || lng > 180) {\n throw new Error('Longitude must be between -180 and 180 degrees inclusive.');\n }\n}\nexports.validateCoordinates = validateCoordinates;\nfunction validateGeofenceId(geofenceId) {\n const geofenceIdRegex = /^[-._\\p{L}\\p{N}]+$/iu;\n // Check if geofenceId is valid\n if (!geofenceIdRegex.test(geofenceId)) {\n throw new Error(`Invalid geofenceId: '${geofenceId}' - IDs can only contain alphanumeric characters, hyphens, underscores and periods.`);\n }\n}\nexports.validateGeofenceId = validateGeofenceId;\nfunction validateLinearRing(linearRing, geofenceId) {\n const errorPrefix = geofenceId ? `${geofenceId}: ` : '';\n // Validate LinearRing size, must be at least 4 points\n if (linearRing.length < 4) {\n throw new Error(`${errorPrefix}LinearRing must contain 4 or more coordinates.`);\n }\n // Validate all coordinates are valid, error with which ones are bad\n const badCoordinates = [];\n linearRing.forEach(coordinates => {\n try {\n validateCoordinates(coordinates[0], coordinates[1]);\n }\n catch (error) {\n badCoordinates.push({ coordinates, error: error.message });\n }\n });\n if (badCoordinates.length > 0) {\n throw new Error(`${errorPrefix}One or more of the coordinates in the Polygon LinearRing are not valid: ${JSON.stringify(badCoordinates)}`);\n }\n // Validate first and last coordinates are the same\n const [lngA, latA] = linearRing[0];\n const [lngB, latB] = linearRing[linearRing.length - 1];\n if (lngA !== lngB || latA !== latB) {\n throw new Error(`${errorPrefix}LinearRing's first and last coordinates are not the same`);\n }\n if ((0, boolean_clockwise_1.default)(linearRing)) {\n throw new Error(`${errorPrefix}LinearRing coordinates must be wound counterclockwise`);\n }\n}\nexports.validateLinearRing = validateLinearRing;\nfunction validatePolygon(polygon, geofenceId) {\n const errorPrefix = geofenceId ? `${geofenceId}: ` : '';\n if (!Array.isArray(polygon)) {\n throw new Error(`${errorPrefix}Polygon is of incorrect structure. It should be an array of LinearRings`);\n }\n if (polygon.length < 1) {\n throw new Error(`${errorPrefix}Polygon must have a single LinearRing array.`);\n }\n if (polygon.length > 1) {\n throw new Error(`${errorPrefix}Polygon must have a single LinearRing array. Note: We do not currently support polygons with holes, multipolygons, polygons that are wound clockwise, or that cross the antimeridian.`);\n }\n const verticesCount = polygon.reduce((prev, linearRing) => prev + linearRing.length, 0);\n if (verticesCount > 1000) {\n throw new Error(`${errorPrefix}Polygon has more than the maximum 1000 vertices.`);\n }\n polygon.forEach(linearRing => {\n validateLinearRing(linearRing, geofenceId);\n });\n}\nexports.validatePolygon = validatePolygon;\nfunction validateGeofencesInput(geofences) {\n const geofenceIds = {};\n geofences.forEach((geofence) => {\n // verify all required properties are present\n // Validate geofenceId exists\n if (!geofence.geofenceId) {\n throw new Error(`Geofence '${geofence}' is missing geofenceId`);\n }\n const { geofenceId } = geofence;\n validateGeofenceId(geofenceId);\n // Validate geofenceId is unique\n if (geofenceIds[geofenceId]) {\n throw new Error(`Duplicate geofenceId: ${geofenceId}`);\n }\n else {\n geofenceIds[geofenceId] = true;\n }\n // Validate geometry exists\n if (!geofence.geometry) {\n throw new Error(`Geofence '${geofenceId}' is missing geometry`);\n }\n const { geometry } = geofence;\n // Validate polygon exists\n if (!geometry.polygon) {\n throw new Error(`Geofence '${geofenceId}' is missing geometry.polygon`);\n }\n const { polygon } = geometry;\n // Validate polygon length and structure\n try {\n validatePolygon(polygon, geofenceId);\n }\n catch (error) {\n if (error.message.includes('Polygon has more than the maximum 1000 vertices.')) {\n throw new Error(`Geofence '${geofenceId}' has more than the maximum of 1000 vertices`);\n }\n }\n // Validate LinearRing length, structure, and coordinates\n const [linearRing] = polygon;\n validateLinearRing(linearRing, geofenceId);\n });\n}\nexports.validateGeofencesInput = validateGeofencesInput;\nfunction mapSearchOptions(options, locationServiceInput) {\n const locationServiceModifiedInput = { ...locationServiceInput };\n locationServiceModifiedInput.FilterCountries = options.countries;\n locationServiceModifiedInput.MaxResults = options.maxResults;\n locationServiceModifiedInput.Language = options.language;\n if (options.searchIndexName) {\n locationServiceModifiedInput.IndexName = options.searchIndexName;\n }\n if (options.biasPosition && options.searchAreaConstraints) {\n throw new Error('BiasPosition and SearchAreaConstraints are mutually exclusive, please remove one or the other from the options object');\n }\n if (options.biasPosition) {\n locationServiceModifiedInput.BiasPosition = options.biasPosition;\n }\n if (options.searchAreaConstraints) {\n locationServiceModifiedInput.FilterBBox = options.searchAreaConstraints;\n }\n return locationServiceModifiedInput;\n}\nexports.mapSearchOptions = mapSearchOptions;\nfunction getGeoUserAgent(action) {\n return (0, utils_1.getAmplifyUserAgentObject)({\n category: utils_1.Category.Geo,\n action,\n });\n}\nexports.getGeoUserAgent = getGeoUserAgent;\nfunction getGeoUserAgentString(action) {\n return (0, utils_1.getAmplifyUserAgent)({\n category: utils_1.Category.Geo,\n action,\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AAC,YAAY,IAAI,OAAO,CAAC,qBAAqB,EAAE;AAC/D,QAAQ,MAAM,IAAI,KAAK,CAAC,uHAAuH,CAAC,CAAC;AACjJ,KAAK;AACL,IAAI,IAAI,OAAO,CAAC,YAAY,EAAE;AAC9B,QAAQ,4BAA4B,CAAC,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC;AACzE,KAAK;AACL,IAAI,IAAI,OAAO,CAAC,qBAAqB,EAAE;AACvC,QAAQ,4BAA4B,CAAC,UAAU,GAAG,OAAO,CAAC,qBAAqB,CAAC;AAChF,KAAK;AACL,IAAI,OAAO,4BAA4B,CAAC;AACxC,CAAC;AACD,OAAO,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;AAC5C,SAAS,eAAe,CAAC,MAAM,EAAE;AACjC,IAAI,OAAO,IAAI,OAAO,CAAC,yBAAyB,EAAE;AAClD,QAAQ,QAAQ,EAAE,OAAO,CAAC,QAAQ,CAAC,GAAG;AACtC,QAAQ,MAAM;AACd,KAAK,CAAC,CAAC;AACP,CAAC;AACD,OAAO,CAAC,eAAe,GAAG,eAAe,CAAC;AAC1C,SAAS,qBAAqB,CAAC,MAAM,EAAE;AACvC,IAAI,OAAO,IAAI,OAAO,CAAC,mBAAmB,EAAE;AAC5C,QAAQ,QAAQ,EAAE,OAAO,CAAC,QAAQ,CAAC,GAAG;AACtC,QAAQ,MAAM;AACd,KAAK,CAAC,CAAC;AACP,CAAC;AACD,OAAO,CAAC,qBAAqB,GAAG,qBAAqB;;"}
|
package/dist/esm/Geo.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Coordinates, DeleteGeofencesResults, GeoProvider, Geofence, GeofenceId, GeofenceInput, GeofenceOptions, ListGeofenceOptions, ListGeofenceResults, MapStyle, Place, SaveGeofencesResults, SearchByCoordinatesOptions, SearchByTextOptions, SearchForSuggestionsResults, searchByPlaceIdOptions } from './types';
|
|
2
2
|
export declare class GeoClass {
|
|
3
3
|
static MODULE: string;
|
|
4
4
|
/**
|
|
@@ -14,17 +14,17 @@ export declare class GeoClass {
|
|
|
14
14
|
getModuleName(): string;
|
|
15
15
|
/**
|
|
16
16
|
* add plugin into Geo category
|
|
17
|
-
* @param {Object} pluggable
|
|
17
|
+
* @param {Object} pluggable an instance of the plugin
|
|
18
18
|
*/
|
|
19
19
|
addPluggable(pluggable: GeoProvider): void;
|
|
20
20
|
/**
|
|
21
21
|
* Get the plugin object
|
|
22
|
-
* @param providerName
|
|
22
|
+
* @param providerName the name of the plugin
|
|
23
23
|
*/
|
|
24
24
|
getPluggable(providerName: string): GeoProvider;
|
|
25
25
|
/**
|
|
26
26
|
* Remove the plugin object
|
|
27
|
-
* @param providerName
|
|
27
|
+
* @param providerName the name of the plugin
|
|
28
28
|
*/
|
|
29
29
|
removePluggable(providerName: string): void;
|
|
30
30
|
/**
|
|
@@ -41,36 +41,36 @@ export declare class GeoClass {
|
|
|
41
41
|
getDefaultMap(provider?: string): MapStyle;
|
|
42
42
|
/**
|
|
43
43
|
* Search by text input with optional parameters
|
|
44
|
-
* @param {string} text
|
|
45
|
-
* @param {SearchByTextOptions} options
|
|
44
|
+
* @param {string} text The text string that is to be searched for
|
|
45
|
+
* @param {SearchByTextOptions} options Optional parameters to the search
|
|
46
46
|
* @returns {Promise<Place[]>} - Promise resolves to a list of Places that match search parameters
|
|
47
47
|
*/
|
|
48
48
|
searchByText(text: string, options?: SearchByTextOptions): Promise<Place[]>;
|
|
49
49
|
/**
|
|
50
50
|
* Search for search term suggestions based on input text
|
|
51
|
-
* @param {string} text
|
|
52
|
-
* @param {SearchByTextOptions} options
|
|
53
|
-
* @returns {
|
|
51
|
+
* @param {string} text The text string that is to be search for
|
|
52
|
+
* @param {SearchByTextOptions} options Optional parameters to the search
|
|
53
|
+
* @returns a `Promise` of {@link SearchForSuggestionsResults} that resolves to an array of search suggestion strings
|
|
54
54
|
*/
|
|
55
|
-
searchForSuggestions(text: string, options?: SearchByTextOptions): Promise<
|
|
55
|
+
searchForSuggestions(text: string, options?: SearchByTextOptions): Promise<SearchForSuggestionsResults>;
|
|
56
56
|
/**
|
|
57
57
|
* Search for location by unique ID
|
|
58
|
-
* @param {string} placeId
|
|
59
|
-
* @param {searchByPlaceIdOptions} options
|
|
58
|
+
* @param {string} placeId Unique ID of the location that is to be searched for
|
|
59
|
+
* @param {searchByPlaceIdOptions} options Optional parameters to the search
|
|
60
60
|
* @returns {Promise<Place>} - Resolves to a place with the given placeId
|
|
61
61
|
*/
|
|
62
62
|
searchByPlaceId(placeId: string, options?: searchByPlaceIdOptions): Promise<Place | undefined>;
|
|
63
63
|
/**
|
|
64
64
|
* Reverse geocoding search via a coordinate point on the map
|
|
65
|
-
* @param coordinates
|
|
66
|
-
* @param options
|
|
65
|
+
* @param coordinates Coordinates array for the search input
|
|
66
|
+
* @param options Options parameters for the search
|
|
67
67
|
* @returns {Promise<Place>} - Promise that resolves to a place matching search coordinates
|
|
68
68
|
*/
|
|
69
69
|
searchByCoordinates(coordinates: Coordinates, options?: SearchByCoordinatesOptions): Promise<Place>;
|
|
70
70
|
/**
|
|
71
71
|
* Create geofences
|
|
72
|
-
* @param geofences
|
|
73
|
-
* @param options
|
|
72
|
+
* @param geofences Single or array of geofence objects to create
|
|
73
|
+
* @param options Optional parameters for creating geofences
|
|
74
74
|
* @returns {Promise<SaveGeofencesResults>} - Promise that resolves to an object with:
|
|
75
75
|
* successes: list of geofences successfully created
|
|
76
76
|
* errors: list of geofences that failed to create
|
|
@@ -78,23 +78,23 @@ export declare class GeoClass {
|
|
|
78
78
|
saveGeofences(geofences: GeofenceInput | GeofenceInput[], options?: GeofenceOptions): Promise<SaveGeofencesResults>;
|
|
79
79
|
/**
|
|
80
80
|
* Get a single geofence by geofenceId
|
|
81
|
-
* @param geofenceId
|
|
82
|
-
* @param options
|
|
81
|
+
* @param geofenceId The string id of the geofence to get
|
|
82
|
+
* @param options Optional parameters for getting a geofence
|
|
83
83
|
* @returns Promise<Geofence> - Promise that resolves to a geofence object
|
|
84
84
|
*/
|
|
85
85
|
getGeofence(geofenceId: GeofenceId, options?: GeofenceOptions): Promise<Geofence>;
|
|
86
86
|
/**
|
|
87
87
|
* List geofences
|
|
88
|
-
* @param options
|
|
89
|
-
* @returns
|
|
88
|
+
* @param options ListGeofenceOptions
|
|
89
|
+
* @returns a promise that resolves to an object that conforms to {@link ListGeofenceResults}:
|
|
90
90
|
* entries: list of geofences - 100 geofences are listed per page
|
|
91
91
|
* nextToken: token for next page of geofences
|
|
92
92
|
*/
|
|
93
93
|
listGeofences(options?: ListGeofenceOptions): Promise<ListGeofenceResults>;
|
|
94
94
|
/**
|
|
95
95
|
* Delete geofences
|
|
96
|
-
* @param geofenceIds
|
|
97
|
-
* @param options
|
|
96
|
+
* @param geofenceIds string|string[]
|
|
97
|
+
* @param options GeofenceOptions
|
|
98
98
|
* @returns {Promise<DeleteGeofencesResults>} - Promise that resolves to an object with:
|
|
99
99
|
* successes: list of geofences successfully deleted
|
|
100
100
|
* errors: list of geofences that failed to delete
|
package/dist/esm/Geo.mjs
CHANGED
|
@@ -25,7 +25,7 @@ class GeoClass {
|
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
27
27
|
* add plugin into Geo category
|
|
28
|
-
* @param {Object} pluggable
|
|
28
|
+
* @param {Object} pluggable an instance of the plugin
|
|
29
29
|
*/
|
|
30
30
|
addPluggable(pluggable) {
|
|
31
31
|
if (pluggable && pluggable.getCategory() === 'Geo') {
|
|
@@ -34,24 +34,23 @@ class GeoClass {
|
|
|
34
34
|
}
|
|
35
35
|
/**
|
|
36
36
|
* Get the plugin object
|
|
37
|
-
* @param providerName
|
|
37
|
+
* @param providerName the name of the plugin
|
|
38
38
|
*/
|
|
39
39
|
getPluggable(providerName) {
|
|
40
|
-
const
|
|
41
|
-
if (
|
|
40
|
+
const targetPluggable = this._pluggables.find(pluggable => pluggable.getProviderName() === providerName);
|
|
41
|
+
if (targetPluggable === undefined) {
|
|
42
42
|
logger.debug('No plugin found with providerName', providerName);
|
|
43
43
|
throw new Error('No plugin found in Geo for the provider');
|
|
44
44
|
}
|
|
45
45
|
else
|
|
46
|
-
return
|
|
46
|
+
return targetPluggable;
|
|
47
47
|
}
|
|
48
48
|
/**
|
|
49
49
|
* Remove the plugin object
|
|
50
|
-
* @param providerName
|
|
50
|
+
* @param providerName the name of the plugin
|
|
51
51
|
*/
|
|
52
52
|
removePluggable(providerName) {
|
|
53
53
|
this._pluggables = this._pluggables.filter(pluggable => pluggable.getProviderName() !== providerName);
|
|
54
|
-
return;
|
|
55
54
|
}
|
|
56
55
|
/**
|
|
57
56
|
* Get the map resources that are currently available through the provider
|
|
@@ -73,8 +72,8 @@ class GeoClass {
|
|
|
73
72
|
}
|
|
74
73
|
/**
|
|
75
74
|
* Search by text input with optional parameters
|
|
76
|
-
* @param {string} text
|
|
77
|
-
* @param {SearchByTextOptions} options
|
|
75
|
+
* @param {string} text The text string that is to be searched for
|
|
76
|
+
* @param {SearchByTextOptions} options Optional parameters to the search
|
|
78
77
|
* @returns {Promise<Place[]>} - Promise resolves to a list of Places that match search parameters
|
|
79
78
|
*/
|
|
80
79
|
async searchByText(text, options) {
|
|
@@ -90,9 +89,9 @@ class GeoClass {
|
|
|
90
89
|
}
|
|
91
90
|
/**
|
|
92
91
|
* Search for search term suggestions based on input text
|
|
93
|
-
* @param {string} text
|
|
94
|
-
* @param {SearchByTextOptions} options
|
|
95
|
-
* @returns {
|
|
92
|
+
* @param {string} text The text string that is to be search for
|
|
93
|
+
* @param {SearchByTextOptions} options Optional parameters to the search
|
|
94
|
+
* @returns a `Promise` of {@link SearchForSuggestionsResults} that resolves to an array of search suggestion strings
|
|
96
95
|
*/
|
|
97
96
|
async searchForSuggestions(text, options) {
|
|
98
97
|
const { providerName = DEFAULT_PROVIDER } = options || {};
|
|
@@ -107,8 +106,8 @@ class GeoClass {
|
|
|
107
106
|
}
|
|
108
107
|
/**
|
|
109
108
|
* Search for location by unique ID
|
|
110
|
-
* @param {string} placeId
|
|
111
|
-
* @param {searchByPlaceIdOptions} options
|
|
109
|
+
* @param {string} placeId Unique ID of the location that is to be searched for
|
|
110
|
+
* @param {searchByPlaceIdOptions} options Optional parameters to the search
|
|
112
111
|
* @returns {Promise<Place>} - Resolves to a place with the given placeId
|
|
113
112
|
*/
|
|
114
113
|
async searchByPlaceId(placeId, options) {
|
|
@@ -124,8 +123,8 @@ class GeoClass {
|
|
|
124
123
|
}
|
|
125
124
|
/**
|
|
126
125
|
* Reverse geocoding search via a coordinate point on the map
|
|
127
|
-
* @param coordinates
|
|
128
|
-
* @param options
|
|
126
|
+
* @param coordinates Coordinates array for the search input
|
|
127
|
+
* @param options Options parameters for the search
|
|
129
128
|
* @returns {Promise<Place>} - Promise that resolves to a place matching search coordinates
|
|
130
129
|
*/
|
|
131
130
|
async searchByCoordinates(coordinates, options) {
|
|
@@ -143,8 +142,8 @@ class GeoClass {
|
|
|
143
142
|
}
|
|
144
143
|
/**
|
|
145
144
|
* Create geofences
|
|
146
|
-
* @param geofences
|
|
147
|
-
* @param options
|
|
145
|
+
* @param geofences Single or array of geofence objects to create
|
|
146
|
+
* @param options Optional parameters for creating geofences
|
|
148
147
|
* @returns {Promise<SaveGeofencesResults>} - Promise that resolves to an object with:
|
|
149
148
|
* successes: list of geofences successfully created
|
|
150
149
|
* errors: list of geofences that failed to create
|
|
@@ -170,8 +169,8 @@ class GeoClass {
|
|
|
170
169
|
}
|
|
171
170
|
/**
|
|
172
171
|
* Get a single geofence by geofenceId
|
|
173
|
-
* @param geofenceId
|
|
174
|
-
* @param options
|
|
172
|
+
* @param geofenceId The string id of the geofence to get
|
|
173
|
+
* @param options Optional parameters for getting a geofence
|
|
175
174
|
* @returns Promise<Geofence> - Promise that resolves to a geofence object
|
|
176
175
|
*/
|
|
177
176
|
async getGeofence(geofenceId, options) {
|
|
@@ -187,8 +186,8 @@ class GeoClass {
|
|
|
187
186
|
}
|
|
188
187
|
/**
|
|
189
188
|
* List geofences
|
|
190
|
-
* @param options
|
|
191
|
-
* @returns
|
|
189
|
+
* @param options ListGeofenceOptions
|
|
190
|
+
* @returns a promise that resolves to an object that conforms to {@link ListGeofenceResults}:
|
|
192
191
|
* entries: list of geofences - 100 geofences are listed per page
|
|
193
192
|
* nextToken: token for next page of geofences
|
|
194
193
|
*/
|
|
@@ -205,8 +204,8 @@ class GeoClass {
|
|
|
205
204
|
}
|
|
206
205
|
/**
|
|
207
206
|
* Delete geofences
|
|
208
|
-
* @param geofenceIds
|
|
209
|
-
* @param options
|
|
207
|
+
* @param geofenceIds string|string[]
|
|
208
|
+
* @param options GeofenceOptions
|
|
210
209
|
* @returns {Promise<DeleteGeofencesResults>} - Promise that resolves to an object with:
|
|
211
210
|
* successes: list of geofences successfully deleted
|
|
212
211
|
* errors: list of geofences that failed to delete
|
package/dist/esm/Geo.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Geo.mjs","sources":["../../src/Geo.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Amplify, ConsoleLogger } from '@aws-amplify/core';\nimport { AmazonLocationServiceProvider } from './providers/location-service/AmazonLocationServiceProvider';\nimport { validateCoordinates } from './util';\nconst logger = new ConsoleLogger('Geo');\nconst DEFAULT_PROVIDER = 'AmazonLocationService';\nexport class GeoClass {\n constructor() {\n this._config = undefined;\n this._pluggables = [];\n const amplifyConfig = Amplify.getConfig() ?? {};\n this._config = Object.assign({}, this._config, amplifyConfig.Geo);\n const locationProvider = new AmazonLocationServiceProvider(amplifyConfig.Geo);\n this._pluggables.push(locationProvider);\n logger.debug('Geo Options', this._config);\n }\n /**\n * get the name of the module category\n * @returns {string} name of the module category\n */\n getModuleName() {\n return GeoClass.MODULE;\n }\n /**\n * add plugin into Geo category\n * @param {Object} pluggable - an instance of the plugin\n */\n addPluggable(pluggable) {\n if (pluggable && pluggable.getCategory() === 'Geo') {\n this._pluggables.push(pluggable);\n }\n }\n /**\n * Get the plugin object\n * @param providerName - the name of the plugin\n */\n getPluggable(providerName) {\n const pluggable = this._pluggables.find(pluggable => pluggable.getProviderName() === providerName);\n if (pluggable === undefined) {\n logger.debug('No plugin found with providerName', providerName);\n throw new Error('No plugin found in Geo for the provider');\n }\n else\n return pluggable;\n }\n /**\n * Remove the plugin object\n * @param providerName - the name of the plugin\n */\n removePluggable(providerName) {\n this._pluggables = this._pluggables.filter(pluggable => pluggable.getProviderName() !== providerName);\n return;\n }\n /**\n * Get the map resources that are currently available through the provider\n * @param {string} provider\n * @returns - Array of available map resources\n */\n getAvailableMaps(provider = DEFAULT_PROVIDER) {\n const prov = this.getPluggable(provider);\n return prov.getAvailableMaps();\n }\n /**\n * Get the map resource set as default in amplify config\n * @param {string} provider\n * @returns - Map resource set as the default in amplify config\n */\n getDefaultMap(provider = DEFAULT_PROVIDER) {\n const prov = this.getPluggable(provider);\n return prov.getDefaultMap();\n }\n /**\n * Search by text input with optional parameters\n * @param {string} text - The text string that is to be searched for\n * @param {SearchByTextOptions} options? - Optional parameters to the search\n * @returns {Promise<Place[]>} - Promise resolves to a list of Places that match search parameters\n */\n async searchByText(text, options) {\n const { providerName = DEFAULT_PROVIDER } = options || {};\n const prov = this.getPluggable(providerName);\n try {\n return await prov.searchByText(text, options);\n }\n catch (error) {\n logger.debug(error);\n throw error;\n }\n }\n /**\n * Search for search term suggestions based on input text\n * @param {string} text - The text string that is to be search for\n * @param {SearchByTextOptions} options? - Optional parameters to the search\n * @returns {Promise<SearchForSuggestionsResults>} - Resolves to an array of search suggestion strings\n */\n async searchForSuggestions(text, options) {\n const { providerName = DEFAULT_PROVIDER } = options || {};\n const prov = this.getPluggable(providerName);\n try {\n return await prov.searchForSuggestions(text, options);\n }\n catch (error) {\n logger.debug(error);\n throw error;\n }\n }\n /**\n * Search for location by unique ID\n * @param {string} placeId - Unique ID of the location that is to be searched for\n * @param {searchByPlaceIdOptions} options? - Optional parameters to the search\n * @returns {Promise<Place>} - Resolves to a place with the given placeId\n */\n async searchByPlaceId(placeId, options) {\n const providerName = DEFAULT_PROVIDER;\n const prov = this.getPluggable(providerName);\n try {\n return await prov.searchByPlaceId(placeId, options);\n }\n catch (error) {\n logger.debug(error);\n throw error;\n }\n }\n /**\n * Reverse geocoding search via a coordinate point on the map\n * @param coordinates - Coordinates array for the search input\n * @param options - Options parameters for the search\n * @returns {Promise<Place>} - Promise that resolves to a place matching search coordinates\n */\n async searchByCoordinates(coordinates, options) {\n const { providerName = DEFAULT_PROVIDER } = options || {};\n const prov = this.getPluggable(providerName);\n const [lng, lat] = coordinates;\n try {\n validateCoordinates(lng, lat);\n return await prov.searchByCoordinates(coordinates, options);\n }\n catch (error) {\n logger.debug(error);\n throw error;\n }\n }\n /**\n * Create geofences\n * @param geofences - Single or array of geofence objects to create\n * @param options? - Optional parameters for creating geofences\n * @returns {Promise<SaveGeofencesResults>} - Promise that resolves to an object with:\n * successes: list of geofences successfully created\n * errors: list of geofences that failed to create\n */\n async saveGeofences(geofences, options) {\n const { providerName = DEFAULT_PROVIDER } = options || {};\n const prov = this.getPluggable(providerName);\n // If single geofence input, make it an array for batch call\n let geofenceInputArray;\n if (!Array.isArray(geofences)) {\n geofenceInputArray = [geofences];\n }\n else {\n geofenceInputArray = geofences;\n }\n try {\n return await prov.saveGeofences(geofenceInputArray, options);\n }\n catch (error) {\n logger.debug(error);\n throw error;\n }\n }\n /**\n * Get a single geofence by geofenceId\n * @param geofenceId: GeofenceId - The string id of the geofence to get\n * @param options?: GeofenceOptions - Optional parameters for getting a geofence\n * @returns Promise<Geofence> - Promise that resolves to a geofence object\n */\n async getGeofence(geofenceId, options) {\n const { providerName = DEFAULT_PROVIDER } = options || {};\n const prov = this.getPluggable(providerName);\n try {\n return await prov.getGeofence(geofenceId, options);\n }\n catch (error) {\n logger.debug(error);\n throw error;\n }\n }\n /**\n * List geofences\n * @param options?: ListGeofenceOptions\n * @returns {Promise<ListGeofencesResults>} - Promise that resolves to an object with:\n * entries: list of geofences - 100 geofences are listed per page\n * nextToken: token for next page of geofences\n */\n async listGeofences(options) {\n const { providerName = DEFAULT_PROVIDER } = options || {};\n const prov = this.getPluggable(providerName);\n try {\n return await prov.listGeofences(options);\n }\n catch (error) {\n logger.debug(error);\n throw error;\n }\n }\n /**\n * Delete geofences\n * @param geofenceIds: string|string[]\n * @param options?: GeofenceOptions\n * @returns {Promise<DeleteGeofencesResults>} - Promise that resolves to an object with:\n * successes: list of geofences successfully deleted\n * errors: list of geofences that failed to delete\n */\n async deleteGeofences(geofenceIds, options) {\n const { providerName = DEFAULT_PROVIDER } = options || {};\n const prov = this.getPluggable(providerName);\n // If single geofence input, make it an array for batch call\n let geofenceIdsInputArray;\n if (!Array.isArray(geofenceIds)) {\n geofenceIdsInputArray = [geofenceIds];\n }\n else {\n geofenceIdsInputArray = geofenceIds;\n }\n // Delete geofences\n try {\n return await prov.deleteGeofences(geofenceIdsInputArray, options);\n }\n catch (error) {\n logger.debug(error);\n throw error;\n }\n }\n}\nGeoClass.MODULE = 'Geo';\nexport const Geo = new GeoClass();\n"],"names":[],"mappings":";;;;AAAA;AACA;AAIA,MAAM,MAAM,GAAG,IAAI,aAAa,CAAC,KAAK,CAAC,CAAC;AACxC,MAAM,gBAAgB,GAAG,uBAAuB,CAAC;AAC1C,MAAM,QAAQ,CAAC;AACtB,IAAI,WAAW,GAAG;AAClB,QAAQ,IAAI,CAAC,OAAO,GAAG,SAAS,CAAC;AACjC,QAAQ,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;AAC9B,QAAQ,MAAM,aAAa,GAAG,OAAO,CAAC,SAAS,EAAE,IAAI,EAAE,CAAC;AACxD,QAAQ,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,OAAO,EAAE,aAAa,CAAC,GAAG,CAAC,CAAC;AAC1E,QAAQ,MAAM,gBAAgB,GAAG,IAAI,6BAA6B,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;AACtF,Q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its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Amplify, ConsoleLogger } from '@aws-amplify/core';\nimport { AmazonLocationServiceProvider } from './providers/location-service/AmazonLocationServiceProvider';\nimport { validateCoordinates } from './util';\nconst logger = new ConsoleLogger('Geo');\nconst DEFAULT_PROVIDER = 'AmazonLocationService';\nexport class GeoClass {\n constructor() {\n this._config = undefined;\n this._pluggables = [];\n const amplifyConfig = Amplify.getConfig() ?? {};\n this._config = Object.assign({}, this._config, amplifyConfig.Geo);\n const locationProvider = new AmazonLocationServiceProvider(amplifyConfig.Geo);\n this._pluggables.push(locationProvider);\n logger.debug('Geo Options', this._config);\n }\n /**\n * get the name of the module category\n * @returns {string} name of the module category\n */\n getModuleName() {\n return GeoClass.MODULE;\n }\n /**\n * add plugin into Geo category\n * @param {Object} pluggable an instance of the plugin\n */\n addPluggable(pluggable) {\n if (pluggable && pluggable.getCategory() === 'Geo') {\n this._pluggables.push(pluggable);\n }\n }\n /**\n * Get the plugin object\n * @param providerName the name of the plugin\n */\n getPluggable(providerName) {\n const targetPluggable = this._pluggables.find(pluggable => pluggable.getProviderName() === providerName);\n if (targetPluggable === undefined) {\n logger.debug('No plugin found with providerName', providerName);\n throw new Error('No plugin found in Geo for the provider');\n }\n else\n return targetPluggable;\n }\n /**\n * Remove the plugin object\n * @param providerName the name of the plugin\n */\n removePluggable(providerName) {\n this._pluggables = this._pluggables.filter(pluggable => pluggable.getProviderName() !== providerName);\n }\n /**\n * Get the map resources that are currently available through the provider\n * @param {string} provider\n * @returns - Array of available map resources\n */\n getAvailableMaps(provider = DEFAULT_PROVIDER) {\n const prov = this.getPluggable(provider);\n return prov.getAvailableMaps();\n }\n /**\n * Get the map resource set as default in amplify config\n * @param {string} provider\n * @returns - Map resource set as the default in amplify config\n */\n getDefaultMap(provider = DEFAULT_PROVIDER) {\n const prov = this.getPluggable(provider);\n return prov.getDefaultMap();\n }\n /**\n * Search by text input with optional parameters\n * @param {string} text The text string that is to be searched for\n * @param {SearchByTextOptions} options Optional parameters to the search\n * @returns {Promise<Place[]>} - Promise resolves to a list of Places that match search parameters\n */\n async searchByText(text, options) {\n const { providerName = DEFAULT_PROVIDER } = options || {};\n const prov = this.getPluggable(providerName);\n try {\n return await prov.searchByText(text, options);\n }\n catch (error) {\n logger.debug(error);\n throw error;\n }\n }\n /**\n * Search for search term suggestions based on input text\n * @param {string} text The text string that is to be search for\n * @param {SearchByTextOptions} options Optional parameters to the search\n * @returns a `Promise` of {@link SearchForSuggestionsResults} that resolves to an array of search suggestion strings\n */\n async searchForSuggestions(text, options) {\n const { providerName = DEFAULT_PROVIDER } = options || {};\n const prov = this.getPluggable(providerName);\n try {\n return await prov.searchForSuggestions(text, options);\n }\n catch (error) {\n logger.debug(error);\n throw error;\n }\n }\n /**\n * Search for location by unique ID\n * @param {string} placeId Unique ID of the location that is to be searched for\n * @param {searchByPlaceIdOptions} options Optional parameters to the search\n * @returns {Promise<Place>} - Resolves to a place with the given placeId\n */\n async searchByPlaceId(placeId, options) {\n const providerName = DEFAULT_PROVIDER;\n const prov = this.getPluggable(providerName);\n try {\n return await prov.searchByPlaceId(placeId, options);\n }\n catch (error) {\n logger.debug(error);\n throw error;\n }\n }\n /**\n * Reverse geocoding search via a coordinate point on the map\n * @param coordinates Coordinates array for the search input\n * @param options Options parameters for the search\n * @returns {Promise<Place>} - Promise that resolves to a place matching search coordinates\n */\n async searchByCoordinates(coordinates, options) {\n const { providerName = DEFAULT_PROVIDER } = options || {};\n const prov = this.getPluggable(providerName);\n const [lng, lat] = coordinates;\n try {\n validateCoordinates(lng, lat);\n return await prov.searchByCoordinates(coordinates, options);\n }\n catch (error) {\n logger.debug(error);\n throw error;\n }\n }\n /**\n * Create geofences\n * @param geofences Single or array of geofence objects to create\n * @param options Optional parameters for creating geofences\n * @returns {Promise<SaveGeofencesResults>} - Promise that resolves to an object with:\n * successes: list of geofences successfully created\n * errors: list of geofences that failed to create\n */\n async saveGeofences(geofences, options) {\n const { providerName = DEFAULT_PROVIDER } = options || {};\n const prov = this.getPluggable(providerName);\n // If single geofence input, make it an array for batch call\n let geofenceInputArray;\n if (!Array.isArray(geofences)) {\n geofenceInputArray = [geofences];\n }\n else {\n geofenceInputArray = geofences;\n }\n try {\n return await prov.saveGeofences(geofenceInputArray, options);\n }\n catch (error) {\n logger.debug(error);\n throw error;\n }\n }\n /**\n * Get a single geofence by geofenceId\n * @param geofenceId The string id of the geofence to get\n * @param options Optional parameters for getting a geofence\n * @returns Promise<Geofence> - Promise that resolves to a geofence object\n */\n async getGeofence(geofenceId, options) {\n const { providerName = DEFAULT_PROVIDER } = options || {};\n const prov = this.getPluggable(providerName);\n try {\n return await prov.getGeofence(geofenceId, options);\n }\n catch (error) {\n logger.debug(error);\n throw error;\n }\n }\n /**\n * List geofences\n * @param options ListGeofenceOptions\n * @returns a promise that resolves to an object that conforms to {@link ListGeofenceResults}:\n * entries: list of geofences - 100 geofences are listed per page\n * nextToken: token for next page of geofences\n */\n async listGeofences(options) {\n const { providerName = DEFAULT_PROVIDER } = options || {};\n const prov = this.getPluggable(providerName);\n try {\n return await prov.listGeofences(options);\n }\n catch (error) {\n logger.debug(error);\n throw error;\n }\n }\n /**\n * Delete geofences\n * @param geofenceIds string|string[]\n * @param options GeofenceOptions\n * @returns {Promise<DeleteGeofencesResults>} - Promise that resolves to an object with:\n * successes: list of geofences successfully deleted\n * errors: list of geofences that failed to delete\n */\n async deleteGeofences(geofenceIds, options) {\n const { providerName = DEFAULT_PROVIDER } = options || {};\n const prov = this.getPluggable(providerName);\n // If single geofence input, make it an array for batch call\n let geofenceIdsInputArray;\n if (!Array.isArray(geofenceIds)) {\n geofenceIdsInputArray = [geofenceIds];\n }\n else {\n geofenceIdsInputArray = geofenceIds;\n }\n // Delete geofences\n try {\n return await prov.deleteGeofences(geofenceIdsInputArray, options);\n }\n catch (error) {\n logger.debug(error);\n throw error;\n }\n }\n}\nGeoClass.MODULE = 'Geo';\nexport const Geo = new GeoClass();\n"],"names":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AY,qBAAqB,GAAG,CAAC,WAAW,CAAC,CAAC;AAClD,SAAS;AACT,aAAa;AACb,YAAY,qBAAqB,GAAG,WAAW,CAAC;AAChD,SAAS;AACT;AACA,QAAQ,IAAI;AACZ,YAAY,OAAO,MAAM,IAAI,CAAC,eAAe,CAAC,qBAAqB,EAAE,OAAO,CAAC,CAAC;AAC9E,SAAS;AACT,QAAQ,OAAO,KAAK,EAAE;AACtB,YAAY,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AAChC,YAAY,MAAM,KAAK,CAAC;AACxB,SAAS;AACT,KAAK;AACL,CAAC;AACD,QAAQ,CAAC,MAAM,GAAG,KAAK,CAAC;AACZ,MAAC,GAAG,GAAG,IAAI,QAAQ;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AmazonLocationServiceDeleteGeofencesResults, AmazonLocationServiceGeofence, AmazonLocationServiceGeofenceOptions, AmazonLocationServiceListGeofenceOptions, AmazonLocationServiceMapStyle, Coordinates, GeoConfig, GeoProvider, GeofenceId, GeofenceInput, ListGeofenceResults, Place, SaveGeofencesResults, SearchByCoordinatesOptions, SearchByTextOptions, SearchForSuggestionsResults, searchByPlaceIdOptions } from '../../types';
|
|
2
2
|
export declare class AmazonLocationServiceProvider implements GeoProvider {
|
|
3
3
|
static CATEGORY: string;
|
|
4
4
|
static PROVIDER_NAME: string;
|
|
@@ -34,15 +34,15 @@ export declare class AmazonLocationServiceProvider implements GeoProvider {
|
|
|
34
34
|
getDefaultMap(): AmazonLocationServiceMapStyle;
|
|
35
35
|
/**
|
|
36
36
|
* Search by text input with optional parameters
|
|
37
|
-
* @param {string} text
|
|
38
|
-
* @param {SearchByTextOptions} options
|
|
37
|
+
* @param {string} text The text string that is to be searched for
|
|
38
|
+
* @param {SearchByTextOptions} options Optional parameters to the search
|
|
39
39
|
* @returns {Promise<Place[]>} - Promise resolves to a list of Places that match search parameters
|
|
40
40
|
*/
|
|
41
41
|
searchByText(text: string, options?: SearchByTextOptions): Promise<Place[]>;
|
|
42
42
|
/**
|
|
43
43
|
* Search for suggestions based on the input text
|
|
44
|
-
* @param {string} text
|
|
45
|
-
* @param {SearchByTextOptions} options
|
|
44
|
+
* @param {string} text The text string that is to be searched for
|
|
45
|
+
* @param {SearchByTextOptions} options Optional parameters to the search
|
|
46
46
|
* @returns {Promise<SearchForSuggestionsResults>} - Resolves to an array of search suggestion strings
|
|
47
47
|
*/
|
|
48
48
|
searchForSuggestions(text: string, options?: SearchByTextOptions): Promise<SearchForSuggestionsResults>;
|
|
@@ -50,40 +50,40 @@ export declare class AmazonLocationServiceProvider implements GeoProvider {
|
|
|
50
50
|
searchByPlaceId(placeId: string, options?: searchByPlaceIdOptions): Promise<Place | undefined>;
|
|
51
51
|
/**
|
|
52
52
|
* Reverse geocoding search via a coordinate point on the map
|
|
53
|
-
* @param coordinates
|
|
54
|
-
* @param options
|
|
53
|
+
* @param coordinates Coordinates array for the search input
|
|
54
|
+
* @param options Options parameters for the search
|
|
55
55
|
* @returns {Promise<Place>} - Promise that resolves to a place matching search coordinates
|
|
56
56
|
*/
|
|
57
57
|
searchByCoordinates(coordinates: Coordinates, options?: SearchByCoordinatesOptions): Promise<Place>;
|
|
58
58
|
/**
|
|
59
59
|
* Create geofences inside of a geofence collection
|
|
60
|
-
* @param geofences
|
|
61
|
-
* @param options
|
|
62
|
-
* @returns
|
|
60
|
+
* @param geofences Array of geofence objects to create
|
|
61
|
+
* @param options Optional parameters for creating geofences
|
|
62
|
+
* @returns a promise that resolves to an object that conforms to {@link SaveGeofencesResults}:
|
|
63
63
|
* successes: list of geofences successfully created
|
|
64
64
|
* errors: list of geofences that failed to create
|
|
65
65
|
*/
|
|
66
66
|
saveGeofences(geofences: GeofenceInput[], options?: AmazonLocationServiceGeofenceOptions): Promise<SaveGeofencesResults>;
|
|
67
67
|
/**
|
|
68
68
|
* Get geofence from a geofence collection
|
|
69
|
-
* @param geofenceId
|
|
70
|
-
* @param options
|
|
69
|
+
* @param geofenceId string
|
|
70
|
+
* @param options Optional parameters for getGeofence
|
|
71
71
|
* @returns {Promise<AmazonLocationServiceGeofence>} - Promise that resolves to a geofence object
|
|
72
72
|
*/
|
|
73
73
|
getGeofence(geofenceId: GeofenceId, options?: AmazonLocationServiceGeofenceOptions): Promise<AmazonLocationServiceGeofence>;
|
|
74
74
|
/**
|
|
75
75
|
* List geofences from a geofence collection
|
|
76
|
-
* @param options
|
|
77
|
-
* @returns
|
|
76
|
+
* @param options ListGeofenceOptions
|
|
77
|
+
* @returns a promise that resolves to an object that conforms to {@link ListGeofenceResults}:
|
|
78
78
|
* entries: list of geofences - 100 geofences are listed per page
|
|
79
79
|
* nextToken: token for next page of geofences
|
|
80
80
|
*/
|
|
81
81
|
listGeofences(options?: AmazonLocationServiceListGeofenceOptions): Promise<ListGeofenceResults>;
|
|
82
82
|
/**
|
|
83
83
|
* Delete geofences from a geofence collection
|
|
84
|
-
* @param geofenceIds
|
|
85
|
-
* @param options
|
|
86
|
-
* @returns
|
|
84
|
+
* @param geofenceIds string|string[]
|
|
85
|
+
* @param options GeofenceOptions
|
|
86
|
+
* @returns a promise that resolves to an object that conforms to {@link AmazonLocationServiceDeleteGeofencesResults}:
|
|
87
87
|
* successes: list of geofences successfully deleted
|
|
88
88
|
* errors: list of geofences that failed to delete
|
|
89
89
|
*/
|