@aws-amplify/geo 1.2.1 → 1.2.2-geo.3

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.
Files changed (39) hide show
  1. package/dist/aws-amplify-geo.js +1062 -51
  2. package/dist/aws-amplify-geo.js.map +1 -1
  3. package/dist/aws-amplify-geo.min.js +6 -6
  4. package/dist/aws-amplify-geo.min.js.map +1 -1
  5. package/lib/Geo.d.ts +36 -3
  6. package/lib/Geo.js +170 -5
  7. package/lib/Geo.js.map +1 -1
  8. package/lib/Providers/AmazonLocationServiceProvider.d.ts +37 -1
  9. package/lib/Providers/AmazonLocationServiceProvider.js +409 -8
  10. package/lib/Providers/AmazonLocationServiceProvider.js.map +1 -1
  11. package/lib/types/AmazonLocationServiceProvider.d.ts +21 -1
  12. package/lib/types/Geo.d.ts +48 -1
  13. package/lib/types/Provider.d.ts +5 -1
  14. package/lib/types/Provider.js +0 -12
  15. package/lib/types/Provider.js.map +1 -1
  16. package/lib/util.d.ts +6 -0
  17. package/lib/util.js +163 -0
  18. package/lib/util.js.map +1 -0
  19. package/lib-esm/Geo.d.ts +36 -3
  20. package/lib-esm/Geo.js +170 -5
  21. package/lib-esm/Geo.js.map +1 -1
  22. package/lib-esm/Providers/AmazonLocationServiceProvider.d.ts +37 -1
  23. package/lib-esm/Providers/AmazonLocationServiceProvider.js +410 -9
  24. package/lib-esm/Providers/AmazonLocationServiceProvider.js.map +1 -1
  25. package/lib-esm/types/AmazonLocationServiceProvider.d.ts +21 -1
  26. package/lib-esm/types/Geo.d.ts +48 -1
  27. package/lib-esm/types/Provider.d.ts +5 -1
  28. package/lib-esm/types/Provider.js +0 -12
  29. package/lib-esm/types/Provider.js.map +1 -1
  30. package/lib-esm/util.d.ts +6 -0
  31. package/lib-esm/util.js +156 -0
  32. package/lib-esm/util.js.map +1 -0
  33. package/package.json +5 -4
  34. package/src/Geo.ts +144 -2
  35. package/src/Providers/AmazonLocationServiceProvider.ts +409 -6
  36. package/src/types/AmazonLocationServiceProvider.ts +56 -1
  37. package/src/types/Geo.ts +72 -2
  38. package/src/types/Provider.ts +31 -1
  39. package/src/util.ts +182 -0
@@ -25,6 +25,19 @@ import {
25
25
  SearchPlaceIndexForSuggestionsCommandInput,
26
26
  SearchPlaceIndexForPositionCommand,
27
27
  SearchPlaceIndexForPositionCommandInput,
28
+ BatchPutGeofenceCommand,
29
+ BatchPutGeofenceCommandInput,
30
+ BatchPutGeofenceRequestEntry,
31
+ BatchPutGeofenceCommandOutput,
32
+ GetGeofenceCommand,
33
+ GetGeofenceCommandInput,
34
+ GetGeofenceCommandOutput,
35
+ ListGeofencesCommand,
36
+ ListGeofencesCommandInput,
37
+ ListGeofencesCommandOutput,
38
+ BatchDeleteGeofenceCommand,
39
+ BatchDeleteGeofenceCommandInput,
40
+ BatchDeleteGeofenceCommandOutput,
28
41
  } from '@aws-sdk/client-location';
29
42
 
