Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@aws-amplify/geo

Package Overview
Dependencies
Maintainers
8
Versions
1044
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aws-amplify/geo - npm Package Compare versions

Comparing version 1.1.14-unstable.4 to 1.1.14-unstable.5

9

lib-esm/Geo.d.ts

@@ -1,2 +0,2 @@

import { GeoConfig, Coordinates, SearchByTextOptions, SearchByCoordinatesOptions, GeoProvider, MapStyle } from './types';
import { GeoConfig, Coordinates, SearchByTextOptions, SearchForSuggestionsResults, SearchByCoordinatesOptions, GeoProvider, MapStyle } from './types';
export declare class GeoClass {

@@ -56,2 +56,9 @@ static MODULE: string;

/**
* Search for search term suggestions based on input text
* @param {string} text - The text string that is to be search for
* @param {SearchByTextOptions} options? - Optional parameters to the search
* @returns {Promise<SearchForSuggestionsResults>} - Resolves to an array of search suggestion strings
*/
searchForSuggestions(text: string, options?: SearchByTextOptions): Promise<SearchForSuggestionsResults>;
/**
* Reverse geocoding search via a coordinate point on the map

@@ -58,0 +65,0 @@ * @param coordinates - Coordinates array for the search input

@@ -167,2 +167,30 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

/**
* Search for search term suggestions based on input text
* @param {string} text - The text string that is to be search for
* @param {SearchByTextOptions} options? - Optional parameters to the search
* @returns {Promise<SearchForSuggestionsResults>} - Resolves to an array of search suggestion strings
*/
GeoClass.prototype.searchForSuggestions = function (text, options) {
return __awaiter(this, void 0, void 0, function () {
var _a, providerName, prov, error_2;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
_a = (options || {}).providerName, providerName = _a === void 0 ? DEFAULT_PROVIDER : _a;
prov = this.getPluggable(providerName);
_b.label = 1;
case 1:
_b.trys.push([1, 3, , 4]);
return [4 /*yield*/, prov.searchForSuggestions(text, options)];
case 2: return [2 /*return*/, _b.sent()];
case 3:
error_2 = _b.sent();
logger.debug(error_2);
throw error_2;
case 4: return [2 /*return*/];
}
});
});
};
/**
* Reverse geocoding search via a coordinate point on the map

@@ -175,3 +203,3 @@ * @param coordinates - Coordinates array for the search input

return __awaiter(this, void 0, void 0, function () {
var _a, providerName, prov, error_2;
var _a, providerName, prov, error_3;
return __generator(this, function (_b) {

@@ -188,5 +216,5 @@ switch (_b.label) {

case 3:
error_2 = _b.sent();
logger.debug(error_2);
throw error_2;
error_3 = _b.sent();
logger.debug(error_3);
throw error_3;
case 4: return [2 /*return*/];

@@ -193,0 +221,0 @@ }

@@ -1,2 +0,2 @@

