react-native-appwrite 0.19.0 → 0.21.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 (156) hide show
  1. package/.github/workflows/publish.yml +9 -8
  2. package/CHANGELOG.md +12 -0
  3. package/LICENSE +1 -1
  4. package/README.md +3 -3
  5. package/dist/cjs/sdk.js +254 -64
  6. package/dist/cjs/sdk.js.map +1 -1
  7. package/dist/esm/sdk.js +250 -65
  8. package/dist/esm/sdk.js.map +1 -1
  9. package/docs/examples/account/create-anonymous-session.md +2 -0
  10. package/docs/examples/account/create-email-password-session.md +2 -0
  11. package/docs/examples/account/create-email-token.md +2 -0
  12. package/docs/examples/account/create-email-verification.md +2 -0
  13. package/docs/examples/account/create-jwt.md +5 -1
  14. package/docs/examples/account/create-magic-url-token.md +2 -0
  15. package/docs/examples/account/create-mfa-authenticator.md +2 -0
  16. package/docs/examples/account/create-mfa-challenge.md +2 -0
  17. package/docs/examples/account/create-mfa-recovery-codes.md +2 -0
  18. package/docs/examples/account/create-o-auth-2-session.md +2 -0
  19. package/docs/examples/account/create-o-auth-2-token.md +2 -0
  20. package/docs/examples/account/create-phone-token.md +2 -0
  21. package/docs/examples/account/create-phone-verification.md +2 -0
  22. package/docs/examples/account/create-push-target.md +2 -0
  23. package/docs/examples/account/create-recovery.md +2 -0
  24. package/docs/examples/account/create-session.md +2 -0
  25. package/docs/examples/account/create-verification.md +2 -0
  26. package/docs/examples/account/create.md +2 -0
  27. package/docs/examples/account/delete-identity.md +2 -0
  28. package/docs/examples/account/delete-mfa-authenticator.md +2 -0
  29. package/docs/examples/account/delete-push-target.md +2 -0
  30. package/docs/examples/account/delete-session.md +2 -0
  31. package/docs/examples/account/delete-sessions.md +2 -0
  32. package/docs/examples/account/get-mfa-recovery-codes.md +2 -0
  33. package/docs/examples/account/get-prefs.md +2 -0
  34. package/docs/examples/account/get-session.md +2 -0
  35. package/docs/examples/account/get.md +2 -0
  36. package/docs/examples/account/list-identities.md +2 -0
  37. package/docs/examples/account/list-logs.md +2 -0
  38. package/docs/examples/account/list-mfa-factors.md +2 -0
  39. package/docs/examples/account/list-sessions.md +2 -0
  40. package/docs/examples/account/update-email-verification.md +2 -0
  41. package/docs/examples/account/update-email.md +2 -0
  42. package/docs/examples/account/update-magic-url-session.md +2 -0
  43. package/docs/examples/account/update-mfa-authenticator.md +2 -0
  44. package/docs/examples/account/update-mfa-challenge.md +2 -0
  45. package/docs/examples/account/update-mfa-recovery-codes.md +2 -0
  46. package/docs/examples/account/update-mfa.md +2 -0
  47. package/docs/examples/account/update-name.md +2 -0
  48. package/docs/examples/account/update-password.md +2 -0
  49. package/docs/examples/account/update-phone-session.md +2 -0
  50. package/docs/examples/account/update-phone-verification.md +2 -0
  51. package/docs/examples/account/update-phone.md +2 -0
  52. package/docs/examples/account/update-prefs.md +2 -0
  53. package/docs/examples/account/update-push-target.md +2 -0
  54. package/docs/examples/account/update-recovery.md +2 -0
  55. package/docs/examples/account/update-session.md +2 -0
  56. package/docs/examples/account/update-status.md +2 -0
  57. package/docs/examples/account/update-verification.md +2 -0
  58. package/docs/examples/avatars/get-browser.md +2 -0
  59. package/docs/examples/avatars/get-credit-card.md +2 -0
  60. package/docs/examples/avatars/get-favicon.md +2 -0
  61. package/docs/examples/avatars/get-flag.md +2 -0
  62. package/docs/examples/avatars/get-image.md +2 -0
  63. package/docs/examples/avatars/get-initials.md +2 -0
  64. package/docs/examples/avatars/get-qr.md +2 -0
  65. package/docs/examples/avatars/get-screenshot.md +7 -5
  66. package/docs/examples/databases/create-document.md +2 -0
  67. package/docs/examples/databases/create-operations.md +2 -0
  68. package/docs/examples/databases/create-transaction.md +2 -0
  69. package/docs/examples/databases/decrement-document-attribute.md +2 -0
  70. package/docs/examples/databases/delete-document.md +2 -0
  71. package/docs/examples/databases/delete-transaction.md +2 -0
  72. package/docs/examples/databases/get-document.md +2 -0
  73. package/docs/examples/databases/get-transaction.md +2 -0
  74. package/docs/examples/databases/increment-document-attribute.md +2 -0
  75. package/docs/examples/databases/list-documents.md +2 -0
  76. package/docs/examples/databases/list-transactions.md +2 -0
  77. package/docs/examples/databases/update-document.md +9 -1
  78. package/docs/examples/databases/update-transaction.md +2 -0
  79. package/docs/examples/databases/upsert-document.md +9 -1
  80. package/docs/examples/functions/create-execution.md +2 -0
  81. package/docs/examples/functions/get-execution.md +2 -0
  82. package/docs/examples/functions/list-executions.md +2 -0
  83. package/docs/examples/graphql/mutation.md +2 -0
  84. package/docs/examples/graphql/query.md +2 -0
  85. package/docs/examples/locale/get.md +2 -0
  86. package/docs/examples/locale/list-codes.md +2 -0
  87. package/docs/examples/locale/list-continents.md +2 -0
  88. package/docs/examples/locale/list-countries-eu.md +2 -0
  89. package/docs/examples/locale/list-countries-phones.md +2 -0
  90. package/docs/examples/locale/list-countries.md +2 -0
  91. package/docs/examples/locale/list-currencies.md +2 -0
  92. package/docs/examples/locale/list-languages.md +2 -0
  93. package/docs/examples/messaging/create-subscriber.md +2 -0
  94. package/docs/examples/messaging/delete-subscriber.md +2 -0
  95. package/docs/examples/storage/create-file.md +2 -0
  96. package/docs/examples/storage/delete-file.md +2 -0
  97. package/docs/examples/storage/get-file-download.md +2 -0
  98. package/docs/examples/storage/get-file-preview.md +2 -0
  99. package/docs/examples/storage/get-file-view.md +2 -0
  100. package/docs/examples/storage/get-file.md +2 -0
  101. package/docs/examples/storage/list-files.md +2 -0
  102. package/docs/examples/storage/update-file.md +2 -0
  103. package/docs/examples/tablesdb/create-operations.md +2 -0
  104. package/docs/examples/tablesdb/create-row.md +2 -0
  105. package/docs/examples/tablesdb/create-transaction.md +2 -0
  106. package/docs/examples/tablesdb/decrement-row-column.md +2 -0
  107. package/docs/examples/tablesdb/delete-row.md +2 -0
  108. package/docs/examples/tablesdb/delete-transaction.md +2 -0
  109. package/docs/examples/tablesdb/get-row.md +2 -0
  110. package/docs/examples/tablesdb/get-transaction.md +2 -0
  111. package/docs/examples/tablesdb/increment-row-column.md +2 -0
  112. package/docs/examples/tablesdb/list-rows.md +2 -0
  113. package/docs/examples/tablesdb/list-transactions.md +2 -0
  114. package/docs/examples/tablesdb/update-row.md +9 -1
  115. package/docs/examples/tablesdb/update-transaction.md +2 -0
  116. package/docs/examples/tablesdb/upsert-row.md +9 -1
  117. package/docs/examples/teams/create-membership.md +2 -0
  118. package/docs/examples/teams/create.md +2 -0
  119. package/docs/examples/teams/delete-membership.md +2 -0
  120. package/docs/examples/teams/delete.md +2 -0
  121. package/docs/examples/teams/get-membership.md +2 -0
  122. package/docs/examples/teams/get-prefs.md +2 -0
  123. package/docs/examples/teams/get.md +2 -0
  124. package/docs/examples/teams/list-memberships.md +2 -0
  125. package/docs/examples/teams/list.md +2 -0
  126. package/docs/examples/teams/update-membership-status.md +2 -0
  127. package/docs/examples/teams/update-membership.md +2 -0
  128. package/docs/examples/teams/update-name.md +2 -0
  129. package/docs/examples/teams/update-prefs.md +2 -0
  130. package/package.json +6 -3
  131. package/rollup.config.js +3 -1
  132. package/src/channel.ts +132 -0
  133. package/src/client.ts +72 -10
  134. package/src/enums/browser-permission.ts +22 -0
  135. package/src/enums/o-auth-provider.ts +2 -1
  136. package/src/index.ts +3 -2
  137. package/src/models.ts +8 -0
  138. package/src/query.ts +54 -9
  139. package/src/services/account.ts +45 -16
  140. package/src/services/avatars.ts +20 -19
  141. package/src/services/databases.ts +5 -9
  142. package/src/services/graphql.ts +2 -2
  143. package/src/services/storage.ts +8 -8
  144. package/types/channel.d.ts +71 -0
  145. package/types/client.d.ts +2 -1
  146. package/types/enums/browser-permission.d.ts +22 -0
  147. package/types/enums/o-auth-provider.d.ts +2 -1
  148. package/types/index.d.ts +3 -2
  149. package/types/models.d.ts +8 -0
  150. package/types/query.d.ts +36 -6
  151. package/types/services/account.d.ts +17 -5
  152. package/types/services/avatars.d.ts +12 -11
  153. package/types/services/databases.d.ts +2 -2
  154. package/types/services/storage.d.ts +8 -8
  155. package/src/enums/output.ts +0 -9
  156. package/types/enums/output.d.ts +0 -9
