react-native-appwrite 0.7.1 → 0.7.3

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/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Appwrite React Native SDK
2
2
 
3
3
  ![License](https://img.shields.io/github/license/appwrite/sdk-for-react-native.svg?style=flat-square)
4
- ![Version](https://img.shields.io/badge/api%20version-1.6.1-blue.svg?style=flat-square)
4
+ ![Version](https://img.shields.io/badge/api%20version-1.6.2-blue.svg?style=flat-square)
5
5
  [![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator)
6
6
  [![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite)
7
7
  [![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord)
package/dist/cjs/sdk.js CHANGED
@@ -99,7 +99,7 @@ class Client {
99
99
  'x-sdk-name': 'React Native',
100
100
  'x-sdk-platform': 'client',
101
101
  'x-sdk-language': 'reactnative',
102
- 'x-sdk-version': '0.7.1',
102
+ 'x-sdk-version': '0.7.3',
103
103
  'X-Appwrite-Response-Format': '1.6.0',
104
104
  };
105
105
  this.realtime = {
@@ -249,8 +249,11 @@ class Client {
249
249
  * @returns {this}
250
250
  */
251
251
  setEndpoint(endpoint) {
252
+ if (!endpoint.startsWith('http://') && !endpoint.startsWith('https://')) {
253
+ throw new AppwriteException('Invalid endpoint URL: ' + endpoint);
254
+ }
252
255
  this.config.endpoint = endpoint;
253
- this.config.endpointRealtime = this.config.endpointRealtime || this.config.endpoint.replace('https://', 'wss://').replace('http://', 'ws://');
256
+ this.config.endpointRealtime = endpoint.replace('https://', 'wss://').replace('http://', 'ws://');
254
257
  return this;
255
258
  }
256
259
  /**
@@ -261,6 +264,9 @@ class Client {
261
264
  * @returns {this}
262
265
  */
263
266
  setEndpointRealtime(endpointRealtime) {
267
+ if (!endpointRealtime.startsWith('ws://') && !endpointRealtime.startsWith('wss://')) {
268
+ throw new AppwriteException('Invalid realtime endpoint URL: ' + endpointRealtime);
269
+ }
264
270
  this.config.endpointRealtime = endpointRealtime;
265
271
  return this;
266
272
  }
@@ -370,9 +376,9 @@ class Client {
370
376
  this.realtime.connect();
371
377
  };
372
378
  }
373
- call(method, url, headers = {}, params = {}) {
374
- var _a;
375
- return __awaiter(this, void 0, void 0, function* () {
379
+ call(method_1, url_1) {
380
+ return __awaiter(this, arguments, void 0, function* (method, url, headers = {}, params = {}) {
381
+ var _a, _b;
376
382
  method = method.toUpperCase();
377
383
  headers = Object.assign({}, this.headers, headers);
378
384
  headers.Origin = `appwrite-${reactNative.Platform.OS}://${this.config.platform}`;
@@ -411,7 +417,6 @@ class Client {
411
417
  try {
412
418
  let data = null;
413
419
  const response = yield fetch(url.toString(), options);
414
- const text = yield response.text();
415
420
  const warnings = response.headers.get('x-appwrite-warning');
416
421
  if (warnings) {
417
422
  warnings.split(';').forEach((warning) => console.warn('Warning: ' + warning));
@@ -421,11 +426,18 @@ class Client {
421
426
  }
422
427
  else {
423
428
  data = {
424
- message: text
429
+ message: yield response.text()
425
430
  };
426
431
  }
427
432
  if (400 <= response.status) {
428
- throw new AppwriteException(data === null || data === void 0 ? void 0 : data.message, response.status, data === null || data === void 0 ? void 0 : data.type, text);
433
+ let responseText = '';
434
+ if ((_b = response.headers.get('content-type')) === null || _b === void 0 ? void 0 : _b.includes('application/json')) {
435
+ responseText = JSON.stringify(data);
436
+ }
437
+ else {
438
+ responseText = data === null || data === void 0 ? void 0 : data.message;
439
+ }
440
+ throw new AppwriteException(data === null || data === void 0 ? void 0 : data.message, response.status, data === null || data === void 0 ? void 0 : data.type, responseText);
429
441
  }
430
442
  const cookieFallback = response.headers.get('X-Fallback-Cookies');
431
443
  if (typeof window !== 'undefined' && window.localStorage && cookieFallback) {
@@ -458,9 +470,7 @@ class Account extends Service {
458
470
  const apiPath = '/account';
459
471
  const payload = {};
460
472
  const uri = new URL(this.client.config.endpoint + apiPath);
461
- return this.client.call('get', uri, {
462
- 'content-type': 'application/json',
463
- }, payload);
473
+ return this.client.call('get', uri, {}, payload);
464
474
  }
465
475
  /**
466
476
  * Use this endpoint to allow a new user to register a new account in your
@@ -556,9 +566,7 @@ class Account extends Service {
556
566
  payload['queries'] = queries;
557
567
  }
558
568
  const uri = new URL(this.client.config.endpoint + apiPath);
559
- return this.client.call('get', uri, {
560
- 'content-type': 'application/json',
561
- }, payload);
569
+ return this.client.call('get', uri, {}, payload);
562
570
  }
563
571
  /**
564
572
  * Delete an identity by its unique ID.
@@ -611,9 +619,7 @@ class Account extends Service {
611
619
  payload['queries'] = queries;
612
620
  }
613
621
  const uri = new URL(this.client.config.endpoint + apiPath);
614
- return this.client.call('get', uri, {
615
- 'content-type': 'application/json',
616
- }, payload);
622
+ return this.client.call('get', uri, {}, payload);
617
623
  }
618
624
  /**
619
625
  * Enable or disable MFA on an account.
@@ -767,9 +773,7 @@ class Account extends Service {
767
773
  const apiPath = '/account/mfa/factors';
768
774
  const payload = {};
769
775
  const uri = new URL(this.client.config.endpoint + apiPath);
770
- return this.client.call('get', uri, {
771
- 'content-type': 'application/json',
772
- }, payload);
776
+ return this.client.call('get', uri, {}, payload);
773
777
  }
774
778
  /**
775
779
  * Get recovery codes that can be used as backup for MFA flow. Before getting
@@ -784,9 +788,7 @@ class Account extends Service {
784
788
  const apiPath = '/account/mfa/recovery-codes';
785
789
  const payload = {};
786
790
  const uri = new URL(this.client.config.endpoint + apiPath);
787
- return this.client.call('get', uri, {
788
- 'content-type': 'application/json',
789
- }, payload);
791
+ return this.client.call('get', uri, {}, payload);
790
792
  }
791
793
  /**
792
794
  * Generate recovery codes as backup for MFA flow. It's recommended to
@@ -913,9 +915,7 @@ class Account extends Service {
913
915
  const apiPath = '/account/prefs';
914
916
  const payload = {};
915
917
  const uri = new URL(this.client.config.endpoint + apiPath);
916
- return this.client.call('get', uri, {
917
- 'content-type': 'application/json',
918
- }, payload);
918
+ return this.client.call('get', uri, {}, payload);
919
919
  }
920
920
  /**
921
921
  * Update currently logged in user account preferences. The object you pass is
@@ -1030,9 +1030,7 @@ class Account extends Service {
1030
1030
  const apiPath = '/account/sessions';
1031
1031
  const payload = {};
1032
1032
  const uri = new URL(this.client.config.endpoint + apiPath);
1033
- return this.client.call('get', uri, {
1034
- 'content-type': 'application/json',
1035
- }, payload);
1033
+ return this.client.call('get', uri, {}, payload);
1036
1034
  }
1037
1035
  /**
1038
1036
  * Delete all sessions from the user account and remove any sessions cookies
@@ -1254,9 +1252,7 @@ class Account extends Service {
1254
1252
  const apiPath = '/account/sessions/{sessionId}'.replace('{sessionId}', sessionId);
1255
1253
  const payload = {};
1256
1254
  const uri = new URL(this.client.config.endpoint + apiPath);
1257
- return this.client.call('get', uri, {
1258
- 'content-type': 'application/json',
1259
- }, payload);
1255
+ return this.client.call('get', uri, {}, payload);
1260
1256
  }
1261
1257
  /**
1262
1258
  * Use this endpoint to extend a session's length. Extending a session is
@@ -1999,9 +1995,7 @@ class Databases extends Service {
1999
1995
  payload['queries'] = queries;
2000
1996
  }
2001
1997
  const uri = new URL(this.client.config.endpoint + apiPath);
2002
- return this.client.call('get', uri, {
2003
- 'content-type': 'application/json',
2004
- }, payload);
1998
+ return this.client.call('get', uri, {}, payload);
2005
1999
  }
2006
2000
  /**
2007
2001
  * Create a new Document. Before using this route, you should create a new
@@ -2009,6 +2003,7 @@ class Databases extends Service {
2009
2003
  * integration](https://appwrite.io/docs/server/databases#databasesCreateCollection)
2010
2004
  * API or directly from your database console.
2011
2005
  *
2006
+ *
2012
2007
  * @param {string} databaseId
2013
2008
  * @param {string} collectionId
2014
2009
  * @param {string} documentId
@@ -2073,9 +2068,7 @@ class Databases extends Service {
2073
2068
  payload['queries'] = queries;
2074
2069
  }
2075
2070
  const uri = new URL(this.client.config.endpoint + apiPath);
2076
- return this.client.call('get', uri, {
2077
- 'content-type': 'application/json',
2078
- }, payload);
2071
+ return this.client.call('get', uri, {}, payload);
2079
2072
  }
2080
2073
  /**
2081
2074
  * Update a document by its unique ID. Using the patch method you can pass
@@ -2167,9 +2160,7 @@ class Functions extends Service {
2167
2160
  payload['search'] = search;
2168
2161
  }
2169
2162
  const uri = new URL(this.client.config.endpoint + apiPath);
2170
- return this.client.call('get', uri, {
2171
- 'content-type': 'application/json',
2172
- }, payload);
2163
+ return this.client.call('get', uri, {}, payload);
2173
2164
  }
2174
2165
  /**
2175
2166
  * Trigger a function execution. The returned object will return you the
@@ -2234,9 +2225,7 @@ class Functions extends Service {
2234
2225
  const apiPath = '/functions/{functionId}/executions/{executionId}'.replace('{functionId}', functionId).replace('{executionId}', executionId);
2235
2226
  const payload = {};
2236
2227
  const uri = new URL(this.client.config.endpoint + apiPath);
2237
- return this.client.call('get', uri, {
2238
- 'content-type': 'application/json',
2239
- }, payload);
2228
+ return this.client.call('get', uri, {}, payload);
2240
2229
  }
2241
2230
  }
2242
2231
 
@@ -2309,9 +2298,7 @@ class Locale extends Service {
2309
2298
  const apiPath = '/locale';
2310
2299
  const payload = {};
2311
2300
  const uri = new URL(this.client.config.endpoint + apiPath);
2312
- return this.client.call('get', uri, {
2313
- 'content-type': 'application/json',
2314
- }, payload);
2301
+ return this.client.call('get', uri, {}, payload);
2315
2302
  }
2316
2303
  /**
2317
2304
  * List of all locale codes in [ISO
@@ -2324,9 +2311,7 @@ class Locale extends Service {
2324
2311
  const apiPath = '/locale/codes';
2325
2312
  const payload = {};
2326
2313
  const uri = new URL(this.client.config.endpoint + apiPath);
2327
- return this.client.call('get', uri, {
2328
- 'content-type': 'application/json',
2329
- }, payload);
2314
+ return this.client.call('get', uri, {}, payload);
2330
2315
  }
2331
2316
  /**
2332
2317
  * List of all continents. You can use the locale header to get the data in a
@@ -2339,9 +2324,7 @@ class Locale extends Service {
2339
2324
  const apiPath = '/locale/continents';
2340
2325
  const payload = {};
2341
2326
  const uri = new URL(this.client.config.endpoint + apiPath);
2342
- return this.client.call('get', uri, {
2343
- 'content-type': 'application/json',
2344
- }, payload);
2327
+ return this.client.call('get', uri, {}, payload);
2345
2328
  }
2346
2329
  /**
2347
2330
  * List of all countries. You can use the locale header to get the data in a
@@ -2354,9 +2337,7 @@ class Locale extends Service {
2354
2337
  const apiPath = '/locale/countries';
2355
2338
  const payload = {};
2356
2339
  const uri = new URL(this.client.config.endpoint + apiPath);
2357
- return this.client.call('get', uri, {
2358
- 'content-type': 'application/json',
2359
- }, payload);
2340
+ return this.client.call('get', uri, {}, payload);
2360
2341
  }
2361
2342
  /**
2362
2343
  * List of all countries that are currently members of the EU. You can use the
@@ -2369,9 +2350,7 @@ class Locale extends Service {
2369
2350
  const apiPath = '/locale/countries/eu';
2370
2351
  const payload = {};
2371
2352
  const uri = new URL(this.client.config.endpoint + apiPath);
2372
- return this.client.call('get', uri, {
2373
- 'content-type': 'application/json',
2374
- }, payload);
2353
+ return this.client.call('get', uri, {}, payload);
2375
2354
  }
2376
2355
  /**
2377
2356
  * List of all countries phone codes. You can use the locale header to get the
@@ -2384,9 +2363,7 @@ class Locale extends Service {
2384
2363
  const apiPath = '/locale/countries/phones';
2385
2364
  const payload = {};
2386
2365
  const uri = new URL(this.client.config.endpoint + apiPath);
2387
- return this.client.call('get', uri, {
2388
- 'content-type': 'application/json',
2389
- }, payload);
2366
+ return this.client.call('get', uri, {}, payload);
2390
2367
  }
2391
2368
  /**
2392
2369
  * List of all currencies, including currency symbol, name, plural, and
@@ -2400,9 +2377,7 @@ class Locale extends Service {
2400
2377
  const apiPath = '/locale/currencies';
2401
2378
  const payload = {};
2402
2379
  const uri = new URL(this.client.config.endpoint + apiPath);
2403
- return this.client.call('get', uri, {
2404
- 'content-type': 'application/json',
2405
- }, payload);
2380
+ return this.client.call('get', uri, {}, payload);
2406
2381
  }
2407
2382
  /**
2408
2383
  * List of all languages classified by ISO 639-1 including 2-letter code, name
@@ -2415,9 +2390,7 @@ class Locale extends Service {
2415
2390
  const apiPath = '/locale/languages';
2416
2391
  const payload = {};
2417
2392
  const uri = new URL(this.client.config.endpoint + apiPath);
2418
- return this.client.call('get', uri, {
2419
- 'content-type': 'application/json',
2420
- }, payload);
2393
+ return this.client.call('get', uri, {}, payload);
2421
2394
  }
2422
2395
  }
2423
2396
 
@@ -2508,9 +2481,7 @@ class Storage extends Service {
2508
2481
  payload['search'] = search;
2509
2482
  }
2510
2483
  const uri = new URL(this.client.config.endpoint + apiPath);
2511
- return this.client.call('get', uri, {
2512
- 'content-type': 'application/json',
2513
- }, payload);
2484
+ return this.client.call('get', uri, {}, payload);
2514
2485
  }
2515
2486
  /**
2516
2487
  * Create a new file. Before using this route, you should create a new bucket
@@ -2539,8 +2510,8 @@ class Storage extends Service {
2539
2510
  * @throws {AppwriteException}
2540
2511
  * @returns {Promise}
2541
2512
  */
2542
- createFile(bucketId, fileId, file, permissions, onProgress = (progress) => { }) {
2543
- return __awaiter(this, void 0, void 0, function* () {
2513
+ createFile(bucketId_1, fileId_1, file_1, permissions_1) {
2514
+ return __awaiter(this, arguments, void 0, function* (bucketId, fileId, file, permissions, onProgress = (progress) => { }) {
2544
2515
  if (typeof bucketId === 'undefined') {
2545
2516
  throw new AppwriteException('Missing required parameter: "bucketId"');
2546
2517
  }
@@ -2631,9 +2602,7 @@ class Storage extends Service {
2631
2602
  const apiPath = '/storage/buckets/{bucketId}/files/{fileId}'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
2632
2603
  const payload = {};
2633
2604
  const uri = new URL(this.client.config.endpoint + apiPath);
2634
- return this.client.call('get', uri, {
2635
- 'content-type': 'application/json',
2636
- }, payload);
2605
+ return this.client.call('get', uri, {}, payload);
2637
2606
  }
2638
2607
  /**
2639
2608
  * Update a file by its unique ID. Only users with write permissions have
@@ -2838,9 +2807,7 @@ class Teams extends Service {
2838
2807
  payload['search'] = search;
2839
2808
  }
2840
2809
  const uri = new URL(this.client.config.endpoint + apiPath);
2841
- return this.client.call('get', uri, {
2842
- 'content-type': 'application/json',
2843
- }, payload);
2810
+ return this.client.call('get', uri, {}, payload);
2844
2811
  }
2845
2812
  /**
2846
2813
  * Create a new team. The user who creates the team will automatically be
@@ -2890,9 +2857,7 @@ class Teams extends Service {
2890
2857
  const apiPath = '/teams/{teamId}'.replace('{teamId}', teamId);
2891
2858
  const payload = {};
2892
2859
  const uri = new URL(this.client.config.endpoint + apiPath);
2893
- return this.client.call('get', uri, {
2894
- 'content-type': 'application/json',
2895
- }, payload);
2860
+ return this.client.call('get', uri, {}, payload);
2896
2861
  }
2897
2862
  /**
2898
2863
  * Update the team's name by its unique ID.
@@ -2962,9 +2927,7 @@ class Teams extends Service {
2962
2927
  payload['search'] = search;
2963
2928
  }
2964
2929
  const uri = new URL(this.client.config.endpoint + apiPath);
2965
- return this.client.call('get', uri, {
2966
- 'content-type': 'application/json',
2967
- }, payload);
2930
+ return this.client.call('get', uri, {}, payload);
2968
2931
  }
2969
2932
  /**
2970
2933
  * Invite a new member to join your team. Provide an ID for existing users, or
@@ -3051,9 +3014,7 @@ class Teams extends Service {
3051
3014
  const apiPath = '/teams/{teamId}/memberships/{membershipId}'.replace('{teamId}', teamId).replace('{membershipId}', membershipId);
3052
3015
  const payload = {};
3053
3016
  const uri = new URL(this.client.config.endpoint + apiPath);
3054
- return this.client.call('get', uri, {
3055
- 'content-type': 'application/json',
3056
- }, payload);
3017
+ return this.client.call('get', uri, {}, payload);
3057
3018
  }
3058
3019
  /**
3059
3020
  * Modify the roles of a team member. Only team members with the owner role
@@ -3169,9 +3130,7 @@ class Teams extends Service {
3169
3130
  const apiPath = '/teams/{teamId}/prefs'.replace('{teamId}', teamId);
3170
3131
  const payload = {};
3171
3132
  const uri = new URL(this.client.config.endpoint + apiPath);
3172
- return this.client.call('get', uri, {
3173
- 'content-type': 'application/json',
3174
- }, payload);
3133
+ return this.client.call('get', uri, {}, payload);
3175
3134
  }
3176
3135
  /**
3177
3136
  * Update the team's preferences by its unique ID. The object you pass is
@@ -3365,7 +3324,7 @@ class ID {
3365
3324
  }
3366
3325
  static unique(padding = 7) {
3367
3326
  // Generate a unique ID with padding to have a longer ID
3368
- const baseId = __classPrivateFieldGet(ID, _a, "m", _ID_hexTimestamp).call(ID);
3327
+ const baseId = __classPrivateFieldGet(_a, _a, "m", _ID_hexTimestamp).call(_a);
3369
3328
  let randomPadding = '';
3370
3329
  for (let i = 0; i < padding; i++) {
3371
3330
  const randomHexDigit = Math.floor(Math.random() * 16).toString(16);
@@ -3412,6 +3371,7 @@ exports.OAuthProvider = void 0;
3412
3371
  OAuthProvider["Dropbox"] = "dropbox";
3413
3372
  OAuthProvider["Etsy"] = "etsy";
3414
3373
  OAuthProvider["Facebook"] = "facebook";
3374
+ OAuthProvider["Figma"] = "figma";
3415
3375
  OAuthProvider["Github"] = "github";
3416
3376
  OAuthProvider["Gitlab"] = "gitlab";
3417
3377
  OAuthProvider["Google"] = "google";
@@ -3475,6 +3435,7 @@ exports.CreditCard = void 0;
3475
3435
  CreditCard["Visa"] = "visa";
3476
3436
  CreditCard["MIR"] = "mir";
3477
3437
  CreditCard["Maestro"] = "maestro";
3438
+ CreditCard["Rupay"] = "rupay";
3478
3439
  })(exports.CreditCard || (exports.CreditCard = {}));
3479
3440
 
3480
3441
  exports.Flag = void 0;