react-native-appwrite 0.2.2 → 0.3.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 (131) hide show
  1. package/.github/workflows/publish.yml +13 -4
  2. package/CHANGELOG.md +1 -1
  3. package/LICENSE +1 -1
  4. package/README.md +22 -9
  5. package/dist/cjs/sdk.js +1193 -269
  6. package/dist/cjs/sdk.js.map +1 -1
  7. package/dist/esm/sdk.js +1193 -270
  8. package/dist/esm/sdk.js.map +1 -1
  9. package/docs/examples/account/create-anonymous-session.md +6 -13
  10. package/docs/examples/account/create-email-password-session.md +14 -0
  11. package/docs/examples/account/create-email-token.md +15 -0
  12. package/docs/examples/account/create-j-w-t.md +6 -13
  13. package/docs/examples/account/create-magic-u-r-l-token.md +16 -0
  14. package/docs/examples/account/create-mfa-authenticator.md +13 -0
  15. package/docs/examples/account/create-mfa-challenge.md +13 -0
  16. package/docs/examples/account/create-mfa-recovery-codes.md +11 -0
  17. package/docs/examples/account/create-o-auth2session.md +10 -9
  18. package/docs/examples/account/create-o-auth2token.md +15 -0
  19. package/docs/examples/account/create-phone-token.md +14 -0
  20. package/docs/examples/account/create-phone-verification.md +6 -13
  21. package/docs/examples/account/create-push-target.md +15 -0
  22. package/docs/examples/account/create-recovery.md +9 -13
  23. package/docs/examples/account/create-session.md +14 -0
  24. package/docs/examples/account/create-verification.md +8 -13
  25. package/docs/examples/account/create.md +11 -13
  26. package/docs/examples/account/delete-identity.md +8 -13
  27. package/docs/examples/account/delete-mfa-authenticator.md +14 -0
  28. package/docs/examples/account/delete-push-target.md +13 -0
  29. package/docs/examples/account/delete-session.md +8 -13
  30. package/docs/examples/account/delete-sessions.md +6 -13
  31. package/docs/examples/account/get-mfa-recovery-codes.md +11 -0
  32. package/docs/examples/account/get-prefs.md +6 -13
  33. package/docs/examples/account/get-session.md +8 -13
  34. package/docs/examples/account/get.md +6 -13
  35. package/docs/examples/account/list-identities.md +8 -13
  36. package/docs/examples/account/list-logs.md +8 -13
  37. package/docs/examples/account/list-mfa-factors.md +11 -0
  38. package/docs/examples/account/list-sessions.md +6 -13
  39. package/docs/examples/account/update-email.md +9 -13
  40. package/docs/examples/account/update-m-f-a.md +13 -0
  41. package/docs/examples/account/update-magic-u-r-l-session.md +9 -13
  42. package/docs/examples/account/update-mfa-authenticator.md +14 -0
  43. package/docs/examples/account/update-mfa-challenge.md +14 -0
  44. package/docs/examples/account/update-mfa-recovery-codes.md +11 -0
  45. package/docs/examples/account/update-name.md +8 -13
  46. package/docs/examples/account/update-password.md +9 -13
  47. package/docs/examples/account/update-phone-session.md +9 -13
  48. package/docs/examples/account/update-phone-verification.md +9 -13
  49. package/docs/examples/account/update-phone.md +9 -13
  50. package/docs/examples/account/update-prefs.md +8 -13
  51. package/docs/examples/account/update-push-target.md +14 -0
  52. package/docs/examples/account/update-recovery.md +10 -13
  53. package/docs/examples/account/update-session.md +8 -13
  54. package/docs/examples/account/update-status.md +6 -13
  55. package/docs/examples/account/update-verification.md +9 -13
  56. package/docs/examples/avatars/get-browser.md +11 -9
  57. package/docs/examples/avatars/get-credit-card.md +11 -9
  58. package/docs/examples/avatars/get-favicon.md +8 -9
  59. package/docs/examples/avatars/get-flag.md +11 -9
  60. package/docs/examples/avatars/get-image.md +10 -9
  61. package/docs/examples/avatars/get-initials.md +11 -9
  62. package/docs/examples/avatars/get-q-r.md +11 -9
  63. package/docs/examples/databases/create-document.md +12 -13
  64. package/docs/examples/databases/delete-document.md +10 -13
  65. package/docs/examples/databases/get-document.md +11 -13
  66. package/docs/examples/databases/list-documents.md +10 -13
  67. package/docs/examples/databases/update-document.md +12 -13
  68. package/docs/examples/functions/create-execution.md +13 -13
  69. package/docs/examples/functions/get-execution.md +9 -13
  70. package/docs/examples/functions/list-executions.md +10 -13
  71. package/docs/examples/graphql/mutation.md +8 -13
  72. package/docs/examples/graphql/query.md +8 -13
  73. package/docs/examples/locale/get.md +6 -13
  74. package/docs/examples/locale/list-codes.md +6 -13
  75. package/docs/examples/locale/list-continents.md +6 -13
  76. package/docs/examples/locale/list-countries-e-u.md +6 -13
  77. package/docs/examples/locale/list-countries-phones.md +6 -13
  78. package/docs/examples/locale/list-countries.md +6 -13
  79. package/docs/examples/locale/list-currencies.md +6 -13
  80. package/docs/examples/locale/list-languages.md +6 -13
  81. package/docs/examples/messaging/create-subscriber.md +15 -0
  82. package/docs/examples/messaging/delete-subscriber.md +14 -0
  83. package/docs/examples/storage/create-file.md +11 -13
  84. package/docs/examples/storage/delete-file.md +9 -13
  85. package/docs/examples/storage/get-file-download.md +9 -9
  86. package/docs/examples/storage/get-file-preview.md +20 -9
  87. package/docs/examples/storage/get-file-view.md +9 -9
  88. package/docs/examples/storage/get-file.md +9 -13
  89. package/docs/examples/storage/list-files.md +10 -13
  90. package/docs/examples/storage/update-file.md +11 -13
  91. package/docs/examples/teams/create-membership.md +14 -13
  92. package/docs/examples/teams/create.md +10 -13
  93. package/docs/examples/teams/delete-membership.md +9 -13
  94. package/docs/examples/teams/delete.md +8 -13
  95. package/docs/examples/teams/get-membership.md +9 -13
  96. package/docs/examples/teams/get-prefs.md +8 -13
  97. package/docs/examples/teams/get.md +8 -13
  98. package/docs/examples/teams/list-memberships.md +10 -13
  99. package/docs/examples/teams/list.md +9 -13
  100. package/docs/examples/teams/update-membership-status.md +11 -13
  101. package/docs/examples/teams/update-membership.md +10 -13
  102. package/docs/examples/teams/update-name.md +9 -13
  103. package/docs/examples/teams/update-prefs.md +9 -13
  104. package/package.json +1 -1
  105. package/src/client.ts +37 -11
  106. package/src/enums/authentication-factor.ts +6 -0
  107. package/src/enums/authenticator-type.ts +3 -0
  108. package/src/enums/browser.ts +16 -0
  109. package/src/enums/credit-card.ts +18 -0
  110. package/src/enums/execution-method.ts +8 -0
  111. package/src/enums/flag.ts +197 -0
  112. package/src/enums/image-format.ts +7 -0
  113. package/src/enums/image-gravity.ts +11 -0
  114. package/src/enums/o-auth-provider.ts +41 -0
  115. package/src/id.ts +23 -4
  116. package/src/index.ts +13 -2
  117. package/src/models.ts +174 -0
  118. package/src/query.ts +61 -34
  119. package/src/service.ts +4 -7
  120. package/src/services/account.ts +643 -119
  121. package/src/services/avatars.ts +12 -6
  122. package/src/services/databases.ts +7 -4
  123. package/src/services/functions.ts +6 -2
  124. package/src/services/graphql.ts +3 -0
  125. package/src/services/locale.ts +3 -0
  126. package/src/services/messaging.ts +84 -0
  127. package/src/services/storage.ts +12 -6
  128. package/src/services/teams.ts +3 -0
  129. package/docs/examples/account/create-email-session.md +0 -18
  130. package/docs/examples/account/create-magic-u-r-l-session.md +0 -18
  131. package/docs/examples/account/create-phone-session.md +0 -18
