react-native-appwrite 0.9.2 → 0.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/publish.yml +1 -1
- package/CHANGELOG.md +18 -0
- package/README.md +1 -1
- package/dist/cjs/sdk.js +401 -20
- package/dist/cjs/sdk.js.map +1 -1
- package/dist/esm/sdk.js +401 -20
- package/dist/esm/sdk.js.map +1 -1
- package/package.json +1 -1
- package/src/client.ts +4 -2
- package/src/enums/image-format.ts +1 -0
- package/src/services/avatars.ts +331 -20
- package/src/services/databases.ts +4 -0
- package/src/services/storage.ts +155 -8
- package/types/client.d.ts +1 -1
- package/types/enums/image-format.d.ts +2 -1
- package/types/services/avatars.d.ts +136 -7
- package/types/services/databases.d.ts +4 -0
- package/types/services/storage.d.ts +52 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# Change log
|
|
2
2
|
|
|
3
|
+
## 0.10.1
|
|
4
|
+
|
|
5
|
+
* Fix URL based methods like `getFileViewURL`, `getFilePreviewURL` etc. by adding the missing `projectId` to searchParams
|
|
6
|
+
* Add `gif` to ImageFormat enum
|
|
7
|
+
|
|
8
|
+
## 0.10.0
|
|
9
|
+
|
|
10
|
+
* Add generate file URL methods like`getFilePreviewURL`, `getFileViewURL` etc.
|
|
11
|
+
* Update (breaking) existing methods like `getFilePreview` to download the image instead of returning URLs
|
|
12
|
+
|
|
13
|
+
## 0.9.2
|
|
14
|
+
|
|
15
|
+
* Fix `devKeys` by removing credentials from requests when the key is set
|
|
16
|
+
|
|
17
|
+
## 0.9.1
|
|
18
|
+
|
|
19
|
+
* Add `setDevkey` and `upsertDocument` methods
|
|
20
|
+
|
|
3
21
|
## 0.9.0
|
|
4
22
|
|
|
5
23
|
* Add `token` param to `getFilePreview` and `getFileView` for File tokens usage
|
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Appwrite React Native SDK
|
|
2
2
|
|
|
3
3
|

|
|
4
|
-

