react-native-appwrite 0.10.1 → 0.12.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 (126) hide show
  1. package/CHANGELOG.md +7 -1
  2. package/README.md +84 -3
  3. package/dist/cjs/sdk.js +1810 -1113
  4. package/dist/cjs/sdk.js.map +1 -1
  5. package/dist/esm/sdk.js +1810 -1114
  6. package/dist/esm/sdk.js.map +1 -1
  7. package/docs/examples/account/create-email-password-session.md +4 -4
  8. package/docs/examples/account/create-email-token.md +5 -5
  9. package/docs/examples/account/{create-magic-u-r-l-token.md → create-magic-url-token.md} +6 -6
  10. package/docs/examples/account/create-mfa-authenticator.md +3 -3
  11. package/docs/examples/account/create-mfa-challenge.md +3 -3
  12. package/docs/examples/account/create-mfa-recovery-codes.md +1 -1
  13. package/docs/examples/account/{create-o-auth2token.md → create-o-auth-2-session.md} +6 -6
  14. package/docs/examples/account/{create-o-auth2session.md → create-o-auth-2-token.md} +6 -6
  15. package/docs/examples/account/create-phone-token.md +4 -4
  16. package/docs/examples/account/create-push-target.md +5 -5
  17. package/docs/examples/account/create-recovery.md +4 -4
  18. package/docs/examples/account/create-session.md +4 -4
  19. package/docs/examples/account/create-verification.md +3 -3
  20. package/docs/examples/account/create.md +6 -6
  21. package/docs/examples/account/delete-identity.md +3 -3
  22. package/docs/examples/account/delete-mfa-authenticator.md +3 -3
  23. package/docs/examples/account/delete-push-target.md +3 -3
  24. package/docs/examples/account/delete-session.md +3 -3
  25. package/docs/examples/account/get-mfa-recovery-codes.md +1 -1
  26. package/docs/examples/account/get-session.md +3 -3
  27. package/docs/examples/account/list-identities.md +3 -3
  28. package/docs/examples/account/list-logs.md +3 -3
  29. package/docs/examples/account/list-mfa-factors.md +1 -1
  30. package/docs/examples/account/update-email.md +4 -4
  31. package/docs/examples/account/{update-magic-u-r-l-session.md → update-magic-url-session.md} +4 -4
  32. package/docs/examples/account/update-mfa-authenticator.md +4 -4
  33. package/docs/examples/account/update-mfa-challenge.md +4 -4
  34. package/docs/examples/account/update-mfa-recovery-codes.md +1 -1
  35. package/docs/examples/account/{update-m-f-a.md → update-mfa.md} +3 -3
  36. package/docs/examples/account/update-name.md +3 -3
  37. package/docs/examples/account/update-password.md +4 -4
  38. package/docs/examples/account/update-phone-session.md +4 -4
  39. package/docs/examples/account/update-phone-verification.md +4 -4
  40. package/docs/examples/account/update-phone.md +4 -4
  41. package/docs/examples/account/update-prefs.md +3 -3
  42. package/docs/examples/account/update-push-target.md +4 -4
  43. package/docs/examples/account/update-recovery.md +5 -5
  44. package/docs/examples/account/update-session.md +3 -3
  45. package/docs/examples/account/update-verification.md +4 -4
  46. package/docs/examples/avatars/get-browser.md +6 -6
  47. package/docs/examples/avatars/get-credit-card.md +6 -6
  48. package/docs/examples/avatars/get-favicon.md +3 -3
  49. package/docs/examples/avatars/get-flag.md +6 -6
  50. package/docs/examples/avatars/get-image.md +5 -5
  51. package/docs/examples/avatars/get-initials.md +6 -6
  52. package/docs/examples/avatars/{get-q-r.md → get-qr.md} +6 -6
  53. package/docs/examples/databases/create-document.md +8 -10
  54. package/docs/examples/databases/decrement-document-attribute.md +18 -0
  55. package/docs/examples/databases/delete-document.md +5 -5
  56. package/docs/examples/databases/get-document.md +6 -6
  57. package/docs/examples/databases/increment-document-attribute.md +18 -0
  58. package/docs/examples/databases/list-documents.md +5 -5
  59. package/docs/examples/databases/update-document.md +7 -7
  60. package/docs/examples/databases/upsert-document.md +7 -7
  61. package/docs/examples/functions/create-execution.md +9 -9
  62. package/docs/examples/functions/get-execution.md +4 -4
  63. package/docs/examples/functions/list-executions.md +4 -4
  64. package/docs/examples/graphql/mutation.md +3 -3
  65. package/docs/examples/graphql/query.md +3 -3
  66. package/docs/examples/messaging/create-subscriber.md +5 -5
  67. package/docs/examples/messaging/delete-subscriber.md +4 -4
  68. package/docs/examples/storage/create-file.md +6 -6
  69. package/docs/examples/storage/delete-file.md +4 -4
  70. package/docs/examples/storage/get-file-download.md +5 -5
  71. package/docs/examples/storage/get-file-preview.md +16 -16
  72. package/docs/examples/storage/get-file-view.md +5 -5
  73. package/docs/examples/storage/get-file.md +4 -4
  74. package/docs/examples/storage/list-files.md +5 -5
  75. package/docs/examples/storage/update-file.md +6 -6
  76. package/docs/examples/tablesdb/create-row.md +17 -0
  77. package/docs/examples/tablesdb/decrement-row-column.md +18 -0
  78. package/docs/examples/tablesdb/delete-row.md +15 -0
  79. package/docs/examples/tablesdb/get-row.md +16 -0
  80. package/docs/examples/tablesdb/increment-row-column.md +18 -0
  81. package/docs/examples/tablesdb/list-rows.md +15 -0
  82. package/docs/examples/tablesdb/update-row.md +17 -0
  83. package/docs/examples/tablesdb/upsert-row.md +17 -0
  84. package/docs/examples/teams/create-membership.md +9 -9
  85. package/docs/examples/teams/create.md +5 -5
  86. package/docs/examples/teams/delete-membership.md +4 -4
  87. package/docs/examples/teams/delete.md +3 -3
  88. package/docs/examples/teams/get-membership.md +4 -4
  89. package/docs/examples/teams/get-prefs.md +3 -3
  90. package/docs/examples/teams/get.md +3 -3
  91. package/docs/examples/teams/list-memberships.md +5 -5
  92. package/docs/examples/teams/list.md +4 -4
  93. package/docs/examples/teams/update-membership-status.md +6 -6
  94. package/docs/examples/teams/update-membership.md +5 -5
  95. package/docs/examples/teams/update-name.md +4 -4
  96. package/docs/examples/teams/update-prefs.md +4 -4
  97. package/package.json +1 -1
  98. package/src/client.ts +2 -2
  99. package/src/index.ts +1 -0
  100. package/src/models.ts +139 -21
  101. package/src/query.ts +95 -0
  102. package/src/services/account.ts +1518 -364
  103. package/src/services/avatars.ts +296 -87
  104. package/src/services/databases.ts +438 -55
  105. package/src/services/functions.ts +118 -23
  106. package/src/services/graphql.ts +54 -6
  107. package/src/services/locale.ts +16 -27
  108. package/src/services/messaging.ts +68 -9
  109. package/src/services/storage.ts +353 -84
  110. package/src/services/tables-db.ts +621 -0
  111. package/src/services/teams.ts +467 -106
  112. package/types/index.d.ts +1 -0
  113. package/types/models.d.ts +127 -62
  114. package/types/query.d.ts +77 -0
  115. package/types/services/account.d.ts +791 -337
  116. package/types/services/avatars.d.ts +175 -80
  117. package/types/services/databases.d.ts +220 -53
  118. package/types/services/functions.d.ts +65 -20
  119. package/types/services/graphql.d.ts +26 -4
  120. package/types/services/locale.d.ts +16 -27
  121. package/types/services/messaging.d.ts +35 -7
  122. package/types/services/storage.d.ts +209 -76
  123. package/types/services/tables-db.d.ts +245 -0
  124. package/types/services/teams.d.ts +261 -99
  125. /package/docs/examples/account/{create-j-w-t.md → create-jwt.md} +0 -0
  126. /package/docs/examples/locale/{list-countries-e-u.md → list-countries-eu.md} +0 -0
package/dist/esm/sdk.js CHANGED
@@ -78,8 +78,8 @@ class Client {
78
78
  'x-sdk-name': 'React Native',
79
79
  'x-sdk-platform': 'client',
80
80
  'x-sdk-language': 'reactnative',
81
- 'x-sdk-version': '0.10.1',
82
- 'X-Appwrite-Response-Format': '1.7.0',
81
+ 'x-sdk-version': '0.12.0',
82
+ 'X-Appwrite-Response-Format': '1.8.0',
83
83
  };
84
84
  this.realtime = {
85
85
  socket: undefined,
@@ -463,30 +463,30 @@ class Account extends Service {
463
463
  *
464
464
  * @throws {AppwriteException}
465
465
  * @returns {Promise}
466
- */
466
+ */
467
467
  get() {
468
468
  const apiPath = '/account';
469
469
  const payload = {};
470
470
  const uri = new URL(this.client.config.endpoint + apiPath);
471
471
  return this.client.call('get', uri, {}, payload);
472
472
  }
473
- /**
474
- * Use this endpoint to allow a new user to register a new account in your
475
- * project. After the user registration completes successfully, you can use
476
- * the
477
- * [/account/verfication](https://appwrite.io/docs/references/cloud/client-web/account#createVerification)
478
- * route to start verifying the user email address. To allow the new user to
479
- * login to their new account, you need to create a new [account
480
- * session](https://appwrite.io/docs/references/cloud/client-web/account#createEmailSession).
481
- *
482
- * @param {string} userId
483
- * @param {string} email
484
- * @param {string} password
485
- * @param {string} name
486
- * @throws {AppwriteException}
487
- * @returns {Promise}
488
- */
489
- create(userId, email, password, name) {
473
+ create(paramsOrFirst, ...rest) {
474
+ let params;
475
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
476
+ params = (paramsOrFirst || {});
477
+ }
478
+ else {
479
+ params = {
480
+ userId: paramsOrFirst,
481
+ email: rest[0],
482
+ password: rest[1],
483
+ name: rest[2]
484
+ };
485
+ }
486
+ const userId = params.userId;
487
+ const email = params.email;
488
+ const password = params.password;
489
+ const name = params.name;
490
490
  if (typeof userId === 'undefined') {
491
491
  throw new AppwriteException('Missing required parameter: "userId"');
492
492
  }
@@ -515,22 +515,19 @@ class Account extends Service {
515
515
  'content-type': 'application/json',
516
516
  }, payload);
517
517
  }
518
- /**
519
- * Update currently logged in user account email address. After changing user
520
- * address, the user confirmation status will get reset. A new confirmation
521
- * email is not sent automatically however you can use the send confirmation
522
- * email endpoint again to send the confirmation email. For security measures,
523
- * user password is required to complete this request.
524
- * This endpoint can also be used to convert an anonymous account to a normal
525
- * one, by passing an email address and a new password.
526
- *
527
- *
528
- * @param {string} email
529
- * @param {string} password
530
- * @throws {AppwriteException}
531
- * @returns {Promise}
532
- */
533
- updateEmail(email, password) {
518
+ updateEmail(paramsOrFirst, ...rest) {
519
+ let params;
520
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
521
+ params = (paramsOrFirst || {});
522
+ }
523
+ else {
524
+ params = {
525
+ email: paramsOrFirst,
526
+ password: rest[0]
527
+ };
528
+ }
529
+ const email = params.email;
530
+ const password = params.password;
534
531
  if (typeof email === 'undefined') {
535
532
  throw new AppwriteException('Missing required parameter: "email"');
536
533
  }
@@ -550,14 +547,17 @@ class Account extends Service {
550
547
  'content-type': 'application/json',
551
548
  }, payload);
552
549
  }
553
- /**
554
- * Get the list of identities for the currently logged in user.
555
- *
556
- * @param {string[]} queries
557
- * @throws {AppwriteException}
558
- * @returns {Promise}
559
- */
560
- listIdentities(queries) {
550
+ listIdentities(paramsOrFirst) {
551
+ let params;
552
+ if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
553
+ params = (paramsOrFirst || {});
554
+ }
555
+ else {
556
+ params = {
557
+ queries: paramsOrFirst
558
+ };
559
+ }
560
+ const queries = params.queries;
561
561
  const apiPath = '/account/identities';
562
562
  const payload = {};
563
563
  if (typeof queries !== 'undefined') {
@@ -566,14 +566,17 @@ class Account extends Service {
566
566
  const uri = new URL(this.client.config.endpoint + apiPath);
567
567
  return this.client.call('get', uri, {}, payload);
568
568
  }
569
- /**
570
- * Delete an identity by its unique ID.
571
- *
572
- * @param {string} identityId
573
- * @throws {AppwriteException}
574
- * @returns {Promise}
575
- */
576
- deleteIdentity(identityId) {
569
+ deleteIdentity(paramsOrFirst) {
570
+ let params;
571
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
572
+ params = (paramsOrFirst || {});
573
+ }
574
+ else {
575
+ params = {
576
+ identityId: paramsOrFirst
577
+ };
578
+ }
579
+ const identityId = params.identityId;
577
580
  if (typeof identityId === 'undefined') {
578
581
  throw new AppwriteException('Missing required parameter: "identityId"');
579
582
  }
@@ -585,15 +588,11 @@ class Account extends Service {
585
588
  }, payload);
586
589
  }
587
590
  /**
588
- * Use this endpoint to create a JSON Web Token. You can use the resulting JWT
589
- * to authenticate on behalf of the current user when working with the
590
- * Appwrite server-side API and SDKs. The JWT secret is valid for 15 minutes
591
- * from its creation and will be invalid if the user will logout in that time
592
- * frame.
591
+ * 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.
593
592
  *
594
593
  * @throws {AppwriteException}
595
594
  * @returns {Promise}
596
- */
595
+ */
597
596
  createJWT() {
598
597
  const apiPath = '/account/jwts';
599
598
  const payload = {};
@@ -602,15 +601,17 @@ class Account extends Service {
602
601
  'content-type': 'application/json',
603
602
  }, payload);
604
603
  }
605
- /**
606
- * Get the list of latest security activity logs for the currently logged in
607
- * user. Each log returns user IP address, location and date and time of log.
608
- *
609
- * @param {string[]} queries
610
- * @throws {AppwriteException}
611
- * @returns {Promise}
612
- */
613
- listLogs(queries) {
604
+ listLogs(paramsOrFirst) {
605
+ let params;
606
+ if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
607
+ params = (paramsOrFirst || {});
608
+ }
609
+ else {
610
+ params = {
611
+ queries: paramsOrFirst
612
+ };
613
+ }
614
+ const queries = params.queries;
614
615
  const apiPath = '/account/logs';
615
616
  const payload = {};
616
617
  if (typeof queries !== 'undefined') {
@@ -619,14 +620,17 @@ class Account extends Service {
619
620
  const uri = new URL(this.client.config.endpoint + apiPath);
620
621
  return this.client.call('get', uri, {}, payload);
621
622
  }
622
- /**
623
- * Enable or disable MFA on an account.
624
- *
625
- * @param {boolean} mfa
626
- * @throws {AppwriteException}
627
- * @returns {Promise}
628
- */
629
- updateMFA(mfa) {
623
+ updateMFA(paramsOrFirst) {
624
+ let params;
625
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
626
+ params = (paramsOrFirst || {});
627
+ }
628
+ else {
629
+ params = {
630
+ mfa: paramsOrFirst
631
+ };
632
+ }
633
+ const mfa = params.mfa;
630
634
  if (typeof mfa === 'undefined') {
631
635
  throw new AppwriteException('Missing required parameter: "mfa"');
632
636
  }
@@ -640,17 +644,17 @@ class Account extends Service {
640
644
  'content-type': 'application/json',
641
645
  }, payload);
642
646
  }
643
- /**
644
- * Add an authenticator app to be used as an MFA factor. Verify the
645
- * authenticator using the [verify
646
- * authenticator](/docs/references/cloud/client-web/account#updateMfaAuthenticator)
647
- * method.
648
- *
649
- * @param {AuthenticatorType} type
650
- * @throws {AppwriteException}
651
- * @returns {Promise}
652
- */
653
- createMfaAuthenticator(type) {
647
+ createMfaAuthenticator(paramsOrFirst) {
648
+ let params;
649
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'type' in paramsOrFirst)) {
650
+ params = (paramsOrFirst || {});
651
+ }
652
+ else {
653
+ params = {
654
+ type: paramsOrFirst
655
+ };
656
+ }
657
+ const type = params.type;
654
658
  if (typeof type === 'undefined') {
655
659
  throw new AppwriteException('Missing required parameter: "type"');
656
660
  }
@@ -661,17 +665,40 @@ class Account extends Service {
661
665
  'content-type': 'application/json',
662
666
  }, payload);
663
667
  }
664
- /**
665
- * Verify an authenticator app after adding it using the [add
666
- * authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator)
667
- * method.
668
- *
669
- * @param {AuthenticatorType} type
670
- * @param {string} otp
671
- * @throws {AppwriteException}
672
- * @returns {Promise}
673
- */
674
- updateMfaAuthenticator(type, otp) {
668
+ createMFAAuthenticator(paramsOrFirst) {
669
+ let params;
670
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'type' in paramsOrFirst)) {
671
+ params = (paramsOrFirst || {});
672
+ }
673
+ else {
674
+ params = {
675
+ type: paramsOrFirst
676
+ };
677
+ }
678
+ const type = params.type;
679
+ if (typeof type === 'undefined') {
680
+ throw new AppwriteException('Missing required parameter: "type"');
681
+ }
682
+ const apiPath = '/account/mfa/authenticators/{type}'.replace('{type}', type);
683
+ const payload = {};
684
+ const uri = new URL(this.client.config.endpoint + apiPath);
685
+ return this.client.call('post', uri, {
686
+ 'content-type': 'application/json',
687
+ }, payload);
688
+ }
689
+ updateMfaAuthenticator(paramsOrFirst, ...rest) {
690
+ let params;
691
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'type' in paramsOrFirst)) {
692
+ params = (paramsOrFirst || {});
693
+ }
694
+ else {
695
+ params = {
696
+ type: paramsOrFirst,
697
+ otp: rest[0]
698
+ };
699
+ }
700
+ const type = params.type;
701
+ const otp = params.otp;
675
702
  if (typeof type === 'undefined') {
676
703
  throw new AppwriteException('Missing required parameter: "type"');
677
704
  }
@@ -688,14 +715,46 @@ class Account extends Service {
688
715
  'content-type': 'application/json',
689
716
  }, payload);
690
717
  }
