@aws-amplify/geo 3.0.22-unstable.bd1fefd.0 → 3.0.22
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 +6 -5
- package/dist/cjs/Geo.js.map +1 -1
- package/dist/cjs/providers/location-service/AmazonLocationServiceProvider.js +36 -22
- 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 +6 -5
- 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 +36 -22
- 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 +88 -89
- package/src/Geo.ts +16 -16
- package/src/providers/location-service/AmazonLocationServiceProvider.ts +65 -69
- 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 +9 -10
|
@@ -1,33 +1,34 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
import camelcaseKeys from 'camelcase-keys';
|
|
4
|
-
|
|
4
|
+
|
|
5
|
+
import { Amplify, fetchAuthSession, ConsoleLogger } from '@aws-amplify/core';
|
|
5
6
|
import { GeoAction } from '@aws-amplify/core/internals/utils';
|
|
6
7
|
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
Place as PlaceResult,
|
|
9
|
+
LocationClient,
|
|
10
|
+
SearchPlaceIndexForTextCommand,
|
|
11
|
+
SearchPlaceIndexForTextCommandInput,
|
|
12
|
+
SearchPlaceIndexForSuggestionsCommand,
|
|
13
|
+
SearchPlaceIndexForSuggestionsCommandInput,
|
|
14
|
+
SearchPlaceIndexForPositionCommand,
|
|
15
|
+
SearchPlaceIndexForPositionCommandInput,
|
|
10
16
|
BatchPutGeofenceCommand,
|
|
11
17
|
BatchPutGeofenceCommandInput,
|
|
12
|
-
BatchPutGeofenceCommandOutput,
|
|
13
18
|
BatchPutGeofenceRequestEntry,
|
|
14
|
-
|
|
15
|
-
GetGeofenceCommandInput,
|
|
16
|
-
GetGeofenceCommandOutput,
|
|
19
|
+
BatchPutGeofenceCommandOutput,
|
|
17
20
|
GetPlaceCommand,
|
|
18
21
|
GetPlaceCommandInput,
|
|
19
22
|
GetPlaceCommandOutput,
|
|
23
|
+
GetGeofenceCommand,
|
|
24
|
+
GetGeofenceCommandInput,
|
|
25
|
+
GetGeofenceCommandOutput,
|
|
20
26
|
ListGeofencesCommand,
|
|
21
27
|
ListGeofencesCommandInput,
|
|
22
28
|
ListGeofencesCommandOutput,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
SearchPlaceIndexForPositionCommandInput,
|
|
27
|
-
SearchPlaceIndexForSuggestionsCommand,
|
|
28
|
-
SearchPlaceIndexForSuggestionsCommandInput,
|
|
29
|
-
SearchPlaceIndexForTextCommand,
|
|
30
|
-
SearchPlaceIndexForTextCommandInput,
|
|
29
|
+
BatchDeleteGeofenceCommand,
|
|
30
|
+
BatchDeleteGeofenceCommandInput,
|
|
31
|
+
BatchDeleteGeofenceCommandOutput,
|
|
31
32
|
} from '@aws-sdk/client-location';
|
|
32
33
|
|
|
33
34
|
import {
|
|
@@ -36,27 +37,28 @@ import {
|
|
|
36
37
|
validateGeofenceId,
|
|
37
38
|
validateGeofencesInput,
|
|
38
39
|
} from '../../util';
|
|
40
|
+
|
|
39
41
|
import {
|
|
40
|
-
AmazonLocationServiceBatchGeofenceErrorMessages,
|
|
41
|
-
AmazonLocationServiceDeleteGeofencesResults,
|
|
42
|
-
AmazonLocationServiceGeofence,
|
|
43
|
-
AmazonLocationServiceGeofenceOptions,
|
|
44
|
-
AmazonLocationServiceGeofenceStatus,
|
|
45
|
-
AmazonLocationServiceListGeofenceOptions,
|
|
46
|
-
AmazonLocationServiceMapStyle,
|
|
47
|
-
Coordinates,
|
|
48
42
|
GeoConfig,
|
|
43
|
+
SearchByTextOptions,
|
|
44
|
+
SearchByCoordinatesOptions,
|
|
49
45
|
GeoProvider,
|
|
46
|
+
Place,
|
|
47
|
+
AmazonLocationServiceMapStyle,
|
|
48
|
+
Coordinates,
|
|
49
|
+
SearchForSuggestionsResults,
|
|
50
50
|
GeofenceId,
|
|
51
51
|
GeofenceInput,
|
|
52
|
-
|
|
52
|
+
AmazonLocationServiceGeofenceOptions,
|
|
53
|
+
AmazonLocationServiceListGeofenceOptions,
|
|
53
54
|
ListGeofenceResults,
|
|
54
|
-
|
|
55
|
+
AmazonLocationServiceGeofenceStatus,
|
|
55
56
|
SaveGeofencesResults,
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
AmazonLocationServiceGeofence,
|
|
58
|
+
GeofencePolygon,
|
|
59
|
+
AmazonLocationServiceDeleteGeofencesResults,
|
|
59
60
|
searchByPlaceIdOptions,
|
|
61
|
+
AmazonLocationServiceBatchGeofenceErrorMessages,
|
|
60
62
|
} from '../../types';
|
|
61
63
|
|
|
62
64
|
const logger = new ConsoleLogger('AmazonLocationServiceProvider');
|
|
@@ -76,7 +78,7 @@ export class AmazonLocationServiceProvider implements GeoProvider {
|
|
|
76
78
|
* @param {Object} config - Configuration object for Geo
|
|
77
79
|
*/
|
|
78
80
|
constructor(config?: GeoConfig) {
|
|
79
|
-
this._config = config
|
|
81
|
+
this._config = config ? config : {};
|
|
80
82
|
logger.debug('Geo Options', this._config);
|
|
81
83
|
}
|
|
82
84
|
|
|
@@ -105,10 +107,10 @@ export class AmazonLocationServiceProvider implements GeoProvider {
|
|
|
105
107
|
|
|
106
108
|
const mapStyles: AmazonLocationServiceMapStyle[] = [];
|
|
107
109
|
const availableMaps = this._config.maps.items;
|
|
108
|
-
const
|
|
110
|
+
const region = this._config.region;
|
|
109
111
|
|
|
110
112
|
for (const mapName in availableMaps) {
|
|
111
|
-
const
|
|
113
|
+
const style = availableMaps[mapName].style;
|
|
112
114
|
mapStyles.push({ mapName, style, region });
|
|
113
115
|
}
|
|
114
116
|
|
|
@@ -123,8 +125,8 @@ export class AmazonLocationServiceProvider implements GeoProvider {
|
|
|
123
125
|
this._verifyMapResources();
|
|
124
126
|
|
|
125
127
|
const mapName = this._config.maps.default;
|
|
126
|
-
const
|
|
127
|
-
const
|
|
128
|
+
const style = this._config.maps.items[mapName].style;
|
|
129
|
+
const region = this._config.region;
|
|
128
130
|
|
|
129
131
|
return { mapName, style, region };
|
|
130
132
|
}
|
|
@@ -304,6 +306,7 @@ export class AmazonLocationServiceProvider implements GeoProvider {
|
|
|
304
306
|
if (place) {
|
|
305
307
|
return camelcaseKeys(place, { deep: true }) as unknown as Place;
|
|
306
308
|
}
|
|
309
|
+
return;
|
|
307
310
|
}
|
|
308
311
|
|
|
309
312
|
/**
|
|
@@ -369,7 +372,7 @@ export class AmazonLocationServiceProvider implements GeoProvider {
|
|
|
369
372
|
* Create geofences inside of a geofence collection
|
|
370
373
|
* @param geofences Array of geofence objects to create
|
|
371
374
|
* @param options Optional parameters for creating geofences
|
|
372
|
-
* @returns
|
|
375
|
+
* @returns {Promise<AmazonLocationServiceSaveGeofencesResults>} - Promise that resolves to an object with:
|
|
373
376
|
* successes: list of geofences successfully created
|
|
374
377
|
* errors: list of geofences that failed to create
|
|
375
378
|
*/
|
|
@@ -440,15 +443,14 @@ export class AmazonLocationServiceProvider implements GeoProvider {
|
|
|
440
443
|
},
|
|
441
444
|
});
|
|
442
445
|
});
|
|
443
|
-
|
|
444
446
|
return;
|
|
445
447
|
}
|
|
446
448
|
|
|
447
449
|
// Push all successes to results
|
|
448
450
|
response.Successes?.forEach(success => {
|
|
449
|
-
const { GeofenceId
|
|
451
|
+
const { GeofenceId, CreateTime, UpdateTime } = success;
|
|
450
452
|
results.successes.push({
|
|
451
|
-
geofenceId:
|
|
453
|
+
geofenceId: GeofenceId!,
|
|
452
454
|
createTime: CreateTime,
|
|
453
455
|
updateTime: UpdateTime,
|
|
454
456
|
});
|
|
@@ -456,14 +458,14 @@ export class AmazonLocationServiceProvider implements GeoProvider {
|
|
|
456
458
|
|
|
457
459
|
// Push all errors to results
|
|
458
460
|
response.Errors?.forEach(error => {
|
|
459
|
-
const { Error, GeofenceId
|
|
461
|
+
const { Error, GeofenceId } = error;
|
|
460
462
|
const { Code, Message } = Error!;
|
|
461
463
|
results.errors.push({
|
|
462
464
|
error: {
|
|
463
465
|
code: Code!,
|
|
464
466
|
message: Message!,
|
|
465
467
|
},
|
|
466
|
-
geofenceId:
|
|
468
|
+
geofenceId: GeofenceId!,
|
|
467
469
|
});
|
|
468
470
|
});
|
|
469
471
|
}),
|
|
@@ -522,16 +524,10 @@ export class AmazonLocationServiceProvider implements GeoProvider {
|
|
|
522
524
|
}
|
|
523
525
|
|
|
524
526
|
// Convert response to camelCase for return
|
|
525
|
-
const {
|
|
526
|
-
GeofenceId: responseGeofenceId,
|
|
527
|
-
CreateTime,
|
|
528
|
-
UpdateTime,
|
|
529
|
-
Status,
|
|
530
|
-
Geometry,
|
|
531
|
-
} = response;
|
|
527
|
+
const { GeofenceId, CreateTime, UpdateTime, Status, Geometry } = response;
|
|
532
528
|
const geofence: AmazonLocationServiceGeofence = {
|
|
533
529
|
createTime: CreateTime,
|
|
534
|
-
geofenceId:
|
|
530
|
+
geofenceId: GeofenceId!,
|
|
535
531
|
geometry: {
|
|
536
532
|
polygon: Geometry!.Polygon as GeofencePolygon,
|
|
537
533
|
},
|
|
@@ -545,7 +541,7 @@ export class AmazonLocationServiceProvider implements GeoProvider {
|
|
|
545
541
|
/**
|
|
546
542
|
* List geofences from a geofence collection
|
|
547
543
|
* @param options ListGeofenceOptions
|
|
548
|
-
* @returns
|
|
544
|
+
* @returns {Promise<ListGeofencesResults>} - Promise that resolves to an object with:
|
|
549
545
|
* entries: list of geofences - 100 geofences are listed per page
|
|
550
546
|
* nextToken: token for next page of geofences
|
|
551
547
|
*/
|
|
@@ -598,15 +594,9 @@ export class AmazonLocationServiceProvider implements GeoProvider {
|
|
|
598
594
|
|
|
599
595
|
const results: ListGeofenceResults = {
|
|
600
596
|
entries: Entries!.map(
|
|
601
|
-
({
|
|
602
|
-
GeofenceId: geofenceId,
|
|
603
|
-
CreateTime,
|
|
604
|
-
UpdateTime,
|
|
605
|
-
Status,
|
|
606
|
-
Geometry,
|
|
607
|
-
}) => {
|
|
597
|
+
({ GeofenceId, CreateTime, UpdateTime, Status, Geometry }) => {
|
|
608
598
|
return {
|
|
609
|
-
geofenceId:
|
|
599
|
+
geofenceId: GeofenceId!,
|
|
610
600
|
createTime: CreateTime,
|
|
611
601
|
updateTime: UpdateTime,
|
|
612
602
|
status: Status,
|
|
@@ -626,7 +616,7 @@ export class AmazonLocationServiceProvider implements GeoProvider {
|
|
|
626
616
|
* Delete geofences from a geofence collection
|
|
627
617
|
* @param geofenceIds string|string[]
|
|
628
618
|
* @param options GeofenceOptions
|
|
629
|
-
* @returns
|
|
619
|
+
* @returns {Promise<DeleteGeofencesResults>} - Promise that resolves to an object with:
|
|
630
620
|
* successes: list of geofences successfully deleted
|
|
631
621
|
* errors: list of geofences that failed to delete
|
|
632
622
|
*/
|
|
@@ -652,8 +642,6 @@ export class AmazonLocationServiceProvider implements GeoProvider {
|
|
|
652
642
|
} catch (error) {
|
|
653
643
|
return true;
|
|
654
644
|
}
|
|
655
|
-
|
|
656
|
-
return false;
|
|
657
645
|
});
|
|
658
646
|
if (badGeofenceIds.length > 0) {
|
|
659
647
|
throw new Error(`Invalid geofence ids: ${badGeofenceIds.join(', ')}`);
|
|
@@ -693,19 +681,17 @@ export class AmazonLocationServiceProvider implements GeoProvider {
|
|
|
693
681
|
};
|
|
694
682
|
results.errors.push(errorObject);
|
|
695
683
|
});
|
|
696
|
-
|
|
697
684
|
return;
|
|
698
685
|
}
|
|
699
686
|
|
|
700
|
-
const
|
|
687
|
+
const badGeofenceIds = response.Errors.map(
|
|
701
688
|
({ geofenceId }) => geofenceId,
|
|
702
689
|
);
|
|
703
690
|
results.successes.push(
|
|
704
|
-
...batch.filter(Id => !
|
|
691
|
+
...batch.filter(Id => !badGeofenceIds.includes(Id)),
|
|
705
692
|
);
|
|
706
693
|
}),
|
|
707
694
|
);
|
|
708
|
-
|
|
709
695
|
return results;
|
|
710
696
|
}
|
|
711
697
|
|
|
@@ -714,18 +700,16 @@ export class AmazonLocationServiceProvider implements GeoProvider {
|
|
|
714
700
|
*/
|
|
715
701
|
private async _ensureCredentials(): Promise<boolean> {
|
|
716
702
|
try {
|
|
717
|
-
const
|
|
703
|
+
const credentials = (await fetchAuthSession()).credentials;
|
|
718
704
|
if (!credentials) return false;
|
|
719
705
|
logger.debug(
|
|
720
706
|
'Set credentials for storage. Credentials are:',
|
|
721
707
|
credentials,
|
|
722
708
|
);
|
|
723
709
|
this._credentials = credentials;
|
|
724
|
-
|
|
725
710
|
return true;
|
|
726
711
|
} catch (error) {
|
|
727
712
|
logger.debug('Ensure credentials error. Credentials are:', error);
|
|
728
|
-
|
|
729
713
|
return false;
|
|
730
714
|
}
|
|
731
715
|
}
|
|
@@ -801,7 +785,13 @@ export class AmazonLocationServiceProvider implements GeoProvider {
|
|
|
801
785
|
});
|
|
802
786
|
const command = new BatchPutGeofenceCommand(geofenceInput);
|
|
803
787
|
|
|
804
|
-
|
|
788
|
+
let response: BatchPutGeofenceCommandOutput;
|
|
789
|
+
try {
|
|
790
|
+
response = await client.send(command);
|
|
791
|
+
} catch (error) {
|
|
792
|
+
throw error;
|
|
793
|
+
}
|
|
794
|
+
return response;
|
|
805
795
|
}
|
|
806
796
|
|
|
807
797
|
private async _AmazonLocationServiceBatchDeleteGeofenceCall(
|
|
@@ -822,6 +812,12 @@ export class AmazonLocationServiceProvider implements GeoProvider {
|
|
|
822
812
|
});
|
|
823
813
|
const command = new BatchDeleteGeofenceCommand(deleteGeofencesInput);
|
|
824
814
|
|
|
825
|
-
|
|
815
|
+
let response: BatchDeleteGeofenceCommandOutput;
|
|
816
|
+
try {
|
|
817
|
+
response = await client.send(command);
|
|
818
|
+
} catch (error) {
|
|
819
|
+
throw error;
|
|
820
|
+
}
|
|
821
|
+
return response;
|
|
826
822
|
}
|
|
827
823
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
import {
|
|
4
|
-
|
|
5
|
-
Geofence,
|
|
6
|
-
GeofenceError,
|
|
4
|
+
MapStyle,
|
|
7
5
|
GeofenceOptions,
|
|
8
6
|
ListGeofenceOptions,
|
|
9
|
-
|
|
7
|
+
Geofence,
|
|
8
|
+
DeleteGeofencesResults,
|
|
9
|
+
GeofenceError,
|
|
10
10
|
} from './Geo';
|
|
11
11
|
|
|
12
12
|
// Maps
|
package/src/types/Geo.ts
CHANGED
|
@@ -53,20 +53,20 @@ export type SearchByTextOptions =
|
|
|
53
53
|
| SearchByTextOptionsWithSearchAreaConstraints;
|
|
54
54
|
|
|
55
55
|
// Options object for searchByCoordinates
|
|
56
|
-
export
|
|
56
|
+
export type SearchByCoordinatesOptions = {
|
|
57
57
|
maxResults?: number;
|
|
58
58
|
searchIndexName?: string;
|
|
59
59
|
providerName?: string;
|
|
60
|
-
}
|
|
60
|
+
};
|
|
61
61
|
|
|
62
|
-
export
|
|
62
|
+
export type searchByPlaceIdOptions = {
|
|
63
63
|
searchIndexName?: string;
|
|
64
|
-
}
|
|
64
|
+
};
|
|
65
65
|
|
|
66
66
|
// Geometry object for Place points
|
|
67
|
-
export
|
|
67
|
+
export type PlaceGeometry = {
|
|
68
68
|
point: Coordinates;
|
|
69
|
-
}
|
|
69
|
+
};
|
|
70
70
|
|
|
71
71
|
// Place object with locality information
|
|
72
72
|
export interface Place {
|
|
@@ -88,38 +88,38 @@ export type LinearRing = Coordinates[];
|
|
|
88
88
|
export type GeofencePolygon = LinearRing[];
|
|
89
89
|
|
|
90
90
|
// Geometry object for Polygon
|
|
91
|
-
export
|
|
91
|
+
export type PolygonGeometry = {
|
|
92
92
|
polygon: GeofencePolygon;
|
|
93
|
-
}
|
|
93
|
+
};
|
|
94
94
|
|
|
95
95
|
export type GeofenceId = string;
|
|
96
96
|
|
|
97
97
|
// Geofence object used as input for saveGeofences
|
|
98
|
-
export
|
|
98
|
+
export type GeofenceInput = {
|
|
99
99
|
geofenceId: GeofenceId;
|
|
100
100
|
geometry: PolygonGeometry;
|
|
101
|
-
}
|
|
101
|
+
};
|
|
102
102
|
|
|
103
103
|
// Options object for saveGeofences
|
|
104
|
-
export
|
|
104
|
+
export type GeofenceOptions = {
|
|
105
105
|
providerName?: string;
|
|
106
|
-
}
|
|
106
|
+
};
|
|
107
107
|
|
|
108
108
|
// Error type for errors related to Geofence API calls
|
|
109
|
-
export
|
|
109
|
+
export type GeofenceError = {
|
|
110
110
|
error: {
|
|
111
111
|
code: string;
|
|
112
112
|
message: string;
|
|
113
113
|
};
|
|
114
114
|
geofenceId: GeofenceId;
|
|
115
|
-
}
|
|
115
|
+
};
|
|
116
116
|
|
|
117
117
|
// Base geofence object
|
|
118
|
-
|
|
118
|
+
type GeofenceBase = {
|
|
119
119
|
geofenceId: GeofenceId;
|
|
120
120
|
createTime?: Date;
|
|
121
121
|
updateTime?: Date;
|
|
122
|
-
}
|
|
122
|
+
};
|
|
123
123
|
|
|
124
124
|
// Results object for getGeofence
|
|
125
125
|
export type Geofence = GeofenceBase & {
|
|
@@ -127,10 +127,10 @@ export type Geofence = GeofenceBase & {
|
|
|
127
127
|
};
|
|
128
128
|
|
|
129
129
|
// Results object for saveGeofences
|
|
130
|
-
export
|
|
130
|
+
export type SaveGeofencesResults = {
|
|
131
131
|
successes: GeofenceBase[];
|
|
132
132
|
errors: GeofenceError[];
|
|
133
|
-
}
|
|
133
|
+
};
|
|
134
134
|
|
|
135
135
|
// Options object for listGeofence
|
|
136
136
|
export type ListGeofenceOptions = GeofenceOptions & {
|
|
@@ -138,21 +138,21 @@ export type ListGeofenceOptions = GeofenceOptions & {
|
|
|
138
138
|
};
|
|
139
139
|
|
|
140
140
|
// Results options for listGeofence
|
|
141
|
-
export
|
|
141
|
+
export type ListGeofenceResults = {
|
|
142
142
|
entries: Geofence[];
|
|
143
143
|
nextToken: string | undefined;
|
|
144
|
-
}
|
|
144
|
+
};
|
|
145
145
|
|
|
146
146
|
// Results object for deleteGeofence
|
|
147
|
-
export
|
|
147
|
+
export type DeleteGeofencesResults = {
|
|
148
148
|
successes: GeofenceId[];
|
|
149
149
|
errors: GeofenceError[];
|
|
150
|
-
}
|
|
150
|
+
};
|
|
151
151
|
|
|
152
152
|
// Return type for searchForSuggestions
|
|
153
153
|
export type SearchForSuggestionsResults = SearchForSuggestionsResult[];
|
|
154
154
|
|
|
155
|
-
export
|
|
155
|
+
export type SearchForSuggestionsResult = {
|
|
156
156
|
text: string;
|
|
157
157
|
placeId?: string;
|
|
158
|
-
}
|
|
158
|
+
};
|
package/src/types/Provider.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
import {
|
|
4
|
+
SearchByTextOptions,
|
|
5
|
+
SearchByCoordinatesOptions,
|
|
6
|
+
SearchForSuggestionsResults,
|
|
4
7
|
Coordinates,
|
|
5
|
-
|
|
8
|
+
Place,
|
|
9
|
+
MapStyle,
|
|
6
10
|
Geofence,
|
|
7
11
|
GeofenceId,
|
|
8
12
|
GeofenceInput,
|
|
9
13
|
GeofenceOptions,
|
|
10
14
|
ListGeofenceOptions,
|
|
11
15
|
ListGeofenceResults,
|
|
12
|
-
MapStyle,
|
|
13
|
-
Place,
|
|
14
16
|
SaveGeofencesResults,
|
|
15
|
-
|
|
16
|
-
SearchByTextOptions,
|
|
17
|
-
SearchForSuggestionsResults,
|
|
17
|
+
DeleteGeofencesResults,
|
|
18
18
|
searchByPlaceIdOptions,
|
|
19
19
|
} from './Geo';
|
|
20
20
|
|
package/src/util.ts
CHANGED
|
@@ -10,21 +10,21 @@ import {
|
|
|
10
10
|
import { UserAgent } from '@aws-sdk/types';
|
|
11
11
|
|
|
12
12
|
import {
|
|
13
|
+
Longitude,
|
|
14
|
+
Latitude,
|
|
13
15
|
GeofenceId,
|
|
14
16
|
GeofenceInput,
|
|
15
17
|
GeofencePolygon,
|
|
16
|
-
Latitude,
|
|
17
18
|
LinearRing,
|
|
18
|
-
Longitude,
|
|
19
19
|
} from './types';
|
|
20
20
|
|
|
21
21
|
export function validateCoordinates(lng: Longitude, lat: Latitude): void {
|
|
22
22
|
if (!Number.isFinite(lng) || !Number.isFinite(lat)) {
|
|
23
23
|
throw new Error(`Invalid coordinates: [${lng},${lat}]`);
|
|
24
24
|
}
|
|
25
|
-
if (lat < -90 ||
|
|
25
|
+
if (lat < -90 || 90 < lat) {
|
|
26
26
|
throw new Error('Latitude must be between -90 and 90 degrees inclusive.');
|
|
27
|
-
} else if (lng < -180 ||
|
|
27
|
+
} else if (lng < -180 || 180 < lng) {
|
|
28
28
|
throw new Error(
|
|
29
29
|
'Longitude must be between -180 and 180 degrees inclusive.',
|
|
30
30
|
);
|
|
@@ -186,18 +186,17 @@ export function mapSearchOptions(options, locationServiceInput) {
|
|
|
186
186
|
locationServiceModifiedInput.IndexName = options.searchIndexName;
|
|
187
187
|
}
|
|
188
188
|
|
|
189
|
-
if (options
|
|
189
|
+
if (options['biasPosition'] && options['searchAreaConstraints']) {
|
|
190
190
|
throw new Error(
|
|
191
191
|
'BiasPosition and SearchAreaConstraints are mutually exclusive, please remove one or the other from the options object',
|
|
192
192
|
);
|
|
193
193
|
}
|
|
194
|
-
if (options
|
|
195
|
-
locationServiceModifiedInput.BiasPosition = options
|
|
194
|
+
if (options['biasPosition']) {
|
|
195
|
+
locationServiceModifiedInput.BiasPosition = options['biasPosition'];
|
|
196
196
|
}
|
|
197
|
-
if (options
|
|
198
|
-
locationServiceModifiedInput.FilterBBox = options
|
|
197
|
+
if (options['searchAreaConstraints']) {
|
|
198
|
+
locationServiceModifiedInput.FilterBBox = options['searchAreaConstraints'];
|
|
199
199
|
}
|
|
200
|
-
|
|
201
200
|
return locationServiceModifiedInput;
|
|
202
201
|
}
|
|
203
202
|
|