react-native-appwrite 0.7.4 → 0.9.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/CHANGELOG.md +7 -0
- package/README.md +2 -2
- package/dist/cjs/sdk.js +73 -11
- package/dist/cjs/sdk.js.map +1 -1
- package/dist/esm/sdk.js +73 -11
- package/dist/esm/sdk.js.map +1 -1
- package/docs/examples/avatars/get-browser.md +1 -1
- package/docs/examples/avatars/get-credit-card.md +1 -1
- package/docs/examples/avatars/get-flag.md +1 -1
- package/docs/examples/databases/create-document.md +3 -1
- package/docs/examples/databases/upsert-document.md +17 -0
- package/docs/examples/functions/list-executions.md +1 -2
- package/docs/examples/storage/get-file-download.md +2 -1
- package/docs/examples/storage/get-file-preview.md +3 -2
- package/docs/examples/storage/get-file-view.md +2 -1
- package/package.json +1 -1
- package/src/client.ts +18 -2
- package/src/enums/image-format.ts +0 -1
- package/src/models.ts +1 -1
- package/src/services/databases.ts +48 -0
- package/src/services/functions.ts +1 -6
- package/src/services/storage.ts +18 -3
- package/types/client.d.ts +11 -0
- package/types/enums/image-format.d.ts +0 -1
- package/types/models.d.ts +1 -1
- package/types/services/databases.d.ts +15 -0
- package/types/services/functions.d.ts +1 -2
- package/types/services/storage.d.ts +6 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Change log
|
|
2
2
|
|
|
3
|
+
## 0.9.0
|
|
4
|
+
|
|
5
|
+
* Add `token` param to `getFilePreview` and `getFileView` for File tokens usage
|
|
6
|
+
* Update default `quality` for `getFilePreview` from 0 to -1
|
|
7
|
+
* Remove `Gif` from ImageFormat enum
|
|
8
|
+
* Remove `search` param from `listExecutions` method
|
|
9
|
+
|
|
3
10
|
## 0.7.4
|
|
4
11
|
|
|
5
12
|
* Upgrade dependencies to resolve PlatformConstants error with Expo 53
|
package/README.md
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
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)
|
|
8
8
|
|
|
9
|
-
**This SDK is compatible with Appwrite server version 1.
|
|
9
|
+
**This SDK is compatible with Appwrite server version 1.7.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-react-native/releases).**
|
|
10
10
|
|
|
11
11
|
Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the React Native SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs)
|
|
12
12
|
|
package/dist/cjs/sdk.js
CHANGED
|
@@ -93,14 +93,15 @@ class Client {
|
|
|
93
93
|
jwt: '',
|
|
94
94
|
locale: '',
|
|
95
95
|
session: '',
|
|
96
|
+
devkey: '',
|
|
96
97
|
platform: '',
|
|
97
98
|
};
|
|
98
99
|
this.headers = {
|
|
99
100
|
'x-sdk-name': 'React Native',
|
|
100
101
|
'x-sdk-platform': 'client',
|
|
101
102
|
'x-sdk-language': 'reactnative',
|
|
102
|
-
'x-sdk-version': '0.
|
|
103
|
-
'X-Appwrite-Response-Format': '1.
|
|
103
|
+
'x-sdk-version': '0.9.1',
|
|
104
|
+
'X-Appwrite-Response-Format': '1.7.0',
|
|
104
105
|
};
|
|
105
106
|
this.realtime = {
|
|
106
107
|
socket: undefined,
|
|
@@ -336,6 +337,20 @@ class Client {
|
|
|
336
337
|
this.config.session = value;
|
|
337
338
|
return this;
|
|
338
339
|
}
|
|
340
|
+
/**
|
|
341
|
+
* Set DevKey
|
|
342
|
+
*
|
|
343
|
+
* Your secret dev API key
|
|
344
|
+
*
|
|
345
|
+
* @param value string
|
|
346
|
+
*
|
|
347
|
+
* @return {this}
|
|
348
|
+
*/
|
|
349
|
+
setDevKey(value) {
|
|
350
|
+
this.headers['X-Appwrite-Dev-Key'] = value;
|
|
351
|
+
this.config.devkey = value;
|
|
352
|
+
return this;
|
|
353
|
+
}
|
|
339
354
|
/**
|
|
340
355
|
* Subscribes to Appwrite events and passes you the payload in realtime.
|
|
341
356
|
*
|
|
@@ -2069,6 +2084,46 @@ class Databases extends Service {
|
|
|
2069
2084
|
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
2070
2085
|
return this.client.call('get', uri, {}, payload);
|
|
2071
2086
|
}
|
|
2087
|
+
/**
|
|
2088
|
+
* Create or update a Document. Before using this route, you should create a
|
|
2089
|
+
* new collection resource using either a [server
|
|
2090
|
+
* integration](https://appwrite.io/docs/server/databases#databasesCreateCollection)
|
|
2091
|
+
* API or directly from your database console.
|
|
2092
|
+
*
|
|
2093
|
+
* @param {string} databaseId
|
|
2094
|
+
* @param {string} collectionId
|
|
2095
|
+
* @param {string} documentId
|
|
2096
|
+
* @param {object} data
|
|
2097
|
+
* @param {string[]} permissions
|
|
2098
|
+
* @throws {AppwriteException}
|
|
2099
|
+
* @returns {Promise}
|
|
2100
|
+
*/
|
|
2101
|
+
upsertDocument(databaseId, collectionId, documentId, data, permissions) {
|
|
2102
|
+
if (typeof databaseId === 'undefined') {
|
|
2103
|
+
throw new AppwriteException('Missing required parameter: "databaseId"');
|
|
2104
|
+
}
|
|
2105
|
+
if (typeof collectionId === 'undefined') {
|
|
2106
|
+
throw new AppwriteException('Missing required parameter: "collectionId"');
|
|
2107
|
+
}
|
|
2108
|
+
if (typeof documentId === 'undefined') {
|
|
2109
|
+
throw new AppwriteException('Missing required parameter: "documentId"');
|
|
2110
|
+
}
|
|
2111
|
+
if (typeof data === 'undefined') {
|
|
2112
|
+
throw new AppwriteException('Missing required parameter: "data"');
|
|
2113
|
+
}
|
|
2114
|
+
const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId);
|
|
2115
|
+
const payload = {};
|
|
2116
|
+
if (typeof data !== 'undefined') {
|
|
2117
|
+
payload['data'] = data;
|
|
2118
|
+
}
|
|
2119
|
+
if (typeof permissions !== 'undefined') {
|
|
2120
|
+
payload['permissions'] = permissions;
|
|
2121
|
+
}
|
|
2122
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
2123
|
+
return this.client.call('put', uri, {
|
|
2124
|
+
'content-type': 'application/json',
|
|
2125
|
+
}, payload);
|
|
2126
|
+
}
|
|
2072
2127
|
/**
|
|
2073
2128
|
* Update a document by its unique ID. Using the patch method you can pass
|
|
2074
2129
|
* only specific fields that will get updated.
|
|
@@ -2142,11 +2197,10 @@ class Functions extends Service {
|
|
|
2142
2197
|
*
|
|
2143
2198
|
* @param {string} functionId
|
|
2144
2199
|
* @param {string[]} queries
|
|
2145
|
-
* @param {string} search
|
|
2146
2200
|
* @throws {AppwriteException}
|
|
2147
2201
|
* @returns {Promise}
|
|
2148
2202
|
*/
|
|
2149
|
-
listExecutions(functionId, queries
|
|
2203
|
+
listExecutions(functionId, queries) {
|
|
2150
2204
|
if (typeof functionId === 'undefined') {
|
|
2151
2205
|
throw new AppwriteException('Missing required parameter: "functionId"');
|
|
2152
2206
|
}
|
|
@@ -2155,9 +2209,6 @@ class Functions extends Service {
|
|
|
2155
2209
|
if (typeof queries !== 'undefined') {
|
|
2156
2210
|
payload['queries'] = queries;
|
|
2157
2211
|
}
|
|
2158
|
-
if (typeof search !== 'undefined') {
|
|
2159
|
-
payload['search'] = search;
|
|
2160
|
-
}
|
|
2161
2212
|
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
2162
2213
|
return this.client.call('get', uri, {}, payload);
|
|
2163
2214
|
}
|
|
@@ -2664,10 +2715,11 @@ class Storage extends Service {
|
|
|
2664
2715
|
*
|
|
2665
2716
|
* @param {string} bucketId
|
|
2666
2717
|
* @param {string} fileId
|
|
2718
|
+
* @param {string} token
|
|
2667
2719
|
* @throws {AppwriteException}
|
|
2668
2720
|
* @returns {URL}
|
|
2669
2721
|
*/
|
|
2670
|
-
getFileDownload(bucketId, fileId) {
|
|
2722
|
+
getFileDownload(bucketId, fileId, token) {
|
|
2671
2723
|
if (typeof bucketId === 'undefined') {
|
|
2672
2724
|
throw new AppwriteException('Missing required parameter: "bucketId"');
|
|
2673
2725
|
}
|
|
@@ -2676,6 +2728,9 @@ class Storage extends Service {
|
|
|
2676
2728
|
}
|
|
2677
2729
|
const apiPath = '/storage/buckets/{bucketId}/files/{fileId}/download'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
|
|
2678
2730
|
const payload = {};
|
|
2731
|
+
if (typeof token !== 'undefined') {
|
|
2732
|
+
payload['token'] = token;
|
|
2733
|
+
}
|
|
2679
2734
|
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
2680
2735
|
payload['project'] = this.client.config.project;
|
|
2681
2736
|
for (const [key, value] of Object.entries(Service.flatten(payload))) {
|
|
@@ -2703,10 +2758,11 @@ class Storage extends Service {
|
|
|
2703
2758
|
* @param {number} rotation
|
|
2704
2759
|
* @param {string} background
|
|
2705
2760
|
* @param {ImageFormat} output
|
|
2761
|
+
* @param {string} token
|
|
2706
2762
|
* @throws {AppwriteException}
|
|
2707
2763
|
* @returns {URL}
|
|
2708
2764
|
*/
|
|
2709
|
-
getFilePreview(bucketId, fileId, width, height, gravity, quality, borderWidth, borderColor, borderRadius, opacity, rotation, background, output) {
|
|
2765
|
+
getFilePreview(bucketId, fileId, width, height, gravity, quality, borderWidth, borderColor, borderRadius, opacity, rotation, background, output, token) {
|
|
2710
2766
|
if (typeof bucketId === 'undefined') {
|
|
2711
2767
|
throw new AppwriteException('Missing required parameter: "bucketId"');
|
|
2712
2768
|
}
|
|
@@ -2748,6 +2804,9 @@ class Storage extends Service {
|
|
|
2748
2804
|
if (typeof output !== 'undefined') {
|
|
2749
2805
|
payload['output'] = output;
|
|
2750
2806
|
}
|
|
2807
|
+
if (typeof token !== 'undefined') {
|
|
2808
|
+
payload['token'] = token;
|
|
2809
|
+
}
|
|
2751
2810
|
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
2752
2811
|
payload['project'] = this.client.config.project;
|
|
2753
2812
|
for (const [key, value] of Object.entries(Service.flatten(payload))) {
|
|
@@ -2762,10 +2821,11 @@ class Storage extends Service {
|
|
|
2762
2821
|
*
|
|
2763
2822
|
* @param {string} bucketId
|
|
2764
2823
|
* @param {string} fileId
|
|
2824
|
+
* @param {string} token
|
|
2765
2825
|
* @throws {AppwriteException}
|
|
2766
2826
|
* @returns {URL}
|
|
2767
2827
|
*/
|
|
2768
|
-
getFileView(bucketId, fileId) {
|
|
2828
|
+
getFileView(bucketId, fileId, token) {
|
|
2769
2829
|
if (typeof bucketId === 'undefined') {
|
|
2770
2830
|
throw new AppwriteException('Missing required parameter: "bucketId"');
|
|
2771
2831
|
}
|
|
@@ -2774,6 +2834,9 @@ class Storage extends Service {
|
|
|
2774
2834
|
}
|
|
2775
2835
|
const apiPath = '/storage/buckets/{bucketId}/files/{fileId}/view'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
|
|
2776
2836
|
const payload = {};
|
|
2837
|
+
if (typeof token !== 'undefined') {
|
|
2838
|
+
payload['token'] = token;
|
|
2839
|
+
}
|
|
2777
2840
|
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
2778
2841
|
payload['project'] = this.client.config.project;
|
|
2779
2842
|
for (const [key, value] of Object.entries(Service.flatten(payload))) {
|
|
@@ -3663,7 +3726,6 @@ exports.ImageFormat = void 0;
|
|
|
3663
3726
|
(function (ImageFormat) {
|
|
3664
3727
|
ImageFormat["Jpg"] = "jpg";
|
|
3665
3728
|
ImageFormat["Jpeg"] = "jpeg";
|
|
3666
|
-
ImageFormat["Gif"] = "gif";
|
|
3667
3729
|
ImageFormat["Png"] = "png";
|
|
3668
3730
|
ImageFormat["Webp"] = "webp";
|
|
3669
3731
|
ImageFormat["Heic"] = "heic";
|