@aws-amplify/geo 3.0.8 → 3.0.9-unstable.01d9e8a.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/util.js +1 -0
- package/dist/cjs/util.js.map +1 -1
- package/dist/esm/types/Geo.d.ts +1 -0
- package/dist/esm/util.mjs +1 -0
- package/dist/esm/util.mjs.map +1 -1
- package/package.json +91 -91
- package/src/types/Geo.ts +1 -0
- package/src/util.ts +1 -0
package/dist/cjs/util.js
CHANGED
|
@@ -123,6 +123,7 @@ function mapSearchOptions(options, locationServiceInput) {
|
|
|
123
123
|
const locationServiceModifiedInput = { ...locationServiceInput };
|
|
124
124
|
locationServiceModifiedInput.FilterCountries = options.countries;
|
|
125
125
|
locationServiceModifiedInput.MaxResults = options.maxResults;
|
|
126
|
+
locationServiceModifiedInput.Language = options.language;
|
|
126
127
|
if (options.searchIndexName) {
|
|
127
128
|
locationServiceModifiedInput.IndexName = options.searchIndexName;
|
|
128
129
|
}
|
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 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,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;AACxD,QAAQ,MAAM,IAAI,KAAK,CAAC,CAAC,sBAAsB,EAAE,GAAG,C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AK,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 || 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,GAA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,4BAA4B,CAAC,YAAY,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;AAC5E,KAAK;AACL,IAAI,IAAI,OAAO,CAAC,uBAAuB,CAAC,EAAE;AAC1C,QAAQ,4BAA4B,CAAC,UAAU,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;AACnF,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/types/Geo.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export interface SearchByTextOptionsBase {
|
|
|
16
16
|
maxResults?: number;
|
|
17
17
|
searchIndexName?: string;
|
|
18
18
|
providerName?: string;
|
|
19
|
+
language?: string;
|
|
19
20
|
}
|
|
20
21
|
export interface SearchByTextOptionsWithBiasPosition extends SearchByTextOptionsBase {
|
|
21
22
|
biasPosition?: Coordinates;
|
package/dist/esm/util.mjs
CHANGED
|
@@ -114,6 +114,7 @@ function mapSearchOptions(options, locationServiceInput) {
|
|
|
114
114
|
const locationServiceModifiedInput = { ...locationServiceInput };
|
|
115
115
|
locationServiceModifiedInput.FilterCountries = options.countries;
|
|
116
116
|
locationServiceModifiedInput.MaxResults = options.maxResults;
|
|
117
|
+
locationServiceModifiedInput.Language = options.language;
|
|
117
118
|
if (options.searchIndexName) {
|
|
118
119
|
locationServiceModifiedInput.IndexName = options.searchIndexName;
|
|
119
120
|
}
|
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 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,CA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AAC,cAAc,CAAC,EAAE;AACjC,QAAQ,4BAA4B,CAAC,YAAY,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;AAC5E,KAAK;AACL,IAAI,IAAI,OAAO,CAAC,uBAAuB,CAAC,EAAE;AAC1C,QAAQ,4BAA4B,CAAC,UAAU,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;AACnF,KAAK;AACL,IAAI,OAAO,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 || 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,m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
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
2
|
+
"name": "@aws-amplify/geo",
|
|
3
|
+
"version": "3.0.9-unstable.01d9e8a.0+01d9e8a",
|
|
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:cjs:watch": "rimraf dist/cjs && tsc -m commonjs --outDir dist/cjs --watch",
|
|
23
|
+
"build:esm:watch": "rimraf dist/esm && tsc -m esnext --outDir dist/esm --watch",
|
|
24
|
+
"build": "npm run clean && npm run build:esm-cjs && npm run build:umd",
|
|
25
|
+
"clean": "npm run clean:size && rimraf dist lib lib-esm",
|
|
26
|
+
"clean:size": "rimraf dual-publish-tmp tmp*",
|
|
27
|
+
"format": "echo \"Not implemented\"",
|
|
28
|
+
"lint": "tslint '{__tests__,src}/**/*.ts' && npm run ts-coverage",
|
|
29
|
+
"ts-coverage": "typescript-coverage-report -p ./tsconfig.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.9-unstable.01d9e8a.0+01d9e8a"
|
|
77
|
+
},
|
|
78
|
+
"devDependencies": {
|
|
79
|
+
"@aws-amplify/core": "6.0.9-unstable.01d9e8a.0+01d9e8a",
|
|
80
|
+
"@rollup/plugin-typescript": "11.1.5",
|
|
81
|
+
"rollup": "3.29.4",
|
|
82
|
+
"typescript": "5.0.2"
|
|
83
|
+
},
|
|
84
|
+
"size-limit": [
|
|
85
|
+
{
|
|
86
|
+
"name": "Geo (top-level class)",
|
|
87
|
+
"path": "./dist/esm/index.mjs",
|
|
88
|
+
"import": "{ Amplify, Geo }",
|
|
89
|
+
"limit": "43.9 kB"
|
|
90
|
+
}
|
|
91
|
+
],
|
|
92
|
+
"gitHead": "01d9e8ac9d3624508ea93c077d39075484e54336"
|
|
93
93
|
}
|
package/src/types/Geo.ts
CHANGED
package/src/util.ts
CHANGED
|
@@ -180,6 +180,7 @@ export function mapSearchOptions(options, locationServiceInput) {
|
|
|
180
180
|
const locationServiceModifiedInput = { ...locationServiceInput };
|
|
181
181
|
locationServiceModifiedInput.FilterCountries = options.countries;
|
|
182
182
|
locationServiceModifiedInput.MaxResults = options.maxResults;
|
|
183
|
+
locationServiceModifiedInput.Language = options.language;
|
|
183
184
|
|
|
184
185
|
if (options.searchIndexName) {
|
|
185
186
|
locationServiceModifiedInput.IndexName = options.searchIndexName;
|