@@ -30,9 +30,13 @@ public class RealtimeChannel<T> {
3030 self . segments = segments
3131 }
3232
33- /// Internal helper to transition to next state with segment and ID
34- internal func next< N> ( _ segment: String , _ id: String = " * " ) -> RealtimeChannel < N > {
35- return RealtimeChannel < N > ( segments + [ segment, normalize ( id) ] )
33+ /// Internal helper to transition to next state with segment and optional ID
34+ internal func next< N> ( _ segment: String , _ id: String ? = nil ) -> RealtimeChannel < N > {
35+ if let id = id {
36+ return RealtimeChannel < N > ( segments + [ segment, normalize ( id) ] )
37+ }
38+
39+ return RealtimeChannel < N > ( segments + [ segment] )
3640 }
3741
3842 /// Internal helper for terminal actions (no ID segment)
@@ -67,6 +71,10 @@ public enum Channel {
6771 return RealtimeChannel < _Func > ( [ " functions " , normalize ( id) ] )
6872 }
6973
74+ public static func execution( _ id: String = " * " ) -> RealtimeChannel < _Execution > {
75+ return RealtimeChannel < _Execution > ( [ " executions " , normalize ( id) ] )
76+ }
77+
7078 public static func team( _ id: String = " * " ) -> RealtimeChannel < _Team > {
7179 return RealtimeChannel < _Team > ( [ " teams " , normalize ( id) ] )
7280 }
@@ -75,9 +83,8 @@ public enum Channel {
7583 return RealtimeChannel < _Membership > ( [ " memberships " , normalize ( id) ] )
7684 }
7785
78- public static func account( _ userId: String = " " ) -> String {
79- let id = normalize ( userId)
80- return id == " * " ? " account " : " account. \( id) "
86+ public static func account( ) -> String {
87+ return " account "
8188 }
8289
8390 // Global events
@@ -93,14 +100,14 @@ public enum Channel {
93100
94101/// Only available on RealtimeChannel<_Database>
95102extension RealtimeChannel where T == _Database {
96- public func collection( _ id: String = " * " ) -> RealtimeChannel < _Collection > {
97- return self . next ( " collections " , id)
103+ public func collection( _ id: String ? = nil ) -> RealtimeChannel < _Collection > {
104+ return self . next ( " collections " , id ?? " * " )
98105 }
99106}
100107
101108/// Only available on RealtimeChannel<_Collection>
102109extension RealtimeChannel where T == _Collection {
103- public func document( _ id: String = " * " ) -> RealtimeChannel < _Document > {
110+ public func document( _ id: String ? = nil ) -> RealtimeChannel < _Document > {
104111 return self . next ( " documents " , id)
105112 }
106113}
@@ -109,14 +116,14 @@ extension RealtimeChannel where T == _Collection {
109116
110117/// Only available on RealtimeChannel<_TablesDB>
111118extension RealtimeChannel where T == _TablesDB {
112- public func table( _ id: String = " * " ) -> RealtimeChannel < _Table > {
113- return self . next ( " tables " , id)
119+ public func table( _ id: String ? = nil ) -> RealtimeChannel < _Table > {
120+ return self . next ( " tables " , id ?? " * " )
114121 }
115122}
116123
117124/// Only available on RealtimeChannel<_Table>
118125extension RealtimeChannel where T == _Table {
119- public func row( _ id: String = " * " ) -> RealtimeChannel < _Row > {
126+ public func row( _ id: String ? = nil ) -> RealtimeChannel < _Row > {
120127 return self . next ( " rows " , id)
121128 }
122129}
@@ -125,20 +132,11 @@ extension RealtimeChannel where T == _Table {
125132
126133/// Only available on RealtimeChannel<_Bucket>
127134extension RealtimeChannel where T == _Bucket {
128- public func file( _ id: String = " * " ) -> RealtimeChannel < _File > {
135+ public func file( _ id: String ? = nil ) -> RealtimeChannel < _File > {
129136 return self . next ( " files " , id)
130137 }
131138}
132139
133- // MARK: - FUNCTION ROUTE
134-
135- /// Only available on RealtimeChannel<_Func>
136- extension RealtimeChannel where T == _Func {
137- public func execution( _ id: String = " * " ) -> RealtimeChannel < _Execution > {
138- return self . next ( " executions " , id)
139- }
140- }
141-
142140// MARK: - TERMINAL ACTIONS
143141// Restricted to actionable types (_Document, _Row, _File, _Execution, _Team, _Membership)
144142
@@ -187,21 +185,6 @@ extension RealtimeChannel where T == _File {
187185 }
188186}
189187
190- /// Only available on RealtimeChannel<_Execution>
191- extension RealtimeChannel where T == _Execution {
192- public func create( ) -> RealtimeChannel < _Resolved > {
193- return self . resolve ( " create " )
194- }
195-
196- public func update( ) -> RealtimeChannel < _Resolved > {
197- return self . resolve ( " update " )
198- }
199-
200- public func delete( ) -> RealtimeChannel < _Resolved > {
201- return self . resolve ( " delete " )
202- }
203- }
204-
205188/// Only available on RealtimeChannel<_Team>
206189extension RealtimeChannel where T == _Team {
207190 public func create( ) -> RealtimeChannel < _Resolved > {
0 commit comments