From 465d11d6c6d92487862af13c2d3488935156a93a Mon Sep 17 00:00:00 2001 From: root Date: Fri, 28 Nov 2025 19:06:49 +0000 Subject: [PATCH 1/3] feat: add method to service --- CHANGELOG.md | 4 + README.md | 2 +- Sources/Appwrite/Client.swift | 3 +- Sources/Appwrite/Services/Avatars.swift | 94 ++++ Sources/Appwrite/Services/Functions.swift | 13 +- Sources/Appwrite/Services/Sites.swift | 15 +- Sources/Appwrite/Services/Storage.swift | 14 +- .../{TablesDb.swift => TablesDB.swift} | 0 Sources/AppwriteEnums/BuildRuntime.swift | 2 + Sources/AppwriteEnums/Output.swift | 15 + Sources/AppwriteEnums/Runtime.swift | 2 + .../AppwriteEnums/TemplateReferenceType.swift | 11 + Sources/AppwriteEnums/Theme.swift | 10 + Sources/AppwriteEnums/Timezone.swift | 427 ++++++++++++++++++ ...ymentType.swift => VCSReferenceType.swift} | 2 +- Sources/AppwriteModels/Bucket.swift | 16 +- docs/examples/avatars/get-screenshot.md | 33 ++ .../functions/create-template-deployment.md | 4 +- .../sites/create-template-deployment.md | 4 +- docs/examples/storage/create-bucket.md | 3 +- docs/examples/storage/update-bucket.md | 3 +- 21 files changed, 652 insertions(+), 25 deletions(-) rename Sources/Appwrite/Services/{TablesDb.swift => TablesDB.swift} (100%) create mode 100644 Sources/AppwriteEnums/Output.swift create mode 100644 Sources/AppwriteEnums/TemplateReferenceType.swift create mode 100644 Sources/AppwriteEnums/Theme.swift create mode 100644 Sources/AppwriteEnums/Timezone.swift rename Sources/AppwriteEnums/{VCSDeploymentType.swift => VCSReferenceType.swift} (71%) create mode 100644 docs/examples/avatars/get-screenshot.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 33ec214..09ff062 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 13.4.0 + +* Add `getScreenshot` method to `Avatars` service + ## 13.3.0 * Add `total` parameter to list queries allowing skipping counting rows in a table for improved performance diff --git a/README.md b/README.md index 61bbff6..738e613 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ Add the package to your `Package.swift` dependencies: ```swift dependencies: [ - .package(url: "git@github.com:appwrite/sdk-for-swift.git", from: "13.3.0"), + .package(url: "git@github.com:appwrite/sdk-for-swift.git", from: "13.4.0"), ], ``` diff --git a/Sources/Appwrite/Client.swift b/Sources/Appwrite/Client.swift index 383708d..d2b9e11 100644 --- a/Sources/Appwrite/Client.swift +++ b/Sources/Appwrite/Client.swift @@ -5,6 +5,7 @@ import NIOSSL import Foundation import AsyncHTTPClient @_exported import AppwriteModels +@_exported import JSONCodable let DASHDASH = "--" let CRLF = "\r\n" @@ -21,7 +22,7 @@ open class Client { "x-sdk-name": "Swift", "x-sdk-platform": "server", "x-sdk-language": "swift", - "x-sdk-version": "13.3.0", + "x-sdk-version": "13.4.0", "x-appwrite-response-format": "1.8.0" ] diff --git a/Sources/Appwrite/Services/Avatars.swift b/Sources/Appwrite/Services/Avatars.swift index 24f4b07..0b0c381 100644 --- a/Sources/Appwrite/Services/Avatars.swift +++ b/Sources/Appwrite/Services/Avatars.swift @@ -311,5 +311,99 @@ open class Avatars: Service { ) } + /// + /// Use this endpoint to capture a screenshot of any website URL. This endpoint + /// uses a headless browser to render the webpage and capture it as an image. + /// + /// You can configure the browser viewport size, theme, user agent, + /// geolocation, permissions, and more. Capture either just the viewport or the + /// full page scroll. + /// + /// When width and height are specified, the image is resized accordingly. If + /// both dimensions are 0, the API provides an image at original size. If + /// dimensions are not specified, the default viewport size is 1280x720px. + /// + /// - Parameters: + /// - url: String + /// - headers: Any (optional) + /// - viewportWidth: Int (optional) + /// - viewportHeight: Int (optional) + /// - scale: Double (optional) + /// - theme: AppwriteEnums.Theme (optional) + /// - userAgent: String (optional) + /// - fullpage: Bool (optional) + /// - locale: String (optional) + /// - timezone: AppwriteEnums.Timezone (optional) + /// - latitude: Double (optional) + /// - longitude: Double (optional) + /// - accuracy: Double (optional) + /// - touch: Bool (optional) + /// - permissions: [String] (optional) + /// - sleep: Int (optional) + /// - width: Int (optional) + /// - height: Int (optional) + /// - quality: Int (optional) + /// - output: AppwriteEnums.Output (optional) + /// - Throws: Exception if the request fails + /// - Returns: ByteBuffer + /// + open func getScreenshot( + url: String, + headers: Any? = nil, + viewportWidth: Int? = nil, + viewportHeight: Int? = nil, + scale: Double? = nil, + theme: AppwriteEnums.Theme? = nil, + userAgent: String? = nil, + fullpage: Bool? = nil, + locale: String? = nil, + timezone: AppwriteEnums.Timezone? = nil, + latitude: Double? = nil, + longitude: Double? = nil, + accuracy: Double? = nil, + touch: Bool? = nil, + permissions: [String]? = nil, + sleep: Int? = nil, + width: Int? = nil, + height: Int? = nil, + quality: Int? = nil, + output: AppwriteEnums.Output? = nil + ) async throws -> ByteBuffer { + let apiPath: String = "/avatars/screenshots" + + let apiParams: [String: Any?] = [ + "url": url, + "headers": headers, + "viewportWidth": viewportWidth, + "viewportHeight": viewportHeight, + "scale": scale, + "theme": theme, + "userAgent": userAgent, + "fullpage": fullpage, + "locale": locale, + "timezone": timezone, + "latitude": latitude, + "longitude": longitude, + "accuracy": accuracy, + "touch": touch, + "permissions": permissions, + "sleep": sleep, + "width": width, + "height": height, + "quality": quality, + "output": output, + "project": client.config["project"], + "session": client.config["session"] + ] + + let apiHeaders: [String: String] = [:] + + return try await client.call( + method: "GET", + path: apiPath, + params: apiParams + ) + } + } \ No newline at end of file diff --git a/Sources/Appwrite/Services/Functions.swift b/Sources/Appwrite/Services/Functions.swift index 5174edd..d8a6856 100644 --- a/Sources/Appwrite/Services/Functions.swift +++ b/Sources/Appwrite/Services/Functions.swift @@ -528,7 +528,8 @@ open class Functions: Service { /// - repository: String /// - owner: String /// - rootDirectory: String - /// - version: String + /// - type: AppwriteEnums.TemplateReferenceType + /// - reference: String /// - activate: Bool (optional) /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Deployment @@ -538,7 +539,8 @@ open class Functions: Service { repository: String, owner: String, rootDirectory: String, - version: String, + type: AppwriteEnums.TemplateReferenceType, + reference: String, activate: Bool? = nil ) async throws -> AppwriteModels.Deployment { let apiPath: String = "/functions/{functionId}/deployments/template" @@ -548,7 +550,8 @@ open class Functions: Service { "repository": repository, "owner": owner, "rootDirectory": rootDirectory, - "version": version, + "type": type, + "reference": reference, "activate": activate ] @@ -576,7 +579,7 @@ open class Functions: Service { /// /// - Parameters: /// - functionId: String - /// - type: AppwriteEnums.VCSDeploymentType + /// - type: AppwriteEnums.VCSReferenceType /// - reference: String /// - activate: Bool (optional) /// - Throws: Exception if the request fails @@ -584,7 +587,7 @@ open class Functions: Service { /// open func createVcsDeployment( functionId: String, - type: AppwriteEnums.VCSDeploymentType, + type: AppwriteEnums.VCSReferenceType, reference: String, activate: Bool? = nil ) async throws -> AppwriteModels.Deployment { diff --git a/Sources/Appwrite/Services/Sites.swift b/Sources/Appwrite/Services/Sites.swift index 328570e..4b1fee8 100644 --- a/Sources/Appwrite/Services/Sites.swift +++ b/Sources/Appwrite/Services/Sites.swift @@ -413,7 +413,7 @@ open class Sites: Service { /// /// Create a new site code deployment. Use this endpoint to upload a new /// version of your site code. To activate your newly uploaded code, you'll - /// need to update the function's deployment to use your new deployment ID. + /// need to update the site's deployment to use your new deployment ID. /// /// - Parameters: /// - siteId: String @@ -519,7 +519,8 @@ open class Sites: Service { /// - repository: String /// - owner: String /// - rootDirectory: String - /// - version: String + /// - type: AppwriteEnums.TemplateReferenceType + /// - reference: String /// - activate: Bool (optional) /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Deployment @@ -529,7 +530,8 @@ open class Sites: Service { repository: String, owner: String, rootDirectory: String, - version: String, + type: AppwriteEnums.TemplateReferenceType, + reference: String, activate: Bool? = nil ) async throws -> AppwriteModels.Deployment { let apiPath: String = "/sites/{siteId}/deployments/template" @@ -539,7 +541,8 @@ open class Sites: Service { "repository": repository, "owner": owner, "rootDirectory": rootDirectory, - "version": version, + "type": type, + "reference": reference, "activate": activate ] @@ -567,7 +570,7 @@ open class Sites: Service { /// /// - Parameters: /// - siteId: String - /// - type: AppwriteEnums.VCSDeploymentType + /// - type: AppwriteEnums.VCSReferenceType /// - reference: String /// - activate: Bool (optional) /// - Throws: Exception if the request fails @@ -575,7 +578,7 @@ open class Sites: Service { /// open func createVcsDeployment( siteId: String, - type: AppwriteEnums.VCSDeploymentType, + type: AppwriteEnums.VCSReferenceType, reference: String, activate: Bool? = nil ) async throws -> AppwriteModels.Deployment { diff --git a/Sources/Appwrite/Services/Storage.swift b/Sources/Appwrite/Services/Storage.swift index e40487f..f45e37d 100644 --- a/Sources/Appwrite/Services/Storage.swift +++ b/Sources/Appwrite/Services/Storage.swift @@ -61,6 +61,7 @@ open class Storage: Service { /// - compression: AppwriteEnums.Compression (optional) /// - encryption: Bool (optional) /// - antivirus: Bool (optional) + /// - transformations: Bool (optional) /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Bucket /// @@ -74,7 +75,8 @@ open class Storage: Service { allowedFileExtensions: [String]? = nil, compression: AppwriteEnums.Compression? = nil, encryption: Bool? = nil, - antivirus: Bool? = nil + antivirus: Bool? = nil, + transformations: Bool? = nil ) async throws -> AppwriteModels.Bucket { let apiPath: String = "/storage/buckets" @@ -88,7 +90,8 @@ open class Storage: Service { "allowedFileExtensions": allowedFileExtensions, "compression": compression, "encryption": encryption, - "antivirus": antivirus + "antivirus": antivirus, + "transformations": transformations ] let apiHeaders: [String: String] = [ @@ -154,6 +157,7 @@ open class Storage: Service { /// - compression: AppwriteEnums.Compression (optional) /// - encryption: Bool (optional) /// - antivirus: Bool (optional) + /// - transformations: Bool (optional) /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Bucket /// @@ -167,7 +171,8 @@ open class Storage: Service { allowedFileExtensions: [String]? = nil, compression: AppwriteEnums.Compression? = nil, encryption: Bool? = nil, - antivirus: Bool? = nil + antivirus: Bool? = nil, + transformations: Bool? = nil ) async throws -> AppwriteModels.Bucket { let apiPath: String = "/storage/buckets/{bucketId}" .replacingOccurrences(of: "{bucketId}", with: bucketId) @@ -181,7 +186,8 @@ open class Storage: Service { "allowedFileExtensions": allowedFileExtensions, "compression": compression, "encryption": encryption, - "antivirus": antivirus + "antivirus": antivirus, + "transformations": transformations ] let apiHeaders: [String: String] = [ diff --git a/Sources/Appwrite/Services/TablesDb.swift b/Sources/Appwrite/Services/TablesDB.swift similarity index 100% rename from Sources/Appwrite/Services/TablesDb.swift rename to Sources/Appwrite/Services/TablesDB.swift diff --git a/Sources/AppwriteEnums/BuildRuntime.swift b/Sources/AppwriteEnums/BuildRuntime.swift index dc9b179..11a2c03 100644 --- a/Sources/AppwriteEnums/BuildRuntime.swift +++ b/Sources/AppwriteEnums/BuildRuntime.swift @@ -39,6 +39,7 @@ public enum BuildRuntime: String, CustomStringConvertible { case dart33 = "dart-3.3" case dart35 = "dart-3.5" case dart38 = "dart-3.8" + case dart39 = "dart-3.9" case dotnet60 = "dotnet-6.0" case dotnet70 = "dotnet-7.0" case dotnet80 = "dotnet-8.0" @@ -66,6 +67,7 @@ public enum BuildRuntime: String, CustomStringConvertible { case flutter327 = "flutter-3.27" case flutter329 = "flutter-3.29" case flutter332 = "flutter-3.32" + case flutter335 = "flutter-3.35" public var description: String { return rawValue diff --git a/Sources/AppwriteEnums/Output.swift b/Sources/AppwriteEnums/Output.swift new file mode 100644 index 0000000..c8d245f --- /dev/null +++ b/Sources/AppwriteEnums/Output.swift @@ -0,0 +1,15 @@ +import Foundation + +public enum Output: String, CustomStringConvertible { + case jpg = "jpg" + case jpeg = "jpeg" + case png = "png" + case webp = "webp" + case heic = "heic" + case avif = "avif" + case gif = "gif" + + public var description: String { + return rawValue + } +} diff --git a/Sources/AppwriteEnums/Runtime.swift b/Sources/AppwriteEnums/Runtime.swift index a461f31..d1d5abf 100644 --- a/Sources/AppwriteEnums/Runtime.swift +++ b/Sources/AppwriteEnums/Runtime.swift @@ -39,6 +39,7 @@ public enum Runtime: String, CustomStringConvertible { case dart33 = "dart-3.3" case dart35 = "dart-3.5" case dart38 = "dart-3.8" + case dart39 = "dart-3.9" case dotnet60 = "dotnet-6.0" case dotnet70 = "dotnet-7.0" case dotnet80 = "dotnet-8.0" @@ -66,6 +67,7 @@ public enum Runtime: String, CustomStringConvertible { case flutter327 = "flutter-3.27" case flutter329 = "flutter-3.29" case flutter332 = "flutter-3.32" + case flutter335 = "flutter-3.35" public var description: String { return rawValue diff --git a/Sources/AppwriteEnums/TemplateReferenceType.swift b/Sources/AppwriteEnums/TemplateReferenceType.swift new file mode 100644 index 0000000..3509c83 --- /dev/null +++ b/Sources/AppwriteEnums/TemplateReferenceType.swift @@ -0,0 +1,11 @@ +import Foundation + +public enum TemplateReferenceType: String, CustomStringConvertible { + case branch = "branch" + case commit = "commit" + case tag = "tag" + + public var description: String { + return rawValue + } +} diff --git a/Sources/AppwriteEnums/Theme.swift b/Sources/AppwriteEnums/Theme.swift new file mode 100644 index 0000000..4b42ad8 --- /dev/null +++ b/Sources/AppwriteEnums/Theme.swift @@ -0,0 +1,10 @@ +import Foundation + +public enum Theme: String, CustomStringConvertible { + case light = "light" + case dark = "dark" + + public var description: String { + return rawValue + } +} diff --git a/Sources/AppwriteEnums/Timezone.swift b/Sources/AppwriteEnums/Timezone.swift new file mode 100644 index 0000000..05d0367 --- /dev/null +++ b/Sources/AppwriteEnums/Timezone.swift @@ -0,0 +1,427 @@ +import Foundation + +public enum Timezone: String, CustomStringConvertible { + case africaAbidjan = "africa/abidjan" + case africaAccra = "africa/accra" + case africaAddisAbaba = "africa/addis_ababa" + case africaAlgiers = "africa/algiers" + case africaAsmara = "africa/asmara" + case africaBamako = "africa/bamako" + case africaBangui = "africa/bangui" + case africaBanjul = "africa/banjul" + case africaBissau = "africa/bissau" + case africaBlantyre = "africa/blantyre" + case africaBrazzaville = "africa/brazzaville" + case africaBujumbura = "africa/bujumbura" + case africaCairo = "africa/cairo" + case africaCasablanca = "africa/casablanca" + case africaCeuta = "africa/ceuta" + case africaConakry = "africa/conakry" + case africaDakar = "africa/dakar" + case africaDarEsSalaam = "africa/dar_es_salaam" + case africaDjibouti = "africa/djibouti" + case africaDouala = "africa/douala" + case africaElAaiun = "africa/el_aaiun" + case africaFreetown = "africa/freetown" + case africaGaborone = "africa/gaborone" + case africaHarare = "africa/harare" + case africaJohannesburg = "africa/johannesburg" + case africaJuba = "africa/juba" + case africaKampala = "africa/kampala" + case africaKhartoum = "africa/khartoum" + case africaKigali = "africa/kigali" + case africaKinshasa = "africa/kinshasa" + case africaLagos = "africa/lagos" + case africaLibreville = "africa/libreville" + case africaLome = "africa/lome" + case africaLuanda = "africa/luanda" + case africaLubumbashi = "africa/lubumbashi" + case africaLusaka = "africa/lusaka" + case africaMalabo = "africa/malabo" + case africaMaputo = "africa/maputo" + case africaMaseru = "africa/maseru" + case africaMbabane = "africa/mbabane" + case africaMogadishu = "africa/mogadishu" + case africaMonrovia = "africa/monrovia" + case africaNairobi = "africa/nairobi" + case africaNdjamena = "africa/ndjamena" + case africaNiamey = "africa/niamey" + case africaNouakchott = "africa/nouakchott" + case africaOuagadougou = "africa/ouagadougou" + case africaPortoNovo = "africa/porto-novo" + case africaSaoTome = "africa/sao_tome" + case africaTripoli = "africa/tripoli" + case africaTunis = "africa/tunis" + case africaWindhoek = "africa/windhoek" + case americaAdak = "america/adak" + case americaAnchorage = "america/anchorage" + case americaAnguilla = "america/anguilla" + case americaAntigua = "america/antigua" + case americaAraguaina = "america/araguaina" + case americaArgentinaBuenosAires = "america/argentina/buenos_aires" + case americaArgentinaCatamarca = "america/argentina/catamarca" + case americaArgentinaCordoba = "america/argentina/cordoba" + case americaArgentinaJujuy = "america/argentina/jujuy" + case americaArgentinaLaRioja = "america/argentina/la_rioja" + case americaArgentinaMendoza = "america/argentina/mendoza" + case americaArgentinaRioGallegos = "america/argentina/rio_gallegos" + case americaArgentinaSalta = "america/argentina/salta" + case americaArgentinaSanJuan = "america/argentina/san_juan" + case americaArgentinaSanLuis = "america/argentina/san_luis" + case americaArgentinaTucuman = "america/argentina/tucuman" + case americaArgentinaUshuaia = "america/argentina/ushuaia" + case americaAruba = "america/aruba" + case americaAsuncion = "america/asuncion" + case americaAtikokan = "america/atikokan" + case americaBahia = "america/bahia" + case americaBahiaBanderas = "america/bahia_banderas" + case americaBarbados = "america/barbados" + case americaBelem = "america/belem" + case americaBelize = "america/belize" + case americaBlancSablon = "america/blanc-sablon" + case americaBoaVista = "america/boa_vista" + case americaBogota = "america/bogota" + case americaBoise = "america/boise" + case americaCambridgeBay = "america/cambridge_bay" + case americaCampoGrande = "america/campo_grande" + case americaCancun = "america/cancun" + case americaCaracas = "america/caracas" + case americaCayenne = "america/cayenne" + case americaCayman = "america/cayman" + case americaChicago = "america/chicago" + case americaChihuahua = "america/chihuahua" + case americaCiudadJuarez = "america/ciudad_juarez" + case americaCostaRica = "america/costa_rica" + case americaCoyhaique = "america/coyhaique" + case americaCreston = "america/creston" + case americaCuiaba = "america/cuiaba" + case americaCuracao = "america/curacao" + case americaDanmarkshavn = "america/danmarkshavn" + case americaDawson = "america/dawson" + case americaDawsonCreek = "america/dawson_creek" + case americaDenver = "america/denver" + case americaDetroit = "america/detroit" + case americaDominica = "america/dominica" + case americaEdmonton = "america/edmonton" + case americaEirunepe = "america/eirunepe" + case americaElSalvador = "america/el_salvador" + case americaFortNelson = "america/fort_nelson" + case americaFortaleza = "america/fortaleza" + case americaGlaceBay = "america/glace_bay" + case americaGooseBay = "america/goose_bay" + case americaGrandTurk = "america/grand_turk" + case americaGrenada = "america/grenada" + case americaGuadeloupe = "america/guadeloupe" + case americaGuatemala = "america/guatemala" + case americaGuayaquil = "america/guayaquil" + case americaGuyana = "america/guyana" + case americaHalifax = "america/halifax" + case americaHavana = "america/havana" + case americaHermosillo = "america/hermosillo" + case americaIndianaIndianapolis = "america/indiana/indianapolis" + case americaIndianaKnox = "america/indiana/knox" + case americaIndianaMarengo = "america/indiana/marengo" + case americaIndianaPetersburg = "america/indiana/petersburg" + case americaIndianaTellCity = "america/indiana/tell_city" + case americaIndianaVevay = "america/indiana/vevay" + case americaIndianaVincennes = "america/indiana/vincennes" + case americaIndianaWinamac = "america/indiana/winamac" + case americaInuvik = "america/inuvik" + case americaIqaluit = "america/iqaluit" + case americaJamaica = "america/jamaica" + case americaJuneau = "america/juneau" + case americaKentuckyLouisville = "america/kentucky/louisville" + case americaKentuckyMonticello = "america/kentucky/monticello" + case americaKralendijk = "america/kralendijk" + case americaLaPaz = "america/la_paz" + case americaLima = "america/lima" + case americaLosAngeles = "america/los_angeles" + case americaLowerPrinces = "america/lower_princes" + case americaMaceio = "america/maceio" + case americaManagua = "america/managua" + case americaManaus = "america/manaus" + case americaMarigot = "america/marigot" + case americaMartinique = "america/martinique" + case americaMatamoros = "america/matamoros" + case americaMazatlan = "america/mazatlan" + case americaMenominee = "america/menominee" + case americaMerida = "america/merida" + case americaMetlakatla = "america/metlakatla" + case americaMexicoCity = "america/mexico_city" + case americaMiquelon = "america/miquelon" + case americaMoncton = "america/moncton" + case americaMonterrey = "america/monterrey" + case americaMontevideo = "america/montevideo" + case americaMontserrat = "america/montserrat" + case americaNassau = "america/nassau" + case americaNewYork = "america/new_york" + case americaNome = "america/nome" + case americaNoronha = "america/noronha" + case americaNorthDakotaBeulah = "america/north_dakota/beulah" + case americaNorthDakotaCenter = "america/north_dakota/center" + case americaNorthDakotaNewSalem = "america/north_dakota/new_salem" + case americaNuuk = "america/nuuk" + case americaOjinaga = "america/ojinaga" + case americaPanama = "america/panama" + case americaParamaribo = "america/paramaribo" + case americaPhoenix = "america/phoenix" + case americaPortAuPrince = "america/port-au-prince" + case americaPortOfSpain = "america/port_of_spain" + case americaPortoVelho = "america/porto_velho" + case americaPuertoRico = "america/puerto_rico" + case americaPuntaArenas = "america/punta_arenas" + case americaRankinInlet = "america/rankin_inlet" + case americaRecife = "america/recife" + case americaRegina = "america/regina" + case americaResolute = "america/resolute" + case americaRioBranco = "america/rio_branco" + case americaSantarem = "america/santarem" + case americaSantiago = "america/santiago" + case americaSantoDomingo = "america/santo_domingo" + case americaSaoPaulo = "america/sao_paulo" + case americaScoresbysund = "america/scoresbysund" + case americaSitka = "america/sitka" + case americaStBarthelemy = "america/st_barthelemy" + case americaStJohns = "america/st_johns" + case americaStKitts = "america/st_kitts" + case americaStLucia = "america/st_lucia" + case americaStThomas = "america/st_thomas" + case americaStVincent = "america/st_vincent" + case americaSwiftCurrent = "america/swift_current" + case americaTegucigalpa = "america/tegucigalpa" + case americaThule = "america/thule" + case americaTijuana = "america/tijuana" + case americaToronto = "america/toronto" + case americaTortola = "america/tortola" + case americaVancouver = "america/vancouver" + case americaWhitehorse = "america/whitehorse" + case americaWinnipeg = "america/winnipeg" + case americaYakutat = "america/yakutat" + case antarcticaCasey = "antarctica/casey" + case antarcticaDavis = "antarctica/davis" + case antarcticaDumontdurville = "antarctica/dumontdurville" + case antarcticaMacquarie = "antarctica/macquarie" + case antarcticaMawson = "antarctica/mawson" + case antarcticaMcmurdo = "antarctica/mcmurdo" + case antarcticaPalmer = "antarctica/palmer" + case antarcticaRothera = "antarctica/rothera" + case antarcticaSyowa = "antarctica/syowa" + case antarcticaTroll = "antarctica/troll" + case antarcticaVostok = "antarctica/vostok" + case arcticLongyearbyen = "arctic/longyearbyen" + case asiaAden = "asia/aden" + case asiaAlmaty = "asia/almaty" + case asiaAmman = "asia/amman" + case asiaAnadyr = "asia/anadyr" + case asiaAqtau = "asia/aqtau" + case asiaAqtobe = "asia/aqtobe" + case asiaAshgabat = "asia/ashgabat" + case asiaAtyrau = "asia/atyrau" + case asiaBaghdad = "asia/baghdad" + case asiaBahrain = "asia/bahrain" + case asiaBaku = "asia/baku" + case asiaBangkok = "asia/bangkok" + case asiaBarnaul = "asia/barnaul" + case asiaBeirut = "asia/beirut" + case asiaBishkek = "asia/bishkek" + case asiaBrunei = "asia/brunei" + case asiaChita = "asia/chita" + case asiaColombo = "asia/colombo" + case asiaDamascus = "asia/damascus" + case asiaDhaka = "asia/dhaka" + case asiaDili = "asia/dili" + case asiaDubai = "asia/dubai" + case asiaDushanbe = "asia/dushanbe" + case asiaFamagusta = "asia/famagusta" + case asiaGaza = "asia/gaza" + case asiaHebron = "asia/hebron" + case asiaHoChiMinh = "asia/ho_chi_minh" + case asiaHongKong = "asia/hong_kong" + case asiaHovd = "asia/hovd" + case asiaIrkutsk = "asia/irkutsk" + case asiaJakarta = "asia/jakarta" + case asiaJayapura = "asia/jayapura" + case asiaJerusalem = "asia/jerusalem" + case asiaKabul = "asia/kabul" + case asiaKamchatka = "asia/kamchatka" + case asiaKarachi = "asia/karachi" + case asiaKathmandu = "asia/kathmandu" + case asiaKhandyga = "asia/khandyga" + case asiaKolkata = "asia/kolkata" + case asiaKrasnoyarsk = "asia/krasnoyarsk" + case asiaKualaLumpur = "asia/kuala_lumpur" + case asiaKuching = "asia/kuching" + case asiaKuwait = "asia/kuwait" + case asiaMacau = "asia/macau" + case asiaMagadan = "asia/magadan" + case asiaMakassar = "asia/makassar" + case asiaManila = "asia/manila" + case asiaMuscat = "asia/muscat" + case asiaNicosia = "asia/nicosia" + case asiaNovokuznetsk = "asia/novokuznetsk" + case asiaNovosibirsk = "asia/novosibirsk" + case asiaOmsk = "asia/omsk" + case asiaOral = "asia/oral" + case asiaPhnomPenh = "asia/phnom_penh" + case asiaPontianak = "asia/pontianak" + case asiaPyongyang = "asia/pyongyang" + case asiaQatar = "asia/qatar" + case asiaQostanay = "asia/qostanay" + case asiaQyzylorda = "asia/qyzylorda" + case asiaRiyadh = "asia/riyadh" + case asiaSakhalin = "asia/sakhalin" + case asiaSamarkand = "asia/samarkand" + case asiaSeoul = "asia/seoul" + case asiaShanghai = "asia/shanghai" + case asiaSingapore = "asia/singapore" + case asiaSrednekolymsk = "asia/srednekolymsk" + case asiaTaipei = "asia/taipei" + case asiaTashkent = "asia/tashkent" + case asiaTbilisi = "asia/tbilisi" + case asiaTehran = "asia/tehran" + case asiaThimphu = "asia/thimphu" + case asiaTokyo = "asia/tokyo" + case asiaTomsk = "asia/tomsk" + case asiaUlaanbaatar = "asia/ulaanbaatar" + case asiaUrumqi = "asia/urumqi" + case asiaUstNera = "asia/ust-nera" + case asiaVientiane = "asia/vientiane" + case asiaVladivostok = "asia/vladivostok" + case asiaYakutsk = "asia/yakutsk" + case asiaYangon = "asia/yangon" + case asiaYekaterinburg = "asia/yekaterinburg" + case asiaYerevan = "asia/yerevan" + case atlanticAzores = "atlantic/azores" + case atlanticBermuda = "atlantic/bermuda" + case atlanticCanary = "atlantic/canary" + case atlanticCapeVerde = "atlantic/cape_verde" + case atlanticFaroe = "atlantic/faroe" + case atlanticMadeira = "atlantic/madeira" + case atlanticReykjavik = "atlantic/reykjavik" + case atlanticSouthGeorgia = "atlantic/south_georgia" + case atlanticStHelena = "atlantic/st_helena" + case atlanticStanley = "atlantic/stanley" + case australiaAdelaide = "australia/adelaide" + case australiaBrisbane = "australia/brisbane" + case australiaBrokenHill = "australia/broken_hill" + case australiaDarwin = "australia/darwin" + case australiaEucla = "australia/eucla" + case australiaHobart = "australia/hobart" + case australiaLindeman = "australia/lindeman" + case australiaLordHowe = "australia/lord_howe" + case australiaMelbourne = "australia/melbourne" + case australiaPerth = "australia/perth" + case australiaSydney = "australia/sydney" + case europeAmsterdam = "europe/amsterdam" + case europeAndorra = "europe/andorra" + case europeAstrakhan = "europe/astrakhan" + case europeAthens = "europe/athens" + case europeBelgrade = "europe/belgrade" + case europeBerlin = "europe/berlin" + case europeBratislava = "europe/bratislava" + case europeBrussels = "europe/brussels" + case europeBucharest = "europe/bucharest" + case europeBudapest = "europe/budapest" + case europeBusingen = "europe/busingen" + case europeChisinau = "europe/chisinau" + case europeCopenhagen = "europe/copenhagen" + case europeDublin = "europe/dublin" + case europeGibraltar = "europe/gibraltar" + case europeGuernsey = "europe/guernsey" + case europeHelsinki = "europe/helsinki" + case europeIsleOfMan = "europe/isle_of_man" + case europeIstanbul = "europe/istanbul" + case europeJersey = "europe/jersey" + case europeKaliningrad = "europe/kaliningrad" + case europeKirov = "europe/kirov" + case europeKyiv = "europe/kyiv" + case europeLisbon = "europe/lisbon" + case europeLjubljana = "europe/ljubljana" + case europeLondon = "europe/london" + case europeLuxembourg = "europe/luxembourg" + case europeMadrid = "europe/madrid" + case europeMalta = "europe/malta" + case europeMariehamn = "europe/mariehamn" + case europeMinsk = "europe/minsk" + case europeMonaco = "europe/monaco" + case europeMoscow = "europe/moscow" + case europeOslo = "europe/oslo" + case europeParis = "europe/paris" + case europePodgorica = "europe/podgorica" + case europePrague = "europe/prague" + case europeRiga = "europe/riga" + case europeRome = "europe/rome" + case europeSamara = "europe/samara" + case europeSanMarino = "europe/san_marino" + case europeSarajevo = "europe/sarajevo" + case europeSaratov = "europe/saratov" + case europeSimferopol = "europe/simferopol" + case europeSkopje = "europe/skopje" + case europeSofia = "europe/sofia" + case europeStockholm = "europe/stockholm" + case europeTallinn = "europe/tallinn" + case europeTirane = "europe/tirane" + case europeUlyanovsk = "europe/ulyanovsk" + case europeVaduz = "europe/vaduz" + case europeVatican = "europe/vatican" + case europeVienna = "europe/vienna" + case europeVilnius = "europe/vilnius" + case europeVolgograd = "europe/volgograd" + case europeWarsaw = "europe/warsaw" + case europeZagreb = "europe/zagreb" + case europeZurich = "europe/zurich" + case indianAntananarivo = "indian/antananarivo" + case indianChagos = "indian/chagos" + case indianChristmas = "indian/christmas" + case indianCocos = "indian/cocos" + case indianComoro = "indian/comoro" + case indianKerguelen = "indian/kerguelen" + case indianMahe = "indian/mahe" + case indianMaldives = "indian/maldives" + case indianMauritius = "indian/mauritius" + case indianMayotte = "indian/mayotte" + case indianReunion = "indian/reunion" + case pacificApia = "pacific/apia" + case pacificAuckland = "pacific/auckland" + case pacificBougainville = "pacific/bougainville" + case pacificChatham = "pacific/chatham" + case pacificChuuk = "pacific/chuuk" + case pacificEaster = "pacific/easter" + case pacificEfate = "pacific/efate" + case pacificFakaofo = "pacific/fakaofo" + case pacificFiji = "pacific/fiji" + case pacificFunafuti = "pacific/funafuti" + case pacificGalapagos = "pacific/galapagos" + case pacificGambier = "pacific/gambier" + case pacificGuadalcanal = "pacific/guadalcanal" + case pacificGuam = "pacific/guam" + case pacificHonolulu = "pacific/honolulu" + case pacificKanton = "pacific/kanton" + case pacificKiritimati = "pacific/kiritimati" + case pacificKosrae = "pacific/kosrae" + case pacificKwajalein = "pacific/kwajalein" + case pacificMajuro = "pacific/majuro" + case pacificMarquesas = "pacific/marquesas" + case pacificMidway = "pacific/midway" + case pacificNauru = "pacific/nauru" + case pacificNiue = "pacific/niue" + case pacificNorfolk = "pacific/norfolk" + case pacificNoumea = "pacific/noumea" + case pacificPagoPago = "pacific/pago_pago" + case pacificPalau = "pacific/palau" + case pacificPitcairn = "pacific/pitcairn" + case pacificPohnpei = "pacific/pohnpei" + case pacificPortMoresby = "pacific/port_moresby" + case pacificRarotonga = "pacific/rarotonga" + case pacificSaipan = "pacific/saipan" + case pacificTahiti = "pacific/tahiti" + case pacificTarawa = "pacific/tarawa" + case pacificTongatapu = "pacific/tongatapu" + case pacificWake = "pacific/wake" + case pacificWallis = "pacific/wallis" + case utc = "utc" + + public var description: String { + return rawValue + } +} diff --git a/Sources/AppwriteEnums/VCSDeploymentType.swift b/Sources/AppwriteEnums/VCSReferenceType.swift similarity index 71% rename from Sources/AppwriteEnums/VCSDeploymentType.swift rename to Sources/AppwriteEnums/VCSReferenceType.swift index 3d40494..d337233 100644 --- a/Sources/AppwriteEnums/VCSDeploymentType.swift +++ b/Sources/AppwriteEnums/VCSReferenceType.swift @@ -1,6 +1,6 @@ import Foundation -public enum VCSDeploymentType: String, CustomStringConvertible { +public enum VCSReferenceType: String, CustomStringConvertible { case branch = "branch" case commit = "commit" case tag = "tag" diff --git a/Sources/AppwriteModels/Bucket.swift b/Sources/AppwriteModels/Bucket.swift index be437f5..326635b 100644 --- a/Sources/AppwriteModels/Bucket.swift +++ b/Sources/AppwriteModels/Bucket.swift @@ -17,6 +17,7 @@ open class Bucket: Codable { case compression = "compression" case encryption = "encryption" case antivirus = "antivirus" + case transformations = "transformations" } /// Bucket ID. @@ -55,6 +56,9 @@ open class Bucket: Codable { /// Virus scanning is enabled. public let antivirus: Bool + /// Image transformations are enabled. + public let transformations: Bool + init( id: String, @@ -68,7 +72,8 @@ open class Bucket: Codable { allowedFileExtensions: [String], compression: String, encryption: Bool, - antivirus: Bool + antivirus: Bool, + transformations: Bool ) { self.id = id self.createdAt = createdAt @@ -82,6 +87,7 @@ open class Bucket: Codable { self.compression = compression self.encryption = encryption self.antivirus = antivirus + self.transformations = transformations } public required init(from decoder: Decoder) throws { @@ -99,6 +105,7 @@ open class Bucket: Codable { self.compression = try container.decode(String.self, forKey: .compression) self.encryption = try container.decode(Bool.self, forKey: .encryption) self.antivirus = try container.decode(Bool.self, forKey: .antivirus) + self.transformations = try container.decode(Bool.self, forKey: .transformations) } public func encode(to encoder: Encoder) throws { @@ -116,6 +123,7 @@ open class Bucket: Codable { try container.encode(compression, forKey: .compression) try container.encode(encryption, forKey: .encryption) try container.encode(antivirus, forKey: .antivirus) + try container.encode(transformations, forKey: .transformations) } public func toMap() -> [String: Any] { @@ -131,7 +139,8 @@ open class Bucket: Codable { "allowedFileExtensions": allowedFileExtensions as Any, "compression": compression as Any, "encryption": encryption as Any, - "antivirus": antivirus as Any + "antivirus": antivirus as Any, + "transformations": transformations as Any ] } @@ -148,7 +157,8 @@ open class Bucket: Codable { allowedFileExtensions: map["allowedFileExtensions"] as! [String], compression: map["compression"] as! String, encryption: map["encryption"] as! Bool, - antivirus: map["antivirus"] as! Bool + antivirus: map["antivirus"] as! Bool, + transformations: map["transformations"] as! Bool ) } } diff --git a/docs/examples/avatars/get-screenshot.md b/docs/examples/avatars/get-screenshot.md new file mode 100644 index 0000000..3aa1661 --- /dev/null +++ b/docs/examples/avatars/get-screenshot.md @@ -0,0 +1,33 @@ +import Appwrite +import AppwriteEnums + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setSession("") // The user session to authenticate with + +let avatars = Avatars(client) + +let bytes = try await avatars.getScreenshot( + url: "https://example.com", + headers: [:], // optional + viewportWidth: 1, // optional + viewportHeight: 1, // optional + scale: 0.1, // optional + theme: .light, // optional + userAgent: "", // optional + fullpage: false, // optional + locale: "", // optional + timezone: .africaAbidjan, // optional + latitude: -90, // optional + longitude: -180, // optional + accuracy: 0, // optional + touch: false, // optional + permissions: [], // optional + sleep: 0, // optional + width: 0, // optional + height: 0, // optional + quality: -1, // optional + output: .jpg // optional +) + diff --git a/docs/examples/functions/create-template-deployment.md b/docs/examples/functions/create-template-deployment.md index 27c5311..6a90456 100644 --- a/docs/examples/functions/create-template-deployment.md +++ b/docs/examples/functions/create-template-deployment.md @@ -1,4 +1,5 @@ import Appwrite +import AppwriteEnums let client = Client() .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -12,7 +13,8 @@ let deployment = try await functions.createTemplateDeployment( repository: "", owner: "", rootDirectory: "", - version: "", + type: .commit, + reference: "", activate: false // optional ) diff --git a/docs/examples/sites/create-template-deployment.md b/docs/examples/sites/create-template-deployment.md index 1cb3e42..250eb12 100644 --- a/docs/examples/sites/create-template-deployment.md +++ b/docs/examples/sites/create-template-deployment.md @@ -1,4 +1,5 @@ import Appwrite +import AppwriteEnums let client = Client() .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -12,7 +13,8 @@ let deployment = try await sites.createTemplateDeployment( repository: "", owner: "", rootDirectory: "", - version: "", + type: .branch, + reference: "", activate: false // optional ) diff --git a/docs/examples/storage/create-bucket.md b/docs/examples/storage/create-bucket.md index a97f450..9931b81 100644 --- a/docs/examples/storage/create-bucket.md +++ b/docs/examples/storage/create-bucket.md @@ -18,6 +18,7 @@ let bucket = try await storage.createBucket( allowedFileExtensions: [], // optional compression: .none, // optional encryption: false, // optional - antivirus: false // optional + antivirus: false, // optional + transformations: false // optional ) diff --git a/docs/examples/storage/update-bucket.md b/docs/examples/storage/update-bucket.md index 2d89d7c..be283b7 100644 --- a/docs/examples/storage/update-bucket.md +++ b/docs/examples/storage/update-bucket.md @@ -18,6 +18,7 @@ let bucket = try await storage.updateBucket( allowedFileExtensions: [], // optional compression: .none, // optional encryption: false, // optional - antivirus: false // optional + antivirus: false, // optional + transformations: false // optional ) From 0673d1e95132c6c4cacdb841db9ea3c681ce6519 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 28 Nov 2025 19:31:16 +0000 Subject: [PATCH 2/3] fix changelog --- CHANGELOG.md | 5 ++++- README.md | 2 +- Sources/Appwrite/Client.swift | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 09ff062..22ae471 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,11 @@ # Change Log -## 13.4.0 +## 14.0.0 +* Rename `VCSDeploymentType` enum to `VCSReferenceType` +* Change `createTemplateDeployment` method signature: replace `version` parameter with `type` (TemplateReferenceType) and `reference` parameters * Add `getScreenshot` method to `Avatars` service +* Add `Theme`, `Timezone` and `Output` enums ## 13.3.0 diff --git a/README.md b/README.md index 738e613..0496367 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ Add the package to your `Package.swift` dependencies: ```swift dependencies: [ - .package(url: "git@github.com:appwrite/sdk-for-swift.git", from: "13.4.0"), + .package(url: "git@github.com:appwrite/sdk-for-swift.git", from: "14.0.0"), ], ``` diff --git a/Sources/Appwrite/Client.swift b/Sources/Appwrite/Client.swift index d2b9e11..06327f2 100644 --- a/Sources/Appwrite/Client.swift +++ b/Sources/Appwrite/Client.swift @@ -22,7 +22,7 @@ open class Client { "x-sdk-name": "Swift", "x-sdk-platform": "server", "x-sdk-language": "swift", - "x-sdk-version": "13.4.0", + "x-sdk-version": "14.0.0", "x-appwrite-response-format": "1.8.0" ] From c5ed447c1af0bd63b02f935b7a486e4e9c6aef04 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 1 Dec 2025 13:56:33 +0000 Subject: [PATCH 3/3] update examples --- Sources/Appwrite/Services/Account.swift | 8 +++--- docs/examples/avatars/get-screenshot.md | 35 ++++++++++++++----------- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/Sources/Appwrite/Services/Account.swift b/Sources/Appwrite/Services/Account.swift index 8a46e2d..6f69edf 100644 --- a/Sources/Appwrite/Services/Account.swift +++ b/Sources/Appwrite/Services/Account.swift @@ -654,7 +654,7 @@ open class Account: Service { open func createMfaChallenge( factor: AppwriteEnums.AuthenticationFactor ) async throws -> AppwriteModels.MfaChallenge { - let apiPath: String = "/account/mfa/challenge" + let apiPath: String = "/account/mfa/challenges" let apiParams: [String: Any?] = [ "factor": factor @@ -690,7 +690,7 @@ open class Account: Service { open func createMFAChallenge( factor: AppwriteEnums.AuthenticationFactor ) async throws -> AppwriteModels.MfaChallenge { - let apiPath: String = "/account/mfa/challenge" + let apiPath: String = "/account/mfa/challenges" let apiParams: [String: Any?] = [ "factor": factor @@ -731,7 +731,7 @@ open class Account: Service { challengeId: String, otp: String ) async throws -> AppwriteModels.Session { - let apiPath: String = "/account/mfa/challenge" + let apiPath: String = "/account/mfa/challenges" let apiParams: [String: Any?] = [ "challengeId": challengeId, @@ -772,7 +772,7 @@ open class Account: Service { challengeId: String, otp: String ) async throws -> AppwriteModels.Session { - let apiPath: String = "/account/mfa/challenge" + let apiPath: String = "/account/mfa/challenges" let apiParams: [String: Any?] = [ "challengeId": challengeId, diff --git a/docs/examples/avatars/get-screenshot.md b/docs/examples/avatars/get-screenshot.md index 3aa1661..91e08d9 100644 --- a/docs/examples/avatars/get-screenshot.md +++ b/docs/examples/avatars/get-screenshot.md @@ -10,24 +10,27 @@ let avatars = Avatars(client) let bytes = try await avatars.getScreenshot( url: "https://example.com", - headers: [:], // optional - viewportWidth: 1, // optional - viewportHeight: 1, // optional - scale: 0.1, // optional + headers: [ + "Authorization": "Bearer token123", + "X-Custom-Header": "value" + ], // optional + viewportWidth: 1920, // optional + viewportHeight: 1080, // optional + scale: 2, // optional theme: .light, // optional - userAgent: "", // optional - fullpage: false, // optional - locale: "", // optional + userAgent: "Mozilla/5.0 (iPhone; CPU iPhone OS 14_0 like Mac OS X) AppleWebKit/605.1.15", // optional + fullpage: true, // optional + locale: "en-US", // optional timezone: .africaAbidjan, // optional - latitude: -90, // optional - longitude: -180, // optional - accuracy: 0, // optional - touch: false, // optional - permissions: [], // optional - sleep: 0, // optional - width: 0, // optional - height: 0, // optional - quality: -1, // optional + latitude: 37.7749, // optional + longitude: -122.4194, // optional + accuracy: 100, // optional + touch: true, // optional + permissions: ["geolocation","notifications"], // optional + sleep: 3, // optional + width: 800, // optional + height: 600, // optional + quality: 85, // optional output: .jpg // optional )