diff --git a/.circleci/config.yml b/.circleci/config.yml index e59574eab..0f2f18eba 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -10,19 +10,23 @@ workflows: develop-build: jobs: - pre-check: + context: SDK Registry Token filters: tags: only: /v.*/ - build: + context: SDK Registry Token requires: - pre-check filters: tags: only: /v.*/ - spm-build: + context: SDK Registry Token requires: - pre-check - release-pre-check: + context: SDK Registry Token requires: - pre-check filters: diff --git a/CHANGELOG.md b/CHANGELOG.md index 46711d9a0..fc4679a82 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,17 @@ Guide: https://keepachangelog.com/en/1.0.0/ +- [SearchResult] Add support for `mapboxId` field when availalbe. +- [FavoriteRecord] Add support for `mapboxId` field when availalbe. +- [HistoryRecord] Add support for `mapboxId` field when availalbe. +- [Discover] Add more complete support for `mapboxId` field in Result subtype when availalbe. +- [Address Autofill] Add more complete support for `mapboxId` field in Result and Suggestion subtypes when availalbe. +- [Place Autocomplete] Add more complete support for `mapboxId` field in Result and Suggestion subtypes when availalbe. +- [Demo] Add `mapboxId` table view cell to PlaceAutocomplete detail view controller when available. + +- [Offline] Remove `CoreOfflineIndexChangeEventType` extension previously used for development. +- [Core] Remove usages of `@_implementationOnly import` due to compilation issue. + - [Offline] Add optional `language` parameter to SearchOfflineManager.createTilesetDescriptor and SearchOfflineManager.createPlacesTilesetDescriptor functions. - [Tests] Add Spanish language offline search test. diff --git a/MapboxSearch.xcodeproj/project.pbxproj b/MapboxSearch.xcodeproj/project.pbxproj index 5bd2f145d..1f3f568b7 100644 --- a/MapboxSearch.xcodeproj/project.pbxproj +++ b/MapboxSearch.xcodeproj/project.pbxproj @@ -33,7 +33,6 @@ 0477904E2B890F4E00A99528 /* search-box-retrieve-minsk.json in Resources */ = {isa = PBXBuildFile; fileRef = 0477904C2B890F4E00A99528 /* search-box-retrieve-minsk.json */; }; 0477904F2B890F4E00A99528 /* search-box-retrieve-minsk.json in Resources */ = {isa = PBXBuildFile; fileRef = 0477904C2B890F4E00A99528 /* search-box-retrieve-minsk.json */; }; 0484BCDF2BC4865C003CF408 /* OfflineIndexObserver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0484BCDE2BC4865C003CF408 /* OfflineIndexObserver.swift */; }; - 0484BCE22BC49A23003CF408 /* CoreOfflineIndexChangeEventType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0484BCE12BC49A23003CF408 /* CoreOfflineIndexChangeEventType.swift */; }; 048823482B6B0A9D00C770AA /* category-hotel-search-along-route-jp.json in Resources */ = {isa = PBXBuildFile; fileRef = 04AB0B7C2B6B043C00FDE7D5 /* category-hotel-search-along-route-jp.json */; }; 048823492B6B0A9D00C770AA /* category-hotel-search-along-route-jp.json in Resources */ = {isa = PBXBuildFile; fileRef = 04AB0B7C2B6B043C00FDE7D5 /* category-hotel-search-along-route-jp.json */; }; 0488234A2B6B0A9E00C770AA /* category-hotel-search-along-route-jp.json in Resources */ = {isa = PBXBuildFile; fileRef = 04AB0B7C2B6B043C00FDE7D5 /* category-hotel-search-along-route-jp.json */; }; @@ -543,7 +542,6 @@ 047790482B890A8500A99528 /* search-box-recursion.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = "search-box-recursion.json"; sourceTree = ""; }; 0477904C2B890F4E00A99528 /* search-box-retrieve-minsk.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = "search-box-retrieve-minsk.json"; sourceTree = ""; }; 0484BCDE2BC4865C003CF408 /* OfflineIndexObserver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OfflineIndexObserver.swift; sourceTree = ""; }; - 0484BCE12BC49A23003CF408 /* CoreOfflineIndexChangeEventType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CoreOfflineIndexChangeEventType.swift; sourceTree = ""; }; 04970F8C2B7A97C900213763 /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = PrivacyInfo.xcprivacy; sourceTree = ""; }; 04AB0B4A2B6AADB700FDE7D5 /* mapbox.places.san.francisco.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = mapbox.places.san.francisco.json; sourceTree = ""; }; 04AB0B792B6AF37800FDE7D5 /* DiscoverIntegrationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DiscoverIntegrationTests.swift; sourceTree = ""; }; @@ -1056,14 +1054,6 @@ path = sbs; sourceTree = ""; }; - 0484BCE02BC49A18003CF408 /* Offline */ = { - isa = PBXGroup; - children = ( - 0484BCE12BC49A23003CF408 /* CoreOfflineIndexChangeEventType.swift */, - ); - path = Offline; - sourceTree = ""; - }; 04970F8B2B7A97C900213763 /* Resources */ = { isa = PBXGroup; children = ( @@ -1744,7 +1734,6 @@ FEEDD2C12508DFE400DC0A98 /* InternalAPI */ = { isa = PBXGroup; children = ( - 0484BCE02BC49A18003CF408 /* Offline */, 04C127562B62FFD000884325 /* Engine */, 148DE66E285777050085684D /* Common */, F98BECBB2577B9150081D3BC /* Telemetry */, @@ -2677,7 +2666,6 @@ F9E8146225418E7D00F6378E /* EventsManager.swift in Sources */, FEEDD3002508DFE400DC0A98 /* CLLocationCoordinate2DCodable.swift in Sources */, FEEDD3042508DFE400DC0A98 /* SearchResultType.swift in Sources */, - 0484BCE22BC49A23003CF408 /* CoreOfflineIndexChangeEventType.swift in Sources */, F91FD66C258CCB41008CB8E1 /* CoreResultType+Extensions.swift in Sources */, FEEDD3152508DFE400DC0A98 /* ServerSearchResult.swift in Sources */, 140E47A2298BC90E00677E30 /* Discover.swift in Sources */, diff --git a/Sources/Demo/PlaceAutocompleteDetailsViewController.swift b/Sources/Demo/PlaceAutocompleteDetailsViewController.swift index 4633deec7..2cec68a52 100644 --- a/Sources/Demo/PlaceAutocompleteDetailsViewController.swift +++ b/Sources/Demo/PlaceAutocompleteDetailsViewController.swift @@ -168,6 +168,12 @@ extension PlaceAutocomplete.Result { ) } + if let mapboxId { + components.append( + (name: "Mapbox ID", value: mapboxId) + ) + } + return components } } diff --git a/Sources/MapboxSearch/InternalAPI/CoreAliases.swift b/Sources/MapboxSearch/InternalAPI/CoreAliases.swift index 1c69bb309..c718e5480 100644 --- a/Sources/MapboxSearch/InternalAPI/CoreAliases.swift +++ b/Sources/MapboxSearch/InternalAPI/CoreAliases.swift @@ -1,10 +1,8 @@ -@_implementationOnly import MapboxCommon_Private +import MapboxCommon_Private +import MapboxCoreSearch +import MapboxCoreSearch_Private -/// https://forums.swift.org/t/update-on-implementation-only-imports/26996 -@_implementationOnly import MapboxCoreSearch -@_implementationOnly import MapboxCoreSearch_Private - -// Note: This file included in MapboxSearch and MapboxSearchTests targets +// Note: This file is included in MapboxSearch and MapboxSearchTests targets typealias CoreSearchEngine = MapboxCoreSearch.SearchEngine typealias CoreSearchResponse = MapboxCoreSearch_Private.SearchResponse diff --git a/Sources/MapboxSearch/InternalAPI/Offline/CoreOfflineIndexChangeEventType.swift b/Sources/MapboxSearch/InternalAPI/Offline/CoreOfflineIndexChangeEventType.swift deleted file mode 100644 index 0be3ffce2..000000000 --- a/Sources/MapboxSearch/InternalAPI/Offline/CoreOfflineIndexChangeEventType.swift +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright © 2024 Mapbox. All rights reserved. - -import Foundation - -extension CoreOfflineIndexChangeEventType: CustomDebugStringConvertible { - public var debugDescription: String { - switch self { - case .added: - return "Added" - case .removed: - return "Removed" - case .updated: - return "Updated" - @unknown default: - return "Unknown" - } - } -} diff --git a/Sources/MapboxSearch/PublicAPI/FavoriteRecord.swift b/Sources/MapboxSearch/PublicAPI/FavoriteRecord.swift index 24b962b07..9904f2db6 100644 --- a/Sources/MapboxSearch/PublicAPI/FavoriteRecord.swift +++ b/Sources/MapboxSearch/PublicAPI/FavoriteRecord.swift @@ -8,6 +8,9 @@ public struct FavoriteRecord: IndexableRecord, SearchResult, Codable, Equatable /// Displayable name of the record. public var name: String + /// A unique identifier for the geographic feature + public var mapboxId: String? + /** The feature name, as matched by the search algorithm. @@ -79,6 +82,7 @@ public struct FavoriteRecord: IndexableRecord, SearchResult, Codable, Equatable /// - resultType: Favorite result type public init( id: String? = nil, + mapboxId: String? = nil, name: String, matchingName: String?, coordinate: CLLocationCoordinate2D, @@ -93,6 +97,7 @@ public struct FavoriteRecord: IndexableRecord, SearchResult, Codable, Equatable metadata: SearchResultMetadata? = nil ) { self.id = id ?? UUID().uuidString + self.mapboxId = mapboxId self.name = name self.matchingName = matchingName self.coordinateCodable = .init(coordinate) @@ -118,6 +123,7 @@ public struct FavoriteRecord: IndexableRecord, SearchResult, Codable, Equatable ) { self.init( id: id, + mapboxId: searchResult.mapboxId, name: name, matchingName: searchResult.matchingName, coordinate: searchResult.coordinate, diff --git a/Sources/MapboxSearch/PublicAPI/HistoryRecord.swift b/Sources/MapboxSearch/PublicAPI/HistoryRecord.swift index 4fbed4019..3acb136b6 100644 --- a/Sources/MapboxSearch/PublicAPI/HistoryRecord.swift +++ b/Sources/MapboxSearch/PublicAPI/HistoryRecord.swift @@ -20,6 +20,8 @@ public struct HistoryRecord: IndexableRecord, SearchResult, Codable, Hashable { /// Unique identifier public private(set) var id: String + public private(set) var mapboxId: String? + /// Record's name public private(set) var name: String @@ -97,6 +99,7 @@ public struct HistoryRecord: IndexableRecord, SearchResult, Codable, Hashable { /// - routablePoints: Coordinates of building entries public init( id: String = UUID().uuidString, + mapboxId: String?, name: String, matchingName: String?, serverIndex: Int?, @@ -112,6 +115,7 @@ public struct HistoryRecord: IndexableRecord, SearchResult, Codable, Hashable { routablePoints: [RoutablePoint]? = nil ) { self.id = id + self.mapboxId = mapboxId self.name = name self.matchingName = matchingName self.serverIndex = serverIndex @@ -138,6 +142,7 @@ public struct HistoryRecord: IndexableRecord, SearchResult, Codable, Hashable { timestamp: Date = Date() ) { self.id = searchResult.id + self.mapboxId = searchResult.mapboxId self.name = searchResult.name self.matchingName = searchResult.matchingName self.serverIndex = searchResult.serverIndex diff --git a/Sources/MapboxSearch/PublicAPI/Search Results/ExternalRecordPlaceholder.swift b/Sources/MapboxSearch/PublicAPI/Search Results/ExternalRecordPlaceholder.swift index 3ac5ee654..f567f91ff 100644 --- a/Sources/MapboxSearch/PublicAPI/Search Results/ExternalRecordPlaceholder.swift +++ b/Sources/MapboxSearch/PublicAPI/Search Results/ExternalRecordPlaceholder.swift @@ -2,14 +2,14 @@ import CoreLocation import Foundation class ExternalRecordPlaceholder: SearchResultSuggestion, CoreResponseProvider { - var mapboxId: String? - var originalResponse: CoreSearchResultResponse var dataLayerIdentifier: String var id: String + var mapboxId: String? + var name: String var address: Address? diff --git a/Sources/MapboxSearch/PublicAPI/Search Results/SearchCategorySuggestionImpl.swift b/Sources/MapboxSearch/PublicAPI/Search Results/SearchCategorySuggestionImpl.swift index eef83e73b..da12c829c 100644 --- a/Sources/MapboxSearch/PublicAPI/Search Results/SearchCategorySuggestionImpl.swift +++ b/Sources/MapboxSearch/PublicAPI/Search Results/SearchCategorySuggestionImpl.swift @@ -2,12 +2,12 @@ import CoreLocation import Foundation class SearchCategorySuggestionImpl: SearchCategorySuggestion, CoreResponseProvider { - var mapboxId: String? - var originalResponse: CoreSearchResultResponse var id: String + var mapboxId: String? + var name: String var address: Address? diff --git a/Sources/MapboxSearch/PublicAPI/Search Results/SearchResult.swift b/Sources/MapboxSearch/PublicAPI/Search Results/SearchResult.swift index 37c6381ac..55cd92a51 100644 --- a/Sources/MapboxSearch/PublicAPI/Search Results/SearchResult.swift +++ b/Sources/MapboxSearch/PublicAPI/Search Results/SearchResult.swift @@ -9,6 +9,9 @@ public protocol SearchResult { /// Result name. var name: String { get } + /// A unique identifier for the geographic feature + var mapboxId: String? { get } + /// Icon name according to [Mapbox Maki icon set](https://github.com/mapbox/maki/) var iconName: String? { get } diff --git a/Sources/MapboxSearch/PublicAPI/Search Results/SearchResultSuggestionImpl.swift b/Sources/MapboxSearch/PublicAPI/Search Results/SearchResultSuggestionImpl.swift index c4322650c..4808b2627 100644 --- a/Sources/MapboxSearch/PublicAPI/Search Results/SearchResultSuggestionImpl.swift +++ b/Sources/MapboxSearch/PublicAPI/Search Results/SearchResultSuggestionImpl.swift @@ -2,14 +2,14 @@ import CoreLocation import Foundation class SearchResultSuggestionImpl: SearchResultSuggestion, CoreResponseProvider { - var mapboxId: String? - var originalResponse: CoreSearchResultResponse let dataLayerIdentifier = SearchEngine.providerIdentifier var id: String + var mapboxId: String? + var name: String var address: Address? diff --git a/Sources/MapboxSearch/PublicAPI/Search Results/SearchSuggestion.swift b/Sources/MapboxSearch/PublicAPI/Search Results/SearchSuggestion.swift index 5a39ee621..907592213 100644 --- a/Sources/MapboxSearch/PublicAPI/Search Results/SearchSuggestion.swift +++ b/Sources/MapboxSearch/PublicAPI/Search Results/SearchSuggestion.swift @@ -11,6 +11,7 @@ public protocol SearchSuggestion { /// - Attention: Mapbox backend may change the identifier of the object in the future. var id: String { get } + /// A unique identifier for the geographic feature var mapboxId: String? { get } /// Suggestion name. diff --git a/Sources/MapboxSearch/PublicAPI/Search Results/ServerSearchResult.swift b/Sources/MapboxSearch/PublicAPI/Search Results/ServerSearchResult.swift index 0b3854288..cb90ac222 100644 --- a/Sources/MapboxSearch/PublicAPI/Search Results/ServerSearchResult.swift +++ b/Sources/MapboxSearch/PublicAPI/Search Results/ServerSearchResult.swift @@ -2,8 +2,6 @@ import CoreLocation import Foundation class ServerSearchResult: SearchResult, SearchResultSuggestion, CoreResponseProvider { - var mapboxId: String? - var distance: CLLocationDistance? var originalResponse: CoreSearchResultResponse @@ -37,6 +35,8 @@ class ServerSearchResult: SearchResult, SearchResultSuggestion, CoreResponseProv var id: String + var mapboxId: String? + var name: String var matchingName: String? diff --git a/Sources/MapboxSearch/PublicAPI/Use Cases/Address Autofill/AddressAutofill.swift b/Sources/MapboxSearch/PublicAPI/Use Cases/Address Autofill/AddressAutofill.swift index c3473fd1a..1a950f7b2 100644 --- a/Sources/MapboxSearch/PublicAPI/Use Cases/Address Autofill/AddressAutofill.swift +++ b/Sources/MapboxSearch/PublicAPI/Use Cases/Address Autofill/AddressAutofill.swift @@ -132,6 +132,7 @@ extension AddressAutofill { } let result = AddressAutofill.Result( name: suggestion.name, + mapboxId: suggestion.mapboxId, formattedAddress: suggestion.formattedAddress, coordinate: coordinate, addressComponents: suggestion.addressComponents @@ -248,6 +249,7 @@ extension AddressAutofill { return Suggestion( name: name, + mapboxId: result.mapboxId, formattedAddress: fullAddress, coordinate: result.center?.value, addressComponents: resultAddress, @@ -287,6 +289,7 @@ extension AddressAutofill { let autofillResult = AddressAutofill.Result( name: result.name, + mapboxId: result.mapboxId, formattedAddress: formattedAddress, coordinate: result.coordinate, addressComponents: addressComponents diff --git a/Sources/MapboxSearch/PublicAPI/Use Cases/Address Autofill/Models/AddressAutofill+Result.swift b/Sources/MapboxSearch/PublicAPI/Use Cases/Address Autofill/Models/AddressAutofill+Result.swift index 8d82bc0c1..df4a283d2 100644 --- a/Sources/MapboxSearch/PublicAPI/Use Cases/Address Autofill/Models/AddressAutofill+Result.swift +++ b/Sources/MapboxSearch/PublicAPI/Use Cases/Address Autofill/Models/AddressAutofill+Result.swift @@ -5,6 +5,9 @@ extension AddressAutofill { /// Result name. public let name: String + /// A unique identifier for the geographic feature + public let mapboxId: String? + /// Textual representation of the address. public let formattedAddress: String @@ -16,11 +19,13 @@ extension AddressAutofill { init( name: String, + mapboxId: String?, formattedAddress: String, coordinate: CLLocationCoordinate2D, addressComponents: NonEmptyArray ) { self.name = name + self.mapboxId = mapboxId self.formattedAddress = formattedAddress self.coordinate = coordinate self.addressComponents = addressComponents diff --git a/Sources/MapboxSearch/PublicAPI/Use Cases/Address Autofill/Models/Suggestion/AddressAutofill+Suggestion.swift b/Sources/MapboxSearch/PublicAPI/Use Cases/Address Autofill/Models/Suggestion/AddressAutofill+Suggestion.swift index 05d554348..278e5259f 100644 --- a/Sources/MapboxSearch/PublicAPI/Use Cases/Address Autofill/Models/Suggestion/AddressAutofill+Suggestion.swift +++ b/Sources/MapboxSearch/PublicAPI/Use Cases/Address Autofill/Models/Suggestion/AddressAutofill+Suggestion.swift @@ -6,6 +6,9 @@ extension AddressAutofill { /// Suggestion name. public let name: String + /// A unique identifier for the geographic feature + public let mapboxId: String? + /// Textual representation of the address. public let formattedAddress: String @@ -21,12 +24,14 @@ extension AddressAutofill { init( name: String, + mapboxId: String?, formattedAddress: String, coordinate: CLLocationCoordinate2D?, addressComponents: NonEmptyArray, underlying: Underlying ) { self.name = name + self.mapboxId = mapboxId self.formattedAddress = formattedAddress self.coordinate = coordinate self.addressComponents = addressComponents diff --git a/Sources/MapboxSearch/PublicAPI/Use Cases/Address Autofill/Models/Suggestion/AddressAutofill.Suggestion+SearchResult.swift b/Sources/MapboxSearch/PublicAPI/Use Cases/Address Autofill/Models/Suggestion/AddressAutofill.Suggestion+SearchResult.swift index 0d9bd80bb..b725e4a55 100644 --- a/Sources/MapboxSearch/PublicAPI/Use Cases/Address Autofill/Models/Suggestion/AddressAutofill.Suggestion+SearchResult.swift +++ b/Sources/MapboxSearch/PublicAPI/Use Cases/Address Autofill/Models/Suggestion/AddressAutofill.Suggestion+SearchResult.swift @@ -23,6 +23,7 @@ extension AddressAutofill.Suggestion { return try .init( name: searchResult.name, + mapboxId: searchResult.mapboxId, formattedAddress: formattedAddress, coordinate: searchResult.coordinate, addressComponents: address.toAutofillComponents(), diff --git a/Sources/MapboxSearch/PublicAPI/Use Cases/Discover/Models/Discover+Result.swift b/Sources/MapboxSearch/PublicAPI/Use Cases/Discover/Models/Discover+Result.swift index ef2c09638..d2fd9283e 100644 --- a/Sources/MapboxSearch/PublicAPI/Use Cases/Discover/Models/Discover+Result.swift +++ b/Sources/MapboxSearch/PublicAPI/Use Cases/Discover/Models/Discover+Result.swift @@ -6,6 +6,9 @@ extension Discover { /// Result's name public let name: String + /// A unique identifier for the geographic feature + public let mapboxId: String? + /// Result's address public let address: AddressComponents @@ -34,6 +37,7 @@ extension Discover.Result { return .init( name: searchResult.name, + mapboxId: searchResult.mapboxId, address: .init(searchResult: searchResult), coordinate: searchResult.coordinate, routablePoints: routablePointsArray, diff --git a/Sources/MapboxSearch/PublicAPI/Use Cases/Place Autocomplete/Models/PlaceAutocomplete+Result.swift b/Sources/MapboxSearch/PublicAPI/Use Cases/Place Autocomplete/Models/PlaceAutocomplete+Result.swift index b97ba0b89..afcafb3fa 100644 --- a/Sources/MapboxSearch/PublicAPI/Use Cases/Place Autocomplete/Models/PlaceAutocomplete+Result.swift +++ b/Sources/MapboxSearch/PublicAPI/Use Cases/Place Autocomplete/Models/PlaceAutocomplete+Result.swift @@ -5,6 +5,9 @@ extension PlaceAutocomplete { /// Result name. public let name: String + /// A unique identifier for the geographic feature + public let mapboxId: String? + /// Contains formatted address. public let description: String? diff --git a/Sources/MapboxSearch/PublicAPI/Use Cases/Place Autocomplete/Models/PlaceAutocomplete+Suggestion.swift b/Sources/MapboxSearch/PublicAPI/Use Cases/Place Autocomplete/Models/PlaceAutocomplete+Suggestion.swift index 193018f92..0bf179b3d 100644 --- a/Sources/MapboxSearch/PublicAPI/Use Cases/Place Autocomplete/Models/PlaceAutocomplete+Suggestion.swift +++ b/Sources/MapboxSearch/PublicAPI/Use Cases/Place Autocomplete/Models/PlaceAutocomplete+Suggestion.swift @@ -6,6 +6,9 @@ extension PlaceAutocomplete { /// Place's name. public let name: String + /// A unique identifier for the geographic feature + public let mapboxId: String? + /// Contains formatted address. public let description: String? @@ -36,6 +39,7 @@ extension PlaceAutocomplete { init( name: String, + mapboxId: String?, description: String?, coordinate: CLLocationCoordinate2D?, iconName: String?, @@ -47,6 +51,7 @@ extension PlaceAutocomplete { underlying: Underlying ) { self.name = name + self.mapboxId = mapboxId self.description = description self.coordinate = coordinate self.iconName = iconName @@ -69,6 +74,7 @@ extension PlaceAutocomplete.Suggestion { func result(for underlyingResult: SearchResult) -> PlaceAutocomplete.Result { .init( name: name, + mapboxId: underlyingResult.mapboxId, description: description, type: placeType, coordinate: coordinate, @@ -108,6 +114,7 @@ extension PlaceAutocomplete.Suggestion { return .init( name: searchResult.name, + mapboxId: searchResult.mapboxId, description: searchResult.descriptionText, coordinate: searchResult.coordinate, iconName: searchResult.iconName, @@ -136,6 +143,7 @@ extension PlaceAutocomplete.Suggestion { return .init( name: searchSuggestion.names.first ?? "", + mapboxId: searchSuggestion.mapboxId, description: searchSuggestion.addressDescription, coordinate: coordinate, iconName: searchSuggestion.icon, diff --git a/Sources/MapboxSearch/PublicAPI/Use Cases/Place Autocomplete/PlaceAutocomplete.swift b/Sources/MapboxSearch/PublicAPI/Use Cases/Place Autocomplete/PlaceAutocomplete.swift index 58b1b6141..5cae61dd2 100644 --- a/Sources/MapboxSearch/PublicAPI/Use Cases/Place Autocomplete/PlaceAutocomplete.swift +++ b/Sources/MapboxSearch/PublicAPI/Use Cases/Place Autocomplete/PlaceAutocomplete.swift @@ -317,6 +317,7 @@ extension PlaceAutocomplete { return Suggestion( name: name, + mapboxId: result.mapboxId, description: result.addressDescription, coordinate: result.center?.value, iconName: result.icon, diff --git a/Tests/MapboxSearchIntegrationTests/AddressAutofillIntegrationTests.swift b/Tests/MapboxSearchIntegrationTests/AddressAutofillIntegrationTests.swift index 89dead51c..7bb35d2d0 100644 --- a/Tests/MapboxSearchIntegrationTests/AddressAutofillIntegrationTests.swift +++ b/Tests/MapboxSearchIntegrationTests/AddressAutofillIntegrationTests.swift @@ -41,7 +41,7 @@ final class AddressAutofillIntegrationTests: MockServerIntegrationTestCase { switch result { case .success(let searchResults): XCTAssertFalse(searchResults.isEmpty) + let firstResult = searchResults.first + XCTAssertNotNil(firstResult?.mapboxId) expectation.fulfill() case .failure: XCTFail("Error not expected") diff --git a/Tests/MapboxSearchIntegrationTests/PlaceAutocompleteIntegrationTests.swift b/Tests/MapboxSearchIntegrationTests/PlaceAutocompleteIntegrationTests.swift index 895402f3c..e13e4fb18 100644 --- a/Tests/MapboxSearchIntegrationTests/PlaceAutocompleteIntegrationTests.swift +++ b/Tests/MapboxSearchIntegrationTests/PlaceAutocompleteIntegrationTests.swift @@ -62,6 +62,7 @@ final class PlaceAutocompleteIntegrationTests: MockServerIntegrationTestCase Self { .init( name: "name", + mapboxId: nil, description: "description", coordinate: CLLocationCoordinate2D(latitude: 10, longitude: 10), iconName: "iconName", diff --git a/Tests/MapboxSearchTests/Common/Stubs&Models/SearchResultStub.swift b/Tests/MapboxSearchTests/Common/Stubs&Models/SearchResultStub.swift index 47e7ef7bf..7f0500d07 100644 --- a/Tests/MapboxSearchTests/Common/Stubs&Models/SearchResultStub.swift +++ b/Tests/MapboxSearchTests/Common/Stubs&Models/SearchResultStub.swift @@ -4,6 +4,7 @@ import CoreLocation class SearchResultStub: SearchResult { init( id: String, + mapboxId: String?, accuracy: SearchResultAccuracy? = nil, categories: [String]? = nil, name: String, @@ -19,6 +20,7 @@ class SearchResultStub: SearchResult { dataLayerIdentifier: String = "unit-test-stub" ) { self.id = id + self.mapboxId = mapboxId self.accuracy = accuracy self.categories = categories self.name = name @@ -37,6 +39,7 @@ class SearchResultStub: SearchResult { var dataLayerIdentifier: String var id: String + var mapboxId: String? var accuracy: SearchResultAccuracy? var categories: [String]? var name: String @@ -68,6 +71,7 @@ extension SearchResultStub { static var `default`: SearchResultStub { SearchResultStub( id: "AddressAutofillAddressComponentTests", + mapboxId: nil, name: "AddressAutofillAddressComponentTests", matchingName: nil, serverIndex: nil, diff --git a/Tests/MapboxSearchTests/Common/Stubs&Models/TestDataProviderRecord.swift b/Tests/MapboxSearchTests/Common/Stubs&Models/TestDataProviderRecord.swift index 4e6d67a18..7b5bde27e 100644 --- a/Tests/MapboxSearchTests/Common/Stubs&Models/TestDataProviderRecord.swift +++ b/Tests/MapboxSearchTests/Common/Stubs&Models/TestDataProviderRecord.swift @@ -4,7 +4,7 @@ import CoreLocation struct TestDataProviderRecord: IndexableRecord, SearchResult { var type: SearchResultType var id: String = UUID().uuidString - var mapboxId: String = UUID().uuidString // TODO: Revisit + var mapboxId: String? var accuracy: SearchResultAccuracy? var name: String var matchingName: String? diff --git a/Tests/MapboxSearchTests/CoreAliases.swift b/Tests/MapboxSearchTests/CoreAliases.swift deleted file mode 120000 index 94c9daba1..000000000 --- a/Tests/MapboxSearchTests/CoreAliases.swift +++ /dev/null @@ -1 +0,0 @@ -../../Sources/MapboxSearch/InternalAPI/CoreAliases.swift \ No newline at end of file diff --git a/Tests/MapboxSearchTests/Legacy/CodablePersistentServiceTests.swift b/Tests/MapboxSearchTests/Legacy/CodablePersistentServiceTests.swift index 6b9788cc6..ae47955ae 100644 --- a/Tests/MapboxSearchTests/Legacy/CodablePersistentServiceTests.swift +++ b/Tests/MapboxSearchTests/Legacy/CodablePersistentServiceTests.swift @@ -59,6 +59,7 @@ class CodablePersistentServiceTests: XCTestCase { let coordinate = CLLocationCoordinate2D(latitude: 10.0, longitude: 10.0) let record = HistoryRecord( id: UUID().uuidString, + mapboxId: nil, name: "DaName", matchingName: nil, serverIndex: nil, diff --git a/Tests/MapboxSearchTests/Legacy/FavoriteRecordTests.swift b/Tests/MapboxSearchTests/Legacy/FavoriteRecordTests.swift index 83363642b..97b731ff0 100644 --- a/Tests/MapboxSearchTests/Legacy/FavoriteRecordTests.swift +++ b/Tests/MapboxSearchTests/Legacy/FavoriteRecordTests.swift @@ -7,6 +7,7 @@ class FavoriteRecordTests: XCTestCase { let record = FavoriteRecord(id: "unique-id", name: "Custom Name", searchResult: resultStub) XCTAssertEqual(record.id, "unique-id") + XCTAssertNotNil(record.mapboxId) XCTAssertEqual(record.name, "Custom Name") XCTAssertEqual(record.address, resultStub.address) XCTAssertEqual(record.categories, resultStub.categories) diff --git a/Tests/MapboxSearchTests/Legacy/HistoryRecordTests.swift b/Tests/MapboxSearchTests/Legacy/HistoryRecordTests.swift index 9a86ad439..b614793a0 100644 --- a/Tests/MapboxSearchTests/Legacy/HistoryRecordTests.swift +++ b/Tests/MapboxSearchTests/Legacy/HistoryRecordTests.swift @@ -5,6 +5,7 @@ class HistoryRecordTests: XCTestCase { func testHistoryRecordCategories() throws { let record = HistoryRecord( id: UUID().uuidString, + mapboxId: nil, name: "DaName", matchingName: nil, serverIndex: nil, @@ -22,6 +23,7 @@ class HistoryRecordTests: XCTestCase { func testHistoryRecordCoordinates() { var record = HistoryRecord( id: UUID().uuidString, + mapboxId: nil, name: "DaName", matchingName: nil, serverIndex: nil, @@ -43,6 +45,7 @@ class HistoryRecordTests: XCTestCase { func testHistoryRecordDescriptionText() { let record = HistoryRecord( id: UUID().uuidString, + mapboxId: nil, name: "DaName", matchingName: nil, serverIndex: nil, diff --git a/Tests/MockWebServer/MockResponse.swift b/Tests/MockWebServer/MockResponse.swift index cea7235d3..d37d5170e 100644 --- a/Tests/MockWebServer/MockResponse.swift +++ b/Tests/MockWebServer/MockResponse.swift @@ -1,5 +1,4 @@ import Foundation -@_implementationOnly import MapboxCoreSearch @testable import MapboxSearch import Swifter import XCTest