@@ -1,14 +1,14 @@
1
- import { Client, Storage } from "appwrite";
1
+ import { Client, Storage } from "react-native-appwrite";
2
2
 
3
- const client = new Client();
3
+ const client = new Client()
4
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
5
+ .setProject('5df5acd0d48c2'); // Your project ID
4
6
 
5
7
  const storage = new Storage(client);
6
8
 
7
- client
8
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
9
- .setProject('5df5acd0d48c2') // Your project ID
10
- ;
11
-
12
- const result = storage.getFileView('[BUCKET_ID]', '[FILE_ID]');
9
+ const result = storage.getFileView(
10
+ '<BUCKET_ID>', // bucketId
11
+ '<FILE_ID>' // fileId
12
+ );
13
13
 
14
- console.log(result); // Resource URL
14
+ console.log(result);
@@ -1,18 +1,14 @@
1
- import { Client, Storage } from "appwrite";
1
+ import { Client, Storage } from "react-native-appwrite";
2
2
 
3
- const client = new Client();
3
+ const client = new Client()
4
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
5
+ .setProject('5df5acd0d48c2'); // Your project ID
4
6
 
5
7
  const storage = new Storage(client);
6
8
 
7
- client
8
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
9
- .setProject('5df5acd0d48c2') // Your project ID
10
- ;
11
-
12
- const promise = storage.getFile('[BUCKET_ID]', '[FILE_ID]');
9
+ const result = await storage.getFile(
10
+ '<BUCKET_ID>', // bucketId
11
+ '<FILE_ID>' // fileId
12
+ );
13
13
 