30
43
  import {
@@ -36,6 +49,15 @@ import {
36
49
  AmazonLocationServiceMapStyle,
37
50
  Coordinates,
38
51
  SearchForSuggestionsResults,
52
+ GeofenceInput,
53
+ AmazonLocationServiceGeofenceOptions,
54
+ AmazonLocationServiceListGeofenceOptions,
55
+ ListGeofenceResults,
56
+ AmazonLocationServiceGeofenceStatus,
57
+ SaveGeofencesResults,
58
+ AmazonLocationServiceGeofence,
59
+ GeofencePolygon,
60
+ AmazonLocationServiceDeleteGeofencesResults,
39
61
  } from '../types';
40
62
 
41
63
  const logger = new Logger('AmazonLocationServiceProvider');
@@ -333,6 +355,320 @@ export class AmazonLocationServiceProvider implements GeoProvider {
333
355
  return results;
334
356
  }
335
357
 
358
+ /**
359
+ * Create geofences inside of a geofence collection
360
+ * @param geofences - Array of geofence objects to create
361
+ * @param options? - Optional parameters for creating geofences
362
+ * @returns {Promise<AmazonLocationServiceSaveGeofencesResults>} - Promise that resolves to an object with:
363
+ * successes: list of geofences successfully created
364
+ * errors: list of geofences that failed to create
365
+ */
366
+ public async saveGeofences(
367
+ geofences: GeofenceInput[],
368
+ options?: AmazonLocationServiceGeofenceOptions
369
+ ): Promise<SaveGeofencesResults> {
370
+ const credentialsOK = await this._ensureCredentials();
371
+ if (!credentialsOK) {
372
+ throw new Error('No credentials');
373
+ }
374
+
375
+ try {
376
+ this._verifyGeofenceCollections(options?.collectionName);
377
+ } catch (error) {
378
+ logger.debug(error);
379
+ throw error;
380
+ }
381
+
382
+ // Convert geofences to PascalCase for Amazon Location Service format
383
+ const PascalGeofences: BatchPutGeofenceRequestEntry[] = geofences.map(
384
+ ({ geofenceId, geometry: { polygon } }) => {
385
+ return {
386
+ GeofenceId: geofenceId,
387
+ Geometry: {
388
+ Polygon: polygon,
389
+ },
390
+ };
391
+ }
392
+ );
393
+ const results: SaveGeofencesResults = {
394
+ successes: [],
395
+ errors: [],
396
+ };
397
+
398
+ const batches = [];
399
+
400
+ while (PascalGeofences.length > 0) {
401
+ // Splice off 10 geofences from input clone due to Amazon Location Service API limit
402
+ batches.push(PascalGeofences.splice(0, 10));
403
+ }
404
+
405
+ await Promise.all(
406
+ batches.map(async batch => {
407
+ // for (const batch of batches) {
408
+ // Make API call for the 10 geofences
409
+ let response: BatchPutGeofenceCommandOutput;
410
+ try {
411
+ response = await this._AmazonLocationServiceBatchPutGeofenceCall(
412
+ batch,
413
+ options?.collectionName || this._config.geofenceCollections.default
414
+ );
415
+ } catch (error) {
416
+ // If the API call fails, add the geofences to the errors array and move to next batch
417
+ batch.forEach(geofence => {
418
+ results.errors.push({
419
+ geofenceId: geofence.GeofenceId,
420
+ error: {
421
+ code: 'APIConnectionError',
422
+ message: error.message,
423
+ },
424
+ });
425
+ });
426
+ return;
427
+ }
428
+
429
+ // Push all successes to results
430
+ response.Successes.forEach(success => {
431
+ const { GeofenceId, CreateTime, UpdateTime } = success;
432
+ results.successes.push({
433
+ geofenceId: GeofenceId,
434
+ createTime: CreateTime,
435
+ updateTime: UpdateTime,
436
+ });
437
+ });
438
+
439
+ // Push all errors to results
440
+ response.Errors.forEach(error => {
441
+ const {
442
+ Error: { Code, Message },
443
+ GeofenceId,
444
+ } = error;
445
+ results.errors.push({
446
+ error: {
447
+ code: Code,
448
+ message: Message,
449
+ },
450
+ geofenceId: GeofenceId,
451
+ });
452
+ });
453
+ })
454
+ );
455
+
456
+ return results;
457
+ }
458
+
459
+ /**
460
+ * Get geofence from a geofence collection
461
+ * @param geofenceId:string
462
+ * @param options?: Optional parameters for getGeofence
463
+ * @returns {Promise<AmazonLocationServiceGeofence>} - Promise that resolves to a geofence object
464
+ */
465
+ public async getGeofence(
466
+ geofenceId: string,
467
+ options?: AmazonLocationServiceGeofenceOptions
468
+ ): Promise<AmazonLocationServiceGeofence> {
469
+ const credentialsOK = await this._ensureCredentials();
470
+ if (!credentialsOK) {
471
+ throw new Error('No credentials');
472
+ }
473
+
474
+ // Verify geofence collection exists in aws-config.js
475
+ try {
476
+ this._verifyGeofenceCollections(options?.collectionName);
477
+ } catch (error) {
478
+ logger.debug(error);
479
+ throw error;
480
+ }
481
+
482
+ // Create Amazon Location Service Client
483
+ const client = new LocationClient({
484
+ credentials: this._config.credentials,
485
+ region: this._config.region,
486
+ customUserAgent: getAmplifyUserAgent(),
487
+ });
488
+
489
+ // Create Amazon Location Service command
490
+ const commandInput: GetGeofenceCommandInput = {
491
+ GeofenceId: geofenceId,
492
+ CollectionName:
493
+ options?.collectionName || this._config.geofenceCollections.default,
494
+ };
495
+ const command = new GetGeofenceCommand(commandInput);
496
+
497
+ // Make API call
498
+ let response: GetGeofenceCommandOutput;
499
+ try {
500
+ response = await client.send(command);
501
+ } catch (error) {
502
+ logger.debug(error);
503
+ throw error;
504
+ }
505
+
506
+ // Convert response to camelCase for return
507
+ const { GeofenceId, CreateTime, UpdateTime, Status, Geometry } = response;
508
+ const geofence: AmazonLocationServiceGeofence = {
509
+ createTime: CreateTime,
510
+ geofenceId: GeofenceId,
511
+ geometry: {
512
+ polygon: Geometry.Polygon as GeofencePolygon,
513
+ },
514
+ status: Status as AmazonLocationServiceGeofenceStatus,
515
+ updateTime: UpdateTime,
516
+ };
517
+
518
+ return geofence;
519
+ }
520
+
521
+ /**
522
+ * List geofences from a geofence collection
523
+ * @param options?: ListGeofenceOptions
524
+ * @returns {Promise<ListGeofencesResults>} - Promise that resolves to an object with:
525
+ * entries: list of geofences - 100 geofences are listed per page
526
+ * nextToken: token for next page of geofences
527
+ */
528
+ public async listGeofences(
529
+ options?: AmazonLocationServiceListGeofenceOptions
530
+ ): Promise<ListGeofenceResults> {
531
+ const credentialsOK = await this._ensureCredentials();
532
+ if (!credentialsOK) {
533
+ throw new Error('No credentials');
534
+ }
535
+
536
+ // Verify geofence collection exists in aws-config.js
537
+ try {
538
+ this._verifyGeofenceCollections(options?.collectionName);
539
+ } catch (error) {
540
+ logger.debug(error);
541
+ throw error;
542
+ }
543
+
544
+ // Create Amazon Location Service Client
545
+ const client = new LocationClient({
546
+ credentials: this._config.credentials,
547
+ region: this._config.region,
548
+ customUserAgent: getAmplifyUserAgent(),
549
+ });
550
+
551
+ // Create Amazon Location Service input
552
+ const listGeofencesInput: ListGeofencesCommandInput = {
553
+ NextToken: options?.nextToken,
554
+ CollectionName:
555
+ options?.collectionName || this._config.geofenceCollections.default,
556
+ };
557
+
558
+ // Create Amazon Location Service command
559
+ const command: ListGeofencesCommand = new ListGeofencesCommand(
560
+ listGeofencesInput
561
+ );
562
+
563
+ // Make API call
564
+ let response: ListGeofencesCommandOutput;
565
+ try {
566
+ response = await client.send(command);
567
+ } catch (error) {
568
+ logger.debug(error);
569
+ throw error;
570
+ }
571
+
572
+ // Convert response to camelCase for return
573
+ const { NextToken, Entries } = response;
574
+
575
+ const results: ListGeofenceResults = {
576
+ entries: Entries.map(
577
+ ({
578
+ GeofenceId,
579
+ CreateTime,
580
+ UpdateTime,
581
+ Status,
582
+ Geometry: { Polygon },
583
+ }) => {
584
+ return {
585
+ geofenceId: GeofenceId,
586
+ createTime: CreateTime,
587
+ updateTime: UpdateTime,
588
+ status: Status,
589
+ geometry: {
590
+ polygon: Polygon as GeofencePolygon,
591
+ },
592
+ };
593
+ }
594
+ ),
595
+ nextToken: NextToken,
596
+ };
597
+
598
+ return results;
599
+ }
600
+
601
+ /**
602
+ * Delete geofences from a geofence collection
603
+ * @param geofenceIds: string|string[]
604
+ * @param options?: GeofenceOptions
605
+ * @returns {Promise<DeleteGeofencesResults>} - Promise that resolves to an object with:
606
+ * successes: list of geofences successfully deleted
607
+ * errors: list of geofences that failed to delete
608
+ */
609
+ public async deleteGeofences(
610
+ geofenceIds: string[],
611
+ options?: AmazonLocationServiceGeofenceOptions
612
+ ): Promise<AmazonLocationServiceDeleteGeofencesResults> {
613
+ const credentialsOK = await this._ensureCredentials();
614
+ if (!credentialsOK) {
615
+ throw new Error('No credentials');
616
+ }
617
+
618
+ // Verify geofence collection exists in aws-config.js
619
+ try {
620
+ this._verifyGeofenceCollections(options?.collectionName);
621
+ } catch (error) {
622
+ logger.debug(error);
623
+ throw error;
624
+ }
625
+
626
+ const results: AmazonLocationServiceDeleteGeofencesResults = {
627
+ successes: [],
628
+ errors: [],
629
+ };
630
+
631
+ const batches = [];
632
+
633
+ let count = 0;
634
+ while (count < geofenceIds.length) {
635
+ batches.push(geofenceIds.slice(count, (count += 10)));
636
+ }
637
+
638
+ await Promise.all(
639
+ batches.map(async batch => {
640
+ let response;
641
+ try {
642
+ response = await this._AmazonLocationServiceBatchDeleteGeofenceCall(
643
+ batch,
644
+ options?.collectionName || this._config.geofenceCollections.default
645
+ );
646
+ } catch (error) {
647
+ // If the API call fails, add the geofences to the errors array and move to next batch
648
+ batch.forEach(geofenceId => {
649
+ const errorObject = {
650
+ geofenceId,
651
+ error: {
652
+ code: error.message,
653
+ message: error.message,
654
+ },
655
+ };
656
+ results.errors.push(errorObject);
657
+ });
658
+ return;
659
+ }
660
+
661
+ const badGeofenceIds = response.Errors.map(
662
+ ({ geofenceId }) => geofenceId
663
+ );
664
+ results.successes.push(
665
+ ...batch.filter(Id => !badGeofenceIds.includes(Id))
666
+ );
667
+ })
668
+ );
669
+ return results;
670
+ }
671
+
336
672
  /**
337
673
  * @private
338
674
  */
@@ -345,7 +681,7 @@ export class AmazonLocationServiceProvider implements GeoProvider {
345
681
  this._config.credentials = cred;
346
682
  return true;
347
683
  } catch (error) {
348
- logger.warn('Ensure credentials error. Credentials are:', error);
684
+ logger.debug('Ensure credentials error. Credentials are:', error);
349
685
  return false;
350
686
  }
351
687
  }
