From 964aa9d8e174f343b8c420a92ad0277e844b0f2d Mon Sep 17 00:00:00 2001 From: root Date: Fri, 28 Nov 2025 19:03:58 +0000 Subject: [PATCH 1/3] feat: add method to service --- .gitpod.yml | 10 - CHANGELOG.md | 4 + docs/examples/avatars/get-screenshot.md | 32 ++ package.json | 4 +- src/client.ts | 2 +- src/enums/output.ts | 9 + src/enums/theme.ts | 4 + src/enums/timezone.ts | 421 ++++++++++++++++++++++++ src/index.ts | 3 + src/services/avatars.ts | 347 +++++++++++++++++++ 10 files changed, 823 insertions(+), 13 deletions(-) delete mode 100644 .gitpod.yml create mode 100644 docs/examples/avatars/get-screenshot.md create mode 100644 src/enums/output.ts create mode 100644 src/enums/theme.ts create mode 100644 src/enums/timezone.ts diff --git a/.gitpod.yml b/.gitpod.yml deleted file mode 100644 index 74e3b8d6..00000000 --- a/.gitpod.yml +++ /dev/null @@ -1,10 +0,0 @@ -# This configuration file was automatically generated by Gitpod. -# Please adjust to your needs (see https://www.gitpod.io/docs/introduction/learn-gitpod/gitpod-yaml) -# and commit this file to your remote git repository to share the goodness with others. - -# Learn more from ready-to-use templates: https://www.gitpod.io/docs/introduction/getting-started/quickstart - -tasks: - - init: npm install && npm run build - - diff --git a/CHANGELOG.md b/CHANGELOG.md index 757a5f01..ae1adfd2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Change log +## 0.19.0 + +* Add `getScreenshot` method to `Avatars` service + ## 0.18.0 * Add `total` parameter to list queries allowing skipping counting rows in a table for improved performance diff --git a/docs/examples/avatars/get-screenshot.md b/docs/examples/avatars/get-screenshot.md new file mode 100644 index 00000000..918ab667 --- /dev/null +++ b/docs/examples/avatars/get-screenshot.md @@ -0,0 +1,32 @@ +import { Client, Avatars, Theme, Timezone, Output } from "react-native-appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const avatars = new Avatars(client); + +const result = avatars.getScreenshot({ + url: 'https://example.com', + headers: {}, // optional + viewportWidth: 1, // optional + viewportHeight: 1, // optional + scale: 0.1, // optional + theme: Theme.Light, // optional + userAgent: '', // optional + fullpage: false, // optional + locale: '', // optional + timezone: 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: Output.Jpg // optional +}); + +console.log(result); diff --git a/package.json b/package.json index 190e7f5a..3db97fd6 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "react-native-appwrite", "homepage": "https://appwrite.io/support", "description": "Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API", - "version": "0.18.0", + "version": "0.19.0", "license": "BSD-3-Clause", "main": "dist/cjs/sdk.js", "exports": { @@ -26,7 +26,7 @@ }, "devDependencies": { "@rollup/plugin-typescript": "8.3.2", - "playwright": "1.15.0", + "playwright": "1.56.1", "rollup": "2.75.4", "serve-handler": "6.1.0", "tslib": "2.4.0", diff --git a/src/client.ts b/src/client.ts index 1bd50680..7bcdd095 100644 --- a/src/client.ts +++ b/src/client.ts @@ -115,7 +115,7 @@ class Client { 'x-sdk-name': 'React Native', 'x-sdk-platform': 'client', 'x-sdk-language': 'reactnative', - 'x-sdk-version': '0.18.0', + 'x-sdk-version': '0.19.0', 'X-Appwrite-Response-Format': '1.8.0', }; diff --git a/src/enums/output.ts b/src/enums/output.ts new file mode 100644 index 00000000..c339a512 --- /dev/null +++ b/src/enums/output.ts @@ -0,0 +1,9 @@ +export enum Output { + Jpg = 'jpg', + Jpeg = 'jpeg', + Png = 'png', + Webp = 'webp', + Heic = 'heic', + Avif = 'avif', + Gif = 'gif', +} \ No newline at end of file diff --git a/src/enums/theme.ts b/src/enums/theme.ts new file mode 100644 index 00000000..5e823a9b --- /dev/null +++ b/src/enums/theme.ts @@ -0,0 +1,4 @@ +export enum Theme { + Light = 'light', + Dark = 'dark', +} \ No newline at end of file diff --git a/src/enums/timezone.ts b/src/enums/timezone.ts new file mode 100644 index 00000000..b67cdd2a --- /dev/null +++ b/src/enums/timezone.ts @@ -0,0 +1,421 @@ +export enum Timezone { + AfricaAbidjan = 'africa/abidjan', + AfricaAccra = 'africa/accra', + AfricaAddisAbaba = 'africa/addis_ababa', + AfricaAlgiers = 'africa/algiers', + AfricaAsmara = 'africa/asmara', + AfricaBamako = 'africa/bamako', + AfricaBangui = 'africa/bangui', + AfricaBanjul = 'africa/banjul', + AfricaBissau = 'africa/bissau', + AfricaBlantyre = 'africa/blantyre', + AfricaBrazzaville = 'africa/brazzaville', + AfricaBujumbura = 'africa/bujumbura', + AfricaCairo = 'africa/cairo', + AfricaCasablanca = 'africa/casablanca', + AfricaCeuta = 'africa/ceuta', + AfricaConakry = 'africa/conakry', + AfricaDakar = 'africa/dakar', + AfricaDarEsSalaam = 'africa/dar_es_salaam', + AfricaDjibouti = 'africa/djibouti', + AfricaDouala = 'africa/douala', + AfricaElAaiun = 'africa/el_aaiun', + AfricaFreetown = 'africa/freetown', + AfricaGaborone = 'africa/gaborone', + AfricaHarare = 'africa/harare', + AfricaJohannesburg = 'africa/johannesburg', + AfricaJuba = 'africa/juba', + AfricaKampala = 'africa/kampala', + AfricaKhartoum = 'africa/khartoum', + AfricaKigali = 'africa/kigali', + AfricaKinshasa = 'africa/kinshasa', + AfricaLagos = 'africa/lagos', + AfricaLibreville = 'africa/libreville', + AfricaLome = 'africa/lome', + AfricaLuanda = 'africa/luanda', + AfricaLubumbashi = 'africa/lubumbashi', + AfricaLusaka = 'africa/lusaka', + AfricaMalabo = 'africa/malabo', + AfricaMaputo = 'africa/maputo', + AfricaMaseru = 'africa/maseru', + AfricaMbabane = 'africa/mbabane', + AfricaMogadishu = 'africa/mogadishu', + AfricaMonrovia = 'africa/monrovia', + AfricaNairobi = 'africa/nairobi', + AfricaNdjamena = 'africa/ndjamena', + AfricaNiamey = 'africa/niamey', + AfricaNouakchott = 'africa/nouakchott', + AfricaOuagadougou = 'africa/ouagadougou', + AfricaPortoNovo = 'africa/porto-novo', + AfricaSaoTome = 'africa/sao_tome', + AfricaTripoli = 'africa/tripoli', + AfricaTunis = 'africa/tunis', + AfricaWindhoek = 'africa/windhoek', + AmericaAdak = 'america/adak', + AmericaAnchorage = 'america/anchorage', + AmericaAnguilla = 'america/anguilla', + AmericaAntigua = 'america/antigua', + AmericaAraguaina = 'america/araguaina', + AmericaArgentinaBuenosAires = 'america/argentina/buenos_aires', + AmericaArgentinaCatamarca = 'america/argentina/catamarca', + AmericaArgentinaCordoba = 'america/argentina/cordoba', + AmericaArgentinaJujuy = 'america/argentina/jujuy', + AmericaArgentinaLaRioja = 'america/argentina/la_rioja', + AmericaArgentinaMendoza = 'america/argentina/mendoza', + AmericaArgentinaRioGallegos = 'america/argentina/rio_gallegos', + AmericaArgentinaSalta = 'america/argentina/salta', + AmericaArgentinaSanJuan = 'america/argentina/san_juan', + AmericaArgentinaSanLuis = 'america/argentina/san_luis', + AmericaArgentinaTucuman = 'america/argentina/tucuman', + AmericaArgentinaUshuaia = 'america/argentina/ushuaia', + AmericaAruba = 'america/aruba', + AmericaAsuncion = 'america/asuncion', + AmericaAtikokan = 'america/atikokan', + AmericaBahia = 'america/bahia', + AmericaBahiaBanderas = 'america/bahia_banderas', + AmericaBarbados = 'america/barbados', + AmericaBelem = 'america/belem', + AmericaBelize = 'america/belize', + AmericaBlancSablon = 'america/blanc-sablon', + AmericaBoaVista = 'america/boa_vista', + AmericaBogota = 'america/bogota', + AmericaBoise = 'america/boise', + AmericaCambridgeBay = 'america/cambridge_bay', + AmericaCampoGrande = 'america/campo_grande', + AmericaCancun = 'america/cancun', + AmericaCaracas = 'america/caracas', + AmericaCayenne = 'america/cayenne', + AmericaCayman = 'america/cayman', + AmericaChicago = 'america/chicago', + AmericaChihuahua = 'america/chihuahua', + AmericaCiudadJuarez = 'america/ciudad_juarez', + AmericaCostaRica = 'america/costa_rica', + AmericaCoyhaique = 'america/coyhaique', + AmericaCreston = 'america/creston', + AmericaCuiaba = 'america/cuiaba', + AmericaCuracao = 'america/curacao', + AmericaDanmarkshavn = 'america/danmarkshavn', + AmericaDawson = 'america/dawson', + AmericaDawsonCreek = 'america/dawson_creek', + AmericaDenver = 'america/denver', + AmericaDetroit = 'america/detroit', + AmericaDominica = 'america/dominica', + AmericaEdmonton = 'america/edmonton', + AmericaEirunepe = 'america/eirunepe', + AmericaElSalvador = 'america/el_salvador', + AmericaFortNelson = 'america/fort_nelson', + AmericaFortaleza = 'america/fortaleza', + AmericaGlaceBay = 'america/glace_bay', + AmericaGooseBay = 'america/goose_bay', + AmericaGrandTurk = 'america/grand_turk', + AmericaGrenada = 'america/grenada', + AmericaGuadeloupe = 'america/guadeloupe', + AmericaGuatemala = 'america/guatemala', + AmericaGuayaquil = 'america/guayaquil', + AmericaGuyana = 'america/guyana', + AmericaHalifax = 'america/halifax', + AmericaHavana = 'america/havana', + AmericaHermosillo = 'america/hermosillo', + AmericaIndianaIndianapolis = 'america/indiana/indianapolis', + AmericaIndianaKnox = 'america/indiana/knox', + AmericaIndianaMarengo = 'america/indiana/marengo', + AmericaIndianaPetersburg = 'america/indiana/petersburg', + AmericaIndianaTellCity = 'america/indiana/tell_city', + AmericaIndianaVevay = 'america/indiana/vevay', + AmericaIndianaVincennes = 'america/indiana/vincennes', + AmericaIndianaWinamac = 'america/indiana/winamac', + AmericaInuvik = 'america/inuvik', + AmericaIqaluit = 'america/iqaluit', + AmericaJamaica = 'america/jamaica', + AmericaJuneau = 'america/juneau', + AmericaKentuckyLouisville = 'america/kentucky/louisville', + AmericaKentuckyMonticello = 'america/kentucky/monticello', + AmericaKralendijk = 'america/kralendijk', + AmericaLaPaz = 'america/la_paz', + AmericaLima = 'america/lima', + AmericaLosAngeles = 'america/los_angeles', + AmericaLowerPrinces = 'america/lower_princes', + AmericaMaceio = 'america/maceio', + AmericaManagua = 'america/managua', + AmericaManaus = 'america/manaus', + AmericaMarigot = 'america/marigot', + AmericaMartinique = 'america/martinique', + AmericaMatamoros = 'america/matamoros', + AmericaMazatlan = 'america/mazatlan', + AmericaMenominee = 'america/menominee', + AmericaMerida = 'america/merida', + AmericaMetlakatla = 'america/metlakatla', + AmericaMexicoCity = 'america/mexico_city', + AmericaMiquelon = 'america/miquelon', + AmericaMoncton = 'america/moncton', + AmericaMonterrey = 'america/monterrey', + AmericaMontevideo = 'america/montevideo', + AmericaMontserrat = 'america/montserrat', + AmericaNassau = 'america/nassau', + AmericaNewYork = 'america/new_york', + AmericaNome = 'america/nome', + AmericaNoronha = 'america/noronha', + AmericaNorthDakotaBeulah = 'america/north_dakota/beulah', + AmericaNorthDakotaCenter = 'america/north_dakota/center', + AmericaNorthDakotaNewSalem = 'america/north_dakota/new_salem', + AmericaNuuk = 'america/nuuk', + AmericaOjinaga = 'america/ojinaga', + AmericaPanama = 'america/panama', + AmericaParamaribo = 'america/paramaribo', + AmericaPhoenix = 'america/phoenix', + AmericaPortAuPrince = 'america/port-au-prince', + AmericaPortOfSpain = 'america/port_of_spain', + AmericaPortoVelho = 'america/porto_velho', + AmericaPuertoRico = 'america/puerto_rico', + AmericaPuntaArenas = 'america/punta_arenas', + AmericaRankinInlet = 'america/rankin_inlet', + AmericaRecife = 'america/recife', + AmericaRegina = 'america/regina', + AmericaResolute = 'america/resolute', + AmericaRioBranco = 'america/rio_branco', + AmericaSantarem = 'america/santarem', + AmericaSantiago = 'america/santiago', + AmericaSantoDomingo = 'america/santo_domingo', + AmericaSaoPaulo = 'america/sao_paulo', + AmericaScoresbysund = 'america/scoresbysund', + AmericaSitka = 'america/sitka', + AmericaStBarthelemy = 'america/st_barthelemy', + AmericaStJohns = 'america/st_johns', + AmericaStKitts = 'america/st_kitts', + AmericaStLucia = 'america/st_lucia', + AmericaStThomas = 'america/st_thomas', + AmericaStVincent = 'america/st_vincent', + AmericaSwiftCurrent = 'america/swift_current', + AmericaTegucigalpa = 'america/tegucigalpa', + AmericaThule = 'america/thule', + AmericaTijuana = 'america/tijuana', + AmericaToronto = 'america/toronto', + AmericaTortola = 'america/tortola', + AmericaVancouver = 'america/vancouver', + AmericaWhitehorse = 'america/whitehorse', + AmericaWinnipeg = 'america/winnipeg', + AmericaYakutat = 'america/yakutat', + AntarcticaCasey = 'antarctica/casey', + AntarcticaDavis = 'antarctica/davis', + AntarcticaDumontdurville = 'antarctica/dumontdurville', + AntarcticaMacquarie = 'antarctica/macquarie', + AntarcticaMawson = 'antarctica/mawson', + AntarcticaMcmurdo = 'antarctica/mcmurdo', + AntarcticaPalmer = 'antarctica/palmer', + AntarcticaRothera = 'antarctica/rothera', + AntarcticaSyowa = 'antarctica/syowa', + AntarcticaTroll = 'antarctica/troll', + AntarcticaVostok = 'antarctica/vostok', + ArcticLongyearbyen = 'arctic/longyearbyen', + AsiaAden = 'asia/aden', + AsiaAlmaty = 'asia/almaty', + AsiaAmman = 'asia/amman', + AsiaAnadyr = 'asia/anadyr', + AsiaAqtau = 'asia/aqtau', + AsiaAqtobe = 'asia/aqtobe', + AsiaAshgabat = 'asia/ashgabat', + AsiaAtyrau = 'asia/atyrau', + AsiaBaghdad = 'asia/baghdad', + AsiaBahrain = 'asia/bahrain', + AsiaBaku = 'asia/baku', + AsiaBangkok = 'asia/bangkok', + AsiaBarnaul = 'asia/barnaul', + AsiaBeirut = 'asia/beirut', + AsiaBishkek = 'asia/bishkek', + AsiaBrunei = 'asia/brunei', + AsiaChita = 'asia/chita', + AsiaColombo = 'asia/colombo', + AsiaDamascus = 'asia/damascus', + AsiaDhaka = 'asia/dhaka', + AsiaDili = 'asia/dili', + AsiaDubai = 'asia/dubai', + AsiaDushanbe = 'asia/dushanbe', + AsiaFamagusta = 'asia/famagusta', + AsiaGaza = 'asia/gaza', + AsiaHebron = 'asia/hebron', + AsiaHoChiMinh = 'asia/ho_chi_minh', + AsiaHongKong = 'asia/hong_kong', + AsiaHovd = 'asia/hovd', + AsiaIrkutsk = 'asia/irkutsk', + AsiaJakarta = 'asia/jakarta', + AsiaJayapura = 'asia/jayapura', + AsiaJerusalem = 'asia/jerusalem', + AsiaKabul = 'asia/kabul', + AsiaKamchatka = 'asia/kamchatka', + AsiaKarachi = 'asia/karachi', + AsiaKathmandu = 'asia/kathmandu', + AsiaKhandyga = 'asia/khandyga', + AsiaKolkata = 'asia/kolkata', + AsiaKrasnoyarsk = 'asia/krasnoyarsk', + AsiaKualaLumpur = 'asia/kuala_lumpur', + AsiaKuching = 'asia/kuching', + AsiaKuwait = 'asia/kuwait', + AsiaMacau = 'asia/macau', + AsiaMagadan = 'asia/magadan', + AsiaMakassar = 'asia/makassar', + AsiaManila = 'asia/manila', + AsiaMuscat = 'asia/muscat', + AsiaNicosia = 'asia/nicosia', + AsiaNovokuznetsk = 'asia/novokuznetsk', + AsiaNovosibirsk = 'asia/novosibirsk', + AsiaOmsk = 'asia/omsk', + AsiaOral = 'asia/oral', + AsiaPhnomPenh = 'asia/phnom_penh', + AsiaPontianak = 'asia/pontianak', + AsiaPyongyang = 'asia/pyongyang', + AsiaQatar = 'asia/qatar', + AsiaQostanay = 'asia/qostanay', + AsiaQyzylorda = 'asia/qyzylorda', + AsiaRiyadh = 'asia/riyadh', + AsiaSakhalin = 'asia/sakhalin', + AsiaSamarkand = 'asia/samarkand', + AsiaSeoul = 'asia/seoul', + AsiaShanghai = 'asia/shanghai', + AsiaSingapore = 'asia/singapore', + AsiaSrednekolymsk = 'asia/srednekolymsk', + AsiaTaipei = 'asia/taipei', + AsiaTashkent = 'asia/tashkent', + AsiaTbilisi = 'asia/tbilisi', + AsiaTehran = 'asia/tehran', + AsiaThimphu = 'asia/thimphu', + AsiaTokyo = 'asia/tokyo', + AsiaTomsk = 'asia/tomsk', + AsiaUlaanbaatar = 'asia/ulaanbaatar', + AsiaUrumqi = 'asia/urumqi', + AsiaUstNera = 'asia/ust-nera', + AsiaVientiane = 'asia/vientiane', + AsiaVladivostok = 'asia/vladivostok', + AsiaYakutsk = 'asia/yakutsk', + AsiaYangon = 'asia/yangon', + AsiaYekaterinburg = 'asia/yekaterinburg', + AsiaYerevan = 'asia/yerevan', + AtlanticAzores = 'atlantic/azores', + AtlanticBermuda = 'atlantic/bermuda', + AtlanticCanary = 'atlantic/canary', + AtlanticCapeVerde = 'atlantic/cape_verde', + AtlanticFaroe = 'atlantic/faroe', + AtlanticMadeira = 'atlantic/madeira', + AtlanticReykjavik = 'atlantic/reykjavik', + AtlanticSouthGeorgia = 'atlantic/south_georgia', + AtlanticStHelena = 'atlantic/st_helena', + AtlanticStanley = 'atlantic/stanley', + AustraliaAdelaide = 'australia/adelaide', + AustraliaBrisbane = 'australia/brisbane', + AustraliaBrokenHill = 'australia/broken_hill', + AustraliaDarwin = 'australia/darwin', + AustraliaEucla = 'australia/eucla', + AustraliaHobart = 'australia/hobart', + AustraliaLindeman = 'australia/lindeman', + AustraliaLordHowe = 'australia/lord_howe', + AustraliaMelbourne = 'australia/melbourne', + AustraliaPerth = 'australia/perth', + AustraliaSydney = 'australia/sydney', + EuropeAmsterdam = 'europe/amsterdam', + EuropeAndorra = 'europe/andorra', + EuropeAstrakhan = 'europe/astrakhan', + EuropeAthens = 'europe/athens', + EuropeBelgrade = 'europe/belgrade', + EuropeBerlin = 'europe/berlin', + EuropeBratislava = 'europe/bratislava', + EuropeBrussels = 'europe/brussels', + EuropeBucharest = 'europe/bucharest', + EuropeBudapest = 'europe/budapest', + EuropeBusingen = 'europe/busingen', + EuropeChisinau = 'europe/chisinau', + EuropeCopenhagen = 'europe/copenhagen', + EuropeDublin = 'europe/dublin', + EuropeGibraltar = 'europe/gibraltar', + EuropeGuernsey = 'europe/guernsey', + EuropeHelsinki = 'europe/helsinki', + EuropeIsleOfMan = 'europe/isle_of_man', + EuropeIstanbul = 'europe/istanbul', + EuropeJersey = 'europe/jersey', + EuropeKaliningrad = 'europe/kaliningrad', + EuropeKirov = 'europe/kirov', + EuropeKyiv = 'europe/kyiv', + EuropeLisbon = 'europe/lisbon', + EuropeLjubljana = 'europe/ljubljana', + EuropeLondon = 'europe/london', + EuropeLuxembourg = 'europe/luxembourg', + EuropeMadrid = 'europe/madrid', + EuropeMalta = 'europe/malta', + EuropeMariehamn = 'europe/mariehamn', + EuropeMinsk = 'europe/minsk', + EuropeMonaco = 'europe/monaco', + EuropeMoscow = 'europe/moscow', + EuropeOslo = 'europe/oslo', + EuropeParis = 'europe/paris', + EuropePodgorica = 'europe/podgorica', + EuropePrague = 'europe/prague', + EuropeRiga = 'europe/riga', + EuropeRome = 'europe/rome', + EuropeSamara = 'europe/samara', + EuropeSanMarino = 'europe/san_marino', + EuropeSarajevo = 'europe/sarajevo', + EuropeSaratov = 'europe/saratov', + EuropeSimferopol = 'europe/simferopol', + EuropeSkopje = 'europe/skopje', + EuropeSofia = 'europe/sofia', + EuropeStockholm = 'europe/stockholm', + EuropeTallinn = 'europe/tallinn', + EuropeTirane = 'europe/tirane', + EuropeUlyanovsk = 'europe/ulyanovsk', + EuropeVaduz = 'europe/vaduz', + EuropeVatican = 'europe/vatican', + EuropeVienna = 'europe/vienna', + EuropeVilnius = 'europe/vilnius', + EuropeVolgograd = 'europe/volgograd', + EuropeWarsaw = 'europe/warsaw', + EuropeZagreb = 'europe/zagreb', + EuropeZurich = 'europe/zurich', + IndianAntananarivo = 'indian/antananarivo', + IndianChagos = 'indian/chagos', + IndianChristmas = 'indian/christmas', + IndianCocos = 'indian/cocos', + IndianComoro = 'indian/comoro', + IndianKerguelen = 'indian/kerguelen', + IndianMahe = 'indian/mahe', + IndianMaldives = 'indian/maldives', + IndianMauritius = 'indian/mauritius', + IndianMayotte = 'indian/mayotte', + IndianReunion = 'indian/reunion', + PacificApia = 'pacific/apia', + PacificAuckland = 'pacific/auckland', + PacificBougainville = 'pacific/bougainville', + PacificChatham = 'pacific/chatham', + PacificChuuk = 'pacific/chuuk', + PacificEaster = 'pacific/easter', + PacificEfate = 'pacific/efate', + PacificFakaofo = 'pacific/fakaofo', + PacificFiji = 'pacific/fiji', + PacificFunafuti = 'pacific/funafuti', + PacificGalapagos = 'pacific/galapagos', + PacificGambier = 'pacific/gambier', + PacificGuadalcanal = 'pacific/guadalcanal', + PacificGuam = 'pacific/guam', + PacificHonolulu = 'pacific/honolulu', + PacificKanton = 'pacific/kanton', + PacificKiritimati = 'pacific/kiritimati', + PacificKosrae = 'pacific/kosrae', + PacificKwajalein = 'pacific/kwajalein', + PacificMajuro = 'pacific/majuro', + PacificMarquesas = 'pacific/marquesas', + PacificMidway = 'pacific/midway', + PacificNauru = 'pacific/nauru', + PacificNiue = 'pacific/niue', + PacificNorfolk = 'pacific/norfolk', + PacificNoumea = 'pacific/noumea', + PacificPagoPago = 'pacific/pago_pago', + PacificPalau = 'pacific/palau', + PacificPitcairn = 'pacific/pitcairn', + PacificPohnpei = 'pacific/pohnpei', + PacificPortMoresby = 'pacific/port_moresby', + PacificRarotonga = 'pacific/rarotonga', + PacificSaipan = 'pacific/saipan', + PacificTahiti = 'pacific/tahiti', + PacificTarawa = 'pacific/tarawa', + PacificTongatapu = 'pacific/tongatapu', + PacificWake = 'pacific/wake', + PacificWallis = 'pacific/wallis', + Utc = 'utc', +} \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index cbb31951..a949462c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -22,6 +22,9 @@ export { OAuthProvider } from './enums/o-auth-provider'; export { Browser } from './enums/browser'; export { CreditCard } from './enums/credit-card'; export { Flag } from './enums/flag'; +export { Theme } from './enums/theme'; +export { Timezone } from './enums/timezone'; +export { Output } from './enums/output'; export { ExecutionMethod } from './enums/execution-method'; export { ImageGravity } from './enums/image-gravity'; export { ImageFormat } from './enums/image-format'; diff --git a/src/services/avatars.ts b/src/services/avatars.ts index e429691b..4a07449f 100644 --- a/src/services/avatars.ts +++ b/src/services/avatars.ts @@ -8,6 +8,9 @@ import { Platform } from 'react-native'; import { Browser } from '../enums/browser'; import { CreditCard } from '../enums/credit-card'; import { Flag } from '../enums/flag'; +import { Theme } from '../enums/theme'; +import { Timezone } from '../enums/timezone'; +import { Output } from '../enums/output'; export class Avatars extends Service { @@ -560,6 +563,221 @@ export class Avatars extends Service { }, payload, 'arrayBuffer'); } + /** + * 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. + * + * @param {string} params.url - Website URL which you want to capture. + * @param {object} params.headers - HTTP headers to send with the browser request. Defaults to empty. + * @param {number} params.viewportWidth - Browser viewport width. Pass an integer between 1 to 1920. Defaults to 1280. + * @param {number} params.viewportHeight - Browser viewport height. Pass an integer between 1 to 1080. Defaults to 720. + * @param {number} params.scale - Browser scale factor. Pass a number between 0.1 to 3. Defaults to 1. + * @param {Theme} params.theme - Browser theme. Pass "light" or "dark". Defaults to "light". + * @param {string} params.userAgent - Custom user agent string. Defaults to browser default. + * @param {boolean} params.fullpage - Capture full page scroll. Pass 0 for viewport only, or 1 for full page. Defaults to 0. + * @param {string} params.locale - Browser locale (e.g., "en-US", "fr-FR"). Defaults to browser default. + * @param {Timezone} params.timezone - IANA timezone identifier (e.g., "America/New_York", "Europe/London"). Defaults to browser default. + * @param {number} params.latitude - Geolocation latitude. Pass a number between -90 to 90. Defaults to 0. + * @param {number} params.longitude - Geolocation longitude. Pass a number between -180 to 180. Defaults to 0. + * @param {number} params.accuracy - Geolocation accuracy in meters. Pass a number between 0 to 100000. Defaults to 0. + * @param {boolean} params.touch - Enable touch support. Pass 0 for no touch, or 1 for touch enabled. Defaults to 0. + * @param {string[]} params.permissions - Browser permissions to grant. Pass an array of permission names like ["geolocation", "camera", "microphone"]. Defaults to empty. + * @param {number} params.sleep - Wait time in seconds before taking the screenshot. Pass an integer between 0 to 10. Defaults to 0. + * @param {number} params.width - Output image width. Pass 0 to use original width, or an integer between 1 to 2000. Defaults to 0 (original width). + * @param {number} params.height - Output image height. Pass 0 to use original height, or an integer between 1 to 2000. Defaults to 0 (original height). + * @param {number} params.quality - Screenshot quality. Pass an integer between 0 to 100. Defaults to keep existing image quality. + * @param {Output} params.output - Output format type (jpeg, jpg, png, gif and webp). + * @throws {AppwriteException} + * @returns {ArrayBuffer} + */ + getScreenshot(params: { url: string, headers?: object, viewportWidth?: number, viewportHeight?: number, scale?: number, theme?: Theme, userAgent?: string, fullpage?: boolean, locale?: string, timezone?: Timezone, latitude?: number, longitude?: number, accuracy?: number, touch?: boolean, permissions?: string[], sleep?: number, width?: number, height?: number, quality?: number, output?: Output }): Promise; + /** + * 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. + * + * @param {string} url - Website URL which you want to capture. + * @param {object} headers - HTTP headers to send with the browser request. Defaults to empty. + * @param {number} viewportWidth - Browser viewport width. Pass an integer between 1 to 1920. Defaults to 1280. + * @param {number} viewportHeight - Browser viewport height. Pass an integer between 1 to 1080. Defaults to 720. + * @param {number} scale - Browser scale factor. Pass a number between 0.1 to 3. Defaults to 1. + * @param {Theme} theme - Browser theme. Pass "light" or "dark". Defaults to "light". + * @param {string} userAgent - Custom user agent string. Defaults to browser default. + * @param {boolean} fullpage - Capture full page scroll. Pass 0 for viewport only, or 1 for full page. Defaults to 0. + * @param {string} locale - Browser locale (e.g., "en-US", "fr-FR"). Defaults to browser default. + * @param {Timezone} timezone - IANA timezone identifier (e.g., "America/New_York", "Europe/London"). Defaults to browser default. + * @param {number} latitude - Geolocation latitude. Pass a number between -90 to 90. Defaults to 0. + * @param {number} longitude - Geolocation longitude. Pass a number between -180 to 180. Defaults to 0. + * @param {number} accuracy - Geolocation accuracy in meters. Pass a number between 0 to 100000. Defaults to 0. + * @param {boolean} touch - Enable touch support. Pass 0 for no touch, or 1 for touch enabled. Defaults to 0. + * @param {string[]} permissions - Browser permissions to grant. Pass an array of permission names like ["geolocation", "camera", "microphone"]. Defaults to empty. + * @param {number} sleep - Wait time in seconds before taking the screenshot. Pass an integer between 0 to 10. Defaults to 0. + * @param {number} width - Output image width. Pass 0 to use original width, or an integer between 1 to 2000. Defaults to 0 (original width). + * @param {number} height - Output image height. Pass 0 to use original height, or an integer between 1 to 2000. Defaults to 0 (original height). + * @param {number} quality - Screenshot quality. Pass an integer between 0 to 100. Defaults to keep existing image quality. + * @param {Output} output - Output format type (jpeg, jpg, png, gif and webp). + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getScreenshot(url: string, headers?: object, viewportWidth?: number, viewportHeight?: number, scale?: number, theme?: Theme, userAgent?: string, fullpage?: boolean, locale?: string, timezone?: Timezone, latitude?: number, longitude?: number, accuracy?: number, touch?: boolean, permissions?: string[], sleep?: number, width?: number, height?: number, quality?: number, output?: Output): Promise; + getScreenshot( + paramsOrFirst: { url: string, headers?: object, viewportWidth?: number, viewportHeight?: number, scale?: number, theme?: Theme, userAgent?: string, fullpage?: boolean, locale?: string, timezone?: Timezone, latitude?: number, longitude?: number, accuracy?: number, touch?: boolean, permissions?: string[], sleep?: number, width?: number, height?: number, quality?: number, output?: Output } | string, + ...rest: [(object)?, (number)?, (number)?, (number)?, (Theme)?, (string)?, (boolean)?, (string)?, (Timezone)?, (number)?, (number)?, (number)?, (boolean)?, (string[])?, (number)?, (number)?, (number)?, (number)?, (Output)?] + ): Promise { + let params: { url: string, headers?: object, viewportWidth?: number, viewportHeight?: number, scale?: number, theme?: Theme, userAgent?: string, fullpage?: boolean, locale?: string, timezone?: Timezone, latitude?: number, longitude?: number, accuracy?: number, touch?: boolean, permissions?: string[], sleep?: number, width?: number, height?: number, quality?: number, output?: Output }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { url: string, headers?: object, viewportWidth?: number, viewportHeight?: number, scale?: number, theme?: Theme, userAgent?: string, fullpage?: boolean, locale?: string, timezone?: Timezone, latitude?: number, longitude?: number, accuracy?: number, touch?: boolean, permissions?: string[], sleep?: number, width?: number, height?: number, quality?: number, output?: Output }; + } else { + params = { + url: paramsOrFirst as string, + headers: rest[0] as object, + viewportWidth: rest[1] as number, + viewportHeight: rest[2] as number, + scale: rest[3] as number, + theme: rest[4] as Theme, + userAgent: rest[5] as string, + fullpage: rest[6] as boolean, + locale: rest[7] as string, + timezone: rest[8] as Timezone, + latitude: rest[9] as number, + longitude: rest[10] as number, + accuracy: rest[11] as number, + touch: rest[12] as boolean, + permissions: rest[13] as string[], + sleep: rest[14] as number, + width: rest[15] as number, + height: rest[16] as number, + quality: rest[17] as number, + output: rest[18] as Output + }; + } + + const url = params.url; + const headers = params.headers; + const viewportWidth = params.viewportWidth; + const viewportHeight = params.viewportHeight; + const scale = params.scale; + const theme = params.theme; + const userAgent = params.userAgent; + const fullpage = params.fullpage; + const locale = params.locale; + const timezone = params.timezone; + const latitude = params.latitude; + const longitude = params.longitude; + const accuracy = params.accuracy; + const touch = params.touch; + const permissions = params.permissions; + const sleep = params.sleep; + const width = params.width; + const height = params.height; + const quality = params.quality; + const output = params.output; + + if (typeof url === 'undefined') { + throw new AppwriteException('Missing required parameter: "url"'); + } + + const apiPath = '/avatars/screenshots'; + const payload: Payload = {}; + + if (typeof url !== 'undefined') { + payload['url'] = url; + } + + if (typeof headers !== 'undefined') { + payload['headers'] = headers; + } + + if (typeof viewportWidth !== 'undefined') { + payload['viewportWidth'] = viewportWidth; + } + + if (typeof viewportHeight !== 'undefined') { + payload['viewportHeight'] = viewportHeight; + } + + if (typeof scale !== 'undefined') { + payload['scale'] = scale; + } + + if (typeof theme !== 'undefined') { + payload['theme'] = theme; + } + + if (typeof userAgent !== 'undefined') { + payload['userAgent'] = userAgent; + } + + if (typeof fullpage !== 'undefined') { + payload['fullpage'] = fullpage; + } + + if (typeof locale !== 'undefined') { + payload['locale'] = locale; + } + + if (typeof timezone !== 'undefined') { + payload['timezone'] = timezone; + } + + if (typeof latitude !== 'undefined') { + payload['latitude'] = latitude; + } + + if (typeof longitude !== 'undefined') { + payload['longitude'] = longitude; + } + + if (typeof accuracy !== 'undefined') { + payload['accuracy'] = accuracy; + } + + if (typeof touch !== 'undefined') { + payload['touch'] = touch; + } + + if (typeof permissions !== 'undefined') { + payload['permissions'] = permissions; + } + + if (typeof sleep !== 'undefined') { + payload['sleep'] = sleep; + } + + if (typeof width !== 'undefined') { + payload['width'] = width; + } + + if (typeof height !== 'undefined') { + payload['height'] = height; + } + + if (typeof quality !== 'undefined') { + payload['quality'] = quality; + } + + if (typeof output !== 'undefined') { + payload['output'] = output; + } + + const uri = new URL(this.client.config.endpoint + apiPath); + payload['project'] = this.client.config.project; + + + for (const [key, value] of Object.entries(Service.flatten(payload))) { + uri.searchParams.append(key, value); + } + return this.client.call('get', uri, { + }, payload, 'arrayBuffer'); + } + /** * You can use this endpoint to show different browser icons to your users. * The code argument receives the browser code as it appears in your user [GET @@ -863,4 +1081,133 @@ export class Avatars extends Service { return uri; } + + /** + * 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. + * + * @param {string} url + * @param {object} headers + * @param {number} viewportWidth + * @param {number} viewportHeight + * @param {number} scale + * @param {Theme} theme + * @param {string} userAgent + * @param {boolean} fullpage + * @param {string} locale + * @param {Timezone} timezone + * @param {number} latitude + * @param {number} longitude + * @param {number} accuracy + * @param {boolean} touch + * @param {string[]} permissions + * @param {number} sleep + * @param {number} width + * @param {number} height + * @param {number} quality + * @param {Output} output + * @throws {AppwriteException} + * @returns {URL} + */ + getScreenshotURL(url: string, headers?: object, viewportWidth?: number, viewportHeight?: number, scale?: number, theme?: Theme, userAgent?: string, fullpage?: boolean, locale?: string, timezone?: Timezone, latitude?: number, longitude?: number, accuracy?: number, touch?: boolean, permissions?: string[], sleep?: number, width?: number, height?: number, quality?: number, output?: Output): URL { + const apiPath = '/avatars/screenshots'; + const payload: Payload = {}; + + if (typeof url !== 'undefined') { + payload['url'] = url; + } + + if (typeof headers !== 'undefined') { + payload['headers'] = headers; + } + + if (typeof viewportWidth !== 'undefined') { + payload['viewportWidth'] = viewportWidth; + } + + if (typeof viewportHeight !== 'undefined') { + payload['viewportHeight'] = viewportHeight; + } + + if (typeof scale !== 'undefined') { + payload['scale'] = scale; + } + + if (typeof theme !== 'undefined') { + payload['theme'] = theme; + } + + if (typeof userAgent !== 'undefined') { + payload['userAgent'] = userAgent; + } + + if (typeof fullpage !== 'undefined') { + payload['fullpage'] = fullpage; + } + + if (typeof locale !== 'undefined') { + payload['locale'] = locale; + } + + if (typeof timezone !== 'undefined') { + payload['timezone'] = timezone; + } + + if (typeof latitude !== 'undefined') { + payload['latitude'] = latitude; + } + + if (typeof longitude !== 'undefined') { + payload['longitude'] = longitude; + } + + if (typeof accuracy !== 'undefined') { + payload['accuracy'] = accuracy; + } + + if (typeof touch !== 'undefined') { + payload['touch'] = touch; + } + + if (typeof permissions !== 'undefined') { + payload['permissions'] = permissions; + } + + if (typeof sleep !== 'undefined') { + payload['sleep'] = sleep; + } + + if (typeof width !== 'undefined') { + payload['width'] = width; + } + + if (typeof height !== 'undefined') { + payload['height'] = height; + } + + if (typeof quality !== 'undefined') { + payload['quality'] = quality; + } + + if (typeof output !== 'undefined') { + payload['output'] = output; + } + + const uri = new URL(this.client.config.endpoint + apiPath); + payload['project'] = this.client.config.project; + + for (const [key, value] of Object.entries(Service.flatten(payload))) { + uri.searchParams.append(key, value); + } + + return uri; + } }; From e6cdf9db0c187475184520daa72ff2b645c256cb Mon Sep 17 00:00:00 2001 From: root Date: Fri, 28 Nov 2025 19:28:21 +0000 Subject: [PATCH 2/3] fix changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ae1adfd2..8ab9bcca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## 0.19.0 * Add `getScreenshot` method to `Avatars` service +* Add `Theme`, `Timezone` and `Output` enums ## 0.18.0 From 827c5387fe2c79db0a971356056d0e23625ebc0e Mon Sep 17 00:00:00 2001 From: root Date: Mon, 1 Dec 2025 13:54:10 +0000 Subject: [PATCH 3/3] update examples --- docs/examples/avatars/get-screenshot.md | 35 ++++++++++++++----------- src/services/account.ts | 8 +++--- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/docs/examples/avatars/get-screenshot.md b/docs/examples/avatars/get-screenshot.md index 918ab667..2e4b84de 100644 --- a/docs/examples/avatars/get-screenshot.md +++ b/docs/examples/avatars/get-screenshot.md @@ -8,24 +8,27 @@ const avatars = new Avatars(client); const result = 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: 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: 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: Output.Jpg // optional }); diff --git a/src/services/account.ts b/src/services/account.ts index e3b86e18..7ef9574d 100644 --- a/src/services/account.ts +++ b/src/services/account.ts @@ -731,7 +731,7 @@ export class Account extends Service { throw new AppwriteException('Missing required parameter: "factor"'); } - const apiPath = '/account/mfa/challenge'; + const apiPath = '/account/mfa/challenges'; const payload: Payload = {}; if (typeof factor !== 'undefined') { @@ -780,7 +780,7 @@ export class Account extends Service { throw new AppwriteException('Missing required parameter: "factor"'); } - const apiPath = '/account/mfa/challenge'; + const apiPath = '/account/mfa/challenges'; const payload: Payload = {}; if (typeof factor !== 'undefined') { @@ -839,7 +839,7 @@ export class Account extends Service { throw new AppwriteException('Missing required parameter: "otp"'); } - const apiPath = '/account/mfa/challenge'; + const apiPath = '/account/mfa/challenges'; const payload: Payload = {}; if (typeof challengeId !== 'undefined') { @@ -901,7 +901,7 @@ export class Account extends Service { throw new AppwriteException('Missing required parameter: "otp"'); } - const apiPath = '/account/mfa/challenge'; + const apiPath = '/account/mfa/challenges'; const payload: Payload = {}; if (typeof challengeId !== 'undefined') {