14
- promise.then(function (response) {
15
- console.log(response); // Success
16
- }, function (error) {
17
- console.log(error); // Failure
18
- });
14
+ console.log(response);
@@ -1,18 +1,15 @@
1
- import { Client, Storage } from "appwrite";
1
+ import { Client, Storage } from "react-native-appwrite";
2
2
 
3
- const client = new Client();
3
+ const client = new Client()
4
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
5
+ .setProject('5df5acd0d48c2'); // Your project ID
4
6
 
5
7
  const storage = new Storage(client);
6
8
 
7
- client
8
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
9
- .setProject('5df5acd0d48c2') // Your project ID
10
- ;
11
-
12
- const promise = storage.listFiles('[BUCKET_ID]');
9
+ const result = await storage.listFiles(
10
+ '<BUCKET_ID>', // bucketId
11
+ [], // queries (optional)
12
+ '<SEARCH>' // search (optional)
13
+ );
13
14
 
14
- promise.then(function (response) {
15
- console.log(response); // Success
16
- }, function (error) {
17
- console.log(error); // Failure
18
- });
15
+ console.log(response);
@@ -1,18 +1,16 @@
1
- import { Client, Storage } from "appwrite";
1
+ import { Client, Storage } from "react-native-appwrite";
2
2
 
3
- const client = new Client();
3
+ const client = new Client()
4
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
5
+ .setProject('5df5acd0d48c2'); // Your project ID
4
6
 
5
7
  const storage = new Storage(client);
6
8
 
7
- client
8
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
9
- .setProject('5df5acd0d48c2') // Your project ID
10
- ;
11
-
12
- const promise = storage.updateFile('[BUCKET_ID]', '[FILE_ID]');
9
+ const result = await storage.updateFile(
10
+ '<BUCKET_ID>', // bucketId
11
+ '<FILE_ID>', // fileId
12
+ '<NAME>', // name (optional)
13
+ ["read("any")"] // permissions (optional)
14
+ );
13
15
 
14
- promise.then(function (response) {
15
- console.log(response); // Success
16
- }, function (error) {
17
- console.log(error); // Failure
18
- });
16
+ console.log(response);
@@ -1,18 +1,19 @@
1
- import { Client, Teams } from "appwrite";
1
+ import { Client, Teams } from "react-native-appwrite";
2
2
 
3
- const client = new Client();
3
+ const client = new Client()
4
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
5
+ .setProject('5df5acd0d48c2'); // Your project ID
4
6
 
5
7
  const teams = new Teams(client);
6
8
 
7
- client
8
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
9
- .setProject('5df5acd0d48c2') // Your project ID
10
- ;
11
-
12
- const promise = teams.createMembership('[TEAM_ID]', []);
9
+ const result = await teams.createMembership(
10
+ '<TEAM_ID>', // teamId
11
+ [], // roles
12
+ 'email@example.com', // email (optional)
13
+ '<USER_ID>', // userId (optional)
14
+ '+12065550100', // phone (optional)
15
+ 'https://example.com', // url (optional)
16
+ '<NAME>' // name (optional)
17
+ );
13
18
 
