react-native-appwrite 0.9.1 → 0.10.0

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/dist/esm/sdk.js CHANGED
@@ -78,7 +78,7 @@ class Client {
78
78
  'x-sdk-name': 'React Native',
79
79
  'x-sdk-platform': 'client',
80
80
  'x-sdk-language': 'reactnative',
81
- 'x-sdk-version': '0.9.1',
81
+ 'x-sdk-version': '0.10.0',
82
82
  'X-Appwrite-Response-Format': '1.7.0',
83
83
  };
84
84
  this.realtime = {
@@ -370,7 +370,7 @@ class Client {
370
370
  };
371
371
  }
372
372
  call(method_1, url_1) {
373
- return __awaiter(this, arguments, void 0, function* (method, url, headers = {}, params = {}) {
373
+ return __awaiter(this, arguments, void 0, function* (method, url, headers = {}, params = {}, responseType = 'json') {
374
374
  var _a, _b;
375
375
  method = method.toUpperCase();
376
376
  headers = Object.assign({}, this.headers, headers);
@@ -378,8 +378,10 @@ class Client {
378
378
  let options = {
379
379
  method,
380
380
  headers,
381
- credentials: 'include'
382
381
  };
382
+ if (headers['X-Appwrite-Dev-Key'] === undefined) {
383
+ options.credentials = 'include';
384
+ }
383
385
  if (method === 'GET') {
384
386
  for (const [key, value] of Object.entries(Service.flatten(params))) {
385
387
  url.searchParams.append(key, value);
@@ -417,6 +419,9 @@ class Client {
417
419
  if ((_a = response.headers.get('content-type')) === null || _a === void 0 ? void 0 : _a.includes('application/json')) {
418
420
  data = yield response.json();
419
421
  }
422
+ else if (responseType === 'arrayBuffer') {
423
+ data = yield response.arrayBuffer();
424
+ }
420
425
  else {
421
426
  data = {
422
427
  message: yield response.text()
@@ -1703,7 +1708,7 @@ class Avatars extends Service {
1703
1708
  * @param {number} height
1704
1709
  * @param {number} quality
1705
1710
  * @throws {AppwriteException}
1706
- * @returns {URL}
1711
+ * @returns {ArrayBuffer}
1707
1712
  */
1708
1713
  getBrowser(code, width, height, quality) {
1709
1714
  if (typeof code === 'undefined') {
@@ -1725,7 +1730,7 @@ class Avatars extends Service {
1725
1730
  for (const [key, value] of Object.entries(Service.flatten(payload))) {
1726
1731
  uri.searchParams.append(key, value);
1727
1732
  }
1728
- return uri;
1733
+ return this.client.call('get', uri, {}, payload, 'arrayBuffer');
1729
1734
  }
1730
1735
  /**
1731
1736
  * The credit card endpoint will return you the icon of the credit card
@@ -1743,7 +1748,7 @@ class Avatars extends Service {
1743
1748
  * @param {number} height
1744
1749
  * @param {number} quality
1745
1750
  * @throws {AppwriteException}
1746
- * @returns {URL}
1751
+ * @returns {ArrayBuffer}
1747
1752
  */
1748
1753
  getCreditCard(code, width, height, quality) {
1749
1754
  if (typeof code === 'undefined') {
@@ -1765,7 +1770,7 @@ class Avatars extends Service {
1765
1770
  for (const [key, value] of Object.entries(Service.flatten(payload))) {
1766
1771
  uri.searchParams.append(key, value);
1767
1772
  }
1768
- return uri;
1773
+ return this.client.call('get', uri, {}, payload, 'arrayBuffer');
1769
1774
  }
1770
1775
  /**
1771
1776
  * Use this endpoint to fetch the favorite icon (AKA favicon) of any remote
@@ -1775,7 +1780,7 @@ class Avatars extends Service {
1775
1780
  *
1776
1781
  * @param {string} url
1777
1782
  * @throws {AppwriteException}
1778
- * @returns {URL}
1783
+ * @returns {ArrayBuffer}
1779
1784
  */
1780
1785
  getFavicon(url) {
1781
1786
  if (typeof url === 'undefined') {
@@ -1791,7 +1796,7 @@ class Avatars extends Service {
1791
1796
  for (const [key, value] of Object.entries(Service.flatten(payload))) {
1792
1797
  uri.searchParams.append(key, value);
1793
1798
  }
1794
- return uri;
1799
+ return this.client.call('get', uri, {}, payload, 'arrayBuffer');
1795
1800
  }
1796
1801
  /**
1797
1802
  * You can use this endpoint to show different country flags icons to your
@@ -1810,7 +1815,7 @@ class Avatars extends Service {
1810
1815
  * @param {number} height
1811
1816
  * @param {number} quality
1812
1817
  * @throws {AppwriteException}
1813
- * @returns {URL}
1818
+ * @returns {ArrayBuffer}
1814
1819
  */
1815
1820
  getFlag(code, width, height, quality) {
1816
1821
  if (typeof code === 'undefined') {
@@ -1832,7 +1837,7 @@ class Avatars extends Service {
1832
1837
  for (const [key, value] of Object.entries(Service.flatten(payload))) {
1833
1838
  uri.searchParams.append(key, value);
1834
1839
  }
1835
- return uri;
1840
+ return this.client.call('get', uri, {}, payload, 'arrayBuffer');
1836
1841
  }
1837
1842
  /**
1838
1843
  * Use this endpoint to fetch a remote image URL and crop it to any image size
@@ -1851,7 +1856,7 @@ class Avatars extends Service {
1851
1856
  * @param {number} width
1852
1857
  * @param {number} height
1853
1858
  * @throws {AppwriteException}
1854
- * @returns {URL}
1859
+ * @returns {ArrayBuffer}
1855
1860
  */
1856
1861
  getImage(url, width, height) {
1857
1862
  if (typeof url === 'undefined') {
@@ -1873,7 +1878,7 @@ class Avatars extends Service {
1873
1878
  for (const [key, value] of Object.entries(Service.flatten(payload))) {
1874
1879
  uri.searchParams.append(key, value);
1875
1880
  }
1876
- return uri;
1881
+ return this.client.call('get', uri, {}, payload, 'arrayBuffer');
1877
1882
  }
1878
1883
  /**
1879
1884
  * Use this endpoint to show your user initials avatar icon on your website or
@@ -1898,7 +1903,7 @@ class Avatars extends Service {
1898
1903
  * @param {number} height
1899
1904
  * @param {string} background
1900
1905
  * @throws {AppwriteException}
1901
- * @returns {URL}
1906
+ * @returns {ArrayBuffer}
1902
1907
  */
1903
1908
  getInitials(name, width, height, background) {
1904
1909
  const apiPath = '/avatars/initials';
@@ -1920,7 +1925,7 @@ class Avatars extends Service {
1920
1925
  for (const [key, value] of Object.entries(Service.flatten(payload))) {
1921
1926
  uri.searchParams.append(key, value);
1922
1927
  }
1923
- return uri;
1928
+ return this.client.call('get', uri, {}, payload, 'arrayBuffer');
1924
1929
  }
1925
1930
  /**
1926
1931
  * Converts a given plain text to a QR code image. You can use the query
@@ -1932,7 +1937,7 @@ class Avatars extends Service {
1932
1937
  * @param {number} margin
1933
1938
  * @param {boolean} download
1934
1939
  * @throws {AppwriteException}
1935
- * @returns {URL}
1940
+ * @returns {ArrayBuffer}
1936
1941
  */
1937
1942
  getQR(text, size, margin, download) {
1938
1943
  if (typeof text === 'undefined') {
@@ -1957,6 +1962,163 @@ class Avatars extends Service {
1957
1962
  for (const [key, value] of Object.entries(Service.flatten(payload))) {
1958
1963
  uri.searchParams.append(key, value);
1959
1964
  }
1965
+ return this.client.call('get', uri, {}, payload, 'arrayBuffer');
1966
+ }
1967
+ /**
1968
+ * You can use this endpoint to show different browser icons to your users.
1969
+ * The code argument receives the browser code as it appears in your user [GET
1970
+ * /account/sessions](https://appwrite.io/docs/references/cloud/client-web/account#getSessions)
1971
+ * endpoint. Use width, height and quality arguments to change the output
1972
+ * settings.
1973
+ *
1974
+ * When one dimension is specified and the other is 0, the image is scaled
1975
+ * with preserved aspect ratio. If both dimensions are 0, the API provides an
1976
+ * image at source quality. If dimensions are not specified, the default size
1977
+ * of image returned is 100x100px.
1978
+ *
1979
+ * @param {Browser} code
1980
+ * @param {number} width
1981
+ * @param {number} height
1982
+ * @param {number} quality
1983
+ * @throws {AppwriteException}
1984
+ * @returns {URL}
1985
+ */
1986
+ getBrowserURL(code, width, height, quality) {
1987
+ const apiPath = '/avatars/browsers/{code}'.replace('{code}', code);
1988
+ const uri = new URL(this.client.config.endpoint + apiPath);
1989
+ return uri;
1990
+ }
1991
+ /**
1992
+ * The credit card endpoint will return you the icon of the credit card
1993
+ * provider you need. Use width, height and quality arguments to change the
1994
+ * output 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
+ *
2002
+ * @param {CreditCard} code
2003
+ * @param {number} width
2004
+ * @param {number} height
2005
+ * @param {number} quality
2006
+ * @throws {AppwriteException}
2007
+ * @returns {URL}
2008
+ */
2009
+ getCreditCardURL(code, width, height, quality) {
2010
+ const apiPath = '/avatars/credit-cards/{code}'.replace('{code}', code);
2011
+ const uri = new URL(this.client.config.endpoint + apiPath);
2012
+ return uri;
2013
+ }
2014
+ /**
2015
+ * Use this endpoint to fetch the favorite icon (AKA favicon) of any remote
2016
+ * website URL.
2017
+ *
2018
+ * This endpoint does not follow HTTP redirects.
2019
+ *
2020
+ * @param {string} url
2021
+ * @throws {AppwriteException}
2022
+ * @returns {URL}
2023
+ */
2024
+ getFaviconURL(url) {
2025
+ const apiPath = '/avatars/favicon';
2026
+ const uri = new URL(this.client.config.endpoint + apiPath);
2027
+ return uri;
2028
+ }
2029
+ /**
2030
+ * You can use this endpoint to show different country flags icons to your
2031
+ * users. The code argument receives the 2 letter country code. Use width,
2032
+ * height and quality arguments to change the output settings. Country codes
2033
+ * follow the [ISO 3166-1](https://en.wikipedia.org/wiki/ISO_3166-1) standard.
2034
+ *
2035
+ * When one dimension is specified and the other is 0, the image is scaled
2036
+ * with preserved aspect ratio. If both dimensions are 0, the API provides an
2037
+ * image at source quality. If dimensions are not specified, the default size
2038
+ * of image returned is 100x100px.
2039
+ *
2040
+ *
2041
+ * @param {Flag} code
2042
+ * @param {number} width
2043
+ * @param {number} height
2044
+ * @param {number} quality
2045
+ * @throws {AppwriteException}
2046
+ * @returns {URL}
2047
+ */
2048
+ getFlagURL(code, width, height, quality) {
2049
+ const apiPath = '/avatars/flags/{code}'.replace('{code}', code);
2050
+ const uri = new URL(this.client.config.endpoint + apiPath);
2051
+ return uri;
2052
+ }
2053
+ /**
2054
+ * Use this endpoint to fetch a remote image URL and crop it to any image size
2055
+ * you want. This endpoint is very useful if you need to crop and display
2056
+ * remote images in your app or in case you want to make sure a 3rd party
2057
+ * image is properly served using a TLS protocol.
2058
+ *
2059
+ * When one dimension is specified and the other is 0, the image is scaled
2060
+ * with preserved aspect ratio. If both dimensions are 0, the API provides an
2061
+ * image at source quality. If dimensions are not specified, the default size
2062
+ * of image returned is 400x400px.
2063
+ *
2064
+ * This endpoint does not follow HTTP redirects.
2065
+ *
2066
+ * @param {string} url
2067
+ * @param {number} width
2068
+ * @param {number} height
2069
+ * @throws {AppwriteException}
2070
+ * @returns {URL}
2071
+ */
2072
+ getImageURL(url, width, height) {
2073
+ const apiPath = '/avatars/image';
2074
+ const uri = new URL(this.client.config.endpoint + apiPath);
2075
+ return uri;
2076
+ }
2077
+ /**
2078
+ * Use this endpoint to show your user initials avatar icon on your website or
2079
+ * app. By default, this route will try to print your logged-in user name or
2080
+ * email initials. You can also overwrite the user name if you pass the 'name'
2081
+ * parameter. If no name is given and no user is logged, an empty avatar will
2082
+ * be returned.
2083
+ *
2084
+ * You can use the color and background params to change the avatar colors. By
2085
+ * default, a random theme will be selected. The random theme will persist for
2086
+ * the user's initials when reloading the same theme will always return for
2087
+ * the same initials.
2088
+ *
2089
+ * When one dimension is specified and the other is 0, the image is scaled
2090
+ * with preserved aspect ratio. If both dimensions are 0, the API provides an
2091
+ * image at source quality. If dimensions are not specified, the default size
2092
+ * of image returned is 100x100px.
2093
+ *
2094
+ *
2095
+ * @param {string} name
2096
+ * @param {number} width
2097
+ * @param {number} height
2098
+ * @param {string} background
2099
+ * @throws {AppwriteException}
2100
+ * @returns {URL}
2101
+ */
2102
+ getInitialsURL(name, width, height, background) {
2103
+ const apiPath = '/avatars/initials';
2104
+ const uri = new URL(this.client.config.endpoint + apiPath);
2105
+ return uri;
2106
+ }
2107
+ /**
2108
+ * Converts a given plain text to a QR code image. You can use the query
2109
+ * parameters to change the size and style of the resulting image.
2110
+ *
2111
+ *
2112
+ * @param {string} text
2113
+ * @param {number} size
2114
+ * @param {number} margin
2115
+ * @param {boolean} download
2116
+ * @throws {AppwriteException}
2117
+ * @returns {URL}
2118
+ */
2119
+ getQRURL(text, size, margin, download) {
2120
+ const apiPath = '/avatars/qr';
2121
+ const uri = new URL(this.client.config.endpoint + apiPath);
1960
2122
  return uri;
1961
2123
  }
1962
2124
  }
@@ -2695,7 +2857,7 @@ class Storage extends Service {
2695
2857
  * @param {string} fileId
2696
2858
  * @param {string} token
2697
2859
  * @throws {AppwriteException}
2698
- * @returns {URL}
2860
+ * @returns {ArrayBuffer}
2699
2861
  */
2700
2862
  getFileDownload(bucketId, fileId, token) {
2701
2863
  if (typeof bucketId === 'undefined') {
@@ -2714,7 +2876,7 @@ class Storage extends Service {
2714
2876
  for (const [key, value] of Object.entries(Service.flatten(payload))) {
2715
2877
  uri.searchParams.append(key, value);
2716
2878
  }
2717
- return uri;
2879
+ return this.client.call('get', uri, {}, payload, 'arrayBuffer');
2718
2880
  }
2719
2881
  /**
2720
2882
  * Get a file preview image. Currently, this method supports preview for image
@@ -2738,7 +2900,7 @@ class Storage extends Service {
2738
2900
  * @param {ImageFormat} output
2739
2901
  * @param {string} token
2740
2902
  * @throws {AppwriteException}
2741
- * @returns {URL}
2903
+ * @returns {ArrayBuffer}
2742
2904
  */
2743
2905
  getFilePreview(bucketId, fileId, width, height, gravity, quality, borderWidth, borderColor, borderRadius, opacity, rotation, background, output, token) {
2744
2906
  if (typeof bucketId === 'undefined') {
@@ -2790,7 +2952,7 @@ class Storage extends Service {
2790
2952
  for (const [key, value] of Object.entries(Service.flatten(payload))) {
2791
2953
  uri.searchParams.append(key, value);
2792
2954
  }
2793
- return uri;
2955
+ return this.client.call('get', uri, {}, payload, 'arrayBuffer');
2794
2956
  }
2795
2957
  /**
2796
2958
  * Get a file content by its unique ID. This endpoint is similar to the
@@ -2801,7 +2963,7 @@ class Storage extends Service {
2801
2963
  * @param {string} fileId
2802
2964
  * @param {string} token
2803
2965
  * @throws {AppwriteException}
2804
- * @returns {URL}
2966
+ * @returns {ArrayBuffer}
2805
2967
  */
2806
2968
  getFileView(bucketId, fileId, token) {
2807
2969
  if (typeof bucketId === 'undefined') {
@@ -2820,6 +2982,67 @@ class Storage extends Service {
2820
2982
  for (const [key, value] of Object.entries(Service.flatten(payload))) {
2821
2983
  uri.searchParams.append(key, value);
2822
2984
  }
2985
+ return this.client.call('get', uri, {}, payload, 'arrayBuffer');
2986
+ }
2987
+ /**
2988
+ * Get a file content by its unique ID. The endpoint response return with a
2989
+ * 'Content-Disposition: attachment' header that tells the browser to start
2990
+ * downloading the file to user downloads directory.
2991
+ *
2992
+ * @param {string} bucketId
2993
+ * @param {string} fileId
2994
+ * @param {string} token
2995
+ * @throws {AppwriteException}
2996
+ * @returns {URL}
2997
+ */
2998
+ getFileDownloadURL(bucketId, fileId, token) {
2999
+ const apiPath = '/storage/buckets/{bucketId}/files/{fileId}/download'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
3000
+ const uri = new URL(this.client.config.endpoint + apiPath);
3001
+ return uri;
3002
+ }
3003
+ /**
3004
+ * Get a file preview image. Currently, this method supports preview for image
3005
+ * files (jpg, png, and gif), other supported formats, like pdf, docs, slides,
3006
+ * and spreadsheets, will return the file icon image. You can also pass query
3007
+ * string arguments for cutting and resizing your preview image. Preview is
3008
+ * supported only for image files smaller than 10MB.
3009
+ *
3010
+ * @param {string} bucketId
3011
+ * @param {string} fileId
3012
+ * @param {number} width
3013
+ * @param {number} height
3014
+ * @param {ImageGravity} gravity
3015
+ * @param {number} quality
3016
+ * @param {number} borderWidth
3017
+ * @param {string} borderColor
3018
+ * @param {number} borderRadius
3019
+ * @param {number} opacity
3020
+ * @param {number} rotation
3021
+ * @param {string} background
3022
+ * @param {ImageFormat} output
3023
+ * @param {string} token
3024
+ * @throws {AppwriteException}
3025
+ * @returns {URL}
3026
+ */
3027
+ getFilePreviewURL(bucketId, fileId, width, height, gravity, quality, borderWidth, borderColor, borderRadius, opacity, rotation, background, output, token) {
3028
+ const apiPath = '/storage/buckets/{bucketId}/files/{fileId}/preview'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
3029
+ const uri = new URL(this.client.config.endpoint + apiPath);
3030
+ return uri;
3031
+ }
3032
+ /**
3033
+ * Get a file content by its unique ID. This endpoint is similar to the
3034
+ * download method but returns with no 'Content-Disposition: attachment'
3035
+ * header.
3036
+ *
3037
+ * @param {string} bucketId
3038
+ * @param {string} fileId
3039
+ * @param {string} token
3040
+ * @throws {AppwriteException}
3041
+ * @returns {URL}
3042
+ */
3043
+ getFileViewURL(bucketId, fileId, token) {
3044
+ const apiPath = '/storage/buckets/{bucketId}/files/{fileId}/view'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
3045
+ const uri = new URL(this.client.config.endpoint + apiPath);
2823
3046
  return uri;
2824
3047
  }
2825
3048
  }