@tomtom-org/maps-sdk 0.30.2 → 0.31.1

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/map/package.json CHANGED
@@ -14,14 +14,6 @@
14
14
  "clean:dist": "rimraf ./dist"
15
15
  },
16
16
  "types": "./dist/index.d.ts",
17
- "repository": {
18
- "type": "git",
19
- "url": "git+https://github.com/tomtom-international/maps-sdk-js.git"
20
- },
21
- "bugs": {
22
- "url": "https://github.com/tomtom-international/maps-sdk-js/issues"
23
- },
24
- "homepage": "https://github.com/tomtom-international/maps-sdk-js#readme",
25
17
  "devDependencies": {
26
18
  "@microsoft/api-extractor": "catalog:",
27
19
  "@rollup/plugin-terser": "catalog:",
package/package.json CHANGED
@@ -2,12 +2,8 @@
2
2
  "name": "@tomtom-org/maps-sdk",
3
3
  "author": "TomTom International B.V.",
4
4
  "license": "See in LICENSE.txt",
5
- "version": "0.30.2",
6
- "description": "JavaScript library for TomTom maps and location services",
7
- "repository": {
8
- "type": "git",
9
- "url": "git+https://github.com/tomtom-international/maps-sdk-js.git"
10
- },
5
+ "version": "0.31.1",
6
+ "description": "TomTom Maps for JavaScript",
11
7
  "keywords": [
12
8
  "tomtom",
13
9
  "sdk",
@@ -21,12 +17,8 @@
21
17
  "web",
22
18
  "nodejs"
23
19
  ],
24
- "bugs": {
25
- "url": "https://github.com/tomtom-international/maps-sdk-js/issues"
26
- },
27
- "homepage": "https://github.com/tomtom-international/maps-sdk-js#readme",
28
20
  "devDependencies": {
29
- "@biomejs/biome": "^2.3.3",
21
+ "@biomejs/biome": "^2.3.4",
30
22
  "@size-limit/file": "^11.2.0",
31
23
  "@size-limit/preset-app": "^11.2.0",
32
24
  "size-limit": "^11.2.0",
@@ -60,8 +52,6 @@
60
52
  "services/package.json",
61
53
  "package.json",
62
54
  "README.md",
63
- "sdk-examples-collage.png",
64
- "tomtom-logo-big.svg",
65
55
  "CHANGELOG.md",
66
56
  "LICENSE.txt"
67
57
  ],
@@ -665,7 +665,7 @@ declare type BatteryCurve = {
665
665
  *
666
666
  * @group Fuzzy Search
667
667
  */
668
- declare type BookmarkIntent = {
668
+ export declare type BookmarkIntent = {
669
669
  /**
670
670
  * Query type identifier.
671
671
  *
@@ -685,7 +685,7 @@ declare type BookmarkIntent = {
685
685
  *
686
686
  * @group Fuzzy Search
687
687
  */
688
- declare type BookmarkIntentDetails = {
688
+ export declare type BookmarkIntentDetails = {
689
689
  /**
690
690
  * The detected bookmark keyword.
691
691
  *
@@ -834,86 +834,13 @@ export declare const buildResponseError: (error: unknown, serviceName: ServiceNa
834
834
  export declare const buildValidationError: (error: ValidationError, serviceName: ServiceName) => SDKError;
835
835
 
836
836
  /**
837
- * Calculate optimal routes between locations with comprehensive routing options.
837
+ * Calculates a route between an origin and destination, optionally passing through extra waypoints.
838
838
  *
839
- * The Calculate Route service computes the best path between an origin and destination,
840
- * optionally passing through intermediate waypoints. Routes account for real-time traffic,
841
- * vehicle characteristics, and user preferences.
839
+ * @param params - Route calculation parameters including locations, travel mode, and other options
840
+ * @param customTemplate - Optional template customization for request/response handling
841
+ * @returns Promise resolving to calculated route(s) with geometry, distance, and travel time
842
842
  *
843
- * @remarks
844
- * This service provides:
845
- * - **Traffic-aware routing**: Uses current traffic and typical road speeds
846
- * - **Turn-by-turn guidance**: Optional navigation instructions
847
- * - **Alternative routes**: Multiple route options with different characteristics
848
- * - **EV routing**: Long-distance electric vehicle routing with charging stops
849
- * - **Consumption estimates**: Fuel or battery consumption calculations
850
- * - **Route sections**: Detailed breakdowns (tolls, ferries, traffic, countries)
851
- *
852
- * Route calculations consider:
853
- * - Current and historic traffic patterns
854
- * - Road types and speeds
855
- * - Vehicle specifications (dimensions, weight, engine type)
856
- * - User preferences (avoid tolls, motorways, ferries, etc.)
857
- * - Departure/arrival time
858
- *
859
- * @param params - Routing parameters including waypoints and options
860
- * @param customTemplate - Advanced customization for request/response handling
861
- *
862
- * @returns Promise resolving to calculated route(s) with geometry and metadata
863
- *
864
- * @example
865
- * ```typescript
866
- * // Basic route calculation
867
- * const route = await calculateRoute({
868
- * key: 'your-api-key',
869
- * locations: [
870
- * [4.9041, 52.3676], // Amsterdam
871
- * [4.4777, 51.9244] // Rotterdam
872
- * ]
873
- * });
874
- *
875
- * // Route with guidance and alternatives
876
- * const guidedRoute = await calculateRoute({
877
- * key: 'your-api-key',
878
- * locations: [[4.9, 52.3], [4.5, 51.9]],
879
- * guidance: { type: 'coded', phonetics: 'IPA' },
880
- * maxAlternatives: 2,
881
- * routeType: 'fastest',
882
- * avoid: ['tollRoads'],
883
- * departAt: new Date('2025-10-20T08:00:00Z')
884
- * });
885
- *
886
- * // Electric vehicle route with charging
887
- * const evRoute = await calculateRoute({
888
- * key: 'your-api-key',
889
- * locations: [[4.9, 52.3], [8.5, 50.1]], // Long distance
890
- * vehicleEngineType: 'electric',
891
- * currentChargeInkWh: 50,
892
- * maxChargeInkWh: 85,
893
- * constantSpeedConsumptionInkWhPerHundredkm: [[50, 8], [80, 12], [120, 18]]
894
- * });
895
- *
896
- * // Multi-stop delivery route
897
- * const deliveryRoute = await calculateRoute({
898
- * key: 'your-api-key',
899
- * locations: [
900
- * [4.9, 52.3], // Warehouse
901
- * [4.85, 52.32], // Stop 1
902
- * [4.88, 52.35], // Stop 2
903
- * [4.92, 52.38] // Stop 3
904
- * ],
905
- * vehicleCommercial: true,
906
- * vehicleLoadType: ['otherHazmatGeneral']
907
- * });
908
- * ```
909
- *
910
- * @see [Calculate Route API Documentation](https://docs.tomtom.com/routing-api/documentation/routing/calculate-route)
911
- * @see [Routing Quickstart Guide](https://docs.tomtom.com/maps-sdk-js/guides/services/routing/quickstart)
912
- * @see [Planning a Route Guide](https://docs.tomtom.com/maps-sdk-js/guides/services/routing/planning-a-route)
913
- * @see [Waypoints and Custom Routes Guide](https://docs.tomtom.com/maps-sdk-js/guides/services/routing/waypoints-and-custom-routes)
914
- * @see [Planning Criteria Guide](https://docs.tomtom.com/maps-sdk-js/guides/services/routing/planning-criteria)
915
- * @see [Route Sections Guide](https://docs.tomtom.com/maps-sdk-js/guides/services/routing/route-sections)
916
- * @see [Long Distance EV Routing Guide](https://docs.tomtom.com/maps-sdk-js/guides/services/routing/long-distance-ev-routing)
843
+ * @see [Calculate Route API Documentation](https://docs.tomtom.com/routing-api/documentation/tomtom-maps/calculate-route)
917
844
  *
918
845
  * @group Routing
919
846
  */
@@ -929,7 +856,7 @@ export declare const calculateRoute: (params: CalculateRouteParams, customTempla
929
856
  * ```typescript
930
857
  * // Basic route from A to B
931
858
  * const params: CalculateRouteParams = {
932
- * key: 'your-api-key',
859
+ * apiKey: 'your-api-key',
933
860
  * locations: [
934
861
  * [4.9041, 52.3676], // Amsterdam
935
862
  * [4.4777, 51.9244] // Rotterdam
@@ -938,23 +865,40 @@ export declare const calculateRoute: (params: CalculateRouteParams, customTempla
938
865
  *
939
866
  * // Route with guidance and alternatives
940
867
  * const advancedParams: CalculateRouteParams = {
941
- * key: 'your-api-key',
868
+ * apiKey: 'your-api-key',
942
869
  * locations: [[4.9041, 52.3676], [4.4777, 51.9244]],
943
870
  * guidance: { type: 'coded', phonetics: 'IPA' },
944
871
  * maxAlternatives: 2,
945
- * routeType: 'fastest',
946
- * avoid: ['tollRoads', 'motorways'],
947
- * departAt: new Date('2025-10-20T08:00:00Z')
872
+ * costModel: {
873
+ * routeType: 'fast',
874
+ * avoid: ['tollRoads', 'motorways']
875
+ * },
876
+ * when: {
877
+ * option: 'departAt',
878
+ * date: new Date('2025-10-20T08:00:00Z')
879
+ * }
948
880
  * };
949
881
  *
950
882
  * // Electric vehicle route with charging
951
883
  * const evParams: CalculateRouteParams = {
952
- * key: 'your-api-key',
884
+ * apiKey: 'your-api-key',
953
885
  * locations: [[4.9, 52.3], [8.5, 50.1]],
954
- * vehicleEngineType: 'electric',
955
- * currentChargeInkWh: 50,
956
- * maxChargeInkWh: 85,
957
- * constantSpeedConsumptionInkWhPerHundredkm: [[50, 8], [80, 12], [120, 18]]
886
+ * vehicle: {
887
+ * engineType: 'electric',
888
+ * model: {
889
+ * engine: {
890
+ * consumption: {
891
+ * charging: { maxChargeKWH: 85 },
892
+ * speedToConsumption: [
893
+ * { speedKMH: 50, consumptionUnitsPer100KM: 8 },
894
+ * { speedKMH: 80, consumptionUnitsPer100KM: 12 },
895
+ * { speedKMH: 120, consumptionUnitsPer100KM: 18 }
896
+ * ]
897
+ * }
898
+ * }
899
+ * },
900
+ * state: { currentChargeInkWh: 50 }
901
+ * }
958
902
  * };
959
903
  * ```
960
904
  *
@@ -2864,7 +2808,7 @@ declare type ConsumptionModelEfficiency = {
2864
2808
  *
2865
2809
  * @group Fuzzy Search
2866
2810
  */
2867
- declare type CoordinateIntent = {
2811
+ export declare type CoordinateIntent = {
2868
2812
  /**
2869
2813
  * Query type identifier.
2870
2814
  *
@@ -2880,7 +2824,7 @@ declare type CoordinateIntent = {
2880
2824
  /**
2881
2825
  * @ignore
2882
2826
  */
2883
- declare type CoordinateIntentAPI = {
2827
+ export declare type CoordinateIntentAPI = {
2884
2828
  /**
2885
2829
  * the query is a coordinate in one of the supported formats (e.g., "48.858380, 2.294440").
2886
2830
  */
@@ -2895,7 +2839,7 @@ declare type CoordinateIntentAPI = {
2895
2839
  *
2896
2840
  * @group Fuzzy Search
2897
2841
  */
2898
- declare type CoordinateIntentDetails = {
2842
+ export declare type CoordinateIntentDetails = {
2899
2843
  /**
2900
2844
  * Position of the parsed coordinate from user input.
2901
2845
  *
@@ -2909,7 +2853,7 @@ declare type CoordinateIntentDetails = {
2909
2853
  /**
2910
2854
  * @ignore
2911
2855
  */
2912
- declare type CoordinateIntentDetailsAPI = {
2856
+ export declare type CoordinateIntentDetailsAPI = {
2913
2857
  /**
2914
2858
  * Latitude of the (parsed) user input coordinate. See LatLon. The results will be places nearby this coordinate.
2915
2859
  * If lat and lon parameters are specified, the dist field will have the distance between the geoBias and the searched coordinate.
@@ -3630,6 +3574,75 @@ export declare type FetchInput<PostData = void> = {
3630
3574
  method: 'POST';
3631
3575
  } & PostObject<PostData>);
3632
3576
 
3577
+ /**
3578
+ * Search for places using free-text queries with fuzzy matching.
3579
+ *
3580
+ * The Fuzzy Search service provides a flexible search that handles typos, abbreviations,
3581
+ * and incomplete addresses. It searches across POIs (Points of Interest), addresses,
3582
+ * and geographic areas to find the best matches for your query.
3583
+ *
3584
+ * @remarks
3585
+ * Key features:
3586
+ * - **Typo tolerance**: Handles misspellings and typing errors
3587
+ * - **Partial matching**: Works with incomplete queries
3588
+ * - **Multi-category search**: Searches POIs, addresses, and places simultaneously
3589
+ * - **Position bias**: Prioritizes results near a given location
3590
+ * - **Flexible input**: Accepts natural language queries
3591
+ *
3592
+ * The service is ideal for:
3593
+ * - User-facing search boxes where typos are common
3594
+ * - Location lookup without knowing exact names
3595
+ * - General "find anything" search functionality
3596
+ * - Autocomplete with final selection
3597
+ *
3598
+ * @param params Fuzzy search parameters including the search query
3599
+ * @param customTemplate Advanced customization for request/response handling
3600
+ *
3601
+ * @returns Promise resolving to a collection of matching places
3602
+ *
3603
+ * @example
3604
+ * ```typescript
3605
+ * // Basic search with typo tolerance
3606
+ * const results = await fuzzySearch({
3607
+ * key: 'your-api-key',
3608
+ * query: 'amstrdam' // Typo: missing 'e'
3609
+ * });
3610
+ * // Still finds "Amsterdam"
3611
+ *
3612
+ * // Search near a specific location
3613
+ * const nearby = await fuzzySearch({
3614
+ * key: 'your-api-key',
3615
+ * query: 'pizza',
3616
+ * at: [4.9041, 52.3676], // Amsterdam
3617
+ * radius: 2000, // Within 2km
3618
+ * limit: 10
3619
+ * });
3620
+ *
3621
+ * // Search with category filter
3622
+ * const restaurants = await fuzzySearch({
3623
+ * key: 'your-api-key',
3624
+ * query: 'italian',
3625
+ * categorySet: [7315], // Restaurant category
3626
+ * at: [4.9041, 52.3676]
3627
+ * });
3628
+ *
3629
+ * // Partial address search
3630
+ * const addresses = await fuzzySearch({
3631
+ * key: 'your-api-key',
3632
+ * query: '123 main st',
3633
+ * countrySet: ['US'],
3634
+ * limit: 5
3635
+ * });
3636
+ * ```
3637
+ *
3638
+ * @see [Fuzzy Search API Documentation](https://docs.tomtom.com/search-api/documentation/search-service/fuzzy-search)
3639
+ * @see [Places Quickstart Guide](https://docs.tomtom.com/maps-sdk-js/guides/services/places/quickstart)
3640
+ * @see [Search Guide](https://docs.tomtom.com/maps-sdk-js/guides/services/places/search)
3641
+ *
3642
+ * @group Search
3643
+ */
3644
+ export declare const fuzzySearch: (params: FuzzySearchParams, customTemplate?: Partial<FuzzySearchTemplate>) => Promise<FuzzySearchResponse>;
3645
+
3633
3646
  /**
3634
3647
  * Additional properties for fuzzy search feature collection.
3635
3648
  *
@@ -3689,7 +3702,7 @@ declare type FuzzySearchFeatureCollectionProps = SearchSummary & {
3689
3702
  *
3690
3703
  * @group Search
3691
3704
  */
3692
- declare type FuzzySearchParams = CommonSearchParams<URL, FuzzySearchResponseAPI> & CommonGeocodeAndFuzzySearchParams & {
3705
+ export declare type FuzzySearchParams = CommonSearchParams<URL, FuzzySearchResponseAPI> & CommonGeocodeAndFuzzySearchParams & {
3693
3706
  /**
3694
3707
  * Minimum fuzziness level to be used.
3695
3708
  *
@@ -3750,12 +3763,12 @@ declare type FuzzySearchParams = CommonSearchParams<URL, FuzzySearchResponseAPI>
3750
3763
  *
3751
3764
  * @group Fuzzy Search
3752
3765
  */
3753
- declare type FuzzySearchResponse = Places<SearchPlaceProps, FuzzySearchFeatureCollectionProps>;
3766
+ export declare type FuzzySearchResponse = Places<SearchPlaceProps, FuzzySearchFeatureCollectionProps>;
3754
3767
 
3755
3768
  /**
3756
3769
  * @ignore
3757
3770
  */
3758
- declare type FuzzySearchResponseAPI = {
3771
+ export declare type FuzzySearchResponseAPI = {
3759
3772
  /**
3760
3773
  * Summary information about the search that was performed.
3761
3774
  */
@@ -3771,7 +3784,7 @@ declare type FuzzySearchResponseAPI = {
3771
3784
  /**
3772
3785
  * @ignore
3773
3786
  */
3774
- declare type FuzzySearchResultAPI = CommonSearchPlaceResultAPI;
3787
+ export declare type FuzzySearchResultAPI = CommonSearchPlaceResultAPI;
3775
3788
 
3776
3789
  /**
3777
3790
  * Fuzzy search service template type.
@@ -4722,7 +4735,7 @@ declare type MomentAPI = {
4722
4735
  *
4723
4736
  * @group Fuzzy Search
4724
4737
  */
4725
- declare type NearbyIntent = {
4738
+ export declare type NearbyIntent = {
4726
4739
  /**
4727
4740
  * Query type identifier.
4728
4741
  *
@@ -4738,7 +4751,7 @@ declare type NearbyIntent = {
4738
4751
  /**
4739
4752
  * @ignore
4740
4753
  */
4741
- declare type NearbyIntentAPI = {
4754
+ export declare type NearbyIntentAPI = {
4742
4755
  /**
4743
4756
  * the query asks for some entity in the proximity of another entity (e.g., "hotel near Lyon").
4744
4757
  */
@@ -4754,7 +4767,7 @@ declare type NearbyIntentAPI = {
4754
4767
  *
4755
4768
  * @group Fuzzy Search
4756
4769
  */
4757
- declare type NearbyIntentDetails = {
4770
+ export declare type NearbyIntentDetails = {
4758
4771
  /**
4759
4772
  * Position of the reference location in the nearby search.
4760
4773
  *
@@ -4783,7 +4796,7 @@ declare type NearbyIntentDetails = {
4783
4796
  /**
4784
4797
  * @ignore
4785
4798
  */
4786
- declare type NearbyIntentDetailsAPI = Omit<NearbyIntentDetails, 'position'> & {
4799
+ export declare type NearbyIntentDetailsAPI = Omit<NearbyIntentDetails, 'position'> & {
4787
4800
  /**
4788
4801
  * Latitude of the place, near which the user searches for something.
4789
4802
  * For example, for the input restaurant near Berlin central station this is the position of "Berlin Central Station".
@@ -5192,12 +5205,12 @@ declare type PredefinedVehicleModel = {
5192
5205
  *
5193
5206
  * @group Fuzzy Search
5194
5207
  */
5195
- declare type QueryIntent = CoordinateIntent | NearbyIntent | W3WIntent | BookmarkIntent;
5208
+ export declare type QueryIntent = CoordinateIntent | NearbyIntent | W3WIntent | BookmarkIntent;
5196
5209
 
5197
5210
  /**
5198
5211
  * @ignore
5199
5212
  */
5200
- declare type QueryIntentAPI = CoordinateIntentAPI | NearbyIntentAPI | W3WIntent | BookmarkIntent;
5213
+ export declare type QueryIntentAPI = CoordinateIntentAPI | NearbyIntentAPI | W3WIntent | BookmarkIntent;
5201
5214
 
5202
5215
  /**
5203
5216
  * Budget constraint for reachable range calculation.
@@ -6951,7 +6964,7 @@ declare type ViewportAPI = {
6951
6964
  *
6952
6965
  * @group Fuzzy Search
6953
6966
  */
6954
- declare type W3WIntent = {
6967
+ export declare type W3WIntent = {
6955
6968
  /**
6956
6969
  * Query type identifier.
6957
6970
  *
@@ -6971,7 +6984,7 @@ declare type W3WIntent = {
6971
6984
  *
6972
6985
  * @group Fuzzy Search
6973
6986
  */
6974
- declare type W3WIntentDetails = {
6987
+ export declare type W3WIntentDetails = {
6975
6988
  /**
6976
6989
  * The detected what3words address.
6977
6990
  *
@@ -4670,11 +4670,60 @@ const toCountrySectionProps = (apiSection) => ({
4670
4670
  countryCodeISO3: apiSection.countryCode
4671
4671
  });
4672
4672
  const toVehicleRestrictedSectionProps = (apiSection) => apiSection.travelMode === "other" ? toSectionProps(apiSection) : null;
4673
+ const calculateTrafficCategory = (tecMainCauseCode) => {
4674
+ switch (tecMainCauseCode) {
4675
+ case 1:
4676
+ return "jam";
4677
+ case 2:
4678
+ return "accident";
4679
+ case 3:
4680
+ return "roadworks";
4681
+ case 4:
4682
+ return "narrow-lanes";
4683
+ case 5:
4684
+ return "road-closed";
4685
+ case 9:
4686
+ return "danger";
4687
+ case 11:
4688
+ return "animals-on-road";
4689
+ case 13:
4690
+ return "broken-down-vehicle";
4691
+ case 16:
4692
+ return "lane-closed";
4693
+ case 17:
4694
+ return "wind";
4695
+ case 18:
4696
+ return "fog";
4697
+ case 19:
4698
+ return "rain";
4699
+ case 22:
4700
+ return "frost";
4701
+ case 23:
4702
+ return "flooding";
4703
+ default:
4704
+ return "other";
4705
+ }
4706
+ };
4707
+ const toTrafficCategories = (apiSection) => {
4708
+ if (apiSection.tec?.causes?.length) {
4709
+ return apiSection.tec.causes.map((cause) => calculateTrafficCategory(cause.mainCauseCode));
4710
+ }
4711
+ switch (apiSection.simpleCategory) {
4712
+ case "JAM":
4713
+ return ["jam"];
4714
+ case "ROAD_WORK":
4715
+ return ["roadworks"];
4716
+ case "ROAD_CLOSURE":
4717
+ return ["road-closed"];
4718
+ default:
4719
+ return ["other"];
4720
+ }
4721
+ };
4673
4722
  const toTrafficSectionProps = (apiSection) => ({
4674
4723
  ...toSectionProps(apiSection),
4675
4724
  delayInSeconds: apiSection.delayInSeconds,
4676
4725
  effectiveSpeedInKmh: apiSection.effectiveSpeedInKmh,
4677
- simpleCategory: apiSection.simpleCategory.toLowerCase(),
4726
+ categories: toTrafficCategories(apiSection),
4678
4727
  magnitudeOfDelay: core.indexedMagnitudes[apiSection.magnitudeOfDelay],
4679
4728
  tec: apiSection.tec
4680
4729
  });
@@ -4999,6 +5048,7 @@ exports.buildValidationError = buildValidationError;
4999
5048
  exports.calculateRoute = calculateRoute;
5000
5049
  exports.customizeService = customizeService;
5001
5050
  exports.evChargingStationsAvailability = evChargingStationsAvailability;
5051
+ exports.fuzzySearch = fuzzySearch;
5002
5052
  exports.geocode = geocode;
5003
5053
  exports.geocodeOne = geocodeOne;
5004
5054
  exports.geometryData = geometryData;