Skip to content

Commit

Permalink
Merge pull request #11 from appwrite/dev
Browse files Browse the repository at this point in the history
fix: patch updates for appwrite 1.4.1
  • Loading branch information
abnegate authored Sep 1, 2023
2 parents 0a4beb5 + 2396301 commit c1bf6e2
Show file tree
Hide file tree
Showing 13 changed files with 1,039 additions and 991 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

![Swift Package Manager](https://img.shields.io/github/v/release/appwrite/sdk-for-swift.svg?color=green&style=flat-square)
![License](https://img.shields.io/github/license/appwrite/sdk-for-swift.svg?style=flat-square)
![Version](https://img.shields.io/badge/api%20version-1.4.0-blue.svg?style=flat-square)
![Version](https://img.shields.io/badge/api%20version-1.4.1-blue.svg?style=flat-square)
[![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator)
[![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)
Expand Down Expand Up @@ -33,7 +33,7 @@ Add the package to your `Package.swift` dependencies:

```swift
dependencies: [
.package(url: "[email protected]:appwrite/sdk-for-swift.git", from: "3.0.0"),
.package(url: "[email protected]:appwrite/sdk-for-swift.git", from: "3.0.1"),
],
```

Expand Down
6 changes: 3 additions & 3 deletions Sources/Appwrite/Client.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ open class Client {
"x-sdk-name": "Swift",
"x-sdk-platform": "server",
"x-sdk-language": "swift",
"x-sdk-version": "3.0.0",
"x-sdk-version": "3.0.1",
"X-Appwrite-Response-Format": "1.4.0"
]

Expand Down Expand Up @@ -414,7 +414,7 @@ open class Client {
converter: { return $0 as! [String: Any] }
)
let chunksUploaded = map["chunksUploaded"] as! Int
offset = min(size, (chunksUploaded * Client.chunkSize))
offset = chunksUploaded * Client.chunkSize
} catch {
// File does not exist yet, swallow exception
}
Expand All @@ -425,7 +425,7 @@ open class Client {
?? (input.data as! ByteBuffer).getSlice(at: offset, length: Int(size - offset))

params[paramName] = InputFile.fromBuffer(slice!, filename: input.filename, mimeType: input.mimeType)
headers["content-range"] = "bytes \(offset)-\(min((offset + Client.chunkSize) - 1, size))/\(size)"
headers["content-range"] = "bytes \(offset)-\(min((offset + Client.chunkSize) - 1, size - 1))/\(size)"

result = try await call(
method: "POST",
Expand Down
48 changes: 48 additions & 0 deletions Sources/Appwrite/Role.swift
Original file line number Diff line number Diff line change
@@ -1,34 +1,82 @@
/// Helper class to generate role strings for `Permission`.
public class Role {

/// Grants access to anyone.
///
/// This includes authenticated and unauthenticated users.
public static func any() -> String {
return "any"
}

/// Grants access to a specific user by user ID.
///
/// You can optionally pass verified or unverified for
/// `status` to target specific types of users.
///
/// @param String id
/// @param String status
/// @return String
public static func user(_ id: String, _ status: String = "") -> String {
if(status.isEmpty) {
return "user:\(id)"
}
return "user:\(id)/\(status)"
}

/// Grants access to any authenticated or anonymous user.
///
/// You can optionally pass verified or unverified for
/// `status` to target specific types of users.
///
/// @param String status
/// @return String
public static func users(_ status: String = "") -> String {
if(status.isEmpty) {
return "users"
}
return "users/\(status)"
}

/// Grants access to any guest user without a session.
///
/// Authenticated users don't have access to this role.
///
/// @return String
public static func guests() -> String {
return "guests"
}

/// Grants access to a team by team ID.
///
/// You can optionally pass a role for `role` to target
/// team members with the specified role.
///
/// @param String id
/// @param String role
/// @return String
public static func team(_ id: String, _ role: String = "") -> String {
if(role.isEmpty) {
return "team:\(id)"
}
return "team:\(id)/\(role)"
}

/// Grants access to a specific member of a team.
///
/// When the member is removed from the team, they will
/// no longer have access.
///
/// @param String id
/// @return String
public static func member(_ id: String) -> String {
return "member:\(id)"
}

/// Grants access to a user with the specified label.
///
/// @param String name
/// @return String
public static func label(_ name: String) -> String {
return "label:\(name)"
}
}
Loading

0 comments on commit c1bf6e2

Please sign in to comment.