import { GeoConfig, SearchByTextOptions, SearchByCoordinatesOptions, GeoProvider, Place, AmazonLocationServiceMapStyle, Coordinates } from '../types';
import { GeoConfig, SearchByTextOptions, SearchByCoordinatesOptions, GeoProvider, Place, AmazonLocationServiceMapStyle, Coordinates, SearchForSuggestionsResults } from '../types';
export declare class AmazonLocationServiceProvider implements GeoProvider {

@@ -48,2 +48,9 @@ static CATEGORY: string;

/**
* Search for suggestions based on the input text
* @param {string} text - The text string that is to be searched for
* @param {SearchByTextOptions} options? - Optional parameters to the search
* @returns {Promise<SearchForSuggestionsResults>} - Resolves to an array of search suggestion strings
*/
searchForSuggestions(text: string, options?: SearchByTextOptions): Promise<SearchForSuggestionsResults>;
/**
* Reverse geocoding search via a coordinate point on the map

@@ -50,0 +57,0 @@ * @param coordinates - Coordinates array for the search input

@@ -51,3 +51,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

import { ConsoleLogger as Logger, Credentials, getAmplifyUserAgent, } from '@aws-amplify/core';
import { LocationClient, SearchPlaceIndexForTextCommand, SearchPlaceIndexForPositionCommand, } from '@aws-sdk/client-location';
import { LocationClient, SearchPlaceIndexForTextCommand, SearchPlaceIndexForSuggestionsCommand, SearchPlaceIndexForPositionCommand, } from '@aws-sdk/client-location';
var logger = new Logger('AmazonLocationServiceProvider');

@@ -184,2 +184,67 @@ var AmazonLocationServiceProvider = /** @class */ (function () {

/**
* Search for suggestions based on the input text
* @param {string} text - The text string that is to be searched for
* @param {SearchByTextOptions} options? - Optional parameters to the search
* @returns {Promise<SearchForSuggestionsResults>} - Resolves to an array of search suggestion strings
*/
AmazonLocationServiceProvider.prototype.searchForSuggestions = function (text, options) {
return __awaiter(this, void 0, void 0, function () {
var credentialsOK, locationServiceInput, client, command, response, error_2, results;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this._ensureCredentials()];
case 1:
credentialsOK = _a.sent();
if (!credentialsOK) {
throw new Error('No credentials');
}
this._verifySearchIndex(options === null || options === void 0 ? void 0 : options.searchIndexName);
locationServiceInput = {
Text: text,
IndexName: this._config.search_indices.default,
};
/**
* Map search options to Amazon Location Service input object
*/
if (options) {
locationServiceInput.FilterCountries = options.countries;
locationServiceInput.MaxResults = options.maxResults;
if (options.searchIndexName) {
locationServiceInput.IndexName = options.searchIndexName;
}
if (options['biasPosition'] && options['searchAreaConstraints']) {
throw new Error('BiasPosition and SearchAreaConstraints are mutually exclusive, please remove one or the other from the options object');
}
if (options['biasPosition']) {
locationServiceInput.BiasPosition = options['biasPosition'];
}
if (options['searchAreaConstraints']) {
locationServiceInput.FilterBBox = options['searchAreaConstraints'];
}
}
client = new LocationClient({
credentials: this._config.credentials,
region: this._config.region,
customUserAgent: getAmplifyUserAgent(),
});
command = new SearchPlaceIndexForSuggestionsCommand(locationServiceInput);
_a.label = 2;
case 2:
_a.trys.push([2, 4, , 5]);
return [4 /*yield*/, client.send(command)];
case 3:
response = _a.sent();
return [3 /*break*/, 5];
case 4:
error_2 = _a.sent();
logger.debug(error_2);
throw error_2;
case 5:
results = response.Results.map(function (result) { return result.Text; });
return [2 /*return*/, results];
}
});
});
};
/**
* Reverse geocoding search via a coordinate point on the map

@@ -192,3 +257,3 @@ * @param coordinates - Coordinates array for the search input

return __awaiter(this, void 0, void 0, function () {
var credentialsOK, locationServiceInput, client, command, response, error_2, PascalResults, results;
var credentialsOK, locationServiceInput, client, command, response, error_3, PascalResults, results;
return __generator(this, function (_a) {

@@ -227,5 +292,5 @@ switch (_a.label) {

case 4:
error_2 = _a.sent();
logger.debug(error_2);
throw error_2;
error_3 = _a.sent();
logger.debug(error_3);
throw error_3;
case 5:

@@ -246,3 +311,3 @@ PascalResults = response.Results.map(function (result) { return result.Place; });

return __awaiter(this, void 0, void 0, function () {
var credentials, cred, error_3;
var credentials, cred, error_4;
return __generator(this, function (_a) {

@@ -262,4 +327,4 @@ switch (_a.label) {

case 2:
error_3 = _a.sent();
logger.warn('Ensure credentials error. Credentials are:', error_3);
error_4 = _a.sent();
logger.warn('Ensure credentials error. Credentials are:', error_4);
return [2 /*return*/, false];

@@ -266,0 +331,0 @@ case 3: return [2 /*return*/];

@@ -59,1 +59,2 @@ export interface GeoConfig {

}
export declare type SearchForSuggestionsResults = string[];

3

lib-esm/types/Provider.d.ts

@@ -1,2 +0,2 @@

import { SearchByTextOptions, SearchByCoordinatesOptions, Coordinates, Place, MapStyle } from './Geo';
import { SearchByTextOptions, SearchByCoordinatesOptions, SearchForSuggestionsResults, Coordinates, Place, MapStyle } from './Geo';
export interface GeoProvider {

@@ -10,2 +10,3 @@ getCategory(): string;

searchByCoordinates(coordinates: Coordinates, options?: SearchByCoordinatesOptions): Promise<Place>;
searchForSuggestions(text: string, options?: SearchByTextOptions): Promise<SearchForSuggestionsResults>;
}

@@ -1,2 +0,2 @@