@@ -353,14 +689,14 @@ export class AmazonLocationServiceProvider implements GeoProvider {
353
689
  private _verifyMapResources() {
354
690
  if (!this._config.maps) {
355
691
  const errorString =
356
- "No map resources found in amplify config, run 'amplify add geo' to create them and run `amplify push` after";
357
- logger.warn(errorString);
692
+ "No map resources found in amplify config, run 'amplify add geo' to create one and run `amplify push` after";
693
+ logger.debug(errorString);
358
694
  throw new Error(errorString);
359
695
  }
360
696
  if (!this._config.maps.default) {
361
697
  const errorString =
362
698
  "No default map resource found in amplify config, run 'amplify add geo' to create one and run `amplify push` after";
363
- logger.warn(errorString);
699
+ logger.debug(errorString);
364
700
  throw new Error(errorString);
365
701
  }
366
702
  }
@@ -371,9 +707,76 @@ export class AmazonLocationServiceProvider implements GeoProvider {
371
707
  !optionalSearchIndex
372
708
  ) {
373
709
  const errorString =
374
- 'No Search Index found, please run `amplify add geo` to add one and run `amplify push` after.';
375
- logger.warn(errorString);
710
+ 'No Search Index found in amplify config, please run `amplify add geo` to create one and run `amplify push` after.';
711
+ logger.debug(errorString);
712
+ throw new Error(errorString);
713
+ }
714
+ }
715
+
716
+ private _verifyGeofenceCollections(optionalGeofenceCollectionName?: string) {
717
+ if (
718
+ (!this._config.geofenceCollections ||
719
+ !this._config.geofenceCollections.default) &&
720
+ !optionalGeofenceCollectionName
721
+ ) {
722
+ const errorString =
723
+ 'No Geofence Collections found, please run `amplify add geo` to create one and run `amplify push` after.';
724
+ logger.debug(errorString);
376
725
  throw new Error(errorString);
377
726
  }
378
727
  }