691
- /**
692
- * Delete an authenticator for a user by ID.
693
- *
694
- * @param {AuthenticatorType} type
695
- * @throws {AppwriteException}
696
- * @returns {Promise}
697
- */
698
- deleteMfaAuthenticator(type) {
718
+ updateMFAAuthenticator(paramsOrFirst, ...rest) {
719
+ let params;
720
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'type' in paramsOrFirst)) {
721
+ params = (paramsOrFirst || {});
722
+ }
723
+ else {
724
+ params = {
725
+ type: paramsOrFirst,
726
+ otp: rest[0]
727
+ };
728
+ }
729
+ const type = params.type;
730
+ const otp = params.otp;
731
+ if (typeof type === 'undefined') {
732
+ throw new AppwriteException('Missing required parameter: "type"');
733
+ }
734
+ if (typeof otp === 'undefined') {
735
+ throw new AppwriteException('Missing required parameter: "otp"');
736
+ }
737
+ const apiPath = '/account/mfa/authenticators/{type}'.replace('{type}', type);
738
+ const payload = {};
739
+ if (typeof otp !== 'undefined') {
740
+ payload['otp'] = otp;
741
+ }
742
+ const uri = new URL(this.client.config.endpoint + apiPath);
743
+ return this.client.call('put', uri, {
744
+ 'content-type': 'application/json',
745
+ }, payload);
746
+ }
747
+ deleteMfaAuthenticator(paramsOrFirst) {
748
+ let params;
749
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'type' in paramsOrFirst)) {
750
+ params = (paramsOrFirst || {});
751
+ }
752
+ else {
753
+ params = {
754
+ type: paramsOrFirst
755
+ };
756
+ }
757
+ const type = params.type;
699
758
  if (typeof type === 'undefined') {
700
759
  throw new AppwriteException('Missing required parameter: "type"');
701
760
  }
@@ -706,16 +765,38 @@ class Account extends Service {
706
765
  'content-type': 'application/json',
707
766
  }, payload);
708
767
  }
709
- /**
710
- * Begin the process of MFA verification after sign-in. Finish the flow with
711
- * [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge)
712
- * method.
713
- *
714
- * @param {AuthenticationFactor} factor
715
- * @throws {AppwriteException}
716
- * @returns {Promise}
717
- */
718
- createMfaChallenge(factor) {
768
+ deleteMFAAuthenticator(paramsOrFirst) {
769
+ let params;
770
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'type' in paramsOrFirst)) {
771
+ params = (paramsOrFirst || {});
772
+ }
773
+ else {
774
+ params = {
775
+ type: paramsOrFirst
776
+ };
777
+ }
778
+ const type = params.type;
779
+ if (typeof type === 'undefined') {
780
+ throw new AppwriteException('Missing required parameter: "type"');
781
+ }
782
+ const apiPath = '/account/mfa/authenticators/{type}'.replace('{type}', type);
783
+ const payload = {};
784
+ const uri = new URL(this.client.config.endpoint + apiPath);
785
+ return this.client.call('delete', uri, {
786
+ 'content-type': 'application/json',
787
+ }, payload);
788
+ }
789
+ createMfaChallenge(paramsOrFirst) {
790
+ let params;
791
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'factor' in paramsOrFirst)) {
792
+ params = (paramsOrFirst || {});
793
+ }
794
+ else {
795
+ params = {
796
+ factor: paramsOrFirst
797
+ };
798
+ }
799
+ const factor = params.factor;
719
800
  if (typeof factor === 'undefined') {
720
801
  throw new AppwriteException('Missing required parameter: "factor"');
721
802
  }
@@ -729,19 +810,75 @@ class Account extends Service {
729
810
  'content-type': 'application/json',
730
811
  }, payload);
731
812
  }
732
- /**
733
- * Complete the MFA challenge by providing the one-time password. Finish the
734
- * process of MFA verification by providing the one-time password. To begin
735
- * the flow, use
736
- * [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge)
737
- * method.
738
- *
739
- * @param {string} challengeId
740
- * @param {string} otp
741
- * @throws {AppwriteException}
742
- * @returns {Promise}
743
- */
744
- updateMfaChallenge(challengeId, otp) {
813
+ createMFAChallenge(paramsOrFirst) {
814
+ let params;
815
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'factor' in paramsOrFirst)) {
816
+ params = (paramsOrFirst || {});
817
+ }
818
+ else {
819
+ params = {
820
+ factor: paramsOrFirst
821
+ };
822
+ }
823
+ const factor = params.factor;
824
+ if (typeof factor === 'undefined') {
825
+ throw new AppwriteException('Missing required parameter: "factor"');
826
+ }
827
+ const apiPath = '/account/mfa/challenge';
828
+ const payload = {};
829
+ if (typeof factor !== 'undefined') {
830
+ payload['factor'] = factor;
831
+ }
832
+ const uri = new URL(this.client.config.endpoint + apiPath);
833
+ return this.client.call('post', uri, {
834
+ 'content-type': 'application/json',
835
+ }, payload);
836
+ }
837
+ updateMfaChallenge(paramsOrFirst, ...rest) {
838
+ let params;
839
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
840
+ params = (paramsOrFirst || {});
841
+ }
842
+ else {
843
+ params = {
844
+ challengeId: paramsOrFirst,
845
+ otp: rest[0]
846
+ };
847
+ }
848
+ const challengeId = params.challengeId;
849
+ const otp = params.otp;
850
+ if (typeof challengeId === 'undefined') {
851
+ throw new AppwriteException('Missing required parameter: "challengeId"');
852
+ }
853
+ if (typeof otp === 'undefined') {
854
+ throw new AppwriteException('Missing required parameter: "otp"');
855
+ }
856
+ const apiPath = '/account/mfa/challenge';
857
+ const payload = {};
858
+ if (typeof challengeId !== 'undefined') {
859
+ payload['challengeId'] = challengeId;
860
+ }
861
+ if (typeof otp !== 'undefined') {
862
+ payload['otp'] = otp;
863
+ }
864
+ const uri = new URL(this.client.config.endpoint + apiPath);
865
+ return this.client.call('put', uri, {
866
+ 'content-type': 'application/json',
867
+ }, payload);
868
+ }
869
+ updateMFAChallenge(paramsOrFirst, ...rest) {
870
+ let params;
871
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
872
+ params = (paramsOrFirst || {});
873
+ }
874
+ else {
875
+ params = {
876
+ challengeId: paramsOrFirst,
877
+ otp: rest[0]
878
+ };
879
+ }
880
+ const challengeId = params.challengeId;
881
+ const otp = params.otp;
745
882
  if (typeof challengeId === 'undefined') {
746
883
  throw new AppwriteException('Missing required parameter: "challengeId"');
747
884
  }
@@ -766,7 +903,8 @@ class Account extends Service {
766
903
  *
767
904
  * @throws {AppwriteException}
768
905
  * @returns {Promise}
769
- */
906
+ * @deprecated This API has been deprecated since 1.8.0. Please use `Account.listMFAFactors` instead.
907
+ */
770
908
  listMfaFactors() {
771
909
  const apiPath = '/account/mfa/factors';
772
910
  const payload = {};
@@ -774,14 +912,24 @@ class Account extends Service {
774
912
  return this.client.call('get', uri, {}, payload);
775
913
  }
776
914
  /**
777
- * Get recovery codes that can be used as backup for MFA flow. Before getting
778
- * codes, they must be generated using
779
- * [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes)
780
- * method. An OTP challenge is required to read recovery codes.
915
+ * List the factors available on the account to be used as a MFA challange.
781
916
  *
782
917
  * @throws {AppwriteException}
783
918
  * @returns {Promise}
784
- */
919
+ */
920
+ listMFAFactors() {
921
+ const apiPath = '/account/mfa/factors';
922
+ const payload = {};
923
+ const uri = new URL(this.client.config.endpoint + apiPath);
924
+ return this.client.call('get', uri, {}, payload);
925
+ }
926
+ /**
927
+ * Get recovery codes that can be used as backup for MFA flow. Before getting codes, they must be generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. An OTP challenge is required to read recovery codes.
928
+ *
929
+ * @throws {AppwriteException}
930
+ * @returns {Promise}
931
+ * @deprecated This API has been deprecated since 1.8.0. Please use `Account.getMFARecoveryCodes` instead.
932
+ */
785
933
  getMfaRecoveryCodes() {
786
934
  const apiPath = '/account/mfa/recovery-codes';
787
935
  const payload = {};
@@ -789,15 +937,24 @@ class Account extends Service {
789
937
  return this.client.call('get', uri, {}, payload);
790
938
  }
791
939
  /**
792
- * Generate recovery codes as backup for MFA flow. It's recommended to
793
- * generate and show then immediately after user successfully adds their
794
- * authehticator. Recovery codes can be used as a MFA verification type in
795
- * [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge)
796
- * method.
940
+ * Get recovery codes that can be used as backup for MFA flow. Before getting codes, they must be generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. An OTP challenge is required to read recovery codes.
797
941
  *
798
942
  * @throws {AppwriteException}
799
943
  * @returns {Promise}
800
- */
944
+ */
945
+ getMFARecoveryCodes() {
946
+ const apiPath = '/account/mfa/recovery-codes';
947
+ const payload = {};
948
+ const uri = new URL(this.client.config.endpoint + apiPath);
949
+ return this.client.call('get', uri, {}, payload);
950
+ }
951
+ /**
952
+ * Generate recovery codes as backup for MFA flow. It's recommended to generate and show then immediately after user successfully adds their authehticator. Recovery codes can be used as a MFA verification type in [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) method.
953
+ *
954
+ * @throws {AppwriteException}
955
+ * @returns {Promise}
956
+ * @deprecated This API has been deprecated since 1.8.0. Please use `Account.createMFARecoveryCodes` instead.
957
+ */
801
958
  createMfaRecoveryCodes() {
802
959
  const apiPath = '/account/mfa/recovery-codes';
803
960
  const payload = {};
@@ -807,14 +964,26 @@ class Account extends Service {
807
964
  }, payload);
808
965
  }
809
966
  /**
810
- * Regenerate recovery codes that can be used as backup for MFA flow. Before
811
- * regenerating codes, they must be first generated using
812
- * [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes)
813
- * method. An OTP challenge is required to regenreate recovery codes.
967
+ * Generate recovery codes as backup for MFA flow. It's recommended to generate and show then immediately after user successfully adds their authehticator. Recovery codes can be used as a MFA verification type in [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) method.
814
968
  *
815
969
  * @throws {AppwriteException}
816
970
  * @returns {Promise}
817
- */
971
+ */
972
+ createMFARecoveryCodes() {
973
+ const apiPath = '/account/mfa/recovery-codes';
974
+ const payload = {};
975
+ const uri = new URL(this.client.config.endpoint + apiPath);
976
+ return this.client.call('post', uri, {
977
+ 'content-type': 'application/json',
978
+ }, payload);
979
+ }
980
+ /**
981
+ * Regenerate recovery codes that can be used as backup for MFA flow. Before regenerating codes, they must be first generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. An OTP challenge is required to regenreate recovery codes.
982
+ *
983
+ * @throws {AppwriteException}
984
+ * @returns {Promise}
985
+ * @deprecated This API has been deprecated since 1.8.0. Please use `Account.updateMFARecoveryCodes` instead.
986
+ */
818
987
  updateMfaRecoveryCodes() {
819
988
  const apiPath = '/account/mfa/recovery-codes';
820
989
  const payload = {};
@@ -824,13 +993,30 @@ class Account extends Service {
824
993
  }, payload);
825
994
  }
826
995
  /**
827
- * Update currently logged in user account name.
996
+ * Regenerate recovery codes that can be used as backup for MFA flow. Before regenerating codes, they must be first generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. An OTP challenge is required to regenreate recovery codes.
828
997
  *
829
- * @param {string} name
830
998
  * @throws {AppwriteException}
831
999
  * @returns {Promise}
832
- */
833
- updateName(name) {
1000
+ */
1001
+ updateMFARecoveryCodes() {
1002
+ const apiPath = '/account/mfa/recovery-codes';
1003
+ const payload = {};
1004
+ const uri = new URL(this.client.config.endpoint + apiPath);
1005
+ return this.client.call('patch', uri, {
1006
+ 'content-type': 'application/json',
1007
+ }, payload);
1008
+ }
1009
+ updateName(paramsOrFirst) {
1010
+ let params;
1011
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
1012
+ params = (paramsOrFirst || {});
1013
+ }
1014
+ else {
1015
+ params = {
1016
+ name: paramsOrFirst
1017
+ };
1018
+ }
1019
+ const name = params.name;
834
1020
  if (typeof name === 'undefined') {
835
1021
  throw new AppwriteException('Missing required parameter: "name"');
836
1022
  }
@@ -844,17 +1030,19 @@ class Account extends Service {
844
1030
  'content-type': 'application/json',
845
1031
  }, payload);
846
1032
  }
847
- /**
848
- * Update currently logged in user password. For validation, user is required
849
- * to pass in the new password, and the old password. For users created with
850
- * OAuth, Team Invites and Magic URL, oldPassword is optional.
851
- *
852
- * @param {string} password
853
- * @param {string} oldPassword
854
- * @throws {AppwriteException}
855
- * @returns {Promise}
856
- */
857
- updatePassword(password, oldPassword) {
1033
+ updatePassword(paramsOrFirst, ...rest) {
1034
+ let params;
1035
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
1036
+ params = (paramsOrFirst || {});
1037
+ }
1038
+ else {
1039
+ params = {
1040
+ password: paramsOrFirst,
1041
+ oldPassword: rest[0]
1042
+ };
1043
+ }
1044
+ const password = params.password;
1045
+ const oldPassword = params.oldPassword;
858
1046
  if (typeof password === 'undefined') {
859
1047
  throw new AppwriteException('Missing required parameter: "password"');
860
1048
  }
@@ -871,19 +1059,19 @@ class Account extends Service {
871
1059
  'content-type': 'application/json',
872
1060
  }, payload);
873
1061
  }
874
- /**
875
- * Update the currently logged in user's phone number. After updating the
876
- * phone number, the phone verification status will be reset. A confirmation
877
- * SMS is not sent automatically, however you can use the [POST
878
- * /account/verification/phone](https://appwrite.io/docs/references/cloud/client-web/account#createPhoneVerification)
879
- * endpoint to send a confirmation SMS.
880
- *
881
- * @param {string} phone
882
- * @param {string} password
883
- * @throws {AppwriteException}
884
- * @returns {Promise}
885
- */
886
- updatePhone(phone, password) {
1062
+ updatePhone(paramsOrFirst, ...rest) {
1063
+ let params;
1064
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
1065
+ params = (paramsOrFirst || {});
1066
+ }
1067
+ else {
1068
+ params = {
1069
+ phone: paramsOrFirst,
1070
+ password: rest[0]
1071
+ };
1072
+ }
1073
+ const phone = params.phone;
1074
+ const password = params.password;
887
1075
  if (typeof phone === 'undefined') {
888
1076
  throw new AppwriteException('Missing required parameter: "phone"');
889
1077
  }
@@ -908,23 +1096,24 @@ class Account extends Service {
908
1096
  *
909
1097
  * @throws {AppwriteException}
910
1098
  * @returns {Promise}
911
- */
1099
+ */
912
1100
  getPrefs() {
913
1101
  const apiPath = '/account/prefs';
914
1102
  const payload = {};
915
1103
  const uri = new URL(this.client.config.endpoint + apiPath);
916
1104
  return this.client.call('get', uri, {}, payload);
917
1105
  }
918
- /**
919
- * Update currently logged in user account preferences. The object you pass is
920
- * stored as is, and replaces any previous value. The maximum allowed prefs
921
- * size is 64kB and throws error if exceeded.
922
- *
923
- * @param {object} prefs
924
- * @throws {AppwriteException}
925
- * @returns {Promise}
926
- */
927
- updatePrefs(prefs) {
1106
+ updatePrefs(paramsOrFirst) {
1107
+ let params;
1108
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'prefs' in paramsOrFirst)) {
1109
+ params = (paramsOrFirst || {});
1110
+ }
1111
+ else {
1112
+ params = {
1113
+ prefs: paramsOrFirst
1114
+ };
1115
+ }
1116
+ const prefs = params.prefs;
928
1117
  if (typeof prefs === 'undefined') {
929
1118
  throw new AppwriteException('Missing required parameter: "prefs"');
930
1119
  }
@@ -938,22 +1127,19 @@ class Account extends Service {
938
1127
  'content-type': 'application/json',
939
1128
  }, payload);
940
1129
  }
941
- /**
942
- * Sends the user an email with a temporary secret key for password reset.
943
- * When the user clicks the confirmation link he is redirected back to your
944
- * app password reset URL with the secret key and email address values
945
- * attached to the URL query string. Use the query string params to submit a
946
- * request to the [PUT
947
- * /account/recovery](https://appwrite.io/docs/references/cloud/client-web/account#updateRecovery)
948
- * endpoint to complete the process. The verification link sent to the user's
949
- * email address is valid for 1 hour.
950
- *
951
- * @param {string} email
952
- * @param {string} url
953
- * @throws {AppwriteException}
954
- * @returns {Promise}
955
- */
956
- createRecovery(email, url) {
1130
+ createRecovery(paramsOrFirst, ...rest) {
1131
+ let params;
1132
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
1133
+ params = (paramsOrFirst || {});
1134
+ }
1135
+ else {
1136
+ params = {
1137
+ email: paramsOrFirst,
1138
+ url: rest[0]
1139
+ };
1140
+ }
1141
+ const email = params.email;
1142
+ const url = params.url;
957
1143
  if (typeof email === 'undefined') {
958
1144
  throw new AppwriteException('Missing required parameter: "email"');
959
1145
  }
@@ -973,25 +1159,21 @@ class Account extends Service {
973
1159
  'content-type': 'application/json',
974
1160
  }, payload);
975
1161
  }
976
- /**
977
- * Use this endpoint to complete the user account password reset. Both the
978
- * **userId** and **secret** arguments will be passed as query parameters to
979
- * the redirect URL you have provided when sending your request to the [POST
980
- * /account/recovery](https://appwrite.io/docs/references/cloud/client-web/account#createRecovery)
981
- * endpoint.
982
- *
983
- * Please note that in order to avoid a [Redirect
984
- * Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md)
985
- * the only valid redirect URLs are the ones from domains you have set when
986
- * adding your platforms in the console interface.
987
- *
988
- * @param {string} userId
989
- * @param {string} secret
990
- * @param {string} password
991
- * @throws {AppwriteException}
992
- * @returns {Promise}
993
- */
994
- updateRecovery(userId, secret, password) {
1162
+ updateRecovery(paramsOrFirst, ...rest) {
1163
+ let params;
1164
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
1165
+ params = (paramsOrFirst || {});
1166
+ }
1167
+ else {
1168
+ params = {
1169
+ userId: paramsOrFirst,
1170
+ secret: rest[0],
1171
+ password: rest[1]
1172
+ };
1173
+ }
1174
+ const userId = params.userId;
1175
+ const secret = params.secret;
1176
+ const password = params.password;
995
1177
  if (typeof userId === 'undefined') {
996
1178
  throw new AppwriteException('Missing required parameter: "userId"');
997
1179
  }
@@ -1018,12 +1200,11 @@ class Account extends Service {
1018
1200
  }, payload);