import { GeoConfig, Coordinates, SearchByTextOptions, SearchByCoordinatesOptions, GeoProvider, MapStyle } from './types';
import { GeoConfig, Coordinates, SearchByTextOptions, SearchForSuggestionsResults, SearchByCoordinatesOptions, GeoProvider, MapStyle } from './types';
export declare class GeoClass {

@@ -56,2 +56,9 @@ static MODULE: string;

/**
* Search for search term suggestions based on input text
* @param {string} text - The text string that is to be search for
* @param {SearchByTextOptions} options? - Optional parameters to the search
* @returns {Promise<SearchForSuggestionsResults>} - Resolves to an array of search suggestion strings
*/
searchForSuggestions(text: string, options?: SearchByTextOptions): Promise<SearchForSuggestionsResults>;
/**
* Reverse geocoding search via a coordinate point on the map

@@ -58,0 +65,0 @@ * @param coordinates - Coordinates array for the search input

@@ -169,2 +169,30 @@ "use strict";

/**
* Search for search term suggestions based on input text
* @param {string} text - The text string that is to be search for
* @param {SearchByTextOptions} options? - Optional parameters to the search
* @returns {Promise<SearchForSuggestionsResults>} - Resolves to an array of search suggestion strings
*/
GeoClass.prototype.searchForSuggestions = function (text, options) {
return __awaiter(this, void 0, void 0, function () {
var _a, providerName, prov, error_2;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
_a = (options || {}).providerName, providerName = _a === void 0 ? DEFAULT_PROVIDER : _a;
prov = this.getPluggable(providerName);
_b.label = 1;
case 1:
_b.trys.push([1, 3, , 4]);
return [4 /*yield*/, prov.searchForSuggestions(text, options)];
case 2: return [2 /*return*/, _b.sent()];
case 3:
error_2 = _b.sent();
logger.debug(error_2);
throw error_2;
case 4: return [2 /*return*/];
}
});
});
};
/**
* Reverse geocoding search via a coordinate point on the map

@@ -177,3 +205,3 @@ * @param coordinates - Coordinates array for the search input

return __awaiter(this, void 0, void 0, function () {
var _a, providerName, prov, error_2;
var _a, providerName, prov, error_3;
return __generator(this, function (_b) {

@@ -190,5 +218,5 @@ switch (_b.label) {

case 3:
error_2 = _b.sent();
logger.debug(error_2);
throw error_2;
error_3 = _b.sent();
logger.debug(error_3);
throw error_3;
case 4: return [2 /*return*/];

@@ -195,0 +223,0 @@ }

@@ -1,2 +0,2 @@

