From e4e5be223f03bbc9f43a9994c42eea9fedf139d6 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 28 Nov 2025 19:04:34 +0000 Subject: [PATCH 1/3] feat: add method to service --- CHANGELOG.md | 4 + docs/examples/avatars/get-screenshot.md | 31 ++ .../functions/create-template-deployment.md | 3 +- .../functions/create-vcs-deployment.md | 2 +- docs/examples/functions/create.md | 2 +- docs/examples/functions/update.md | 2 +- docs/examples/health/get-failed-jobs.md | 2 +- .../sites/create-template-deployment.md | 3 +- docs/examples/sites/create-vcs-deployment.md | 2 +- docs/examples/sites/create.md | 6 +- docs/examples/sites/update.md | 6 +- docs/examples/storage/create-bucket.md | 5 +- docs/examples/storage/update-bucket.md | 5 +- package.json | 2 +- src/client.ts | 4 +- src/enums/build-runtime.ts | 2 + src/enums/output.ts | 9 + src/enums/runtime.ts | 2 + src/enums/template-reference-type.ts | 5 + src/enums/theme.ts | 4 + src/enums/timezone.ts | 421 ++++++++++++++++++ ...ployment-type.ts => vcs-reference-type.ts} | 2 +- src/index.ts | 6 +- src/models.ts | 4 + src/services/avatars.ts | 200 +++++++++ src/services/functions.ts | 61 +-- src/services/sites.ts | 65 +-- src/services/storage.ts | 46 +- src/services/tables-db.ts | 4 +- 29 files changed, 818 insertions(+), 92 deletions(-) create mode 100644 docs/examples/avatars/get-screenshot.md create mode 100644 src/enums/output.ts create mode 100644 src/enums/template-reference-type.ts create mode 100644 src/enums/theme.ts create mode 100644 src/enums/timezone.ts rename src/enums/{vcs-deployment-type.ts => vcs-reference-type.ts} (66%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 419b052..659f256 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 20.4.0 + +* Add `getScreenshot` method to `Avatars` service + ## 20.3.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 0000000..60a3898 --- /dev/null +++ b/docs/examples/avatars/get-screenshot.md @@ -0,0 +1,31 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +const avatars = new sdk.Avatars(client); + +const result = await avatars.getScreenshot({ + url: 'https://example.com', + headers: {}, // optional + viewportWidth: 1, // optional + viewportHeight: 1, // optional + scale: 0.1, // optional + theme: sdk.Theme.Light, // optional + userAgent: '', // optional + fullpage: false, // optional + locale: '', // optional + timezone: sdk.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: sdk.Output.Jpg // optional +}); diff --git a/docs/examples/functions/create-template-deployment.md b/docs/examples/functions/create-template-deployment.md index 8f6395f..f1efd7b 100644 --- a/docs/examples/functions/create-template-deployment.md +++ b/docs/examples/functions/create-template-deployment.md @@ -12,6 +12,7 @@ const result = await functions.createTemplateDeployment({ repository: '', owner: '', rootDirectory: '', - version: '', + type: sdk.TemplateReferenceType.Commit, + reference: '', activate: false // optional }); diff --git a/docs/examples/functions/create-vcs-deployment.md b/docs/examples/functions/create-vcs-deployment.md index 0aabfcf..c648625 100644 --- a/docs/examples/functions/create-vcs-deployment.md +++ b/docs/examples/functions/create-vcs-deployment.md @@ -9,7 +9,7 @@ const functions = new sdk.Functions(client); const result = await functions.createVcsDeployment({ functionId: '', - type: sdk.VCSDeploymentType.Branch, + type: sdk.VCSReferenceType.Branch, reference: '', activate: false // optional }); diff --git a/docs/examples/functions/create.md b/docs/examples/functions/create.md index d9f21ff..37ac89d 100644 --- a/docs/examples/functions/create.md +++ b/docs/examples/functions/create.md @@ -10,7 +10,7 @@ const functions = new sdk.Functions(client); const result = await functions.create({ functionId: '', name: '', - runtime: sdk..Node145, + runtime: sdk.Runtime.Node145, execute: ["any"], // optional events: [], // optional schedule: '', // optional diff --git a/docs/examples/functions/update.md b/docs/examples/functions/update.md index 8ed2828..60653b5 100644 --- a/docs/examples/functions/update.md +++ b/docs/examples/functions/update.md @@ -10,7 +10,7 @@ const functions = new sdk.Functions(client); const result = await functions.update({ functionId: '', name: '', - runtime: sdk..Node145, // optional + runtime: sdk.Runtime.Node145, // optional execute: ["any"], // optional events: [], // optional schedule: '', // optional diff --git a/docs/examples/health/get-failed-jobs.md b/docs/examples/health/get-failed-jobs.md index bf77aa2..32c0342 100644 --- a/docs/examples/health/get-failed-jobs.md +++ b/docs/examples/health/get-failed-jobs.md @@ -8,6 +8,6 @@ const client = new sdk.Client() const health = new sdk.Health(client); const result = await health.getFailedJobs({ - name: sdk..V1Database, + name: sdk.Name.V1Database, threshold: null // optional }); diff --git a/docs/examples/sites/create-template-deployment.md b/docs/examples/sites/create-template-deployment.md index 7dfb437..3728f7f 100644 --- a/docs/examples/sites/create-template-deployment.md +++ b/docs/examples/sites/create-template-deployment.md @@ -12,6 +12,7 @@ const result = await sites.createTemplateDeployment({ repository: '', owner: '', rootDirectory: '', - version: '', + type: sdk.TemplateReferenceType.Branch, + reference: '', activate: false // optional }); diff --git a/docs/examples/sites/create-vcs-deployment.md b/docs/examples/sites/create-vcs-deployment.md index 7f7c219..95cefea 100644 --- a/docs/examples/sites/create-vcs-deployment.md +++ b/docs/examples/sites/create-vcs-deployment.md @@ -9,7 +9,7 @@ const sites = new sdk.Sites(client); const result = await sites.createVcsDeployment({ siteId: '', - type: sdk.VCSDeploymentType.Branch, + type: sdk.VCSReferenceType.Branch, reference: '', activate: false // optional }); diff --git a/docs/examples/sites/create.md b/docs/examples/sites/create.md index 25c6715..397d2d3 100644 --- a/docs/examples/sites/create.md +++ b/docs/examples/sites/create.md @@ -10,15 +10,15 @@ const sites = new sdk.Sites(client); const result = await sites.create({ siteId: '', name: '', - framework: sdk..Analog, - buildRuntime: sdk..Node145, + framework: sdk.Framework.Analog, + buildRuntime: sdk.BuildRuntime.Node145, enabled: false, // optional logging: false, // optional timeout: 1, // optional installCommand: '', // optional buildCommand: '', // optional outputDirectory: '', // optional - adapter: sdk..Static, // optional + adapter: sdk.Adapter.Static, // optional installationId: '', // optional fallbackFile: '', // optional providerRepositoryId: '', // optional diff --git a/docs/examples/sites/update.md b/docs/examples/sites/update.md index 5cb52f7..1a919f5 100644 --- a/docs/examples/sites/update.md +++ b/docs/examples/sites/update.md @@ -10,15 +10,15 @@ const sites = new sdk.Sites(client); const result = await sites.update({ siteId: '', name: '', - framework: sdk..Analog, + framework: sdk.Framework.Analog, enabled: false, // optional logging: false, // optional timeout: 1, // optional installCommand: '', // optional buildCommand: '', // optional outputDirectory: '', // optional - buildRuntime: sdk..Node145, // optional - adapter: sdk..Static, // optional + buildRuntime: sdk.BuildRuntime.Node145, // optional + adapter: sdk.Adapter.Static, // optional fallbackFile: '', // optional installationId: '', // optional providerRepositoryId: '', // optional diff --git a/docs/examples/storage/create-bucket.md b/docs/examples/storage/create-bucket.md index b47d2c8..7ef4bef 100644 --- a/docs/examples/storage/create-bucket.md +++ b/docs/examples/storage/create-bucket.md @@ -15,7 +15,8 @@ const result = await storage.createBucket({ enabled: false, // optional maximumFileSize: 1, // optional allowedFileExtensions: [], // optional - compression: sdk..None, // optional + compression: sdk.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 9535914..d528a77 100644 --- a/docs/examples/storage/update-bucket.md +++ b/docs/examples/storage/update-bucket.md @@ -15,7 +15,8 @@ const result = await storage.updateBucket({ enabled: false, // optional maximumFileSize: 1, // optional allowedFileExtensions: [], // optional - compression: sdk..None, // optional + compression: sdk.Compression.None, // optional encryption: false, // optional - antivirus: false // optional + antivirus: false, // optional + transformations: false // optional }); diff --git a/package.json b/package.json index f03f913..11518e3 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "node-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": "20.3.0", + "version": "20.4.0", "license": "BSD-3-Clause", "main": "dist/index.js", "type": "commonjs", diff --git a/src/client.ts b/src/client.ts index 0e9d8e4..b17650d 100644 --- a/src/client.ts +++ b/src/client.ts @@ -33,7 +33,7 @@ class AppwriteException extends Error { } function getUserAgent() { - let ua = 'AppwriteNodeJSSDK/20.3.0'; + let ua = 'AppwriteNodeJSSDK/20.4.0'; // `process` is a global in Node.js, but not fully available in all runtimes. const platform: string[] = []; @@ -82,7 +82,7 @@ class Client { 'x-sdk-name': 'Node.js', 'x-sdk-platform': 'server', 'x-sdk-language': 'nodejs', - 'x-sdk-version': '20.3.0', + 'x-sdk-version': '20.4.0', 'user-agent' : getUserAgent(), 'X-Appwrite-Response-Format': '1.8.0', }; diff --git a/src/enums/build-runtime.ts b/src/enums/build-runtime.ts index 9468229..25dca77 100644 --- a/src/enums/build-runtime.ts +++ b/src/enums/build-runtime.ts @@ -37,6 +37,7 @@ export enum BuildRuntime { Dart33 = 'dart-3.3', Dart35 = 'dart-3.5', Dart38 = 'dart-3.8', + Dart39 = 'dart-3.9', Dotnet60 = 'dotnet-6.0', Dotnet70 = 'dotnet-7.0', Dotnet80 = 'dotnet-8.0', @@ -64,4 +65,5 @@ export enum BuildRuntime { Flutter327 = 'flutter-3.27', Flutter329 = 'flutter-3.29', Flutter332 = 'flutter-3.32', + Flutter335 = 'flutter-3.35', } \ No newline at end of file diff --git a/src/enums/output.ts b/src/enums/output.ts new file mode 100644 index 0000000..c339a51 --- /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/runtime.ts b/src/enums/runtime.ts index 6ea5c33..ecdc452 100644 --- a/src/enums/runtime.ts +++ b/src/enums/runtime.ts @@ -37,6 +37,7 @@ export enum Runtime { Dart33 = 'dart-3.3', Dart35 = 'dart-3.5', Dart38 = 'dart-3.8', + Dart39 = 'dart-3.9', Dotnet60 = 'dotnet-6.0', Dotnet70 = 'dotnet-7.0', Dotnet80 = 'dotnet-8.0', @@ -64,4 +65,5 @@ export enum Runtime { Flutter327 = 'flutter-3.27', Flutter329 = 'flutter-3.29', Flutter332 = 'flutter-3.32', + Flutter335 = 'flutter-3.35', } \ No newline at end of file diff --git a/src/enums/template-reference-type.ts b/src/enums/template-reference-type.ts new file mode 100644 index 0000000..c714c2c --- /dev/null +++ b/src/enums/template-reference-type.ts @@ -0,0 +1,5 @@ +export enum TemplateReferenceType { + Branch = 'branch', + Commit = 'commit', + Tag = 'tag', +} \ No newline at end of file diff --git a/src/enums/theme.ts b/src/enums/theme.ts new file mode 100644 index 0000000..5e823a9 --- /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 0000000..207298a --- /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/enums/vcs-deployment-type.ts b/src/enums/vcs-reference-type.ts similarity index 66% rename from src/enums/vcs-deployment-type.ts rename to src/enums/vcs-reference-type.ts index e685a49..cb5270f 100644 --- a/src/enums/vcs-deployment-type.ts +++ b/src/enums/vcs-reference-type.ts @@ -1,4 +1,4 @@ -export enum VCSDeploymentType { +export enum VCSReferenceType { Branch = 'branch', Commit = 'commit', Tag = 'tag', diff --git a/src/index.ts b/src/index.ts index e29cca2..7dbc903 100644 --- a/src/index.ts +++ b/src/index.ts @@ -25,11 +25,15 @@ 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 { RelationshipType } from './enums/relationship-type'; export { RelationMutate } from './enums/relation-mutate'; export { IndexType } from './enums/index-type'; export { Runtime } from './enums/runtime'; -export { VCSDeploymentType } from './enums/vcs-deployment-type'; +export { TemplateReferenceType } from './enums/template-reference-type'; +export { VCSReferenceType } from './enums/vcs-reference-type'; export { DeploymentDownloadType } from './enums/deployment-download-type'; export { ExecutionMethod } from './enums/execution-method'; export { Name } from './enums/name'; diff --git a/src/models.ts b/src/models.ts index b168b24..7c27b05 100644 --- a/src/models.ts +++ b/src/models.ts @@ -2719,6 +2719,10 @@ export namespace Models { * Virus scanning is enabled. */ antivirus: boolean; + /** + * Image transformations are enabled. + */ + transformations: boolean; } /** diff --git a/src/services/avatars.ts b/src/services/avatars.ts index 42013a1..68e83d1 100644 --- a/src/services/avatars.ts +++ b/src/services/avatars.ts @@ -4,6 +4,9 @@ import type { Models } from '../models'; 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 { client: Client; @@ -549,4 +552,201 @@ export class Avatars { '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 {Promise} + */ + 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); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload, + 'arrayBuffer' + ); + } } diff --git a/src/services/functions.ts b/src/services/functions.ts index 18b6aba..aa14dcd 100644 --- a/src/services/functions.ts +++ b/src/services/functions.ts @@ -2,7 +2,8 @@ import { AppwriteException, Client, type Payload, UploadProgress } from '../clie import type { Models } from '../models'; import { Runtime } from '../enums/runtime'; -import { VCSDeploymentType } from '../enums/vcs-deployment-type'; +import { TemplateReferenceType } from '../enums/template-reference-type'; +import { VCSReferenceType } from '../enums/vcs-reference-type'; import { DeploymentDownloadType } from '../enums/deployment-download-type'; import { ExecutionMethod } from '../enums/execution-method'; @@ -898,12 +899,13 @@ export class Functions { * @param {string} params.repository - Repository name of the template. * @param {string} params.owner - The name of the owner of the template. * @param {string} params.rootDirectory - Path to function code in the template repo. - * @param {string} params.version - Version (tag) for the repo linked to the function template. + * @param {TemplateReferenceType} params.type - Type for the reference provided. Can be commit, branch, or tag + * @param {string} params.reference - Reference value, can be a commit hash, branch name, or release tag * @param {boolean} params.activate - Automatically activate the deployment when it is finished building. * @throws {AppwriteException} * @returns {Promise} */ - createTemplateDeployment(params: { functionId: string, repository: string, owner: string, rootDirectory: string, version: string, activate?: boolean }): Promise; + createTemplateDeployment(params: { functionId: string, repository: string, owner: string, rootDirectory: string, type: TemplateReferenceType, reference: string, activate?: boolean }): Promise; /** * Create a deployment based on a template. * @@ -913,29 +915,31 @@ export class Functions { * @param {string} repository - Repository name of the template. * @param {string} owner - The name of the owner of the template. * @param {string} rootDirectory - Path to function code in the template repo. - * @param {string} version - Version (tag) for the repo linked to the function template. + * @param {TemplateReferenceType} type - Type for the reference provided. Can be commit, branch, or tag + * @param {string} reference - Reference value, can be a commit hash, branch name, or release tag * @param {boolean} activate - Automatically activate the deployment when it is finished building. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createTemplateDeployment(functionId: string, repository: string, owner: string, rootDirectory: string, version: string, activate?: boolean): Promise; + createTemplateDeployment(functionId: string, repository: string, owner: string, rootDirectory: string, type: TemplateReferenceType, reference: string, activate?: boolean): Promise; createTemplateDeployment( - paramsOrFirst: { functionId: string, repository: string, owner: string, rootDirectory: string, version: string, activate?: boolean } | string, - ...rest: [(string)?, (string)?, (string)?, (string)?, (boolean)?] + paramsOrFirst: { functionId: string, repository: string, owner: string, rootDirectory: string, type: TemplateReferenceType, reference: string, activate?: boolean } | string, + ...rest: [(string)?, (string)?, (string)?, (TemplateReferenceType)?, (string)?, (boolean)?] ): Promise { - let params: { functionId: string, repository: string, owner: string, rootDirectory: string, version: string, activate?: boolean }; + let params: { functionId: string, repository: string, owner: string, rootDirectory: string, type: TemplateReferenceType, reference: string, activate?: boolean }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { functionId: string, repository: string, owner: string, rootDirectory: string, version: string, activate?: boolean }; + params = (paramsOrFirst || {}) as { functionId: string, repository: string, owner: string, rootDirectory: string, type: TemplateReferenceType, reference: string, activate?: boolean }; } else { params = { functionId: paramsOrFirst as string, repository: rest[0] as string, owner: rest[1] as string, rootDirectory: rest[2] as string, - version: rest[3] as string, - activate: rest[4] as boolean + type: rest[3] as TemplateReferenceType, + reference: rest[4] as string, + activate: rest[5] as boolean }; } @@ -943,7 +947,8 @@ export class Functions { const repository = params.repository; const owner = params.owner; const rootDirectory = params.rootDirectory; - const version = params.version; + const type = params.type; + const reference = params.reference; const activate = params.activate; if (typeof functionId === 'undefined') { @@ -958,8 +963,11 @@ export class Functions { if (typeof rootDirectory === 'undefined') { throw new AppwriteException('Missing required parameter: "rootDirectory"'); } - if (typeof version === 'undefined') { - throw new AppwriteException('Missing required parameter: "version"'); + if (typeof type === 'undefined') { + throw new AppwriteException('Missing required parameter: "type"'); + } + if (typeof reference === 'undefined') { + throw new AppwriteException('Missing required parameter: "reference"'); } const apiPath = '/functions/{functionId}/deployments/template'.replace('{functionId}', functionId); @@ -973,8 +981,11 @@ export class Functions { if (typeof rootDirectory !== 'undefined') { payload['rootDirectory'] = rootDirectory; } - if (typeof version !== 'undefined') { - payload['version'] = version; + if (typeof type !== 'undefined') { + payload['type'] = type; + } + if (typeof reference !== 'undefined') { + payload['reference'] = reference; } if (typeof activate !== 'undefined') { payload['activate'] = activate; @@ -999,39 +1010,39 @@ export class Functions { * This endpoint lets you create deployment from a branch, commit, or a tag. * * @param {string} params.functionId - Function ID. - * @param {VCSDeploymentType} params.type - Type of reference passed. Allowed values are: branch, commit + * @param {VCSReferenceType} params.type - Type of reference passed. Allowed values are: branch, commit * @param {string} params.reference - VCS reference to create deployment from. Depending on type this can be: branch name, commit hash * @param {boolean} params.activate - Automatically activate the deployment when it is finished building. * @throws {AppwriteException} * @returns {Promise} */ - createVcsDeployment(params: { functionId: string, type: VCSDeploymentType, reference: string, activate?: boolean }): Promise; + createVcsDeployment(params: { functionId: string, type: VCSReferenceType, reference: string, activate?: boolean }): Promise; /** * Create a deployment when a function is connected to VCS. * * This endpoint lets you create deployment from a branch, commit, or a tag. * * @param {string} functionId - Function ID. - * @param {VCSDeploymentType} type - Type of reference passed. Allowed values are: branch, commit + * @param {VCSReferenceType} type - Type of reference passed. Allowed values are: branch, commit * @param {string} reference - VCS reference to create deployment from. Depending on type this can be: branch name, commit hash * @param {boolean} activate - Automatically activate the deployment when it is finished building. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createVcsDeployment(functionId: string, type: VCSDeploymentType, reference: string, activate?: boolean): Promise; + createVcsDeployment(functionId: string, type: VCSReferenceType, reference: string, activate?: boolean): Promise; createVcsDeployment( - paramsOrFirst: { functionId: string, type: VCSDeploymentType, reference: string, activate?: boolean } | string, - ...rest: [(VCSDeploymentType)?, (string)?, (boolean)?] + paramsOrFirst: { functionId: string, type: VCSReferenceType, reference: string, activate?: boolean } | string, + ...rest: [(VCSReferenceType)?, (string)?, (boolean)?] ): Promise { - let params: { functionId: string, type: VCSDeploymentType, reference: string, activate?: boolean }; + let params: { functionId: string, type: VCSReferenceType, reference: string, activate?: boolean }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { functionId: string, type: VCSDeploymentType, reference: string, activate?: boolean }; + params = (paramsOrFirst || {}) as { functionId: string, type: VCSReferenceType, reference: string, activate?: boolean }; } else { params = { functionId: paramsOrFirst as string, - type: rest[0] as VCSDeploymentType, + type: rest[0] as VCSReferenceType, reference: rest[1] as string, activate: rest[2] as boolean }; diff --git a/src/services/sites.ts b/src/services/sites.ts index d12b122..3afc7e3 100644 --- a/src/services/sites.ts +++ b/src/services/sites.ts @@ -4,7 +4,8 @@ import type { Models } from '../models'; import { Framework } from '../enums/framework'; import { BuildRuntime } from '../enums/build-runtime'; import { Adapter } from '../enums/adapter'; -import { VCSDeploymentType } from '../enums/vcs-deployment-type'; +import { TemplateReferenceType } from '../enums/template-reference-type'; +import { VCSReferenceType } from '../enums/vcs-reference-type'; import { DeploymentDownloadType } from '../enums/deployment-download-type'; export class Sites { @@ -728,7 +729,7 @@ export class Sites { } /** - * 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. + * 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 site's deployment to use your new deployment ID. * * @param {string} params.siteId - Site ID. * @param {File} params.code - Gzip file with your code package. When used with the Appwrite CLI, pass the path to your code directory, and the CLI will automatically package your code. Use a path that is within the current directory. @@ -741,7 +742,7 @@ export class Sites { */ createDeployment(params: { siteId: string, code: File, activate: boolean, installCommand?: string, buildCommand?: string, outputDirectory?: string , onProgress?: (progress: UploadProgress) => void }): Promise; /** - * 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. + * 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 site's deployment to use your new deployment ID. * * @param {string} siteId - Site ID. * @param {File} code - Gzip file with your code package. When used with the Appwrite CLI, pass the path to your code directory, and the CLI will automatically package your code. Use a path that is within the current directory. @@ -897,12 +898,13 @@ export class Sites { * @param {string} params.repository - Repository name of the template. * @param {string} params.owner - The name of the owner of the template. * @param {string} params.rootDirectory - Path to site code in the template repo. - * @param {string} params.version - Version (tag) for the repo linked to the site template. + * @param {TemplateReferenceType} params.type - Type for the reference provided. Can be commit, branch, or tag + * @param {string} params.reference - Reference value, can be a commit hash, branch name, or release tag * @param {boolean} params.activate - Automatically activate the deployment when it is finished building. * @throws {AppwriteException} * @returns {Promise} */ - createTemplateDeployment(params: { siteId: string, repository: string, owner: string, rootDirectory: string, version: string, activate?: boolean }): Promise; + createTemplateDeployment(params: { siteId: string, repository: string, owner: string, rootDirectory: string, type: TemplateReferenceType, reference: string, activate?: boolean }): Promise; /** * Create a deployment based on a template. * @@ -912,29 +914,31 @@ export class Sites { * @param {string} repository - Repository name of the template. * @param {string} owner - The name of the owner of the template. * @param {string} rootDirectory - Path to site code in the template repo. - * @param {string} version - Version (tag) for the repo linked to the site template. + * @param {TemplateReferenceType} type - Type for the reference provided. Can be commit, branch, or tag + * @param {string} reference - Reference value, can be a commit hash, branch name, or release tag * @param {boolean} activate - Automatically activate the deployment when it is finished building. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createTemplateDeployment(siteId: string, repository: string, owner: string, rootDirectory: string, version: string, activate?: boolean): Promise; + createTemplateDeployment(siteId: string, repository: string, owner: string, rootDirectory: string, type: TemplateReferenceType, reference: string, activate?: boolean): Promise; createTemplateDeployment( - paramsOrFirst: { siteId: string, repository: string, owner: string, rootDirectory: string, version: string, activate?: boolean } | string, - ...rest: [(string)?, (string)?, (string)?, (string)?, (boolean)?] + paramsOrFirst: { siteId: string, repository: string, owner: string, rootDirectory: string, type: TemplateReferenceType, reference: string, activate?: boolean } | string, + ...rest: [(string)?, (string)?, (string)?, (TemplateReferenceType)?, (string)?, (boolean)?] ): Promise { - let params: { siteId: string, repository: string, owner: string, rootDirectory: string, version: string, activate?: boolean }; + let params: { siteId: string, repository: string, owner: string, rootDirectory: string, type: TemplateReferenceType, reference: string, activate?: boolean }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { siteId: string, repository: string, owner: string, rootDirectory: string, version: string, activate?: boolean }; + params = (paramsOrFirst || {}) as { siteId: string, repository: string, owner: string, rootDirectory: string, type: TemplateReferenceType, reference: string, activate?: boolean }; } else { params = { siteId: paramsOrFirst as string, repository: rest[0] as string, owner: rest[1] as string, rootDirectory: rest[2] as string, - version: rest[3] as string, - activate: rest[4] as boolean + type: rest[3] as TemplateReferenceType, + reference: rest[4] as string, + activate: rest[5] as boolean }; } @@ -942,7 +946,8 @@ export class Sites { const repository = params.repository; const owner = params.owner; const rootDirectory = params.rootDirectory; - const version = params.version; + const type = params.type; + const reference = params.reference; const activate = params.activate; if (typeof siteId === 'undefined') { @@ -957,8 +962,11 @@ export class Sites { if (typeof rootDirectory === 'undefined') { throw new AppwriteException('Missing required parameter: "rootDirectory"'); } - if (typeof version === 'undefined') { - throw new AppwriteException('Missing required parameter: "version"'); + if (typeof type === 'undefined') { + throw new AppwriteException('Missing required parameter: "type"'); + } + if (typeof reference === 'undefined') { + throw new AppwriteException('Missing required parameter: "reference"'); } const apiPath = '/sites/{siteId}/deployments/template'.replace('{siteId}', siteId); @@ -972,8 +980,11 @@ export class Sites { if (typeof rootDirectory !== 'undefined') { payload['rootDirectory'] = rootDirectory; } - if (typeof version !== 'undefined') { - payload['version'] = version; + if (typeof type !== 'undefined') { + payload['type'] = type; + } + if (typeof reference !== 'undefined') { + payload['reference'] = reference; } if (typeof activate !== 'undefined') { payload['activate'] = activate; @@ -998,39 +1009,39 @@ export class Sites { * This endpoint lets you create deployment from a branch, commit, or a tag. * * @param {string} params.siteId - Site ID. - * @param {VCSDeploymentType} params.type - Type of reference passed. Allowed values are: branch, commit + * @param {VCSReferenceType} params.type - Type of reference passed. Allowed values are: branch, commit * @param {string} params.reference - VCS reference to create deployment from. Depending on type this can be: branch name, commit hash * @param {boolean} params.activate - Automatically activate the deployment when it is finished building. * @throws {AppwriteException} * @returns {Promise} */ - createVcsDeployment(params: { siteId: string, type: VCSDeploymentType, reference: string, activate?: boolean }): Promise; + createVcsDeployment(params: { siteId: string, type: VCSReferenceType, reference: string, activate?: boolean }): Promise; /** * Create a deployment when a site is connected to VCS. * * This endpoint lets you create deployment from a branch, commit, or a tag. * * @param {string} siteId - Site ID. - * @param {VCSDeploymentType} type - Type of reference passed. Allowed values are: branch, commit + * @param {VCSReferenceType} type - Type of reference passed. Allowed values are: branch, commit * @param {string} reference - VCS reference to create deployment from. Depending on type this can be: branch name, commit hash * @param {boolean} activate - Automatically activate the deployment when it is finished building. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createVcsDeployment(siteId: string, type: VCSDeploymentType, reference: string, activate?: boolean): Promise; + createVcsDeployment(siteId: string, type: VCSReferenceType, reference: string, activate?: boolean): Promise; createVcsDeployment( - paramsOrFirst: { siteId: string, type: VCSDeploymentType, reference: string, activate?: boolean } | string, - ...rest: [(VCSDeploymentType)?, (string)?, (boolean)?] + paramsOrFirst: { siteId: string, type: VCSReferenceType, reference: string, activate?: boolean } | string, + ...rest: [(VCSReferenceType)?, (string)?, (boolean)?] ): Promise { - let params: { siteId: string, type: VCSDeploymentType, reference: string, activate?: boolean }; + let params: { siteId: string, type: VCSReferenceType, reference: string, activate?: boolean }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { siteId: string, type: VCSDeploymentType, reference: string, activate?: boolean }; + params = (paramsOrFirst || {}) as { siteId: string, type: VCSReferenceType, reference: string, activate?: boolean }; } else { params = { siteId: paramsOrFirst as string, - type: rest[0] as VCSDeploymentType, + type: rest[0] as VCSReferenceType, reference: rest[1] as string, activate: rest[2] as boolean }; diff --git a/src/services/storage.ts b/src/services/storage.ts index 4f44d25..3a115aa 100644 --- a/src/services/storage.ts +++ b/src/services/storage.ts @@ -15,7 +15,7 @@ export class Storage { /** * Get a list of all the storage buckets. You can use the query params to filter your results. * - * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: enabled, name, fileSecurity, maximumFileSize, encryption, antivirus + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: enabled, name, fileSecurity, maximumFileSize, encryption, antivirus, transformations * @param {string} params.search - Search term to filter your list results. Max length: 256 chars. * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. * @throws {AppwriteException} @@ -25,7 +25,7 @@ export class Storage { /** * Get a list of all the storage buckets. You can use the query params to filter your results. * - * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: enabled, name, fileSecurity, maximumFileSize, encryption, antivirus + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: enabled, name, fileSecurity, maximumFileSize, encryption, antivirus, transformations * @param {string} search - Search term to filter your list results. Max length: 256 chars. * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. * @throws {AppwriteException} @@ -91,10 +91,11 @@ export class Storage { * @param {Compression} params.compression - Compression algorithm choosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled * @param {boolean} params.encryption - Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled * @param {boolean} params.antivirus - Is virus scanning enabled? For file size above 20MB AntiVirus scanning is skipped even if it's enabled + * @param {boolean} params.transformations - Are image transformations enabled? * @throws {AppwriteException} * @returns {Promise} */ - createBucket(params: { bucketId: string, name: string, permissions?: string[], fileSecurity?: boolean, enabled?: boolean, maximumFileSize?: number, allowedFileExtensions?: string[], compression?: Compression, encryption?: boolean, antivirus?: boolean }): Promise; + createBucket(params: { bucketId: string, name: string, permissions?: string[], fileSecurity?: boolean, enabled?: boolean, maximumFileSize?: number, allowedFileExtensions?: string[], compression?: Compression, encryption?: boolean, antivirus?: boolean, transformations?: boolean }): Promise; /** * Create a new storage bucket. * @@ -108,19 +109,20 @@ export class Storage { * @param {Compression} compression - Compression algorithm choosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled * @param {boolean} encryption - Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled * @param {boolean} antivirus - Is virus scanning enabled? For file size above 20MB AntiVirus scanning is skipped even if it's enabled + * @param {boolean} transformations - Are image transformations enabled? * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createBucket(bucketId: string, name: string, permissions?: string[], fileSecurity?: boolean, enabled?: boolean, maximumFileSize?: number, allowedFileExtensions?: string[], compression?: Compression, encryption?: boolean, antivirus?: boolean): Promise; + createBucket(bucketId: string, name: string, permissions?: string[], fileSecurity?: boolean, enabled?: boolean, maximumFileSize?: number, allowedFileExtensions?: string[], compression?: Compression, encryption?: boolean, antivirus?: boolean, transformations?: boolean): Promise; createBucket( - paramsOrFirst: { bucketId: string, name: string, permissions?: string[], fileSecurity?: boolean, enabled?: boolean, maximumFileSize?: number, allowedFileExtensions?: string[], compression?: Compression, encryption?: boolean, antivirus?: boolean } | string, - ...rest: [(string)?, (string[])?, (boolean)?, (boolean)?, (number)?, (string[])?, (Compression)?, (boolean)?, (boolean)?] + paramsOrFirst: { bucketId: string, name: string, permissions?: string[], fileSecurity?: boolean, enabled?: boolean, maximumFileSize?: number, allowedFileExtensions?: string[], compression?: Compression, encryption?: boolean, antivirus?: boolean, transformations?: boolean } | string, + ...rest: [(string)?, (string[])?, (boolean)?, (boolean)?, (number)?, (string[])?, (Compression)?, (boolean)?, (boolean)?, (boolean)?] ): Promise { - let params: { bucketId: string, name: string, permissions?: string[], fileSecurity?: boolean, enabled?: boolean, maximumFileSize?: number, allowedFileExtensions?: string[], compression?: Compression, encryption?: boolean, antivirus?: boolean }; + let params: { bucketId: string, name: string, permissions?: string[], fileSecurity?: boolean, enabled?: boolean, maximumFileSize?: number, allowedFileExtensions?: string[], compression?: Compression, encryption?: boolean, antivirus?: boolean, transformations?: boolean }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { bucketId: string, name: string, permissions?: string[], fileSecurity?: boolean, enabled?: boolean, maximumFileSize?: number, allowedFileExtensions?: string[], compression?: Compression, encryption?: boolean, antivirus?: boolean }; + params = (paramsOrFirst || {}) as { bucketId: string, name: string, permissions?: string[], fileSecurity?: boolean, enabled?: boolean, maximumFileSize?: number, allowedFileExtensions?: string[], compression?: Compression, encryption?: boolean, antivirus?: boolean, transformations?: boolean }; } else { params = { bucketId: paramsOrFirst as string, @@ -132,7 +134,8 @@ export class Storage { allowedFileExtensions: rest[5] as string[], compression: rest[6] as Compression, encryption: rest[7] as boolean, - antivirus: rest[8] as boolean + antivirus: rest[8] as boolean, + transformations: rest[9] as boolean }; } @@ -146,6 +149,7 @@ export class Storage { const compression = params.compression; const encryption = params.encryption; const antivirus = params.antivirus; + const transformations = params.transformations; if (typeof bucketId === 'undefined') { throw new AppwriteException('Missing required parameter: "bucketId"'); @@ -186,6 +190,9 @@ export class Storage { if (typeof antivirus !== 'undefined') { payload['antivirus'] = antivirus; } + if (typeof transformations !== 'undefined') { + payload['transformations'] = transformations; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -264,10 +271,11 @@ export class Storage { * @param {Compression} params.compression - Compression algorithm choosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled * @param {boolean} params.encryption - Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled * @param {boolean} params.antivirus - Is virus scanning enabled? For file size above 20MB AntiVirus scanning is skipped even if it's enabled + * @param {boolean} params.transformations - Are image transformations enabled? * @throws {AppwriteException} * @returns {Promise} */ - updateBucket(params: { bucketId: string, name: string, permissions?: string[], fileSecurity?: boolean, enabled?: boolean, maximumFileSize?: number, allowedFileExtensions?: string[], compression?: Compression, encryption?: boolean, antivirus?: boolean }): Promise; + updateBucket(params: { bucketId: string, name: string, permissions?: string[], fileSecurity?: boolean, enabled?: boolean, maximumFileSize?: number, allowedFileExtensions?: string[], compression?: Compression, encryption?: boolean, antivirus?: boolean, transformations?: boolean }): Promise; /** * Update a storage bucket by its unique ID. * @@ -281,19 +289,20 @@ export class Storage { * @param {Compression} compression - Compression algorithm choosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled * @param {boolean} encryption - Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled * @param {boolean} antivirus - Is virus scanning enabled? For file size above 20MB AntiVirus scanning is skipped even if it's enabled + * @param {boolean} transformations - Are image transformations enabled? * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateBucket(bucketId: string, name: string, permissions?: string[], fileSecurity?: boolean, enabled?: boolean, maximumFileSize?: number, allowedFileExtensions?: string[], compression?: Compression, encryption?: boolean, antivirus?: boolean): Promise; + updateBucket(bucketId: string, name: string, permissions?: string[], fileSecurity?: boolean, enabled?: boolean, maximumFileSize?: number, allowedFileExtensions?: string[], compression?: Compression, encryption?: boolean, antivirus?: boolean, transformations?: boolean): Promise; updateBucket( - paramsOrFirst: { bucketId: string, name: string, permissions?: string[], fileSecurity?: boolean, enabled?: boolean, maximumFileSize?: number, allowedFileExtensions?: string[], compression?: Compression, encryption?: boolean, antivirus?: boolean } | string, - ...rest: [(string)?, (string[])?, (boolean)?, (boolean)?, (number)?, (string[])?, (Compression)?, (boolean)?, (boolean)?] + paramsOrFirst: { bucketId: string, name: string, permissions?: string[], fileSecurity?: boolean, enabled?: boolean, maximumFileSize?: number, allowedFileExtensions?: string[], compression?: Compression, encryption?: boolean, antivirus?: boolean, transformations?: boolean } | string, + ...rest: [(string)?, (string[])?, (boolean)?, (boolean)?, (number)?, (string[])?, (Compression)?, (boolean)?, (boolean)?, (boolean)?] ): Promise { - let params: { bucketId: string, name: string, permissions?: string[], fileSecurity?: boolean, enabled?: boolean, maximumFileSize?: number, allowedFileExtensions?: string[], compression?: Compression, encryption?: boolean, antivirus?: boolean }; + let params: { bucketId: string, name: string, permissions?: string[], fileSecurity?: boolean, enabled?: boolean, maximumFileSize?: number, allowedFileExtensions?: string[], compression?: Compression, encryption?: boolean, antivirus?: boolean, transformations?: boolean }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { bucketId: string, name: string, permissions?: string[], fileSecurity?: boolean, enabled?: boolean, maximumFileSize?: number, allowedFileExtensions?: string[], compression?: Compression, encryption?: boolean, antivirus?: boolean }; + params = (paramsOrFirst || {}) as { bucketId: string, name: string, permissions?: string[], fileSecurity?: boolean, enabled?: boolean, maximumFileSize?: number, allowedFileExtensions?: string[], compression?: Compression, encryption?: boolean, antivirus?: boolean, transformations?: boolean }; } else { params = { bucketId: paramsOrFirst as string, @@ -305,7 +314,8 @@ export class Storage { allowedFileExtensions: rest[5] as string[], compression: rest[6] as Compression, encryption: rest[7] as boolean, - antivirus: rest[8] as boolean + antivirus: rest[8] as boolean, + transformations: rest[9] as boolean }; } @@ -319,6 +329,7 @@ export class Storage { const compression = params.compression; const encryption = params.encryption; const antivirus = params.antivirus; + const transformations = params.transformations; if (typeof bucketId === 'undefined') { throw new AppwriteException('Missing required parameter: "bucketId"'); @@ -356,6 +367,9 @@ export class Storage { if (typeof antivirus !== 'undefined') { payload['antivirus'] = antivirus; } + if (typeof transformations !== 'undefined') { + payload['transformations'] = transformations; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { diff --git a/src/services/tables-db.ts b/src/services/tables-db.ts index e63cb91..d60e495 100644 --- a/src/services/tables-db.ts +++ b/src/services/tables-db.ts @@ -892,7 +892,7 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.name - Table name. Max length: 128 chars. * @param {string[]} params.permissions - An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). - * @param {boolean} params.rowSecurity - Enables configuring permissions for individual rows. A user needs one of row or table level permissions to access a document. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} params.rowSecurity - Enables configuring permissions for individual rows. A user needs one of row or table-level permissions to access a row. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} params.enabled - Is table enabled? When set to 'disabled', users cannot access the table but Server SDKs with and API key can still read and write to the table. No data is lost when this is toggled. * @throws {AppwriteException} * @returns {Promise} @@ -905,7 +905,7 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} name - Table name. Max length: 128 chars. * @param {string[]} permissions - An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). - * @param {boolean} rowSecurity - Enables configuring permissions for individual rows. A user needs one of row or table level permissions to access a document. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} rowSecurity - Enables configuring permissions for individual rows. A user needs one of row or table-level permissions to access a row. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} enabled - Is table enabled? When set to 'disabled', users cannot access the table but Server SDKs with and API key can still read and write to the table. No data is lost when this is toggled. * @throws {AppwriteException} * @returns {Promise} From 3d6e7dc31353fa1072bbaff8de7fcf424d1578f1 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 28 Nov 2025 19:28:56 +0000 Subject: [PATCH 2/3] fix changelog --- CHANGELOG.md | 5 ++++- package.json | 2 +- src/client.ts | 4 ++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 659f256..2811a06 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,11 @@ # Change Log -## 20.4.0 +## 21.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 ## 20.3.0 diff --git a/package.json b/package.json index 11518e3..e8c6e4e 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "node-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": "20.4.0", + "version": "21.0.0", "license": "BSD-3-Clause", "main": "dist/index.js", "type": "commonjs", diff --git a/src/client.ts b/src/client.ts index b17650d..8a2e397 100644 --- a/src/client.ts +++ b/src/client.ts @@ -33,7 +33,7 @@ class AppwriteException extends Error { } function getUserAgent() { - let ua = 'AppwriteNodeJSSDK/20.4.0'; + let ua = 'AppwriteNodeJSSDK/21.0.0'; // `process` is a global in Node.js, but not fully available in all runtimes. const platform: string[] = []; @@ -82,7 +82,7 @@ class Client { 'x-sdk-name': 'Node.js', 'x-sdk-platform': 'server', 'x-sdk-language': 'nodejs', - 'x-sdk-version': '20.4.0', + 'x-sdk-version': '21.0.0', 'user-agent' : getUserAgent(), 'X-Appwrite-Response-Format': '1.8.0', }; From cfca36dad2bf5eb2dcc80b18101b112f1c70d600 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 1 Dec 2025 13:54:38 +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 60a3898..dc63102 100644 --- a/docs/examples/avatars/get-screenshot.md +++ b/docs/examples/avatars/get-screenshot.md @@ -9,23 +9,26 @@ const avatars = new sdk.Avatars(client); const result = 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: sdk.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: sdk.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: sdk.Output.Jpg // optional }); diff --git a/src/services/account.ts b/src/services/account.ts index 5731f61..26bd2bc 100644 --- a/src/services/account.ts +++ b/src/services/account.ts @@ -811,7 +811,7 @@ export class Account { throw new AppwriteException('Missing required parameter: "factor"'); } - const apiPath = '/account/mfa/challenge'; + const apiPath = '/account/mfa/challenges'; const payload: Payload = {}; if (typeof factor !== 'undefined') { payload['factor'] = factor; @@ -866,7 +866,7 @@ export class Account { throw new AppwriteException('Missing required parameter: "factor"'); } - const apiPath = '/account/mfa/challenge'; + const apiPath = '/account/mfa/challenges'; const payload: Payload = {}; if (typeof factor !== 'undefined') { payload['factor'] = factor; @@ -930,7 +930,7 @@ export class Account { throw new AppwriteException('Missing required parameter: "otp"'); } - const apiPath = '/account/mfa/challenge'; + const apiPath = '/account/mfa/challenges'; const payload: Payload = {}; if (typeof challengeId !== 'undefined') { payload['challengeId'] = challengeId; @@ -996,7 +996,7 @@ export class Account { throw new AppwriteException('Missing required parameter: "otp"'); } - const apiPath = '/account/mfa/challenge'; + const apiPath = '/account/mfa/challenges'; const payload: Payload = {}; if (typeof challengeId !== 'undefined') { payload['challengeId'] = challengeId;