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/dist/esm/sdk.js
CHANGED
|
@@ -71,14 +71,15 @@ class Client {
|
|
|
71
71
|
jwt: '',
|
|
72
72
|
locale: '',
|
|
73
73
|
session: '',
|
|
74
|
+
devkey: '',
|
|
74
75
|
platform: '',
|
|
75
76
|
};
|
|
76
77
|
this.headers = {
|
|
77
78
|
'x-sdk-name': 'React Native',
|
|
78
79
|
'x-sdk-platform': 'client',
|
|
79
80
|
'x-sdk-language': 'reactnative',
|
|
80
|
-
'x-sdk-version': '0.
|
|
81
|
-
'X-Appwrite-Response-Format': '1.
|
|
81
|
+
'x-sdk-version': '0.9.1',
|
|
82
|
+
'X-Appwrite-Response-Format': '1.7.0',
|
|
82
83
|
};
|
|
83
84
|
this.realtime = {
|
|
84
85
|
socket: undefined,
|
|
@@ -314,6 +315,20 @@ class Client {
|
|
|
314
315
|
this.config.session = value;
|
|
315
316
|
return this;
|
|
316
317
|
}
|
|
318
|
+
/**
|
|
319
|
+
* Set DevKey
|
|
320
|
+
*
|
|
321
|
+
* Your secret dev API key
|
|
322
|
+
*
|
|
323
|
+
* @param value string
|
|
324
|
+
*
|
|
325
|
+
* @return {this}
|
|
326
|
+
*/
|
|
327
|
+
setDevKey(value) {
|
|
328
|
+
this.headers['X-Appwrite-Dev-Key'] = value;
|
|
329
|
+
this.config.devkey = value;
|
|
330
|
+
return this;
|
|
331
|
+
}
|
|
317
332
|
/**
|
|
318
333
|
* Subscribes to Appwrite events and passes you the payload in realtime.
|
|
319
334
|
*
|
|
@@ -2047,6 +2062,46 @@ class Databases extends Service {
|
|
|
2047
2062
|
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
2048
2063
|
return this.client.call('get', uri, {}, payload);
|
|
2049
2064
|
}
|
|
2065
|
+
/**
|
|
2066
|
+
* Create or update a Document. Before using this route, you should create a
|
|
2067
|
+
* new collection resource using either a [server
|
|
2068
|
+
* integration](https://appwrite.io/docs/server/databases#databasesCreateCollection)
|
|
2069
|
+
* API or directly from your database console.
|
|
2070
|
+
*
|
|
2071
|
+
* @param {string} databaseId
|
|
2072
|
+
* @param {string} collectionId
|
|
2073
|
+
* @param {string} documentId
|
|
2074
|
+
* @param {object} data
|
|
2075
|
+
* @param {string[]} permissions
|
|
2076
|
+
* @throws {AppwriteException}
|
|
2077
|
+
* @returns {Promise}
|
|
2078
|
+
*/
|
|
2079
|
+
upsertDocument(databaseId, collectionId, documentId, data, permissions) {
|
|
2080
|
+
if (typeof databaseId === 'undefined') {
|
|
2081
|
+
throw new AppwriteException('Missing required parameter: "databaseId"');
|
|
2082
|
+
}
|
|
2083
|
+
if (typeof collectionId === 'undefined') {
|
|
2084
|
+
throw new AppwriteException('Missing required parameter: "collectionId"');
|
|
2085
|
+
}
|
|
2086
|
+
if (typeof documentId === 'undefined') {
|
|
2087
|
+
throw new AppwriteException('Missing required parameter: "documentId"');
|
|
2088
|
+
}
|
|
2089
|
+
if (typeof data === 'undefined') {
|
|
2090
|
+
throw new AppwriteException('Missing required parameter: "data"');
|
|
2091
|
+
}
|
|
2092
|
+
const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId);
|
|
2093
|
+
const payload = {};
|
|
2094
|
+
if (typeof data !== 'undefined') {
|
|
2095
|
+
payload['data'] = data;
|
|
2096
|
+
}
|
|
2097
|
+
if (typeof permissions !== 'undefined') {
|
|
2098
|
+
payload['permissions'] = permissions;
|
|
2099
|
+
}
|
|
2100
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
2101
|
+
return this.client.call('put', uri, {
|
|
2102
|
+
'content-type': 'application/json',
|
|
2103
|
+
}, payload);
|
|
2104
|
+
}
|
|
2050
2105
|
/**
|
|
2051
2106
|
* Update a document by its unique ID. Using the patch method you can pass
|
|
2052
2107
|
* only specific fields that will get updated.
|
|
@@ -2120,11 +2175,10 @@ class Functions extends Service {
|
|
|
2120
2175
|
*
|
|
2121
2176
|
* @param {string} functionId
|
|
2122
2177
|
* @param {string[]} queries
|
|
2123
|
-
* @param {string} search
|
|
2124
2178
|
* @throws {AppwriteException}
|
|
2125
2179
|
* @returns {Promise}
|
|
2126
2180
|
*/
|
|
2127
|
-
listExecutions(functionId, queries
|
|
2181
|
+
listExecutions(functionId, queries) {
|
|
2128
2182
|
if (typeof functionId === 'undefined') {
|
|
2129
2183
|
throw new AppwriteException('Missing required parameter: "functionId"');
|
|
2130
2184
|
}
|
|
@@ -2133,9 +2187,6 @@ class Functions extends Service {
|
|
|
2133
2187
|
if (typeof queries !== 'undefined') {
|
|
2134
2188
|
payload['queries'] = queries;
|
|
2135
2189
|
}
|
|
2136
|
-
if (typeof search !== 'undefined') {
|
|
2137
|
-
payload['search'] = search;
|
|
2138
|
-
}
|
|
2139
2190
|
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
2140
2191
|
return this.client.call('get', uri, {}, payload);
|
|
2141
2192
|
}
|
|
@@ -2642,10 +2693,11 @@ class Storage extends Service {
|
|
|
2642
2693
|
*
|
|
2643
2694
|
* @param {string} bucketId
|
|
2644
2695
|
* @param {string} fileId
|
|
2696
|
+
* @param {string} token
|
|
2645
2697
|
* @throws {AppwriteException}
|
|
2646
2698
|
* @returns {URL}
|
|
2647
2699
|
*/
|
|
2648
|
-
getFileDownload(bucketId, fileId) {
|
|
2700
|
+
getFileDownload(bucketId, fileId, token) {
|
|
2649
2701
|
if (typeof bucketId === 'undefined') {
|
|
2650
2702
|
throw new AppwriteException('Missing required parameter: "bucketId"');
|
|
2651
2703
|
}
|
|
@@ -2654,6 +2706,9 @@ class Storage extends Service {
|
|
|
2654
2706
|
}
|
|
2655
2707
|
const apiPath = '/storage/buckets/{bucketId}/files/{fileId}/download'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
|
|
2656
2708
|
const payload = {};
|
|
2709
|
+
if (typeof token !== 'undefined') {
|
|
2710
|
+
payload['token'] = token;
|
|
2711
|
+
}
|
|
2657
2712
|
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
2658
2713
|
payload['project'] = this.client.config.project;
|
|
2659
2714
|
for (const [key, value] of Object.entries(Service.flatten(payload))) {
|
|
@@ -2681,10 +2736,11 @@ class Storage extends Service {
|
|
|
2681
2736
|
* @param {number} rotation
|
|
2682
2737
|
* @param {string} background
|
|
2683
2738
|
* @param {ImageFormat} output
|
|
2739
|
+
* @param {string} token
|
|
2684
2740
|
* @throws {AppwriteException}
|
|
2685
2741
|
* @returns {URL}
|
|
2686
2742
|
*/
|
|
2687
|
-
getFilePreview(bucketId, fileId, width, height, gravity, quality, borderWidth, borderColor, borderRadius, opacity, rotation, background, output) {
|
|
2743
|
+
getFilePreview(bucketId, fileId, width, height, gravity, quality, borderWidth, borderColor, borderRadius, opacity, rotation, background, output, token) {
|
|
2688
2744
|
if (typeof bucketId === 'undefined') {
|
|
2689
2745
|
throw new AppwriteException('Missing required parameter: "bucketId"');
|
|
2690
2746
|
}
|
|
@@ -2726,6 +2782,9 @@ class Storage extends Service {
|
|
|
2726
2782
|
if (typeof output !== 'undefined') {
|
|
2727
2783
|
payload['output'] = output;
|
|
2728
2784
|
}
|
|
2785
|
+
if (typeof token !== 'undefined') {
|
|
2786
|
+
payload['token'] = token;
|
|
2787
|
+
}
|
|
2729
2788
|
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
2730
2789
|
payload['project'] = this.client.config.project;
|
|
2731
2790
|
for (const [key, value] of Object.entries(Service.flatten(payload))) {
|
|
@@ -2740,10 +2799,11 @@ class Storage extends Service {
|
|
|
2740
2799
|
*
|
|
2741
2800
|
* @param {string} bucketId
|
|
2742
2801
|
* @param {string} fileId
|
|
2802
|
+
* @param {string} token
|
|
2743
2803
|
* @throws {AppwriteException}
|
|
2744
2804
|
* @returns {URL}
|
|
2745
2805
|
*/
|
|
2746
|
-
getFileView(bucketId, fileId) {
|
|
2806
|
+
getFileView(bucketId, fileId, token) {
|
|
2747
2807
|
if (typeof bucketId === 'undefined') {
|
|
2748
2808
|
throw new AppwriteException('Missing required parameter: "bucketId"');
|
|
2749
2809
|
}
|
|
@@ -2752,6 +2812,9 @@ class Storage extends Service {
|
|
|
2752
2812
|
}
|
|
2753
2813
|
const apiPath = '/storage/buckets/{bucketId}/files/{fileId}/view'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
|
|
2754
2814
|
const payload = {};
|
|
2815
|
+
if (typeof token !== 'undefined') {
|
|
2816
|
+
payload['token'] = token;
|
|
2817
|
+
}
|
|
2755
2818
|
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
2756
2819
|
payload['project'] = this.client.config.project;
|
|
2757
2820
|
for (const [key, value] of Object.entries(Service.flatten(payload))) {
|
|
@@ -3641,7 +3704,6 @@ var ImageFormat;
|
|
|
3641
3704
|
(function (ImageFormat) {
|
|
3642
3705
|
ImageFormat["Jpg"] = "jpg";
|
|
3643
3706
|
ImageFormat["Jpeg"] = "jpeg";
|
|
3644
|
-
ImageFormat["Gif"] = "gif";
|
|
3645
3707
|
ImageFormat["Png"] = "png";
|
|
3646
3708
|
ImageFormat["Webp"] = "webp";
|
|
3647
3709
|
ImageFormat["Heic"] = "heic";
|