From c7c68ffa26a6d4865bb3fd47b8fde9247418f510 Mon Sep 17 00:00:00 2001 From: algolia-bot Date: Mon, 23 Sep 2024 21:12:00 +0000 Subject: [PATCH] fix(kotlin): deserialization (#3822) (generated) [skip ci] Co-authored-by: Thomas Raffray --- .../Models/Recommend/RecommendationsHit.cs | 50 +++++------ .../recommend/model_recommendations_hit.go | 45 ++++++---- .../model/recommend/RecommendationsHit.java | 16 ++-- .../model/abtesting/AddABTestsVariant.kt | 15 ++++ .../model/analytics/GetTopHitsResponse.kt | 22 +++++ .../model/analytics/GetTopSearchesResponse.kt | 22 +++++ .../client/model/ingestion/AuthInput.kt | 43 ++++++++++ .../model/ingestion/AuthInputPartial.kt | 43 ++++++++++ .../model/ingestion/DestinationInput.kt | 8 ++ .../model/ingestion/PlatformWithNone.kt | 15 ++++ .../client/model/ingestion/SourceInput.kt | 57 +++++++++++++ .../model/ingestion/SourceUpdateInput.kt | 50 +++++++++++ .../model/ingestion/TaskCreateTrigger.kt | 29 +++++++ .../client/model/ingestion/TaskInput.kt | 22 +++++ .../algolia/client/model/ingestion/Trigger.kt | 29 +++++++ .../client/model/insights/EventsItems.kt | 85 +++++++++++++++++++ .../model/querysuggestions/Languages.kt | 2 +- .../client/model/recommend/AroundPrecision.kt | 2 +- .../client/model/recommend/AroundRadius.kt | 7 ++ .../client/model/recommend/FacetFilters.kt | 2 +- .../client/model/recommend/HighlightResult.kt | 9 +- .../client/model/recommend/IgnorePlurals.kt | 7 ++ .../client/model/recommend/NumericFilters.kt | 2 +- .../client/model/recommend/OptionalFilters.kt | 2 +- .../model/recommend/ReRankingApplyFilter.kt | 2 +- .../model/recommend/RecommendationsHit.kt | 10 ++- .../model/recommend/RecommendationsRequest.kt | 43 ++++++++++ .../client/model/recommend/SnippetResult.kt | 9 +- .../client/model/recommend/TagFilters.kt | 2 +- .../client/model/recommend/TypoTolerance.kt | 7 ++ .../client/model/search/AroundPrecision.kt | 2 +- .../client/model/search/AroundRadius.kt | 7 ++ .../client/model/search/AttributeToUpdate.kt | 7 ++ .../model/search/AutomaticFacetFilters.kt | 4 +- .../client/model/search/BrowseParams.kt | 15 ++++ .../client/model/search/ConsequenceQuery.kt | 7 ++ .../client/model/search/FacetFilters.kt | 2 +- .../client/model/search/HighlightResult.kt | 9 +- .../client/model/search/IgnorePlurals.kt | 7 ++ .../client/model/search/NumericFilters.kt | 2 +- .../client/model/search/OptionalFilters.kt | 2 +- .../algolia/client/model/search/Promote.kt | 15 ++++ .../model/search/ReRankingApplyFilter.kt | 2 +- .../client/model/search/SearchParams.kt | 15 ++++ .../client/model/search/SearchQuery.kt | 15 ++++ .../client/model/search/SearchResult.kt | 15 ++++ .../client/model/search/SnippetResult.kt | 9 +- .../algolia/client/model/search/TagFilters.kt | 2 +- .../client/model/search/TypoTolerance.kt | 7 ++ .../recommend/RecommendationsHit.scala | 5 +- .../Recommend/Models/RecommendationsHit.swift | 16 ++-- specs/bundled/algoliasearch.yml | 5 ++ specs/bundled/recommend.doc.yml | 5 ++ specs/bundled/recommend.yml | 5 ++ 54 files changed, 756 insertions(+), 81 deletions(-) diff --git a/clients/algoliasearch-client-csharp/algoliasearch/Models/Recommend/RecommendationsHit.cs b/clients/algoliasearch-client-csharp/algoliasearch/Models/Recommend/RecommendationsHit.cs index af85facd99..9e8054b43b 100644 --- a/clients/algoliasearch-client-csharp/algoliasearch/Models/Recommend/RecommendationsHit.cs +++ b/clients/algoliasearch-client-csharp/algoliasearch/Models/Recommend/RecommendationsHit.cs @@ -22,20 +22,20 @@ public partial class RecommendationsHit : AbstractSchema { /// /// Initializes a new instance of the RecommendationsHit class - /// with a RecommendHit + /// with a TrendingFacetHit /// - /// An instance of RecommendHit. - public RecommendationsHit(RecommendHit actualInstance) + /// An instance of TrendingFacetHit. + public RecommendationsHit(TrendingFacetHit actualInstance) { ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); } /// /// Initializes a new instance of the RecommendationsHit class - /// with a TrendingFacetHit + /// with a RecommendHit /// - /// An instance of TrendingFacetHit. - public RecommendationsHit(TrendingFacetHit actualInstance) + /// An instance of RecommendHit. + public RecommendationsHit(RecommendHit actualInstance) { ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); } @@ -47,42 +47,42 @@ public RecommendationsHit(TrendingFacetHit actualInstance) public sealed override object ActualInstance { get; set; } /// - /// Get the actual instance of `RecommendHit`. If the actual instance is not `RecommendHit`, + /// Get the actual instance of `TrendingFacetHit`. If the actual instance is not `TrendingFacetHit`, /// the InvalidClassException will be thrown /// - /// An instance of RecommendHit - public RecommendHit AsRecommendHit() + /// An instance of TrendingFacetHit + public TrendingFacetHit AsTrendingFacetHit() { - return (RecommendHit)ActualInstance; + return (TrendingFacetHit)ActualInstance; } /// - /// Get the actual instance of `TrendingFacetHit`. If the actual instance is not `TrendingFacetHit`, + /// Get the actual instance of `RecommendHit`. If the actual instance is not `RecommendHit`, /// the InvalidClassException will be thrown /// - /// An instance of TrendingFacetHit - public TrendingFacetHit AsTrendingFacetHit() + /// An instance of RecommendHit + public RecommendHit AsRecommendHit() { - return (TrendingFacetHit)ActualInstance; + return (RecommendHit)ActualInstance; } /// - /// Check if the actual instance is of `RecommendHit` type. + /// Check if the actual instance is of `TrendingFacetHit` type. /// /// Whether or not the instance is the type - public bool IsRecommendHit() + public bool IsTrendingFacetHit() { - return ActualInstance.GetType() == typeof(RecommendHit); + return ActualInstance.GetType() == typeof(TrendingFacetHit); } /// - /// Check if the actual instance is of `TrendingFacetHit` type. + /// Check if the actual instance is of `RecommendHit` type. /// /// Whether or not the instance is the type - public bool IsTrendingFacetHit() + public bool IsRecommendHit() { - return ActualInstance.GetType() == typeof(TrendingFacetHit); + return ActualInstance.GetType() == typeof(RecommendHit); } /// @@ -169,28 +169,28 @@ public override RecommendationsHit Read(ref Utf8JsonReader reader, Type typeToCo { var jsonDocument = JsonDocument.ParseValue(ref reader); var root = jsonDocument.RootElement; - if (root.ValueKind == JsonValueKind.Object) + if (root.ValueKind == JsonValueKind.Object && root.TryGetProperty("facetName", out _) && root.TryGetProperty("facetValue", out _)) { try { - return new RecommendationsHit(jsonDocument.Deserialize(JsonConfig.Options)); + return new RecommendationsHit(jsonDocument.Deserialize(JsonConfig.Options)); } catch (Exception exception) { // deserialization failed, try the next one - System.Diagnostics.Debug.WriteLine($"Failed to deserialize into RecommendHit: {exception}"); + System.Diagnostics.Debug.WriteLine($"Failed to deserialize into TrendingFacetHit: {exception}"); } } if (root.ValueKind == JsonValueKind.Object) { try { - return new RecommendationsHit(jsonDocument.Deserialize(JsonConfig.Options)); + return new RecommendationsHit(jsonDocument.Deserialize(JsonConfig.Options)); } catch (Exception exception) { // deserialization failed, try the next one - System.Diagnostics.Debug.WriteLine($"Failed to deserialize into TrendingFacetHit: {exception}"); + System.Diagnostics.Debug.WriteLine($"Failed to deserialize into RecommendHit: {exception}"); } } throw new InvalidDataException($"The JSON string cannot be deserialized into any schema defined."); diff --git a/clients/algoliasearch-client-go/algolia/recommend/model_recommendations_hit.go b/clients/algoliasearch-client-go/algolia/recommend/model_recommendations_hit.go index 380d0c9787..ae90940590 100644 --- a/clients/algoliasearch-client-go/algolia/recommend/model_recommendations_hit.go +++ b/clients/algoliasearch-client-go/algolia/recommend/model_recommendations_hit.go @@ -4,6 +4,8 @@ package recommend import ( "encoding/json" "fmt" + + "github.com/algolia/algoliasearch-client-go/v4/algolia/utils" ) // RecommendationsHit - struct for RecommendationsHit. @@ -12,36 +14,43 @@ type RecommendationsHit struct { TrendingFacetHit *TrendingFacetHit } -// RecommendHitAsRecommendationsHit is a convenience function that returns RecommendHit wrapped in RecommendationsHit. -func RecommendHitAsRecommendationsHit(v RecommendHit) *RecommendationsHit { +// TrendingFacetHitAsRecommendationsHit is a convenience function that returns TrendingFacetHit wrapped in RecommendationsHit. +func TrendingFacetHitAsRecommendationsHit(v *TrendingFacetHit) *RecommendationsHit { return &RecommendationsHit{ - RecommendHit: &v, + TrendingFacetHit: v, } } -// TrendingFacetHitAsRecommendationsHit is a convenience function that returns TrendingFacetHit wrapped in RecommendationsHit. -func TrendingFacetHitAsRecommendationsHit(v *TrendingFacetHit) *RecommendationsHit { +// RecommendHitAsRecommendationsHit is a convenience function that returns RecommendHit wrapped in RecommendationsHit. +func RecommendHitAsRecommendationsHit(v RecommendHit) *RecommendationsHit { return &RecommendationsHit{ - TrendingFacetHit: v, + RecommendHit: &v, } } // Unmarshal JSON data into one of the pointers in the struct. func (dst *RecommendationsHit) UnmarshalJSON(data []byte) error { var err error - // try to unmarshal data into RecommendHit - err = newStrictDecoder(data).Decode(&dst.RecommendHit) - if err == nil && validateStruct(dst.RecommendHit) == nil { - return nil // found the correct type - } else { - dst.RecommendHit = nil + // use discriminator value to speed up the lookup if possible, if not we will try every possibility + var jsonDict map[string]any + _ = newStrictDecoder(data).Decode(&jsonDict) + if utils.HasKey(jsonDict, "facetName") && utils.HasKey(jsonDict, "facetValue") { + // try to unmarshal data into TrendingFacetHit + err = newStrictDecoder(data).Decode(&dst.TrendingFacetHit) + if err == nil && validateStruct(dst.TrendingFacetHit) == nil { + return nil // found the correct type + } else { + dst.TrendingFacetHit = nil + } } - // try to unmarshal data into TrendingFacetHit - err = newStrictDecoder(data).Decode(&dst.TrendingFacetHit) - if err == nil && validateStruct(dst.TrendingFacetHit) == nil { - return nil // found the correct type - } else { - dst.TrendingFacetHit = nil + if utils.HasKey(jsonDict, "objectID") { + // try to unmarshal data into RecommendHit + err = newStrictDecoder(data).Decode(&dst.RecommendHit) + if err == nil && validateStruct(dst.RecommendHit) == nil { + return nil // found the correct type + } else { + dst.RecommendHit = nil + } } return fmt.Errorf("Data failed to match schemas in oneOf(RecommendationsHit)") diff --git a/clients/algoliasearch-client-java/algoliasearch/src/main/java/com/algolia/model/recommend/RecommendationsHit.java b/clients/algoliasearch-client-java/algoliasearch/src/main/java/com/algolia/model/recommend/RecommendationsHit.java index bd94c45389..784855b800 100644 --- a/clients/algoliasearch-client-java/algoliasearch/src/main/java/com/algolia/model/recommend/RecommendationsHit.java +++ b/clients/algoliasearch-client-java/algoliasearch/src/main/java/com/algolia/model/recommend/RecommendationsHit.java @@ -49,23 +49,23 @@ class Deserializer extends JsonDeserializer { @Override public RecommendationsHit deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException { JsonNode tree = jp.readValueAsTree(); - // deserialize RecommendHit - if (tree.isObject()) { + // deserialize TrendingFacetHit + if (tree.isObject() && tree.has("facetName") && tree.has("facetValue")) { try (JsonParser parser = tree.traverse(jp.getCodec())) { - RecommendHit value = parser.readValueAs(RecommendHit.class); - return new RecommendationsHit.RecommendHitWrapper(value); + return parser.readValueAs(TrendingFacetHit.class); } catch (Exception e) { // deserialization failed, continue - LOGGER.finest("Failed to deserialize oneOf RecommendHit (error: " + e.getMessage() + ") (type: RecommendHit)"); + LOGGER.finest("Failed to deserialize oneOf TrendingFacetHit (error: " + e.getMessage() + ") (type: TrendingFacetHit)"); } } - // deserialize TrendingFacetHit + // deserialize RecommendHit if (tree.isObject()) { try (JsonParser parser = tree.traverse(jp.getCodec())) { - return parser.readValueAs(TrendingFacetHit.class); + RecommendHit value = parser.readValueAs(RecommendHit.class); + return new RecommendationsHit.RecommendHitWrapper(value); } catch (Exception e) { // deserialization failed, continue - LOGGER.finest("Failed to deserialize oneOf TrendingFacetHit (error: " + e.getMessage() + ") (type: TrendingFacetHit)"); + LOGGER.finest("Failed to deserialize oneOf RecommendHit (error: " + e.getMessage() + ") (type: RecommendHit)"); } } throw new AlgoliaRuntimeException(String.format("Failed to deserialize json element: %s", tree)); diff --git a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/abtesting/AddABTestsVariant.kt b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/abtesting/AddABTestsVariant.kt index 8fe4088885..70f9372e58 100644 --- a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/abtesting/AddABTestsVariant.kt +++ b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/abtesting/AddABTestsVariant.kt @@ -8,6 +8,7 @@ import kotlinx.serialization.builtins.* import kotlinx.serialization.descriptors.* import kotlinx.serialization.encoding.* import kotlinx.serialization.json.* +import kotlin.jvm.JvmInline /** * AddABTestsVariant @@ -18,8 +19,22 @@ import kotlinx.serialization.json.* */ @Serializable(AddABTestsVariantSerializer::class) public sealed interface AddABTestsVariant { + @Serializable + @JvmInline + public value class AbTestsVariantSearchParamsValue(public val value: AbTestsVariantSearchParams) : AddABTestsVariant + + @Serializable + @JvmInline + public value class AbTestsVariantValue(public val value: AbTestsVariant) : AddABTestsVariant public companion object { + + public fun of(value: AbTestsVariantSearchParams): AddABTestsVariant { + return AbTestsVariantSearchParamsValue(value) + } + public fun of(value: AbTestsVariant): AddABTestsVariant { + return AbTestsVariantValue(value) + } } } diff --git a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/analytics/GetTopHitsResponse.kt b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/analytics/GetTopHitsResponse.kt index 9ee0fbc21a..d82c71a968 100644 --- a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/analytics/GetTopHitsResponse.kt +++ b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/analytics/GetTopHitsResponse.kt @@ -8,6 +8,7 @@ import kotlinx.serialization.builtins.* import kotlinx.serialization.descriptors.* import kotlinx.serialization.encoding.* import kotlinx.serialization.json.* +import kotlin.jvm.JvmInline /** * GetTopHitsResponse @@ -19,8 +20,29 @@ import kotlinx.serialization.json.* */ @Serializable(GetTopHitsResponseSerializer::class) public sealed interface GetTopHitsResponse { + @Serializable + @JvmInline + public value class TopHitsResponseValue(public val value: TopHitsResponse) : GetTopHitsResponse + + @Serializable + @JvmInline + public value class TopHitsResponseWithAnalyticsValue(public val value: TopHitsResponseWithAnalytics) : GetTopHitsResponse + + @Serializable + @JvmInline + public value class TopHitsResponseWithRevenueAnalyticsValue(public val value: TopHitsResponseWithRevenueAnalytics) : GetTopHitsResponse public companion object { + + public fun of(value: TopHitsResponse): GetTopHitsResponse { + return TopHitsResponseValue(value) + } + public fun of(value: TopHitsResponseWithAnalytics): GetTopHitsResponse { + return TopHitsResponseWithAnalyticsValue(value) + } + public fun of(value: TopHitsResponseWithRevenueAnalytics): GetTopHitsResponse { + return TopHitsResponseWithRevenueAnalyticsValue(value) + } } } diff --git a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/analytics/GetTopSearchesResponse.kt b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/analytics/GetTopSearchesResponse.kt index c24c3b135f..45dce390ac 100644 --- a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/analytics/GetTopSearchesResponse.kt +++ b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/analytics/GetTopSearchesResponse.kt @@ -8,6 +8,7 @@ import kotlinx.serialization.builtins.* import kotlinx.serialization.descriptors.* import kotlinx.serialization.encoding.* import kotlinx.serialization.json.* +import kotlin.jvm.JvmInline /** * GetTopSearchesResponse @@ -19,8 +20,29 @@ import kotlinx.serialization.json.* */ @Serializable(GetTopSearchesResponseSerializer::class) public sealed interface GetTopSearchesResponse { + @Serializable + @JvmInline + public value class TopSearchesResponseValue(public val value: TopSearchesResponse) : GetTopSearchesResponse + + @Serializable + @JvmInline + public value class TopSearchesResponseWithAnalyticsValue(public val value: TopSearchesResponseWithAnalytics) : GetTopSearchesResponse + + @Serializable + @JvmInline + public value class TopSearchesResponseWithRevenueAnalyticsValue(public val value: TopSearchesResponseWithRevenueAnalytics) : GetTopSearchesResponse public companion object { + + public fun of(value: TopSearchesResponse): GetTopSearchesResponse { + return TopSearchesResponseValue(value) + } + public fun of(value: TopSearchesResponseWithAnalytics): GetTopSearchesResponse { + return TopSearchesResponseWithAnalyticsValue(value) + } + public fun of(value: TopSearchesResponseWithRevenueAnalytics): GetTopSearchesResponse { + return TopSearchesResponseWithRevenueAnalyticsValue(value) + } } } diff --git a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/ingestion/AuthInput.kt b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/ingestion/AuthInput.kt index 92e8a7da2d..ca9604aa27 100644 --- a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/ingestion/AuthInput.kt +++ b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/ingestion/AuthInput.kt @@ -8,6 +8,7 @@ import kotlinx.serialization.builtins.* import kotlinx.serialization.descriptors.* import kotlinx.serialization.encoding.* import kotlinx.serialization.json.* +import kotlin.jvm.JvmInline /** * AuthInput @@ -22,8 +23,50 @@ import kotlinx.serialization.json.* */ @Serializable(AuthInputSerializer::class) public sealed interface AuthInput { + @Serializable + @JvmInline + public value class AuthOAuthValue(public val value: AuthOAuth) : AuthInput + + @Serializable + @JvmInline + public value class AuthGoogleServiceAccountValue(public val value: AuthGoogleServiceAccount) : AuthInput + + @Serializable + @JvmInline + public value class AuthBasicValue(public val value: AuthBasic) : AuthInput + + @Serializable + @JvmInline + public value class AuthAPIKeyValue(public val value: AuthAPIKey) : AuthInput + + @Serializable + @JvmInline + public value class AuthAlgoliaValue(public val value: AuthAlgolia) : AuthInput + + @Serializable + @JvmInline + public value class AuthAlgoliaInsightsValue(public val value: AuthAlgoliaInsights) : AuthInput public companion object { + + public fun of(value: AuthOAuth): AuthInput { + return AuthOAuthValue(value) + } + public fun of(value: AuthGoogleServiceAccount): AuthInput { + return AuthGoogleServiceAccountValue(value) + } + public fun of(value: AuthBasic): AuthInput { + return AuthBasicValue(value) + } + public fun of(value: AuthAPIKey): AuthInput { + return AuthAPIKeyValue(value) + } + public fun of(value: AuthAlgolia): AuthInput { + return AuthAlgoliaValue(value) + } + public fun of(value: AuthAlgoliaInsights): AuthInput { + return AuthAlgoliaInsightsValue(value) + } } } diff --git a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/ingestion/AuthInputPartial.kt b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/ingestion/AuthInputPartial.kt index 9f1f0a82fc..26b4c849b4 100644 --- a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/ingestion/AuthInputPartial.kt +++ b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/ingestion/AuthInputPartial.kt @@ -8,6 +8,7 @@ import kotlinx.serialization.builtins.* import kotlinx.serialization.descriptors.* import kotlinx.serialization.encoding.* import kotlinx.serialization.json.* +import kotlin.jvm.JvmInline /** * AuthInputPartial @@ -22,8 +23,50 @@ import kotlinx.serialization.json.* */ @Serializable(AuthInputPartialSerializer::class) public sealed interface AuthInputPartial { + @Serializable + @JvmInline + public value class AuthGoogleServiceAccountPartialValue(public val value: AuthGoogleServiceAccountPartial) : AuthInputPartial + + @Serializable + @JvmInline + public value class AuthBasicPartialValue(public val value: AuthBasicPartial) : AuthInputPartial + + @Serializable + @JvmInline + public value class AuthAPIKeyPartialValue(public val value: AuthAPIKeyPartial) : AuthInputPartial + + @Serializable + @JvmInline + public value class AuthOAuthPartialValue(public val value: AuthOAuthPartial) : AuthInputPartial + + @Serializable + @JvmInline + public value class AuthAlgoliaPartialValue(public val value: AuthAlgoliaPartial) : AuthInputPartial + + @Serializable + @JvmInline + public value class AuthAlgoliaInsightsPartialValue(public val value: AuthAlgoliaInsightsPartial) : AuthInputPartial public companion object { + + public fun of(value: AuthGoogleServiceAccountPartial): AuthInputPartial { + return AuthGoogleServiceAccountPartialValue(value) + } + public fun of(value: AuthBasicPartial): AuthInputPartial { + return AuthBasicPartialValue(value) + } + public fun of(value: AuthAPIKeyPartial): AuthInputPartial { + return AuthAPIKeyPartialValue(value) + } + public fun of(value: AuthOAuthPartial): AuthInputPartial { + return AuthOAuthPartialValue(value) + } + public fun of(value: AuthAlgoliaPartial): AuthInputPartial { + return AuthAlgoliaPartialValue(value) + } + public fun of(value: AuthAlgoliaInsightsPartial): AuthInputPartial { + return AuthAlgoliaInsightsPartialValue(value) + } } } diff --git a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/ingestion/DestinationInput.kt b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/ingestion/DestinationInput.kt index c931620f3c..82aa59f9fb 100644 --- a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/ingestion/DestinationInput.kt +++ b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/ingestion/DestinationInput.kt @@ -8,6 +8,7 @@ import kotlinx.serialization.builtins.* import kotlinx.serialization.descriptors.* import kotlinx.serialization.encoding.* import kotlinx.serialization.json.* +import kotlin.jvm.JvmInline /** * DestinationInput @@ -17,8 +18,15 @@ import kotlinx.serialization.json.* */ @Serializable(DestinationInputSerializer::class) public sealed interface DestinationInput { + @Serializable + @JvmInline + public value class DestinationIndexNameValue(public val value: DestinationIndexName) : DestinationInput public companion object { + + public fun of(value: DestinationIndexName): DestinationInput { + return DestinationIndexNameValue(value) + } } } diff --git a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/ingestion/PlatformWithNone.kt b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/ingestion/PlatformWithNone.kt index e134e792bd..b25c523e88 100644 --- a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/ingestion/PlatformWithNone.kt +++ b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/ingestion/PlatformWithNone.kt @@ -8,6 +8,7 @@ import kotlinx.serialization.builtins.* import kotlinx.serialization.descriptors.* import kotlinx.serialization.encoding.* import kotlinx.serialization.json.* +import kotlin.jvm.JvmInline /** * PlatformWithNone @@ -18,8 +19,22 @@ import kotlinx.serialization.json.* */ @Serializable(PlatformWithNoneSerializer::class) public sealed interface PlatformWithNone { + @Serializable + @JvmInline + public value class PlatformValue(public val value: Platform) : PlatformWithNone + + @Serializable + @JvmInline + public value class PlatformNoneValue(public val value: PlatformNone) : PlatformWithNone public companion object { + + public fun of(value: Platform): PlatformWithNone { + return PlatformValue(value) + } + public fun of(value: PlatformNone): PlatformWithNone { + return PlatformNoneValue(value) + } } } diff --git a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/ingestion/SourceInput.kt b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/ingestion/SourceInput.kt index 4ba88c4371..a450211f31 100644 --- a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/ingestion/SourceInput.kt +++ b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/ingestion/SourceInput.kt @@ -8,6 +8,7 @@ import kotlinx.serialization.builtins.* import kotlinx.serialization.descriptors.* import kotlinx.serialization.encoding.* import kotlinx.serialization.json.* +import kotlin.jvm.JvmInline /** * SourceInput @@ -24,8 +25,64 @@ import kotlinx.serialization.json.* */ @Serializable(SourceInputSerializer::class) public sealed interface SourceInput { + @Serializable + @JvmInline + public value class SourceDockerValue(public val value: SourceDocker) : SourceInput + + @Serializable + @JvmInline + public value class SourceGA4BigQueryExportValue(public val value: SourceGA4BigQueryExport) : SourceInput + + @Serializable + @JvmInline + public value class SourceCommercetoolsValue(public val value: SourceCommercetools) : SourceInput + + @Serializable + @JvmInline + public value class SourceBigCommerceValue(public val value: SourceBigCommerce) : SourceInput + + @Serializable + @JvmInline + public value class SourceBigQueryValue(public val value: SourceBigQuery) : SourceInput + + @Serializable + @JvmInline + public value class SourceShopifyValue(public val value: SourceShopify) : SourceInput + + @Serializable + @JvmInline + public value class SourceJSONValue(public val value: SourceJSON) : SourceInput + + @Serializable + @JvmInline + public value class SourceCSVValue(public val value: SourceCSV) : SourceInput public companion object { + + public fun of(value: SourceDocker): SourceInput { + return SourceDockerValue(value) + } + public fun of(value: SourceGA4BigQueryExport): SourceInput { + return SourceGA4BigQueryExportValue(value) + } + public fun of(value: SourceCommercetools): SourceInput { + return SourceCommercetoolsValue(value) + } + public fun of(value: SourceBigCommerce): SourceInput { + return SourceBigCommerceValue(value) + } + public fun of(value: SourceBigQuery): SourceInput { + return SourceBigQueryValue(value) + } + public fun of(value: SourceShopify): SourceInput { + return SourceShopifyValue(value) + } + public fun of(value: SourceJSON): SourceInput { + return SourceJSONValue(value) + } + public fun of(value: SourceCSV): SourceInput { + return SourceCSVValue(value) + } } } diff --git a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/ingestion/SourceUpdateInput.kt b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/ingestion/SourceUpdateInput.kt index 07b3253b38..c3943c8da1 100644 --- a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/ingestion/SourceUpdateInput.kt +++ b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/ingestion/SourceUpdateInput.kt @@ -8,6 +8,7 @@ import kotlinx.serialization.builtins.* import kotlinx.serialization.descriptors.* import kotlinx.serialization.encoding.* import kotlinx.serialization.json.* +import kotlin.jvm.JvmInline /** * SourceUpdateInput @@ -23,8 +24,57 @@ import kotlinx.serialization.json.* */ @Serializable(SourceUpdateInputSerializer::class) public sealed interface SourceUpdateInput { + @Serializable + @JvmInline + public value class SourceGA4BigQueryExportValue(public val value: SourceGA4BigQueryExport) : SourceUpdateInput + + @Serializable + @JvmInline + public value class SourceBigQueryValue(public val value: SourceBigQuery) : SourceUpdateInput + + @Serializable + @JvmInline + public value class SourceUpdateDockerValue(public val value: SourceUpdateDocker) : SourceUpdateInput + + @Serializable + @JvmInline + public value class SourceUpdateCommercetoolsValue(public val value: SourceUpdateCommercetools) : SourceUpdateInput + + @Serializable + @JvmInline + public value class SourceJSONValue(public val value: SourceJSON) : SourceUpdateInput + + @Serializable + @JvmInline + public value class SourceCSVValue(public val value: SourceCSV) : SourceUpdateInput + + @Serializable + @JvmInline + public value class SourceUpdateShopifyValue(public val value: SourceUpdateShopify) : SourceUpdateInput public companion object { + + public fun of(value: SourceGA4BigQueryExport): SourceUpdateInput { + return SourceGA4BigQueryExportValue(value) + } + public fun of(value: SourceBigQuery): SourceUpdateInput { + return SourceBigQueryValue(value) + } + public fun of(value: SourceUpdateDocker): SourceUpdateInput { + return SourceUpdateDockerValue(value) + } + public fun of(value: SourceUpdateCommercetools): SourceUpdateInput { + return SourceUpdateCommercetoolsValue(value) + } + public fun of(value: SourceJSON): SourceUpdateInput { + return SourceJSONValue(value) + } + public fun of(value: SourceCSV): SourceUpdateInput { + return SourceCSVValue(value) + } + public fun of(value: SourceUpdateShopify): SourceUpdateInput { + return SourceUpdateShopifyValue(value) + } } } diff --git a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/ingestion/TaskCreateTrigger.kt b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/ingestion/TaskCreateTrigger.kt index e75c927a4b..e42e96c85d 100644 --- a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/ingestion/TaskCreateTrigger.kt +++ b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/ingestion/TaskCreateTrigger.kt @@ -8,6 +8,7 @@ import kotlinx.serialization.builtins.* import kotlinx.serialization.descriptors.* import kotlinx.serialization.encoding.* import kotlinx.serialization.json.* +import kotlin.jvm.JvmInline /** * TaskCreateTrigger @@ -20,8 +21,36 @@ import kotlinx.serialization.json.* */ @Serializable(TaskCreateTriggerSerializer::class) public sealed interface TaskCreateTrigger { + @Serializable + @JvmInline + public value class ScheduleTriggerInputValue(public val value: ScheduleTriggerInput) : TaskCreateTrigger + + @Serializable + @JvmInline + public value class OnDemandTriggerInputValue(public val value: OnDemandTriggerInput) : TaskCreateTrigger + + @Serializable + @JvmInline + public value class SubscriptionTriggerValue(public val value: SubscriptionTrigger) : TaskCreateTrigger + + @Serializable + @JvmInline + public value class StreamingTriggerValue(public val value: StreamingTrigger) : TaskCreateTrigger public companion object { + + public fun of(value: ScheduleTriggerInput): TaskCreateTrigger { + return ScheduleTriggerInputValue(value) + } + public fun of(value: OnDemandTriggerInput): TaskCreateTrigger { + return OnDemandTriggerInputValue(value) + } + public fun of(value: SubscriptionTrigger): TaskCreateTrigger { + return SubscriptionTriggerValue(value) + } + public fun of(value: StreamingTrigger): TaskCreateTrigger { + return StreamingTriggerValue(value) + } } } diff --git a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/ingestion/TaskInput.kt b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/ingestion/TaskInput.kt index a68c779559..9265778460 100644 --- a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/ingestion/TaskInput.kt +++ b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/ingestion/TaskInput.kt @@ -8,6 +8,7 @@ import kotlinx.serialization.builtins.* import kotlinx.serialization.descriptors.* import kotlinx.serialization.encoding.* import kotlinx.serialization.json.* +import kotlin.jvm.JvmInline /** * Configuration of the task, depending on its type. @@ -19,8 +20,29 @@ import kotlinx.serialization.json.* */ @Serializable(TaskInputSerializer::class) public sealed interface TaskInput { + @Serializable + @JvmInline + public value class StreamingInputValue(public val value: StreamingInput) : TaskInput + + @Serializable + @JvmInline + public value class DockerStreamsInputValue(public val value: DockerStreamsInput) : TaskInput + + @Serializable + @JvmInline + public value class ShopifyInputValue(public val value: ShopifyInput) : TaskInput public companion object { + + public fun of(value: StreamingInput): TaskInput { + return StreamingInputValue(value) + } + public fun of(value: DockerStreamsInput): TaskInput { + return DockerStreamsInputValue(value) + } + public fun of(value: ShopifyInput): TaskInput { + return ShopifyInputValue(value) + } } } diff --git a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/ingestion/Trigger.kt b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/ingestion/Trigger.kt index 8e9cbbe1d6..fbc4d21781 100644 --- a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/ingestion/Trigger.kt +++ b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/ingestion/Trigger.kt @@ -8,6 +8,7 @@ import kotlinx.serialization.builtins.* import kotlinx.serialization.descriptors.* import kotlinx.serialization.encoding.* import kotlinx.serialization.json.* +import kotlin.jvm.JvmInline /** * Trigger that runs the task. @@ -20,8 +21,36 @@ import kotlinx.serialization.json.* */ @Serializable(TriggerSerializer::class) public sealed interface Trigger { + @Serializable + @JvmInline + public value class OnDemandTriggerValue(public val value: OnDemandTrigger) : Trigger + + @Serializable + @JvmInline + public value class ScheduleTriggerValue(public val value: ScheduleTrigger) : Trigger + + @Serializable + @JvmInline + public value class SubscriptionTriggerValue(public val value: SubscriptionTrigger) : Trigger + + @Serializable + @JvmInline + public value class StreamingTriggerValue(public val value: StreamingTrigger) : Trigger public companion object { + + public fun of(value: OnDemandTrigger): Trigger { + return OnDemandTriggerValue(value) + } + public fun of(value: ScheduleTrigger): Trigger { + return ScheduleTriggerValue(value) + } + public fun of(value: SubscriptionTrigger): Trigger { + return SubscriptionTriggerValue(value) + } + public fun of(value: StreamingTrigger): Trigger { + return StreamingTriggerValue(value) + } } } diff --git a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/insights/EventsItems.kt b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/insights/EventsItems.kt index 25bf1c8afb..4b1c6cb710 100644 --- a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/insights/EventsItems.kt +++ b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/insights/EventsItems.kt @@ -8,6 +8,7 @@ import kotlinx.serialization.builtins.* import kotlinx.serialization.descriptors.* import kotlinx.serialization.encoding.* import kotlinx.serialization.json.* +import kotlin.jvm.JvmInline /** * EventsItems @@ -28,8 +29,92 @@ import kotlinx.serialization.json.* */ @Serializable(EventsItemsSerializer::class) public sealed interface EventsItems { + @Serializable + @JvmInline + public value class AddedToCartObjectIDsAfterSearchValue(public val value: AddedToCartObjectIDsAfterSearch) : EventsItems + + @Serializable + @JvmInline + public value class PurchasedObjectIDsAfterSearchValue(public val value: PurchasedObjectIDsAfterSearch) : EventsItems + + @Serializable + @JvmInline + public value class ClickedObjectIDsAfterSearchValue(public val value: ClickedObjectIDsAfterSearch) : EventsItems + + @Serializable + @JvmInline + public value class PurchasedObjectIDsValue(public val value: PurchasedObjectIDs) : EventsItems + + @Serializable + @JvmInline + public value class AddedToCartObjectIDsValue(public val value: AddedToCartObjectIDs) : EventsItems + + @Serializable + @JvmInline + public value class ConvertedObjectIDsAfterSearchValue(public val value: ConvertedObjectIDsAfterSearch) : EventsItems + + @Serializable + @JvmInline + public value class ClickedObjectIDsValue(public val value: ClickedObjectIDs) : EventsItems + + @Serializable + @JvmInline + public value class ConvertedObjectIDsValue(public val value: ConvertedObjectIDs) : EventsItems + + @Serializable + @JvmInline + public value class ClickedFiltersValue(public val value: ClickedFilters) : EventsItems + + @Serializable + @JvmInline + public value class ConvertedFiltersValue(public val value: ConvertedFilters) : EventsItems + + @Serializable + @JvmInline + public value class ViewedObjectIDsValue(public val value: ViewedObjectIDs) : EventsItems + + @Serializable + @JvmInline + public value class ViewedFiltersValue(public val value: ViewedFilters) : EventsItems public companion object { + + public fun of(value: AddedToCartObjectIDsAfterSearch): EventsItems { + return AddedToCartObjectIDsAfterSearchValue(value) + } + public fun of(value: PurchasedObjectIDsAfterSearch): EventsItems { + return PurchasedObjectIDsAfterSearchValue(value) + } + public fun of(value: ClickedObjectIDsAfterSearch): EventsItems { + return ClickedObjectIDsAfterSearchValue(value) + } + public fun of(value: PurchasedObjectIDs): EventsItems { + return PurchasedObjectIDsValue(value) + } + public fun of(value: AddedToCartObjectIDs): EventsItems { + return AddedToCartObjectIDsValue(value) + } + public fun of(value: ConvertedObjectIDsAfterSearch): EventsItems { + return ConvertedObjectIDsAfterSearchValue(value) + } + public fun of(value: ClickedObjectIDs): EventsItems { + return ClickedObjectIDsValue(value) + } + public fun of(value: ConvertedObjectIDs): EventsItems { + return ConvertedObjectIDsValue(value) + } + public fun of(value: ClickedFilters): EventsItems { + return ClickedFiltersValue(value) + } + public fun of(value: ConvertedFilters): EventsItems { + return ConvertedFiltersValue(value) + } + public fun of(value: ViewedObjectIDs): EventsItems { + return ViewedObjectIDsValue(value) + } + public fun of(value: ViewedFilters): EventsItems { + return ViewedFiltersValue(value) + } } } diff --git a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/querysuggestions/Languages.kt b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/querysuggestions/Languages.kt index 657f7366cd..9808afd650 100644 --- a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/querysuggestions/Languages.kt +++ b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/querysuggestions/Languages.kt @@ -41,7 +41,7 @@ public sealed interface Languages { internal class LanguagesSerializer : JsonContentPolymorphicSerializer(Languages::class) { override fun selectDeserializer(element: JsonElement): DeserializationStrategy { return when { - element.isJsonArrayOfPrimitives -> Languages.ListOfStringValue.serializer() + element is JsonArray -> Languages.ListOfStringValue.serializer() element.isBoolean -> Languages.BooleanValue.serializer() else -> throw AlgoliaClientException("Failed to deserialize json element: $element") } diff --git a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/recommend/AroundPrecision.kt b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/recommend/AroundPrecision.kt index d15d1895f7..e96d4a729f 100644 --- a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/recommend/AroundPrecision.kt +++ b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/recommend/AroundPrecision.kt @@ -42,7 +42,7 @@ internal class AroundPrecisionSerializer : JsonContentPolymorphicSerializer { return when { element.isInt -> AroundPrecision.IntValue.serializer() - element.isJsonArrayOfObjects -> AroundPrecision.ListOfRangeValue.serializer() + element is JsonArray -> AroundPrecision.ListOfRangeValue.serializer() else -> throw AlgoliaClientException("Failed to deserialize json element: $element") } } diff --git a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/recommend/AroundRadius.kt b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/recommend/AroundRadius.kt index 9d155232ae..b3201a4125 100644 --- a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/recommend/AroundRadius.kt +++ b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/recommend/AroundRadius.kt @@ -23,11 +23,18 @@ public sealed interface AroundRadius { @JvmInline public value class IntValue(public val value: Int) : AroundRadius + @Serializable + @JvmInline + public value class AroundRadiusAllValue(public val value: AroundRadiusAll) : AroundRadius + public companion object { public fun of(value: Int): AroundRadius { return IntValue(value) } + public fun of(value: AroundRadiusAll): AroundRadius { + return AroundRadiusAllValue(value) + } } } diff --git a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/recommend/FacetFilters.kt b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/recommend/FacetFilters.kt index b1f13770f9..f8061dab56 100644 --- a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/recommend/FacetFilters.kt +++ b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/recommend/FacetFilters.kt @@ -41,7 +41,7 @@ public sealed interface FacetFilters { internal class FacetFiltersSerializer : JsonContentPolymorphicSerializer(FacetFilters::class) { override fun selectDeserializer(element: JsonElement): DeserializationStrategy { return when { - element.isJsonArrayOfObjects -> FacetFilters.ListOfFacetFiltersValue.serializer() + element is JsonArray -> FacetFilters.ListOfFacetFiltersValue.serializer() element.isString -> FacetFilters.StringValue.serializer() else -> throw AlgoliaClientException("Failed to deserialize json element: $element") } diff --git a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/recommend/HighlightResult.kt b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/recommend/HighlightResult.kt index 250b0b3586..ce95169f15 100644 --- a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/recommend/HighlightResult.kt +++ b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/recommend/HighlightResult.kt @@ -20,6 +20,10 @@ import kotlin.jvm.JvmInline */ @Serializable(HighlightResultSerializer::class) public sealed interface HighlightResult { + @Serializable + @JvmInline + public value class HighlightResultOptionValue(public val value: HighlightResultOption) : HighlightResult + @Serializable @JvmInline public value class MapOfkotlinStringHighlightResultValue(public val value: Map) : HighlightResult @@ -30,6 +34,9 @@ public sealed interface HighlightResult { public companion object { + public fun of(value: HighlightResultOption): HighlightResult { + return HighlightResultOptionValue(value) + } public fun of(value: Map): HighlightResult { return MapOfkotlinStringHighlightResultValue(value) } @@ -44,7 +51,7 @@ internal class HighlightResultSerializer : JsonContentPolymorphicSerializer HighlightResultOption.serializer() element is JsonObject -> HighlightResult.MapOfkotlinStringHighlightResultValue.serializer() - element.isJsonArrayOfObjects -> HighlightResult.ListOfHighlightResultValue.serializer() + element is JsonArray -> HighlightResult.ListOfHighlightResultValue.serializer() else -> throw AlgoliaClientException("Failed to deserialize json element: $element") } } diff --git a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/recommend/IgnorePlurals.kt b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/recommend/IgnorePlurals.kt index 6bce085bdd..136e16f386 100644 --- a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/recommend/IgnorePlurals.kt +++ b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/recommend/IgnorePlurals.kt @@ -24,6 +24,10 @@ public sealed interface IgnorePlurals { @JvmInline public value class ListOfSupportedLanguageValue(public val value: List) : IgnorePlurals + @Serializable + @JvmInline + public value class BooleanStringValue(public val value: BooleanString) : IgnorePlurals + @Serializable @JvmInline public value class BooleanValue(public val value: Boolean) : IgnorePlurals @@ -33,6 +37,9 @@ public sealed interface IgnorePlurals { public fun of(value: List): IgnorePlurals { return ListOfSupportedLanguageValue(value) } + public fun of(value: BooleanString): IgnorePlurals { + return BooleanStringValue(value) + } public fun of(value: Boolean): IgnorePlurals { return BooleanValue(value) } diff --git a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/recommend/NumericFilters.kt b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/recommend/NumericFilters.kt index f113169112..bd8ac3230e 100644 --- a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/recommend/NumericFilters.kt +++ b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/recommend/NumericFilters.kt @@ -41,7 +41,7 @@ public sealed interface NumericFilters { internal class NumericFiltersSerializer : JsonContentPolymorphicSerializer(NumericFilters::class) { override fun selectDeserializer(element: JsonElement): DeserializationStrategy { return when { - element.isJsonArrayOfObjects -> NumericFilters.ListOfNumericFiltersValue.serializer() + element is JsonArray -> NumericFilters.ListOfNumericFiltersValue.serializer() element.isString -> NumericFilters.StringValue.serializer() else -> throw AlgoliaClientException("Failed to deserialize json element: $element") } diff --git a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/recommend/OptionalFilters.kt b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/recommend/OptionalFilters.kt index 718878d9ed..7365d71a76 100644 --- a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/recommend/OptionalFilters.kt +++ b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/recommend/OptionalFilters.kt @@ -41,7 +41,7 @@ public sealed interface OptionalFilters { internal class OptionalFiltersSerializer : JsonContentPolymorphicSerializer(OptionalFilters::class) { override fun selectDeserializer(element: JsonElement): DeserializationStrategy { return when { - element.isJsonArrayOfObjects -> OptionalFilters.ListOfOptionalFiltersValue.serializer() + element is JsonArray -> OptionalFilters.ListOfOptionalFiltersValue.serializer() element.isString -> OptionalFilters.StringValue.serializer() else -> throw AlgoliaClientException("Failed to deserialize json element: $element") } diff --git a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/recommend/ReRankingApplyFilter.kt b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/recommend/ReRankingApplyFilter.kt index 8f7201ddba..f735e6a642 100644 --- a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/recommend/ReRankingApplyFilter.kt +++ b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/recommend/ReRankingApplyFilter.kt @@ -41,7 +41,7 @@ public sealed interface ReRankingApplyFilter { internal class ReRankingApplyFilterSerializer : JsonContentPolymorphicSerializer(ReRankingApplyFilter::class) { override fun selectDeserializer(element: JsonElement): DeserializationStrategy { return when { - element.isJsonArrayOfObjects -> ReRankingApplyFilter.ListOfReRankingApplyFilterValue.serializer() + element is JsonArray -> ReRankingApplyFilter.ListOfReRankingApplyFilterValue.serializer() element.isString -> ReRankingApplyFilter.StringValue.serializer() else -> throw AlgoliaClientException("Failed to deserialize json element: $element") } diff --git a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/recommend/RecommendationsHit.kt b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/recommend/RecommendationsHit.kt index f0a195dd1f..2144e6abf6 100644 --- a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/recommend/RecommendationsHit.kt +++ b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/recommend/RecommendationsHit.kt @@ -19,12 +19,19 @@ import kotlin.jvm.JvmInline */ @Serializable(RecommendationsHitSerializer::class) public sealed interface RecommendationsHit { + @Serializable + @JvmInline + public value class TrendingFacetHitValue(public val value: TrendingFacetHit) : RecommendationsHit + @Serializable @JvmInline public value class RecommendHitValue(public val value: RecommendHit) : RecommendationsHit public companion object { + public fun of(value: TrendingFacetHit): RecommendationsHit { + return TrendingFacetHitValue(value) + } public fun of(value: RecommendHit): RecommendationsHit { return RecommendHitValue(value) } @@ -34,7 +41,8 @@ public sealed interface RecommendationsHit { internal class RecommendationsHitSerializer : JsonContentPolymorphicSerializer(RecommendationsHit::class) { override fun selectDeserializer(element: JsonElement): DeserializationStrategy { return when { - element is JsonObject -> TrendingFacetHit.serializer() + element is JsonObject && element.containsKey("facetName") && element.containsKey("facetValue") -> TrendingFacetHit.serializer() + element is JsonObject && element.containsKey("objectID") -> RecommendHit.serializer() else -> throw AlgoliaClientException("Failed to deserialize json element: $element") } } diff --git a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/recommend/RecommendationsRequest.kt b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/recommend/RecommendationsRequest.kt index 16554d4533..37b260d0f3 100644 --- a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/recommend/RecommendationsRequest.kt +++ b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/recommend/RecommendationsRequest.kt @@ -8,6 +8,7 @@ import kotlinx.serialization.builtins.* import kotlinx.serialization.descriptors.* import kotlinx.serialization.encoding.* import kotlinx.serialization.json.* +import kotlin.jvm.JvmInline /** * RecommendationsRequest @@ -22,8 +23,50 @@ import kotlinx.serialization.json.* */ @Serializable(RecommendationsRequestSerializer::class) public sealed interface RecommendationsRequest { + @Serializable + @JvmInline + public value class BoughtTogetherQueryValue(public val value: BoughtTogetherQuery) : RecommendationsRequest + + @Serializable + @JvmInline + public value class RelatedQueryValue(public val value: RelatedQuery) : RecommendationsRequest + + @Serializable + @JvmInline + public value class TrendingItemsQueryValue(public val value: TrendingItemsQuery) : RecommendationsRequest + + @Serializable + @JvmInline + public value class TrendingFacetsQueryValue(public val value: TrendingFacetsQuery) : RecommendationsRequest + + @Serializable + @JvmInline + public value class LookingSimilarQueryValue(public val value: LookingSimilarQuery) : RecommendationsRequest + + @Serializable + @JvmInline + public value class RecommendedForYouQueryValue(public val value: RecommendedForYouQuery) : RecommendationsRequest public companion object { + + public fun of(value: BoughtTogetherQuery): RecommendationsRequest { + return BoughtTogetherQueryValue(value) + } + public fun of(value: RelatedQuery): RecommendationsRequest { + return RelatedQueryValue(value) + } + public fun of(value: TrendingItemsQuery): RecommendationsRequest { + return TrendingItemsQueryValue(value) + } + public fun of(value: TrendingFacetsQuery): RecommendationsRequest { + return TrendingFacetsQueryValue(value) + } + public fun of(value: LookingSimilarQuery): RecommendationsRequest { + return LookingSimilarQueryValue(value) + } + public fun of(value: RecommendedForYouQuery): RecommendationsRequest { + return RecommendedForYouQueryValue(value) + } } } diff --git a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/recommend/SnippetResult.kt b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/recommend/SnippetResult.kt index efaa85b731..de5932ff34 100644 --- a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/recommend/SnippetResult.kt +++ b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/recommend/SnippetResult.kt @@ -20,6 +20,10 @@ import kotlin.jvm.JvmInline */ @Serializable(SnippetResultSerializer::class) public sealed interface SnippetResult { + @Serializable + @JvmInline + public value class SnippetResultOptionValue(public val value: SnippetResultOption) : SnippetResult + @Serializable @JvmInline public value class MapOfkotlinStringSnippetResultValue(public val value: Map) : SnippetResult @@ -30,6 +34,9 @@ public sealed interface SnippetResult { public companion object { + public fun of(value: SnippetResultOption): SnippetResult { + return SnippetResultOptionValue(value) + } public fun of(value: Map): SnippetResult { return MapOfkotlinStringSnippetResultValue(value) } @@ -44,7 +51,7 @@ internal class SnippetResultSerializer : JsonContentPolymorphicSerializer SnippetResultOption.serializer() element is JsonObject -> SnippetResult.MapOfkotlinStringSnippetResultValue.serializer() - element.isJsonArrayOfObjects -> SnippetResult.ListOfSnippetResultValue.serializer() + element is JsonArray -> SnippetResult.ListOfSnippetResultValue.serializer() else -> throw AlgoliaClientException("Failed to deserialize json element: $element") } } diff --git a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/recommend/TagFilters.kt b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/recommend/TagFilters.kt index ca3eb3ee49..18d78a530c 100644 --- a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/recommend/TagFilters.kt +++ b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/recommend/TagFilters.kt @@ -41,7 +41,7 @@ public sealed interface TagFilters { internal class TagFiltersSerializer : JsonContentPolymorphicSerializer(TagFilters::class) { override fun selectDeserializer(element: JsonElement): DeserializationStrategy { return when { - element.isJsonArrayOfObjects -> TagFilters.ListOfTagFiltersValue.serializer() + element is JsonArray -> TagFilters.ListOfTagFiltersValue.serializer() element.isString -> TagFilters.StringValue.serializer() else -> throw AlgoliaClientException("Failed to deserialize json element: $element") } diff --git a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/recommend/TypoTolerance.kt b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/recommend/TypoTolerance.kt index 6fbfd1f506..cee9496a90 100644 --- a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/recommend/TypoTolerance.kt +++ b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/recommend/TypoTolerance.kt @@ -23,11 +23,18 @@ public sealed interface TypoTolerance { @JvmInline public value class BooleanValue(public val value: Boolean) : TypoTolerance + @Serializable + @JvmInline + public value class TypoToleranceEnumValue(public val value: TypoToleranceEnum) : TypoTolerance + public companion object { public fun of(value: Boolean): TypoTolerance { return BooleanValue(value) } + public fun of(value: TypoToleranceEnum): TypoTolerance { + return TypoToleranceEnumValue(value) + } } } diff --git a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/search/AroundPrecision.kt b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/search/AroundPrecision.kt index 8dc7f837c3..6efbd7f949 100644 --- a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/search/AroundPrecision.kt +++ b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/search/AroundPrecision.kt @@ -42,7 +42,7 @@ internal class AroundPrecisionSerializer : JsonContentPolymorphicSerializer { return when { element.isInt -> AroundPrecision.IntValue.serializer() - element.isJsonArrayOfObjects -> AroundPrecision.ListOfRangeValue.serializer() + element is JsonArray -> AroundPrecision.ListOfRangeValue.serializer() else -> throw AlgoliaClientException("Failed to deserialize json element: $element") } } diff --git a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/search/AroundRadius.kt b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/search/AroundRadius.kt index 530681d080..9524f1a607 100644 --- a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/search/AroundRadius.kt +++ b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/search/AroundRadius.kt @@ -23,11 +23,18 @@ public sealed interface AroundRadius { @JvmInline public value class IntValue(public val value: Int) : AroundRadius + @Serializable + @JvmInline + public value class AroundRadiusAllValue(public val value: AroundRadiusAll) : AroundRadius + public companion object { public fun of(value: Int): AroundRadius { return IntValue(value) } + public fun of(value: AroundRadiusAll): AroundRadius { + return AroundRadiusAllValue(value) + } } } diff --git a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/search/AttributeToUpdate.kt b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/search/AttributeToUpdate.kt index 71d16cc54e..02de0f80a4 100644 --- a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/search/AttributeToUpdate.kt +++ b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/search/AttributeToUpdate.kt @@ -24,11 +24,18 @@ public sealed interface AttributeToUpdate { @JvmInline public value class StringValue(public val value: String) : AttributeToUpdate + @Serializable + @JvmInline + public value class BuiltInOperationValue(public val value: BuiltInOperation) : AttributeToUpdate + public companion object { public fun of(value: String): AttributeToUpdate { return StringValue(value) } + public fun of(value: BuiltInOperation): AttributeToUpdate { + return BuiltInOperationValue(value) + } } } diff --git a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/search/AutomaticFacetFilters.kt b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/search/AutomaticFacetFilters.kt index 16af723ba0..c457de85f4 100644 --- a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/search/AutomaticFacetFilters.kt +++ b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/search/AutomaticFacetFilters.kt @@ -40,8 +40,8 @@ public sealed interface AutomaticFacetFilters { internal class AutomaticFacetFiltersSerializer : JsonContentPolymorphicSerializer(AutomaticFacetFilters::class) { override fun selectDeserializer(element: JsonElement): DeserializationStrategy { return when { - element.isJsonArrayOfObjects -> AutomaticFacetFilters.ListOfAutomaticFacetFilterValue.serializer() - element.isJsonArrayOfPrimitives -> AutomaticFacetFilters.ListOfStringValue.serializer() + element is JsonArray -> AutomaticFacetFilters.ListOfAutomaticFacetFilterValue.serializer() + element is JsonArray -> AutomaticFacetFilters.ListOfStringValue.serializer() else -> throw AlgoliaClientException("Failed to deserialize json element: $element") } } diff --git a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/search/BrowseParams.kt b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/search/BrowseParams.kt index 381bcabcf5..9cf6b0eb79 100644 --- a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/search/BrowseParams.kt +++ b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/search/BrowseParams.kt @@ -8,6 +8,7 @@ import kotlinx.serialization.builtins.* import kotlinx.serialization.descriptors.* import kotlinx.serialization.encoding.* import kotlinx.serialization.json.* +import kotlin.jvm.JvmInline /** * BrowseParams @@ -18,8 +19,22 @@ import kotlinx.serialization.json.* */ @Serializable(BrowseParamsSerializer::class) public sealed interface BrowseParams { + @Serializable + @JvmInline + public value class SearchParamsStringValue(public val value: SearchParamsString) : BrowseParams + + @Serializable + @JvmInline + public value class BrowseParamsObjectValue(public val value: BrowseParamsObject) : BrowseParams public companion object { + + public fun of(value: SearchParamsString): BrowseParams { + return SearchParamsStringValue(value) + } + public fun of(value: BrowseParamsObject): BrowseParams { + return BrowseParamsObjectValue(value) + } } } diff --git a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/search/ConsequenceQuery.kt b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/search/ConsequenceQuery.kt index 903dcd7a0b..da1e7b7374 100644 --- a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/search/ConsequenceQuery.kt +++ b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/search/ConsequenceQuery.kt @@ -19,12 +19,19 @@ import kotlin.jvm.JvmInline */ @Serializable(ConsequenceQuerySerializer::class) public sealed interface ConsequenceQuery { + @Serializable + @JvmInline + public value class ConsequenceQueryObjectValue(public val value: ConsequenceQueryObject) : ConsequenceQuery + @Serializable @JvmInline public value class StringValue(public val value: String) : ConsequenceQuery public companion object { + public fun of(value: ConsequenceQueryObject): ConsequenceQuery { + return ConsequenceQueryObjectValue(value) + } public fun of(value: String): ConsequenceQuery { return StringValue(value) } diff --git a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/search/FacetFilters.kt b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/search/FacetFilters.kt index 6864a4c273..e8e279a162 100644 --- a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/search/FacetFilters.kt +++ b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/search/FacetFilters.kt @@ -41,7 +41,7 @@ public sealed interface FacetFilters { internal class FacetFiltersSerializer : JsonContentPolymorphicSerializer(FacetFilters::class) { override fun selectDeserializer(element: JsonElement): DeserializationStrategy { return when { - element.isJsonArrayOfObjects -> FacetFilters.ListOfFacetFiltersValue.serializer() + element is JsonArray -> FacetFilters.ListOfFacetFiltersValue.serializer() element.isString -> FacetFilters.StringValue.serializer() else -> throw AlgoliaClientException("Failed to deserialize json element: $element") } diff --git a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/search/HighlightResult.kt b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/search/HighlightResult.kt index 4dceded1a1..b95dd755c6 100644 --- a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/search/HighlightResult.kt +++ b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/search/HighlightResult.kt @@ -20,6 +20,10 @@ import kotlin.jvm.JvmInline */ @Serializable(HighlightResultSerializer::class) public sealed interface HighlightResult { + @Serializable + @JvmInline + public value class HighlightResultOptionValue(public val value: HighlightResultOption) : HighlightResult + @Serializable @JvmInline public value class MapOfkotlinStringHighlightResultValue(public val value: Map) : HighlightResult @@ -30,6 +34,9 @@ public sealed interface HighlightResult { public companion object { + public fun of(value: HighlightResultOption): HighlightResult { + return HighlightResultOptionValue(value) + } public fun of(value: Map): HighlightResult { return MapOfkotlinStringHighlightResultValue(value) } @@ -44,7 +51,7 @@ internal class HighlightResultSerializer : JsonContentPolymorphicSerializer HighlightResultOption.serializer() element is JsonObject -> HighlightResult.MapOfkotlinStringHighlightResultValue.serializer() - element.isJsonArrayOfObjects -> HighlightResult.ListOfHighlightResultValue.serializer() + element is JsonArray -> HighlightResult.ListOfHighlightResultValue.serializer() else -> throw AlgoliaClientException("Failed to deserialize json element: $element") } } diff --git a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/search/IgnorePlurals.kt b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/search/IgnorePlurals.kt index 2f13c841f7..8f5160b78d 100644 --- a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/search/IgnorePlurals.kt +++ b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/search/IgnorePlurals.kt @@ -24,6 +24,10 @@ public sealed interface IgnorePlurals { @JvmInline public value class ListOfSupportedLanguageValue(public val value: List) : IgnorePlurals + @Serializable + @JvmInline + public value class BooleanStringValue(public val value: BooleanString) : IgnorePlurals + @Serializable @JvmInline public value class BooleanValue(public val value: Boolean) : IgnorePlurals @@ -33,6 +37,9 @@ public sealed interface IgnorePlurals { public fun of(value: List): IgnorePlurals { return ListOfSupportedLanguageValue(value) } + public fun of(value: BooleanString): IgnorePlurals { + return BooleanStringValue(value) + } public fun of(value: Boolean): IgnorePlurals { return BooleanValue(value) } diff --git a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/search/NumericFilters.kt b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/search/NumericFilters.kt index 4dcecfa6a8..862de60b53 100644 --- a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/search/NumericFilters.kt +++ b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/search/NumericFilters.kt @@ -41,7 +41,7 @@ public sealed interface NumericFilters { internal class NumericFiltersSerializer : JsonContentPolymorphicSerializer(NumericFilters::class) { override fun selectDeserializer(element: JsonElement): DeserializationStrategy { return when { - element.isJsonArrayOfObjects -> NumericFilters.ListOfNumericFiltersValue.serializer() + element is JsonArray -> NumericFilters.ListOfNumericFiltersValue.serializer() element.isString -> NumericFilters.StringValue.serializer() else -> throw AlgoliaClientException("Failed to deserialize json element: $element") } diff --git a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/search/OptionalFilters.kt b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/search/OptionalFilters.kt index 1d8d412d2d..e8e323a081 100644 --- a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/search/OptionalFilters.kt +++ b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/search/OptionalFilters.kt @@ -41,7 +41,7 @@ public sealed interface OptionalFilters { internal class OptionalFiltersSerializer : JsonContentPolymorphicSerializer(OptionalFilters::class) { override fun selectDeserializer(element: JsonElement): DeserializationStrategy { return when { - element.isJsonArrayOfObjects -> OptionalFilters.ListOfOptionalFiltersValue.serializer() + element is JsonArray -> OptionalFilters.ListOfOptionalFiltersValue.serializer() element.isString -> OptionalFilters.StringValue.serializer() else -> throw AlgoliaClientException("Failed to deserialize json element: $element") } diff --git a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/search/Promote.kt b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/search/Promote.kt index b94bb2a828..3b9b5a8ee4 100644 --- a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/search/Promote.kt +++ b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/search/Promote.kt @@ -8,6 +8,7 @@ import kotlinx.serialization.builtins.* import kotlinx.serialization.descriptors.* import kotlinx.serialization.encoding.* import kotlinx.serialization.json.* +import kotlin.jvm.JvmInline /** * Promote @@ -18,8 +19,22 @@ import kotlinx.serialization.json.* */ @Serializable(PromoteSerializer::class) public sealed interface Promote { + @Serializable + @JvmInline + public value class PromoteObjectIDsValue(public val value: PromoteObjectIDs) : Promote + + @Serializable + @JvmInline + public value class PromoteObjectIDValue(public val value: PromoteObjectID) : Promote public companion object { + + public fun of(value: PromoteObjectIDs): Promote { + return PromoteObjectIDsValue(value) + } + public fun of(value: PromoteObjectID): Promote { + return PromoteObjectIDValue(value) + } } } diff --git a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/search/ReRankingApplyFilter.kt b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/search/ReRankingApplyFilter.kt index cb73bfa13f..f017bea264 100644 --- a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/search/ReRankingApplyFilter.kt +++ b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/search/ReRankingApplyFilter.kt @@ -41,7 +41,7 @@ public sealed interface ReRankingApplyFilter { internal class ReRankingApplyFilterSerializer : JsonContentPolymorphicSerializer(ReRankingApplyFilter::class) { override fun selectDeserializer(element: JsonElement): DeserializationStrategy { return when { - element.isJsonArrayOfObjects -> ReRankingApplyFilter.ListOfReRankingApplyFilterValue.serializer() + element is JsonArray -> ReRankingApplyFilter.ListOfReRankingApplyFilterValue.serializer() element.isString -> ReRankingApplyFilter.StringValue.serializer() else -> throw AlgoliaClientException("Failed to deserialize json element: $element") } diff --git a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/search/SearchParams.kt b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/search/SearchParams.kt index 6c04f2de3b..0f9e184d9f 100644 --- a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/search/SearchParams.kt +++ b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/search/SearchParams.kt @@ -8,6 +8,7 @@ import kotlinx.serialization.builtins.* import kotlinx.serialization.descriptors.* import kotlinx.serialization.encoding.* import kotlinx.serialization.json.* +import kotlin.jvm.JvmInline /** * SearchParams @@ -18,8 +19,22 @@ import kotlinx.serialization.json.* */ @Serializable(SearchParamsSerializer::class) public sealed interface SearchParams { + @Serializable + @JvmInline + public value class SearchParamsStringValue(public val value: SearchParamsString) : SearchParams + + @Serializable + @JvmInline + public value class SearchParamsObjectValue(public val value: SearchParamsObject) : SearchParams public companion object { + + public fun of(value: SearchParamsString): SearchParams { + return SearchParamsStringValue(value) + } + public fun of(value: SearchParamsObject): SearchParams { + return SearchParamsObjectValue(value) + } } } diff --git a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/search/SearchQuery.kt b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/search/SearchQuery.kt index e487426c70..81edda4da9 100644 --- a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/search/SearchQuery.kt +++ b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/search/SearchQuery.kt @@ -8,6 +8,7 @@ import kotlinx.serialization.builtins.* import kotlinx.serialization.descriptors.* import kotlinx.serialization.encoding.* import kotlinx.serialization.json.* +import kotlin.jvm.JvmInline /** * SearchQuery @@ -18,8 +19,22 @@ import kotlinx.serialization.json.* */ @Serializable(SearchQuerySerializer::class) public sealed interface SearchQuery { + @Serializable + @JvmInline + public value class SearchForFacetsValue(public val value: SearchForFacets) : SearchQuery + + @Serializable + @JvmInline + public value class SearchForHitsValue(public val value: SearchForHits) : SearchQuery public companion object { + + public fun of(value: SearchForFacets): SearchQuery { + return SearchForFacetsValue(value) + } + public fun of(value: SearchForHits): SearchQuery { + return SearchForHitsValue(value) + } } } diff --git a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/search/SearchResult.kt b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/search/SearchResult.kt index c49b60b7a7..749562629c 100644 --- a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/search/SearchResult.kt +++ b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/search/SearchResult.kt @@ -8,6 +8,7 @@ import kotlinx.serialization.builtins.* import kotlinx.serialization.descriptors.* import kotlinx.serialization.encoding.* import kotlinx.serialization.json.* +import kotlin.jvm.JvmInline /** * SearchResult @@ -18,8 +19,22 @@ import kotlinx.serialization.json.* */ @Serializable(SearchResultSerializer::class) public sealed interface SearchResult { + @Serializable + @JvmInline + public value class SearchForFacetValuesResponseValue(public val value: SearchForFacetValuesResponse) : SearchResult + + @Serializable + @JvmInline + public value class SearchResponseValue(public val value: SearchResponse) : SearchResult public companion object { + + public fun of(value: SearchForFacetValuesResponse): SearchResult { + return SearchForFacetValuesResponseValue(value) + } + public fun of(value: SearchResponse): SearchResult { + return SearchResponseValue(value) + } } } diff --git a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/search/SnippetResult.kt b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/search/SnippetResult.kt index c2aa16dce7..3e42f82811 100644 --- a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/search/SnippetResult.kt +++ b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/search/SnippetResult.kt @@ -20,6 +20,10 @@ import kotlin.jvm.JvmInline */ @Serializable(SnippetResultSerializer::class) public sealed interface SnippetResult { + @Serializable + @JvmInline + public value class SnippetResultOptionValue(public val value: SnippetResultOption) : SnippetResult + @Serializable @JvmInline public value class MapOfkotlinStringSnippetResultValue(public val value: Map) : SnippetResult @@ -30,6 +34,9 @@ public sealed interface SnippetResult { public companion object { + public fun of(value: SnippetResultOption): SnippetResult { + return SnippetResultOptionValue(value) + } public fun of(value: Map): SnippetResult { return MapOfkotlinStringSnippetResultValue(value) } @@ -44,7 +51,7 @@ internal class SnippetResultSerializer : JsonContentPolymorphicSerializer SnippetResultOption.serializer() element is JsonObject -> SnippetResult.MapOfkotlinStringSnippetResultValue.serializer() - element.isJsonArrayOfObjects -> SnippetResult.ListOfSnippetResultValue.serializer() + element is JsonArray -> SnippetResult.ListOfSnippetResultValue.serializer() else -> throw AlgoliaClientException("Failed to deserialize json element: $element") } } diff --git a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/search/TagFilters.kt b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/search/TagFilters.kt index b184dd6f98..8e97c0c926 100644 --- a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/search/TagFilters.kt +++ b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/search/TagFilters.kt @@ -41,7 +41,7 @@ public sealed interface TagFilters { internal class TagFiltersSerializer : JsonContentPolymorphicSerializer(TagFilters::class) { override fun selectDeserializer(element: JsonElement): DeserializationStrategy { return when { - element.isJsonArrayOfObjects -> TagFilters.ListOfTagFiltersValue.serializer() + element is JsonArray -> TagFilters.ListOfTagFiltersValue.serializer() element.isString -> TagFilters.StringValue.serializer() else -> throw AlgoliaClientException("Failed to deserialize json element: $element") } diff --git a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/search/TypoTolerance.kt b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/search/TypoTolerance.kt index 84ea3d03c8..f91a561ff4 100644 --- a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/search/TypoTolerance.kt +++ b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/search/TypoTolerance.kt @@ -23,11 +23,18 @@ public sealed interface TypoTolerance { @JvmInline public value class BooleanValue(public val value: Boolean) : TypoTolerance + @Serializable + @JvmInline + public value class TypoToleranceEnumValue(public val value: TypoToleranceEnum) : TypoTolerance + public companion object { public fun of(value: Boolean): TypoTolerance { return BooleanValue(value) } + public fun of(value: TypoToleranceEnum): TypoTolerance { + return TypoToleranceEnumValue(value) + } } } diff --git a/clients/algoliasearch-client-scala/src/main/scala/algoliasearch/recommend/RecommendationsHit.scala b/clients/algoliasearch-client-scala/src/main/scala/algoliasearch/recommend/RecommendationsHit.scala index 5a51670d31..6c44c0405b 100644 --- a/clients/algoliasearch-client-scala/src/main/scala/algoliasearch/recommend/RecommendationsHit.scala +++ b/clients/algoliasearch-client-scala/src/main/scala/algoliasearch/recommend/RecommendationsHit.scala @@ -52,8 +52,9 @@ object RecommendationsHitSerializer extends Serializer[RecommendationsHit] { case (TypeInfo(clazz, _), json) if clazz == classOf[RecommendationsHit] => json match { - case value: JObject => Extraction.extract[TrendingFacetHit](value) - case _ => throw new MappingException("Can't convert " + json + " to RecommendationsHit") + case value: JObject if value.obj.exists(_._1 == "facetName") && value.obj.exists(_._1 == "facetValue") => + Extraction.extract[TrendingFacetHit](value) + case _ => throw new MappingException("Can't convert " + json + " to RecommendationsHit") } } diff --git a/clients/algoliasearch-client-swift/Sources/Recommend/Models/RecommendationsHit.swift b/clients/algoliasearch-client-swift/Sources/Recommend/Models/RecommendationsHit.swift index 928b9d86f2..8e572812b7 100644 --- a/clients/algoliasearch-client-swift/Sources/Recommend/Models/RecommendationsHit.swift +++ b/clients/algoliasearch-client-swift/Sources/Recommend/Models/RecommendationsHit.swift @@ -7,25 +7,25 @@ import Foundation #endif public enum RecommendationsHit: Codable, JSONEncodable, AbstractEncodable { - case recommendHit(RecommendHit) case trendingFacetHit(TrendingFacetHit) + case recommendHit(RecommendHit) public func encode(to encoder: Encoder) throws { var container = encoder.singleValueContainer() switch self { - case let .recommendHit(value): - try container.encode(value) case let .trendingFacetHit(value): try container.encode(value) + case let .recommendHit(value): + try container.encode(value) } } public init(from decoder: Decoder) throws { let container = try decoder.singleValueContainer() - if let value = try? container.decode(RecommendHit.self) { - self = .recommendHit(value) - } else if let value = try? container.decode(TrendingFacetHit.self) { + if let value = try? container.decode(TrendingFacetHit.self) { self = .trendingFacetHit(value) + } else if let value = try? container.decode(RecommendHit.self) { + self = .recommendHit(value) } else { throw DecodingError.typeMismatch( Self.Type.self, @@ -39,10 +39,10 @@ public enum RecommendationsHit: Codable, JSONEncodable, AbstractEncodable { public func GetActualInstance() -> Encodable { switch self { - case let .recommendHit(value): - value as RecommendHit case let .trendingFacetHit(value): value as TrendingFacetHit + case let .recommendHit(value): + value as RecommendHit } } } diff --git a/specs/bundled/algoliasearch.yml b/specs/bundled/algoliasearch.yml index e6352b6d3a..bbc91e2b84 100644 --- a/specs/bundled/algoliasearch.yml +++ b/specs/bundled/algoliasearch.yml @@ -4754,6 +4754,8 @@ components: $ref: '#/components/schemas/distinctSeqID' _score: $ref: '#/components/schemas/recommendScore' + x-discriminator-fields: + - objectID trendingFacetHit: type: object description: Trending facet hit. @@ -4768,6 +4770,9 @@ components: $ref: '#/components/schemas/facetName' facetValue: $ref: '#/components/schemas/facetValue' + x-discriminator-fields: + - facetName + - facetValue recommendationsHit: oneOf: - $ref: '#/components/schemas/recommendHit' diff --git a/specs/bundled/recommend.doc.yml b/specs/bundled/recommend.doc.yml index 1ba467afe8..60dede5f51 100644 --- a/specs/bundled/recommend.doc.yml +++ b/specs/bundled/recommend.doc.yml @@ -5644,6 +5644,8 @@ components: $ref: '#/components/schemas/distinctSeqID' _score: $ref: '#/components/schemas/recommendScore' + x-discriminator-fields: + - objectID trendingFacetHit: type: object description: Trending facet hit. @@ -5658,6 +5660,9 @@ components: $ref: '#/components/schemas/facetName' facetValue: $ref: '#/components/schemas/facetValue' + x-discriminator-fields: + - facetName + - facetValue recommendationsHit: oneOf: - $ref: '#/components/schemas/recommendHit' diff --git a/specs/bundled/recommend.yml b/specs/bundled/recommend.yml index b24da18d41..6245ed2c5c 100644 --- a/specs/bundled/recommend.yml +++ b/specs/bundled/recommend.yml @@ -3417,6 +3417,8 @@ components: $ref: '#/components/schemas/distinctSeqID' _score: $ref: '#/components/schemas/recommendScore' + x-discriminator-fields: + - objectID trendingFacetHit: type: object description: Trending facet hit. @@ -3431,6 +3433,9 @@ components: $ref: '#/components/schemas/facetName' facetValue: $ref: '#/components/schemas/facetValue' + x-discriminator-fields: + - facetName + - facetValue recommendationsHit: oneOf: - $ref: '#/components/schemas/recommendHit'