14
- promise.then(function (response) {
15
- console.log(response); // Success
16
- }, function (error) {
17
- console.log(error); // Failure
18
- });
19
+ console.log(response);
@@ -1,18 +1,15 @@
1
- import { Client, Teams } from "appwrite";
1
+ import { Client, Teams } from "react-native-appwrite";
2
2
 
3
- const client = new Client();
3
+ const client = new Client()
4
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
5
+ .setProject('5df5acd0d48c2'); // Your project ID
4
6
 
5
7
  const teams = new Teams(client);
6
8
 
7
- client
8
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
9
- .setProject('5df5acd0d48c2') // Your project ID
10
- ;
11
-
12
- const promise = teams.create('[TEAM_ID]', '[NAME]');
9
+ const result = await teams.create(
10
+ '<TEAM_ID>', // teamId
11
+ '<NAME>', // name
12
+ [] // roles (optional)
13
+ );
13
14
 
14
- promise.then(function (response) {
15
- console.log(response); // Success
16
- }, function (error) {
17
- console.log(error); // Failure
18
- });
15
+ console.log(response);
@@ -1,18 +1,14 @@
1
- import { Client, Teams } from "appwrite";
1
+ import { Client, Teams } from "react-native-appwrite";
2
2
 
3
- const client = new Client();
3
+ const client = new Client()
4
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
5
+ .setProject('5df5acd0d48c2'); // Your project ID
4
6
 
5
7
  const teams = new Teams(client);
6
8
 
7
- client
8
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
9
- .setProject('5df5acd0d48c2') // Your project ID
10
- ;
11
-
12
- const promise = teams.deleteMembership('[TEAM_ID]', '[MEMBERSHIP_ID]');
9
+ const result = await teams.deleteMembership(
10
+ '<TEAM_ID>', // teamId
11
+ '<MEMBERSHIP_ID>' // membershipId
12
+ );
13
13
 
14
- promise.then(function (response) {
15
- console.log(response); // Success
16
- }, function (error) {
17
- console.log(error); // Failure
18
- });
14
+ console.log(response);
@@ -1,18 +1,13 @@
1
- import { Client, Teams } from "appwrite";
1
+ import { Client, Teams } from "react-native-appwrite";
2
2
 
3
- const client = new Client();
3
+ const client = new Client()
4
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
5
+ .setProject('5df5acd0d48c2'); // Your project ID
4
6
 
5
7
  const teams = new Teams(client);
6
8
 
7
- client
8
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
9
- .setProject('5df5acd0d48c2') // Your project ID
10
- ;
11
-
12
- const promise = teams.delete('[TEAM_ID]');
9
+ const result = await teams.delete(
10
+ '<TEAM_ID>' // teamId
11
+ );
13
12
 
14
- promise.then(function (response) {
15
- console.log(response); // Success
16
- }, function (error) {
17
- console.log(error); // Failure
18
- });
13
+ console.log(response);
@@ -1,18 +1,14 @@
1
- import { Client, Teams } from "appwrite";
1
+ import { Client, Teams } from "react-native-appwrite";
2
2
 
3
- const client = new Client();
3
+ const client = new Client()
4
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
5
+ .setProject('5df5acd0d48c2'); // Your project ID
4
6
 
5
7
  const teams = new Teams(client);
6
8
 
7
- client
8
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
9
- .setProject('5df5acd0d48c2') // Your project ID
10
- ;
11
-
12
- const promise = teams.getMembership('[TEAM_ID]', '[MEMBERSHIP_ID]');
9
+ const result = await teams.getMembership(
10
+ '<TEAM_ID>', // teamId
11
+ '<MEMBERSHIP_ID>' // membershipId
12
+ );
13
13
 
14
- promise.then(function (response) {
15
- console.log(response); // Success
16
- }, function (error) {
17
- console.log(error); // Failure
18
- });
14
+ console.log(response);
@@ -1,18 +1,13 @@
1
- import { Client, Teams } from "appwrite";
1
+ import { Client, Teams } from "react-native-appwrite";
2
2
 
