@aws-amplify/geo 3.0.21 → 3.0.22-unstable.bd1fefd.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/dist/cjs/Geo.js +5 -6
- package/dist/cjs/Geo.js.map +1 -1
- package/dist/cjs/providers/location-service/AmazonLocationServiceProvider.js +22 -36
- 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 +4 -4
- package/dist/esm/Geo.mjs +5 -6
- package/dist/esm/Geo.mjs.map +1 -1
- package/dist/esm/providers/location-service/AmazonLocationServiceProvider.d.ts +4 -4
- package/dist/esm/providers/location-service/AmazonLocationServiceProvider.mjs +22 -36
- 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 +16 -16
- package/src/providers/location-service/AmazonLocationServiceProvider.ts +69 -65
- 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/esm/types/Geo.d.ts
CHANGED
|
@@ -25,17 +25,17 @@ export interface SearchByTextOptionsWithSearchAreaConstraints extends SearchByTe
|
|
|
25
25
|
searchAreaConstraints?: BoundingBox;
|
|
26
26
|
}
|
|
27
27
|
export type SearchByTextOptions = SearchByTextOptionsWithBiasPosition | SearchByTextOptionsWithSearchAreaConstraints;
|
|
28
|
-
export
|
|
28
|
+
export interface SearchByCoordinatesOptions {
|
|
29
29
|
maxResults?: number;
|
|
30
30
|
searchIndexName?: string;
|
|
31
31
|
providerName?: string;
|
|
32
|
-
}
|
|
33
|
-
export
|
|
32
|
+
}
|
|
33
|
+
export interface searchByPlaceIdOptions {
|
|
34
34
|
searchIndexName?: string;
|
|
35
|
-
}
|
|
36
|
-
export
|
|
35
|
+
}
|
|
36
|
+
export interface PlaceGeometry {
|
|
37
37
|
point: Coordinates;
|
|
38
|
-
}
|
|
38
|
+
}
|
|
39
39
|
export interface Place {
|
|
40
40
|
addressNumber?: string;
|
|
41
41
|
country?: string;
|
|
@@ -50,49 +50,49 @@ export interface Place {
|
|
|
50
50
|
}
|
|
51
51
|
export type LinearRing = Coordinates[];
|
|
52
52
|
export type GeofencePolygon = LinearRing[];
|
|
53
|
-
export
|
|
53
|
+
export interface PolygonGeometry {
|
|
54
54
|
polygon: GeofencePolygon;
|
|
55
|
-
}
|
|
55
|
+
}
|
|
56
56
|
export type GeofenceId = string;
|
|
57
|
-
export
|
|
57
|
+
export interface GeofenceInput {
|
|
58
58
|
geofenceId: GeofenceId;
|
|
59
59
|
geometry: PolygonGeometry;
|
|
60
|
-
}
|
|
61
|
-
export
|
|
60
|
+
}
|
|
61
|
+
export interface GeofenceOptions {
|
|
62
62
|
providerName?: string;
|
|
63
|
-
}
|
|
64
|
-
export
|
|
63
|
+
}
|
|
64
|
+
export interface GeofenceError {
|
|
65
65
|
error: {
|
|
66
66
|
code: string;
|
|
67
67
|
message: string;
|
|
68
68
|
};
|
|
69
69
|
geofenceId: GeofenceId;
|
|
70
|
-
}
|
|
71
|
-
|
|
70
|
+
}
|
|
71
|
+
interface GeofenceBase {
|
|
72
72
|
geofenceId: GeofenceId;
|
|
73
73
|
createTime?: Date;
|
|
74
74
|
updateTime?: Date;
|
|
75
|
-
}
|
|
75
|
+
}
|
|
76
76
|
export type Geofence = GeofenceBase & {
|
|
77
77
|
geometry: PolygonGeometry;
|
|
78
78
|
};
|
|
79
|
-
export
|
|
79
|
+
export interface SaveGeofencesResults {
|
|
80
80
|
successes: GeofenceBase[];
|
|
81
81
|
errors: GeofenceError[];
|
|
82
|
-
}
|
|
82
|
+
}
|
|
83
83
|
export type ListGeofenceOptions = GeofenceOptions & {
|
|
84
84
|
nextToken?: string;
|
|
85
85
|
};
|
|
86
|
-
export
|
|
86
|
+
export interface ListGeofenceResults {
|
|
87
87
|
entries: Geofence[];
|
|
88
88
|
nextToken: string | undefined;
|
|
89
|
-
}
|
|
90
|
-
export
|
|
89
|
+
}
|
|
90
|
+
export interface DeleteGeofencesResults {
|
|
91
91
|
successes: GeofenceId[];
|
|
92
92
|
errors: GeofenceError[];
|
|
93
|
-
}
|
|
93
|
+
}
|
|
94
94
|
export type SearchForSuggestionsResults = SearchForSuggestionsResult[];
|
|
95
|
-
export
|
|
95
|
+
export interface SearchForSuggestionsResult {
|
|
96
96
|
text: string;
|
|
97
97
|
placeId?: string;
|
|
98
|
-
}
|
|
98
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Coordinates, DeleteGeofencesResults, Geofence, GeofenceId, GeofenceInput, GeofenceOptions, ListGeofenceOptions, ListGeofenceResults, MapStyle, Place, SaveGeofencesResults, SearchByCoordinatesOptions, SearchByTextOptions, SearchForSuggestionsResults, searchByPlaceIdOptions } from './Geo';
|
|
2
2
|
export interface GeoProvider {
|
|
3
3
|
getCategory(): string;
|
|
4
4
|
getProviderName(): string;
|
package/dist/esm/util.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { GeoAction } from '@aws-amplify/core/internals/utils';
|
|
2
2
|
import { UserAgent } from '@aws-sdk/types';
|
|
3
|
-
import {
|
|
3
|
+
import { GeofenceId, GeofenceInput, GeofencePolygon, Latitude, LinearRing, Longitude } from './types';
|
|
4
4
|
export declare function validateCoordinates(lng: Longitude, lat: Latitude): void;
|
|
5
5
|
export declare function validateGeofenceId(geofenceId: GeofenceId): void;
|
|
6
6
|
export declare function validateLinearRing(linearRing: LinearRing, geofenceId?: GeofenceId): void;
|
package/dist/esm/util.mjs
CHANGED
|
@@ -7,10 +7,10 @@ function validateCoordinates(lng, lat) {
|
|
|
7
7
|
if (!Number.isFinite(lng) || !Number.isFinite(lat)) {
|
|
8
8
|
throw new Error(`Invalid coordinates: [${lng},${lat}]`);
|
|
9
9
|
}
|
|
10
|
-
if (lat < -90 ||
|
|
10
|
+
if (lat < -90 || lat > 90) {
|
|
11
11
|
throw new Error('Latitude must be between -90 and 90 degrees inclusive.');
|
|
12
12
|
}
|
|
13
|
-
else if (lng < -180 ||
|
|
13
|
+
else if (lng < -180 || lng > 180) {
|
|
14
14
|
throw new Error('Longitude must be between -180 and 180 degrees inclusive.');
|
|
15
15
|
}
|
|
16
16
|
}
|
|
@@ -118,14 +118,14 @@ function mapSearchOptions(options, locationServiceInput) {
|
|
|
118
118
|
if (options.searchIndexName) {
|
|
119
119
|
locationServiceModifiedInput.IndexName = options.searchIndexName;
|
|
120
120
|
}
|
|
121
|
-
if (options
|
|
121
|
+
if (options.biasPosition && options.searchAreaConstraints) {
|
|
122
122
|
throw new Error('BiasPosition and SearchAreaConstraints are mutually exclusive, please remove one or the other from the options object');
|
|
123
123
|
}
|
|
124
|
-
if (options
|
|
125
|
-
locationServiceModifiedInput.BiasPosition = options
|
|
124
|
+
if (options.biasPosition) {
|
|
125
|
+
locationServiceModifiedInput.BiasPosition = options.biasPosition;
|
|
126
126
|
}
|
|
127
|
-
if (options
|
|
128
|
-
locationServiceModifiedInput.FilterBBox = options
|
|
127
|
+
if (options.searchAreaConstraints) {
|
|
128
|
+
locationServiceModifiedInput.FilterBBox = options.searchAreaConstraints;
|
|
129
129
|
}
|
|
130
130
|
return locationServiceModifiedInput;
|
|
131
131
|
}
|
package/dist/esm/util.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.mjs","sources":["../../src/util.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport booleanClockwise from '@turf/boolean-clockwise';\nimport { Category, getAmplifyUserAgent, getAmplifyUserAgentObject, } from '@aws-amplify/core/internals/utils';\nexport function 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}\nexport function 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}\nexport function 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 (booleanClockwise(linearRing)) {\n throw new Error(`${errorPrefix}LinearRing coordinates must be wound counterclockwise`);\n }\n}\nexport function 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}\nexport function 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}\nexport function 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}\nexport function getGeoUserAgent(action) {\n return getAmplifyUserAgentObject({\n category: Category.Geo,\n action,\n });\n}\nexport function getGeoUserAgentString(action) {\n return getAmplifyUserAgent({\n category: Category.Geo,\n action,\n });\n}\n"],"names":[],"mappings":";;;AAAA;AACA;AAGO,SAAS,mBAAmB,CAAC,GAAG,EAAE,GAAG,EAAE;AAC9C,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;AACxD,QAAQ,MAAM,IAAI,KAAK,CAAC,CAAC,sBAAsB,EAAE,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AAChE,KAAK;AACL,IAAI,IAAI,GAAG,GAAG,CAAC,EAAE,IAAI,EAAE,GAAG,GAAG,EAAE;AAC/B,QAAQ,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAC;AAClF,KAAK;AACL,SAAS,IAAI,GAAG,GAAG,CAAC,GAAG,IAAI,GAAG,GAAG,GAAG,EAAE;AACtC,QAAQ,MAAM,IAAI,KAAK,CAAC,2DAA2D,CAAC,CAAC;AACrF,KAAK;AACL,CAAC;AACM,SAAS,kBAAkB,CAAC,UAAU,EAAE;AAC/C,IAAI,MAAM,eAAe,GAAG,sBAAsB,CAAC;AACnD;AACA,IAAI,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE;AAC3C,QAAQ,MAAM,IAAI,KAAK,CAAC,CAAC,qBA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,4BAA4B,CAAC;AACxC,CAAC;AACM,SAAS,eAAe,CAAC,MAAM,EAAE;AACxC,IAAI,OAAO,yBAAyB,CAAC;AACrC,QAAQ,QAAQ,EAAE,QAAQ,CAAC,GAAG;AAC9B,QAAQ,MAAM;AACd,KAAK,CAAC,CAAC;AACP,CAAC;AACM,SAAS,qBAAqB,CAAC,MAAM,EAAE;AAC9C,IAAI,OAAO,mBAAmB,CAAC;AAC/B,QAAQ,QAAQ,EAAE,QAAQ,CAAC,GAAG;AAC9B,QAAQ,MAAM;AACd,KAAK,CAAC,CAAC;AACP;;;;"}
|
|
1
|
+
{"version":3,"file":"util.mjs","sources":["../../src/util.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport booleanClockwise from '@turf/boolean-clockwise';\nimport { Category, getAmplifyUserAgent, getAmplifyUserAgentObject, } from '@aws-amplify/core/internals/utils';\nexport function 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}\nexport function 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}\nexport function 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 (booleanClockwise(linearRing)) {\n throw new Error(`${errorPrefix}LinearRing coordinates must be wound counterclockwise`);\n }\n}\nexport function 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}\nexport function 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}\nexport function 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}\nexport function getGeoUserAgent(action) {\n return getAmplifyUserAgentObject({\n category: Category.Geo,\n action,\n });\n}\nexport function getGeoUserAgentString(action) {\n return getAmplifyUserAgent({\n category: Category.Geo,\n action,\n });\n}\n"],"names":[],"mappings":";;;AAAA;AACA;AAGO,SAAS,mBAAmB,CAAC,GAAG,EAAE,GAAG,EAAE;AAC9C,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;AACxD,QAAQ,MAAM,IAAI,KAAK,CAAC,CAAC,sBAAsB,EAAE,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,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
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
2
|
+
"name": "@aws-amplify/geo",
|
|
3
|
+
"version": "3.0.22-unstable.bd1fefd.0+bd1fefd",
|
|
4
|
+
"description": "Geo category for aws-amplify",
|
|
5
|
+
"main": "./dist/cjs/index.js",
|
|
6
|
+
"module": "./dist/esm/index.mjs",
|
|
7
|
+
"typings": "./dist/esm/index.d.ts",
|
|
8
|
+
"react-native": "./src/index.ts",
|
|
9
|
+
"publishConfig": {
|
|
10
|
+
"access": "public"
|
|
11
|
+
},
|
|
12
|
+
"sideEffects": [
|
|
13
|
+
"./dist/cjs/geo/geo.js",
|
|
14
|
+
"./dist/esm/geo/geo.mjs"
|
|
15
|
+
],
|
|
16
|
+
"scripts": {
|
|
17
|
+
"test": "yarn run lint && jest -w 1 --coverage --logHeapUsage",
|
|
18
|
+
"test:size": "size-limit",
|
|
19
|
+
"build-with-test": "npm test && npm run build",
|
|
20
|
+
"build:umd": "webpack && webpack --config ./webpack.config.dev.js",
|
|
21
|
+
"build:esm-cjs": "rollup -c rollup.config.mjs",
|
|
22
|
+
"build:watch": "npm run build:esm-cjs -- --watch",
|
|
23
|
+
"build": "npm run clean && npm run build:esm-cjs && npm run build:umd",
|
|
24
|
+
"clean": "npm run clean:size && rimraf dist lib lib-esm",
|
|
25
|
+
"clean:size": "rimraf dual-publish-tmp tmp*",
|
|
26
|
+
"format": "echo \"Not implemented\"",
|
|
27
|
+
"lint": "eslint '**/*.{ts,tsx}' && npm run ts-coverage",
|
|
28
|
+
"lint:fix": "eslint '**/*.{ts,tsx}' --fix",
|
|
29
|
+
"ts-coverage": "typescript-coverage-report -p ./tsconfig.build.json -t 84.00"
|
|
30
|
+
},
|
|
31
|
+
"exports": {
|
|
32
|
+
".": {
|
|
33
|
+
"types": "./dist/esm/index.d.ts",
|
|
34
|
+
"import": "./dist/esm/index.mjs",
|
|
35
|
+
"require": "./dist/cjs/index.js",
|
|
36
|
+
"react-native": "./src/index.ts"
|
|
37
|
+
},
|
|
38
|
+
"./location-service": {
|
|
39
|
+
"types": "./dist/esm/providers/location-service/AmazonLocationServiceProvider.d.ts",
|
|
40
|
+
"import": "./dist/esm/providers/location-service/AmazonLocationServiceProvider.mjs",
|
|
41
|
+
"require": "./dist/cjs/providers/location-service/AmazonLocationServiceProvider.js",
|
|
42
|
+
"react-native": "./src/providers/location-service/AmazonLocationServiceProvider.ts"
|
|
43
|
+
},
|
|
44
|
+
"./package.json": "./package.json"
|
|
45
|
+
},
|
|
46
|
+
"typesVersions": {
|
|
47
|
+
">=4.2": {
|
|
48
|
+
"location-service": [
|
|
49
|
+
"./dist/esm/providers/location-service/AmazonLocationServiceProvider.d.ts"
|
|
50
|
+
]
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
"repository": {
|
|
54
|
+
"type": "git",
|
|
55
|
+
"url": "https://github.com/aws-amplify/amplify-js.git"
|
|
56
|
+
},
|
|
57
|
+
"author": "Amazon Web Services",
|
|
58
|
+
"license": "Apache-2.0",
|
|
59
|
+
"bugs": {
|
|
60
|
+
"url": "https://github.com/aws/aws-amplify/issues"
|
|
61
|
+
},
|
|
62
|
+
"homepage": "https://aws-amplify.github.io/",
|
|
63
|
+
"files": [
|
|
64
|
+
"dist/cjs",
|
|
65
|
+
"dist/esm",
|
|
66
|
+
"location-service",
|
|
67
|
+
"src"
|
|
68
|
+
],
|
|
69
|
+
"dependencies": {
|
|
70
|
+
"@aws-sdk/client-location": "3.398.0",
|
|
71
|
+
"@turf/boolean-clockwise": "6.5.0",
|
|
72
|
+
"camelcase-keys": "6.2.2",
|
|
73
|
+
"tslib": "^2.5.0"
|
|
74
|
+
},
|
|
75
|
+
"peerDependencies": {
|
|
76
|
+
"@aws-amplify/core": "6.0.22-unstable.bd1fefd.0+bd1fefd"
|
|
77
|
+
},
|
|
78
|
+
"devDependencies": {
|
|
79
|
+
"@aws-amplify/core": "6.0.22-unstable.bd1fefd.0+bd1fefd",
|
|
80
|
+
"typescript": "5.0.2"
|
|
81
|
+
},
|
|
82
|
+
"size-limit": [
|
|
83
|
+
{
|
|
84
|
+
"name": "Geo (top-level class)",
|
|
85
|
+
"path": "./dist/esm/index.mjs",
|
|
86
|
+
"import": "{ Amplify, Geo }",
|
|
87
|
+
"limit": "43.9 kB"
|
|
88
|
+
}
|
|
89
|
+
],
|
|
90
|
+
"gitHead": "bd1fefd8c1540be2949ea70d5d9b21917455533e"
|
|
90
91
|
}
|
package/src/Geo.ts
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
import { Amplify, ConsoleLogger } from '@aws-amplify/core';
|
|
4
|
-
import { AmazonLocationServiceProvider } from './providers/location-service/AmazonLocationServiceProvider';
|
|
5
4
|
|
|
5
|
+
import { AmazonLocationServiceProvider } from './providers/location-service/AmazonLocationServiceProvider';
|
|
6
6
|
import { validateCoordinates } from './util';
|
|
7
|
-
|
|
8
7
|
import {
|
|
9
|
-
Place,
|
|
10
|
-
GeoConfig,
|
|
11
8
|
Coordinates,
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
DeleteGeofencesResults,
|
|
10
|
+
GeoConfig,
|
|
14
11
|
GeoProvider,
|
|
15
|
-
|
|
12
|
+
Geofence,
|
|
16
13
|
GeofenceId,
|
|
17
14
|
GeofenceInput,
|
|
18
15
|
GeofenceOptions,
|
|
19
|
-
SaveGeofencesResults,
|
|
20
|
-
Geofence,
|
|
21
16
|
ListGeofenceOptions,
|
|
22
17
|
ListGeofenceResults,
|
|
23
|
-
|
|
18
|
+
MapStyle,
|
|
19
|
+
Place,
|
|
20
|
+
SaveGeofencesResults,
|
|
21
|
+
SearchByCoordinatesOptions,
|
|
22
|
+
SearchByTextOptions,
|
|
23
|
+
SearchForSuggestionsResults,
|
|
24
24
|
searchByPlaceIdOptions,
|
|
25
25
|
} from './types';
|
|
26
26
|
|
|
@@ -73,13 +73,13 @@ export class GeoClass {
|
|
|
73
73
|
* @param providerName the name of the plugin
|
|
74
74
|
*/
|
|
75
75
|
public getPluggable(providerName: string) {
|
|
76
|
-
const
|
|
76
|
+
const targetPluggable = this._pluggables.find(
|
|
77
77
|
pluggable => pluggable.getProviderName() === providerName,
|
|
78
78
|
);
|
|
79
|
-
if (
|
|
79
|
+
if (targetPluggable === undefined) {
|
|
80
80
|
logger.debug('No plugin found with providerName', providerName);
|
|
81
81
|
throw new Error('No plugin found in Geo for the provider');
|
|
82
|
-
} else return
|
|
82
|
+
} else return targetPluggable;
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
/**
|
|
@@ -90,7 +90,6 @@ export class GeoClass {
|
|
|
90
90
|
this._pluggables = this._pluggables.filter(
|
|
91
91
|
pluggable => pluggable.getProviderName() !== providerName,
|
|
92
92
|
);
|
|
93
|
-
return;
|
|
94
93
|
}
|
|
95
94
|
|
|
96
95
|
/**
|
|
@@ -140,7 +139,7 @@ export class GeoClass {
|
|
|
140
139
|
* Search for search term suggestions based on input text
|
|
141
140
|
* @param {string} text The text string that is to be search for
|
|
142
141
|
* @param {SearchByTextOptions} options Optional parameters to the search
|
|
143
|
-
* @returns {
|
|
142
|
+
* @returns a `Promise` of {@link SearchForSuggestionsResults} that resolves to an array of search suggestion strings
|
|
144
143
|
*/
|
|
145
144
|
public async searchForSuggestions(
|
|
146
145
|
text: string,
|
|
@@ -194,6 +193,7 @@ export class GeoClass {
|
|
|
194
193
|
const [lng, lat] = coordinates;
|
|
195
194
|
try {
|
|
196
195
|
validateCoordinates(lng, lat);
|
|
196
|
+
|
|
197
197
|
return await prov.searchByCoordinates(coordinates, options);
|
|
198
198
|
} catch (error) {
|
|
199
199
|
logger.debug(error);
|
|
@@ -256,7 +256,7 @@ export class GeoClass {
|
|
|
256
256
|
/**
|
|
257
257
|
* List geofences
|
|
258
258
|
* @param options ListGeofenceOptions
|
|
259
|
-
* @returns
|
|
259
|
+
* @returns a promise that resolves to an object that conforms to {@link ListGeofenceResults}:
|
|
260
260
|
* entries: list of geofences - 100 geofences are listed per page
|
|
261
261
|
* nextToken: token for next page of geofences
|
|
262
262
|
*/
|