Skip to content

Commit 3208c17

Browse files
authored
Merge pull request #32 from appwrite/dev
Dev
2 parents b955902 + dddb2a1 commit 3208c17

File tree

326 files changed

+3545
-546
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

326 files changed

+3545
-546
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
![Swift Package Manager](https://img.shields.io/github/v/release/appwrite/sdk-for-swift.svg?color=green&style=flat-square)
44
![License](https://img.shields.io/github/license/appwrite/sdk-for-swift.svg?style=flat-square)
5-
![Version](https://img.shields.io/badge/api%20version-1.6.2-blue.svg?style=flat-square)
5+
![Version](https://img.shields.io/badge/api%20version-1.7.0-blue.svg?style=flat-square)
66
[![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator)
77
[![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite)
88
[![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord)
99

10-
**This SDK is compatible with Appwrite server version 1.6.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-swift/releases).**
10+
**This SDK is compatible with Appwrite server version 1.7.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-swift/releases).**
1111

1212
> This is the Swift SDK for integrating with Appwrite from your Swift server-side code. If you're looking for the Apple SDK you should check [appwrite/sdk-for-apple](https://github.com/appwrite/sdk-for-apple)
1313
@@ -33,7 +33,7 @@ Add the package to your `Package.swift` dependencies:
3333

3434
```swift
3535
dependencies: [
36-
.package(url: "git@github.com:appwrite/sdk-for-swift.git", from: "9.0.0"),
36+
.package(url: "git@github.com:appwrite/sdk-for-swift.git", from: "10.0.0"),
3737
],
3838
```
3939

Sources/Appwrite/Client.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ open class Client {
2121
"x-sdk-name": "Swift",
2222
"x-sdk-platform": "server",
2323
"x-sdk-language": "swift",
24-
"x-sdk-version": "9.0.0",
25-
"x-appwrite-response-format": "1.6.0"
24+
"x-sdk-version": "10.0.0",
25+
"x-appwrite-response-format": "1.7.0"
2626
]
2727

2828
internal var config: [String: String] = [:]

Sources/Appwrite/Services/Databases.swift

Lines changed: 279 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1580,7 +1580,6 @@ open class Databases: Service {
15801580
/// collection resource using either a [server
15811581
/// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection)
15821582
/// API or directly from your database console.
1583-
///
15841583
///
15851584
/// @param String databaseId
15861585
/// @param String collectionId
@@ -1630,7 +1629,6 @@ open class Databases: Service {
16301629
/// collection resource using either a [server
16311630
/// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection)
16321631
/// API or directly from your database console.
1633-
///
16341632
///
16351633
/// @param String databaseId
16361634
/// @param String collectionId
@@ -1657,6 +1655,280 @@ open class Databases: Service {
16571655
)
16581656
}
16591657

1658+
///
1659+
/// Create new Documents. Before using this route, you should create a new
1660+
/// collection resource using either a [server
1661+
/// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection)
1662+
/// API or directly from your database console.
1663+
///
1664+
/// @param String databaseId
1665+
/// @param String collectionId
1666+
/// @param [Any] documents
1667+
/// @throws Exception
1668+
/// @return array
1669+
///
1670+
open func createDocuments<T>(
1671+
databaseId: String,
1672+
collectionId: String,
1673+
documents: [Any],
1674+
nestedType: T.Type
1675+
) async throws -> AppwriteModels.DocumentList<T> {
1676+
let apiPath: String = "/databases/{databaseId}/collections/{collectionId}/documents"
1677+
.replacingOccurrences(of: "{databaseId}", with: databaseId)
1678+
.replacingOccurrences(of: "{collectionId}", with: collectionId)
1679+
1680+
let apiParams: [String: Any?] = [
1681+
"documents": documents
1682+
]
1683+
1684+
let apiHeaders: [String: String] = [
1685+
"content-type": "application/json"
1686+
]
1687+
1688+
let converter: (Any) -> AppwriteModels.DocumentList<T> = { response in
1689+
return AppwriteModels.DocumentList.from(map: response as! [String: Any])
1690+
}
1691+
1692+
return try await client.call(
1693+
method: "POST",
1694+
path: apiPath,
1695+
headers: apiHeaders,
1696+
params: apiParams,
1697+
converter: converter
1698+
)
1699+
}
1700+
1701+
///
1702+
/// Create new Documents. Before using this route, you should create a new
1703+
/// collection resource using either a [server
1704+
/// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection)
1705+
/// API or directly from your database console.
1706+
///
1707+
/// @param String databaseId
1708+
/// @param String collectionId
1709+
/// @param [Any] documents
1710+
/// @throws Exception
1711+
/// @return array
1712+
///
1713+
open func createDocuments(
1714+
databaseId: String,
1715+
collectionId: String,
1716+
documents: [Any]
1717+
) async throws -> AppwriteModels.DocumentList<[String: AnyCodable]> {
1718+
return try await createDocuments(
1719+
databaseId: databaseId,
1720+
collectionId: collectionId,
1721+
documents: documents,
1722+
nestedType: [String: AnyCodable].self
1723+
)
1724+
}
1725+
1726+
///
1727+
/// Create or update Documents. Before using this route, you should create a
1728+
/// new collection resource using either a [server
1729+
/// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection)
1730+
/// API or directly from your database console.
1731+
///
1732+
///
1733+
/// @param String databaseId
1734+
/// @param String collectionId
1735+
/// @param [Any] documents
1736+
/// @throws Exception
1737+
/// @return array
1738+
///
1739+
open func upsertDocuments<T>(
1740+
databaseId: String,
1741+
collectionId: String,
1742+
documents: [Any]? = nil,
1743+
nestedType: T.Type
1744+
) async throws -> AppwriteModels.DocumentList<T> {
1745+
let apiPath: String = "/databases/{databaseId}/collections/{collectionId}/documents"
1746+
.replacingOccurrences(of: "{databaseId}", with: databaseId)
1747+
.replacingOccurrences(of: "{collectionId}", with: collectionId)
1748+
1749+
let apiParams: [String: Any?] = [
1750+
"documents": documents
1751+
]
1752+
1753+
let apiHeaders: [String: String] = [
1754+
"content-type": "application/json"
1755+
]
1756+
1757+
let converter: (Any) -> AppwriteModels.DocumentList<T> = { response in
1758+
return AppwriteModels.DocumentList.from(map: response as! [String: Any])
1759+
}
1760+
1761+
return try await client.call(
1762+
method: "PUT",
1763+
path: apiPath,
1764+
headers: apiHeaders,
1765+
params: apiParams,
1766+
converter: converter
1767+
)
1768+
}
1769+
1770+
///
1771+
/// Create or update Documents. Before using this route, you should create a
1772+
/// new collection resource using either a [server
1773+
/// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection)
1774+
/// API or directly from your database console.
1775+
///
1776+
///
1777+
/// @param String databaseId
1778+
/// @param String collectionId
1779+
/// @param [Any] documents
1780+
/// @throws Exception
1781+
/// @return array
1782+
///
1783+
open func upsertDocuments(
1784+
databaseId: String,
1785+
collectionId: String,
1786+
documents: [Any]? = nil
1787+
) async throws -> AppwriteModels.DocumentList<[String: AnyCodable]> {
1788+
return try await upsertDocuments(
1789+
databaseId: databaseId,
1790+
collectionId: collectionId,
1791+
documents: documents,
1792+
nestedType: [String: AnyCodable].self
1793+
)
1794+
}
1795+
1796+
///
1797+
/// Update all documents that match your queries, if no queries are submitted
1798+
/// then all documents are updated. You can pass only specific fields to be
1799+
/// updated.
1800+
///
1801+
/// @param String databaseId
1802+
/// @param String collectionId
1803+
/// @param Any data
1804+
/// @param [String] queries
1805+
/// @throws Exception
1806+
/// @return array
1807+
///
1808+
open func updateDocuments<T>(
1809+
databaseId: String,
1810+
collectionId: String,
1811+
data: Any? = nil,
1812+
queries: [String]? = nil,
1813+
nestedType: T.Type
1814+
) async throws -> AppwriteModels.DocumentList<T> {
1815+
let apiPath: String = "/databases/{databaseId}/collections/{collectionId}/documents"
1816+
.replacingOccurrences(of: "{databaseId}", with: databaseId)
1817+
.replacingOccurrences(of: "{collectionId}", with: collectionId)
1818+
1819+
let apiParams: [String: Any?] = [
1820+
"data": data,
1821+
"queries": queries
1822+
]
1823+
1824+
let apiHeaders: [String: String] = [
1825+
"content-type": "application/json"
1826+
]
1827+
1828+
let converter: (Any) -> AppwriteModels.DocumentList<T> = { response in
1829+
return AppwriteModels.DocumentList.from(map: response as! [String: Any])
1830+
}
1831+
1832+
return try await client.call(
1833+
method: "PATCH",
1834+
path: apiPath,
1835+
headers: apiHeaders,
1836+
params: apiParams,
1837+
converter: converter
1838+
)
1839+
}
1840+
1841+
///
1842+
/// Update all documents that match your queries, if no queries are submitted
1843+
/// then all documents are updated. You can pass only specific fields to be
1844+
/// updated.
1845+
///
1846+
/// @param String databaseId
1847+
/// @param String collectionId
1848+
/// @param Any data
1849+
/// @param [String] queries
1850+
/// @throws Exception
1851+
/// @return array
1852+
///
1853+
open func updateDocuments(
1854+
databaseId: String,
1855+
collectionId: String,
1856+
data: Any? = nil,
1857+
queries: [String]? = nil
1858+
) async throws -> AppwriteModels.DocumentList<[String: AnyCodable]> {
1859+
return try await updateDocuments(
1860+
databaseId: databaseId,
1861+
collectionId: collectionId,
1862+
data: data,
1863+
queries: queries,
1864+
nestedType: [String: AnyCodable].self
1865+
)
1866+
}
1867+
1868+
///
1869+
/// Bulk delete documents using queries, if no queries are passed then all
1870+
/// documents are deleted.
1871+
///
1872+
/// @param String databaseId
1873+
/// @param String collectionId
1874+
/// @param [String] queries
1875+
/// @throws Exception
1876+
/// @return array
1877+
///
1878+
open func deleteDocuments<T>(
1879+
databaseId: String,
1880+
collectionId: String,
1881+
queries: [String]? = nil,
1882+
nestedType: T.Type
1883+
) async throws -> AppwriteModels.DocumentList<T> {
1884+
let apiPath: String = "/databases/{databaseId}/collections/{collectionId}/documents"
1885+
.replacingOccurrences(of: "{databaseId}", with: databaseId)
1886+
.replacingOccurrences(of: "{collectionId}", with: collectionId)
1887+
1888+
let apiParams: [String: Any?] = [
1889+
"queries": queries
1890+
]
1891+
1892+
let apiHeaders: [String: String] = [
1893+
"content-type": "application/json"
1894+
]
1895+
1896+
let converter: (Any) -> AppwriteModels.DocumentList<T> = { response in
1897+
return AppwriteModels.DocumentList.from(map: response as! [String: Any])
1898+
}
1899+
1900+
return try await client.call(
1901+
method: "DELETE",
1902+
path: apiPath,
1903+
headers: apiHeaders,
1904+
params: apiParams,
1905+
converter: converter
1906+
)
1907+
}
1908+
1909+
///
1910+
/// Bulk delete documents using queries, if no queries are passed then all
1911+
/// documents are deleted.
1912+
///
1913+
/// @param String databaseId
1914+
/// @param String collectionId
1915+
/// @param [String] queries
1916+
/// @throws Exception
1917+
/// @return array
1918+
///
1919+
open func deleteDocuments(
1920+
databaseId: String,
1921+
collectionId: String,
1922+
queries: [String]? = nil
1923+
) async throws -> AppwriteModels.DocumentList<[String: AnyCodable]> {
1924+
return try await deleteDocuments(
1925+
databaseId: databaseId,
1926+
collectionId: collectionId,
1927+
queries: queries,
1928+
nestedType: [String: AnyCodable].self
1929+
)
1930+
}
1931+
16601932
///
16611933
/// Get a document by its unique ID. This endpoint response returns a JSON
16621934
/// object with the document data.
@@ -1881,6 +2153,7 @@ open class Databases: Service {
18812153
/// @param AppwriteEnums.IndexType type
18822154
/// @param [String] attributes
18832155
/// @param [String] orders
2156+
/// @param [Int] lengths
18842157
/// @throws Exception
18852158
/// @return array
18862159
///
@@ -1890,7 +2163,8 @@ open class Databases: Service {
18902163
key: String,
18912164
type: AppwriteEnums.IndexType,
18922165
attributes: [String],
1893-
orders: [String]? = nil
2166+
orders: [String]? = nil,
2167+
lengths: [Int]? = nil
18942168
) async throws -> AppwriteModels.Index {
18952169
let apiPath: String = "/databases/{databaseId}/collections/{collectionId}/indexes"
18962170
.replacingOccurrences(of: "{databaseId}", with: databaseId)
@@ -1900,7 +2174,8 @@ open class Databases: Service {
19002174
"key": key,
19012175
"type": type,
19022176
"attributes": attributes,
1903-
"orders": orders
2177+
"orders": orders,
2178+
"lengths": lengths
19042179
]
19052180

19062181
let apiHeaders: [String: String] = [

0 commit comments

Comments
 (0)