3
- const client = new Client();
3
+ const client = new Client()
4
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
5
+ .setProject('5df5acd0d48c2'); // Your project ID
4
6
 
5
7
  const teams = new Teams(client);
6
8
 
7
- client
8
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
9
- .setProject('5df5acd0d48c2') // Your project ID
10
- ;
11
-
12
- const promise = teams.getPrefs('[TEAM_ID]');
9
+ const result = await teams.getPrefs(
10
+ '<TEAM_ID>' // teamId
11
+ );
13
12
 
14
- promise.then(function (response) {
15
- console.log(response); // Success
16
- }, function (error) {
17
- console.log(error); // Failure
18
- });
13
+ console.log(response);
@@ -1,18 +1,13 @@
1
- import { Client, Teams } from "appwrite";
1
+ import { Client, Teams } from "react-native-appwrite";
2
2
 
3
- const client = new Client();
3
+ const client = new Client()
4
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
5
+ .setProject('5df5acd0d48c2'); // Your project ID
4
6
 
5
7
  const teams = new Teams(client);
6
8
 
7
- client
8
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
9
- .setProject('5df5acd0d48c2') // Your project ID
10
- ;
11
-
12
- const promise = teams.get('[TEAM_ID]');
9
+ const result = await teams.get(
10
+ '<TEAM_ID>' // teamId
11
+ );
13
12
 
14
- promise.then(function (response) {
15
- console.log(response); // Success
16
- }, function (error) {
17
- console.log(error); // Failure
18
- });
13
+ console.log(response);
@@ -1,18 +1,15 @@
1
- import { Client, Teams } from "appwrite";
1
+ import { Client, Teams } from "react-native-appwrite";
2
2
 
3
- const client = new Client();
3
+ const client = new Client()
4
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
5
+ .setProject('5df5acd0d48c2'); // Your project ID
4
6
 
5
7
  const teams = new Teams(client);
6
8
 
7
- client
8
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
9
- .setProject('5df5acd0d48c2') // Your project ID
10
- ;
11
-
12
- const promise = teams.listMemberships('[TEAM_ID]');
9
+ const result = await teams.listMemberships(
10
+ '<TEAM_ID>', // teamId
11
+ [], // queries (optional)
12
+ '<SEARCH>' // search (optional)
13
+ );
13
14
 
14
- promise.then(function (response) {
15
- console.log(response); // Success
16
- }, function (error) {
17
- console.log(error); // Failure
18
- });
15
+ console.log(response);
@@ -1,18 +1,14 @@
1
- import { Client, Teams } from "appwrite";
1
+ import { Client, Teams } from "react-native-appwrite";
2
2
 
3
- const client = new Client();
3
+ const client = new Client()
4
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
5
+ .setProject('5df5acd0d48c2'); // Your project ID
4
6
 
5
7
  const teams = new Teams(client);
6
8
 
7
- client
8
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
9
- .setProject('5df5acd0d48c2') // Your project ID
10
- ;
11
-
12
- const promise = teams.list();
9
+ const result = await teams.list(
10
+ [], // queries (optional)
11
+ '<SEARCH>' // search (optional)
12
+ );
13
13
 
14
- promise.then(function (response) {
15
- console.log(response); // Success
16
- }, function (error) {
17
- console.log(error); // Failure
18
- });
14
+ console.log(response);
@@ -1,18 +1,16 @@
1
- import { Client, Teams } from "appwrite";
1
+ import { Client, Teams } from "react-native-appwrite";
2
2
 
3
- const client = new Client();
3
+ const client = new Client()
4
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
5
+ .setProject('5df5acd0d48c2'); // Your project ID
4
6
 
5
7
  const teams = new Teams(client);
6
8
 
7
- client
8
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
9
- .setProject('5df5acd0d48c2') // Your project ID
10
- ;
11
-
12
- const promise = teams.updateMembershipStatus('[TEAM_ID]', '[MEMBERSHIP_ID]', '[USER_ID]', '[SECRET]');
9
+ const result = await teams.updateMembershipStatus(
10
+ '<TEAM_ID>', // teamId
11
+ '<MEMBERSHIP_ID>', // membershipId
12
+ '<USER_ID>', // userId
13
+ '<SECRET>' // secret
14
+ );
13
15
 