@@ -280,13 +280,42 @@ export class Account extends Service {
280
280
  /**
281
281
  * Use this endpoint to create a JSON Web Token. You can use the resulting JWT to authenticate on behalf of the current user when working with the Appwrite server-side API and SDKs. The JWT secret is valid for 15 minutes from its creation and will be invalid if the user will logout in that time frame.
282
282
  *
283
+ * @param {number} params.duration - Time in seconds before JWT expires. Default duration is 900 seconds, and maximum is 3600 seconds.
283
284
  * @throws {AppwriteException}
284
285
  * @returns {Promise}
285
286
  */
286
- createJWT(): Promise<Models.Jwt> {
287
+ createJWT(params?: { duration?: number }): Promise<Models.Jwt>;
288
+ /**
289
+ * Use this endpoint to create a JSON Web Token. You can use the resulting JWT to authenticate on behalf of the current user when working with the Appwrite server-side API and SDKs. The JWT secret is valid for 15 minutes from its creation and will be invalid if the user will logout in that time frame.
290
+ *
291
+ * @param {number} duration - Time in seconds before JWT expires. Default duration is 900 seconds, and maximum is 3600 seconds.
292
+ * @throws {AppwriteException}
293
+ * @returns {Promise<Models.Jwt>}
294
+ * @deprecated Use the object parameter style method for a better developer experience.
295
+ */
296
+ createJWT(duration?: number): Promise<Models.Jwt>;
297
+ createJWT(
298
+ paramsOrFirst?: { duration?: number } | number
299
+ ): Promise<Models.Jwt> {
300
+ let params: { duration?: number };
301
+
302
+ if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
303
+ params = (paramsOrFirst || {}) as { duration?: number };
304
+ } else {
305
+ params = {
306
+ duration: paramsOrFirst as number
307
+ };
308
+ }
309
+
310
+ const duration = params.duration;
311
+
287
312
  const apiPath = '/account/jwts';
288
313
  const payload: Payload = {};
289
314
 
315
+ if (typeof duration !== 'undefined') {
316
+ payload['duration'] = duration;
317
+ }
318
+
290
319
  const uri = new URL(this.client.config.endpoint + apiPath);
291
320
  return this.client.call('post', uri, {
292
321
  'content-type': 'application/json',
@@ -418,7 +447,7 @@ export class Account extends Service {
418
447
  ): Promise<Models.MfaType> {
419
448
  let params: { type: AuthenticatorType };
420
449
 
421
- if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'type' in paramsOrFirst)) {
450
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('type' in paramsOrFirst))) {
422
451
  params = (paramsOrFirst || {}) as { type: AuthenticatorType };
423
452
  } else {
424
453
  params = {
@@ -463,7 +492,7 @@ export class Account extends Service {
463
492
  ): Promise<Models.MfaType> {
464
493
  let params: { type: AuthenticatorType };
465
494
 
466
- if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'type' in paramsOrFirst)) {
495
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('type' in paramsOrFirst))) {
467
496
  params = (paramsOrFirst || {}) as { type: AuthenticatorType };
468
497
  } else {
469
498
  params = {
@@ -512,7 +541,7 @@ export class Account extends Service {
512
541
  ): Promise<Models.User<Preferences>> {
513
542
  let params: { type: AuthenticatorType, otp: string };
514
543
 
515
- if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'type' in paramsOrFirst)) {
544
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('type' in paramsOrFirst || 'otp' in paramsOrFirst))) {
516
545
  params = (paramsOrFirst || {}) as { type: AuthenticatorType, otp: string };
517
546
  } else {
518
547
  params = {
@@ -570,7 +599,7 @@ export class Account extends Service {
570
599
  ): Promise<Models.User<Preferences>> {
571
600
  let params: { type: AuthenticatorType, otp: string };
572
601
 
573
- if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'type' in paramsOrFirst)) {
602
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('type' in paramsOrFirst || 'otp' in paramsOrFirst))) {
574
603
  params = (paramsOrFirst || {}) as { type: AuthenticatorType, otp: string };
575
604
  } else {
576
605
  params = {
@@ -626,7 +655,7 @@ export class Account extends Service {
626
655
  ): Promise<{}> {
627
656
  let params: { type: AuthenticatorType };
628
657
 
629
- if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'type' in paramsOrFirst)) {
658
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('type' in paramsOrFirst))) {
630
659
  params = (paramsOrFirst || {}) as { type: AuthenticatorType };
631
660
  } else {
632
661
  params = {
@@ -671,7 +700,7 @@ export class Account extends Service {
671
700
  ): Promise<{}> {
672
701
  let params: { type: AuthenticatorType };
673
702
 
674
- if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'type' in paramsOrFirst)) {
703
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('type' in paramsOrFirst))) {
675
704
  params = (paramsOrFirst || {}) as { type: AuthenticatorType };
676
705
  } else {
677
706
  params = {
@@ -717,7 +746,7 @@ export class Account extends Service {
717
746
  ): Promise<Models.MfaChallenge> {
718
747
  let params: { factor: AuthenticationFactor };
719
748
 
720
- if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'factor' in paramsOrFirst)) {
749
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('factor' in paramsOrFirst))) {
721
750
  params = (paramsOrFirst || {}) as { factor: AuthenticationFactor };
722
751
  } else {
723
752
  params = {
@@ -766,7 +795,7 @@ export class Account extends Service {
766
795
  ): Promise<Models.MfaChallenge> {
767
796
  let params: { factor: AuthenticationFactor };
768
797
 
769
- if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'factor' in paramsOrFirst)) {
798
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('factor' in paramsOrFirst))) {
770
799
  params = (paramsOrFirst || {}) as { factor: AuthenticationFactor };
771
800
  } else {
772
801
  params = {
@@ -1252,7 +1281,7 @@ export class Account extends Service {
1252
1281
  ): Promise<Models.User<Preferences>> {
1253
1282
  let params: { prefs: Partial<Preferences> };
1254
1283
 
1255
- if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'prefs' in paramsOrFirst)) {
1284
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('prefs' in paramsOrFirst))) {
1256
1285
  params = (paramsOrFirst || {}) as { prefs: Partial<Preferences> };
1257
1286
  } else {
1258
1287
  params = {
@@ -1603,7 +1632,7 @@ export class Account extends Service {
1603
1632
  * A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits).
1604
1633
  *
1605
1634
  *
1606
- * @param {OAuthProvider} params.provider - OAuth2 Provider. Currently, supported providers are: amazon, apple, auth0, authentik, autodesk, bitbucket, bitly, box, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, github, gitlab, google, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, yahoo, yammer, yandex, zoho, zoom.
1635
+ * @param {OAuthProvider} params.provider - OAuth2 Provider. Currently, supported providers are: amazon, apple, auth0, authentik, autodesk, bitbucket, bitly, box, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, github, gitlab, google, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, yahoo, yammer, yandex, zoho, zoom, githubImagine, googleImagine.
1607
1636
  * @param {string} params.success - URL to redirect back to your app after a successful login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.
1608
1637
  * @param {string} params.failure - URL to redirect back to your app after a failed login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.
1609
1638
  * @param {string[]} params.scopes - A list of custom OAuth2 scopes. Check each provider internal docs for a list of supported scopes. Maximum of 100 scopes are allowed, each 4096 characters long.
@@ -1619,7 +1648,7 @@ export class Account extends Service {
1619
1648
  * A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits).
1620
1649
  *
1621
1650
  *
1622
- * @param {OAuthProvider} provider - OAuth2 Provider. Currently, supported providers are: amazon, apple, auth0, authentik, autodesk, bitbucket, bitly, box, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, github, gitlab, google, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, yahoo, yammer, yandex, zoho, zoom.
1651
+ * @param {OAuthProvider} provider - OAuth2 Provider. Currently, supported providers are: amazon, apple, auth0, authentik, autodesk, bitbucket, bitly, box, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, github, gitlab, google, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, yahoo, yammer, yandex, zoho, zoom, githubImagine, googleImagine.
1623
1652
  * @param {string} success - URL to redirect back to your app after a successful login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.
1624
1653
  * @param {string} failure - URL to redirect back to your app after a failed login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.
1625
1654
  * @param {string[]} scopes - A list of custom OAuth2 scopes. Check each provider internal docs for a list of supported scopes. Maximum of 100 scopes are allowed, each 4096 characters long.
@@ -1634,7 +1663,7 @@ export class Account extends Service {
1634
1663
  ): void | URL {
1635
1664
  let params: { provider: OAuthProvider, success?: string, failure?: string, scopes?: string[] };
1636
1665
 
1637
- if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'provider' in paramsOrFirst)) {
1666
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('provider' in paramsOrFirst || 'success' in paramsOrFirst || 'failure' in paramsOrFirst || 'scopes' in paramsOrFirst))) {
1638
1667
  params = (paramsOrFirst || {}) as { provider: OAuthProvider, success?: string, failure?: string, scopes?: string[] };
1639
1668
  } else {
1640
1669
  params = {
@@ -2294,7 +2323,7 @@ export class Account extends Service {
2294
2323
  *
2295
2324
  * A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits).
2296
2325
  *
2297
- * @param {OAuthProvider} params.provider - OAuth2 Provider. Currently, supported providers are: amazon, apple, auth0, authentik, autodesk, bitbucket, bitly, box, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, github, gitlab, google, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, yahoo, yammer, yandex, zoho, zoom.
2326
+ * @param {OAuthProvider} params.provider - OAuth2 Provider. Currently, supported providers are: amazon, apple, auth0, authentik, autodesk, bitbucket, bitly, box, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, github, gitlab, google, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, yahoo, yammer, yandex, zoho, zoom, githubImagine, googleImagine.
2298
2327
  * @param {string} params.success - URL to redirect back to your app after a successful login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.
2299
2328
  * @param {string} params.failure - URL to redirect back to your app after a failed login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.
2300
2329
  * @param {string[]} params.scopes - A list of custom OAuth2 scopes. Check each provider internal docs for a list of supported scopes. Maximum of 100 scopes are allowed, each 4096 characters long.
@@ -2309,7 +2338,7 @@ export class Account extends Service {
2309
2338
  *
2310
2339
  * A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits).
2311
2340
  *
2312
- * @param {OAuthProvider} provider - OAuth2 Provider. Currently, supported providers are: amazon, apple, auth0, authentik, autodesk, bitbucket, bitly, box, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, github, gitlab, google, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, yahoo, yammer, yandex, zoho, zoom.
2341
+ * @param {OAuthProvider} provider - OAuth2 Provider. Currently, supported providers are: amazon, apple, auth0, authentik, autodesk, bitbucket, bitly, box, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, github, gitlab, google, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, yahoo, yammer, yandex, zoho, zoom, githubImagine, googleImagine.
2313
2342
  * @param {string} success - URL to redirect back to your app after a successful login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.
2314
2343
  * @param {string} failure - URL to redirect back to your app after a failed login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.
2315
2344
  * @param {string[]} scopes - A list of custom OAuth2 scopes. Check each provider internal docs for a list of supported scopes. Maximum of 100 scopes are allowed, each 4096 characters long.
@@ -2324,7 +2353,7 @@ export class Account extends Service {
2324
2353
  ): void | URL {
2325
2354
  let params: { provider: OAuthProvider, success?: string, failure?: string, scopes?: string[] };
2326
2355
 
2327
- if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'provider' in paramsOrFirst)) {
2356
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('provider' in paramsOrFirst || 'success' in paramsOrFirst || 'failure' in paramsOrFirst || 'scopes' in paramsOrFirst))) {
2328
2357
  params = (paramsOrFirst || {}) as { provider: OAuthProvider, success?: string, failure?: string, scopes?: string[] };
2329
2358
  } else {
2330
2359
  params = {
@@ -10,7 +10,8 @@ import { CreditCard } from '../enums/credit-card';
10
10
  import { Flag } from '../enums/flag';
11
11
  import { Theme } from '../enums/theme';
12
12
  import { Timezone } from '../enums/timezone';
13
- import { Output } from '../enums/output';
13
+ import { BrowserPermission } from '../enums/browser-permission';
14
+ import { ImageFormat } from '../enums/image-format';
14
15
 
15
16
  export class Avatars extends Service {
16
17
 
@@ -52,7 +53,7 @@ export class Avatars extends Service {
52
53
  ): Promise<ArrayBuffer> {
53
54
  let params: { code: Browser, width?: number, height?: number, quality?: number };
54
55
 
55
- if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'code' in paramsOrFirst)) {
56
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('code' in paramsOrFirst || 'width' in paramsOrFirst || 'height' in paramsOrFirst || 'quality' in paramsOrFirst))) {
56
57
  params = (paramsOrFirst || {}) as { code: Browser, width?: number, height?: number, quality?: number };
57
58
  } else {
58
59
  params = {
@@ -133,7 +134,7 @@ export class Avatars extends Service {
133
134
  ): Promise<ArrayBuffer> {
134
135
  let params: { code: CreditCard, width?: number, height?: number, quality?: number };
135
136
 
136
- if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'code' in paramsOrFirst)) {
137
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('code' in paramsOrFirst || 'width' in paramsOrFirst || 'height' in paramsOrFirst || 'quality' in paramsOrFirst))) {
137
138
  params = (paramsOrFirst || {}) as { code: CreditCard, width?: number, height?: number, quality?: number };
138
139
  } else {
139
140
  params = {
@@ -272,7 +273,7 @@ export class Avatars extends Service {
272
273
  ): Promise<ArrayBuffer> {
273
274
  let params: { code: Flag, width?: number, height?: number, quality?: number };
274
275
 
275
- if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'code' in paramsOrFirst)) {
276
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('code' in paramsOrFirst || 'width' in paramsOrFirst || 'height' in paramsOrFirst || 'quality' in paramsOrFirst))) {
276
277
  params = (paramsOrFirst || {}) as { code: Flag, width?: number, height?: number, quality?: number };
277
278
  } else {
278
279
  params = {
@@ -584,16 +585,16 @@ export class Avatars extends Service {
584
585
  * @param {number} params.longitude - Geolocation longitude. Pass a number between -180 to 180. Defaults to 0.
585
586
  * @param {number} params.accuracy - Geolocation accuracy in meters. Pass a number between 0 to 100000. Defaults to 0.
586
587
  * @param {boolean} params.touch - Enable touch support. Pass 0 for no touch, or 1 for touch enabled. Defaults to 0.
587
- * @param {string[]} params.permissions - Browser permissions to grant. Pass an array of permission names like ["geolocation", "camera", "microphone"]. Defaults to empty.
588
+ * @param {BrowserPermission[]} params.permissions - Browser permissions to grant. Pass an array of permission names like ["geolocation", "camera", "microphone"]. Defaults to empty.
588
589
  * @param {number} params.sleep - Wait time in seconds before taking the screenshot. Pass an integer between 0 to 10. Defaults to 0.
589
590
  * @param {number} params.width - Output image width. Pass 0 to use original width, or an integer between 1 to 2000. Defaults to 0 (original width).
590
591
  * @param {number} params.height - Output image height. Pass 0 to use original height, or an integer between 1 to 2000. Defaults to 0 (original height).
591
592
  * @param {number} params.quality - Screenshot quality. Pass an integer between 0 to 100. Defaults to keep existing image quality.
592
- * @param {Output} params.output - Output format type (jpeg, jpg, png, gif and webp).
593
+ * @param {ImageFormat} params.output - Output format type (jpeg, jpg, png, gif and webp).
593
594
  * @throws {AppwriteException}
594
595
  * @returns {ArrayBuffer}
595
596
  */
596
- getScreenshot(params: { url: string, headers?: object, viewportWidth?: number, viewportHeight?: number, scale?: number, theme?: Theme, userAgent?: string, fullpage?: boolean, locale?: string, timezone?: Timezone, latitude?: number, longitude?: number, accuracy?: number, touch?: boolean, permissions?: string[], sleep?: number, width?: number, height?: number, quality?: number, output?: Output }): Promise<ArrayBuffer>;
597
+ getScreenshot(params: { url: string, headers?: object, viewportWidth?: number, viewportHeight?: number, scale?: number, theme?: Theme, userAgent?: string, fullpage?: boolean, locale?: string, timezone?: Timezone, latitude?: number, longitude?: number, accuracy?: number, touch?: boolean, permissions?: BrowserPermission[], sleep?: number, width?: number, height?: number, quality?: number, output?: ImageFormat }): Promise<ArrayBuffer>;
597
598
  /**
598
599
  * Use this endpoint to capture a screenshot of any website URL. This endpoint uses a headless browser to render the webpage and capture it as an image.
599
600
  *
@@ -615,25 +616,25 @@ export class Avatars extends Service {
615
616
  * @param {number} longitude - Geolocation longitude. Pass a number between -180 to 180. Defaults to 0.
616
617
  * @param {number} accuracy - Geolocation accuracy in meters. Pass a number between 0 to 100000. Defaults to 0.
617
618
  * @param {boolean} touch - Enable touch support. Pass 0 for no touch, or 1 for touch enabled. Defaults to 0.
618
- * @param {string[]} permissions - Browser permissions to grant. Pass an array of permission names like ["geolocation", "camera", "microphone"]. Defaults to empty.
619
+ * @param {BrowserPermission[]} permissions - Browser permissions to grant. Pass an array of permission names like ["geolocation", "camera", "microphone"]. Defaults to empty.
619
620
  * @param {number} sleep - Wait time in seconds before taking the screenshot. Pass an integer between 0 to 10. Defaults to 0.
620
621
  * @param {number} width - Output image width. Pass 0 to use original width, or an integer between 1 to 2000. Defaults to 0 (original width).
621
622
  * @param {number} height - Output image height. Pass 0 to use original height, or an integer between 1 to 2000. Defaults to 0 (original height).
622
623
  * @param {number} quality - Screenshot quality. Pass an integer between 0 to 100. Defaults to keep existing image quality.
623
- * @param {Output} output - Output format type (jpeg, jpg, png, gif and webp).
624
+ * @param {ImageFormat} output - Output format type (jpeg, jpg, png, gif and webp).
624
625
  * @throws {AppwriteException}
625
626
  * @returns {Promise<ArrayBuffer>}
626
627
  * @deprecated Use the object parameter style method for a better developer experience.
627
628
  */
628
- getScreenshot(url: string, headers?: object, viewportWidth?: number, viewportHeight?: number, scale?: number, theme?: Theme, userAgent?: string, fullpage?: boolean, locale?: string, timezone?: Timezone, latitude?: number, longitude?: number, accuracy?: number, touch?: boolean, permissions?: string[], sleep?: number, width?: number, height?: number, quality?: number, output?: Output): Promise<ArrayBuffer>;
629
+ getScreenshot(url: string, headers?: object, viewportWidth?: number, viewportHeight?: number, scale?: number, theme?: Theme, userAgent?: string, fullpage?: boolean, locale?: string, timezone?: Timezone, latitude?: number, longitude?: number, accuracy?: number, touch?: boolean, permissions?: BrowserPermission[], sleep?: number, width?: number, height?: number, quality?: number, output?: ImageFormat): Promise<ArrayBuffer>;
629
630
  getScreenshot(
630
- paramsOrFirst: { url: string, headers?: object, viewportWidth?: number, viewportHeight?: number, scale?: number, theme?: Theme, userAgent?: string, fullpage?: boolean, locale?: string, timezone?: Timezone, latitude?: number, longitude?: number, accuracy?: number, touch?: boolean, permissions?: string[], sleep?: number, width?: number, height?: number, quality?: number, output?: Output } | string,
631
- ...rest: [(object)?, (number)?, (number)?, (number)?, (Theme)?, (string)?, (boolean)?, (string)?, (Timezone)?, (number)?, (number)?, (number)?, (boolean)?, (string[])?, (number)?, (number)?, (number)?, (number)?, (Output)?]
631
+ paramsOrFirst: { url: string, headers?: object, viewportWidth?: number, viewportHeight?: number, scale?: number, theme?: Theme, userAgent?: string, fullpage?: boolean, locale?: string, timezone?: Timezone, latitude?: number, longitude?: number, accuracy?: number, touch?: boolean, permissions?: BrowserPermission[], sleep?: number, width?: number, height?: number, quality?: number, output?: ImageFormat } | string,
632
+ ...rest: [(object)?, (number)?, (number)?, (number)?, (Theme)?, (string)?, (boolean)?, (string)?, (Timezone)?, (number)?, (number)?, (number)?, (boolean)?, (BrowserPermission[])?, (number)?, (number)?, (number)?, (number)?, (ImageFormat)?]
632
633
  ): Promise<ArrayBuffer> {
633
- let params: { url: string, headers?: object, viewportWidth?: number, viewportHeight?: number, scale?: number, theme?: Theme, userAgent?: string, fullpage?: boolean, locale?: string, timezone?: Timezone, latitude?: number, longitude?: number, accuracy?: number, touch?: boolean, permissions?: string[], sleep?: number, width?: number, height?: number, quality?: number, output?: Output };
634
+ let params: { url: string, headers?: object, viewportWidth?: number, viewportHeight?: number, scale?: number, theme?: Theme, userAgent?: string, fullpage?: boolean, locale?: string, timezone?: Timezone, latitude?: number, longitude?: number, accuracy?: number, touch?: boolean, permissions?: BrowserPermission[], sleep?: number, width?: number, height?: number, quality?: number, output?: ImageFormat };
634
635
 
635
636
  if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
636
- params = (paramsOrFirst || {}) as { url: string, headers?: object, viewportWidth?: number, viewportHeight?: number, scale?: number, theme?: Theme, userAgent?: string, fullpage?: boolean, locale?: string, timezone?: Timezone, latitude?: number, longitude?: number, accuracy?: number, touch?: boolean, permissions?: string[], sleep?: number, width?: number, height?: number, quality?: number, output?: Output };
637
+ params = (paramsOrFirst || {}) as { url: string, headers?: object, viewportWidth?: number, viewportHeight?: number, scale?: number, theme?: Theme, userAgent?: string, fullpage?: boolean, locale?: string, timezone?: Timezone, latitude?: number, longitude?: number, accuracy?: number, touch?: boolean, permissions?: BrowserPermission[], sleep?: number, width?: number, height?: number, quality?: number, output?: ImageFormat };
637
638
  } else {
638
639
  params = {
639
640
  url: paramsOrFirst as string,
@@ -650,12 +651,12 @@ export class Avatars extends Service {
650
651
  longitude: rest[10] as number,
651
652
  accuracy: rest[11] as number,
652
653
  touch: rest[12] as boolean,
653
- permissions: rest[13] as string[],
654
+ permissions: rest[13] as BrowserPermission[],
654
655
  sleep: rest[14] as number,
655
656
  width: rest[15] as number,
656
657
  height: rest[16] as number,
657
658
  quality: rest[17] as number,
658
- output: rest[18] as Output
659
+ output: rest[18] as ImageFormat
659
660
  };
660
661
  }
661
662
 
@@ -1108,16 +1109,16 @@ export class Avatars extends Service {
1108
1109
  * @param {number} longitude
1109
1110
  * @param {number} accuracy
1110
1111
  * @param {boolean} touch
1111
- * @param {string[]} permissions
1112
+ * @param {BrowserPermission[]} permissions
1112
1113
  * @param {number} sleep
1113
1114
  * @param {number} width
1114
1115
  * @param {number} height
1115
1116
  * @param {number} quality
1116
- * @param {Output} output
1117
+ * @param {ImageFormat} output
1117
1118
  * @throws {AppwriteException}
1118
1119
  * @returns {URL}
1119
1120
  */
1120
- getScreenshotURL(url: string, headers?: object, viewportWidth?: number, viewportHeight?: number, scale?: number, theme?: Theme, userAgent?: string, fullpage?: boolean, locale?: string, timezone?: Timezone, latitude?: number, longitude?: number, accuracy?: number, touch?: boolean, permissions?: string[], sleep?: number, width?: number, height?: number, quality?: number, output?: Output): URL {
1121
+ getScreenshotURL(url: string, headers?: object, viewportWidth?: number, viewportHeight?: number, scale?: number, theme?: Theme, userAgent?: string, fullpage?: boolean, locale?: string, timezone?: Timezone, latitude?: number, longitude?: number, accuracy?: number, touch?: boolean, permissions?: BrowserPermission[], sleep?: number, width?: number, height?: number, quality?: number, output?: ImageFormat): URL {
1121
1122
  const apiPath = '/avatars/screenshots';
1122
1123
  const payload: Payload = {};
1123
1124
 
@@ -571,7 +571,7 @@ export class Databases extends Service {
571
571
  * @returns {Promise}
572
572
  * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.upsertRow` instead.
573
573
  */
574
- upsertDocument<Document extends Models.Document = Models.DefaultDocument>(params: { databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>, permissions?: string[], transactionId?: string }): Promise<Document>;
574
+ upsertDocument<Document extends Models.Document = Models.DefaultDocument>(params: { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>, permissions?: string[], transactionId?: string }): Promise<Document>;
575
575
  /**
576
576
  * Create or update a Document. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console.
577
577
  *
@@ -585,15 +585,15 @@ export class Databases extends Service {
585
585
  * @returns {Promise<Document>}
586
586
  * @deprecated Use the object parameter style method for a better developer experience.
587
587
  */
588
- upsertDocument<Document extends Models.Document = Models.DefaultDocument>(databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>, permissions?: string[], transactionId?: string): Promise<Document>;
588
+ upsertDocument<Document extends Models.Document = Models.DefaultDocument>(databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>, permissions?: string[], transactionId?: string): Promise<Document>;
589
589
  upsertDocument<Document extends Models.Document = Models.DefaultDocument>(
590
- paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>, permissions?: string[], transactionId?: string } | string,
590
+ paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>, permissions?: string[], transactionId?: string } | string,
591
591
  ...rest: [(string)?, (string)?, (Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>)?, (string[])?, (string)?]
592
592
  ): Promise<Document> {
593
- let params: { databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>, permissions?: string[], transactionId?: string };
593
+ let params: { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>, permissions?: string[], transactionId?: string };
594
594
 
595
595
  if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
596
- params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>, permissions?: string[], transactionId?: string };
596
+ params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>, permissions?: string[], transactionId?: string };
597
597
  } else {
598
598
  params = {
599
599
  databaseId: paramsOrFirst as string,
@@ -624,10 +624,6 @@ export class Databases extends Service {
624
624
  throw new AppwriteException('Missing required parameter: "documentId"');
625
625
  }
626
626
 
627
- if (typeof data === 'undefined') {
628
- throw new AppwriteException('Missing required parameter: "data"');
629
- }
630
-
631
627
  const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId);
632
628
  const payload: Payload = {};
633
629
 
@@ -35,7 +35,7 @@ export class Graphql extends Service {
35
35
  ): Promise<{}> {
36
36
  let params: { query: object };
37
37
 
38
- if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'query' in paramsOrFirst)) {
38
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('query' in paramsOrFirst))) {
39
39
  params = (paramsOrFirst || {}) as { query: object };
40
40
  } else {
41
41
  params = {
@@ -85,7 +85,7 @@ export class Graphql extends Service {
85
85
  ): Promise<{}> {
86
86
  let params: { query: object };
87
87
 
88
- if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'query' in paramsOrFirst)) {
88
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('query' in paramsOrFirst))) {
89
89
  params = (paramsOrFirst || {}) as { query: object };
90
90
  } else {
91
91
  params = {
@@ -289,10 +289,10 @@ export class Storage extends Service {
289
289
  /**
290
290
  * Update a file by its unique ID. Only users with write permissions have access to update this resource.
291
291
  *
292
- * @param {string} params.bucketId - Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket).
293
- * @param {string} params.fileId - File unique ID.
294
- * @param {string} params.name - Name of the file
295
- * @param {string[]} params.permissions - An array of permission string. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions).
292
+ * @param {string} params.bucketId - Bucket unique ID.
293
+ * @param {string} params.fileId - File ID.
294
+ * @param {string} params.name - File name.
295
+ * @param {string[]} params.permissions - An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions).
296
296
  * @throws {AppwriteException}
297
297
  * @returns {Promise}
298
298
  */
@@ -300,10 +300,10 @@ export class Storage extends Service {
300
300
  /**
301
301
  * Update a file by its unique ID. Only users with write permissions have access to update this resource.
302
302
  *
303
- * @param {string} bucketId - Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket).
304
- * @param {string} fileId - File unique ID.
305
- * @param {string} name - Name of the file
306
- * @param {string[]} permissions - An array of permission string. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions).
303
+ * @param {string} bucketId - Bucket unique ID.
304
+ * @param {string} fileId - File ID.
305
+ * @param {string} name - File name.
306
+ * @param {string[]} permissions - An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions).
307
307
  * @throws {AppwriteException}
308
308
  * @returns {Promise<Models.File>}
309
309
  * @deprecated Use the object parameter style method for a better developer experience.
@@ -0,0 +1,71 @@
1
+ interface Database {
2
+ _db: any;
3
+ }
4
+ interface Collection {
5
+ _coll: any;
6
+ }
7
+ interface Document {
8
+ _doc: any;
9
+ }
10
+ interface TablesDB {
11
+ _tdb: any;
12
+ }
13
+ interface Table {
14
+ _tbl: any;
15
+ }
16
+ interface Row {
17
+ _row: any;
18
+ }
19
+ interface Bucket {
20
+ _bkt: any;
21
+ }
22
+ interface File {
23
+ _file: any;
24
+ }
25
+ interface Func {
26
+ _fn: any;
27
+ }
28
+ interface Execution {
29
+ _exec: any;
30
+ }
31
+ interface Team {
32
+ _team: any;
33
+ }
34
+ interface Membership {
35
+ _mem: any;
36
+ }
37
+ interface Resolved {
38
+ _res: any;
39
+ }
40
+ type Actionable = Document | Row | File | Team | Membership;
41
+ export declare class Channel<T> {
42
+ private readonly segments;
43
+ _type: T;
44
+ private constructor();
45
+ private next;
46
+ private resolve;
47
+ toString(): string;
48
+ collection(this: Channel<Database>, id?: string): Channel<Collection>;
49
+ document(this: Channel<Collection>, id?: string): Channel<Document>;
50
+ table(this: Channel<TablesDB>, id?: string): Channel<Table>;
51
+ row(this: Channel<Table>, id?: string): Channel<Row>;
52
+ file(this: Channel<Bucket>, id?: string): Channel<File>;
53
+ create(this: Channel<Actionable>): Channel<Resolved>;
54
+ update(this: Channel<Actionable>): Channel<Resolved>;
55
+ delete(this: Channel<Actionable>): Channel<Resolved>;
56
+ static database(id?: string): Channel<Database>;
57
+ static tablesdb(id?: string): Channel<TablesDB>;
58
+ static bucket(id?: string): Channel<Bucket>;
59
+ static function(id?: string): Channel<Func>;
60
+ static execution(id?: string): Channel<Execution>;
61
+ static team(id?: string): Channel<Team>;
62
+ static membership(id?: string): Channel<Membership>;
63
+ static account(): string;
64
+ static get documents(): string;
65
+ static get rows(): string;
66
+ static get files(): string;
67
+ static get executions(): string;
68
+ }
69
+ export type ActionableChannel = Channel<Document> | Channel<Row> | Channel<File> | Channel<Execution> | Channel<Team> | Channel<Membership>;
70
+ export type ResolvedChannel = Channel<Resolved>;
71
+ export {};
package/types/client.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { Models } from './models';
2
+ import { Query } from './query';
2
3
  type Payload = {
3
4
  [key: string]: any;
4
5
  };
@@ -137,7 +138,7 @@ declare class Client {
137
138
  * @param {(payload: RealtimeMessage) => void} callback Is called on every realtime update.
138
139
  * @returns {() => void} Unsubscribes from events.
139
140
  */
140
- subscribe<T extends unknown>(channels: string | string[], callback: (payload: RealtimeResponseEvent<T>) => void): () => void;
141
+ subscribe<T extends unknown>(channels: string | string[], callback: (payload: RealtimeResponseEvent<T>) => void, queries?: (string | Query)[]): () => void;
141
142
  call(method: string, url: URL, headers?: Headers, params?: Payload, responseType?: string): Promise<any>;
142
143
  }
143
144
  export { Client, AppwriteException };
@@ -0,0 +1,22 @@
1
+ export declare enum BrowserPermission {
2
+ Geolocation = "geolocation",
3
+ Camera = "camera",
4
+ Microphone = "microphone",
5
+ Notifications = "notifications",
6
+ Midi = "midi",
7
+ Push = "push",
8
+ ClipboardRead = "clipboard-read",
9
+ ClipboardWrite = "clipboard-write",
10
+ PaymentHandler = "payment-handler",
11
+ Usb = "usb",
12
+ Bluetooth = "bluetooth",
13
+ Accelerometer = "accelerometer",
14
+ Gyroscope = "gyroscope",
15
+ Magnetometer = "magnetometer",
16
+ AmbientLightSensor = "ambient-light-sensor",
17
+ BackgroundSync = "background-sync",
18
+ PersistentStorage = "persistent-storage",
19
+ ScreenWakeLock = "screen-wake-lock",
20
+ WebShare = "web-share",
21
+ XrSpatialTracking = "xr-spatial-tracking"
22
+ }
@@ -38,5 +38,6 @@ export declare enum OAuthProvider {
38
38
  Yandex = "yandex",
39
39
  Zoho = "zoho",
40
40
  Zoom = "zoom",
41
- Mock = "mock"
41
+ GithubImagine = "githubImagine",
42
+ GoogleImagine = "googleImagine"
42
43
  }
package/types/index.d.ts CHANGED
@@ -15,6 +15,7 @@ export { Query } from './query';
15
15
  export { Permission } from './permission';
16
16
  export { Role } from './role';
17
17
  export { ID } from './id';
18
+ export { Channel } from './channel';
18
19
  export { Operator, Condition } from './operator';
19
20
  export { AuthenticatorType } from './enums/authenticator-type';
20
21
  export { AuthenticationFactor } from './enums/authentication-factor';
@@ -24,9 +25,9 @@ export { CreditCard } from './enums/credit-card';
24
25
  export { Flag } from './enums/flag';
25
26
  export { Theme } from './enums/theme';
26
27
  export { Timezone } from './enums/timezone';
27
- export { Output } from './enums/output';
28
+ export { BrowserPermission } from './enums/browser-permission';
29
+ export { ImageFormat } from './enums/image-format';
28
30
  export { ExecutionMethod } from './enums/execution-method';
29
31
  export { ImageGravity } from './enums/image-gravity';
30
- export { ImageFormat } from './enums/image-format';
31
32
  export { ExecutionTrigger } from './enums/execution-trigger';
32
33
  export { ExecutionStatus } from './enums/execution-status';
package/types/models.d.ts CHANGED
@@ -863,6 +863,14 @@ export declare namespace Models {
863
863
  * Total number of chunks uploaded
864
864
  */
865
865
  chunksUploaded: number;
866
+ /**
867
+ * Whether file contents are encrypted at rest.
868
+ */
869
+ encryption: boolean;
870
+ /**
871
+ * Compression algorithm used for the file. Will be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd).
872
+ */
873
+ compression: string;
866
874
  };
867
875
  /**
868
876
  * Team