|
|
5
5
|
[](https://travis-ci.com/appwrite/sdk-generator)
|
|
6
6
|
[](https://twitter.com/appwrite)
|
|
7
7
|
[](https://appwrite.io/discord)
|
package/dist/cjs/sdk.js
CHANGED
|
@@ -100,7 +100,7 @@ class Client {
|
|
|
100
100
|
'x-sdk-name': 'React Native',
|
|
101
101
|
'x-sdk-platform': 'client',
|
|
102
102
|
'x-sdk-language': 'reactnative',
|
|
103
|
-
'x-sdk-version': '0.
|
|
103
|
+
'x-sdk-version': '0.10.1',
|
|
104
104
|
'X-Appwrite-Response-Format': '1.7.0',
|
|
105
105
|
};
|
|
106
106
|
this.realtime = {
|
|
@@ -392,7 +392,7 @@ class Client {
|
|
|
392
392
|
};
|
|
393
393
|
}
|
|
394
394
|
call(method_1, url_1) {
|
|
395
|
-
return __awaiter(this, arguments, void 0, function* (method, url, headers = {}, params = {}) {
|
|
395
|
+
return __awaiter(this, arguments, void 0, function* (method, url, headers = {}, params = {}, responseType = 'json') {
|
|
396
396
|
var _a, _b;
|
|
397
397
|
method = method.toUpperCase();
|
|
398
398
|
headers = Object.assign({}, this.headers, headers);
|
|
@@ -441,6 +441,9 @@ class Client {
|
|
|
441
441
|
if ((_a = response.headers.get('content-type')) === null || _a === void 0 ? void 0 : _a.includes('application/json')) {
|
|
442
442
|
data = yield response.json();
|
|
443
443
|
}
|
|
444
|
+
else if (responseType === 'arrayBuffer') {
|
|
445
|
+
data = yield response.arrayBuffer();
|
|
446
|
+
}
|
|
444
447
|
else {
|
|
445
448
|
data = {
|
|
446
449
|
message: yield response.text()
|
|
@@ -1727,7 +1730,7 @@ class Avatars extends Service {
|
|
|
1727
1730
|
* @param {number} height
|
|
1728
1731
|
* @param {number} quality
|
|
1729
1732
|
* @throws {AppwriteException}
|
|
1730
|
-
* @returns {
|
|
1733
|
+
* @returns {ArrayBuffer}
|
|
1731
1734
|
*/
|
|
1732
1735
|
getBrowser(code, width, height, quality) {
|
|
1733
1736
|
if (typeof code === 'undefined') {
|
|
@@ -1749,7 +1752,7 @@ class Avatars extends Service {
|
|
|
1749
1752
|
for (const [key, value] of Object.entries(Service.flatten(payload))) {
|
|
1750
1753
|
uri.searchParams.append(key, value);
|
|
1751
1754
|
}
|
|
1752
|
-
return uri;
|
|
1755
|
+
return this.client.call('get', uri, {}, payload, 'arrayBuffer');
|
|
1753
1756
|
}
|
|
1754
1757
|
/**
|
|
1755
1758
|
* The credit card endpoint will return you the icon of the credit card
|
|
@@ -1767,7 +1770,7 @@ class Avatars extends Service {
|
|
|
1767
1770
|
* @param {number} height
|
|
1768
1771
|
* @param {number} quality
|
|
1769
1772
|
* @throws {AppwriteException}
|
|
1770
|
-
* @returns {
|
|
1773
|
+
* @returns {ArrayBuffer}
|
|
1771
1774
|
*/
|
|
1772
1775
|
getCreditCard(code, width, height, quality) {
|
|
1773
1776
|
if (typeof code === 'undefined') {
|
|
@@ -1789,7 +1792,7 @@ class Avatars extends Service {
|
|
|
1789
1792
|
for (const [key, value] of Object.entries(Service.flatten(payload))) {
|
|
1790
1793
|
uri.searchParams.append(key, value);
|
|
1791
1794
|
}
|
|
1792
|
-
return uri;
|
|
1795
|
+
return this.client.call('get', uri, {}, payload, 'arrayBuffer');
|
|
1793
1796
|
}
|
|
1794
1797
|
/**
|
|
1795
1798
|
* Use this endpoint to fetch the favorite icon (AKA favicon) of any remote
|
|
@@ -1799,7 +1802,7 @@ class Avatars extends Service {
|
|
|
1799
1802
|
*
|
|
1800
1803
|
* @param {string} url
|
|
1801
1804
|
* @throws {AppwriteException}
|
|
1802
|
-
* @returns {
|
|
1805
|
+
* @returns {ArrayBuffer}
|
|
1803
1806
|
*/
|
|
1804
1807
|
getFavicon(url) {
|
|
1805
1808
|
if (typeof url === 'undefined') {
|
|
@@ -1815,7 +1818,7 @@ class Avatars extends Service {
|
|
|
1815
1818
|
for (const [key, value] of Object.entries(Service.flatten(payload))) {
|
|
1816
1819
|
uri.searchParams.append(key, value);
|
|
1817
1820
|
}
|
|
1818
|
-
return uri;
|
|
1821
|
+
return this.client.call('get', uri, {}, payload, 'arrayBuffer');
|
|
1819
1822
|
}
|
|
1820
1823
|
/**
|
|
1821
1824
|
* You can use this endpoint to show different country flags icons to your
|
|
@@ -1834,7 +1837,7 @@ class Avatars extends Service {
|
|
|
1834
1837
|
* @param {number} height
|
|
1835
1838
|
* @param {number} quality
|
|
1836
1839
|
* @throws {AppwriteException}
|
|
1837
|
-
* @returns {
|
|
1840
|
+
* @returns {ArrayBuffer}
|
|
1838
1841
|
*/
|
|
1839
1842
|
getFlag(code, width, height, quality) {
|
|
1840
1843
|
if (typeof code === 'undefined') {
|
|
@@ -1856,7 +1859,7 @@ class Avatars extends Service {
|
|
|
1856
1859
|
for (const [key, value] of Object.entries(Service.flatten(payload))) {
|
|
1857
1860
|
uri.searchParams.append(key, value);
|
|
1858
1861
|
}
|
|
1859
|
-
return uri;
|
|
1862
|
+
return this.client.call('get', uri, {}, payload, 'arrayBuffer');
|
|
1860
1863
|
}
|
|
1861
1864
|
/**
|
|
1862
1865
|
* Use this endpoint to fetch a remote image URL and crop it to any image size
|
|
@@ -1875,7 +1878,7 @@ class Avatars extends Service {
|
|
|
1875
1878
|
* @param {number} width
|
|
1876
1879
|
* @param {number} height
|
|
1877
1880
|
* @throws {AppwriteException}
|
|
1878
|
-
* @returns {
|
|
1881
|
+
* @returns {ArrayBuffer}
|
|
1879
1882
|
*/
|
|
1880
1883
|
getImage(url, width, height) {
|
|
1881
1884
|
if (typeof url === 'undefined') {
|
|
@@ -1897,7 +1900,7 @@ class Avatars extends Service {
|
|
|
1897
1900
|
for (const [key, value] of Object.entries(Service.flatten(payload))) {
|
|
1898
1901
|
uri.searchParams.append(key, value);
|
|
1899
1902
|
}
|
|
1900
|
-
return uri;
|
|
1903
|
+
return this.client.call('get', uri, {}, payload, 'arrayBuffer');
|
|
1901
1904
|
}
|
|
1902
1905
|
/**
|
|
1903
1906
|
* Use this endpoint to show your user initials avatar icon on your website or
|
|
@@ -1922,7 +1925,7 @@ class Avatars extends Service {
|
|
|
1922
1925
|
* @param {number} height
|
|
1923
1926
|
* @param {string} background
|
|
1924
1927
|
* @throws {AppwriteException}
|
|
1925
|
-
* @returns {
|
|
1928
|
+
* @returns {ArrayBuffer}
|
|
1926
1929
|
*/
|
|
1927
1930
|
getInitials(name, width, height, background) {
|
|
1928
1931
|
const apiPath = '/avatars/initials';
|
|
@@ -1944,7 +1947,7 @@ class Avatars extends Service {
|
|
|
1944
1947
|
for (const [key, value] of Object.entries(Service.flatten(payload))) {
|
|
1945
1948
|
uri.searchParams.append(key, value);
|
|
1946
1949
|
}
|
|
1947
|
-
return uri;
|
|
1950
|
+
return this.client.call('get', uri, {}, payload, 'arrayBuffer');
|
|
1948
1951
|
}
|
|
1949
1952
|
/**
|
|
1950
1953
|
* Converts a given plain text to a QR code image. You can use the query
|
|
@@ -1956,12 +1959,267 @@ class Avatars extends Service {
|
|
|
1956
1959
|
* @param {number} margin
|
|
1957
1960
|
* @param {boolean} download
|
|
1958
1961
|
* @throws {AppwriteException}
|
|
1959
|
-
* @returns {
|
|
1962
|
+
* @returns {ArrayBuffer}
|
|
1960
1963
|
*/
|
|
1961
1964
|
getQR(text, size, margin, download) {
|
|
1962
1965
|
if (typeof text === 'undefined') {
|
|
1963
1966
|
throw new AppwriteException('Missing required parameter: "text"');
|
|
1964
1967
|
}
|
|
1968
|
+
const apiPath = '/avatars/qr';
|
|
1969
|
+
const payload = {};
|
|
1970
|
+
if (typeof text !== 'undefined') {
|
|
1971
|
+
payload['text'] = text;
|
|
1972
|
+
}
|
|
1973
|
+
if (typeof size !== 'undefined') {
|
|
1974
|
+
payload['size'] = size;
|
|
1975
|
+
}
|
|
1976
|
+
if (typeof margin !== 'undefined') {
|
|
1977
|
+
payload['margin'] = margin;
|
|
1978
|
+
}
|
|
1979
|
+
if (typeof download !== 'undefined') {
|
|
1980
|
+
payload['download'] = download;
|
|
1981
|
+
}
|
|
1982
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
1983
|
+
payload['project'] = this.client.config.project;
|
|
1984
|
+
for (const [key, value] of Object.entries(Service.flatten(payload))) {
|
|
1985
|
+
uri.searchParams.append(key, value);
|
|
1986
|
+
}
|
|
1987
|
+
return this.client.call('get', uri, {}, payload, 'arrayBuffer');
|
|
1988
|
+
}
|
|
1989
|
+
/**
|
|
1990
|
+
* You can use this endpoint to show different browser icons to your users.
|
|
1991
|
+
* The code argument receives the browser code as it appears in your user [GET
|
|
1992
|
+
* /account/sessions](https://appwrite.io/docs/references/cloud/client-web/account#getSessions)
|
|
1993
|
+
* endpoint. Use width, height and quality arguments to change the output
|
|
1994
|
+
* settings.
|
|
1995
|
+
*
|
|
1996
|
+
* When one dimension is specified and the other is 0, the image is scaled
|
|
1997
|
+
* with preserved aspect ratio. If both dimensions are 0, the API provides an
|
|
1998
|
+
* image at source quality. If dimensions are not specified, the default size
|
|
1999
|
+
* of image returned is 100x100px.
|
|
2000
|
+
*
|
|
2001
|
+
* @param {Browser} code
|
|
2002
|
+
* @param {number} width
|
|
2003
|
+
* @param {number} height
|
|
2004
|
+
* @param {number} quality
|
|
2005
|
+
* @throws {AppwriteException}
|
|
2006
|
+
* @returns {URL}
|
|
2007
|
+
*/
|
|
2008
|
+
getBrowserURL(code, width, height, quality) {
|
|
2009
|
+
const apiPath = '/avatars/browsers/{code}'.replace('{code}', code);
|
|
2010
|
+
const payload = {};
|
|
2011
|
+
if (typeof width !== 'undefined') {
|
|
2012
|
+
payload['width'] = width;
|
|
2013
|
+
}
|
|
2014
|
+
if (typeof height !== 'undefined') {
|
|
2015
|
+
payload['height'] = height;
|
|
2016
|
+
}
|
|
2017
|
+
if (typeof quality !== 'undefined') {
|
|
2018
|
+
payload['quality'] = quality;
|
|
2019
|
+
}
|
|
2020
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
2021
|
+
payload['project'] = this.client.config.project;
|
|
2022
|
+
for (const [key, value] of Object.entries(Service.flatten(payload))) {
|
|
2023
|
+
uri.searchParams.append(key, value);
|
|
2024
|
+
}
|
|
2025
|
+
return uri;
|
|
2026
|
+
}
|
|
2027
|
+
/**
|
|
2028
|
+
* The credit card endpoint will return you the icon of the credit card
|
|
2029
|
+
* provider you need. Use width, height and quality arguments to change the
|
|
2030
|
+
* output settings.
|
|
2031
|
+
*
|
|
2032
|
+
* When one dimension is specified and the other is 0, the image is scaled
|
|
2033
|
+
* with preserved aspect ratio. If both dimensions are 0, the API provides an
|
|
2034
|
+
* image at source quality. If dimensions are not specified, the default size
|
|
2035
|
+
* of image returned is 100x100px.
|
|
2036
|
+
*
|
|
2037
|
+
*
|
|
2038
|
+
* @param {CreditCard} code
|
|
2039
|
+
* @param {number} width
|
|
2040
|
+
* @param {number} height
|
|
2041
|
+
* @param {number} quality
|
|
2042
|
+
* @throws {AppwriteException}
|
|
2043
|
+
* @returns {URL}
|
|
2044
|
+
*/
|
|
2045
|
+
getCreditCardURL(code, width, height, quality) {
|
|
2046
|
+
const apiPath = '/avatars/credit-cards/{code}'.replace('{code}', code);
|
|
2047
|
+
const payload = {};
|
|
2048
|
+
if (typeof width !== 'undefined') {
|
|
2049
|
+
payload['width'] = width;
|
|
2050
|
+
}
|
|
2051
|
+
if (typeof height !== 'undefined') {
|
|
2052
|
+
payload['height'] = height;
|
|
2053
|
+
}
|
|
2054
|
+
if (typeof quality !== 'undefined') {
|
|
2055
|
+
payload['quality'] = quality;
|
|
2056
|
+
}
|
|
2057
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
2058
|
+
payload['project'] = this.client.config.project;
|
|
2059
|
+
for (const [key, value] of Object.entries(Service.flatten(payload))) {
|
|
2060
|
+
uri.searchParams.append(key, value);
|
|
2061
|
+
}
|
|
2062
|
+
return uri;
|
|
2063
|
+
}
|
|
2064
|
+
/**
|
|
2065
|
+
* Use this endpoint to fetch the favorite icon (AKA favicon) of any remote
|
|
2066
|
+
* website URL.
|
|
2067
|
+
*
|
|
2068
|
+
* This endpoint does not follow HTTP redirects.
|
|
2069
|
+
*
|
|
2070
|
+
* @param {string} url
|
|
2071
|
+
* @throws {AppwriteException}
|
|
2072
|
+
* @returns {URL}
|
|
2073
|
+
*/
|
|
2074
|
+
getFaviconURL(url) {
|
|
2075
|
+
const apiPath = '/avatars/favicon';
|
|
2076
|
+
const payload = {};
|
|
2077
|
+
if (typeof url !== 'undefined') {
|
|
2078
|
+
payload['url'] = url;
|
|
2079
|
+
}
|
|
2080
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
2081
|
+
payload['project'] = this.client.config.project;
|
|
2082
|
+
for (const [key, value] of Object.entries(Service.flatten(payload))) {
|
|
2083
|
+
uri.searchParams.append(key, value);
|
|
2084
|
+
}
|
|
2085
|
+
return uri;
|
|
2086
|
+
}
|
|
2087
|
+
/**
|
|
2088
|
+
* You can use this endpoint to show different country flags icons to your
|
|
2089
|
+
* users. The code argument receives the 2 letter country code. Use width,
|
|
2090
|
+
* height and quality arguments to change the output settings. Country codes
|
|
2091
|
+
* follow the [ISO 3166-1](https://en.wikipedia.org/wiki/ISO_3166-1) standard.
|
|
2092
|
+
*
|
|
2093
|
+
* When one dimension is specified and the other is 0, the image is scaled
|
|
2094
|
+
* with preserved aspect ratio. If both dimensions are 0, the API provides an
|
|
2095
|
+
* image at source quality. If dimensions are not specified, the default size
|
|
2096
|
+
* of image returned is 100x100px.
|
|
2097
|
+
*
|
|
2098
|
+
*
|
|
2099
|
+
* @param {Flag} code
|
|
2100
|
+
* @param {number} width
|
|
2101
|
+
* @param {number} height
|
|
2102
|
+
* @param {number} quality
|
|
2103
|
+
* @throws {AppwriteException}
|
|
2104
|
+
* @returns {URL}
|
|
2105
|
+
*/
|
|
2106
|
+
getFlagURL(code, width, height, quality) {
|
|
2107
|
+
const apiPath = '/avatars/flags/{code}'.replace('{code}', code);
|
|
2108
|
+
const payload = {};
|
|
2109
|
+
if (typeof width !== 'undefined') {
|
|
2110
|
+
payload['width'] = width;
|
|
2111
|
+
}
|
|
2112
|
+
if (typeof height !== 'undefined') {
|
|
2113
|
+
payload['height'] = height;
|
|
2114
|
+
}
|
|
2115
|
+
if (typeof quality !== 'undefined') {
|
|
2116
|
+
payload['quality'] = quality;
|
|
2117
|
+
}
|
|
2118
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
2119
|
+
payload['project'] = this.client.config.project;
|
|
2120
|
+
for (const [key, value] of Object.entries(Service.flatten(payload))) {
|
|
2121
|
+
uri.searchParams.append(key, value);
|
|
2122
|
+
}
|
|
2123
|
+
return uri;
|
|
2124
|
+
}
|
|
2125
|
+
/**
|
|
2126
|
+
* Use this endpoint to fetch a remote image URL and crop it to any image size
|
|
2127
|
+
* you want. This endpoint is very useful if you need to crop and display
|
|
2128
|
+
* remote images in your app or in case you want to make sure a 3rd party
|
|
2129
|
+
* image is properly served using a TLS protocol.
|
|
2130
|
+
*
|
|
2131
|
+
* When one dimension is specified and the other is 0, the image is scaled
|
|
2132
|
+
* with preserved aspect ratio. If both dimensions are 0, the API provides an
|
|
2133
|
+
* image at source quality. If dimensions are not specified, the default size
|
|
2134
|
+
* of image returned is 400x400px.
|
|
2135
|
+
*
|
|
2136
|
+
* This endpoint does not follow HTTP redirects.
|
|
2137
|
+
*
|
|
2138
|
+
* @param {string} url
|
|
2139
|
+
* @param {number} width
|
|
2140
|
+
* @param {number} height
|
|
2141
|
+
* @throws {AppwriteException}
|
|
2142
|
+
* @returns {URL}
|
|
2143
|
+
*/
|
|
2144
|
+
getImageURL(url, width, height) {
|
|
2145
|
+
const apiPath = '/avatars/image';
|
|
2146
|
+
const payload = {};
|
|
2147
|
+
if (typeof url !== 'undefined') {
|
|
2148
|
+
payload['url'] = url;
|
|
2149
|
+
}
|
|
2150
|
+
if (typeof width !== 'undefined') {
|
|
2151
|
+
payload['width'] = width;
|
|
2152
|
+
}
|
|
2153
|
+
if (typeof height !== 'undefined') {
|
|
2154
|
+
payload['height'] = height;
|
|
2155
|
+
}
|
|
2156
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
2157
|
+
payload['project'] = this.client.config.project;
|
|
2158
|
+
for (const [key, value] of Object.entries(Service.flatten(payload))) {
|
|
2159
|
+
uri.searchParams.append(key, value);
|
|
2160
|
+
}
|
|
2161
|
+
return uri;
|
|
2162
|
+
}
|
|
2163
|
+
/**
|
|
2164
|
+
* Use this endpoint to show your user initials avatar icon on your website or
|
|
2165
|
+
* app. By default, this route will try to print your logged-in user name or
|
|
2166
|
+
* email initials. You can also overwrite the user name if you pass the 'name'
|
|
2167
|
+
* parameter. If no name is given and no user is logged, an empty avatar will
|
|
2168
|
+
* be returned.
|
|
2169
|
+
*
|
|
2170
|
+
* You can use the color and background params to change the avatar colors. By
|
|
2171
|
+
* default, a random theme will be selected. The random theme will persist for
|
|
2172
|
+
* the user's initials when reloading the same theme will always return for
|
|
2173
|
+
* the same initials.
|
|
2174
|
+
*
|
|
2175
|
+
* When one dimension is specified and the other is 0, the image is scaled
|
|
2176
|
+
* with preserved aspect ratio. If both dimensions are 0, the API provides an
|
|
2177
|
+
* image at source quality. If dimensions are not specified, the default size
|
|
2178
|
+
* of image returned is 100x100px.
|
|
2179
|
+
*
|
|
2180
|
+
*
|
|
2181
|
+
* @param {string} name
|
|
2182
|
+
* @param {number} width
|
|
2183
|
+
* @param {number} height
|
|
2184
|
+
* @param {string} background
|
|
2185
|
+
* @throws {AppwriteException}
|
|
2186
|
+
* @returns {URL}
|
|
2187
|
+
*/
|
|
2188
|
+
getInitialsURL(name, width, height, background) {
|
|
2189
|
+
const apiPath = '/avatars/initials';
|
|
2190
|
+
const payload = {};
|
|
2191
|
+
if (typeof name !== 'undefined') {
|
|
2192
|
+
payload['name'] = name;
|
|
2193
|
+
}
|
|
2194
|
+
if (typeof width !== 'undefined') {
|
|
2195
|
+
payload['width'] = width;
|
|
2196
|
+
}
|
|
2197
|
+
if (typeof height !== 'undefined') {
|
|
2198
|
+
payload['height'] = height;
|
|
2199
|
+
}
|
|
2200
|
+
if (typeof background !== 'undefined') {
|
|
2201
|
+
payload['background'] = background;
|
|
2202
|
+
}
|
|
2203
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
2204
|
+
payload['project'] = this.client.config.project;
|
|
2205
|
+
for (const [key, value] of Object.entries(Service.flatten(payload))) {
|
|
2206
|
+
uri.searchParams.append(key, value);
|
|
2207
|
+
}
|
|
2208
|
+
return uri;
|
|
2209
|
+
}
|
|
2210
|
+
/**
|
|
2211
|
+
* Converts a given plain text to a QR code image. You can use the query
|
|
2212
|
+
* parameters to change the size and style of the resulting image.
|
|
2213
|
+
*
|
|
2214
|
+
*
|
|
2215
|
+
* @param {string} text
|
|
2216
|
+
* @param {number} size
|
|
2217
|
+
* @param {number} margin
|
|
2218
|
+
* @param {boolean} download
|
|
2219
|
+
* @throws {AppwriteException}
|
|
2220
|
+
* @returns {URL}
|
|
2221
|
+
*/
|
|
2222
|
+
getQRURL(text, size, margin, download) {
|
|
1965
2223
|
const apiPath = '/avatars/qr';
|
|
1966
2224
|
const payload = {};
|
|
1967
2225
|
if (typeof text !== 'undefined') {
|
|
@@ -2087,6 +2345,10 @@ class Databases extends Service {
|
|
|
2087
2345
|
return this.client.call('get', uri, {}, payload);
|
|
2088
2346
|
}
|
|
2089
2347
|
/**
|
|
2348
|
+
* **WARNING: Experimental Feature** - This endpoint is experimental and not
|
|
2349
|
+
* yet officially supported. It may be subject to breaking changes or removal
|
|
2350
|
+
* in future versions.
|
|
2351
|
+
*
|
|
2090
2352
|
* Create or update a Document. Before using this route, you should create a
|
|
2091
2353
|
* new collection resource using either a [server
|
|
2092
2354
|
* integration](https://appwrite.io/docs/server/databases#databasesCreateCollection)
|
|
@@ -2719,7 +2981,7 @@ class Storage extends Service {
|
|
|
2719
2981
|
* @param {string} fileId
|
|
2720
2982
|
* @param {string} token
|
|
2721
2983
|
* @throws {AppwriteException}
|
|
2722
|
-
* @returns {
|
|
2984
|
+
* @returns {ArrayBuffer}
|
|
2723
2985
|
*/
|
|
2724
2986
|
getFileDownload(bucketId, fileId, token) {
|
|
2725
2987
|
if (typeof bucketId === 'undefined') {
|
|
@@ -2738,7 +3000,7 @@ class Storage extends Service {
|
|
|
2738
3000
|
for (const [key, value] of Object.entries(Service.flatten(payload))) {
|
|
2739
3001
|
uri.searchParams.append(key, value);
|
|
2740
3002
|
}
|
|
2741
|
-
return uri;
|
|
3003
|
+
return this.client.call('get', uri, {}, payload, 'arrayBuffer');
|
|
2742
3004
|
}
|
|
2743
3005
|
/**
|
|
2744
3006
|
* Get a file preview image. Currently, this method supports preview for image
|
|
@@ -2762,7 +3024,7 @@ class Storage extends Service {
|
|
|
2762
3024
|
* @param {ImageFormat} output
|
|
2763
3025
|
* @param {string} token
|
|
2764
3026
|
* @throws {AppwriteException}
|
|
2765
|
-
* @returns {
|
|
3027
|
+
* @returns {ArrayBuffer}
|
|
2766
3028
|
*/
|
|
2767
3029
|
getFilePreview(bucketId, fileId, width, height, gravity, quality, borderWidth, borderColor, borderRadius, opacity, rotation, background, output, token) {
|
|
2768
3030
|
if (typeof bucketId === 'undefined') {
|
|
@@ -2814,7 +3076,7 @@ class Storage extends Service {
|
|
|
2814
3076
|
for (const [key, value] of Object.entries(Service.flatten(payload))) {
|
|
2815
3077
|
uri.searchParams.append(key, value);
|
|
2816
3078
|
}
|
|
2817
|
-
return uri;
|
|
3079
|
+
return this.client.call('get', uri, {}, payload, 'arrayBuffer');
|
|
2818
3080
|
}
|
|
2819
3081
|
/**
|
|
2820
3082
|
* Get a file content by its unique ID. This endpoint is similar to the
|
|
@@ -2825,7 +3087,7 @@ class Storage extends Service {
|
|
|
2825
3087
|
* @param {string} fileId
|
|
2826
3088
|
* @param {string} token
|
|
2827
3089
|
* @throws {AppwriteException}
|
|
2828
|
-
* @returns {
|
|
3090
|
+
* @returns {ArrayBuffer}
|
|
2829
3091
|
*/
|
|
2830
3092
|
getFileView(bucketId, fileId, token) {
|
|
2831
3093
|
if (typeof bucketId === 'undefined') {
|
|
@@ -2834,6 +3096,124 @@ class Storage extends Service {
|
|
|
2834
3096
|
if (typeof fileId === 'undefined') {
|
|
2835
3097
|
throw new AppwriteException('Missing required parameter: "fileId"');
|
|
2836
3098
|
}
|
|
3099
|
+
const apiPath = '/storage/buckets/{bucketId}/files/{fileId}/view'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
|
|
3100
|
+
const payload = {};
|
|
3101
|
+
if (typeof token !== 'undefined') {
|
|
3102
|
+
payload['token'] = token;
|
|
3103
|
+
}
|
|
3104
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
3105
|
+
payload['project'] = this.client.config.project;
|
|
3106
|
+
for (const [key, value] of Object.entries(Service.flatten(payload))) {
|
|
3107
|
+
uri.searchParams.append(key, value);
|
|
3108
|
+
}
|
|
3109
|
+
return this.client.call('get', uri, {}, payload, 'arrayBuffer');
|
|
3110
|
+
}
|
|
3111
|
+
/**
|
|
3112
|
+
* Get a file content by its unique ID. The endpoint response return with a
|
|
3113
|
+
* 'Content-Disposition: attachment' header that tells the browser to start
|
|
3114
|
+
* downloading the file to user downloads directory.
|
|
3115
|
+
*
|
|
3116
|
+
* @param {string} bucketId
|
|
3117
|
+
* @param {string} fileId
|
|
3118
|
+
* @param {string} token
|
|
3119
|
+
* @throws {AppwriteException}
|
|
3120
|
+
* @returns {URL}
|
|
3121
|
+
*/
|
|
3122
|
+
getFileDownloadURL(bucketId, fileId, token) {
|
|
3123
|
+
const apiPath = '/storage/buckets/{bucketId}/files/{fileId}/download'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
|
|
3124
|
+
const payload = {};
|
|
3125
|
+
if (typeof token !== 'undefined') {
|
|
3126
|
+
payload['token'] = token;
|
|
3127
|
+
}
|
|
3128
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
3129
|
+
payload['project'] = this.client.config.project;
|
|
3130
|
+
for (const [key, value] of Object.entries(Service.flatten(payload))) {
|
|
3131
|
+
uri.searchParams.append(key, value);
|
|
3132
|
+
}
|
|
3133
|
+
return uri;
|
|
3134
|
+
}
|
|
3135
|
+
/**
|
|
3136
|
+
* Get a file preview image. Currently, this method supports preview for image
|
|
3137
|
+
* files (jpg, png, and gif), other supported formats, like pdf, docs, slides,
|
|
3138
|
+
* and spreadsheets, will return the file icon image. You can also pass query
|
|
3139
|
+
* string arguments for cutting and resizing your preview image. Preview is
|
|
3140
|
+
* supported only for image files smaller than 10MB.
|
|
3141
|
+
*
|
|
3142
|
+
* @param {string} bucketId
|
|
3143
|
+
* @param {string} fileId
|
|
3144
|
+
* @param {number} width
|
|
3145
|
+
* @param {number} height
|
|
3146
|
+
* @param {ImageGravity} gravity
|
|
3147
|
+
* @param {number} quality
|
|
3148
|
+
* @param {number} borderWidth
|
|
3149
|
+
* @param {string} borderColor
|
|
3150
|
+
* @param {number} borderRadius
|
|
3151
|
+
* @param {number} opacity
|
|
3152
|
+
* @param {number} rotation
|
|
3153
|
+
* @param {string} background
|
|
3154
|
+
* @param {ImageFormat} output
|
|
3155
|
+
* @param {string} token
|
|
3156
|
+
* @throws {AppwriteException}
|
|
3157
|
+
* @returns {URL}
|
|
3158
|
+
*/
|
|
3159
|
+
getFilePreviewURL(bucketId, fileId, width, height, gravity, quality, borderWidth, borderColor, borderRadius, opacity, rotation, background, output, token) {
|
|
3160
|
+
const apiPath = '/storage/buckets/{bucketId}/files/{fileId}/preview'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
|
|
3161
|
+
const payload = {};
|
|
3162
|
+
if (typeof width !== 'undefined') {
|
|
3163
|
+
payload['width'] = width;
|
|
3164
|
+
}
|
|
3165
|
+
if (typeof height !== 'undefined') {
|
|
3166
|
+
payload['height'] = height;
|
|
3167
|
+
}
|
|
3168
|
+
if (typeof gravity !== 'undefined') {
|
|
3169
|
+
payload['gravity'] = gravity;
|
|
3170
|
+
}
|
|
3171
|
+
if (typeof quality !== 'undefined') {
|
|
3172
|
+
payload['quality'] = quality;
|
|
3173
|
+
}
|
|
3174
|
+
if (typeof borderWidth !== 'undefined') {
|
|
3175
|
+
payload['borderWidth'] = borderWidth;
|
|
3176
|
+
}
|
|
3177
|
+
if (typeof borderColor !== 'undefined') {
|
|
3178
|
+
payload['borderColor'] = borderColor;
|
|
3179
|
+
}
|
|
3180
|
+
if (typeof borderRadius !== 'undefined') {
|
|
3181
|
+
payload['borderRadius'] = borderRadius;
|
|
3182
|
+
}
|
|
3183
|
+
if (typeof opacity !== 'undefined') {
|
|
3184
|
+
payload['opacity'] = opacity;
|
|
3185
|
+
}
|
|
3186
|
+
if (typeof rotation !== 'undefined') {
|
|
3187
|
+
payload['rotation'] = rotation;
|
|
3188
|
+
}
|
|
3189
|
+
if (typeof background !== 'undefined') {
|
|
3190
|
+
payload['background'] = background;
|
|
3191
|
+
}
|
|
3192
|
+
if (typeof output !== 'undefined') {
|
|
3193
|
+
payload['output'] = output;
|
|
3194
|
+
}
|
|
3195
|
+
if (typeof token !== 'undefined') {
|
|
3196
|
+
payload['token'] = token;
|
|
3197
|
+
}
|
|
3198
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
3199
|
+
payload['project'] = this.client.config.project;
|
|
3200
|
+
for (const [key, value] of Object.entries(Service.flatten(payload))) {
|
|
3201
|
+
uri.searchParams.append(key, value);
|
|
3202
|
+
}
|
|
3203
|
+
return uri;
|
|
3204
|
+
}
|
|
3205
|
+
/**
|
|
3206
|
+
* Get a file content by its unique ID. This endpoint is similar to the
|
|
3207
|
+
* download method but returns with no 'Content-Disposition: attachment'
|
|
3208
|
+
* header.
|
|
3209
|
+
*
|
|
3210
|
+
* @param {string} bucketId
|
|
3211
|
+
* @param {string} fileId
|
|
3212
|
+
* @param {string} token
|
|
3213
|
+
* @throws {AppwriteException}
|
|
3214
|
+
* @returns {URL}
|
|
3215
|
+
*/
|
|
3216
|
+
getFileViewURL(bucketId, fileId, token) {
|
|
2837
3217
|
const apiPath = '/storage/buckets/{bucketId}/files/{fileId}/view'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
|
|
2838
3218
|
const payload = {};
|
|
2839
3219
|
if (typeof token !== 'undefined') {
|
|
@@ -3732,6 +4112,7 @@ exports.ImageFormat = void 0;
|
|
|
3732
4112
|
ImageFormat["Webp"] = "webp";
|
|
3733
4113
|
ImageFormat["Heic"] = "heic";
|
|
3734
4114
|
ImageFormat["Avif"] = "avif";
|
|
4115
|
+
ImageFormat["Gif"] = "gif";
|
|
3735
4116
|
})(exports.ImageFormat || (exports.ImageFormat = {}));
|
|
3736
4117
|
|
|
3737
4118
|
exports.Account = Account;
|