14
- promise.then(function (response) {
15
- console.log(response); // Success
16
- }, function (error) {
17
- console.log(error); // Failure
18
- });
16
+ console.log(response);
@@ -1,18 +1,15 @@
1
- import { Client, Teams } from "appwrite";
1
+ import { Client, Teams } from "react-native-appwrite";
2
2
 
3
- const client = new Client();
3
+ const client = new Client()
4
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
5
+ .setProject('5df5acd0d48c2'); // Your project ID
4
6
 
5
7
  const teams = new Teams(client);
6
8
 
7
- client
8
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
9
- .setProject('5df5acd0d48c2') // Your project ID
10
- ;
11
-
12
- const promise = teams.updateMembership('[TEAM_ID]', '[MEMBERSHIP_ID]', []);
9
+ const result = await teams.updateMembership(
10
+ '<TEAM_ID>', // teamId
11
+ '<MEMBERSHIP_ID>', // membershipId
12
+ [] // roles
13
+ );
13
14
 
14
- promise.then(function (response) {
15
- console.log(response); // Success
16
- }, function (error) {
17
- console.log(error); // Failure
18
- });
15
+ console.log(response);
@@ -1,18 +1,14 @@
1
- import { Client, Teams } from "appwrite";
1
+ import { Client, Teams } from "react-native-appwrite";
2
2
 
3
- const client = new Client();
3
+ const client = new Client()
4
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
5
+ .setProject('5df5acd0d48c2'); // Your project ID
4
6
 
5
7
  const teams = new Teams(client);
6
8
 
7
- client
8
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
9
- .setProject('5df5acd0d48c2') // Your project ID
10
- ;
11
-
12
- const promise = teams.updateName('[TEAM_ID]', '[NAME]');
9
+ const result = await teams.updateName(
10
+ '<TEAM_ID>', // teamId
11
+ '<NAME>' // name
12
+ );
13
13
 
14
- promise.then(function (response) {
15
- console.log(response); // Success
16
- }, function (error) {
17
- console.log(error); // Failure
18
- });
14
+ console.log(response);
@@ -1,18 +1,14 @@
1
- import { Client, Teams } from "appwrite";
1
+ import { Client, Teams } from "react-native-appwrite";
2
2
 
3
- const client = new Client();
3
+ const client = new Client()
4
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
5
+ .setProject('5df5acd0d48c2'); // Your project ID
4
6
 
5
7
  const teams = new Teams(client);
6
8
 
7
- client
8
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
9
- .setProject('5df5acd0d48c2') // Your project ID
10
- ;
11
-
12
- const promise = teams.updatePrefs('[TEAM_ID]', {});
9
+ const result = await teams.updatePrefs(
10
+ '<TEAM_ID>', // teamId
11
+ {} // prefs
12
+ );
13
13
 
14
- promise.then(function (response) {
15
- console.log(response); // Success
16
- }, function (error) {
17
- console.log(error); // Failure
18
- });
14
+ console.log(response);
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "react-native-appwrite",
3
3
  "homepage": "https://appwrite.io/support",
4
4
  "description": "Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API",
5
- "version": "0.2.2",
5
+ "version": "0.3.0",
6
6
  "license": "BSD-3-Clause",
7
7
  "main": "dist/cjs/sdk.js",