import { GeoConfig, SearchByTextOptions, SearchByCoordinatesOptions, GeoProvider, Place, AmazonLocationServiceMapStyle, Coordinates } from '../types';
import { GeoConfig, SearchByTextOptions, SearchByCoordinatesOptions, GeoProvider, Place, AmazonLocationServiceMapStyle, Coordinates, SearchForSuggestionsResults } from '../types';
export declare class AmazonLocationServiceProvider implements GeoProvider {

@@ -48,2 +48,9 @@ static CATEGORY: string;

/**
* Search for suggestions based on the input text
* @param {string} text - The text string that is to be searched for
* @param {SearchByTextOptions} options? - Optional parameters to the search
* @returns {Promise<SearchForSuggestionsResults>} - Resolves to an array of search suggestion strings
*/
searchForSuggestions(text: string, options?: SearchByTextOptions): Promise<SearchForSuggestionsResults>;
/**
* Reverse geocoding search via a coordinate point on the map

@@ -50,0 +57,0 @@ * @param coordinates - Coordinates array for the search input

@@ -188,2 +188,67 @@ "use strict";

/**
* Search for suggestions based on the input text
* @param {string} text - The text string that is to be searched for
* @param {SearchByTextOptions} options? - Optional parameters to the search
* @returns {Promise<SearchForSuggestionsResults>} - Resolves to an array of search suggestion strings
*/
AmazonLocationServiceProvider.prototype.searchForSuggestions = function (text, options) {
return __awaiter(this, void 0, void 0, function () {
var credentialsOK, locationServiceInput, client, command, response, error_2, results;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this._ensureCredentials()];
case 1:
credentialsOK = _a.sent();
if (!credentialsOK) {
throw new Error('No credentials');
}
this._verifySearchIndex(options === null || options === void 0 ? void 0 : options.searchIndexName);
locationServiceInput = {
Text: text,
IndexName: this._config.search_indices.default,
};
/**
* Map search options to Amazon Location Service input object
*/
if (options) {
locationServiceInput.FilterCountries = options.countries;
locationServiceInput.MaxResults = options.maxResults;
if (options.searchIndexName) {
locationServiceInput.IndexName = options.searchIndexName;
}
if (options['biasPosition'] && options['searchAreaConstraints']) {
throw new Error('BiasPosition and SearchAreaConstraints are mutually exclusive, please remove one or the other from the options object');
}
if (options['biasPosition']) {
locationServiceInput.BiasPosition = options['biasPosition'];
}
if (options['searchAreaConstraints']) {
locationServiceInput.FilterBBox = options['searchAreaConstraints'];
}
}
client = new client_location_1.LocationClient({
credentials: this._config.credentials,
region: this._config.region,
customUserAgent: core_1.getAmplifyUserAgent(),
});
command = new client_location_1.SearchPlaceIndexForSuggestionsCommand(locationServiceInput);
_a.label = 2;
case 2:
_a.trys.push([2, 4, , 5]);
return [4 /*yield*/, client.send(command)];
case 3:
response = _a.sent();
return [3 /*break*/, 5];
case 4:
error_2 = _a.sent();
logger.debug(error_2);
throw error_2;
case 5:
results = response.Results.map(function (result) { return result.Text; });
return [2 /*return*/, results];
}
});
});
};
/**
* Reverse geocoding search via a coordinate point on the map

@@ -196,3 +261,3 @@ * @param coordinates - Coordinates array for the search input

return __awaiter(this, void 0, void 0, function () {
var credentialsOK, locationServiceInput, client, command, response, error_2, PascalResults, results;
var credentialsOK, locationServiceInput, client, command, response, error_3, PascalResults, results;
return __generator(this, function (_a) {

@@ -231,5 +296,5 @@ switch (_a.label) {

case 4:
error_2 = _a.sent();
logger.debug(error_2);
throw error_2;
error_3 = _a.sent();
logger.debug(error_3);
throw error_3;
case 5:

@@ -250,3 +315,3 @@ PascalResults = response.Results.map(function (result) { return result.Place; });

return __awaiter(this, void 0, void 0, function () {
var credentials, cred, error_3;
var credentials, cred, error_4;
return __generator(this, function (_a) {

@@ -266,4 +331,4 @@ switch (_a.label) {

case 2:
error_3 = _a.sent();
logger.warn('Ensure credentials error. Credentials are:', error_3);
error_4 = _a.sent();
logger.warn('Ensure credentials error. Credentials are:', error_4);
return [2 /*return*/, false];

@@ -270,0 +335,0 @@ case 3: return [2 /*return*/];

@@ -59,1 +59,2 @@ export interface GeoConfig {

}
export declare type SearchForSuggestionsResults = string[];

@@ -1,2 +0,2 @@

import { SearchByTextOptions, SearchByCoordinatesOptions, Coordinates, Place, MapStyle } from './Geo';
import { SearchByTextOptions, SearchByCoordinatesOptions, SearchForSuggestionsResults, Coordinates, Place, MapStyle } from './Geo';
export interface GeoProvider {

@@ -10,2 +10,3 @@ getCategory(): string;

searchByCoordinates(coordinates: Coordinates, options?: SearchByCoordinatesOptions): Promise<Place>;
searchForSuggestions(text: string, options?: SearchByTextOptions): Promise<SearchForSuggestionsResults>;
}
{
"name": "@aws-amplify/geo",
"version": "1.1.14-unstable.4+3f8b83869",
"version": "1.1.14-unstable.5+bb60060d3",
"description": "Geo category for aws-amplify",

@@ -44,4 +44,4 @@ "main": "./lib/index.js",

"dependencies": {
"@aws-amplify/core": "4.3.14-unstable.4+3f8b83869",
"@aws-sdk/client-location": "3.41.0",
"@aws-amplify/core": "4.3.14-unstable.5+bb60060d3",
"@aws-sdk/client-location": "3.48.0",
"camelcase-keys": "6.2.2"

@@ -101,3 +101,3 @@ },

},
"gitHead": "3f8b83869becf5f9963d61e6f7cfe695badb3b53"
"gitHead": "bb60060d30c7463d1893b7678ebc18e959b46990"
}

