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/dist/esm/sdk.js CHANGED
@@ -77,7 +77,7 @@ class Client {
77
77
  'x-sdk-name': 'React Native',
78
78
  'x-sdk-platform': 'client',
79
79
  'x-sdk-language': 'reactnative',
80
- 'x-sdk-version': '0.7.1',
80
+ 'x-sdk-version': '0.7.3',
81
81
  'X-Appwrite-Response-Format': '1.6.0',
82
82
  };
83
83
  this.realtime = {
@@ -227,8 +227,11 @@ class Client {
227
227
  * @returns {this}
228
228
  */
229
229
  setEndpoint(endpoint) {
230
+ if (!endpoint.startsWith('http://') && !endpoint.startsWith('https://')) {
231
+ throw new AppwriteException('Invalid endpoint URL: ' + endpoint);
232
+ }
230
233
  this.config.endpoint = endpoint;
231
- this.config.endpointRealtime = this.config.endpointRealtime || this.config.endpoint.replace('https://', 'wss://').replace('http://', 'ws://');
234
+ this.config.endpointRealtime = endpoint.replace('https://', 'wss://').replace('http://', 'ws://');
232
235
  return this;
233
236
  }
234
237
  /**
@@ -239,6 +242,9 @@ class Client {
239
242
  * @returns {this}
240
243
  */
241
244
  setEndpointRealtime(endpointRealtime) {
245
+ if (!endpointRealtime.startsWith('ws://') && !endpointRealtime.startsWith('wss://')) {
246
+ throw new AppwriteException('Invalid realtime endpoint URL: ' + endpointRealtime);
247
+ }
242
248
  this.config.endpointRealtime = endpointRealtime;
243
249
  return this;
244
250
  }
@@ -348,9 +354,9 @@ class Client {
348
354
  this.realtime.connect();
349
355
  };
350
356
  }
351
- call(method, url, headers = {}, params = {}) {
352
- var _a;
353
- return __awaiter(this, void 0, void 0, function* () {
357
+ call(method_1, url_1) {
358
+ return __awaiter(this, arguments, void 0, function* (method, url, headers = {}, params = {}) {
359
+ var _a, _b;
354
360
  method = method.toUpperCase();
355
361
  headers = Object.assign({}, this.headers, headers);
356
362
  headers.Origin = `appwrite-${Platform.OS}://${this.config.platform}`;
@@ -389,7 +395,6 @@ class Client {
389
395
  try {
390
396
  let data = null;
391
397
  const response = yield fetch(url.toString(), options);
392
- const text = yield response.text();
393
398
  const warnings = response.headers.get('x-appwrite-warning');
394
399
  if (warnings) {
395
400
  warnings.split(';').forEach((warning) => console.warn('Warning: ' + warning));
@@ -399,11 +404,18 @@ class Client {
399
404
  }
400
405
  else {
401
406
  data = {
402
- message: text
407
+ message: yield response.text()
403
408
  };
404
409
  }
405
410
  if (400 <= response.status) {
406
- throw new AppwriteException(data === null || data === void 0 ? void 0 : data.message, response.status, data === null || data === void 0 ? void 0 : data.type, text);
411
+ let responseText = '';
412
+ if ((_b = response.headers.get('content-type')) === null || _b === void 0 ? void 0 : _b.includes('application/json')) {
413
+ responseText = JSON.stringify(data);
414
+ }
415
+ else {
416
+ responseText = data === null || data === void 0 ? void 0 : data.message;
417
+ }
418
+ throw new AppwriteException(data === null || data === void 0 ? void 0 : data.message, response.status, data === null || data === void 0 ? void 0 : data.type, responseText);
407
419
  }
408
420
  const cookieFallback = response.headers.get('X-Fallback-Cookies');
409
421
  if (typeof window !== 'undefined' && window.localStorage && cookieFallback) {
@@ -436,9 +448,7 @@ class Account extends Service {
436
448
  const apiPath = '/account';
437
449
  const payload = {};
438
450
  const uri = new URL(this.client.config.endpoint + apiPath);
439
- return this.client.call('get', uri, {
440
- 'content-type': 'application/json',
441
- }, payload);
451
+ return this.client.call('get', uri, {}, payload);
442
452
  }
443
453
  /**
444
454
  * Use this endpoint to allow a new user to register a new account in your
@@ -534,9 +544,7 @@ class Account extends Service {
534
544
  payload['queries'] = queries;
535
545
  }
536
546
  const uri = new URL(this.client.config.endpoint + apiPath);
537
- return this.client.call('get', uri, {
538
- 'content-type': 'application/json',
539
- }, payload);
547
+ return this.client.call('get', uri, {}, payload);
540
548
  }
541
549
  /**
542
550
  * Delete an identity by its unique ID.
@@ -589,9 +597,7 @@ class Account extends Service {
589
597
  payload['queries'] = queries;
590
598
  }
591
599
  const uri = new URL(this.client.config.endpoint + apiPath);
592
- return this.client.call('get', uri, {
593
- 'content-type': 'application/json',
594
- }, payload);
600
+ return this.client.call('get', uri, {}, payload);
595
601
  }
596
602
  /**
597
603
  * Enable or disable MFA on an account.
@@ -745,9 +751,7 @@ class Account extends Service {
745
751
  const apiPath = '/account/mfa/factors';
746
752
  const payload = {};
747
753
  const uri = new URL(this.client.config.endpoint + apiPath);
748
- return this.client.call('get', uri, {
749
- 'content-type': 'application/json',
750
- }, payload);
754
+ return this.client.call('get', uri, {}, payload);
751
755
  }
752
756
  /**
753
757
  * Get recovery codes that can be used as backup for MFA flow. Before getting
@@ -762,9 +766,7 @@ class Account extends Service {
762
766
  const apiPath = '/account/mfa/recovery-codes';
763
767
  const payload = {};
764
768
  const uri = new URL(this.client.config.endpoint + apiPath);
765
- return this.client.call('get', uri, {
766
- 'content-type': 'application/json',
767
- }, payload);
769
+ return this.client.call('get', uri, {}, payload);
768
770
  }
769
771
  /**
770
772
  * Generate recovery codes as backup for MFA flow. It's recommended to
@@ -891,9 +893,7 @@ class Account extends Service {
891
893
  const apiPath = '/account/prefs';
892
894
  const payload = {};
893
895
  const uri = new URL(this.client.config.endpoint + apiPath);
894
- return this.client.call('get', uri, {
895
- 'content-type': 'application/json',
896
- }, payload);
896
+ return this.client.call('get', uri, {}, payload);
897
897
  }
898
898
  /**
899
899
  * Update currently logged in user account preferences. The object you pass is
@@ -1008,9 +1008,7 @@ class Account extends Service {
1008
1008
  const apiPath = '/account/sessions';
1009
1009
  const payload = {};
1010
1010
  const uri = new URL(this.client.config.endpoint + apiPath);
1011
- return this.client.call('get', uri, {
1012
- 'content-type': 'application/json',
1013
- }, payload);
1011
+ return this.client.call('get', uri, {}, payload);
1014
1012
  }
1015
1013
  /**
1016
1014
  * Delete all sessions from the user account and remove any sessions cookies
@@ -1232,9 +1230,7 @@ class Account extends Service {
1232
1230
  const apiPath = '/account/sessions/{sessionId}'.replace('{sessionId}', sessionId);
1233
1231
  const payload = {};
1234
1232
  const uri = new URL(this.client.config.endpoint + apiPath);
1235
- return this.client.call('get', uri, {
1236
- 'content-type': 'application/json',
1237
- }, payload);
1233
+ return this.client.call('get', uri, {}, payload);
1238
1234
  }
1239
1235
  /**
1240
1236
  * Use this endpoint to extend a session's length. Extending a session is
@@ -1977,9 +1973,7 @@ class Databases extends Service {
1977
1973
  payload['queries'] = queries;
1978
1974
  }
1979
1975
  const uri = new URL(this.client.config.endpoint + apiPath);
1980
- return this.client.call('get', uri, {
1981
- 'content-type': 'application/json',
1982
- }, payload);
1976
+ return this.client.call('get', uri, {}, payload);
1983
1977
  }
1984
1978
  /**
1985
1979
  * Create a new Document. Before using this route, you should create a new
@@ -1987,6 +1981,7 @@ class Databases extends Service {
1987
1981
  * integration](https://appwrite.io/docs/server/databases#databasesCreateCollection)
1988
1982
  * API or directly from your database console.
1989
1983
  *
1984
+ *
1990
1985
  * @param {string} databaseId
1991
1986
  * @param {string} collectionId
1992
1987
  * @param {string} documentId
@@ -2051,9 +2046,7 @@ class Databases extends Service {
2051
2046
  payload['queries'] = queries;
2052
2047
  }
2053
2048
  const uri = new URL(this.client.config.endpoint + apiPath);
2054
- return this.client.call('get', uri, {
2055
- 'content-type': 'application/json',
2056
- }, payload);
2049
+ return this.client.call('get', uri, {}, payload);
2057
2050
  }
2058
2051
  /**
2059
2052
  * Update a document by its unique ID. Using the patch method you can pass
@@ -2145,9 +2138,7 @@ class Functions extends Service {
2145
2138
  payload['search'] = search;
2146
2139
  }
2147
2140
  const uri = new URL(this.client.config.endpoint + apiPath);
2148
- return this.client.call('get', uri, {
2149
- 'content-type': 'application/json',
2150
- }, payload);
2141
+ return this.client.call('get', uri, {}, payload);
2151
2142
  }
2152
2143
  /**
2153
2144
  * Trigger a function execution. The returned object will return you the
@@ -2212,9 +2203,7 @@ class Functions extends Service {
2212
2203
  const apiPath = '/functions/{functionId}/executions/{executionId}'.replace('{functionId}', functionId).replace('{executionId}', executionId);
2213
2204
  const payload = {};
2214
2205
  const uri = new URL(this.client.config.endpoint + apiPath);
2215
- return this.client.call('get', uri, {
2216
- 'content-type': 'application/json',
2217
- }, payload);
2206
+ return this.client.call('get', uri, {}, payload);
2218
2207
  }
2219
2208
  }
2220
2209
 
@@ -2287,9 +2276,7 @@ class Locale extends Service {
2287
2276
  const apiPath = '/locale';
2288
2277
  const payload = {};
2289
2278
  const uri = new URL(this.client.config.endpoint + apiPath);
2290
- return this.client.call('get', uri, {
2291
- 'content-type': 'application/json',
2292
- }, payload);
2279
+ return this.client.call('get', uri, {}, payload);
2293
2280
  }
2294
2281
  /**
2295
2282
  * List of all locale codes in [ISO
@@ -2302,9 +2289,7 @@ class Locale extends Service {
2302
2289
  const apiPath = '/locale/codes';
2303
2290
  const payload = {};
2304
2291
  const uri = new URL(this.client.config.endpoint + apiPath);
2305
- return this.client.call('get', uri, {
2306
- 'content-type': 'application/json',
2307
- }, payload);
2292
+ return this.client.call('get', uri, {}, payload);
2308
2293
  }
2309
2294
  /**
2310
2295
  * List of all continents. You can use the locale header to get the data in a
@@ -2317,9 +2302,7 @@ class Locale extends Service {
2317
2302
  const apiPath = '/locale/continents';
2318
2303
  const payload = {};
2319
2304
  const uri = new URL(this.client.config.endpoint + apiPath);
2320
- return this.client.call('get', uri, {
2321
- 'content-type': 'application/json',
2322
- }, payload);
2305
+ return this.client.call('get', uri, {}, payload);
2323
2306
  }
2324
2307
  /**
2325
2308
  * List of all countries. You can use the locale header to get the data in a
@@ -2332,9 +2315,7 @@ class Locale extends Service {
2332
2315
  const apiPath = '/locale/countries';
2333
2316
  const payload = {};
2334
2317
  const uri = new URL(this.client.config.endpoint + apiPath);
2335
- return this.client.call('get', uri, {
2336
- 'content-type': 'application/json',
2337
- }, payload);
2318
+ return this.client.call('get', uri, {}, payload);
2338
2319
  }
2339
2320
  /**
2340
2321
  * List of all countries that are currently members of the EU. You can use the
@@ -2347,9 +2328,7 @@ class Locale extends Service {
2347
2328
  const apiPath = '/locale/countries/eu';
2348
2329
  const payload = {};
2349
2330
  const uri = new URL(this.client.config.endpoint + apiPath);
2350
- return this.client.call('get', uri, {
2351
- 'content-type': 'application/json',
2352
- }, payload);
2331
+ return this.client.call('get', uri, {}, payload);
2353
2332
  }
2354
2333
  /**
2355
2334
  * List of all countries phone codes. You can use the locale header to get the
@@ -2362,9 +2341,7 @@ class Locale extends Service {
2362
2341
  const apiPath = '/locale/countries/phones';
2363
2342
  const payload = {};
2364
2343
  const uri = new URL(this.client.config.endpoint + apiPath);
2365
- return this.client.call('get', uri, {
2366
- 'content-type': 'application/json',
2367
- }, payload);
2344
+ return this.client.call('get', uri, {}, payload);
2368
2345
  }
2369
2346
  /**
2370
2347
  * List of all currencies, including currency symbol, name, plural, and
@@ -2378,9 +2355,7 @@ class Locale extends Service {
2378
2355
  const apiPath = '/locale/currencies';
2379
2356
  const payload = {};
2380
2357
  const uri = new URL(this.client.config.endpoint + apiPath);
2381
- return this.client.call('get', uri, {
2382
- 'content-type': 'application/json',
2383
- }, payload);
2358
+ return this.client.call('get', uri, {}, payload);
2384
2359
  }
2385
2360
  /**
2386
2361
  * List of all languages classified by ISO 639-1 including 2-letter code, name
@@ -2393,9 +2368,7 @@ class Locale extends Service {
2393
2368
  const apiPath = '/locale/languages';
2394
2369
  const payload = {};
2395
2370
  const uri = new URL(this.client.config.endpoint + apiPath);
2396
- return this.client.call('get', uri, {
2397
- 'content-type': 'application/json',
2398
- }, payload);
2371
+ return this.client.call('get', uri, {}, payload);
2399
2372
  }
2400
2373
  }
2401
2374
 
@@ -2486,9 +2459,7 @@ class Storage extends Service {
2486
2459
  payload['search'] = search;
2487
2460
  }
2488
2461
  const uri = new URL(this.client.config.endpoint + apiPath);
2489
- return this.client.call('get', uri, {
2490
- 'content-type': 'application/json',
2491
- }, payload);
2462
+ return this.client.call('get', uri, {}, payload);
2492
2463
  }
2493
2464
  /**
2494
2465
  * Create a new file. Before using this route, you should create a new bucket
@@ -2517,8 +2488,8 @@ class Storage extends Service {
2517
2488
  * @throws {AppwriteException}
2518
2489
  * @returns {Promise}
2519
2490
  */
2520
- createFile(bucketId, fileId, file, permissions, onProgress = (progress) => { }) {
2521
- return __awaiter(this, void 0, void 0, function* () {
2491
+ createFile(bucketId_1, fileId_1, file_1, permissions_1) {
2492
+ return __awaiter(this, arguments, void 0, function* (bucketId, fileId, file, permissions, onProgress = (progress) => { }) {
2522
2493
  if (typeof bucketId === 'undefined') {
2523
2494
  throw new AppwriteException('Missing required parameter: "bucketId"');
2524
2495
  }
@@ -2609,9 +2580,7 @@ class Storage extends Service {
2609
2580
  const apiPath = '/storage/buckets/{bucketId}/files/{fileId}'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
2610
2581
  const payload = {};
2611
2582
  const uri = new URL(this.client.config.endpoint + apiPath);
2612
- return this.client.call('get', uri, {
2613
- 'content-type': 'application/json',
2614
- }, payload);
2583
+ return this.client.call('get', uri, {}, payload);
2615
2584
  }
2616
2585
  /**
2617
2586
  * Update a file by its unique ID. Only users with write permissions have
@@ -2816,9 +2785,7 @@ class Teams extends Service {
2816
2785
  payload['search'] = search;
2817
2786
  }
2818
2787
  const uri = new URL(this.client.config.endpoint + apiPath);
2819
- return this.client.call('get', uri, {
2820
- 'content-type': 'application/json',
2821
- }, payload);
2788
+ return this.client.call('get', uri, {}, payload);
2822
2789
  }
2823
2790
  /**
2824
2791
  * Create a new team. The user who creates the team will automatically be
@@ -2868,9 +2835,7 @@ class Teams extends Service {
2868
2835
  const apiPath = '/teams/{teamId}'.replace('{teamId}', teamId);
2869
2836
  const payload = {};
2870
2837
  const uri = new URL(this.client.config.endpoint + apiPath);
2871
- return this.client.call('get', uri, {
2872
- 'content-type': 'application/json',
2873
- }, payload);
2838
+ return this.client.call('get', uri, {}, payload);
2874
2839
  }
2875
2840
  /**
2876
2841
  * Update the team's name by its unique ID.
@@ -2940,9 +2905,7 @@ class Teams extends Service {
2940
2905
  payload['search'] = search;
2941
2906
  }
2942
2907
  const uri = new URL(this.client.config.endpoint + apiPath);
2943
- return this.client.call('get', uri, {
2944
- 'content-type': 'application/json',
2945
- }, payload);
2908
+ return this.client.call('get', uri, {}, payload);
2946
2909
  }
2947
2910
  /**
2948
2911
  * Invite a new member to join your team. Provide an ID for existing users, or
@@ -3029,9 +2992,7 @@ class Teams extends Service {
3029
2992
  const apiPath = '/teams/{teamId}/memberships/{membershipId}'.replace('{teamId}', teamId).replace('{membershipId}', membershipId);
3030
2993
  const payload = {};
3031
2994
  const uri = new URL(this.client.config.endpoint + apiPath);
3032
- return this.client.call('get', uri, {
3033
- 'content-type': 'application/json',
3034
- }, payload);
2995
+ return this.client.call('get', uri, {}, payload);
3035
2996
  }
3036
2997
  /**
3037
2998
  * Modify the roles of a team member. Only team members with the owner role
@@ -3147,9 +3108,7 @@ class Teams extends Service {
3147
3108
  const apiPath = '/teams/{teamId}/prefs'.replace('{teamId}', teamId);
3148
3109
  const payload = {};
3149
3110
  const uri = new URL(this.client.config.endpoint + apiPath);
3150
- return this.client.call('get', uri, {
3151
- 'content-type': 'application/json',
3152
- }, payload);
3111
+ return this.client.call('get', uri, {}, payload);
3153
3112
  }
3154
3113
  /**
3155
3114
  * Update the team's preferences by its unique ID. The object you pass is
@@ -3343,7 +3302,7 @@ class ID {
3343
3302
  }
3344
3303
  static unique(padding = 7) {
3345
3304
  // Generate a unique ID with padding to have a longer ID
3346
- const baseId = __classPrivateFieldGet(ID, _a, "m", _ID_hexTimestamp).call(ID);
3305
+ const baseId = __classPrivateFieldGet(_a, _a, "m", _ID_hexTimestamp).call(_a);
3347
3306
  let randomPadding = '';
3348
3307
  for (let i = 0; i < padding; i++) {
3349
3308
  const randomHexDigit = Math.floor(Math.random() * 16).toString(16);
@@ -3390,6 +3349,7 @@ var OAuthProvider;
3390
3349
  OAuthProvider["Dropbox"] = "dropbox";
3391
3350
  OAuthProvider["Etsy"] = "etsy";
3392
3351
  OAuthProvider["Facebook"] = "facebook";
3352
+ OAuthProvider["Figma"] = "figma";
3393
3353
  OAuthProvider["Github"] = "github";
3394
3354
  OAuthProvider["Gitlab"] = "gitlab";
3395
3355
  OAuthProvider["Google"] = "google";
@@ -3453,6 +3413,7 @@ var CreditCard;
3453
3413
  CreditCard["Visa"] = "visa";
3454
3414
  CreditCard["MIR"] = "mir";
3455
3415
  CreditCard["Maestro"] = "maestro";
3416
+ CreditCard["Rupay"] = "rupay";
3456
3417
  })(CreditCard || (CreditCard = {}));
3457
3418
 
3458
3419
  var Flag;