8
8
  "exports": {
package/src/client.ts CHANGED
@@ -91,19 +91,20 @@ class AppwriteException extends Error {
91
91
 
92
92
  class Client {
93
93
  config = {
94
- endpoint: 'https://HOSTNAME/v1',
94
+ endpoint: 'https://cloud.appwrite.io/v1',
95
95
  endpointRealtime: '',
96
96
  project: '',
97
97
  jwt: '',
98
98
  locale: '',
99
+ session: '',
99
100
  platform: '',
100
101
  };
101
102
  headers: Headers = {
102
- 'x-sdk-name': 'Web',
103
+ 'x-sdk-name': 'React Native',
103
104
  'x-sdk-platform': 'client',
104
- 'x-sdk-language': 'web',
105
- 'x-sdk-version': '13.0.2',
106
- 'X-Appwrite-Response-Format': '1.4.0',
105
+ 'x-sdk-language': 'reactnative',
106
+ 'x-sdk-version': '0.3.0',
107
+ 'X-Appwrite-Response-Format': '1.5.0',
107
108
  };
108
109
 
109
110
  /**
@@ -192,6 +193,21 @@ class Client {
192
193
  return this;
193
194
  }
194
195
 
196
+ /**
197
+ * Set Session
198
+ *
199
+ * The user session to authenticate with
200
+ *
201
+ * @param value string
202
+ *
203
+ * @return {this}
204
+ */
205
+ setSession(value: string): this {
206
+ this.headers['X-Appwrite-Session'] = value;
207
+ this.config.session = value;
208
+ return this;
209
+ }
210
+
195
211
 
196
212
  private realtime: Realtime = {
197
213
  socket: undefined,
@@ -222,7 +238,11 @@ class Client {
222
238
  }
223
239
  },
224
240
  createSocket: () => {
225
- if (this.realtime.channels.size < 1) return;
241
+ if (this.realtime.channels.size < 1) {
242
+ this.realtime.reconnect = false;
243
+ this.realtime.socket?.close();
244
+ return;
245
+ }
226
246
 
227
247
  const channels = new URLSearchParams();
228
248
  channels.set('project', this.config.project);
@@ -278,7 +298,7 @@ class Client {
278
298
  })
279
299
  }
280
300
  },
281
- onMessage: async (event) => {
301
+ onMessage: (event) => {
282
302
  try {
283
303
  const message: RealtimeResponse = JSON.parse(event.data);
284
304
  this.realtime.lastMessage = message;
@@ -307,7 +327,7 @@ class Client {
307
327
  cleanUp: channels => {
308
328
  this.realtime.channels.forEach(channel => {
309
329
  if (channels.includes(channel)) {
310
- let found = Array.from(this.realtime.subscriptions).some(([_key, subscription]) => {
330
+ let found = Array.from(this.realtime.subscriptions).some(([_key, subscription] )=> {
311
331
  return subscription.channels.includes(channel);
312
332
  })
313
333
 
@@ -367,7 +387,8 @@ class Client {
367
387
  method = method.toUpperCase();
368
388
 
369
389
  headers = Object.assign({}, this.headers, headers);
370
- headers.Origin = `appwrite-${Platform.OS}://${this.config.platform}`;
390
+ headers.Origin = `appwrite-${Platform.OS}://${this.config.platform}`
391
+
371
392
  let options: RequestInit = {
372
393
  method,
373
394
  headers,
@@ -419,6 +440,13 @@ class Client {
419
440
  throw new AppwriteException(data?.message, response.status, data?.type, data);
420
441
  }
421
442
 
443
+ const cookieFallback = response.headers.get('X-Fallback-Cookies');
444
+
445
+ if (typeof window !== 'undefined' && window.localStorage && cookieFallback) {
446
+ window.console.warn('Appwrite is using localStorage for session management. Increase your security by adding a custom domain as your API endpoint.');
447
+ window.localStorage.setItem('cookieFallback', cookieFallback);
448
+ }
449
+
422
450
  return data;
423
451
  } catch (e) {
424
452
  if (e instanceof AppwriteException) {
@@ -430,6 +458,4 @@ class Client {
430
458
  }
431
459
 
432
460
  export { Client, AppwriteException };
433
- export { Query } from './query';
434
461
  export type { Models, Payload };
435
- export type { QueryTypes, QueryTypesList } from './query';
@@ -0,0 +1,6 @@
1
+ export enum AuthenticationFactor {
2
+ Email = 'email',
3
+ Phone = 'phone',
4
+ Totp = 'totp',
5
+ Recoverycode = 'recoverycode',
6
+ }
@@ -0,0 +1,3 @@
1
+ export enum AuthenticatorType {
2
+ Totp = 'totp',
3
+ }
@@ -0,0 +1,16 @@
1
+ export enum Browser {
2
+ AvantBrowser = 'aa',
3
+ AndroidWebViewBeta = 'an',
4
+ GoogleChrome = 'ch',
5
+ GoogleChromeIOS = 'ci',
6
+ GoogleChromeMobile = 'cm',
7
+ Chromium = 'cr',
8
+ MozillaFirefox = 'ff',
9
+ Safari = 'sf',
10
+ MobileSafari = 'mf',
11
+ MicrosoftEdge = 'ps',
12
+ MicrosoftEdgeIOS = 'oi',
13
+ OperaMini = 'om',
14
+ Opera = 'op',
15
+ OperaNext = 'on',
16
+ }