Skip to content

Commit e3d298a

Browse files
committed
chore(v3/api): Make response codecs accessible from external modules
1 parent daedcfb commit e3d298a

File tree

11 files changed

+20
-18
lines changed

11 files changed

+20
-18
lines changed

v3/api/src/main/kotlin/ru/epserv/proxycheck/v3/api/model/response/AddressResult.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
package ru.epserv.proxycheck.v3.api.model.response
22

3+
import com.mojang.serialization.Codec
34
import org.jetbrains.annotations.ApiStatus
45
import ru.epserv.proxycheck.v3.api.util.buildMapCodec
56
import ru.epserv.proxycheck.v3.api.util.codec.Codecs
67
import ru.epserv.proxycheck.v3.api.util.codec.Codecs.associatedWith
78
import ru.epserv.proxycheck.v3.api.util.codec.Codecs.forNullableGetter
9+
import java.net.InetAddress
810
import java.util.*
911
import kotlin.jvm.optionals.getOrNull
1012
import kotlin.time.ExperimentalTime
@@ -50,7 +52,7 @@ data class AddressResult(
5052

5153
companion object {
5254
@ApiStatus.Internal
53-
internal val CODEC = buildMapCodec { instance ->
55+
val CODEC = buildMapCodec { instance ->
5456
instance.group(
5557
Network.CODEC.fieldOf("network").forGetter(AddressResult::network),
5658
Location.CODEC.fieldOf("location").forGetter(AddressResult::location),
@@ -62,6 +64,6 @@ data class AddressResult(
6264
}
6365

6466
@ApiStatus.Internal
65-
internal val IP_STRING_TO_RESULT_CODEC = Codecs.INET_ADDRESS_STRING.associatedWith(CODEC).codec()
67+
val IP_STRING_TO_RESULT_CODEC: Codec<Map<InetAddress, AddressResult>> = Codecs.INET_ADDRESS_STRING.associatedWith(CODEC).codec()
6668
}
6769
}

v3/api/src/main/kotlin/ru/epserv/proxycheck/v3/api/model/response/Currency.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ data class Currency(
2121
) {
2222
companion object {
2323
@ApiStatus.Internal
24-
internal val CODEC = buildMapCodec { instance ->
24+
val CODEC = buildMapCodec { instance ->
2525
instance.group(
2626
Codec.STRING.fieldOf("code").forGetter(Currency::code),
2727
Codec.STRING.fieldOf("name").forGetter(Currency::name),

v3/api/src/main/kotlin/ru/epserv/proxycheck/v3/api/model/response/Detections.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import org.jetbrains.annotations.Range
66
import ru.epserv.proxycheck.v3.api.util.buildMapCodec
77
import ru.epserv.proxycheck.v3.api.util.codec.Codecs
88
import ru.epserv.proxycheck.v3.api.util.codec.Codecs.forNullableGetter
9-
import java.util.Optional
9+
import java.util.*
1010
import kotlin.jvm.optionals.getOrNull
1111
import kotlin.time.ExperimentalTime
1212
import kotlin.time.Instant
@@ -72,7 +72,7 @@ data class Detections(
7272
)
7373
companion object {
7474
@ApiStatus.Internal
75-
internal val CODEC = buildMapCodec { instance ->
75+
val CODEC = buildMapCodec { instance ->
7676
instance.group(
7777
Codec.BOOL.fieldOf("proxy").forGetter(Detections::proxy),
7878
Codec.BOOL.fieldOf("vpn").forGetter(Detections::vpn),

v3/api/src/main/kotlin/ru/epserv/proxycheck/v3/api/model/response/DeviceEstimate.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ data class DeviceEstimate(
1919
) {
2020
companion object {
2121
@ApiStatus.Internal
22-
internal val CODEC = buildMapCodec { instance ->
22+
val CODEC = buildMapCodec { instance ->
2323
instance.group(
2424
Codec.LONG.fieldOf("address").forGetter(DeviceEstimate::address),
2525
Codec.LONG.fieldOf("subnet").forGetter(DeviceEstimate::subnet),

v3/api/src/main/kotlin/ru/epserv/proxycheck/v3/api/model/response/Location.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ data class Location(
7070

7171
companion object {
7272
@ApiStatus.Internal
73-
internal val CODEC = buildMapCodec { instance ->
73+
val CODEC = buildMapCodec { instance ->
7474
instance.group(
7575
Codec.STRING.fieldOf("continent_name").forGetter(Location::continentName),
7676
Codec.STRING.fieldOf("continent_code").forGetter(Location::continentCode),

v3/api/src/main/kotlin/ru/epserv/proxycheck/v3/api/model/response/Network.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ data class Network(
4848

4949
companion object {
5050
@ApiStatus.Internal
51-
internal val CODEC = buildMapCodec { instance ->
51+
val CODEC = buildMapCodec { instance ->
5252
instance.group(
5353
Codecs.ASN_STRING.optionalFieldOf("asn").forNullableGetter(Network::asn),
5454
CidrIpRange.STRING_CODEC.optionalFieldOf("range").forNullableGetter(Network::range),

v3/api/src/main/kotlin/ru/epserv/proxycheck/v3/api/model/response/Operator.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ data class Operator(
4747

4848
companion object {
4949
@ApiStatus.Internal
50-
internal val CODEC = buildMapCodec { instance ->
50+
val CODEC = buildMapCodec { instance ->
5151
instance.group(
5252
Codec.STRING.fieldOf("name").forGetter(Operator::name),
5353
Codec.STRING.fieldOf("url").forGetter(Operator::url),

v3/api/src/main/kotlin/ru/epserv/proxycheck/v3/api/model/response/OperatorPolicies.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ data class OperatorPolicies(
5454

5555
companion object {
5656
@ApiStatus.Internal
57-
internal val CODEC = buildMapCodec { instance ->
57+
val CODEC = buildMapCodec { instance ->
5858
instance.group(
5959
Codec.BOOL.optionalFieldOf("ad_filtering").forNullableGetter(OperatorPolicies::adFiltering),
6060
Codec.BOOL.optionalFieldOf("free_access").forNullableGetter(OperatorPolicies::freeAccess),

v3/api/src/main/kotlin/ru/epserv/proxycheck/v3/api/model/response/Response.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ sealed interface Response {
125125

126126
companion object {
127127
@ApiStatus.Internal
128-
internal val METADATA_MAP_CODEC = mapCodec { instance ->
128+
val METADATA_MAP_CODEC = mapCodec { instance ->
129129
instance.group(
130130
ResponseStatus.SUCCESSFUL_CODEC.fieldOf("status").forGetter(Success::status),
131131
Codec.STRING.optionalFieldOf("message").forNullableGetter(Success::message),
@@ -145,10 +145,10 @@ sealed interface Response {
145145
}
146146

147147
@ApiStatus.Internal
148-
internal val METADATA_CODEC = METADATA_MAP_CODEC.toCodec()
148+
val METADATA_CODEC = METADATA_MAP_CODEC.toCodec()
149149

150150
@ApiStatus.Internal
151-
internal val CODEC = SuccessCodec
151+
val CODEC: Codec<Success> = SuccessCodec
152152

153153
internal object SuccessCodec : Codec<Success> {
154154
override fun <T : Any> encode(
@@ -210,7 +210,7 @@ sealed interface Response {
210210

211211
companion object {
212212
@ApiStatus.Internal
213-
internal val CODEC = buildMapCodec { instance ->
213+
val CODEC = buildMapCodec { instance ->
214214
instance.group(
215215
ResponseStatus.NON_SUCCESSFUL_CODEC.fieldOf("status").forGetter(Failure::status),
216216
Codec.STRING.optionalFieldOf("message").forNullableGetter(Failure::message),

v3/api/src/main/kotlin/ru/epserv/proxycheck/v3/api/model/response/ResponseStatus.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,16 @@ enum class ResponseStatus(
3232
private val index = entries.associateBy { it.value }
3333

3434
@ApiStatus.Internal
35-
internal val CODEC: Codec<ResponseStatus> = Codec.STRING.comapFlatMap(
35+
val CODEC: Codec<ResponseStatus> = Codec.STRING.comapFlatMap(
3636
{ value -> index[value]?.let { DataResult.success(it) } ?: DataResult.error { "Unknown response status: $value" } },
3737
ResponseStatus::value,
3838
)
3939

4040
@ApiStatus.Internal
41-
internal val SUCCESSFUL_CODEC: Codec<ResponseStatus> = CODEC.flatXmap(::asDataResultSuccessful, ::asDataResultSuccessful)
41+
val SUCCESSFUL_CODEC: Codec<ResponseStatus> = CODEC.flatXmap(::asDataResultSuccessful, ::asDataResultSuccessful)
4242

4343
@ApiStatus.Internal
44-
internal val NON_SUCCESSFUL_CODEC: Codec<ResponseStatus> = CODEC.flatXmap(::asDataResultNonSuccessful, ::asDataResultNonSuccessful)
44+
val NON_SUCCESSFUL_CODEC: Codec<ResponseStatus> = CODEC.flatXmap(::asDataResultNonSuccessful, ::asDataResultNonSuccessful)
4545

4646
private fun asDataResultSuccessful(status: ResponseStatus): DataResult<ResponseStatus> {
4747
return if (status.isSuccessful) DataResult.success(status) else DataResult.error { "Unsuccessful response status: ${status.value}" }

0 commit comments

Comments
 (0)