728
+
729
+ private async _AmazonLocationServiceBatchPutGeofenceCall(
730
+ PascalGeofences: BatchPutGeofenceRequestEntry[],
731
+ collectionName?: string
732
+ ) {
733
+ // Create the BatchPutGeofence input
734
+ const geofenceInput: BatchPutGeofenceCommandInput = {
735
+ Entries: PascalGeofences,
736
+ CollectionName:
737
+ collectionName || this._config.geofenceCollections.default,
738
+ };
739
+
740
+ const client = new LocationClient({
741
+ credentials: this._config.credentials,
742
+ region: this._config.region,
743
+ customUserAgent: getAmplifyUserAgent(),
744
+ });
745
+ const command = new BatchPutGeofenceCommand(geofenceInput);
746
+
747
+ let response: BatchPutGeofenceCommandOutput;
748
+ try {
749
+ response = await client.send(command);
750
+ } catch (error) {
751
+ throw error;
752
+ }
753
+ return response;
754
+ }
755
+
756
+ private async _AmazonLocationServiceBatchDeleteGeofenceCall(
757
+ geofenceIds: string[],
758
+ collectionName?: string
759
+ ): Promise<BatchDeleteGeofenceCommandOutput> {
760
+ // Create the BatchDeleteGeofence input
761
+ const deleteGeofencesInput: BatchDeleteGeofenceCommandInput = {
762
+ GeofenceIds: geofenceIds,
763
+ CollectionName:
764
+ collectionName || this._config.geofenceCollections.default,
765
+ };
766
+
767
+ const client = new LocationClient({
768
+ credentials: this._config.credentials,
769
+ region: this._config.region,
770
+ customUserAgent: getAmplifyUserAgent(),
771
+ });
772
+ const command = new BatchDeleteGeofenceCommand(deleteGeofencesInput);
773
+
774
+ let response: BatchDeleteGeofenceCommandOutput;
775
+ try {
776
+ response = await client.send(command);
777
+ } catch (error) {
778
+ throw error;
779
+ }
780
+ return response;
781
+ }
379
782
  }
