react-native-appwrite 0.4.0 → 0.6.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.
Files changed (118) hide show
  1. package/README.md +2 -2
  2. package/dist/cjs/sdk.js +47 -28
  3. package/dist/cjs/sdk.js.map +1 -1
  4. package/dist/esm/sdk.js +47 -28
  5. package/dist/esm/sdk.js.map +1 -1
  6. package/docs/examples/account/create-anonymous-session.md +2 -2
  7. package/docs/examples/account/create-email-password-session.md +2 -2
  8. package/docs/examples/account/create-email-token.md +2 -2
  9. package/docs/examples/account/create-j-w-t.md +2 -2
  10. package/docs/examples/account/create-magic-u-r-l-token.md +2 -2
  11. package/docs/examples/account/create-mfa-authenticator.md +2 -2
  12. package/docs/examples/account/create-mfa-challenge.md +2 -2
  13. package/docs/examples/account/create-mfa-recovery-codes.md +2 -2
  14. package/docs/examples/account/create-o-auth2session.md +1 -1
  15. package/docs/examples/account/create-o-auth2token.md +1 -1
  16. package/docs/examples/account/create-phone-token.md +2 -2
  17. package/docs/examples/account/create-phone-verification.md +2 -2
  18. package/docs/examples/account/create-push-target.md +2 -2
  19. package/docs/examples/account/create-recovery.md +2 -2
  20. package/docs/examples/account/create-session.md +2 -2
  21. package/docs/examples/account/create-verification.md +2 -2
  22. package/docs/examples/account/create.md +2 -2
  23. package/docs/examples/account/delete-identity.md +2 -2
  24. package/docs/examples/account/delete-mfa-authenticator.md +3 -4
  25. package/docs/examples/account/delete-push-target.md +2 -2
  26. package/docs/examples/account/delete-session.md +2 -2
  27. package/docs/examples/account/delete-sessions.md +2 -2
  28. package/docs/examples/account/get-mfa-recovery-codes.md +2 -2
  29. package/docs/examples/account/get-prefs.md +2 -2
  30. package/docs/examples/account/get-session.md +2 -2
  31. package/docs/examples/account/get.md +2 -2
  32. package/docs/examples/account/list-identities.md +2 -2
  33. package/docs/examples/account/list-logs.md +2 -2
  34. package/docs/examples/account/list-mfa-factors.md +2 -2
  35. package/docs/examples/account/list-sessions.md +2 -2
  36. package/docs/examples/account/update-email.md +2 -2
  37. package/docs/examples/account/update-m-f-a.md +2 -2
  38. package/docs/examples/account/update-magic-u-r-l-session.md +2 -2
  39. package/docs/examples/account/update-mfa-authenticator.md +2 -2
  40. package/docs/examples/account/update-mfa-challenge.md +2 -2
  41. package/docs/examples/account/update-mfa-recovery-codes.md +2 -2
  42. package/docs/examples/account/update-name.md +2 -2
  43. package/docs/examples/account/update-password.md +2 -2
  44. package/docs/examples/account/update-phone-session.md +2 -2
  45. package/docs/examples/account/update-phone-verification.md +2 -2
  46. package/docs/examples/account/update-phone.md +2 -2
  47. package/docs/examples/account/update-prefs.md +2 -2
  48. package/docs/examples/account/update-push-target.md +2 -2
  49. package/docs/examples/account/update-recovery.md +2 -2
  50. package/docs/examples/account/update-session.md +2 -2
  51. package/docs/examples/account/update-status.md +2 -2
  52. package/docs/examples/account/update-verification.md +2 -2
  53. package/docs/examples/avatars/get-browser.md +1 -1
  54. package/docs/examples/avatars/get-credit-card.md +1 -1
  55. package/docs/examples/avatars/get-favicon.md +1 -1
  56. package/docs/examples/avatars/get-flag.md +1 -1
  57. package/docs/examples/avatars/get-image.md +1 -1
  58. package/docs/examples/avatars/get-initials.md +1 -1
  59. package/docs/examples/avatars/get-q-r.md +1 -1
  60. package/docs/examples/databases/create-document.md +2 -2
  61. package/docs/examples/databases/delete-document.md +2 -2
  62. package/docs/examples/databases/get-document.md +2 -2
  63. package/docs/examples/databases/list-documents.md +2 -2
  64. package/docs/examples/databases/update-document.md +2 -2
  65. package/docs/examples/functions/create-execution.md +4 -3
  66. package/docs/examples/functions/get-execution.md +2 -2
  67. package/docs/examples/functions/list-executions.md +2 -2
  68. package/docs/examples/graphql/mutation.md +2 -2
  69. package/docs/examples/graphql/query.md +2 -2
  70. package/docs/examples/locale/get.md +2 -2
  71. package/docs/examples/locale/list-codes.md +2 -2
  72. package/docs/examples/locale/list-continents.md +2 -2
  73. package/docs/examples/locale/list-countries-e-u.md +2 -2
  74. package/docs/examples/locale/list-countries-phones.md +2 -2
  75. package/docs/examples/locale/list-countries.md +2 -2
  76. package/docs/examples/locale/list-currencies.md +2 -2
  77. package/docs/examples/locale/list-languages.md +2 -2
  78. package/docs/examples/messaging/create-subscriber.md +2 -2
  79. package/docs/examples/messaging/delete-subscriber.md +2 -2
  80. package/docs/examples/storage/create-file.md +2 -2
  81. package/docs/examples/storage/delete-file.md +2 -2
  82. package/docs/examples/storage/get-file-download.md +1 -1
  83. package/docs/examples/storage/get-file-preview.md +1 -1
  84. package/docs/examples/storage/get-file-view.md +1 -1
  85. package/docs/examples/storage/get-file.md +2 -2
  86. package/docs/examples/storage/list-files.md +2 -2
  87. package/docs/examples/storage/update-file.md +2 -2
  88. package/docs/examples/teams/create-membership.md +2 -2
  89. package/docs/examples/teams/create.md +2 -2
  90. package/docs/examples/teams/delete-membership.md +2 -2
  91. package/docs/examples/teams/delete.md +2 -2
  92. package/docs/examples/teams/get-membership.md +2 -2
  93. package/docs/examples/teams/get-prefs.md +2 -2
  94. package/docs/examples/teams/get.md +2 -2
  95. package/docs/examples/teams/list-memberships.md +2 -2
  96. package/docs/examples/teams/list.md +2 -2
  97. package/docs/examples/teams/update-membership-status.md +2 -2
  98. package/docs/examples/teams/update-membership.md +2 -2
  99. package/docs/examples/teams/update-name.md +2 -2
  100. package/docs/examples/teams/update-prefs.md +2 -2
  101. package/package.json +1 -1
  102. package/src/client.ts +31 -2
  103. package/src/enums/image-format.ts +1 -0
  104. package/src/models.ts +11 -3
  105. package/src/services/account.ts +14 -23
  106. package/src/services/avatars.ts +2 -0
  107. package/src/services/functions.ts +6 -1
  108. package/src/services/locale.ts +1 -1
  109. package/src/services/storage.ts +1 -1
  110. package/src/services/teams.ts +4 -2
  111. package/types/enums/image-format.d.ts +2 -1
  112. package/types/models.d.ts +11 -3
  113. package/types/services/account.d.ts +13 -14
  114. package/types/services/avatars.d.ts +2 -0
  115. package/types/services/functions.d.ts +2 -1
  116. package/types/services/locale.d.ts +1 -1
  117. package/types/services/storage.d.ts +1 -1
  118. package/types/services/teams.d.ts +4 -2
