Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
[![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite)
[![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord)

**This SDK is compatible with Appwrite server version 1.8.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-apple/releases).**
**This SDK is compatible with Appwrite server version latest. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-apple/releases).**

Appwrite is an open-source backend as a service server that abstracts and simplifies complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the Apple SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs)

Expand Down
57 changes: 20 additions & 37 deletions Sources/Appwrite/Channel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,13 @@ public class RealtimeChannel<T> {
self.segments = segments
}

/// Internal helper to transition to next state with segment and ID
internal func next<N>(_ segment: String, _ id: String = "*") -> RealtimeChannel<N> {
return RealtimeChannel<N>(segments + [segment, normalize(id)])
/// Internal helper to transition to next state with segment and optional ID
internal func next<N>(_ segment: String, _ id: String? = nil) -> RealtimeChannel<N> {
if let id = id {
return RealtimeChannel<N>(segments + [segment, normalize(id)])
}

return RealtimeChannel<N>(segments + [segment])
}

/// Internal helper for terminal actions (no ID segment)
Expand Down Expand Up @@ -67,6 +71,10 @@ public enum Channel {
return RealtimeChannel<_Func>(["functions", normalize(id)])
}

public static func execution(_ id: String = "*") -> RealtimeChannel<_Execution> {
return RealtimeChannel<_Execution>(["executions", normalize(id)])
}

public static func team(_ id: String = "*") -> RealtimeChannel<_Team> {
return RealtimeChannel<_Team>(["teams", normalize(id)])
}
Expand All @@ -75,9 +83,8 @@ public enum Channel {
return RealtimeChannel<_Membership>(["memberships", normalize(id)])
}

public static func account(_ userId: String = "") -> String {
let id = normalize(userId)
return id == "*" ? "account" : "account.\(id)"
public static func account() -> String {
return "account"
}

// Global events
Expand All @@ -93,14 +100,14 @@ public enum Channel {

/// Only available on RealtimeChannel<_Database>
extension RealtimeChannel where T == _Database {
public func collection(_ id: String = "*") -> RealtimeChannel<_Collection> {
return self.next("collections", id)
public func collection(_ id: String? = nil) -> RealtimeChannel<_Collection> {
return self.next("collections", id ?? "*")
}
}

/// Only available on RealtimeChannel<_Collection>
extension RealtimeChannel where T == _Collection {
public func document(_ id: String = "*") -> RealtimeChannel<_Document> {
public func document(_ id: String? = nil) -> RealtimeChannel<_Document> {
return self.next("documents", id)
}
}
Expand All @@ -109,14 +116,14 @@ extension RealtimeChannel where T == _Collection {

/// Only available on RealtimeChannel<_TablesDB>
extension RealtimeChannel where T == _TablesDB {
public func table(_ id: String = "*") -> RealtimeChannel<_Table> {
return self.next("tables", id)
public func table(_ id: String? = nil) -> RealtimeChannel<_Table> {
return self.next("tables", id ?? "*")
}
}

/// Only available on RealtimeChannel<_Table>
extension RealtimeChannel where T == _Table {
public func row(_ id: String = "*") -> RealtimeChannel<_Row> {
public func row(_ id: String? = nil) -> RealtimeChannel<_Row> {
return self.next("rows", id)
}
}
Expand All @@ -125,20 +132,11 @@ extension RealtimeChannel where T == _Table {

/// Only available on RealtimeChannel<_Bucket>
extension RealtimeChannel where T == _Bucket {
public func file(_ id: String = "*") -> RealtimeChannel<_File> {
public func file(_ id: String? = nil) -> RealtimeChannel<_File> {
return self.next("files", id)
}
}

// MARK: - FUNCTION ROUTE

/// Only available on RealtimeChannel<_Func>
extension RealtimeChannel where T == _Func {
public func execution(_ id: String = "*") -> RealtimeChannel<_Execution> {
return self.next("executions", id)
}
}

// MARK: - TERMINAL ACTIONS
// Restricted to actionable types (_Document, _Row, _File, _Execution, _Team, _Membership)

Expand Down Expand Up @@ -187,21 +185,6 @@ extension RealtimeChannel where T == _File {
}
}

/// Only available on RealtimeChannel<_Execution>
extension RealtimeChannel where T == _Execution {
public func create() -> RealtimeChannel<_Resolved> {
return self.resolve("create")
}

public func update() -> RealtimeChannel<_Resolved> {
return self.resolve("update")
}

public func delete() -> RealtimeChannel<_Resolved> {
return self.resolve("delete")
}
}

/// Only available on RealtimeChannel<_Team>
extension RealtimeChannel where T == _Team {
public func create() -> RealtimeChannel<_Resolved> {
Expand Down
2 changes: 2 additions & 0 deletions Sources/AppwriteEnums/OAuthProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ public enum OAuthProvider: String, CustomStringConvertible {
case yandex = "yandex"
case zoho = "zoho"
case zoom = "zoom"
case githubImagine = "githubImagine"
case googleImagine = "googleImagine"
Comment on lines +43 to +44
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# Search for githubImagine and googleImagine in the repository
rg -n "githubImagine|googleImagine" -i

# Check the full context of the OAuthProvider enum
cat -n Sources/AppwriteEnums/OAuthProvider.swift

# Search for any comments or documentation about these providers
rg -n "Imagine" -B2 -A2

Repository: appwrite/sdk-for-apple

Length of output: 2357


🌐 Web query:

Appwrite OAuth providers githubImagine googleImagine official documentation

💡 Result:

In Appwrite Auth, the official docs show that GitHub and Google are supported OAuth2 providers (use provider values github and google when calling the OAuth session/token endpoints, after enabling the provider in the Appwrite Console). [1]

For the Google provider setup, Appwrite’s official integration guide walks through creating a Google OAuth client, adding the Client ID/secret in Auth → Settings → OAuth2 Providers → Google, and configuring the redirect URI. [2]

If “githubImagine / googleImagine” refers to something specific beyond the GitHub/Google OAuth providers, it doesn’t appear as an official Appwrite term in the docs I found. [1]

Sources:
[1] Appwrite Account API Reference (Create OAuth2 session/token; supported providers list)
[2] Appwrite “OAuth with Google” integration guide


Remove or verify these invalid OAuth provider identifiers.

githubImagine and googleImagine are not valid Appwrite OAuth provider identifiers. According to official Appwrite documentation, only github and google are supported providers. These enum cases will fail at runtime if used. Additionally, if they are intentional (e.g., custom or upcoming providers), they should be inserted in alphabetical order between their respective base providers rather than appended at the end (e.g., githubImagine after github, googleImagine after google).

🤖 Prompt for AI Agents
In `@Sources/AppwriteEnums/OAuthProvider.swift` around lines 43 - 44, The
OAuthProvider enum contains invalid cases githubImagine and googleImagine;
remove these two cases from the OAuthProvider enum (or replace/rename them to
valid Appwrite identifiers if they were intentionally meant to represent real
providers) and, if they are intentional custom/upcoming providers, insert them
alphabetically next to their base providers (e.g., place githubImagine
immediately after github and googleImagine immediately after google) while
ensuring the enum raw values match the intended provider identifiers; update any
references to OAuthProvider.githubImagine or OAuthProvider.googleImagine
accordingly.


public var description: String {
return rawValue
Expand Down