Skip to content

Commit

Permalink
Minor changes required for JS Chat SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
wkal-pubnub committed Oct 23, 2024
1 parent 4525c1e commit e2369d6
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,21 +64,28 @@ class PubNubBaseKotlinMultiplatformPlugin : Plugin<Project> {

if (enableJsTarget) {
js { ->
useEsModules()
browser {
project.findProperty("JS_MODULE_NAME")?.toString()?.let { jsModuleName ->
moduleName = jsModuleName
}
// useEsModules()
// browser {
// testTask {
// it.useMocha {
// timeout = "10s"
// }
// }
// }
// binaries.executable()
binaries.library()
generateTypeScriptDefinitions()

nodejs {
testTask {
it.useMocha {
timeout = "10s"
timeout = "5s"
}
}
}
// nodejs {
// testTask {
// it.useMocha {
// timeout = "5s"
// }
// }
// }
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ import com.pubnub.kmp.toJsMap
import kotlin.js.json
import PubNub as PubNubJs

class PubNubImpl(private val jsPubNub: PubNubJs) : PubNub {
class PubNubImpl(val jsPubNub: PubNubJs) : PubNub {
constructor(configuration: PNConfiguration) : this(PubNubJs(configuration.toJs()))

override val configuration: PNConfiguration
Expand Down Expand Up @@ -560,7 +560,7 @@ class PubNubImpl(private val jsPubNub: PubNubJs) : PubNub {
jsPubNub,
createJsObject {
this.channel = channel
this.data = ChannelMetadata(
this.data = createChannelMetadata(
PatchValue.of(name),
PatchValue.of(description),
PatchValue.of(status),
Expand Down Expand Up @@ -633,7 +633,7 @@ class PubNubImpl(private val jsPubNub: PubNubJs) : PubNub {
return SetUUIDMetadataImpl(
jsPubNub,
createJsObject {
data = UUIDMetadata(
data = createUuidMetadata(
PatchValue.of(name),
PatchValue.of(externalId),
PatchValue.of(profileUrl),
Expand Down Expand Up @@ -676,6 +676,7 @@ class PubNubImpl(private val jsPubNub: PubNubJs) : PubNub {
createJsObject {
this.sort = sort.toJsMap()
this.filter = filter
this.page = page.toMetadataPage()
this.include = createJsObject<PubNubJs.MembershipIncludeOptions> {
this.customFields = includeCustom
this.totalCount = includeCount
Expand Down Expand Up @@ -1117,7 +1118,7 @@ private fun Any.adjustCollectionTypes(): Any {
}
}

fun UUIDMetadata(
private fun createUuidMetadata(
name: PatchValue<String?>,
externalId: PatchValue<String?>,
profileUrl: PatchValue<String?>,
Expand All @@ -1137,7 +1138,7 @@ fun UUIDMetadata(
return result
}

fun ChannelMetadata(
private fun createChannelMetadata(
name: PatchValue<String?>,
description: PatchValue<String?>,
status: PatchValue<String?>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,10 @@ enum class PNPushEnvironment {
fun toParamString(): String {
return name.lowercase()
}

companion object {
fun fromParamString(paramString: String): PNPushEnvironment {
return entries.first { it.toParamString() == paramString }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ enum class PNPushType(private val value: String) {
return value.lowercase()
}

companion object {
fun fromParamString(paramString: String): PNPushType {
return entries.first { it.toParamString() == paramString }
}
}

override fun toString(): String {
return value
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ class PNConfigurationImpl(

@Deprecated(
message = "The authKey parameter is deprecated because it relates to deprecated Access Manager (PAM V2) and will be removed in the future." +
"Please, use createPNConfiguration without authKey instead and migrate to new Access Manager " +
"(PAM V3) https://www.pubnub.com/docs/general/resources/migration-guides/pam-v3-migration ",
"Please, use createPNConfiguration without authKey instead and migrate to new Access Manager " +
"(PAM V3) https://www.pubnub.com/docs/general/resources/migration-guides/pam-v3-migration ",
level = DeprecationLevel.WARNING,
replaceWith = ReplaceWith(
"createPNConfiguration(userId, subscribeKey, publishKey, secretKey, logVerbosity)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ internal class SubscribeMessageProcessor(
)
val queryParams = ArrayList<String>()
val authToken =
if (pubnub.tokenManager.getToken() != null){
if (pubnub.tokenManager.getToken() != null) {
pubnub.tokenManager.getToken()
} else if (pubnub.configuration.authKey.isValid()) {
pubnub.configuration.authKey
Expand Down

0 comments on commit e2369d6

Please sign in to comment.