package/README.md CHANGED
@@ -1,12 +1,12 @@
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.5.7-blue.svg?style=flat-square)
4
+ ![Version](https://img.shields.io/badge/api%20version-1.6.0-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)
8
8
 
9
- **This SDK is compatible with Appwrite server version 1.5.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-react-native/releases).**
9
+ **This SDK is compatible with Appwrite server version 1.6.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
@@ -99,12 +99,13 @@ 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.4.0',
103
- 'X-Appwrite-Response-Format': '1.5.0',
102
+ 'x-sdk-version': '0.6.0',
103
+ 'X-Appwrite-Response-Format': '1.6.0',
104
104
  };
105
105
  this.realtime = {
106
106
  socket: undefined,
107
107
  timeout: undefined,
108
+ heartbeat: undefined,
108
109
  url: '',
109
110
  channels: new Set(),
110
111
  subscriptions: new Map(),
@@ -130,6 +131,17 @@ class Client {
130
131
  return 60000;
131
132
  }
132
133
  },
134
+ createHeartbeat: () => {
135
+ if (this.realtime.heartbeat) {
136
+ clearTimeout(this.realtime.heartbeat);
137
+ }
138
+ this.realtime.heartbeat = window === null || window === void 0 ? void 0 : window.setInterval(() => {
139
+ var _a;
140
+ (_a = this.realtime.socket) === null || _a === void 0 ? void 0 : _a.send(JSON.stringify({
141
+ type: 'ping'
142
+ }));
143
+ }, 20000);
144
+ },
133
145
  createSocket: () => {
134
146
  var _a, _b, _c;
135
147
  if (this.realtime.channels.size < 1) {
@@ -163,6 +175,7 @@ class Client {
163
175
  this.realtime.socket.addEventListener('message', this.realtime.onMessage);
164
176
  this.realtime.socket.addEventListener('open', _event => {
165
177
  this.realtime.reconnectAttempts = 0;
178
+ this.realtime.createHeartbeat();
166
179
  });
167
180
  this.realtime.socket.addEventListener('close', event => {
168
181
  var _a, _b, _c;
@@ -396,6 +409,10 @@ class Client {
396
409
  try {
397
410
  let data = null;
398
411
  const response = yield fetch(url.toString(), options);
412
+ const warnings = response.headers.get('x-appwrite-warning');
413
+ if (warnings) {
414
+ warnings.split(';').forEach((warning) => console.warn('Warning: ' + warning));
415
+ }
399
416
  if ((_a = response.headers.get('content-type')) === null || _a === void 0 ? void 0 : _a.includes('application/json')) {
400
417
  data = yield response.json();
401
418
  }
@@ -535,7 +552,7 @@ class Account extends Service {
535
552
  });
536
553
  }
537
554
  /**
538
- * List Identities
555
+ * List identities
539
556
  *
540
557
  * Get the list of identities for the currently logged in user.
541
558
  *
@@ -592,7 +609,7 @@ class Account extends Service {
592
609
  */
593
610
  createJWT() {
594
611
  return __awaiter(this, void 0, void 0, function* () {
595
- const apiPath = '/account/jwt';
612
+ const apiPath = '/account/jwts';
596
613
  const payload = {};
597
614
  const uri = new URL(this.client.config.endpoint + apiPath);
598
615
  return yield this.client.call('post', uri, {
@@ -649,7 +666,7 @@ class Account extends Service {
649
666
  });
650
667
  }
651
668
  /**
652
- * Add Authenticator
669
+ * Create authenticator
653
670
  *
654
671
  * Add an authenticator app to be used as an MFA factor. Verify the
655
672
  * authenticator using the [verify
@@ -674,11 +691,11 @@ class Account extends Service {
674
691
  });
675
692
  }
676
693
  /**
677
- * Verify Authenticator
694
+ * Verify authenticator
678
695
  *
679
696
  * Verify an authenticator app after adding it using the [add
680
697
  * authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator)
681
- * method. add
698
+ * method.
682
699
  *
683
700
  * @param {AuthenticatorType} type
684
701
  * @param {string} otp
@@ -705,28 +722,21 @@ class Account extends Service {
705
722
  });
706
723
  }
707
724
  /**
708
- * Delete Authenticator
725
+ * Delete authenticator
709
726
  *
710
727
  * Delete an authenticator for a user by ID.
711
728
  *
712
729
  * @param {AuthenticatorType} type
713
- * @param {string} otp
714
730
  * @throws {AppwriteException}
715
731
  * @returns {Promise}
716
732
  */
717
- deleteMfaAuthenticator(type, otp) {
733
+ deleteMfaAuthenticator(type) {
718
734
  return __awaiter(this, void 0, void 0, function* () {
719
735
  if (typeof type === 'undefined') {
720
736
  throw new AppwriteException('Missing required parameter: "type"');
721
737
  }
722
- if (typeof otp === 'undefined') {
723
- throw new AppwriteException('Missing required parameter: "otp"');
724
- }
725
738
  const apiPath = '/account/mfa/authenticators/{type}'.replace('{type}', type);
726
739
  const payload = {};
727
- if (typeof otp !== 'undefined') {
728
- payload['otp'] = otp;
729
- }
730
740
  const uri = new URL(this.client.config.endpoint + apiPath);
731
741
  return yield this.client.call('delete', uri, {
732
742
  'content-type': 'application/json',
@@ -734,7 +744,7 @@ class Account extends Service {
734
744
  });
735
745
  }
736
746
  /**
737
- * Create 2FA Challenge
747
+ * Create MFA challenge
738
748
  *
739
749
  * Begin the process of MFA verification after sign-in. Finish the flow with
740
750
  * [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge)
@@ -761,7 +771,7 @@ class Account extends Service {
761
771
  });
762
772
  }
763
773
  /**
764
- * Create MFA Challenge (confirmation)
774
+ * Create MFA challenge (confirmation)
765
775
  *
766
776
  * Complete the MFA challenge by providing the one-time password. Finish the
767
777
  * process of MFA verification by providing the one-time password. To begin
@@ -797,7 +807,7 @@ class Account extends Service {
797
807
  });
798
808
  }
799
809
  /**
800
- * List Factors
810
+ * List factors
801
811
  *
802
812
  * List the factors available on the account to be used as a MFA challange.
803
813
  *
@@ -815,7 +825,7 @@ class Account extends Service {
815
825
  });
816
826
  }
817
827
  /**
818
- * Get MFA Recovery Codes
828
+ * Get MFA recovery codes
819
829
  *
820
830
  * Get recovery codes that can be used as backup for MFA flow. Before getting
821
831
  * codes, they must be generated using
@@ -836,7 +846,7 @@ class Account extends Service {
836
846
  });
837
847
  }
838
848
  /**
839
- * Create MFA Recovery Codes
849
+ * Create MFA recovery codes
840
850
  *
841
851
  * Generate recovery codes as backup for MFA flow. It's recommended to
842
852
  * generate and show then immediately after user successfully adds their
@@ -858,7 +868,7 @@ class Account extends Service {
858
868
  });
859
869
  }
860
870
  /**
861
- * Regenerate MFA Recovery Codes
871
+ * Regenerate MFA recovery codes
862
872
  *
863
873
  * Regenerate recovery codes that can be used as backup for MFA flow. Before
864
874
  * regenerating codes, they must be first generated using
@@ -1817,7 +1827,7 @@ class Account extends Service {
1817
1827
  });
1818
1828
  }
1819
1829
  /**
1820
- * Create phone verification (confirmation)
1830
+ * Update phone verification (confirmation)
1821
1831
  *
1822
1832
  * Use this endpoint to complete the user phone verification process. Use the
1823
1833
  * **userId** and **secret** that were sent to your user's phone number to
@@ -1948,6 +1958,7 @@ class Avatars extends Service {
1948
1958
  * Use this endpoint to fetch the favorite icon (AKA favicon) of any remote
1949
1959
  * website URL.
1950
1960
  *
1961
+ * This endpoint does not follow HTTP redirects.
1951
1962
  *
1952
1963
  * @param {string} url
1953
1964
  * @throws {AppwriteException}
@@ -2025,6 +2036,7 @@ class Avatars extends Service {
2025
2036
  * image at source quality. If dimensions are not specified, the default size
2026
2037
  * of image returned is 400x400px.
2027
2038
  *
2039
+ * This endpoint does not follow HTTP redirects.
2028
2040
  *
2029
2041
  * @param {string} url
2030
2042
  * @param {number} width
@@ -2381,10 +2393,11 @@ class Functions extends Service {
2381
2393
  * @param {string} xpath
2382
2394
  * @param {ExecutionMethod} method
2383
2395
  * @param {object} headers
2396
+ * @param {string} scheduledAt
2384
2397
  * @throws {AppwriteException}
2385
2398
  * @returns {Promise}
2386
2399
  */
2387
- createExecution(functionId, body, async, xpath, method, headers) {
2400
+ createExecution(functionId, body, async, xpath, method, headers, scheduledAt) {
2388
2401
  return __awaiter(this, void 0, void 0, function* () {
2389
2402
  if (typeof functionId === 'undefined') {
2390
2403
  throw new AppwriteException('Missing required parameter: "functionId"');
@@ -2406,6 +2419,9 @@ class Functions extends Service {
2406
2419
  if (typeof headers !== 'undefined') {
2407
2420
  payload['headers'] = headers;
2408
2421
  }
2422
+ if (typeof scheduledAt !== 'undefined') {
2423
+ payload['scheduledAt'] = scheduledAt;
2424
+ }
2409
2425
  const uri = new URL(this.client.config.endpoint + apiPath);
2410
2426
  return yield this.client.call('post', uri, {
2411
2427
  'content-type': 'application/json',
@@ -2526,7 +2542,7 @@ class Locale extends Service {
2526
2542
  });
2527
2543
  }
2528
2544
  /**
2529
- * List Locale Codes
2545
+ * List locale codes
2530
2546
  *
2531
2547
  * List of all locale codes in [ISO
2532
2548
  * 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes).
@@ -2931,7 +2947,7 @@ class Storage extends Service {
2931
2947
  });
2932
2948
  }
2933
2949
  /**
2934
- * Delete File
2950
+ * Delete file
2935
2951
  *
2936
2952
  * Delete a file by its unique ID. Only users with write permissions have
2937
2953
  * access to delete this resource.
@@ -3236,7 +3252,8 @@ class Teams extends Service {
3236
3252
  * List team memberships
3237
3253
  *
3238
3254
  * Use this endpoint to list a team's members using the team's ID. All team
3239
- * members have read access to this endpoint.
3255
+ * members have read access to this endpoint. Hide sensitive attributes from
3256
+ * the response by toggling membership privacy in the Console.
3240
3257
  *
3241
3258
  * @param {string} teamId
3242
3259
  * @param {string[]} queries
@@ -3336,7 +3353,8 @@ class Teams extends Service {
3336
3353
  * Get team membership
3337
3354
  *
3338
3355
  * Get a team member by the membership unique id. All team members have read
3339
- * access for this resource.
3356
+ * access for this resource. Hide sensitive attributes from the response by
3357
+ * toggling membership privacy in the Console.
3340
3358
  *
3341
3359
  * @param {string} teamId
3342
3360
  * @param {string} membershipId
@@ -4030,6 +4048,7 @@ exports.ImageFormat = void 0;
4030
4048
  ImageFormat["Gif"] = "gif";
4031
4049
  ImageFormat["Png"] = "png";
4032
4050
  ImageFormat["Webp"] = "webp";
4051
+ ImageFormat["Avif"] = "avif";
4033
4052
  })(exports.ImageFormat || (exports.ImageFormat = {}));
4034
4053
 
4035
4054
  exports.Account = Account;