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/dist/esm/sdk.js CHANGED
@@ -77,12 +77,13 @@ 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.4.0',
81
- 'X-Appwrite-Response-Format': '1.5.0',
80
+ 'x-sdk-version': '0.6.0',
81
+ 'X-Appwrite-Response-Format': '1.6.0',
82
82
  };
83
83
  this.realtime = {
84
84
  socket: undefined,
85
85
  timeout: undefined,
86
+ heartbeat: undefined,
86
87
  url: '',
87
88
  channels: new Set(),
88
89
  subscriptions: new Map(),
@@ -108,6 +109,17 @@ class Client {
108
109
  return 60000;
109
110
  }
110
111
  },
112
+ createHeartbeat: () => {
113
+ if (this.realtime.heartbeat) {
114
+ clearTimeout(this.realtime.heartbeat);
115
+ }
116
+ this.realtime.heartbeat = window === null || window === void 0 ? void 0 : window.setInterval(() => {
117
+ var _a;
118
+ (_a = this.realtime.socket) === null || _a === void 0 ? void 0 : _a.send(JSON.stringify({
119
+ type: 'ping'
120
+ }));
121
+ }, 20000);
122
+ },
111
123
  createSocket: () => {
112
124
  var _a, _b, _c;
113
125
  if (this.realtime.channels.size < 1) {
@@ -141,6 +153,7 @@ class Client {
141
153
  this.realtime.socket.addEventListener('message', this.realtime.onMessage);
142
154
  this.realtime.socket.addEventListener('open', _event => {
143
155
  this.realtime.reconnectAttempts = 0;
156
+ this.realtime.createHeartbeat();
144
157
  });
145
158
  this.realtime.socket.addEventListener('close', event => {
146
159
  var _a, _b, _c;
@@ -374,6 +387,10 @@ class Client {
374
387
  try {
375
388
  let data = null;
376
389
  const response = yield fetch(url.toString(), options);
390
+ const warnings = response.headers.get('x-appwrite-warning');
391
+ if (warnings) {
392
+ warnings.split(';').forEach((warning) => console.warn('Warning: ' + warning));
393
+ }
377
394
  if ((_a = response.headers.get('content-type')) === null || _a === void 0 ? void 0 : _a.includes('application/json')) {
378
395
  data = yield response.json();
379
396
  }
@@ -513,7 +530,7 @@ class Account extends Service {
513
530
  });
514
531
  }
515
532
  /**
516
- * List Identities
533
+ * List identities
517
534
  *
518
535
  * Get the list of identities for the currently logged in user.
519
536
  *
@@ -570,7 +587,7 @@ class Account extends Service {
570
587
  */
571
588
  createJWT() {
572
589
  return __awaiter(this, void 0, void 0, function* () {
573
- const apiPath = '/account/jwt';
590
+ const apiPath = '/account/jwts';
574
591
  const payload = {};
575
592
  const uri = new URL(this.client.config.endpoint + apiPath);
576
593
  return yield this.client.call('post', uri, {
@@ -627,7 +644,7 @@ class Account extends Service {
627
644
  });
628
645
  }
629
646
  /**
630
- * Add Authenticator
647
+ * Create authenticator
631
648
  *
632
649
  * Add an authenticator app to be used as an MFA factor. Verify the
633
650
  * authenticator using the [verify
@@ -652,11 +669,11 @@ class Account extends Service {
652
669
  });
653
670
  }
654
671
  /**
655
- * Verify Authenticator
672
+ * Verify authenticator
656
673
  *
657
674
  * Verify an authenticator app after adding it using the [add
658
675
  * authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator)
659
- * method. add
676
+ * method.
660
677
  *
661
678
  * @param {AuthenticatorType} type
662
679
  * @param {string} otp
@@ -683,28 +700,21 @@ class Account extends Service {
683
700
  });
684
701
  }
685
702
  /**
686
- * Delete Authenticator
703
+ * Delete authenticator
687
704
  *
688
705
  * Delete an authenticator for a user by ID.
689
706
  *
690
707
  * @param {AuthenticatorType} type
691
- * @param {string} otp
692
708
  * @throws {AppwriteException}
693
709
  * @returns {Promise}
694
710
  */
695
- deleteMfaAuthenticator(type, otp) {
711
+ deleteMfaAuthenticator(type) {
696
712
  return __awaiter(this, void 0, void 0, function* () {
697
713
  if (typeof type === 'undefined') {
698
714
  throw new AppwriteException('Missing required parameter: "type"');
699
715
  }
700
- if (typeof otp === 'undefined') {
701
- throw new AppwriteException('Missing required parameter: "otp"');
702
- }
703
716
  const apiPath = '/account/mfa/authenticators/{type}'.replace('{type}', type);
704
717
  const payload = {};
705
- if (typeof otp !== 'undefined') {
706
- payload['otp'] = otp;
707
- }
708
718
  const uri = new URL(this.client.config.endpoint + apiPath);
709
719
  return yield this.client.call('delete', uri, {
710
720
  'content-type': 'application/json',
@@ -712,7 +722,7 @@ class Account extends Service {
712
722
  });
713
723
  }
714
724
  /**
715
- * Create 2FA Challenge
725
+ * Create MFA challenge
716
726
  *
717
727
  * Begin the process of MFA verification after sign-in. Finish the flow with
718
728
  * [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge)
@@ -739,7 +749,7 @@ class Account extends Service {
739
749
  });
740
750
  }
741
751
  /**
742
- * Create MFA Challenge (confirmation)
752
+ * Create MFA challenge (confirmation)
743
753
  *
744
754
  * Complete the MFA challenge by providing the one-time password. Finish the
745
755
  * process of MFA verification by providing the one-time password. To begin
@@ -775,7 +785,7 @@ class Account extends Service {
775
785
  });
776
786
  }
777
787
  /**
778
- * List Factors
788
+ * List factors
779
789
  *
780
790
  * List the factors available on the account to be used as a MFA challange.
781
791
  *
@@ -793,7 +803,7 @@ class Account extends Service {
793
803
  });
794
804
  }
795
805
  /**
796
- * Get MFA Recovery Codes
806
+ * Get MFA recovery codes
797
807
  *
798
808
  * Get recovery codes that can be used as backup for MFA flow. Before getting
799
809
  * codes, they must be generated using
@@ -814,7 +824,7 @@ class Account extends Service {
814
824
  });
815
825
  }
816
826
  /**
817
- * Create MFA Recovery Codes
827
+ * Create MFA recovery codes
818
828
  *
819
829
  * Generate recovery codes as backup for MFA flow. It's recommended to
820
830
  * generate and show then immediately after user successfully adds their
@@ -836,7 +846,7 @@ class Account extends Service {
836
846
  });
837
847
  }
838
848
  /**
839
- * Regenerate MFA Recovery Codes
849
+ * Regenerate MFA recovery codes
840
850
  *
841
851
  * Regenerate recovery codes that can be used as backup for MFA flow. Before
842
852
  * regenerating codes, they must be first generated using
@@ -1795,7 +1805,7 @@ class Account extends Service {
1795
1805
  });
1796
1806
  }
1797
1807
  /**
1798
- * Create phone verification (confirmation)
1808
+ * Update phone verification (confirmation)
1799
1809
  *
1800
1810
  * Use this endpoint to complete the user phone verification process. Use the
1801
1811
  * **userId** and **secret** that were sent to your user's phone number to
@@ -1926,6 +1936,7 @@ class Avatars extends Service {
1926
1936
  * Use this endpoint to fetch the favorite icon (AKA favicon) of any remote
1927
1937
  * website URL.
1928
1938
  *
1939
+ * This endpoint does not follow HTTP redirects.
1929
1940
  *
1930
1941
  * @param {string} url
1931
1942
  * @throws {AppwriteException}
@@ -2003,6 +2014,7 @@ class Avatars extends Service {
2003
2014
  * image at source quality. If dimensions are not specified, the default size
2004
2015
  * of image returned is 400x400px.
2005
2016
  *
2017
+ * This endpoint does not follow HTTP redirects.
2006
2018
  *
2007
2019
  * @param {string} url
2008
2020
  * @param {number} width
@@ -2359,10 +2371,11 @@ class Functions extends Service {
2359
2371
  * @param {string} xpath
2360
2372
  * @param {ExecutionMethod} method
2361
2373
  * @param {object} headers
2374
+ * @param {string} scheduledAt
2362
2375
  * @throws {AppwriteException}
2363
2376
  * @returns {Promise}
2364
2377
  */
2365
- createExecution(functionId, body, async, xpath, method, headers) {
2378
+ createExecution(functionId, body, async, xpath, method, headers, scheduledAt) {
2366
2379
  return __awaiter(this, void 0, void 0, function* () {
2367
2380
  if (typeof functionId === 'undefined') {
2368
2381
  throw new AppwriteException('Missing required parameter: "functionId"');
@@ -2384,6 +2397,9 @@ class Functions extends Service {
2384
2397
  if (typeof headers !== 'undefined') {
2385
2398
  payload['headers'] = headers;
2386
2399
  }
2400
+ if (typeof scheduledAt !== 'undefined') {
2401
+ payload['scheduledAt'] = scheduledAt;
2402
+ }
2387
2403
  const uri = new URL(this.client.config.endpoint + apiPath);
2388
2404
  return yield this.client.call('post', uri, {
2389
2405
  'content-type': 'application/json',
@@ -2504,7 +2520,7 @@ class Locale extends Service {
2504
2520
  });
2505
2521
  }
2506
2522
  /**
2507
- * List Locale Codes
2523
+ * List locale codes
2508
2524
  *
2509
2525
  * List of all locale codes in [ISO
2510
2526
  * 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes).
@@ -2909,7 +2925,7 @@ class Storage extends Service {
2909
2925
  });
2910
2926
  }
2911
2927
  /**
2912
- * Delete File
2928
+ * Delete file
2913
2929
  *
2914
2930
  * Delete a file by its unique ID. Only users with write permissions have
2915
2931
  * access to delete this resource.
@@ -3214,7 +3230,8 @@ class Teams extends Service {
3214
3230
  * List team memberships
3215
3231
  *
3216
3232
  * Use this endpoint to list a team's members using the team's ID. All team
3217
- * members have read access to this endpoint.
3233
+ * members have read access to this endpoint. Hide sensitive attributes from
3234
+ * the response by toggling membership privacy in the Console.
3218
3235
  *
3219
3236
  * @param {string} teamId
3220
3237
  * @param {string[]} queries
@@ -3314,7 +3331,8 @@ class Teams extends Service {
3314
3331
  * Get team membership
3315
3332
  *
3316
3333
  * Get a team member by the membership unique id. All team members have read
3317
- * access for this resource.
3334
+ * access for this resource. Hide sensitive attributes from the response by
3335
+ * toggling membership privacy in the Console.
3318
3336
  *
3319
3337
  * @param {string} teamId
3320
3338
  * @param {string} membershipId
@@ -4008,6 +4026,7 @@ var ImageFormat;
4008
4026
  ImageFormat["Gif"] = "gif";
4009
4027
  ImageFormat["Png"] = "png";
4010
4028
  ImageFormat["Webp"] = "webp";
4029
+ ImageFormat["Avif"] = "avif";
4011
4030
  })(ImageFormat || (ImageFormat = {}));
4012
4031
 
4013
4032
  export { Account, AppwriteException, AuthenticationFactor, AuthenticatorType, Avatars, Browser, Client, CreditCard, Databases, ExecutionMethod, Flag, Functions, Graphql, ID, ImageFormat, ImageGravity, Locale, Messaging, OAuthProvider, Permission, Query, Role, Storage, Teams };