1019
1201
  }
1020
1202
  /**
1021
- * Get the list of active sessions across different devices for the currently
1022
- * logged in user.
1203
+ * Get the list of active sessions across different devices for the currently logged in user.
1023
1204
  *
1024
1205
  * @throws {AppwriteException}
1025
1206
  * @returns {Promise}
1026
- */
1207
+ */
1027
1208
  listSessions() {
1028
1209
  const apiPath = '/account/sessions';
1029
1210
  const payload = {};
@@ -1031,12 +1212,11 @@ class Account extends Service {
1031
1212
  return this.client.call('get', uri, {}, payload);
1032
1213
  }
1033
1214
  /**
1034
- * Delete all sessions from the user account and remove any sessions cookies
1035
- * from the end client.
1215
+ * Delete all sessions from the user account and remove any sessions cookies from the end client.
1036
1216
  *
1037
1217
  * @throws {AppwriteException}
1038
1218
  * @returns {Promise}
1039
- */
1219
+ */
1040
1220
  deleteSessions() {
1041
1221
  const apiPath = '/account/sessions';
1042
1222
  const payload = {};
@@ -1046,17 +1226,11 @@ class Account extends Service {
1046
1226
  }, payload);
1047
1227
  }
1048
1228
  /**
1049
- * Use this endpoint to allow a new user to register an anonymous account in
1050
- * your project. This route will also create a new session for the user. To
1051
- * allow the new user to convert an anonymous account to a normal account, you
1052
- * need to update its [email and
1053
- * password](https://appwrite.io/docs/references/cloud/client-web/account#updateEmail)
1054
- * or create an [OAuth2
1055
- * session](https://appwrite.io/docs/references/cloud/client-web/account#CreateOAuth2Session).
1229
+ * Use this endpoint to allow a new user to register an anonymous account in your project. This route will also create a new session for the user. To allow the new user to convert an anonymous account to a normal account, you need to update its [email and password](https://appwrite.io/docs/references/cloud/client-web/account#updateEmail) or create an [OAuth2 session](https://appwrite.io/docs/references/cloud/client-web/account#CreateOAuth2Session).
1056
1230
  *
1057
1231
  * @throws {AppwriteException}
1058
1232
  * @returns {Promise}
1059
- */
1233
+ */
1060
1234
  createAnonymousSession() {
1061
1235
  const apiPath = '/account/sessions/anonymous';
1062
1236
  const payload = {};
@@ -1065,20 +1239,19 @@ class Account extends Service {
1065
1239
  'content-type': 'application/json',
1066
1240
  }, payload);
1067
1241
  }
1068
- /**
1069
- * Allow the user to login into their account by providing a valid email and
1070
- * password combination. This route will create a new session for the user.
1071
- *
1072
- * A user is limited to 10 active sessions at a time by default. [Learn more
1073
- * about session
1074
- * limits](https://appwrite.io/docs/authentication-security#limits).
1075
- *
1076
- * @param {string} email
1077
- * @param {string} password
1078
- * @throws {AppwriteException}
1079
- * @returns {Promise}
1080
- */
1081
- createEmailPasswordSession(email, password) {
1242
+ createEmailPasswordSession(paramsOrFirst, ...rest) {
1243
+ let params;
1244
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
1245
+ params = (paramsOrFirst || {});
1246
+ }
1247
+ else {
1248
+ params = {
1249
+ email: paramsOrFirst,
1250
+ password: rest[0]
1251
+ };
1252
+ }
1253
+ const email = params.email;
1254
+ const password = params.password;
1082
1255
  if (typeof email === 'undefined') {
1083
1256
  throw new AppwriteException('Missing required parameter: "email"');
1084
1257
  }
@@ -1098,17 +1271,19 @@ class Account extends Service {
1098
1271
  'content-type': 'application/json',
1099
1272
  }, payload);
1100
1273
  }
1101
- /**
1102
- * Use this endpoint to create a session from token. Provide the **userId**
1103
- * and **secret** parameters from the successful response of authentication
1104
- * flows initiated by token creation. For example, magic URL and phone login.
1105
- *
1106
- * @param {string} userId
1107
- * @param {string} secret
1108
- * @throws {AppwriteException}
1109
- * @returns {Promise}
1110
- */
1111
- updateMagicURLSession(userId, secret) {
1274
+ updateMagicURLSession(paramsOrFirst, ...rest) {
1275
+ let params;
1276
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
1277
+ params = (paramsOrFirst || {});
1278
+ }
1279
+ else {
1280
+ params = {
1281
+ userId: paramsOrFirst,
1282
+ secret: rest[0]
1283
+ };
1284
+ }
1285
+ const userId = params.userId;
1286
+ const secret = params.secret;
1112
1287
  if (typeof userId === 'undefined') {
1113
1288
  throw new AppwriteException('Missing required parameter: "userId"');
1114
1289
  }
@@ -1128,32 +1303,23 @@ class Account extends Service {
1128
1303
  'content-type': 'application/json',
1129
1304
  }, payload);
1130
1305
  }
1131
- /**
1132
- * Allow the user to login to their account using the OAuth2 provider of their
1133
- * choice. Each OAuth2 provider should be enabled from the Appwrite console
1134
- * first. Use the success and failure arguments to provide a redirect URL's
1135
- * back to your app when login is completed.
1136
- *
1137
- * If there is already an active session, the new session will be attached to
1138
- * the logged-in account. If there are no active sessions, the server will
1139
- * attempt to look for a user with the same email address as the email
1140
- * received from the OAuth2 provider and attach the new session to the
1141
- * existing user. If no matching user is found - the server will create a new
1142
- * user.
1143
- *
1144
- * A user is limited to 10 active sessions at a time by default. [Learn more
1145
- * about session
1146
- * limits](https://appwrite.io/docs/authentication-security#limits).
1147
- *
1148
- *
1149
- * @param {OAuthProvider} provider
1150
- * @param {string} success
1151
- * @param {string} failure
1152
- * @param {string[]} scopes
1153
- * @throws {AppwriteException}
1154
- * @returns {void|string}
1155
- */
1156
- createOAuth2Session(provider, success, failure, scopes) {
1306
+ createOAuth2Session(paramsOrFirst, ...rest) {
1307
+ let params;
1308
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'provider' in paramsOrFirst)) {
1309
+ params = (paramsOrFirst || {});
1310
+ }
1311
+ else {
1312
+ params = {
1313
+ provider: paramsOrFirst,
1314
+ success: rest[0],
1315
+ failure: rest[1],
1316
+ scopes: rest[2]
1317
+ };
1318
+ }
1319
+ const provider = params.provider;
1320
+ const success = params.success;
1321
+ const failure = params.failure;
1322
+ const scopes = params.scopes;
1157
1323
  if (typeof provider === 'undefined') {
1158
1324
  throw new AppwriteException('Missing required parameter: "provider"');
1159
1325
  }
@@ -1175,17 +1341,19 @@ class Account extends Service {
1175
1341
  }
1176
1342
  return uri;
1177
1343
  }
1178
- /**
1179
- * Use this endpoint to create a session from token. Provide the **userId**
1180
- * and **secret** parameters from the successful response of authentication
1181
- * flows initiated by token creation. For example, magic URL and phone login.
1182
- *
1183
- * @param {string} userId
1184
- * @param {string} secret
1185
- * @throws {AppwriteException}
1186
- * @returns {Promise}
1187
- */
1188
- updatePhoneSession(userId, secret) {
1344
+ updatePhoneSession(paramsOrFirst, ...rest) {
1345
+ let params;
1346
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
1347
+ params = (paramsOrFirst || {});
1348
+ }
1349
+ else {
1350
+ params = {
1351
+ userId: paramsOrFirst,
1352
+ secret: rest[0]
1353
+ };
1354
+ }
1355
+ const userId = params.userId;
1356
+ const secret = params.secret;
1189
1357
  if (typeof userId === 'undefined') {
1190
1358
  throw new AppwriteException('Missing required parameter: "userId"');
1191
1359
  }
@@ -1205,17 +1373,19 @@ class Account extends Service {
1205
1373
  'content-type': 'application/json',
1206
1374
  }, payload);
1207
1375
  }
1208
- /**
1209
- * Use this endpoint to create a session from token. Provide the **userId**
1210
- * and **secret** parameters from the successful response of authentication
1211
- * flows initiated by token creation. For example, magic URL and phone login.
1212
- *
1213
- * @param {string} userId
1214
- * @param {string} secret
1215
- * @throws {AppwriteException}
1216
- * @returns {Promise}
1217
- */
1218
- createSession(userId, secret) {
1376
+ createSession(paramsOrFirst, ...rest) {
1377
+ let params;
1378
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
1379
+ params = (paramsOrFirst || {});
1380
+ }
1381
+ else {
1382
+ params = {
1383
+ userId: paramsOrFirst,
1384
+ secret: rest[0]
1385
+ };
1386
+ }
1387
+ const userId = params.userId;
1388
+ const secret = params.secret;
1219
1389
  if (typeof userId === 'undefined') {
1220
1390
  throw new AppwriteException('Missing required parameter: "userId"');
1221
1391
  }
@@ -1235,15 +1405,17 @@ class Account extends Service {
1235
1405
  'content-type': 'application/json',
1236
1406
  }, payload);
1237
1407
  }
1238
- /**
1239
- * Use this endpoint to get a logged in user's session using a Session ID.
1240
- * Inputting 'current' will return the current session being used.
1241
- *
1242
- * @param {string} sessionId
1243
- * @throws {AppwriteException}
1244
- * @returns {Promise}
1245
- */
1246
- getSession(sessionId) {
1408
+ getSession(paramsOrFirst) {
1409
+ let params;
1410
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
1411
+ params = (paramsOrFirst || {});
1412
+ }
1413
+ else {
1414
+ params = {
1415
+ sessionId: paramsOrFirst
1416
+ };
1417
+ }
1418
+ const sessionId = params.sessionId;
1247
1419
  if (typeof sessionId === 'undefined') {
1248
1420
  throw new AppwriteException('Missing required parameter: "sessionId"');
1249
1421
  }
@@ -1252,16 +1424,17 @@ class Account extends Service {
1252
1424
  const uri = new URL(this.client.config.endpoint + apiPath);
1253
1425
  return this.client.call('get', uri, {}, payload);
1254
1426
  }
1255
- /**
1256
- * Use this endpoint to extend a session's length. Extending a session is
1257
- * useful when session expiry is short. If the session was created using an
1258
- * OAuth provider, this endpoint refreshes the access token from the provider.
1259
- *
1260
- * @param {string} sessionId
1261
- * @throws {AppwriteException}
1262
- * @returns {Promise}
1263
- */
1264
- updateSession(sessionId) {
1427
+ updateSession(paramsOrFirst) {
1428
+ let params;
1429
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
1430
+ params = (paramsOrFirst || {});
1431
+ }
1432
+ else {
1433
+ params = {
1434
+ sessionId: paramsOrFirst
1435
+ };
1436
+ }
1437
+ const sessionId = params.sessionId;
1265
1438
  if (typeof sessionId === 'undefined') {
1266
1439
  throw new AppwriteException('Missing required parameter: "sessionId"');
1267
1440
  }
@@ -1272,18 +1445,17 @@ class Account extends Service {
1272
1445
  'content-type': 'application/json',
1273
1446
  }, payload);
1274
1447
  }
1275
- /**
1276
- * Logout the user. Use 'current' as the session ID to logout on this device,
1277
- * use a session ID to logout on another device. If you're looking to logout
1278
- * the user on all devices, use [Delete
1279
- * Sessions](https://appwrite.io/docs/references/cloud/client-web/account#deleteSessions)
1280
- * instead.
1281
- *
1282
- * @param {string} sessionId
1283
- * @throws {AppwriteException}
1284
- * @returns {Promise}
1285
- */
1286
- deleteSession(sessionId) {
1448
+ deleteSession(paramsOrFirst) {
1449
+ let params;
1450
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
1451
+ params = (paramsOrFirst || {});
1452
+ }
1453
+ else {
1454
+ params = {
1455
+ sessionId: paramsOrFirst
1456
+ };
1457
+ }
1458
+ const sessionId = params.sessionId;
1287
1459
  if (typeof sessionId === 'undefined') {
1288
1460
  throw new AppwriteException('Missing required parameter: "sessionId"');
1289
1461
  }
@@ -1295,13 +1467,11 @@ class Account extends Service {
1295
1467
  }, payload);
1296
1468
  }
1297
1469
  /**
1298
- * Block the currently logged in user account. Behind the scene, the user
1299
- * record is not deleted but permanently blocked from any access. To
1300
- * completely delete a user, use the Users API instead.
1470
+ * Block the currently logged in user account. Behind the scene, the user record is not deleted but permanently blocked from any access. To completely delete a user, use the Users API instead.
1301
1471
  *
1302
1472
  * @throws {AppwriteException}
1303
1473
  * @returns {Promise}
1304
- */
1474
+ */
1305
1475
  updateStatus() {
1306
1476
  const apiPath = '/account/status';
1307
1477
  const payload = {};
@@ -1310,20 +1480,21 @@ class Account extends Service {
1310
1480
  'content-type': 'application/json',
1311
1481
  }, payload);
1312
1482
  }
1313
- /**
1314
- * Use this endpoint to register a device for push notifications. Provide a
1315
- * target ID (custom or generated using ID.unique()), a device identifier
1316
- * (usually a device token), and optionally specify which provider should send
1317
- * notifications to this target. The target is automatically linked to the
1318
- * current session and includes device information like brand and model.
1319
- *
1320
- * @param {string} targetId
1321
- * @param {string} identifier
1322
- * @param {string} providerId
1323
- * @throws {AppwriteException}
1324
- * @returns {Promise}
1325
- */
1326
- createPushTarget(targetId, identifier, providerId) {
1483
+ createPushTarget(paramsOrFirst, ...rest) {
1484
+ let params;
1485
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
1486
+ params = (paramsOrFirst || {});
1487
+ }
1488
+ else {
1489
+ params = {
1490
+ targetId: paramsOrFirst,
1491
+ identifier: rest[0],
1492
+ providerId: rest[1]
1493
+ };
1494
+ }
1495
+ const targetId = params.targetId;
1496
+ const identifier = params.identifier;
1497
+ const providerId = params.providerId;
1327
1498
  if (typeof targetId === 'undefined') {
1328
1499
  throw new AppwriteException('Missing required parameter: "targetId"');
1329
1500
  }
@@ -1346,19 +1517,19 @@ class Account extends Service {
1346
1517
  'content-type': 'application/json',
1347
1518
  }, payload);
1348
1519
  }
1349
- /**
1350
- * Update the currently logged in user's push notification target. You can
1351
- * modify the target's identifier (device token) and provider ID (token,
1352
- * email, phone etc.). The target must exist and belong to the current user.
1353
- * If you change the provider ID, notifications will be sent through the new
1354
- * messaging provider instead.
1355
- *
1356
- * @param {string} targetId
1357
- * @param {string} identifier
1358
- * @throws {AppwriteException}
1359
- * @returns {Promise}
1360
- */
1361
- updatePushTarget(targetId, identifier) {
1520
+ updatePushTarget(paramsOrFirst, ...rest) {
1521
+ let params;
1522
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
1523
+ params = (paramsOrFirst || {});
1524
+ }
1525
+ else {
1526
+ params = {
1527
+ targetId: paramsOrFirst,
1528
+ identifier: rest[0]
1529
+ };
1530
+ }
1531
+ const targetId = params.targetId;
1532
+ const identifier = params.identifier;
1362
1533
  if (typeof targetId === 'undefined') {
1363
1534
  throw new AppwriteException('Missing required parameter: "targetId"');
1364
1535
  }
@@ -1375,16 +1546,17 @@ class Account extends Service {
1375
1546
  'content-type': 'application/json',
1376
1547
  }, payload);
1377
1548
  }
1378
- /**
1379
- * Delete a push notification target for the currently logged in user. After
1380
- * deletion, the device will no longer receive push notifications. The target
1381
- * must exist and belong to the current user.
1382
- *
1383
- * @param {string} targetId
1384
- * @throws {AppwriteException}
1385
- * @returns {Promise}
1386
- */
1387
- deletePushTarget(targetId) {
1549
+ deletePushTarget(paramsOrFirst) {
1550
+ let params;
1551
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
1552
+ params = (paramsOrFirst || {});
1553
+ }
1554
+ else {
1555
+ params = {
1556
+ targetId: paramsOrFirst
1557
+ };
1558
+ }
1559
+ const targetId = params.targetId;
1388
1560
  if (typeof targetId === 'undefined') {
1389
1561
  throw new AppwriteException('Missing required parameter: "targetId"');
1390
1562
  }
@@ -1395,25 +1567,21 @@ class Account extends Service {
1395
1567
  'content-type': 'application/json',
1396
1568
  }, payload);
1397
1569
  }
1398
- /**
1399
- * Sends the user an email with a secret key for creating a session. If the
1400
- * provided user ID has not be registered, a new user will be created. Use the
1401
- * returned user ID and secret and submit a request to the [POST
1402
- * /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession)
1403
- * endpoint to complete the login process. The secret sent to the user's email
1404
- * is valid for 15 minutes.
1405
- *
1406
- * A user is limited to 10 active sessions at a time by default. [Learn more
1407
- * about session
1408
- * limits](https://appwrite.io/docs/authentication-security#limits).
1409
- *
1410
- * @param {string} userId
1411
- * @param {string} email
1412
- * @param {boolean} phrase
1413
- * @throws {AppwriteException}
1414
- * @returns {Promise}
1415
- */
1416
- createEmailToken(userId, email, phrase) {
1570
+ createEmailToken(paramsOrFirst, ...rest) {
1571
+ let params;
1572
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
1573
+ params = (paramsOrFirst || {});
1574
+ }
1575
+ else {
1576
+ params = {
1577
+ userId: paramsOrFirst,
1578
+ email: rest[0],
1579
+ phrase: rest[1]
1580
+ };
1581
+ }
1582
+ const userId = params.userId;
1583
+ const email = params.email;
1584
+ const phrase = params.phrase;
1417
1585
  if (typeof userId === 'undefined') {
1418
1586
  throw new AppwriteException('Missing required parameter: "userId"');
1419
1587
  }
@@ -1436,30 +1604,23 @@ class Account extends Service {
1436
1604
  'content-type': 'application/json',
1437
1605
  }, payload);
1438
1606
  }
