All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.chat.bsky.convo.MessageInput.kt Maven / Gradle / Ivy

The newest version!
@file:Suppress("DEPRECATION")

package chat.bsky.convo

import app.bsky.embed.Record
import app.bsky.richtext.Facet
import kotlin.String
import kotlin.Suppress
import kotlin.jvm.JvmInline
import kotlinx.collections.immutable.persistentListOf
import kotlinx.serialization.KSerializer
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import sh.christian.ozone.api.model.ReadOnlyList
import sh.christian.ozone.api.runtime.valueClassSerializer

@Serializable
public sealed interface MessageInputEmbedUnion {
  public class AppBskyEmbedRecordSerializer : KSerializer by valueClassSerializer(
    serialName = "app.bsky.embed.record",
    constructor = ::AppBskyEmbedRecord,
    valueProvider = AppBskyEmbedRecord::value,
    valueSerializerProvider = { Record.serializer() },
  )

  @Serializable(with = AppBskyEmbedRecordSerializer::class)
  @JvmInline
  @SerialName("app.bsky.embed.record")
  public value class AppBskyEmbedRecord(
    public val `value`: Record,
  ) : MessageInputEmbedUnion
}

/**
 * @param facets Annotations of text (mentions, URLs, hashtags, etc)
 */
@Serializable
public data class MessageInput(
  public val text: String,
  /**
   * Annotations of text (mentions, URLs, hashtags, etc)
   */
  public val facets: ReadOnlyList = persistentListOf(),
  public val embed: MessageInputEmbedUnion? = null,
) {
  init {
    require(text.count() <= 10_000) {
      "text.count() must be <= 10_000, but was ${text.count()}"
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy