Skip to content

Commit e14f39a

Browse files
authored
Merge pull request #37 from appwrite/dev
fix: for appwrite 1.4.x
2 parents 8fee8f1 + 2635b5a commit e14f39a

File tree

11 files changed

+490
-442
lines changed

11 files changed

+490
-442
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Add the package to your `Package.swift` dependencies:
3131

3232
```swift
3333
dependencies: [
34-
.package(url: "[email protected]:appwrite/sdk-for-apple.git", from: "3.0.0"),
34+
.package(url: "[email protected]:appwrite/sdk-for-apple.git", from: "3.0.1"),
3535
],
3636
```
3737

Sources/Appwrite/Client.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ open class Client {
2323
"x-sdk-name": "Apple",
2424
"x-sdk-platform": "client",
2525
"x-sdk-language": "apple",
26-
"x-sdk-version": "3.0.0",
26+
"x-sdk-version": "3.0.1",
2727
"X-Appwrite-Response-Format": "1.4.0"
2828
]
2929

@@ -399,7 +399,7 @@ open class Client {
399399
converter: { return $0 as! [String: Any] }
400400
)
401401
let chunksUploaded = map["chunksUploaded"] as! Int
402-
offset = min(size, (chunksUploaded * Client.chunkSize))
402+
offset = chunksUploaded * Client.chunkSize
403403
} catch {
404404
// File does not exist yet, swallow exception
405405
}
@@ -410,7 +410,7 @@ open class Client {
410410
?? (input.data as! ByteBuffer).getSlice(at: offset, length: Int(size - offset))
411411

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

415415
result = try await call(
416416
method: "POST",

Sources/Appwrite/Role.swift

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,82 @@
1+
/// Helper class to generate role strings for `Permission`.
12
public class Role {
3+
4+
/// Grants access to anyone.
5+
///
6+
/// This includes authenticated and unauthenticated users.
27
public static func any() -> String {
38
return "any"
49
}
510

11+
/// Grants access to a specific user by user ID.
12+
///
13+
/// You can optionally pass verified or unverified for
14+
/// `status` to target specific types of users.
15+
///
16+
/// @param String id
17+
/// @param String status
18+
/// @return String
619
public static func user(_ id: String, _ status: String = "") -> String {
720
if(status.isEmpty) {
821
return "user:\(id)"
922
}
1023
return "user:\(id)/\(status)"
1124
}
1225

26+
/// Grants access to any authenticated or anonymous user.
27+
///
28+
/// You can optionally pass verified or unverified for
29+
/// `status` to target specific types of users.
30+
///
31+
/// @param String status
32+
/// @return String
1333
public static func users(_ status: String = "") -> String {
1434
if(status.isEmpty) {
1535
return "users"
1636
}
1737
return "users/\(status)"
1838
}
1939

40+
/// Grants access to any guest user without a session.
41+
///
42+
/// Authenticated users don't have access to this role.
43+
///
44+
/// @return String
2045
public static func guests() -> String {
2146
return "guests"
2247
}
2348

49+
/// Grants access to a team by team ID.
50+
///
51+
/// You can optionally pass a role for `role` to target
52+
/// team members with the specified role.
53+
///
54+
/// @param String id
55+
/// @param String role
56+
/// @return String
2457
public static func team(_ id: String, _ role: String = "") -> String {
2558
if(role.isEmpty) {
2659
return "team:\(id)"
2760
}
2861
return "team:\(id)/\(role)"
2962
}
3063

64+
/// Grants access to a specific member of a team.
65+
///
66+
/// When the member is removed from the team, they will
67+
/// no longer have access.
68+
///
69+
/// @param String id
70+
/// @return String
3171
public static func member(_ id: String) -> String {
3272
return "member:\(id)"
3373
}
74+
75+
/// Grants access to a user with the specified label.
76+
///
77+
/// @param String name
78+
/// @return String
79+
public static func label(_ name: String) -> String {
80+
return "label:\(name)"
81+
}
3482
}

0 commit comments

Comments
 (0)