Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
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' => 'swift/Sources/Channel.swift.twig',
],
[
'scope' => 'default',
'destination' => '/Sources/{{ spec.title | caseUcfirst}}/Query.swift',
Expand Down
5 changes: 5 additions & 0 deletions src/SDK/Language/Dart.php
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,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/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' => 'dart/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
116 changes: 116 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,116 @@
package {{ sdk.namespace | caseDot }}

/**
* Helper class to generate channel strings for realtime subscriptions.
*/
class Channel {
companion object {

/**
* Generate a database channel string.
*
* @param databaseId The database ID (default: "*")
* @param collectionId The collection ID (default: "*")
* @param documentId The document ID (default: "*")
* @param action Optional action: "create", "update", or "delete" (default: null)
* @returns The channel string
*/
fun database(databaseId: String = "*", collectionId: String = "*", documentId: String = "*", action: String? = null): String {
var channel = "databases.$databaseId.collections.$collectionId.documents.$documentId"
if (action != null) {
channel += ".$action"
}
return channel
}

/**
* Generate a tables database channel string.
*
* @param databaseId The database ID (default: "*")
* @param tableId The table ID (default: "*")
* @param rowId The row ID (default: "*")
* @param action Optional action: "create", "update", or "delete" (default: null)
* @returns The channel string
*/
fun tablesdb(databaseId: String = "*", tableId: String = "*", rowId: String = "*", action: String? = null): String {
var channel = "tablesdb.$databaseId.tables.$tableId.rows.$rowId"
if (action != null) {
channel += ".$action"
}
return channel
}

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

/**
* Generate a files channel string.
*
* @param bucketId The bucket ID (default: "*")
* @param fileId The file ID (default: "*")
* @param action Optional action: "create", "update", or "delete" (default: null)
* @returns The channel string
*/
fun files(bucketId: String = "*", fileId: String = "*", action: String? = null): String {
var channel = "buckets.$bucketId.files.$fileId"
if (action != null) {
channel += ".$action"
}
return channel
}

/**
* Generate an executions channel string.
*
* @param functionId The function ID (default: "*")
* @param executionId The execution ID (default: "*")
* @param action Optional action: "create", "update", or "delete" (default: null)
* @returns The channel string
*/
fun executions(functionId: String = "*", executionId: String = "*", action: String? = null): String {
var channel = "functions.$functionId.executions.$executionId"
if (action != null) {
channel += ".$action"
}
return channel
}

/**
* Generate a teams channel string.
*
* @param teamId The team ID (default: "*")
* @param action Optional action: "create", "update", or "delete" (default: null)
* @returns The channel string
*/
fun teams(teamId: String = "*", action: String? = null): String {
var channel = "teams.$teamId"
if (action != null) {
channel += ".$action"
}
return channel
}

/**
* Generate a memberships channel string.
*
* @param membershipId The membership ID (default: "*")
* @param action Optional action: "create", "update", or "delete" (default: null)
* @returns The channel string
*/
fun memberships(membershipId: String = "*", action: String? = null): String {
var channel = "memberships.$membershipId"
if (action != null) {
channel += ".$action"
}
return channel
}
}
}

116 changes: 116 additions & 0 deletions templates/dart/lib/channel.dart.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
part of '{{ language.params.packageName }}.dart';

/// Helper class to generate channel strings for realtime subscriptions.
class Channel {
Channel._();

/// Generate a database channel string.
///
/// [databaseId] The database ID (default: '*')
/// [collectionId] The collection ID (default: '*')
/// [documentId] The document ID (default: '*')
/// [action] Optional action: 'create', 'update', or 'delete' (default: null)
static String database({
String databaseId = '*',
String collectionId = '*',
String documentId = '*',
String? action,
}) {
String channel = 'databases.$databaseId.collections.$collectionId.documents.$documentId';
if (action != null) {
channel += '.$action';
}
return channel;
}

/// Generate a tables database channel string.
///
/// [databaseId] The database ID (default: '*')
/// [tableId] The table ID (default: '*')
/// [rowId] The row ID (default: '*')
/// [action] Optional action: 'create', 'update', or 'delete' (default: null)
static String tablesdb({
String databaseId = '*',
String tableId = '*',
String rowId = '*',
String? action,
}) {
String channel = 'tablesdb.$databaseId.tables.$tableId.rows.$rowId';
if (action != null) {
channel += '.$action';
}
return channel;
}

/// Generate an account channel string.
///
/// [userId] The user ID (default: '*')
static String account({String userId = '*'}) {
return 'account.$userId';
}

/// Generate a files channel string.
///
/// [bucketId] The bucket ID (default: '*')
/// [fileId] The file ID (default: '*')
/// [action] Optional action: 'create', 'update', or 'delete' (default: null)
static String files({
String bucketId = '*',
String fileId = '*',
String? action,
}) {
String channel = 'buckets.$bucketId.files.$fileId';
if (action != null) {
channel += '.$action';
}
return channel;
}

/// Generate an executions channel string.
///
/// [functionId] The function ID (default: '*')
/// [executionId] The execution ID (default: '*')
/// [action] Optional action: 'create', 'update', or 'delete' (default: null)
static String executions({
String functionId = '*',
String executionId = '*',
String? action,
}) {
String channel = 'functions.$functionId.executions.$executionId';
if (action != null) {
channel += '.$action';
}
return channel;
}

/// Generate a teams channel string.
///
/// [teamId] The team ID (default: '*')
/// [action] Optional action: 'create', 'update', or 'delete' (default: null)
static String teams({
String teamId = '*',
String? action,
}) {
String channel = 'teams.$teamId';
if (action != null) {
channel += '.$action';
}
return channel;
}

/// Generate a memberships channel string.
///
/// [membershipId] The membership ID (default: '*')
/// [action] Optional action: 'create', 'update', or 'delete' (default: null)
static String memberships({
String membershipId = '*',
String? action,
}) {
String channel = 'memberships.$membershipId';
if (action != null) {
channel += '.$action';
}
return channel;
}
}

1 change: 1 addition & 0 deletions templates/dart/lib/package.dart.twig
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ part 'query.dart';
part 'permission.dart';
part 'role.dart';
part 'id.dart';
part 'channel.dart';
part 'operator.dart';
{% for service in spec.services %}
part 'services/{{service.name | caseSnake}}.dart';
Expand Down
Loading
Loading