Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
29471d1
added channel helpers for realtime in the client sdks
ArnabChatterjee20k Dec 18, 2025
3f13cb1
Add Channel support to SDKs and templates
ArnabChatterjee20k Dec 18, 2025
5d19169
reverted changes
ArnabChatterjee20k Dec 18, 2025
b18671f
Refactor Channel references to use NIOCore.Channel and remove unused …
ArnabChatterjee20k Dec 18, 2025
fd57b65
Refractor channel to use builder pattern
ArnabChatterjee20k Dec 19, 2025
3e2402d
updated flutter config
ArnabChatterjee20k Dec 19, 2025
4ff8dd6
Refactor channel handling and subscription logic across multiple temp…
ArnabChatterjee20k Dec 30, 2025
61710ea
Refactor channel and interface definitions for improved clarity and c…
ArnabChatterjee20k Dec 30, 2025
9252cc3
fixed flutter
ArnabChatterjee20k Dec 30, 2025
4c3bef7
updated kotlin and swift
ArnabChatterjee20k Dec 30, 2025
05046c8
fixed swift
ArnabChatterjee20k Dec 30, 2025
9f5f635
Refactor channel method names for consistency across languages
ArnabChatterjee20k Jan 9, 2026
0b840f9
updated bucket
ArnabChatterjee20k Jan 9, 2026
7571e2d
updated react native and web ts
ArnabChatterjee20k Jan 9, 2026
2ed26c9
updated channel and resolved channel validation in web
ArnabChatterjee20k Jan 9, 2026
77147bd
added overloading for type strictness in kotlin
ArnabChatterjee20k Jan 9, 2026
6b30e48
removed leftovers
ArnabChatterjee20k Jan 9, 2026
cd88974
updated leftover
ArnabChatterjee20k Jan 9, 2026
d248155
fixed failing swift tests
ArnabChatterjee20k Jan 9, 2026
b0533b1
fixed failing swift tests
ArnabChatterjee20k Jan 9, 2026
903bdb3
Merge remote-tracking branch 'origin/dat-971' into dat-971
ArnabChatterjee20k Jan 9, 2026
18152a1
revamped realtime channel support for the js realtime
ArnabChatterjee20k Jan 12, 2026
9a74e33
refactor: enhance channel structure and type safety across multiple l…
ArnabChatterjee20k Jan 12, 2026
6d627f3
Merge remote-tracking branch 'origin/master' into dat-971
ArnabChatterjee20k Jan 12, 2026
dde2c4b
refactor: update channel interfaces for improved type safety
ArnabChatterjee20k Jan 12, 2026
3ed2d3e
updated kotlin
ArnabChatterjee20k Jan 12, 2026
163e7fc
updated swift issue
ArnabChatterjee20k Jan 12, 2026
45a8b61
Merge remote-tracking branch 'origin/master' into dat-971
ArnabChatterjee20k Jan 13, 2026
8af59f4
fixed android client build
ArnabChatterjee20k Jan 13, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/SDK/Language/Android.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ public function getFiles(): array
'destination' => '/library/src/main/java/{{ sdk.namespace | caseSlash }}/ID.kt',
'template' => '/android/library/src/main/java/io/package/ID.kt.twig',
],
[
'scope' => 'default',
'destination' => '/library/src/main/java/{{ sdk.namespace | caseSlash }}/Channel.kt',
'template' => '/android/library/src/main/java/io/package/Channel.kt.twig',
],
[
'scope' => 'default',
'destination' => '/library/src/main/java/{{ sdk.namespace | caseSlash }}/Query.kt',
Expand Down
5 changes: 5 additions & 0 deletions src/SDK/Language/Apple.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ public function getFiles(): array
'destination' => '/Sources/{{ spec.title | caseUcfirst}}/ID.swift',
'template' => 'swift/Sources/ID.swift.twig',
],
[
'scope' => 'default',
'destination' => '/Sources/{{ spec.title | caseUcfirst}}/Channel.swift',
'template' => 'apple/Sources/Channel.swift.twig',
],
[
'scope' => 'default',
'destination' => '/Sources/{{ spec.title | caseUcfirst}}/Query.swift',
Expand Down
10 changes: 10 additions & 0 deletions src/SDK/Language/Dart.php
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,11 @@ public function getFiles(): array
'destination' => '/lib/id.dart',
'template' => 'dart/lib/id.dart.twig',
],
[
'scope' => 'default',
'destination' => '/lib/channel.dart',
'template' => 'dart/lib/channel.dart.twig',
],
[
'scope' => 'default',
'destination' => '/lib/query.dart',
Expand Down Expand Up @@ -464,6 +469,11 @@ public function getFiles(): array
'destination' => '/test/role_test.dart',
'template' => 'dart/test/role_test.dart.twig',
],
[
'scope' => 'default',
'destination' => '/test/channel_test.dart',
'template' => 'dart/test/channel_test.dart.twig',
],
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
[
'scope' => 'default',
'destination' => '/test/src/enums_test.dart',
Expand Down
10 changes: 10 additions & 0 deletions src/SDK/Language/Flutter.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ public function getFiles(): array
'destination' => '/lib/id.dart',
'template' => 'dart/lib/id.dart.twig',
],
[
'scope' => 'default',
'destination' => '/lib/channel.dart',
'template' => 'flutter/lib/channel.dart.twig',
],
[
'scope' => 'default',
'destination' => '/lib/query.dart',
Expand Down Expand Up @@ -290,6 +295,11 @@ public function getFiles(): array
'destination' => '/test/role_test.dart',
'template' => 'dart/test/role_test.dart.twig',
],
[
'scope' => 'default',
'destination' => '/test/channel_test.dart',
'template' => 'dart/test/channel_test.dart.twig',
],
[
'scope' => 'default',
'destination' => '/test/src/cookie_manager_test.dart',
Expand Down
5 changes: 5 additions & 0 deletions src/SDK/Language/ReactNative.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ public function getFiles(): array
'destination' => 'src/id.ts',
'template' => 'react-native/src/id.ts.twig',
],
[
'scope' => 'default',
'destination' => 'src/channel.ts',
'template' => 'react-native/src/channel.ts.twig',
],
[
'scope' => 'default',
'destination' => 'src/query.ts',
Expand Down
5 changes: 5 additions & 0 deletions src/SDK/Language/Web.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ public function getFiles(): array
'destination' => 'src/id.ts',
'template' => 'web/src/id.ts.twig',
],
[
'scope' => 'default',
'destination' => 'src/channel.ts',
'template' => 'web/src/channel.ts.twig',
],
[
'scope' => 'default',
'destination' => 'src/query.ts',
Expand Down
190 changes: 190 additions & 0 deletions templates/android/library/src/main/java/io/package/Channel.kt.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
package {{ sdk.namespace | caseDot }}

class ResolvedChannel(private val value: String) {
override fun toString(): String {
return value
}
}

abstract class ActionChannel(protected val base: String) {
fun create(): ResolvedChannel {
return ResolvedChannel("$base.create")
}

fun update(): ResolvedChannel {
return ResolvedChannel("$base.update")
}

fun delete(): ResolvedChannel {
return ResolvedChannel("$base.delete")
}

override fun toString(): String {
return base
}
}

class DocumentChannel(base: String) : ActionChannel(base)

class CollectionChannel(
private val databaseId: String,
private val collectionId: String
) {
private val base = "databases.$databaseId.collections.$collectionId"

fun document(documentId: String = "*"): DocumentChannel {
return DocumentChannel("$base.documents.$documentId")
}

override fun toString(): String {
return base
}
}

class DatabaseChannel(private val databaseId: String) {
private val base = "databases.$databaseId"

fun collection(collectionId: String = "*"): CollectionChannel {
return CollectionChannel(databaseId, collectionId)
}

override fun toString(): String {
return base
}
}

class RowChannel(base: String) : ActionChannel(base)

class TableChannel(
private val databaseId: String,
private val tableId: String
) {
private val base = "tablesdb.$databaseId.tables.$tableId"

fun row(rowId: String = "*"): RowChannel {
return RowChannel("$base.rows.$rowId")
}

override fun toString(): String {
return base
}
}

class TablesDBChannel(private val databaseId: String) {
private val base = "tablesdb.$databaseId"

fun table(tableId: String = "*"): TableChannel {
return TableChannel(databaseId, tableId)
}

override fun toString(): String {
return base
}
}

class FileChannel(base: String) : ActionChannel(base)

class BucketChannel(private val bucketId: String) {
private val base = "buckets.$bucketId"

fun file(fileId: String = "*"): FileChannel {
return FileChannel("$base.files.$fileId")
}

override fun toString(): String {
return base
}
}

class ExecutionChannel(base: String) : ActionChannel(base)

class FunctionChannel(private val functionId: String) {
private val base = "functions.$functionId"

fun execution(executionId: String = "*"): ExecutionChannel {
return ExecutionChannel("$base.executions.$executionId")
}

override fun toString(): String {
return base
}
}

class TeamChannel(teamId: String = "*") : ActionChannel("teams.$teamId")

class MembershipChannel(membershipId: String = "*") : ActionChannel("memberships.$membershipId")

class Channel {
companion object {
/**
* Generate a database channel builder.
*
* @param databaseId The database ID (default: "*")
* @returns DatabaseChannel
*/
fun database(databaseId: String = "*"): DatabaseChannel {
return DatabaseChannel(databaseId)
}

/**
* Generate a tables database channel builder.
*
* @param databaseId The database ID (default: "*")
* @returns TablesDBChannel
*/
fun tablesdb(databaseId: String = "*"): TablesDBChannel {
return TablesDBChannel(databaseId)
}

/**
* Generate a buckets channel builder.
*
* @param bucketId The bucket ID (default: "*")
* @returns BucketChannel
*/
fun buckets(bucketId: String = "*"): BucketChannel {
return BucketChannel(bucketId)
}

/**
* Generate a functions channel builder.
*
* @param functionId The function ID (default: "*")
* @returns FunctionChannel
*/
fun functions(functionId: String = "*"): FunctionChannel {
return FunctionChannel(functionId)
}

/**
* Generate a teams channel builder.
*
* @param teamId The team ID (default: "*")
* @returns TeamChannel
*/
fun teams(teamId: String = "*"): TeamChannel {
return TeamChannel(teamId)
}

/**
* Generate a memberships channel builder.
*
* @param membershipId The membership ID (default: "*")
* @returns MembershipChannel
*/
fun memberships(membershipId: String = "*"): MembershipChannel {
return MembershipChannel(membershipId)
}

/**
* Generate an account channel string.
*
* @param userId The user ID (default: "*")
* @returns The channel string
*/
fun account(userId: String = "*"): String {
return "account.$userId"
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,25 @@ class Realtime(client: Client) : Service(client), CoroutineScope {
else -> 60000L
}

/**
* Convert channel value to string
*/
private fun channelToString(channel: Any): String {
return when (channel) {
is String -> channel
else -> channel.toString()
}
}

fun subscribe(
vararg channels: Any,
Comment thread
abnegate marked this conversation as resolved.
Outdated
callback: (RealtimeResponseEvent<Any>) -> Unit,
) = subscribe(
channels = channels.map { channelToString(it) }.toTypedArray(),
Any::class.java,
callback
)

fun subscribe(
vararg channels: String,
callback: (RealtimeResponseEvent<Any>) -> Unit,
Expand All @@ -118,6 +137,18 @@ class Realtime(client: Client) : Service(client), CoroutineScope {
callback
)

fun <T> subscribe(
vararg channels: Any,
payloadType: Class<T>,
callback: (RealtimeResponseEvent<T>) -> Unit,
): RealtimeSubscription {
return subscribe(
channels = channels.map { channelToString(it) }.toTypedArray(),
payloadType = payloadType,
callback = callback
)
}

fun <T> subscribe(
vararg channels: String,
payloadType: Class<T>,
Expand Down
Loading
Loading