1439
- /**
1440
- * Sends the user an email with a secret key for creating a session. If the
1441
- * provided user ID has not been registered, a new user will be created. When
1442
- * the user clicks the link in the email, the user is redirected back to the
1443
- * URL you provided with the secret key and userId values attached to the URL
1444
- * query string. Use the query string parameters to submit a request to the
1445
- * [POST
1446
- * /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession)
1447
- * endpoint to complete the login process. The link sent to the user's email
1448
- * address is valid for 1 hour.
1449
- *
1450
- * A user is limited to 10 active sessions at a time by default. [Learn more
1451
- * about session
1452
- * limits](https://appwrite.io/docs/authentication-security#limits).
1453
- *
1454
- *
1455
- * @param {string} userId
1456
- * @param {string} email
1457
- * @param {string} url
1458
- * @param {boolean} phrase
1459
- * @throws {AppwriteException}
1460
- * @returns {Promise}
1461
- */
1462
- createMagicURLToken(userId, email, url, phrase) {
1607
+ createMagicURLToken(paramsOrFirst, ...rest) {
1608
+ let params;
1609
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
1610
+ params = (paramsOrFirst || {});
1611
+ }
1612
+ else {
1613
+ params = {
1614
+ userId: paramsOrFirst,
1615
+ email: rest[0],
1616
+ url: rest[1],
1617
+ phrase: rest[2]
1618
+ };
1619
+ }
1620
+ const userId = params.userId;
1621
+ const email = params.email;
1622
+ const url = params.url;
1623
+ const phrase = params.phrase;
1463
1624
  if (typeof userId === 'undefined') {
1464
1625
  throw new AppwriteException('Missing required parameter: "userId"');
1465
1626
  }
@@ -1485,30 +1646,23 @@ class Account extends Service {
1485
1646
  'content-type': 'application/json',
1486
1647
  }, payload);
1487
1648
  }
1488
- /**
1489
- * Allow the user to login to their account using the OAuth2 provider of their
1490
- * choice. Each OAuth2 provider should be enabled from the Appwrite console
1491
- * first. Use the success and failure arguments to provide a redirect URL's
1492
- * back to your app when login is completed.
1493
- *
1494
- * If authentication succeeds, `userId` and `secret` of a token will be
1495
- * appended to the success URL as query parameters. These can be used to
1496
- * create a new session using the [Create
1497
- * session](https://appwrite.io/docs/references/cloud/client-web/account#createSession)
1498
- * endpoint.
1499
- *
1500
- * A user is limited to 10 active sessions at a time by default. [Learn more
1501
- * about session
1502
- * limits](https://appwrite.io/docs/authentication-security#limits).
1503
- *
1504
- * @param {OAuthProvider} provider
1505
- * @param {string} success
1506
- * @param {string} failure
1507
- * @param {string[]} scopes
1508
- * @throws {AppwriteException}
1509
- * @returns {void|string}
1510
- */
1511
- createOAuth2Token(provider, success, failure, scopes) {
1649
+ createOAuth2Token(paramsOrFirst, ...rest) {
1650
+ let params;
1651
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'provider' in paramsOrFirst)) {
1652
+ params = (paramsOrFirst || {});
1653
+ }
1654
+ else {
1655
+ params = {
1656
+ provider: paramsOrFirst,
1657
+ success: rest[0],
1658
+ failure: rest[1],
1659
+ scopes: rest[2]
1660
+ };
1661
+ }
1662
+ const provider = params.provider;
1663
+ const success = params.success;
1664
+ const failure = params.failure;
1665
+ const scopes = params.scopes;
1512
1666
  if (typeof provider === 'undefined') {
1513
1667
  throw new AppwriteException('Missing required parameter: "provider"');
1514
1668
  }
@@ -1530,24 +1684,19 @@ class Account extends Service {
1530
1684
  }
1531
1685
  return uri;
1532
1686
  }
1533
- /**
1534
- * Sends the user an SMS with a secret key for creating a session. If the
1535
- * provided user ID has not be registered, a new user will be created. Use the
1536
- * returned user ID and secret and submit a request to the [POST
1537
- * /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession)
1538
- * endpoint to complete the login process. The secret sent to the user's phone
1539
- * is valid for 15 minutes.
1540
- *
1541
- * A user is limited to 10 active sessions at a time by default. [Learn more
1542
- * about session
1543
- * limits](https://appwrite.io/docs/authentication-security#limits).
1544
- *
1545
- * @param {string} userId
1546
- * @param {string} phone
1547
- * @throws {AppwriteException}
1548
- * @returns {Promise}
1549
- */
1550
- createPhoneToken(userId, phone) {
1687
+ createPhoneToken(paramsOrFirst, ...rest) {
1688
+ let params;
1689
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
1690
+ params = (paramsOrFirst || {});
1691
+ }
1692
+ else {
1693
+ params = {
1694
+ userId: paramsOrFirst,
1695
+ phone: rest[0]
1696
+ };
1697
+ }
1698
+ const userId = params.userId;
1699
+ const phone = params.phone;
1551
1700
  if (typeof userId === 'undefined') {
1552
1701
  throw new AppwriteException('Missing required parameter: "userId"');
1553
1702
  }
@@ -1567,28 +1716,17 @@ class Account extends Service {
1567
1716
  'content-type': 'application/json',
1568
1717
  }, payload);
1569
1718
  }
1570
- /**
1571
- * Use this endpoint to send a verification message to your user email address
1572
- * to confirm they are the valid owners of that address. Both the **userId**
1573
- * and **secret** arguments will be passed as query parameters to the URL you
1574
- * have provided to be attached to the verification email. The provided URL
1575
- * should redirect the user back to your app and allow you to complete the
1576
- * verification process by verifying both the **userId** and **secret**
1577
- * parameters. Learn more about how to [complete the verification
1578
- * process](https://appwrite.io/docs/references/cloud/client-web/account#updateVerification).
1579
- * The verification link sent to the user's email address is valid for 7 days.
1580
- *
1581
- * Please note that in order to avoid a [Redirect
1582
- * Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md),
1583
- * the only valid redirect URLs are the ones from domains you have set when
1584
- * adding your platforms in the console interface.
1585
- *
1586
- *
1587
- * @param {string} url
1588
- * @throws {AppwriteException}
1589
- * @returns {Promise}
1590
- */
1591
- createVerification(url) {
1719
+ createVerification(paramsOrFirst) {
1720
+ let params;
1721
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
1722
+ params = (paramsOrFirst || {});
1723
+ }
1724
+ else {
1725
+ params = {
1726
+ url: paramsOrFirst
1727
+ };
1728
+ }
1729
+ const url = params.url;
1592
1730
  if (typeof url === 'undefined') {
1593
1731
  throw new AppwriteException('Missing required parameter: "url"');
1594
1732
  }
@@ -1602,18 +1740,19 @@ class Account extends Service {
1602
1740
  'content-type': 'application/json',
1603
1741
  }, payload);
1604
1742
  }
1605
- /**
1606
- * Use this endpoint to complete the user email verification process. Use both
1607
- * the **userId** and **secret** parameters that were attached to your app URL
1608
- * to verify the user email ownership. If confirmed this route will return a
1609
- * 200 status code.
1610
- *
1611
- * @param {string} userId
1612
- * @param {string} secret
1613
- * @throws {AppwriteException}
1614
- * @returns {Promise}
1615
- */
1616
- updateVerification(userId, secret) {
1743
+ updateVerification(paramsOrFirst, ...rest) {
1744
+ let params;
1745
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
1746
+ params = (paramsOrFirst || {});
1747
+ }
1748
+ else {
1749
+ params = {
1750
+ userId: paramsOrFirst,
1751
+ secret: rest[0]
1752
+ };
1753
+ }
1754
+ const userId = params.userId;
1755
+ const secret = params.secret;
1617
1756
  if (typeof userId === 'undefined') {
1618
1757
  throw new AppwriteException('Missing required parameter: "userId"');
1619
1758
  }
@@ -1634,18 +1773,11 @@ class Account extends Service {
1634
1773
  }, payload);
1635
1774
  }
1636
1775
  /**
1637
- * Use this endpoint to send a verification SMS to the currently logged in
1638
- * user. This endpoint is meant for use after updating a user's phone number
1639
- * using the
1640
- * [accountUpdatePhone](https://appwrite.io/docs/references/cloud/client-web/account#updatePhone)
1641
- * endpoint. Learn more about how to [complete the verification
1642
- * process](https://appwrite.io/docs/references/cloud/client-web/account#updatePhoneVerification).
1643
- * The verification code sent to the user's phone number is valid for 15
1644
- * minutes.
1776
+ * Use this endpoint to send a verification SMS to the currently logged in user. This endpoint is meant for use after updating a user's phone number using the [accountUpdatePhone](https://appwrite.io/docs/references/cloud/client-web/account#updatePhone) endpoint. Learn more about how to [complete the verification process](https://appwrite.io/docs/references/cloud/client-web/account#updatePhoneVerification). The verification code sent to the user's phone number is valid for 15 minutes.
1645
1777
  *
1646
1778
  * @throws {AppwriteException}
1647
1779
  * @returns {Promise}
1648
- */
1780
+ */
1649
1781
  createPhoneVerification() {
1650
1782
  const apiPath = '/account/verification/phone';
1651
1783
  const payload = {};
@@ -1654,18 +1786,19 @@ class Account extends Service {
1654
1786
  'content-type': 'application/json',
1655
1787
  }, payload);
1656
1788
  }
1657
- /**
1658
- * Use this endpoint to complete the user phone verification process. Use the
1659
- * **userId** and **secret** that were sent to your user's phone number to
1660
- * verify the user email ownership. If confirmed this route will return a 200
1661
- * status code.
1662
- *
1663
- * @param {string} userId
1664
- * @param {string} secret
1665
- * @throws {AppwriteException}
1666
- * @returns {Promise}
1667
- */
1668
- updatePhoneVerification(userId, secret) {
1789
+ updatePhoneVerification(paramsOrFirst, ...rest) {
1790
+ let params;
1791
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
1792
+ params = (paramsOrFirst || {});
1793
+ }
1794
+ else {
1795
+ params = {
1796
+ userId: paramsOrFirst,
1797
+ secret: rest[0]
1798
+ };
1799
+ }
1800
+ const userId = params.userId;
1801
+ const secret = params.secret;
1669
1802
  if (typeof userId === 'undefined') {
1670
1803
  throw new AppwriteException('Missing required parameter: "userId"');
1671
1804
  }
@@ -1691,26 +1824,23 @@ class Avatars extends Service {
1691
1824
  constructor(client) {
1692
1825
  super(client);
1693
1826
  }
1694
- /**
1695
- * You can use this endpoint to show different browser icons to your users.
1696
- * The code argument receives the browser code as it appears in your user [GET
1697
- * /account/sessions](https://appwrite.io/docs/references/cloud/client-web/account#getSessions)
1698
- * endpoint. Use width, height and quality arguments to change the output
1699
- * settings.
1700
- *
1701
- * When one dimension is specified and the other is 0, the image is scaled
1702
- * with preserved aspect ratio. If both dimensions are 0, the API provides an
1703
- * image at source quality. If dimensions are not specified, the default size
1704
- * of image returned is 100x100px.
1705
- *
1706
- * @param {Browser} code
1707
- * @param {number} width
1708
- * @param {number} height
1709
- * @param {number} quality
1710
- * @throws {AppwriteException}
1711
- * @returns {ArrayBuffer}
1712
- */
1713
- getBrowser(code, width, height, quality) {
1827
+ getBrowser(paramsOrFirst, ...rest) {
1828
+ let params;
1829
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'code' in paramsOrFirst)) {
1830
+ params = (paramsOrFirst || {});
1831
+ }
1832
+ else {
1833
+ params = {
1834
+ code: paramsOrFirst,
1835
+ width: rest[0],
1836
+ height: rest[1],
1837
+ quality: rest[2]
1838
+ };
1839
+ }
1840
+ const code = params.code;
1841
+ const width = params.width;
1842
+ const height = params.height;
1843
+ const quality = params.quality;
1714
1844
  if (typeof code === 'undefined') {
1715
1845
  throw new AppwriteException('Missing required parameter: "code"');
1716
1846
  }
@@ -1732,25 +1862,23 @@ class Avatars extends Service {
1732
1862
  }
1733
1863
  return this.client.call('get', uri, {}, payload, 'arrayBuffer');
1734
1864
  }
1735
- /**
1736
- * The credit card endpoint will return you the icon of the credit card
1737
- * provider you need. Use width, height and quality arguments to change the
1738
- * output settings.
1739
- *
1740
- * When one dimension is specified and the other is 0, the image is scaled
1741
- * with preserved aspect ratio. If both dimensions are 0, the API provides an
1742
- * image at source quality. If dimensions are not specified, the default size
1743
- * of image returned is 100x100px.
1744
- *
1745
- *
1746
- * @param {CreditCard} code
1747
- * @param {number} width
1748
- * @param {number} height
1749
- * @param {number} quality
1750
- * @throws {AppwriteException}
1751
- * @returns {ArrayBuffer}
1752
- */
1753
- getCreditCard(code, width, height, quality) {
1865
+ getCreditCard(paramsOrFirst, ...rest) {
1866
+ let params;
1867
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'code' in paramsOrFirst)) {
1868
+ params = (paramsOrFirst || {});
1869
+ }
1870
+ else {
1871
+ params = {
1872
+ code: paramsOrFirst,
1873
+ width: rest[0],
1874
+ height: rest[1],
1875
+ quality: rest[2]
1876
+ };
1877
+ }
1878
+ const code = params.code;
1879
+ const width = params.width;
1880
+ const height = params.height;
1881
+ const quality = params.quality;
1754
1882
  if (typeof code === 'undefined') {
1755
1883
  throw new AppwriteException('Missing required parameter: "code"');
1756
1884
  }
@@ -1772,17 +1900,17 @@ class Avatars extends Service {
1772
1900
  }
1773
1901
  return this.client.call('get', uri, {}, payload, 'arrayBuffer');
1774
1902
  }
1775
- /**
1776
- * Use this endpoint to fetch the favorite icon (AKA favicon) of any remote
1777
- * website URL.
1778
- *
1779
- * This endpoint does not follow HTTP redirects.
1780
- *
1781
- * @param {string} url
1782
- * @throws {AppwriteException}
1783
- * @returns {ArrayBuffer}
1784
- */
1785
- getFavicon(url) {
1903
+ getFavicon(paramsOrFirst) {
1904
+ let params;
1905
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
1906
+ params = (paramsOrFirst || {});
1907
+ }
1908
+ else {
1909
+ params = {
1910
+ url: paramsOrFirst
1911
+ };
1912
+ }
1913
+ const url = params.url;
1786
1914
  if (typeof url === 'undefined') {
1787
1915
  throw new AppwriteException('Missing required parameter: "url"');
1788
1916
  }
@@ -1798,26 +1926,23 @@ class Avatars extends Service {
1798
1926
  }
1799
1927
  return this.client.call('get', uri, {}, payload, 'arrayBuffer');
1800
1928
  }
1801
- /**
1802
- * You can use this endpoint to show different country flags icons to your
1803
- * users. The code argument receives the 2 letter country code. Use width,
1804
- * height and quality arguments to change the output settings. Country codes
1805
- * follow the [ISO 3166-1](https://en.wikipedia.org/wiki/ISO_3166-1) standard.
1806
- *
1807
- * When one dimension is specified and the other is 0, the image is scaled
1808
- * with preserved aspect ratio. If both dimensions are 0, the API provides an
1809
- * image at source quality. If dimensions are not specified, the default size
1810
- * of image returned is 100x100px.
1811
- *
1812
- *
1813
- * @param {Flag} code
1814
- * @param {number} width
1815
- * @param {number} height
1816
- * @param {number} quality
1817
- * @throws {AppwriteException}
1818
- * @returns {ArrayBuffer}
1819
- */
1820
- getFlag(code, width, height, quality) {
1929
+ getFlag(paramsOrFirst, ...rest) {
1930
+ let params;
1931
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'code' in paramsOrFirst)) {
1932
+ params = (paramsOrFirst || {});
1933
+ }
1934
+ else {
1935
+ params = {
1936
+ code: paramsOrFirst,
1937
+ width: rest[0],
1938
+ height: rest[1],
1939
+ quality: rest[2]
1940
+ };
1941
+ }
1942
+ const code = params.code;
1943
+ const width = params.width;
1944
+ const height = params.height;
1945
+ const quality = params.quality;
1821
1946
  if (typeof code === 'undefined') {
1822
1947
  throw new AppwriteException('Missing required parameter: "code"');
1823
1948
  }
@@ -1839,26 +1964,21 @@ class Avatars extends Service {
1839
1964
  }
1840
1965
  return this.client.call('get', uri, {}, payload, 'arrayBuffer');
1841
1966
  }
1842
- /**
1843
- * Use this endpoint to fetch a remote image URL and crop it to any image size
1844
- * you want. This endpoint is very useful if you need to crop and display
1845
- * remote images in your app or in case you want to make sure a 3rd party
1846
- * image is properly served using a TLS protocol.
1847
- *
1848
- * When one dimension is specified and the other is 0, the image is scaled
1849
- * with preserved aspect ratio. If both dimensions are 0, the API provides an
1850
- * image at source quality. If dimensions are not specified, the default size
1851
- * of image returned is 400x400px.
1852
- *
1853
- * This endpoint does not follow HTTP redirects.
1854
- *
1855
- * @param {string} url
1856
- * @param {number} width
1857
- * @param {number} height
1858
- * @throws {AppwriteException}
1859
- * @returns {ArrayBuffer}
1860
- */
1861
- getImage(url, width, height) {
1967
+ getImage(paramsOrFirst, ...rest) {
1968
+ let params;
1969
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
1970
+ params = (paramsOrFirst || {});
1971
+ }
1972
+ else {
1973
+ params = {
1974
+ url: paramsOrFirst,
1975
+ width: rest[0],
1976
+ height: rest[1]
1977
+ };
1978
+ }
1979
+ const url = params.url;
1980
+ const width = params.width;
1981
+ const height = params.height;
1862
1982
  if (typeof url === 'undefined') {
1863
1983
  throw new AppwriteException('Missing required parameter: "url"');
1864
1984
  }
@@ -1880,32 +2000,23 @@ class Avatars extends Service {
1880
2000
  }
1881
2001
  return this.client.call('get', uri, {}, payload, 'arrayBuffer');
1882
2002
  }
1883
- /**
1884
- * Use this endpoint to show your user initials avatar icon on your website or
1885
- * app. By default, this route will try to print your logged-in user name or
1886
- * email initials. You can also overwrite the user name if you pass the 'name'
1887
- * parameter. If no name is given and no user is logged, an empty avatar will
1888
- * be returned.
1889
- *
1890
- * You can use the color and background params to change the avatar colors. By
1891
- * default, a random theme will be selected. The random theme will persist for
1892
- * the user's initials when reloading the same theme will always return for
1893
- * the same initials.
1894
- *
1895
- * When one dimension is specified and the other is 0, the image is scaled
1896
- * with preserved aspect ratio. If both dimensions are 0, the API provides an
1897
- * image at source quality. If dimensions are not specified, the default size
1898
- * of image returned is 100x100px.
1899
- *
1900
- *
1901
- * @param {string} name
1902
- * @param {number} width
1903
- * @param {number} height
1904
- * @param {string} background
1905
- * @throws {AppwriteException}
1906
- * @returns {ArrayBuffer}
1907
- */
1908
- getInitials(name, width, height, background) {
2003
+ getInitials(paramsOrFirst, ...rest) {
2004
+ let params;
2005
+ if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
2006
+ params = (paramsOrFirst || {});
2007
+ }
2008
+ else {
2009
+ params = {
2010
+ name: paramsOrFirst,
2011
+ width: rest[0],
2012
+ height: rest[1],
2013
+ background: rest[2]
2014
+ };
2015
+ }
2016
+ const name = params.name;
2017
+ const width = params.width;
2018
+ const height = params.height;
2019
+ const background = params.background;
1909
2020
  const apiPath = '/avatars/initials';
1910
2021
  const payload = {};
1911
2022
  if (typeof name !== 'undefined') {
@@ -1927,19 +2038,23 @@ class Avatars extends Service {
1927
2038
  }
1928
2039
  return this.client.call('get', uri, {}, payload, 'arrayBuffer');
1929
2040
  }
1930
- /**
1931
- * Converts a given plain text to a QR code image. You can use the query
1932
- * parameters to change the size and style of the resulting image.
1933
- *
1934
- *
1935
- * @param {string} text
1936
- * @param {number} size
1937
- * @param {number} margin
1938
- * @param {boolean} download
1939
- * @throws {AppwriteException}
1940
- * @returns {ArrayBuffer}
1941
- */
1942
- getQR(text, size, margin, download) {
2041
+ getQR(paramsOrFirst, ...rest) {
2042
+ let params;
2043
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
2044
+ params = (paramsOrFirst || {});
2045
+ }
2046
+ else {
2047
+ params = {
2048
+ text: paramsOrFirst,
2049
+ size: rest[0],
2050
+ margin: rest[1],
2051
+ download: rest[2]
2052
+ };
2053
+ }
2054
+ const text = params.text;
2055
+ const size = params.size;
2056
+ const margin = params.margin;
2057
+ const download = params.download;
1943
2058
  if (typeof text === 'undefined') {
1944
2059
  throw new AppwriteException('Missing required parameter: "text"');
1945
2060
  }
@@ -2225,17 +2340,21 @@ class Databases extends Service {
2225
2340
  constructor(client) {
2226
2341
  super(client);
2227
2342
  }
2228
- /**
2229
- * Get a list of all the user's documents in a given collection. You can use
2230
- * the query params to filter your results.
2231
- *
2232
- * @param {string} databaseId
2233
- * @param {string} collectionId
2234
- * @param {string[]} queries
2235
- * @throws {AppwriteException}
2236
- * @returns {Promise}
2237
- */
2238
- listDocuments(databaseId, collectionId, queries) {
2343
+ listDocuments(paramsOrFirst, ...rest) {
2344
+ let params;
2345
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
2346
+ params = (paramsOrFirst || {});
2347
+ }
2348
+ else {
2349
+ params = {
2350
+ databaseId: paramsOrFirst,
2351
+ collectionId: rest[0],
2352
+ queries: rest[1]
2353
+ };
2354
+ }
2355
+ const databaseId = params.databaseId;
2356
+ const collectionId = params.collectionId;
2357
+ const queries = params.queries;
2239
2358
  if (typeof databaseId === 'undefined') {
2240
2359
  throw new AppwriteException('Missing required parameter: "databaseId"');
2241
2360
  }
@@ -2250,21 +2369,25 @@ class Databases extends Service {
2250
2369
  const uri = new URL(this.client.config.endpoint + apiPath);
2251
2370
  return this.client.call('get', uri, {}, payload);
2252
2371
  }
2253
- /**
2254
- * Create a new Document. Before using this route, you should create a new
2255
- * collection resource using either a [server
2256
- * integration](https://appwrite.io/docs/server/databases#databasesCreateCollection)
2257
- * API or directly from your database console.
2258
- *
2259
- * @param {string} databaseId
2260
- * @param {string} collectionId
2261
- * @param {string} documentId
2262
- * @param {object} data
2263
- * @param {string[]} permissions
2264
- * @throws {AppwriteException}
2265
- * @returns {Promise}
2266
- */
2267
- createDocument(databaseId, collectionId, documentId, data, permissions) {
2372
+ createDocument(paramsOrFirst, ...rest) {
2373
+ let params;
2374
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
2375
+ params = (paramsOrFirst || {});
2376
+ }
2377
+ else {
2378
+ params = {
2379
+ databaseId: paramsOrFirst,
2380
+ collectionId: rest[0],
2381
+ documentId: rest[1],
2382
+ data: rest[2],
2383
+ permissions: rest[3]
2384
+ };
2385
+ }
2386
+ const databaseId = params.databaseId;
2387
+ const collectionId = params.collectionId;
2388
+ const documentId = params.documentId;
2389
+ const data = params.data;
2390
+ const permissions = params.permissions;
2268
2391
  if (typeof databaseId === 'undefined') {
2269
2392
  throw new AppwriteException('Missing required parameter: "databaseId"');
2270
2393
  }
@@ -2277,6 +2400,9 @@ class Databases extends Service {
2277
2400
  if (typeof data === 'undefined') {
2278
2401
  throw new AppwriteException('Missing required parameter: "data"');
2279
2402
  }
2403
+ data === null || data === void 0 ? true : delete data.$sequence;
2404
+ data === null || data === void 0 ? true : delete data.$collectionId;
2405
+ data === null || data === void 0 ? true : delete data.$databaseId;
2280
2406
  const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
2281
2407
  const payload = {};
2282
2408
  if (typeof documentId !== 'undefined') {
@@ -2293,18 +2419,23 @@ class Databases extends Service {
2293
2419
  'content-type': 'application/json',
2294
2420
  }, payload);
2295
2421
  }
2296
- /**
2297
- * Get a document by its unique ID. This endpoint response returns a JSON
2298
- * object with the document data.
2299
- *
2300
- * @param {string} databaseId
2301
- * @param {string} collectionId
2302
- * @param {string} documentId
2303
- * @param {string[]} queries
2304
- * @throws {AppwriteException}
2305
- * @returns {Promise}
2306
- */
2307
- getDocument(databaseId, collectionId, documentId, queries) {
2422
+ getDocument(paramsOrFirst, ...rest) {
2423
+ let params;
2424
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
2425
+ params = (paramsOrFirst || {});
2426
+ }
2427
+ else {
2428
+ params = {
2429
+ databaseId: paramsOrFirst,
2430
+ collectionId: rest[0],
2431
+ documentId: rest[1],
2432
+ queries: rest[2]
2433
+ };
2434
+ }
2435
+ const databaseId = params.databaseId;
2436
+ const collectionId = params.collectionId;
2437
+ const documentId = params.documentId;
2438
+ const queries = params.queries;
2308
2439
  if (typeof databaseId === 'undefined') {
2309
2440
  throw new AppwriteException('Missing required parameter: "databaseId"');
2310
2441
  }
@@ -2322,25 +2453,25 @@ class Databases extends Service {
2322
2453
  const uri = new URL(this.client.config.endpoint + apiPath);
2323
2454
  return this.client.call('get', uri, {}, payload);
2324
2455
  }
2325
- /**
2326
- * **WARNING: Experimental Feature** - This endpoint is experimental and not
2327
- * yet officially supported. It may be subject to breaking changes or removal
2328
- * in future versions.
2329
- *
2330
- * Create or update a Document. Before using this route, you should create a
2331
- * new collection resource using either a [server
2332
- * integration](https://appwrite.io/docs/server/databases#databasesCreateCollection)
2333
- * API or directly from your database console.
2334
- *
2335
- * @param {string} databaseId
2336
- * @param {string} collectionId
2337
- * @param {string} documentId
2338
- * @param {object} data
2339
- * @param {string[]} permissions
2340
- * @throws {AppwriteException}
2341
- * @returns {Promise}
2342
- */
2343
- upsertDocument(databaseId, collectionId, documentId, data, permissions) {
2456
+ upsertDocument(paramsOrFirst, ...rest) {
2457
+ let params;
2458
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
2459
+ params = (paramsOrFirst || {});
2460
+ }
2461
+ else {
2462
+ params = {
2463
+ databaseId: paramsOrFirst,
2464
+ collectionId: rest[0],
2465
+ documentId: rest[1],
2466
+ data: rest[2],
2467
+ permissions: rest[3]
2468
+ };
2469
+ }
2470
+ const databaseId = params.databaseId;
2471
+ const collectionId = params.collectionId;
2472
+ const documentId = params.documentId;
2473
+ const data = params.data;
2474
+ const permissions = params.permissions;
2344
2475
  if (typeof databaseId === 'undefined') {
2345
2476
  throw new AppwriteException('Missing required parameter: "databaseId"');
2346
2477
  }
@@ -2353,6 +2484,9 @@ class Databases extends Service {
2353
2484
  if (typeof data === 'undefined') {
2354
2485
  throw new AppwriteException('Missing required parameter: "data"');
2355
2486
  }
2487
+ data === null || data === void 0 ? true : delete data.$sequence;
2488
+ data === null || data === void 0 ? true : delete data.$collectionId;
2489
+ data === null || data === void 0 ? true : delete data.$databaseId;
2356
2490
  const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId);
2357
2491
  const payload = {};
2358
2492
  if (typeof data !== 'undefined') {
@@ -2366,19 +2500,25 @@ class Databases extends Service {
2366
2500
  'content-type': 'application/json',
2367
2501
  }, payload);
2368
2502
  }
2369
- /**
2370
- * Update a document by its unique ID. Using the patch method you can pass
2371
- * only specific fields that will get updated.
2372
- *
2373
- * @param {string} databaseId
2374
- * @param {string} collectionId
2375
- * @param {string} documentId
2376
- * @param {object} data
2377
- * @param {string[]} permissions
2378
- * @throws {AppwriteException}
2379
- * @returns {Promise}
2380
- */
2381
- updateDocument(databaseId, collectionId, documentId, data, permissions) {
2503
+ updateDocument(paramsOrFirst, ...rest) {
2504
+ let params;
2505
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
2506
+ params = (paramsOrFirst || {});
2507
+ }
2508
+ else {
2509
+ params = {
2510
+ databaseId: paramsOrFirst,
2511
+ collectionId: rest[0],
2512
+ documentId: rest[1],
2513
+ data: rest[2],
2514
+ permissions: rest[3]
2515
+ };
2516
+ }
2517
+ const databaseId = params.databaseId;
2518
+ const collectionId = params.collectionId;
2519
+ const documentId = params.documentId;
2520
+ const data = params.data;
2521
+ const permissions = params.permissions;
2382
2522
  if (typeof databaseId === 'undefined') {
2383
2523
  throw new AppwriteException('Missing required parameter: "databaseId"');
2384
2524
  }
@@ -2388,6 +2528,9 @@ class Databases extends Service {
2388
2528
  if (typeof documentId === 'undefined') {
2389
2529
  throw new AppwriteException('Missing required parameter: "documentId"');
2390
2530
  }
2531
+ data === null || data === void 0 ? true : delete data.$sequence;
2532
+ data === null || data === void 0 ? true : delete data.$collectionId;
2533
+ data === null || data === void 0 ? true : delete data.$databaseId;
2391
2534
  const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId);
2392
2535
  const payload = {};
2393
2536
  if (typeof data !== 'undefined') {
@@ -2401,16 +2544,21 @@ class Databases extends Service {
2401
2544
  'content-type': 'application/json',
2402
2545
  }, payload);
2403
2546
  }
2404
- /**
2405
- * Delete a document by its unique ID.
2406
- *
2407
- * @param {string} databaseId
2408
- * @param {string} collectionId
2409
- * @param {string} documentId
2410
- * @throws {AppwriteException}
2411
- * @returns {Promise}
2412
- */
2413
- deleteDocument(databaseId, collectionId, documentId) {
2547
+ deleteDocument(paramsOrFirst, ...rest) {
2548
+ let params;
2549
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
2550
+ params = (paramsOrFirst || {});
2551
+ }
2552
+ else {
2553
+ params = {
2554
+ databaseId: paramsOrFirst,
2555
+ collectionId: rest[0],
2556
+ documentId: rest[1]
2557
+ };
2558
+ }
2559
+ const databaseId = params.databaseId;
2560
+ const collectionId = params.collectionId;
2561
+ const documentId = params.documentId;
2414
2562
  if (typeof databaseId === 'undefined') {
2415
2563
  throw new AppwriteException('Missing required parameter: "databaseId"');
2416
2564
  }
@@ -2427,22 +2575,117 @@ class Databases extends Service {
2427
2575
  'content-type': 'application/json',
2428
2576
  }, payload);
2429
2577
  }
2578
+ decrementDocumentAttribute(paramsOrFirst, ...rest) {
2579
+ let params;
2580
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
2581
+ params = (paramsOrFirst || {});
2582
+ }
2583
+ else {
2584
+ params = {
2585
+ databaseId: paramsOrFirst,
2586
+ collectionId: rest[0],
2587
+ documentId: rest[1],
2588
+ attribute: rest[2],
2589
+ value: rest[3],
2590
+ min: rest[4]
2591
+ };
2592
+ }
2593
+ const databaseId = params.databaseId;
2594
+ const collectionId = params.collectionId;
2595
+ const documentId = params.documentId;
2596
+ const attribute = params.attribute;
2597
+ const value = params.value;
2598
+ const min = params.min;
2599
+ if (typeof databaseId === 'undefined') {
2600
+ throw new AppwriteException('Missing required parameter: "databaseId"');
2601
+ }
2602
+ if (typeof collectionId === 'undefined') {
2603
+ throw new AppwriteException('Missing required parameter: "collectionId"');
2604
+ }
2605
+ if (typeof documentId === 'undefined') {
2606
+ throw new AppwriteException('Missing required parameter: "documentId"');
2607
+ }
2608
+ if (typeof attribute === 'undefined') {
2609
+ throw new AppwriteException('Missing required parameter: "attribute"');
2610
+ }
2611
+ const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId).replace('{attribute}', attribute);
2612
+ const payload = {};
2613
+ if (typeof value !== 'undefined') {
2614
+ payload['value'] = value;
2615
+ }
2616
+ if (typeof min !== 'undefined') {
2617
+ payload['min'] = min;
2618
+ }
2619
+ const uri = new URL(this.client.config.endpoint + apiPath);
2620
+ return this.client.call('patch', uri, {
2621
+ 'content-type': 'application/json',
2622
+ }, payload);
2623
+ }
2624
+ incrementDocumentAttribute(paramsOrFirst, ...rest) {
2625
+ let params;
2626
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
2627
+ params = (paramsOrFirst || {});
2628
+ }
2629
+ else {
2630
+ params = {
2631
+ databaseId: paramsOrFirst,
2632
+ collectionId: rest[0],
2633
+ documentId: rest[1],
2634
+ attribute: rest[2],
2635
+ value: rest[3],
2636
+ max: rest[4]
2637
+ };
2638
+ }
2639
+ const databaseId = params.databaseId;
2640
+ const collectionId = params.collectionId;
2641
+ const documentId = params.documentId;
2642
+ const attribute = params.attribute;
2643
+ const value = params.value;
2644
+ const max = params.max;
2645
+ if (typeof databaseId === 'undefined') {
2646
+ throw new AppwriteException('Missing required parameter: "databaseId"');
2647
+ }
2648
+ if (typeof collectionId === 'undefined') {
2649
+ throw new AppwriteException('Missing required parameter: "collectionId"');
2650
+ }
2651
+ if (typeof documentId === 'undefined') {
2652
+ throw new AppwriteException('Missing required parameter: "documentId"');
2653
+ }
2654
+ if (typeof attribute === 'undefined') {
2655
+ throw new AppwriteException('Missing required parameter: "attribute"');
2656
+ }
2657
+ const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId).replace('{attribute}', attribute);
2658
+ const payload = {};
2659
+ if (typeof value !== 'undefined') {
2660
+ payload['value'] = value;
2661
+ }
2662
+ if (typeof max !== 'undefined') {
2663
+ payload['max'] = max;
2664
+ }
2665
+ const uri = new URL(this.client.config.endpoint + apiPath);
2666
+ return this.client.call('patch', uri, {
2667
+ 'content-type': 'application/json',
2668
+ }, payload);
2669
+ }
2430
2670
  }
2431
2671
 
2432
2672
  class Functions extends Service {
2433
2673
  constructor(client) {
2434
2674
  super(client);
2435
2675
  }
2436
- /**
2437
- * Get a list of all the current user function execution logs. You can use the
2438
- * query params to filter your results.
2439
- *
2440
- * @param {string} functionId
2441
- * @param {string[]} queries
2442
- * @throws {AppwriteException}
2443
- * @returns {Promise}
2444
- */
2445
- listExecutions(functionId, queries) {
2676
+ listExecutions(paramsOrFirst, ...rest) {
2677
+ let params;
2678
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
2679
+ params = (paramsOrFirst || {});
2680
+ }
2681
+ else {
2682
+ params = {
2683
+ functionId: paramsOrFirst,
2684
+ queries: rest[0]
2685
+ };
2686
+ }
2687
+ const functionId = params.functionId;
2688
+ const queries = params.queries;
2446
2689
  if (typeof functionId === 'undefined') {
2447
2690
  throw new AppwriteException('Missing required parameter: "functionId"');
2448
2691
  }
@@ -2454,23 +2697,29 @@ class Functions extends Service {
2454
2697
  const uri = new URL(this.client.config.endpoint + apiPath);
2455
2698
  return this.client.call('get', uri, {}, payload);
2456
2699
  }
2457
- /**
2458
- * Trigger a function execution. The returned object will return you the
2459
- * current execution status. You can ping the `Get Execution` endpoint to get
2460
- * updates on the current execution status. Once this endpoint is called, your
2461
- * function execution process will start asynchronously.
2462
- *
2463
- * @param {string} functionId
2464
- * @param {string} body
2465
- * @param {boolean} async
2466
- * @param {string} xpath
2467
- * @param {ExecutionMethod} method
2468
- * @param {object} headers
2469
- * @param {string} scheduledAt
2470
- * @throws {AppwriteException}
2471
- * @returns {Promise}
2472
- */
2473
- createExecution(functionId, body, async, xpath, method, headers, scheduledAt) {
2700
+ createExecution(paramsOrFirst, ...rest) {
2701
+ let params;
2702
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
2703
+ params = (paramsOrFirst || {});
2704
+ }
2705
+ else {
2706
+ params = {
2707
+ functionId: paramsOrFirst,
2708
+ body: rest[0],
2709
+ async: rest[1],
2710
+ xpath: rest[2],
2711
+ method: rest[3],
2712
+ headers: rest[4],
2713
+ scheduledAt: rest[5]
2714
+ };
2715
+ }
2716
+ const functionId = params.functionId;
2717
+ const body = params.body;
2718
+ const async = params.async;
2719
+ const xpath = params.xpath;
2720
+ const method = params.method;
2721
+ const headers = params.headers;
2722
+ const scheduledAt = params.scheduledAt;
2474
2723
  if (typeof functionId === 'undefined') {
2475
2724
  throw new AppwriteException('Missing required parameter: "functionId"');
2476
2725
  }
@@ -2499,15 +2748,19 @@ class Functions extends Service {
2499
2748
  'content-type': 'application/json',
2500
2749
  }, payload);
2501
2750
  }
2502
- /**
2503
- * Get a function execution log by its unique ID.
2504
- *
2505
- * @param {string} functionId
2506
- * @param {string} executionId
2507
- * @throws {AppwriteException}
2508
- * @returns {Promise}
2509
- */
2510
- getExecution(functionId, executionId) {
2751
+ getExecution(paramsOrFirst, ...rest) {
2752
+ let params;
2753
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
2754
+ params = (paramsOrFirst || {});
2755
+ }
2756
+ else {
2757
+ params = {
2758
+ functionId: paramsOrFirst,
2759
+ executionId: rest[0]
2760
+ };
2761
+ }
2762
+ const functionId = params.functionId;
2763
+ const executionId = params.executionId;
2511
2764
  if (typeof functionId === 'undefined') {
2512
2765
  throw new AppwriteException('Missing required parameter: "functionId"');
2513
2766
  }
@@ -2525,14 +2778,17 @@ class Graphql extends Service {
2525
2778
  constructor(client) {
2526
2779
  super(client);
2527
2780
  }
2528
- /**
2529
- * Execute a GraphQL mutation.
2530
- *
2531
- * @param {object} query
2532
- * @throws {AppwriteException}
2533
- * @returns {Promise}
2534
- */
2535
- query(query) {
2781
+ query(paramsOrFirst) {
2782
+ let params;
2783
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'query' in paramsOrFirst)) {
2784
+ params = (paramsOrFirst || {});
2785
+ }
2786
+ else {
2787
+ params = {
2788
+ query: paramsOrFirst
2789
+ };
2790
+ }
2791
+ const query = params.query;
2536
2792
  if (typeof query === 'undefined') {
2537
2793
  throw new AppwriteException('Missing required parameter: "query"');
2538
2794
  }
@@ -2547,14 +2803,17 @@ class Graphql extends Service {
2547
2803
  'content-type': 'application/json',
2548
2804
  }, payload);
2549
2805
  }
2550
- /**
2551
- * Execute a GraphQL mutation.
2552
- *
2553
- * @param {object} query
2554
- * @throws {AppwriteException}
2555
- * @returns {Promise}
2556
- */
2557
- mutation(query) {
2806
+ mutation(paramsOrFirst) {
2807
+ let params;
2808
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'query' in paramsOrFirst)) {
2809
+ params = (paramsOrFirst || {});
2810
+ }
2811
+ else {
2812
+ params = {
2813
+ query: paramsOrFirst
2814
+ };
2815
+ }
2816
+ const query = params.query;
2558
2817
  if (typeof query === 'undefined') {
2559
2818
  throw new AppwriteException('Missing required parameter: "query"');
2560
2819
  }
@@ -2576,16 +2835,13 @@ class Locale extends Service {
2576
2835
  super(client);
2577
2836
  }
2578
2837
  /**
2579
- * Get the current user location based on IP. Returns an object with user
2580
- * country code, country name, continent name, continent code, ip address and
2581
- * suggested currency. You can use the locale header to get the data in a
2582
- * supported language.
2838
+ * Get the current user location based on IP. Returns an object with user country code, country name, continent name, continent code, ip address and suggested currency. You can use the locale header to get the data in a supported language.
2583
2839
  *
2584
2840
  * ([IP Geolocation by DB-IP](https://db-ip.com))
2585
2841
  *
2586
2842
  * @throws {AppwriteException}
2587
2843
  * @returns {Promise}
2588
- */
2844
+ */
2589
2845
  get() {
2590
2846
  const apiPath = '/locale';
2591
2847
  const payload = {};
@@ -2593,12 +2849,11 @@ class Locale extends Service {
2593
2849
  return this.client.call('get', uri, {}, payload);
2594
2850
  }
2595
2851
  /**
2596
- * List of all locale codes in [ISO
2597
- * 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes).
2852
+ * List of all locale codes in [ISO 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes).
2598
2853
  *
2599
2854
  * @throws {AppwriteException}
2600
2855
  * @returns {Promise}
2601
- */
2856
+ */
2602
2857
  listCodes() {
2603
2858
  const apiPath = '/locale/codes';
2604
2859
  const payload = {};
@@ -2606,12 +2861,11 @@ class Locale extends Service {
2606
2861
  return this.client.call('get', uri, {}, payload);
2607
2862
  }
2608
2863
  /**
2609
- * List of all continents. You can use the locale header to get the data in a
2610
- * supported language.
2864
+ * List of all continents. You can use the locale header to get the data in a supported language.
2611
2865
  *
2612
2866
  * @throws {AppwriteException}
2613
2867
  * @returns {Promise}
2614
- */
2868
+ */
2615
2869
  listContinents() {
2616
2870
  const apiPath = '/locale/continents';
2617
2871
  const payload = {};
@@ -2619,12 +2873,11 @@ class Locale extends Service {
2619
2873
  return this.client.call('get', uri, {}, payload);
2620
2874
  }
2621
2875
  /**
2622
- * List of all countries. You can use the locale header to get the data in a
2623
- * supported language.
2876
+ * List of all countries. You can use the locale header to get the data in a supported language.
2624
2877
  *
2625
2878
  * @throws {AppwriteException}
2626
2879
  * @returns {Promise}
2627
- */
2880
+ */
2628
2881
  listCountries() {
2629
2882
  const apiPath = '/locale/countries';
2630
2883
  const payload = {};
@@ -2632,12 +2885,11 @@ class Locale extends Service {
2632
2885
  return this.client.call('get', uri, {}, payload);
2633
2886
  }
2634
2887
  /**
2635
- * List of all countries that are currently members of the EU. You can use the
2636
- * locale header to get the data in a supported language.
2888
+ * List of all countries that are currently members of the EU. You can use the locale header to get the data in a supported language.
2637
2889
  *
2638
2890
  * @throws {AppwriteException}
2639
2891
  * @returns {Promise}
2640
- */
2892
+ */
2641
2893
  listCountriesEU() {
2642
2894
  const apiPath = '/locale/countries/eu';
2643
2895
  const payload = {};
@@ -2645,12 +2897,11 @@ class Locale extends Service {
2645
2897
  return this.client.call('get', uri, {}, payload);
2646
2898
  }
2647
2899
  /**
2648
- * List of all countries phone codes. You can use the locale header to get the
2649
- * data in a supported language.
2900
+ * List of all countries phone codes. You can use the locale header to get the data in a supported language.
2650
2901
  *
2651
2902
  * @throws {AppwriteException}
2652
2903
  * @returns {Promise}
2653
- */
2904
+ */
2654
2905
  listCountriesPhones() {
2655
2906
  const apiPath = '/locale/countries/phones';
2656
2907
  const payload = {};
@@ -2658,13 +2909,11 @@ class Locale extends Service {
2658
2909
  return this.client.call('get', uri, {}, payload);
2659
2910
  }
2660
2911
  /**
2661
- * List of all currencies, including currency symbol, name, plural, and
2662
- * decimal digits for all major and minor currencies. You can use the locale
2663
- * header to get the data in a supported language.
2912
+ * List of all currencies, including currency symbol, name, plural, and decimal digits for all major and minor currencies. You can use the locale header to get the data in a supported language.
2664
2913
  *
2665
2914
  * @throws {AppwriteException}
2666
2915
  * @returns {Promise}
2667
- */
2916
+ */
2668
2917
  listCurrencies() {
2669
2918
  const apiPath = '/locale/currencies';
2670
2919
  const payload = {};
@@ -2672,12 +2921,11 @@ class Locale extends Service {
2672
2921
  return this.client.call('get', uri, {}, payload);
2673
2922
  }
2674
2923
  /**
2675
- * List of all languages classified by ISO 639-1 including 2-letter code, name
2676
- * in English, and name in the respective language.
2924
+ * List of all languages classified by ISO 639-1 including 2-letter code, name in English, and name in the respective language.
2677
2925
  *
2678
2926
  * @throws {AppwriteException}
2679
2927
  * @returns {Promise}
2680
- */
2928
+ */
2681
2929
  listLanguages() {
2682
2930
  const apiPath = '/locale/languages';
2683
2931
  const payload = {};
@@ -2690,16 +2938,21 @@ class Messaging extends Service {
2690
2938
  constructor(client) {
2691
2939
  super(client);
2692
2940
  }
2693
- /**
2694
- * Create a new subscriber.
2695
- *
2696
- * @param {string} topicId
2697
- * @param {string} subscriberId
2698
- * @param {string} targetId
2699
- * @throws {AppwriteException}
2700
- * @returns {Promise}
2701
- */
2702
- createSubscriber(topicId, subscriberId, targetId) {
2941
+ createSubscriber(paramsOrFirst, ...rest) {
2942
+ let params;
2943
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
2944
+ params = (paramsOrFirst || {});
2945
+ }
2946
+ else {
2947
+ params = {
2948
+ topicId: paramsOrFirst,
2949
+ subscriberId: rest[0],
2950
+ targetId: rest[1]
2951
+ };
2952
+ }
2953
+ const topicId = params.topicId;
2954
+ const subscriberId = params.subscriberId;
2955
+ const targetId = params.targetId;
2703
2956
  if (typeof topicId === 'undefined') {
2704
2957
  throw new AppwriteException('Missing required parameter: "topicId"');
2705
2958
  }
@@ -2722,15 +2975,19 @@ class Messaging extends Service {
2722
2975
  'content-type': 'application/json',
2723
2976
  }, payload);
2724
2977
  }
2725
- /**
2726
- * Delete a subscriber by its unique ID.
2727
- *
2728
- * @param {string} topicId
2729
- * @param {string} subscriberId
2730
- * @throws {AppwriteException}
2731
- * @returns {Promise}
2732
- */
2733
- deleteSubscriber(topicId, subscriberId) {
2978
+ deleteSubscriber(paramsOrFirst, ...rest) {
2979
+ let params;
2980
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
2981
+ params = (paramsOrFirst || {});
2982
+ }
2983
+ else {
2984
+ params = {
2985
+ topicId: paramsOrFirst,
2986
+ subscriberId: rest[0]
2987
+ };
2988
+ }
2989
+ const topicId = params.topicId;
2990
+ const subscriberId = params.subscriberId;
2734
2991
  if (typeof topicId === 'undefined') {
2735
2992
  throw new AppwriteException('Missing required parameter: "topicId"');
2736
2993
  }
@@ -2750,17 +3007,21 @@ class Storage extends Service {
2750
3007
  constructor(client) {
2751
3008
  super(client);
2752
3009
  }
2753
- /**
2754
- * Get a list of all the user files. You can use the query params to filter
2755
- * your results.
2756
- *
2757
- * @param {string} bucketId
2758
- * @param {string[]} queries
2759
- * @param {string} search
2760
- * @throws {AppwriteException}
2761
- * @returns {Promise}
2762
- */
2763
- listFiles(bucketId, queries, search) {
3010
+ listFiles(paramsOrFirst, ...rest) {
3011
+ let params;
3012
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
3013
+ params = (paramsOrFirst || {});
3014
+ }
3015
+ else {
3016
+ params = {
3017
+ bucketId: paramsOrFirst,
3018
+ queries: rest[0],
3019
+ search: rest[1]
3020
+ };
3021
+ }
3022
+ const bucketId = params.bucketId;
3023
+ const queries = params.queries;
3024
+ const search = params.search;
2764
3025
  if (typeof bucketId === 'undefined') {
2765
3026
  throw new AppwriteException('Missing required parameter: "bucketId"');
2766
3027
  }
@@ -2775,35 +3036,27 @@ class Storage extends Service {
2775
3036
  const uri = new URL(this.client.config.endpoint + apiPath);
2776
3037
  return this.client.call('get', uri, {}, payload);
2777
3038
  }
2778
- /**
2779
- * Create a new file. Before using this route, you should create a new bucket
2780
- * resource using either a [server
2781
- * integration](https://appwrite.io/docs/server/storage#storageCreateBucket)
2782
- * API or directly from your Appwrite console.
2783
- *
2784
- * Larger files should be uploaded using multiple requests with the
2785
- * [content-range](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Range)
2786
- * header to send a partial request with a maximum supported chunk of `5MB`.
2787
- * The `content-range` header values should always be in bytes.
2788
- *
2789
- * When the first request is sent, the server will return the **File** object,
2790
- * and the subsequent part request must include the file's **id** in
2791
- * `x-appwrite-id` header to allow the server to know that the partial upload
2792
- * is for the existing file and not for a new one.
2793
- *
2794
- * If you're creating a new file using one of the Appwrite SDKs, all the
2795
- * chunking logic will be managed by the SDK internally.
2796
- *
2797
- *
2798
- * @param {string} bucketId
2799
- * @param {string} fileId
2800
- * @param {{name: string, type: string, size: number, uri: string}} file
2801
- * @param {string[]} permissions
2802
- * @throws {AppwriteException}
2803
- * @returns {Promise}
2804
- */
2805
- createFile(bucketId_1, fileId_1, file_1, permissions_1) {
2806
- return __awaiter(this, arguments, void 0, function* (bucketId, fileId, file, permissions, onProgress = (progress) => { }) {
3039
+ createFile(paramsOrFirst, ...rest) {
3040
+ return __awaiter(this, void 0, void 0, function* () {
3041
+ let params;
3042
+ let onProgress;
3043
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
3044
+ params = (paramsOrFirst || {});
3045
+ onProgress = paramsOrFirst === null || paramsOrFirst === void 0 ? void 0 : paramsOrFirst.onProgress;
3046
+ }
3047
+ else {
3048
+ params = {
3049
+ bucketId: paramsOrFirst,
3050
+ fileId: rest[0],
3051
+ file: rest[1],
3052
+ permissions: rest[2]
3053
+ };
3054
+ onProgress = rest[3];
3055
+ }
3056
+ const bucketId = params.bucketId;
3057
+ const fileId = params.fileId;
3058
+ const file = params.file;
3059
+ const permissions = params.permissions;
2807
3060
  if (typeof bucketId === 'undefined') {
2808
3061
  throw new AppwriteException('Missing required parameter: "bucketId"');
2809
3062
  }
@@ -2875,16 +3128,19 @@ class Storage extends Service {
2875
3128
  return response;
2876
3129
  });
2877
3130
  }
2878
- /**
2879
- * Get a file by its unique ID. This endpoint response returns a JSON object
2880
- * with the file metadata.
2881
- *
2882
- * @param {string} bucketId
2883
- * @param {string} fileId
2884
- * @throws {AppwriteException}
2885
- * @returns {Promise}
2886
- */
2887
- getFile(bucketId, fileId) {
3131
+ getFile(paramsOrFirst, ...rest) {
3132
+ let params;
3133
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
3134
+ params = (paramsOrFirst || {});
3135
+ }
3136
+ else {
3137
+ params = {
3138
+ bucketId: paramsOrFirst,
3139
+ fileId: rest[0]
3140
+ };
3141
+ }
3142
+ const bucketId = params.bucketId;
3143
+ const fileId = params.fileId;
2888
3144
  if (typeof bucketId === 'undefined') {
2889
3145
  throw new AppwriteException('Missing required parameter: "bucketId"');
2890
3146
  }
@@ -2896,18 +3152,23 @@ class Storage extends Service {
2896
3152
  const uri = new URL(this.client.config.endpoint + apiPath);
2897
3153
  return this.client.call('get', uri, {}, payload);
2898
3154
  }
2899
- /**
2900
- * Update a file by its unique ID. Only users with write permissions have
2901
- * access to update this resource.
2902
- *
2903
- * @param {string} bucketId
2904
- * @param {string} fileId
2905
- * @param {string} name
2906
- * @param {string[]} permissions
2907
- * @throws {AppwriteException}
2908
- * @returns {Promise}
2909
- */
2910
- updateFile(bucketId, fileId, name, permissions) {
3155
+ updateFile(paramsOrFirst, ...rest) {
3156
+ let params;
3157
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
3158
+ params = (paramsOrFirst || {});
3159
+ }
3160
+ else {
3161
+ params = {
3162
+ bucketId: paramsOrFirst,
3163
+ fileId: rest[0],
3164
+ name: rest[1],
3165
+ permissions: rest[2]
3166
+ };
3167
+ }
3168
+ const bucketId = params.bucketId;
3169
+ const fileId = params.fileId;
3170
+ const name = params.name;
3171
+ const permissions = params.permissions;
2911
3172
  if (typeof bucketId === 'undefined') {
2912
3173
  throw new AppwriteException('Missing required parameter: "bucketId"');
2913
3174
  }
@@ -2927,16 +3188,19 @@ class Storage extends Service {
2927
3188
  'content-type': 'application/json',
2928
3189
  }, payload);
2929
3190
  }
2930
- /**
2931
- * Delete a file by its unique ID. Only users with write permissions have
2932
- * access to delete this resource.
2933
- *
2934
- * @param {string} bucketId
2935
- * @param {string} fileId
2936
- * @throws {AppwriteException}
2937
- * @returns {Promise}
2938
- */
2939
- deleteFile(bucketId, fileId) {
3191
+ deleteFile(paramsOrFirst, ...rest) {
3192
+ let params;
3193
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
3194
+ params = (paramsOrFirst || {});
3195
+ }
3196
+ else {
3197
+ params = {
3198
+ bucketId: paramsOrFirst,
3199
+ fileId: rest[0]
3200
+ };
3201
+ }
3202
+ const bucketId = params.bucketId;
3203
+ const fileId = params.fileId;
2940
3204
  if (typeof bucketId === 'undefined') {
2941
3205
  throw new AppwriteException('Missing required parameter: "bucketId"');
2942
3206
  }
@@ -2950,18 +3214,21 @@ class Storage extends Service {
2950
3214
  'content-type': 'application/json',
2951
3215
  }, payload);
2952
3216
  }
2953
- /**
2954
- * Get a file content by its unique ID. The endpoint response return with a
2955
- * 'Content-Disposition: attachment' header that tells the browser to start
2956
- * downloading the file to user downloads directory.
2957
- *
2958
- * @param {string} bucketId
2959
- * @param {string} fileId
2960
- * @param {string} token
2961
- * @throws {AppwriteException}
2962
- * @returns {ArrayBuffer}
2963
- */
2964
- getFileDownload(bucketId, fileId, token) {
3217
+ getFileDownload(paramsOrFirst, ...rest) {
3218
+ let params;
3219
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
3220
+ params = (paramsOrFirst || {});
3221
+ }
3222
+ else {
3223
+ params = {
3224
+ bucketId: paramsOrFirst,
3225
+ fileId: rest[0],
3226
+ token: rest[1]
3227
+ };
3228
+ }
3229
+ const bucketId = params.bucketId;
3230
+ const fileId = params.fileId;
3231
+ const token = params.token;
2965
3232
  if (typeof bucketId === 'undefined') {
2966
3233
  throw new AppwriteException('Missing required parameter: "bucketId"');
2967
3234
  }
@@ -2980,31 +3247,43 @@ class Storage extends Service {
2980
3247
  }
2981
3248
  return this.client.call('get', uri, {}, payload, 'arrayBuffer');
2982
3249
  }
2983
- /**
2984
- * Get a file preview image. Currently, this method supports preview for image
2985
- * files (jpg, png, and gif), other supported formats, like pdf, docs, slides,
2986
- * and spreadsheets, will return the file icon image. You can also pass query
2987
- * string arguments for cutting and resizing your preview image. Preview is
2988
- * supported only for image files smaller than 10MB.
2989
- *
2990
- * @param {string} bucketId
2991
- * @param {string} fileId
2992
- * @param {number} width
2993
- * @param {number} height
2994
- * @param {ImageGravity} gravity
2995
- * @param {number} quality
2996
- * @param {number} borderWidth
2997
- * @param {string} borderColor
2998
- * @param {number} borderRadius
2999
- * @param {number} opacity
3000
- * @param {number} rotation
3001
- * @param {string} background
3002
- * @param {ImageFormat} output
3003
- * @param {string} token
3004
- * @throws {AppwriteException}
3005
- * @returns {ArrayBuffer}
3006
- */
3007
- getFilePreview(bucketId, fileId, width, height, gravity, quality, borderWidth, borderColor, borderRadius, opacity, rotation, background, output, token) {
3250
+ getFilePreview(paramsOrFirst, ...rest) {
3251
+ let params;
3252
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
3253
+ params = (paramsOrFirst || {});
3254
+ }
3255
+ else {
3256
+ params = {
3257
+ bucketId: paramsOrFirst,
3258
+ fileId: rest[0],
3259
+ width: rest[1],
3260
+ height: rest[2],
3261
+ gravity: rest[3],
3262
+ quality: rest[4],
3263
+ borderWidth: rest[5],
3264
+ borderColor: rest[6],
3265
+ borderRadius: rest[7],
3266
+ opacity: rest[8],
3267
+ rotation: rest[9],
3268
+ background: rest[10],
3269
+ output: rest[11],
3270
+ token: rest[12]
3271
+ };
3272
+ }
3273
+ const bucketId = params.bucketId;
3274
+ const fileId = params.fileId;
3275
+ const width = params.width;
3276
+ const height = params.height;
3277
+ const gravity = params.gravity;
3278
+ const quality = params.quality;
3279
+ const borderWidth = params.borderWidth;
3280
+ const borderColor = params.borderColor;
3281
+ const borderRadius = params.borderRadius;
3282
+ const opacity = params.opacity;
3283
+ const rotation = params.rotation;
3284
+ const background = params.background;
3285
+ const output = params.output;
3286
+ const token = params.token;
3008
3287
  if (typeof bucketId === 'undefined') {
3009
3288
  throw new AppwriteException('Missing required parameter: "bucketId"');
3010
3289
  }
@@ -3056,18 +3335,21 @@ class Storage extends Service {
3056
3335
  }
3057
3336
  return this.client.call('get', uri, {}, payload, 'arrayBuffer');
3058
3337
  }
3059
- /**
3060
- * Get a file content by its unique ID. This endpoint is similar to the
3061
- * download method but returns with no 'Content-Disposition: attachment'
3062
- * header.
3063
- *
3064
- * @param {string} bucketId
3065
- * @param {string} fileId
3066
- * @param {string} token
3067
- * @throws {AppwriteException}
3068
- * @returns {ArrayBuffer}
3069
- */
3070
- getFileView(bucketId, fileId, token) {
3338
+ getFileView(paramsOrFirst, ...rest) {
3339
+ let params;
3340
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
3341
+ params = (paramsOrFirst || {});
3342
+ }
3343
+ else {
3344
+ params = {
3345
+ bucketId: paramsOrFirst,
3346
+ fileId: rest[0],
3347
+ token: rest[1]
3348
+ };
3349
+ }
3350
+ const bucketId = params.bucketId;
3351
+ const fileId = params.fileId;
3352
+ const token = params.token;
3071
3353
  if (typeof bucketId === 'undefined') {
3072
3354
  throw new AppwriteException('Missing required parameter: "bucketId"');
3073
3355
  }
@@ -3206,20 +3488,344 @@ class Storage extends Service {
3206
3488
  }
3207
3489
  }
3208
3490
 
3491
+ class TablesDB extends Service {
3492
+ constructor(client) {
3493
+ super(client);
3494
+ }
3495
+ listRows(paramsOrFirst, ...rest) {
3496
+ let params;
3497
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
3498
+ params = (paramsOrFirst || {});
3499
+ }
3500
+ else {
3501
+ params = {
3502
+ databaseId: paramsOrFirst,
3503
+ tableId: rest[0],
3504
+ queries: rest[1]
3505
+ };
3506
+ }
3507
+ const databaseId = params.databaseId;
3508
+ const tableId = params.tableId;
3509
+ const queries = params.queries;
3510
+ if (typeof databaseId === 'undefined') {
3511
+ throw new AppwriteException('Missing required parameter: "databaseId"');
3512
+ }
3513
+ if (typeof tableId === 'undefined') {
3514
+ throw new AppwriteException('Missing required parameter: "tableId"');
3515
+ }
3516
+ const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows'.replace('{databaseId}', databaseId).replace('{tableId}', tableId);
3517
+ const payload = {};
3518
+ if (typeof queries !== 'undefined') {
3519
+ payload['queries'] = queries;
3520
+ }
3521
+ const uri = new URL(this.client.config.endpoint + apiPath);
3522
+ return this.client.call('get', uri, {}, payload);
3523
+ }
3524
+ createRow(paramsOrFirst, ...rest) {
3525
+ let params;
3526
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
3527
+ params = (paramsOrFirst || {});
3528
+ }
3529
+ else {
3530
+ params = {
3531
+ databaseId: paramsOrFirst,
3532
+ tableId: rest[0],
3533
+ rowId: rest[1],
3534
+ data: rest[2],
3535
+ permissions: rest[3]
3536
+ };
3537
+ }
3538
+ const databaseId = params.databaseId;
3539
+ const tableId = params.tableId;
3540
+ const rowId = params.rowId;
3541
+ const data = params.data;
3542
+ const permissions = params.permissions;
3543
+ if (typeof databaseId === 'undefined') {
3544
+ throw new AppwriteException('Missing required parameter: "databaseId"');
3545
+ }
3546
+ if (typeof tableId === 'undefined') {
3547
+ throw new AppwriteException('Missing required parameter: "tableId"');
3548
+ }
3549
+ if (typeof rowId === 'undefined') {
3550
+ throw new AppwriteException('Missing required parameter: "rowId"');
3551
+ }
3552
+ if (typeof data === 'undefined') {
3553
+ throw new AppwriteException('Missing required parameter: "data"');
3554
+ }
3555
+ const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows'.replace('{databaseId}', databaseId).replace('{tableId}', tableId);
3556
+ const payload = {};
3557
+ if (typeof rowId !== 'undefined') {
3558
+ payload['rowId'] = rowId;
3559
+ }
3560
+ if (typeof data !== 'undefined') {
3561
+ payload['data'] = data;
3562
+ }
3563
+ if (typeof permissions !== 'undefined') {
3564
+ payload['permissions'] = permissions;
3565
+ }
3566
+ const uri = new URL(this.client.config.endpoint + apiPath);
3567
+ return this.client.call('post', uri, {
3568
+ 'content-type': 'application/json',
3569
+ }, payload);
3570
+ }
3571
+ getRow(paramsOrFirst, ...rest) {
3572
+ let params;
3573
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
3574
+ params = (paramsOrFirst || {});
3575
+ }
3576
+ else {
3577
+ params = {
3578
+ databaseId: paramsOrFirst,
3579
+ tableId: rest[0],
3580
+ rowId: rest[1],
3581
+ queries: rest[2]
3582
+ };
3583
+ }
3584
+ const databaseId = params.databaseId;
3585
+ const tableId = params.tableId;
3586
+ const rowId = params.rowId;
3587
+ const queries = params.queries;
3588
+ if (typeof databaseId === 'undefined') {
3589
+ throw new AppwriteException('Missing required parameter: "databaseId"');
3590
+ }
3591
+ if (typeof tableId === 'undefined') {
3592
+ throw new AppwriteException('Missing required parameter: "tableId"');
3593
+ }
3594
+ if (typeof rowId === 'undefined') {
3595
+ throw new AppwriteException('Missing required parameter: "rowId"');
3596
+ }
3597
+ const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{rowId}', rowId);
3598
+ const payload = {};
3599
+ if (typeof queries !== 'undefined') {
3600
+ payload['queries'] = queries;
3601
+ }
3602
+ const uri = new URL(this.client.config.endpoint + apiPath);
3603
+ return this.client.call('get', uri, {}, payload);
3604
+ }
3605
+ upsertRow(paramsOrFirst, ...rest) {
3606
+ let params;
3607
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
3608
+ params = (paramsOrFirst || {});
3609
+ }
3610
+ else {
3611
+ params = {
3612
+ databaseId: paramsOrFirst,
3613
+ tableId: rest[0],
3614
+ rowId: rest[1],
3615
+ data: rest[2],
3616
+ permissions: rest[3]
3617
+ };
3618
+ }
3619
+ const databaseId = params.databaseId;
3620
+ const tableId = params.tableId;
3621
+ const rowId = params.rowId;
3622
+ const data = params.data;
3623
+ const permissions = params.permissions;
3624
+ if (typeof databaseId === 'undefined') {
3625
+ throw new AppwriteException('Missing required parameter: "databaseId"');
3626
+ }
3627
+ if (typeof tableId === 'undefined') {
3628
+ throw new AppwriteException('Missing required parameter: "tableId"');
3629
+ }
3630
+ if (typeof rowId === 'undefined') {
3631
+ throw new AppwriteException('Missing required parameter: "rowId"');
3632
+ }
3633
+ const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{rowId}', rowId);
3634
+ const payload = {};
3635
+ if (typeof data !== 'undefined') {
3636
+ payload['data'] = data;
3637
+ }
3638
+ if (typeof permissions !== 'undefined') {
3639
+ payload['permissions'] = permissions;
3640
+ }
3641
+ const uri = new URL(this.client.config.endpoint + apiPath);
3642
+ return this.client.call('put', uri, {
3643
+ 'content-type': 'application/json',
3644
+ }, payload);
3645
+ }
3646
+ updateRow(paramsOrFirst, ...rest) {
3647
+ let params;
3648
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
3649
+ params = (paramsOrFirst || {});
3650
+ }
3651
+ else {
3652
+ params = {
3653
+ databaseId: paramsOrFirst,
3654
+ tableId: rest[0],
3655
+ rowId: rest[1],
3656
+ data: rest[2],
3657
+ permissions: rest[3]
3658
+ };
3659
+ }
3660
+ const databaseId = params.databaseId;
3661
+ const tableId = params.tableId;
3662
+ const rowId = params.rowId;
3663
+ const data = params.data;
3664
+ const permissions = params.permissions;
3665
+ if (typeof databaseId === 'undefined') {
3666
+ throw new AppwriteException('Missing required parameter: "databaseId"');
3667
+ }
3668
+ if (typeof tableId === 'undefined') {
3669
+ throw new AppwriteException('Missing required parameter: "tableId"');
3670
+ }
3671
+ if (typeof rowId === 'undefined') {
3672
+ throw new AppwriteException('Missing required parameter: "rowId"');
3673
+ }
3674
+ const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{rowId}', rowId);
3675
+ const payload = {};
3676
+ if (typeof data !== 'undefined') {
3677
+ payload['data'] = data;
3678
+ }
3679
+ if (typeof permissions !== 'undefined') {
3680
+ payload['permissions'] = permissions;
3681
+ }
3682
+ const uri = new URL(this.client.config.endpoint + apiPath);
3683
+ return this.client.call('patch', uri, {
3684
+ 'content-type': 'application/json',
3685
+ }, payload);
3686
+ }
3687
+ deleteRow(paramsOrFirst, ...rest) {
3688
+ let params;
3689
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
3690
+ params = (paramsOrFirst || {});
3691
+ }
3692
+ else {
3693
+ params = {
3694
+ databaseId: paramsOrFirst,
3695
+ tableId: rest[0],
3696
+ rowId: rest[1]
3697
+ };
3698
+ }
3699
+ const databaseId = params.databaseId;
3700
+ const tableId = params.tableId;
3701
+ const rowId = params.rowId;
3702
+ if (typeof databaseId === 'undefined') {
3703
+ throw new AppwriteException('Missing required parameter: "databaseId"');
3704
+ }
3705
+ if (typeof tableId === 'undefined') {
3706
+ throw new AppwriteException('Missing required parameter: "tableId"');
3707
+ }
3708
+ if (typeof rowId === 'undefined') {
3709
+ throw new AppwriteException('Missing required parameter: "rowId"');
3710
+ }
3711
+ const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{rowId}', rowId);
3712
+ const payload = {};
3713
+ const uri = new URL(this.client.config.endpoint + apiPath);
3714
+ return this.client.call('delete', uri, {
3715
+ 'content-type': 'application/json',
3716
+ }, payload);
3717
+ }
3718
+ decrementRowColumn(paramsOrFirst, ...rest) {
3719
+ let params;
3720
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
3721
+ params = (paramsOrFirst || {});
3722
+ }
3723
+ else {
3724
+ params = {
3725
+ databaseId: paramsOrFirst,
3726
+ tableId: rest[0],
3727
+ rowId: rest[1],
3728
+ column: rest[2],
3729
+ value: rest[3],
3730
+ min: rest[4]
3731
+ };
3732
+ }
3733
+ const databaseId = params.databaseId;
3734
+ const tableId = params.tableId;
3735
+ const rowId = params.rowId;
3736
+ const column = params.column;
3737
+ const value = params.value;
3738
+ const min = params.min;
3739
+ if (typeof databaseId === 'undefined') {
3740
+ throw new AppwriteException('Missing required parameter: "databaseId"');
3741
+ }
3742
+ if (typeof tableId === 'undefined') {
3743
+ throw new AppwriteException('Missing required parameter: "tableId"');
3744
+ }
3745
+ if (typeof rowId === 'undefined') {
3746
+ throw new AppwriteException('Missing required parameter: "rowId"');
3747
+ }
3748
+ if (typeof column === 'undefined') {
3749
+ throw new AppwriteException('Missing required parameter: "column"');
3750
+ }
3751
+ const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/decrement'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{rowId}', rowId).replace('{column}', column);
3752
+ const payload = {};
3753
+ if (typeof value !== 'undefined') {
3754
+ payload['value'] = value;
3755
+ }
3756
+ if (typeof min !== 'undefined') {
3757
+ payload['min'] = min;
3758
+ }
3759
+ const uri = new URL(this.client.config.endpoint + apiPath);
3760
+ return this.client.call('patch', uri, {
3761
+ 'content-type': 'application/json',
3762
+ }, payload);
3763
+ }
3764
+ incrementRowColumn(paramsOrFirst, ...rest) {
3765
+ let params;
3766
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
3767
+ params = (paramsOrFirst || {});
3768
+ }
3769
+ else {
3770
+ params = {
3771
+ databaseId: paramsOrFirst,
3772
+ tableId: rest[0],
3773
+ rowId: rest[1],
3774
+ column: rest[2],
3775
+ value: rest[3],
3776
+ max: rest[4]
3777
+ };
3778
+ }
3779
+ const databaseId = params.databaseId;
3780
+ const tableId = params.tableId;
3781
+ const rowId = params.rowId;
3782
+ const column = params.column;
3783
+ const value = params.value;
3784
+ const max = params.max;
3785
+ if (typeof databaseId === 'undefined') {
3786
+ throw new AppwriteException('Missing required parameter: "databaseId"');
3787
+ }
3788
+ if (typeof tableId === 'undefined') {
3789
+ throw new AppwriteException('Missing required parameter: "tableId"');
3790
+ }
3791
+ if (typeof rowId === 'undefined') {
3792
+ throw new AppwriteException('Missing required parameter: "rowId"');
3793
+ }
3794
+ if (typeof column === 'undefined') {
3795
+ throw new AppwriteException('Missing required parameter: "column"');
3796
+ }
3797
+ const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/increment'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{rowId}', rowId).replace('{column}', column);
3798
+ const payload = {};
3799
+ if (typeof value !== 'undefined') {
3800
+ payload['value'] = value;
3801
+ }
3802
+ if (typeof max !== 'undefined') {
3803
+ payload['max'] = max;
3804
+ }
3805
+ const uri = new URL(this.client.config.endpoint + apiPath);
3806
+ return this.client.call('patch', uri, {
3807
+ 'content-type': 'application/json',
3808
+ }, payload);
3809
+ }
3810
+ }
3811
+
3209
3812
  class Teams extends Service {
3210
3813
  constructor(client) {
3211
3814
  super(client);
3212
3815
  }
3213
- /**
3214
- * Get a list of all the teams in which the current user is a member. You can
3215
- * use the parameters to filter your results.
3216
- *
3217
- * @param {string[]} queries
3218
- * @param {string} search
3219
- * @throws {AppwriteException}
3220
- * @returns {Promise}
3221
- */
3222
- list(queries, search) {
3816
+ list(paramsOrFirst, ...rest) {
3817
+ let params;
3818
+ if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
3819
+ params = (paramsOrFirst || {});
3820
+ }
3821
+ else {
3822
+ params = {
3823
+ queries: paramsOrFirst,
3824
+ search: rest[0]
3825
+ };
3826
+ }
3827
+ const queries = params.queries;
3828
+ const search = params.search;
3223
3829
  const apiPath = '/teams';
3224
3830
  const payload = {};
3225
3831
  if (typeof queries !== 'undefined') {
@@ -3231,18 +3837,21 @@ class Teams extends Service {
3231
3837
  const uri = new URL(this.client.config.endpoint + apiPath);
3232
3838
  return this.client.call('get', uri, {}, payload);
3233
3839
  }
3234
- /**
3235
- * Create a new team. The user who creates the team will automatically be
3236
- * assigned as the owner of the team. Only the users with the owner role can
3237
- * invite new members, add new owners and delete or update the team.
3238
- *
3239
- * @param {string} teamId
3240
- * @param {string} name
3241
- * @param {string[]} roles
3242
- * @throws {AppwriteException}
3243
- * @returns {Promise}
3244
- */
3245
- create(teamId, name, roles) {
3840
+ create(paramsOrFirst, ...rest) {
3841
+ let params;
3842
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
3843
+ params = (paramsOrFirst || {});
3844
+ }
3845
+ else {
3846
+ params = {
3847
+ teamId: paramsOrFirst,
3848
+ name: rest[0],
3849
+ roles: rest[1]
3850
+ };
3851
+ }
3852
+ const teamId = params.teamId;
3853
+ const name = params.name;
3854
+ const roles = params.roles;
3246
3855
  if (typeof teamId === 'undefined') {
3247
3856
  throw new AppwriteException('Missing required parameter: "teamId"');
3248
3857
  }
@@ -3265,14 +3874,17 @@ class Teams extends Service {
3265
3874
  'content-type': 'application/json',
3266
3875
  }, payload);
3267
3876
  }
3268
- /**
3269
- * Get a team by its ID. All team members have read access for this resource.
3270
- *
3271
- * @param {string} teamId
3272
- * @throws {AppwriteException}
3273
- * @returns {Promise}
3274
- */
3275
- get(teamId) {
3877
+ get(paramsOrFirst) {
3878
+ let params;
3879
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
3880
+ params = (paramsOrFirst || {});
3881
+ }
3882
+ else {
3883
+ params = {
3884
+ teamId: paramsOrFirst
3885
+ };
3886
+ }
3887
+ const teamId = params.teamId;
3276
3888
  if (typeof teamId === 'undefined') {
3277
3889
  throw new AppwriteException('Missing required parameter: "teamId"');
3278
3890
  }
@@ -3281,15 +3893,19 @@ class Teams extends Service {
3281
3893
  const uri = new URL(this.client.config.endpoint + apiPath);
3282
3894
  return this.client.call('get', uri, {}, payload);
3283
3895
  }
3284
- /**
3285
- * Update the team's name by its unique ID.
3286
- *
3287
- * @param {string} teamId
3288
- * @param {string} name
3289
- * @throws {AppwriteException}
3290
- * @returns {Promise}
3291
- */
3292
- updateName(teamId, name) {
3896
+ updateName(paramsOrFirst, ...rest) {
3897
+ let params;
3898
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
3899
+ params = (paramsOrFirst || {});
3900
+ }
3901
+ else {
3902
+ params = {
3903
+ teamId: paramsOrFirst,
3904
+ name: rest[0]
3905
+ };
3906
+ }
3907
+ const teamId = params.teamId;
3908
+ const name = params.name;
3293
3909
  if (typeof teamId === 'undefined') {
3294
3910
  throw new AppwriteException('Missing required parameter: "teamId"');
3295
3911
  }
@@ -3306,15 +3922,17 @@ class Teams extends Service {
3306
3922
  'content-type': 'application/json',
3307
3923
  }, payload);
3308
3924
  }
3309
- /**
3310
- * Delete a team using its ID. Only team members with the owner role can
3311
- * delete the team.
3312
- *
3313
- * @param {string} teamId
3314
- * @throws {AppwriteException}
3315
- * @returns {Promise}
3316
- */
3317
- delete(teamId) {
3925
+ delete(paramsOrFirst) {
3926
+ let params;
3927
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
3928
+ params = (paramsOrFirst || {});
3929
+ }
3930
+ else {
3931
+ params = {
3932
+ teamId: paramsOrFirst
3933
+ };
3934
+ }
3935
+ const teamId = params.teamId;
3318
3936
  if (typeof teamId === 'undefined') {
3319
3937
  throw new AppwriteException('Missing required parameter: "teamId"');
3320
3938
  }
@@ -3325,18 +3943,21 @@ class Teams extends Service {
3325
3943
  'content-type': 'application/json',
3326
3944
  }, payload);
3327
3945
  }
3328
- /**
3329
- * Use this endpoint to list a team's members using the team's ID. All team
3330
- * members have read access to this endpoint. Hide sensitive attributes from
3331
- * the response by toggling membership privacy in the Console.
3332
- *
3333
- * @param {string} teamId
3334
- * @param {string[]} queries
3335
- * @param {string} search
3336
- * @throws {AppwriteException}
3337
- * @returns {Promise}
3338
- */
3339
- listMemberships(teamId, queries, search) {
3946
+ listMemberships(paramsOrFirst, ...rest) {
3947
+ let params;
3948
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
3949
+ params = (paramsOrFirst || {});
3950
+ }
3951
+ else {
3952
+ params = {
3953
+ teamId: paramsOrFirst,
3954
+ queries: rest[0],
3955
+ search: rest[1]
3956
+ };
3957
+ }
3958
+ const teamId = params.teamId;
3959
+ const queries = params.queries;
3960
+ const search = params.search;
3340
3961
  if (typeof teamId === 'undefined') {
3341
3962
  throw new AppwriteException('Missing required parameter: "teamId"');
3342
3963
  }
@@ -3351,40 +3972,29 @@ class Teams extends Service {
3351
3972
  const uri = new URL(this.client.config.endpoint + apiPath);
3352
3973
  return this.client.call('get', uri, {}, payload);
3353
3974
  }
3354
- /**
3355
- * Invite a new member to join your team. Provide an ID for existing users, or
3356
- * invite unregistered users using an email or phone number. If initiated from
3357
- * a Client SDK, Appwrite will send an email or sms with a link to join the
3358
- * team to the invited user, and an account will be created for them if one
3359
- * doesn't exist. If initiated from a Server SDK, the new member will be added
3360
- * automatically to the team.
3361
- *
3362
- * You only need to provide one of a user ID, email, or phone number. Appwrite
3363
- * will prioritize accepting the user ID > email > phone number if you provide
3364
- * more than one of these parameters.
3365
- *
3366
- * Use the `url` parameter to redirect the user from the invitation email to
3367
- * your app. After the user is redirected, use the [Update Team Membership
3368
- * Status](https://appwrite.io/docs/references/cloud/client-web/teams#updateMembershipStatus)
3369
- * endpoint to allow the user to accept the invitation to the team.
3370
- *
3371
- * Please note that to avoid a [Redirect
3372
- * Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md)
3373
- * Appwrite will accept the only redirect URLs under the domains you have
3374
- * added as a platform on the Appwrite Console.
3375
- *
3376
- *
3377
- * @param {string} teamId
3378
- * @param {string[]} roles
3379
- * @param {string} email
3380
- * @param {string} userId
3381
- * @param {string} phone
3382
- * @param {string} url
3383
- * @param {string} name
3384
- * @throws {AppwriteException}
3385
- * @returns {Promise}
3386
- */
3387
- createMembership(teamId, roles, email, userId, phone, url, name) {
3975
+ createMembership(paramsOrFirst, ...rest) {
3976
+ let params;
3977
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
3978
+ params = (paramsOrFirst || {});
3979
+ }
3980
+ else {
3981
+ params = {
3982
+ teamId: paramsOrFirst,
3983
+ roles: rest[0],
3984
+ email: rest[1],
3985
+ userId: rest[2],
3986
+ phone: rest[3],
3987
+ url: rest[4],
3988
+ name: rest[5]
3989
+ };
3990
+ }
3991
+ const teamId = params.teamId;
3992
+ const roles = params.roles;
3993
+ const email = params.email;
3994
+ const userId = params.userId;
3995
+ const phone = params.phone;
3996
+ const url = params.url;
3997
+ const name = params.name;
3388
3998
  if (typeof teamId === 'undefined') {
3389
3999
  throw new AppwriteException('Missing required parameter: "teamId"');
3390
4000
  }
@@ -3416,17 +4026,19 @@ class Teams extends Service {
3416
4026
  'content-type': 'application/json',
3417
4027
  }, payload);
3418
4028
  }
3419
- /**
3420
- * Get a team member by the membership unique id. All team members have read
3421
- * access for this resource. Hide sensitive attributes from the response by
3422
- * toggling membership privacy in the Console.
3423
- *
3424
- * @param {string} teamId
3425
- * @param {string} membershipId
3426
- * @throws {AppwriteException}
3427
- * @returns {Promise}
3428
- */
3429
- getMembership(teamId, membershipId) {
4029
+ getMembership(paramsOrFirst, ...rest) {
4030
+ let params;
4031
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
4032
+ params = (paramsOrFirst || {});
4033
+ }
4034
+ else {
4035
+ params = {
4036
+ teamId: paramsOrFirst,
4037
+ membershipId: rest[0]
4038
+ };
4039
+ }
4040
+ const teamId = params.teamId;
4041
+ const membershipId = params.membershipId;
3430
4042
  if (typeof teamId === 'undefined') {
3431
4043
  throw new AppwriteException('Missing required parameter: "teamId"');
3432
4044
  }
@@ -3438,19 +4050,21 @@ class Teams extends Service {
3438
4050
  const uri = new URL(this.client.config.endpoint + apiPath);
3439
4051
  return this.client.call('get', uri, {}, payload);
3440
4052
  }
3441
- /**
3442
- * Modify the roles of a team member. Only team members with the owner role
3443
- * have access to this endpoint. Learn more about [roles and
3444
- * permissions](https://appwrite.io/docs/permissions).
3445
- *
3446
- *
3447
- * @param {string} teamId
3448
- * @param {string} membershipId
3449
- * @param {string[]} roles
3450
- * @throws {AppwriteException}
3451
- * @returns {Promise}
3452
- */
3453
- updateMembership(teamId, membershipId, roles) {
4053
+ updateMembership(paramsOrFirst, ...rest) {
4054
+ let params;
4055
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
4056
+ params = (paramsOrFirst || {});
4057
+ }
4058
+ else {
4059
+ params = {
4060
+ teamId: paramsOrFirst,
4061
+ membershipId: rest[0],
4062
+ roles: rest[1]
4063
+ };
4064
+ }
4065
+ const teamId = params.teamId;
4066
+ const membershipId = params.membershipId;
4067
+ const roles = params.roles;
3454
4068
  if (typeof teamId === 'undefined') {
3455
4069
  throw new AppwriteException('Missing required parameter: "teamId"');
3456
4070
  }
@@ -3470,17 +4084,19 @@ class Teams extends Service {
3470
4084
  'content-type': 'application/json',
3471
4085
  }, payload);
3472
4086
  }
3473
- /**
3474
- * This endpoint allows a user to leave a team or for a team owner to delete
3475
- * the membership of any other team member. You can also use this endpoint to
3476
- * delete a user membership even if it is not accepted.
3477
- *
3478
- * @param {string} teamId
3479
- * @param {string} membershipId
3480
- * @throws {AppwriteException}
3481
- * @returns {Promise}
3482
- */
3483
- deleteMembership(teamId, membershipId) {
4087
+ deleteMembership(paramsOrFirst, ...rest) {
4088
+ let params;
4089
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
4090
+ params = (paramsOrFirst || {});
4091
+ }
4092
+ else {
4093
+ params = {
4094
+ teamId: paramsOrFirst,
4095
+ membershipId: rest[0]
4096
+ };
4097
+ }
4098
+ const teamId = params.teamId;
4099
+ const membershipId = params.membershipId;
3484
4100
  if (typeof teamId === 'undefined') {
3485
4101
  throw new AppwriteException('Missing required parameter: "teamId"');
3486
4102
  }
@@ -3494,23 +4110,23 @@ class Teams extends Service {
3494
4110
  'content-type': 'application/json',
3495
4111
  }, payload);
3496
4112
  }
3497
- /**
3498
- * Use this endpoint to allow a user to accept an invitation to join a team
3499
- * after being redirected back to your app from the invitation email received
3500
- * by the user.
3501
- *
3502
- * If the request is successful, a session for the user is automatically
3503
- * created.
3504
- *
3505
- *
3506
- * @param {string} teamId
3507
- * @param {string} membershipId
3508
- * @param {string} userId
3509
- * @param {string} secret
3510
- * @throws {AppwriteException}
3511
- * @returns {Promise}
3512
- */
3513
- updateMembershipStatus(teamId, membershipId, userId, secret) {
4113
+ updateMembershipStatus(paramsOrFirst, ...rest) {
4114
+ let params;
4115
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
4116
+ params = (paramsOrFirst || {});
4117
+ }
4118
+ else {
4119
+ params = {
4120
+ teamId: paramsOrFirst,
4121
+ membershipId: rest[0],
4122
+ userId: rest[1],
4123
+ secret: rest[2]
4124
+ };
4125
+ }
4126
+ const teamId = params.teamId;
4127
+ const membershipId = params.membershipId;
4128
+ const userId = params.userId;
4129
+ const secret = params.secret;
3514
4130
  if (typeof teamId === 'undefined') {
3515
4131
  throw new AppwriteException('Missing required parameter: "teamId"');
3516
4132
  }
@@ -3536,16 +4152,17 @@ class Teams extends Service {
3536
4152
  'content-type': 'application/json',
3537
4153
  }, payload);
3538
4154
  }
3539
- /**
3540
- * Get the team's shared preferences by its unique ID. If a preference doesn't
3541
- * need to be shared by all team members, prefer storing them in [user
3542
- * preferences](https://appwrite.io/docs/references/cloud/client-web/account#getPrefs).
3543
- *
3544
- * @param {string} teamId
3545
- * @throws {AppwriteException}
3546
- * @returns {Promise}
3547
- */
3548
- getPrefs(teamId) {
4155
+ getPrefs(paramsOrFirst) {
4156
+ let params;
4157
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
4158
+ params = (paramsOrFirst || {});
4159
+ }
4160
+ else {
4161
+ params = {
4162
+ teamId: paramsOrFirst
4163
+ };
4164
+ }
4165
+ const teamId = params.teamId;
3549
4166
  if (typeof teamId === 'undefined') {
3550
4167
  throw new AppwriteException('Missing required parameter: "teamId"');
3551
4168
  }
@@ -3554,17 +4171,19 @@ class Teams extends Service {
3554
4171
  const uri = new URL(this.client.config.endpoint + apiPath);
3555
4172
  return this.client.call('get', uri, {}, payload);
3556
4173
  }
3557
- /**
3558
- * Update the team's preferences by its unique ID. The object you pass is
3559
- * stored as is and replaces any previous value. The maximum allowed prefs
3560
- * size is 64kB and throws an error if exceeded.
3561
- *
3562
- * @param {string} teamId
3563
- * @param {object} prefs
3564
- * @throws {AppwriteException}
3565
- * @returns {Promise}
3566
- */
3567
- updatePrefs(teamId, prefs) {
4174
+ updatePrefs(paramsOrFirst, ...rest) {
4175
+ let params;
4176
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
4177
+ params = (paramsOrFirst || {});
4178
+ }
4179
+ else {
4180
+ params = {
4181
+ teamId: paramsOrFirst,
4182
+ prefs: rest[0]
4183
+ };
4184
+ }
4185
+ const teamId = params.teamId;
4186
+ const prefs = params.prefs;
3568
4187
  if (typeof teamId === 'undefined') {
3569
4188
  throw new AppwriteException('Missing required parameter: "teamId"');
3570
4189
  }
@@ -3623,7 +4242,84 @@ Query.cursorAfter = (documentId) => new Query("cursorAfter", undefined, document
3623
4242
  Query.cursorBefore = (documentId) => new Query("cursorBefore", undefined, documentId).toString();
3624
4243
  Query.limit = (limit) => new Query("limit", undefined, limit).toString();
3625
4244
  Query.offset = (offset) => new Query("offset", undefined, offset).toString();
4245
+ /**
4246
+ * Filter resources where attribute contains the specified value.
4247
+ *
4248
+ * @param {string} attribute
4249
+ * @param {string | string[]} value
4250
+ * @returns {string}
4251
+ */
3626
4252
  Query.contains = (attribute, value) => new Query("contains", attribute, value).toString();
4253
+ /**
4254
+ * Filter resources where attribute does not contain the specified value.
4255
+ *
4256
+ * @param {string} attribute
4257
+ * @param {string | string[]} value
4258
+ * @returns {string}
4259
+ */
4260
+ Query.notContains = (attribute, value) => new Query("notContains", attribute, value).toString();
4261
+ /**
4262
+ * Filter resources by searching attribute for value (inverse of search).
4263
+ * A fulltext index on attribute is required for this query to work.
4264
+ *
4265
+ * @param {string} attribute
4266
+ * @param {string} value
4267
+ * @returns {string}
4268
+ */
4269
+ Query.notSearch = (attribute, value) => new Query("notSearch", attribute, value).toString();
4270
+ /**
4271
+ * Filter resources where attribute is not between start and end (exclusive).
4272
+ *
4273
+ * @param {string} attribute
4274
+ * @param {string | number} start
4275
+ * @param {string | number} end
4276
+ * @returns {string}
4277
+ */
4278
+ Query.notBetween = (attribute, start, end) => new Query("notBetween", attribute, [start, end]).toString();
4279
+ /**
4280
+ * Filter resources where attribute does not start with value.
4281
+ *
4282
+ * @param {string} attribute
4283
+ * @param {string} value
4284
+ * @returns {string}
4285
+ */
4286
+ Query.notStartsWith = (attribute, value) => new Query("notStartsWith", attribute, value).toString();
4287
+ /**
4288
+ * Filter resources where attribute does not end with value.
4289
+ *
4290
+ * @param {string} attribute
4291
+ * @param {string} value
4292
+ * @returns {string}
4293
+ */
4294
+ Query.notEndsWith = (attribute, value) => new Query("notEndsWith", attribute, value).toString();
4295
+ /**
4296
+ * Filter resources where document was created before date.
4297
+ *
4298
+ * @param {string} value
4299
+ * @returns {string}
4300
+ */
4301
+ Query.createdBefore = (value) => new Query("createdBefore", undefined, value).toString();
4302
+ /**
4303
+ * Filter resources where document was created after date.
4304
+ *
4305
+ * @param {string} value
4306
+ * @returns {string}
4307
+ */
4308
+ Query.createdAfter = (value) => new Query("createdAfter", undefined, value).toString();
4309
+ /**
4310
+ * Filter resources where document was updated before date.
4311
+ *
4312
+ * @param {string} value
4313
+ * @returns {string}
4314
+ */
4315
+ Query.updatedBefore = (value) => new Query("updatedBefore", undefined, value).toString();
4316
+ /**
4317
+ * Filter resources where document was updated after date.
4318
+ *
4319
+ * @param {string} value
4320
+ * @returns {string}
4321
+ */
4322
+ Query.updatedAfter = (value) => new Query("updatedAfter", undefined, value).toString();
3627
4323
  Query.or = (queries) => new Query("or", undefined, queries.map((query) => JSON.parse(query))).toString();
3628
4324
  Query.and = (queries) => new Query("and", undefined, queries.map((query) => JSON.parse(query))).toString();
3629
4325
 
@@ -4093,5 +4789,5 @@ var ImageFormat;
4093
4789
  ImageFormat["Gif"] = "gif";
4094
4790
  })(ImageFormat || (ImageFormat = {}));
4095
4791
 
4096
- export { Account, AppwriteException, AuthenticationFactor, AuthenticatorType, Avatars, Browser, Client, CreditCard, Databases, ExecutionMethod, Flag, Functions, Graphql, ID, ImageFormat, ImageGravity, Locale, Messaging, OAuthProvider, Permission, Query, Role, Storage, Teams };
4792
+ export { Account, AppwriteException, AuthenticationFactor, AuthenticatorType, Avatars, Browser, Client, CreditCard, Databases, ExecutionMethod, Flag, Functions, Graphql, ID, ImageFormat, ImageGravity, Locale, Messaging, OAuthProvider, Permission, Query, Role, Storage, TablesDB, Teams };
4097
4793
  //# sourceMappingURL=sdk.js.map