@@ -1,5 +1,60 @@
1
- import { MapStyle } from './Geo';
1
+ import {
2
+ MapStyle,
3
+ GeofenceOptions,
4
+ ListGeofenceOptions,
5
+ Geofence,
6
+ DeleteGeofencesResults,
7
+ GeofenceError,
8
+ } from './Geo';
2
9
 
10
+ // Maps
3
11
  export interface AmazonLocationServiceMapStyle extends MapStyle {
4
12
  region: string;
5
13
  }
14
+
15
+ // Geofences
16
+ export type AmazonLocationServiceGeofenceOptions = GeofenceOptions & {
17
+ collectionName?: string;
18
+ };
19
+
20
+ // Status types for Geofences
21
+ export type AmazonLocationServiceGeofenceStatus =
22
+ | 'ACTIVE'
23
+ | 'PENDING'
24
+ | 'FAILED'
25
+ | 'DELETED'
26
+ | 'DELETING';
27
+
28
+ export type AmazonLocationServiceGeofence = Omit<Geofence, 'status'> & {
29
+ status: AmazonLocationServiceGeofenceStatus;
30
+ };
31
+
32
+ // List Geofences
33
+ export type AmazonLocationServiceListGeofenceOptions = ListGeofenceOptions & {
34
+ collectionName?: string;
35
+ };
36
+
37
+ // Delete Geofences
38
+ export type AmazonLocationServiceBatchGeofenceErrorMessages =
39
+ | 'AccessDeniedException'
40
+ | 'InternalServerException'
41
+ | 'ResourceNotFoundException'
42
+ | 'ThrottlingException'
43
+ | 'ValidationException';
44
+
45
+ export type AmazonLocationServiceBatchGeofenceError = Omit<
46
+ GeofenceError,
47
+ 'error'
48
+ > & {
49
+ error: {
50
+ code: string;
51
+ message: AmazonLocationServiceBatchGeofenceErrorMessages;
52
+ };
53
+ };
54
+
55
+ export type AmazonLocationServiceDeleteGeofencesResults = Omit<
56
+ DeleteGeofencesResults,
57
+ 'errors'
58
+ > & {
59
+ errors: AmazonLocationServiceBatchGeofenceError[];
60
+ };
package/src/types/Geo.ts CHANGED
@@ -22,6 +22,10 @@ export interface GeoConfig {
22
22
  items: string[];
23
23
  default: string;
24
24
  };