@@ -24,2 +24,3 @@ /*

SearchByTextOptions,
SearchForSuggestionsResults,
SearchByCoordinatesOptions,

@@ -159,2 +160,23 @@ GeoProvider,

/**
* Search for search term suggestions based on input text
* @param {string} text - The text string that is to be search for
* @param {SearchByTextOptions} options? - Optional parameters to the search
* @returns {Promise<SearchForSuggestionsResults>} - Resolves to an array of search suggestion strings
*/
public async searchForSuggestions(
text: string,
options?: SearchByTextOptions
) {
const { providerName = DEFAULT_PROVIDER } = options || {};
const prov = this.getPluggable(providerName);
try {
return await prov.searchForSuggestions(text, options);
} catch (error) {
logger.debug(error);
throw error;
}
}
/**
* Reverse geocoding search via a coordinate point on the map

@@ -161,0 +183,0 @@ * @param coordinates - Coordinates array for the search input

@@ -21,5 +21,7 @@ /*

Place as PlaceResult,
SearchPlaceIndexForTextCommandInput,
LocationClient,
SearchPlaceIndexForTextCommand,
SearchPlaceIndexForTextCommandInput,
SearchPlaceIndexForSuggestionsCommand,
SearchPlaceIndexForSuggestionsCommandInput,
SearchPlaceIndexForPositionCommand,

@@ -37,2 +39,3 @@ SearchPlaceIndexForPositionCommandInput,

Coordinates,
SearchForSuggestionsResults,
} from '../types';

@@ -193,5 +196,5 @@

);
const results: Place[] = (camelcaseKeys(PascalResults, {
const results: Place[] = camelcaseKeys(PascalResults, {
deep: true,
}) as undefined) as Place[];
}) as undefined as Place[];

@@ -202,2 +205,78 @@ return results;

/**
* Search for suggestions based on the input text
* @param {string} text - The text string that is to be searched for
* @param {SearchByTextOptions} options? - Optional parameters to the search
* @returns {Promise<SearchForSuggestionsResults>} - Resolves to an array of search suggestion strings
*/
public async searchForSuggestions(
text: string,
options?: SearchByTextOptions
): Promise<SearchForSuggestionsResults> {
const credentialsOK = await this._ensureCredentials();
if (!credentialsOK) {
throw new Error('No credentials');
}
this._verifySearchIndex(options?.searchIndexName);
/**
* Setup the searchInput
*/
const locationServiceInput: SearchPlaceIndexForSuggestionsCommandInput = {
Text: text,
IndexName: this._config.search_indices.default,
};
/**
* Map search options to Amazon Location Service input object
*/
if (options) {
locationServiceInput.FilterCountries = options.countries;
locationServiceInput.MaxResults = options.maxResults;
if (options.searchIndexName) {
locationServiceInput.IndexName = options.searchIndexName;
}
if (options['biasPosition'] && options['searchAreaConstraints']) {
throw new Error(
'BiasPosition and SearchAreaConstraints are mutually exclusive, please remove one or the other from the options object'
);
}
if (options['biasPosition']) {
locationServiceInput.BiasPosition = options['biasPosition'];
}
if (options['searchAreaConstraints']) {
locationServiceInput.FilterBBox = options['searchAreaConstraints'];
}
}
const client = new LocationClient({
credentials: this._config.credentials,
region: this._config.region,
customUserAgent: getAmplifyUserAgent(),
});
const command = new SearchPlaceIndexForSuggestionsCommand(
locationServiceInput
);
let response;
try {
response = await client.send(command);
} catch (error) {
logger.debug(error);
throw error;
}
/**
* The response from Amazon Location Service is a "Results" array of objects with a single `Text` item.
* Here we want to flatten that to an array of just the strings from those `Text` items.
*/
const results = response.Results.map(result => result.Text);
return results;
}
/**
* Reverse geocoding search via a coordinate point on the map

@@ -254,5 +333,5 @@ * @param coordinates - Coordinates array for the search input

const PascalResults = response.Results.map(result => result.Place);
const results: Place = (camelcaseKeys(PascalResults[0], {
const results: Place = camelcaseKeys(PascalResults[0], {
deep: true,
}) as any) as Place;
}) as any as Place;

@@ -259,0 +338,0 @@ return results;

@@ -100,1 +100,4 @@ /*

}
// Return type for searchForSuggestions
export type SearchForSuggestionsResults = string[];

@@ -17,2 +17,3 @@ /*

SearchByCoordinatesOptions,
SearchForSuggestionsResults,
Coordinates,

@@ -45,2 +46,7 @@ Place,

): Promise<Place>;
searchForSuggestions(
text: string,
options?: SearchByTextOptions
): Promise<SearchForSuggestionsResults>;
}

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc