react-native-appwrite 0.3.1 → 0.5.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 (115) hide show
  1. package/.github/workflows/autoclose.yml +11 -0
  2. package/README.md +2 -2
  3. package/dist/cjs/package.json +3 -0
  4. package/dist/cjs/sdk.js +20 -17
  5. package/dist/cjs/sdk.js.map +1 -1
  6. package/dist/esm/package.json +3 -0
  7. package/dist/esm/sdk.js +20 -17
  8. package/dist/esm/sdk.js.map +1 -1
  9. package/docs/examples/account/create-anonymous-session.md +2 -2
  10. package/docs/examples/account/create-email-password-session.md +2 -2
  11. package/docs/examples/account/create-email-token.md +2 -2
  12. package/docs/examples/account/create-j-w-t.md +2 -2
  13. package/docs/examples/account/create-magic-u-r-l-token.md +2 -2
  14. package/docs/examples/account/create-mfa-authenticator.md +2 -2
  15. package/docs/examples/account/create-mfa-challenge.md +2 -2
  16. package/docs/examples/account/create-mfa-recovery-codes.md +2 -2
  17. package/docs/examples/account/create-o-auth2session.md +1 -1
  18. package/docs/examples/account/create-o-auth2token.md +1 -1
  19. package/docs/examples/account/create-phone-token.md +2 -2
  20. package/docs/examples/account/create-phone-verification.md +2 -2
  21. package/docs/examples/account/create-push-target.md +2 -2
  22. package/docs/examples/account/create-recovery.md +2 -2
  23. package/docs/examples/account/create-session.md +2 -2
  24. package/docs/examples/account/create-verification.md +2 -2
  25. package/docs/examples/account/create.md +2 -2
  26. package/docs/examples/account/delete-identity.md +2 -2
  27. package/docs/examples/account/delete-mfa-authenticator.md +3 -4
  28. package/docs/examples/account/delete-push-target.md +2 -2
  29. package/docs/examples/account/delete-session.md +2 -2
  30. package/docs/examples/account/delete-sessions.md +2 -2
  31. package/docs/examples/account/get-mfa-recovery-codes.md +2 -2
  32. package/docs/examples/account/get-prefs.md +2 -2
  33. package/docs/examples/account/get-session.md +2 -2
  34. package/docs/examples/account/get.md +2 -2
  35. package/docs/examples/account/list-identities.md +2 -2
  36. package/docs/examples/account/list-logs.md +2 -2
  37. package/docs/examples/account/list-mfa-factors.md +2 -2
  38. package/docs/examples/account/list-sessions.md +2 -2
  39. package/docs/examples/account/update-email.md +2 -2
  40. package/docs/examples/account/update-m-f-a.md +2 -2
  41. package/docs/examples/account/update-magic-u-r-l-session.md +2 -2
  42. package/docs/examples/account/update-mfa-authenticator.md +2 -2
  43. package/docs/examples/account/update-mfa-challenge.md +2 -2
  44. package/docs/examples/account/update-mfa-recovery-codes.md +2 -2
  45. package/docs/examples/account/update-name.md +2 -2
  46. package/docs/examples/account/update-password.md +2 -2
  47. package/docs/examples/account/update-phone-session.md +2 -2
  48. package/docs/examples/account/update-phone-verification.md +2 -2
  49. package/docs/examples/account/update-phone.md +2 -2
  50. package/docs/examples/account/update-prefs.md +2 -2
  51. package/docs/examples/account/update-push-target.md +2 -2
  52. package/docs/examples/account/update-recovery.md +2 -2
  53. package/docs/examples/account/update-session.md +2 -2
  54. package/docs/examples/account/update-status.md +2 -2
  55. package/docs/examples/account/update-verification.md +2 -2
  56. package/docs/examples/avatars/get-browser.md +1 -1
  57. package/docs/examples/avatars/get-credit-card.md +1 -1
  58. package/docs/examples/avatars/get-favicon.md +1 -1
  59. package/docs/examples/avatars/get-flag.md +1 -1
  60. package/docs/examples/avatars/get-image.md +1 -1
  61. package/docs/examples/avatars/get-initials.md +1 -1
  62. package/docs/examples/avatars/get-q-r.md +1 -1
  63. package/docs/examples/databases/create-document.md +2 -2
  64. package/docs/examples/databases/delete-document.md +2 -2
  65. package/docs/examples/databases/get-document.md +2 -2
  66. package/docs/examples/databases/list-documents.md +2 -2
  67. package/docs/examples/databases/update-document.md +2 -2
  68. package/docs/examples/functions/create-execution.md +4 -3
  69. package/docs/examples/functions/get-execution.md +2 -2
  70. package/docs/examples/functions/list-executions.md +2 -2
  71. package/docs/examples/graphql/mutation.md +2 -2
  72. package/docs/examples/graphql/query.md +2 -2
  73. package/docs/examples/locale/get.md +2 -2
  74. package/docs/examples/locale/list-codes.md +2 -2
  75. package/docs/examples/locale/list-continents.md +2 -2
  76. package/docs/examples/locale/list-countries-e-u.md +2 -2
  77. package/docs/examples/locale/list-countries-phones.md +2 -2
  78. package/docs/examples/locale/list-countries.md +2 -2
  79. package/docs/examples/locale/list-currencies.md +2 -2
  80. package/docs/examples/locale/list-languages.md +2 -2
  81. package/docs/examples/messaging/create-subscriber.md +2 -2
  82. package/docs/examples/messaging/delete-subscriber.md +2 -2
  83. package/docs/examples/storage/create-file.md +2 -2
  84. package/docs/examples/storage/delete-file.md +2 -2
  85. package/docs/examples/storage/get-file-download.md +1 -1
  86. package/docs/examples/storage/get-file-preview.md +1 -1
  87. package/docs/examples/storage/get-file-view.md +1 -1
  88. package/docs/examples/storage/get-file.md +2 -2
  89. package/docs/examples/storage/list-files.md +2 -2
  90. package/docs/examples/storage/update-file.md +2 -2
  91. package/docs/examples/teams/create-membership.md +2 -2
  92. package/docs/examples/teams/create.md +2 -2
  93. package/docs/examples/teams/delete-membership.md +2 -2
  94. package/docs/examples/teams/delete.md +2 -2
  95. package/docs/examples/teams/get-membership.md +2 -2
  96. package/docs/examples/teams/get-prefs.md +2 -2
  97. package/docs/examples/teams/get.md +2 -2
  98. package/docs/examples/teams/list-memberships.md +2 -2
  99. package/docs/examples/teams/list.md +2 -2
  100. package/docs/examples/teams/update-membership-status.md +2 -2
  101. package/docs/examples/teams/update-membership.md +2 -2
  102. package/docs/examples/teams/update-name.md +2 -2
  103. package/docs/examples/teams/update-prefs.md +2 -2
  104. package/package.json +1 -1
  105. package/src/client.ts +7 -2
  106. package/src/enums/credit-card.ts +1 -1
  107. package/src/models.ts +4 -0
  108. package/src/services/account.ts +6 -15
  109. package/src/services/avatars.ts +2 -0
  110. package/src/services/functions.ts +6 -1
  111. package/types/enums/credit-card.d.ts +1 -1
  112. package/types/models.d.ts +4 -0
  113. package/types/services/account.d.ts +5 -6
  114. package/types/services/avatars.d.ts +2 -0
  115. package/types/services/functions.d.ts +2 -1
@@ -2,7 +2,7 @@ import { Client, Teams } from "react-native-appwrite";
2
2
 
3
3
  const client = new Client()
4
4
  .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
5
- .setProject('5df5acd0d48c2'); // Your project ID
5
+ .setProject('<YOUR_PROJECT_ID>'); // Your project ID
6
6
 
7
7
  const teams = new Teams(client);
8
8
 
@@ -10,4 +10,4 @@ const result = await teams.getPrefs(
10
10
  '<TEAM_ID>' // teamId
11
11
  );
12
12
 
13
- console.log(response);
13
+ console.log(result);
@@ -2,7 +2,7 @@ import { Client, Teams } from "react-native-appwrite";
2
2
 
3
3
  const client = new Client()
4
4
  .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
5
- .setProject('5df5acd0d48c2'); // Your project ID
5
+ .setProject('<YOUR_PROJECT_ID>'); // Your project ID
6
6
 
7
7
  const teams = new Teams(client);
8
8
 
@@ -10,4 +10,4 @@ const result = await teams.get(
10
10
  '<TEAM_ID>' // teamId
11
11
  );
12
12
 
13
- console.log(response);
13
+ console.log(result);
@@ -2,7 +2,7 @@ import { Client, Teams } from "react-native-appwrite";
2
2
 
3
3
  const client = new Client()
4
4
  .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
5
- .setProject('5df5acd0d48c2'); // Your project ID
5
+ .setProject('<YOUR_PROJECT_ID>'); // Your project ID
6
6
 
7
7
  const teams = new Teams(client);
8
8
 
@@ -12,4 +12,4 @@ const result = await teams.listMemberships(
12
12
  '<SEARCH>' // search (optional)
13
13
  );
14
14
 
15
- console.log(response);
15
+ console.log(result);
@@ -2,7 +2,7 @@ import { Client, Teams } from "react-native-appwrite";
2
2
 
3
3
  const client = new Client()
4
4
  .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
5
- .setProject('5df5acd0d48c2'); // Your project ID
5
+ .setProject('<YOUR_PROJECT_ID>'); // Your project ID
6
6
 
7
7
  const teams = new Teams(client);
8
8
 
@@ -11,4 +11,4 @@ const result = await teams.list(
11
11
  '<SEARCH>' // search (optional)
12
12
  );
13
13
 
14
- console.log(response);
14
+ console.log(result);
@@ -2,7 +2,7 @@ import { Client, Teams } from "react-native-appwrite";
2
2
 
3
3
  const client = new Client()
4
4
  .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
5
- .setProject('5df5acd0d48c2'); // Your project ID
5
+ .setProject('<YOUR_PROJECT_ID>'); // Your project ID
6
6
 
7
7
  const teams = new Teams(client);
8
8
 
@@ -13,4 +13,4 @@ const result = await teams.updateMembershipStatus(
13
13
  '<SECRET>' // secret
14
14
  );
15
15
 
16
- console.log(response);
16
+ console.log(result);
@@ -2,7 +2,7 @@ import { Client, Teams } from "react-native-appwrite";
2
2
 
3
3
  const client = new Client()
4
4
  .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
5
- .setProject('5df5acd0d48c2'); // Your project ID
5
+ .setProject('<YOUR_PROJECT_ID>'); // Your project ID
6
6
 
7
7
  const teams = new Teams(client);
8
8
 
@@ -12,4 +12,4 @@ const result = await teams.updateMembership(
12
12
  [] // roles
13
13
  );
14
14
 
15
- console.log(response);
15
+ console.log(result);
@@ -2,7 +2,7 @@ import { Client, Teams } from "react-native-appwrite";
2
2
 
3
3
  const client = new Client()
4
4
  .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
5
- .setProject('5df5acd0d48c2'); // Your project ID
5
+ .setProject('<YOUR_PROJECT_ID>'); // Your project ID
6
6
 
7
7
  const teams = new Teams(client);
8
8
 
@@ -11,4 +11,4 @@ const result = await teams.updateName(
11
11
  '<NAME>' // name
12
12
  );
13
13
 
14
- console.log(response);
14
+ console.log(result);
@@ -2,7 +2,7 @@ import { Client, Teams } from "react-native-appwrite";
2
2
 
3
3
  const client = new Client()
4
4
  .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
5
- .setProject('5df5acd0d48c2'); // Your project ID
5
+ .setProject('<YOUR_PROJECT_ID>'); // Your project ID
6
6
 
7
7
  const teams = new Teams(client);
8
8
 
@@ -11,4 +11,4 @@ const result = await teams.updatePrefs(
11
11
  {} // prefs
12
12
  );
13
13
 
14
- console.log(response);
14
+ console.log(result);
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.3.1",
5
+ "version": "0.5.0",
6
6
  "license": "BSD-3-Clause",
7
7
  "main": "dist/cjs/sdk.js",
8
8
  "exports": {
package/src/client.ts CHANGED
@@ -103,8 +103,8 @@ class Client {
103
103
  'x-sdk-name': 'React Native',
104
104
  'x-sdk-platform': 'client',
105
105
  'x-sdk-language': 'reactnative',
106
- 'x-sdk-version': '0.3.0',
107
- 'X-Appwrite-Response-Format': '1.5.0',
106
+ 'x-sdk-version': '0.5.0',
107
+ 'X-Appwrite-Response-Format': '1.6.0',
108
108
  };
109
109
 
110
110
  /**
@@ -428,6 +428,11 @@ class Client {
428
428
  let data = null;
429
429
  const response = await fetch(url.toString(), options);
430
430
 
431
+ const warnings = response.headers.get('x-appwrite-warning');
432
+ if (warnings) {
433
+ warnings.split(';').forEach((warning: string) => console.warn('Warning: ' + warning));
434
+ }
435
+
431
436
  if (response.headers.get('content-type')?.includes('application/json')) {
432
437
  data = await response.json();
433
438
  } else {
@@ -2,7 +2,7 @@ export enum CreditCard {
2
2
  AmericanExpress = 'amex',
3
3
  Argencard = 'argencard',
4
4
  Cabal = 'cabal',
5
- Consosud = 'censosud',
5
+ Cencosud = 'cencosud',
6
6
  DinersClub = 'diners',
7
7
  Discover = 'discover',
8
8
  Elo = 'elo',
package/src/models.ts CHANGED
@@ -943,6 +943,10 @@ export namespace Models {
943
943
  * Function execution duration in seconds.
944
944
  */
945
945
  duration: number;
946
+ /**
947
+ * The scheduled time for execution. If left empty, execution will be queued immediately.
948
+ */
949
+ scheduledAt?: string;
946
950
  }
947
951
  /**
948
952
  * Country
@@ -192,7 +192,7 @@ export class Account extends Service {
192
192
  * @returns {Promise}
193
193
  */
194
194
  async createJWT(): Promise<Models.Jwt> {
195
- const apiPath = '/account/jwt';
195
+ const apiPath = '/account/jwts';
196
196
  const payload: Payload = {};
197
197
 
198
198
  const uri = new URL(this.client.config.endpoint + apiPath);
@@ -253,7 +253,7 @@ export class Account extends Service {
253
253
  }
254
254
 
255
255
  /**
256
- * Add Authenticator
256
+ * Create Authenticator
257
257
  *
258
258
  * Add an authenticator app to be used as an MFA factor. Verify the
259
259
  * authenticator using the [verify
@@ -283,7 +283,7 @@ export class Account extends Service {
283
283
  *
284
284
  * Verify an authenticator app after adding it using the [add
285
285
  * authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator)
286
- * method. add
286
+ * method.
287
287
  *
288
288
  * @param {AuthenticatorType} type
289
289
  * @param {string} otp
@@ -318,26 +318,17 @@ export class Account extends Service {
318
318
  * Delete an authenticator for a user by ID.
319
319
  *
320
320
  * @param {AuthenticatorType} type
321
- * @param {string} otp
322
321
  * @throws {AppwriteException}
323
322
  * @returns {Promise}
324
323
  */
325
- async deleteMfaAuthenticator(type: AuthenticatorType, otp: string): Promise<{}> {
324
+ async deleteMfaAuthenticator(type: AuthenticatorType): Promise<{}> {
326
325
  if (typeof type === 'undefined') {
327
326
  throw new AppwriteException('Missing required parameter: "type"');
328
327
  }
329
328
 
330
- if (typeof otp === 'undefined') {
331
- throw new AppwriteException('Missing required parameter: "otp"');
332
- }
333
-
334
329
  const apiPath = '/account/mfa/authenticators/{type}'.replace('{type}', type);
335
330
  const payload: Payload = {};
336
331
 
337
- if (typeof otp !== 'undefined') {
338
- payload['otp'] = otp;
339
- }
340
-
341
332
  const uri = new URL(this.client.config.endpoint + apiPath);
342
333
  return await this.client.call('delete', uri, {
343
334
  'content-type': 'application/json',
@@ -345,7 +336,7 @@ export class Account extends Service {
345
336
  }
346
337
 
347
338
  /**
348
- * Create 2FA Challenge
339
+ * Create MFA Challenge
349
340
  *
350
341
  * Begin the process of MFA verification after sign-in. Finish the flow with
351
342
  * [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge)
@@ -1520,7 +1511,7 @@ export class Account extends Service {
1520
1511
  }
1521
1512
 
1522
1513
  /**
1523
- * Create phone verification (confirmation)
1514
+ * Update phone verification (confirmation)
1524
1515
  *
1525
1516
  * Use this endpoint to complete the user phone verification process. Use the
1526
1517
  * **userId** and **secret** that were sent to your user's phone number to
@@ -123,6 +123,7 @@ export class Avatars extends Service {
123
123
  * Use this endpoint to fetch the favorite icon (AKA favicon) of any remote
124
124
  * website URL.
125
125
  *
126
+ * This endpoint does not follow HTTP redirects.
126
127
  *
127
128
  * @param {string} url
128
129
  * @throws {AppwriteException}
@@ -214,6 +215,7 @@ export class Avatars extends Service {
214
215
  * image at source quality. If dimensions are not specified, the default size
215
216
  * of image returned is 400x400px.
216
217
  *
218
+ * This endpoint does not follow HTTP redirects.
217
219
  *
218
220
  * @param {string} url
219
221
  * @param {number} width
@@ -62,10 +62,11 @@ export class Functions extends Service {
62
62
  * @param {string} xpath
63
63
  * @param {ExecutionMethod} method
64
64
  * @param {object} headers
65
+ * @param {string} scheduledAt
65
66
  * @throws {AppwriteException}
66
67
  * @returns {Promise}
67
68
  */
68
- async createExecution(functionId: string, body?: string, async?: boolean, xpath?: string, method?: ExecutionMethod, headers?: object): Promise<Models.Execution> {
69
+ async createExecution(functionId: string, body?: string, async?: boolean, xpath?: string, method?: ExecutionMethod, headers?: object, scheduledAt?: string): Promise<Models.Execution> {
69
70
  if (typeof functionId === 'undefined') {
70
71
  throw new AppwriteException('Missing required parameter: "functionId"');
71
72
  }
@@ -93,6 +94,10 @@ export class Functions extends Service {
93
94
  payload['headers'] = headers;
94
95
  }
95
96
 
97
+ if (typeof scheduledAt !== 'undefined') {
98
+ payload['scheduledAt'] = scheduledAt;
99
+ }
100
+
96
101
  const uri = new URL(this.client.config.endpoint + apiPath);
97
102
  return await this.client.call('post', uri, {
98
103
  'content-type': 'application/json',
@@ -2,7 +2,7 @@ export declare enum CreditCard {
2
2
  AmericanExpress = "amex",
3
3
  Argencard = "argencard",
4
4
  Cabal = "cabal",
5
- Consosud = "censosud",
5
+ Cencosud = "cencosud",
6
6
  DinersClub = "diners",
7
7
  Discover = "discover",
8
8
  Elo = "elo",
package/types/models.d.ts CHANGED
@@ -943,6 +943,10 @@ export declare namespace Models {
943
943
  * Function execution duration in seconds.
944
944
  */
945
945
  duration: number;
946
+ /**
947
+ * The scheduled time for execution. If left empty, execution will be queued immediately.
948
+ */
949
+ scheduledAt?: string;
946
950
  };
947
951
  /**
948
952
  * Country
@@ -107,7 +107,7 @@ export declare class Account extends Service {
107
107
  */
108
108
  updateMFA<Preferences extends Models.Preferences>(mfa: boolean): Promise<Models.User<Preferences>>;
109
109
  /**
110
- * Add Authenticator
110
+ * Create Authenticator
111
111
  *
112
112
  * Add an authenticator app to be used as an MFA factor. Verify the
113
113
  * authenticator using the [verify
@@ -124,7 +124,7 @@ export declare class Account extends Service {
124
124
  *
125
125
  * Verify an authenticator app after adding it using the [add
126
126
  * authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator)
127
- * method. add
127
+ * method.
128
128
  *
129
129
  * @param {AuthenticatorType} type
130
130
  * @param {string} otp
@@ -138,13 +138,12 @@ export declare class Account extends Service {
138
138
  * Delete an authenticator for a user by ID.
139
139
  *
140
140
  * @param {AuthenticatorType} type
141
- * @param {string} otp
142
141
  * @throws {AppwriteException}
143
142
  * @returns {Promise}
144
143
  */
145
- deleteMfaAuthenticator(type: AuthenticatorType, otp: string): Promise<{}>;
144
+ deleteMfaAuthenticator(type: AuthenticatorType): Promise<{}>;
146
145
  /**
147
- * Create 2FA Challenge
146
+ * Create MFA Challenge
148
147
  *
149
148
  * Begin the process of MFA verification after sign-in. Finish the flow with
150
149
  * [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge)
@@ -660,7 +659,7 @@ export declare class Account extends Service {
660
659
  */
661
660
  createPhoneVerification(): Promise<Models.Token>;
662
661
  /**
663
- * Create phone verification (confirmation)
662
+ * Update phone verification (confirmation)
664
663
  *
665
664
  * Use this endpoint to complete the user phone verification process. Use the
666
665
  * **userId** and **secret** that were sent to your user's phone number to
@@ -54,6 +54,7 @@ export declare class Avatars extends Service {
54
54
  * Use this endpoint to fetch the favorite icon (AKA favicon) of any remote
55
55
  * website URL.
56
56
  *
57
+ * This endpoint does not follow HTTP redirects.
57
58
  *
58
59
  * @param {string} url
59
60
  * @throws {AppwriteException}
@@ -95,6 +96,7 @@ export declare class Avatars extends Service {
95
96
  * image at source quality. If dimensions are not specified, the default size
96
97
  * of image returned is 400x400px.
97
98
  *
99
+ * This endpoint does not follow HTTP redirects.
98
100
  *
99
101
  * @param {string} url
100
102
  * @param {number} width
@@ -31,10 +31,11 @@ export declare class Functions extends Service {
31
31
  * @param {string} xpath
32
32
  * @param {ExecutionMethod} method
33
33
  * @param {object} headers
34
+ * @param {string} scheduledAt
34
35
  * @throws {AppwriteException}
35
36
  * @returns {Promise}
36
37
  */
37
- createExecution(functionId: string, body?: string, async?: boolean, xpath?: string, method?: ExecutionMethod, headers?: object): Promise<Models.Execution>;
38
+ createExecution(functionId: string, body?: string, async?: boolean, xpath?: string, method?: ExecutionMethod, headers?: object, scheduledAt?: string): Promise<Models.Execution>;
38
39
  /**
39
40
  * Get execution
40
41
  *