25
+ geofenceCollections?: {
26
+ items: string[];
27
+ default: string;
28
+ };
25
29
  };
26
30
  }
27
31
 
@@ -31,10 +35,10 @@ export interface MapStyle {
31
35
  style: string;
32
36
  }
33
37
 
34
- export type Latitude = number;
35
38
  export type Longitude = number;
39
+ export type Latitude = number;
36
40
 
37
- // Coordinate point
41
+ // Coordinates are a tuple of longitude and latitude
38
42
  export type Coordinates = [Longitude, Latitude];
39
43
 
40
44
  // SW Longitude point for bounding box
@@ -73,6 +77,7 @@ export type SearchByTextOptions =
73
77
  | SearchByTextOptionsWithBiasPosition
74
78
  | SearchByTextOptionsWithSearchAreaConstraints;
75
79
 
80
+ // Options object for searchByCoodinates
76
81
  export type SearchByCoordinatesOptions = {
77
82
  maxResults?: number;
78
83
  searchIndexName?: string;
@@ -100,3 +105,68 @@ export interface Place {
100
105
 
101
106
  // Return type for searchForSuggestions
102
107
  export type SearchForSuggestionsResults = string[];
108
+ // Array of 4 or more coordinates, where the first and last coordinate are the same to form a closed boundary
109
+ export type LinearRing = Coordinates[];
110
+
111
+ // An array of one linear ring
112
+ export type GeofencePolygon = LinearRing[];
113
+
114
+ // Geometry object for Polygon
115
+ export type PolygonGeometry = {
116
+ polygon: GeofencePolygon;
117
+ };
118
+
119
+ // Geofence object used as input for saveGeofences
120
+ export type GeofenceInput = {
121
+ geofenceId: string;
122
+ geometry: PolygonGeometry;
123
+ };
124
+
125
+ // Options object for saveGeofences
126
+ export type GeofenceOptions = {
127
+ providerName?: string;
128
+ };
129
+
130
+ // Error type for errors related to Geofence API calls
131
+ export type GeofenceError = {
132
+ error: {
133
+ code: string;
134
+ message: string;
135
+ };
136
+ geofenceId: string;
137
+ };
138
+
139
+ // Base geofence object
140
+ type GeofenceBase = {
141
+ geofenceId: string;
142
+ createTime?: Date;
143
+ updateTime?: Date;
144
+ };
145
+
146
+ // Results object for getGeofence
147
+ export type Geofence = GeofenceBase & {
148
+ geometry: PolygonGeometry;
149
+ };
150
+
151
+ // Results object for saveGeofences
152
+ export type SaveGeofencesResults = {
153
+ successes: GeofenceBase[];
154
+ errors: GeofenceError[];
155
+ };
156
+
157
+ // Options object for listGeofence
158
+ export type ListGeofenceOptions = GeofenceOptions & {
159
+ nextToken?: string;
160
+ };
161
+
162
+ // Results options for listGeofence
163
+ export type ListGeofenceResults = {
164
+ entries: Geofence[];
165
+ nextToken: string;
166
+ };
167
+
168
+ // Results object for deleteGeofence
169
+ export type DeleteGeofencesResults = {
170
+ successes: string[];
171
+ errors: GeofenceError[];
172
+ };
@@ -10,7 +10,6 @@
10
10
  * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
11
11
  * and limitations under the License.
12
12
  */
13
-
14
13
  import {
15
14
  SearchByTextOptions,
16
15
  SearchByCoordinatesOptions,
@@ -18,6 +17,13 @@ import {
18
17
  Coordinates,
19
18
  Place,
20
19
  MapStyle,
20
+ Geofence,
21
+ GeofenceInput,
22
+ GeofenceOptions,
23
+ ListGeofenceOptions,
24
+ ListGeofenceResults,
25
+ SaveGeofencesResults,
26
+ DeleteGeofencesResults,
21
27
  } from './Geo';
22
28
 
23
29
  export interface GeoProvider {
@@ -36,15 +42,39 @@ export interface GeoProvider {
36
42
  // get the map resource listed as default
37
43
  getDefaultMap(): MapStyle;
38
44
 
45
+ // search by a text string and return a list of places
39
46
  searchByText(text: string, options?: SearchByTextOptions): Promise<Place[]>;
40
47
 
48
+ // search by coordinates and return a matching place
41
49
  searchByCoordinates(
42
50
  coordinates: Coordinates,
43
51
  options?: SearchByCoordinatesOptions
44
52
  ): Promise<Place>;
45
53
 
54
+ // search for suggestions based on a text string
46
55
  searchForSuggestions(
47
56
  text: string,
48
57
  options?: SearchByTextOptions
49
58
  ): Promise<SearchForSuggestionsResults>;
59
+
60
+ // create geofences
61
+ saveGeofences(
62
+ geofences: GeofenceInput[],
63
+ options?: GeofenceOptions
64
+ ): Promise<SaveGeofencesResults>;
65
+
66
+ // get a single geofence
67
+ getGeofence(
68
+ geofenceId: string,
69
+ options?: ListGeofenceOptions
70
+ ): Promise<Geofence>;
71
+
72
+ // list all geofences
73
+ listGeofences(options?: ListGeofenceOptions): Promise<ListGeofenceResults>;
74
+
75
+ // Delete geofences
76
+ deleteGeofences(
77
+ geofenceIds: string[],
78
+ options?: GeofenceOptions
79
+ ): Promise<DeleteGeofencesResults>;
50
80
  }