node-appwrite 8.2.0 → 9.0.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 (30) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +2 -2
  3. package/docs/examples/account/update-password.md +1 -1
  4. package/docs/examples/databases/create-relationship-attribute.md +20 -0
  5. package/docs/examples/databases/update-boolean-attribute.md +20 -0
  6. package/docs/examples/databases/update-datetime-attribute.md +20 -0
  7. package/docs/examples/databases/update-email-attribute.md +20 -0
  8. package/docs/examples/databases/update-enum-attribute.md +20 -0
  9. package/docs/examples/databases/update-float-attribute.md +20 -0
  10. package/docs/examples/databases/update-integer-attribute.md +20 -0
  11. package/docs/examples/databases/update-ip-attribute.md +20 -0
  12. package/docs/examples/databases/update-relationship-attribute.md +20 -0
  13. package/docs/examples/databases/update-string-attribute.md +20 -0
  14. package/docs/examples/databases/update-url-attribute.md +20 -0
  15. package/docs/examples/functions/create.md +1 -1
  16. package/docs/examples/functions/update.md +1 -1
  17. package/docs/examples/teams/create-membership.md +1 -1
  18. package/docs/examples/teams/get-prefs.md +20 -0
  19. package/docs/examples/teams/{update.md → update-name.md} +1 -1
  20. package/docs/examples/teams/update-prefs.md +20 -0
  21. package/docs/examples/users/update-password.md +1 -1
  22. package/index.d.ts +334 -112
  23. package/lib/client.js +2 -1
  24. package/lib/inputFile.js +6 -8
  25. package/lib/query.js +18 -0
  26. package/lib/services/databases.js +720 -104
  27. package/lib/services/functions.js +45 -45
  28. package/lib/services/storage.js +43 -35
  29. package/lib/services/teams.js +87 -19
  30. package/package.json +6 -4
@@ -429,6 +429,54 @@ class Databases extends Service {
429
429
  }, payload);
430
430
  }
431
431
 
432
+ /**
433
+ * Update Boolean Attribute
434
+ *
435
+ * @param {string} databaseId
436
+ * @param {string} collectionId
437
+ * @param {string} key
438
+ * @param {boolean} required
439
+ * @param {boolean} xdefault
440
+ * @throws {AppwriteException}
441
+ * @returns {Promise}
442
+ */
443
+ async updateBooleanAttribute(databaseId, collectionId, key, required, xdefault) {
444
+ let path = '/databases/{databaseId}/collections/{collectionId}/attributes/boolean/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key);
445
+ let payload = {};
446
+ if (typeof databaseId === 'undefined') {
447
+ throw new AppwriteException('Missing required parameter: "databaseId"');
448
+ }
449
+
450
+ if (typeof collectionId === 'undefined') {
451
+ throw new AppwriteException('Missing required parameter: "collectionId"');
452
+ }
453
+
454
+ if (typeof key === 'undefined') {
455
+ throw new AppwriteException('Missing required parameter: "key"');
456
+ }
457
+
458
+ if (typeof required === 'undefined') {
459
+ throw new AppwriteException('Missing required parameter: "required"');
460
+ }
461
+
462
+ if (typeof xdefault === 'undefined') {
463
+ throw new AppwriteException('Missing required parameter: "xdefault"');
464
+ }
465
+
466
+
467
+ if (typeof required !== 'undefined') {
468
+ payload['required'] = required;
469
+ }
470
+
471
+ if (typeof xdefault !== 'undefined') {
472
+ payload['default'] = xdefault;
473
+ }
474
+
475
+ return await this.client.call('patch', path, {
476
+ 'content-type': 'application/json',
477
+ }, payload);
478
+ }
479
+
432
480
  /**
433
481
  * Create DateTime Attribute
434
482
  *
@@ -436,13 +484,488 @@ class Databases extends Service {
436
484
  * @param {string} collectionId
437
485
  * @param {string} key
438
486
  * @param {boolean} required
439
- * @param {string} xdefault
487
+ * @param {string} xdefault
488
+ * @param {boolean} array
489
+ * @throws {AppwriteException}
490
+ * @returns {Promise}
491
+ */
492
+ async createDatetimeAttribute(databaseId, collectionId, key, required, xdefault, array) {
493
+ let path = '/databases/{databaseId}/collections/{collectionId}/attributes/datetime'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
494
+ let payload = {};
495
+ if (typeof databaseId === 'undefined') {
496
+ throw new AppwriteException('Missing required parameter: "databaseId"');
497
+ }
498
+
499
+ if (typeof collectionId === 'undefined') {
500
+ throw new AppwriteException('Missing required parameter: "collectionId"');
501
+ }
502
+
503
+ if (typeof key === 'undefined') {
504
+ throw new AppwriteException('Missing required parameter: "key"');
505
+ }
506
+
507
+ if (typeof required === 'undefined') {
508
+ throw new AppwriteException('Missing required parameter: "required"');
509
+ }
510
+
511
+
512
+ if (typeof key !== 'undefined') {
513
+ payload['key'] = key;
514
+ }
515
+
516
+ if (typeof required !== 'undefined') {
517
+ payload['required'] = required;
518
+ }
519
+
520
+ if (typeof xdefault !== 'undefined') {
521
+ payload['default'] = xdefault;
522
+ }
523
+
524
+ if (typeof array !== 'undefined') {
525
+ payload['array'] = array;
526
+ }
527
+
528
+ return await this.client.call('post', path, {
529
+ 'content-type': 'application/json',
530
+ }, payload);
531
+ }
532
+
533
+ /**
534
+ * Update DateTime Attribute
535
+ *
536
+ * @param {string} databaseId
537
+ * @param {string} collectionId
538
+ * @param {string} key
539
+ * @param {boolean} required
540
+ * @param {string} xdefault
541
+ * @throws {AppwriteException}
542
+ * @returns {Promise}
543
+ */
544
+ async updateDatetimeAttribute(databaseId, collectionId, key, required, xdefault) {
545
+ let path = '/databases/{databaseId}/collections/{collectionId}/attributes/datetime/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key);
546
+ let payload = {};
547
+ if (typeof databaseId === 'undefined') {
548
+ throw new AppwriteException('Missing required parameter: "databaseId"');
549
+ }
550
+
551
+ if (typeof collectionId === 'undefined') {
552
+ throw new AppwriteException('Missing required parameter: "collectionId"');
553
+ }
554
+
555
+ if (typeof key === 'undefined') {
556
+ throw new AppwriteException('Missing required parameter: "key"');
557
+ }
558
+
559
+ if (typeof required === 'undefined') {
560
+ throw new AppwriteException('Missing required parameter: "required"');
561
+ }
562
+
563
+ if (typeof xdefault === 'undefined') {
564
+ throw new AppwriteException('Missing required parameter: "xdefault"');
565
+ }
566
+
567
+
568
+ if (typeof required !== 'undefined') {
569
+ payload['required'] = required;
570
+ }
571
+
572
+ if (typeof xdefault !== 'undefined') {
573
+ payload['default'] = xdefault;
574
+ }
575
+
576
+ return await this.client.call('patch', path, {
577
+ 'content-type': 'application/json',
578
+ }, payload);
579
+ }
580
+
581
+ /**
582
+ * Create Email Attribute
583
+ *
584
+ * Create an email attribute.
585
+ *
586
+ *
587
+ * @param {string} databaseId
588
+ * @param {string} collectionId
589
+ * @param {string} key
590
+ * @param {boolean} required
591
+ * @param {string} xdefault
592
+ * @param {boolean} array
593
+ * @throws {AppwriteException}
594
+ * @returns {Promise}
595
+ */
596
+ async createEmailAttribute(databaseId, collectionId, key, required, xdefault, array) {
597
+ let path = '/databases/{databaseId}/collections/{collectionId}/attributes/email'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
598
+ let payload = {};
599
+ if (typeof databaseId === 'undefined') {
600
+ throw new AppwriteException('Missing required parameter: "databaseId"');
601
+ }
602
+
603
+ if (typeof collectionId === 'undefined') {
604
+ throw new AppwriteException('Missing required parameter: "collectionId"');
605
+ }
606
+
607
+ if (typeof key === 'undefined') {
608
+ throw new AppwriteException('Missing required parameter: "key"');
609
+ }
610
+
611
+ if (typeof required === 'undefined') {
612
+ throw new AppwriteException('Missing required parameter: "required"');
613
+ }
614
+
615
+
616
+ if (typeof key !== 'undefined') {
617
+ payload['key'] = key;
618
+ }
619
+
620
+ if (typeof required !== 'undefined') {
621
+ payload['required'] = required;
622
+ }
623
+
624
+ if (typeof xdefault !== 'undefined') {
625
+ payload['default'] = xdefault;
626
+ }
627
+
628
+ if (typeof array !== 'undefined') {
629
+ payload['array'] = array;
630
+ }
631
+
632
+ return await this.client.call('post', path, {
633
+ 'content-type': 'application/json',
634
+ }, payload);
635
+ }
636
+
637
+ /**
638
+ * Update Email Attribute
639
+ *
640
+ * Update an email attribute. Changing the `default` value will not update
641
+ * already existing documents.
642
+ *
643
+ *
644
+ * @param {string} databaseId
645
+ * @param {string} collectionId
646
+ * @param {string} key
647
+ * @param {boolean} required
648
+ * @param {string} xdefault
649
+ * @throws {AppwriteException}
650
+ * @returns {Promise}
651
+ */
652
+ async updateEmailAttribute(databaseId, collectionId, key, required, xdefault) {
653
+ let path = '/databases/{databaseId}/collections/{collectionId}/attributes/email/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key);
654
+ let payload = {};
655
+ if (typeof databaseId === 'undefined') {
656
+ throw new AppwriteException('Missing required parameter: "databaseId"');
657
+ }
658
+
659
+ if (typeof collectionId === 'undefined') {
660
+ throw new AppwriteException('Missing required parameter: "collectionId"');
661
+ }
662
+
663
+ if (typeof key === 'undefined') {
664
+ throw new AppwriteException('Missing required parameter: "key"');
665
+ }
666
+
667
+ if (typeof required === 'undefined') {
668
+ throw new AppwriteException('Missing required parameter: "required"');
669
+ }
670
+
671
+ if (typeof xdefault === 'undefined') {
672
+ throw new AppwriteException('Missing required parameter: "xdefault"');
673
+ }
674
+
675
+
676
+ if (typeof required !== 'undefined') {
677
+ payload['required'] = required;
678
+ }
679
+
680
+ if (typeof xdefault !== 'undefined') {
681
+ payload['default'] = xdefault;
682
+ }
683
+
684
+ return await this.client.call('patch', path, {
685
+ 'content-type': 'application/json',
686
+ }, payload);
687
+ }
688
+
689
+ /**
690
+ * Create Enum Attribute
691
+ *
692
+ * @param {string} databaseId
693
+ * @param {string} collectionId
694
+ * @param {string} key
695
+ * @param {string[]} elements
696
+ * @param {boolean} required
697
+ * @param {string} xdefault
698
+ * @param {boolean} array
699
+ * @throws {AppwriteException}
700
+ * @returns {Promise}
701
+ */
702
+ async createEnumAttribute(databaseId, collectionId, key, elements, required, xdefault, array) {
703
+ let path = '/databases/{databaseId}/collections/{collectionId}/attributes/enum'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
704
+ let payload = {};
705
+ if (typeof databaseId === 'undefined') {
706
+ throw new AppwriteException('Missing required parameter: "databaseId"');
707
+ }
708
+
709
+ if (typeof collectionId === 'undefined') {
710
+ throw new AppwriteException('Missing required parameter: "collectionId"');
711
+ }
712
+
713
+ if (typeof key === 'undefined') {
714
+ throw new AppwriteException('Missing required parameter: "key"');
715
+ }
716
+
717
+ if (typeof elements === 'undefined') {
718
+ throw new AppwriteException('Missing required parameter: "elements"');
719
+ }
720
+
721
+ if (typeof required === 'undefined') {
722
+ throw new AppwriteException('Missing required parameter: "required"');
723
+ }
724
+
725
+
726
+ if (typeof key !== 'undefined') {
727
+ payload['key'] = key;
728
+ }
729
+
730
+ if (typeof elements !== 'undefined') {
731
+ payload['elements'] = elements;
732
+ }
733
+
734
+ if (typeof required !== 'undefined') {
735
+ payload['required'] = required;
736
+ }
737
+
738
+ if (typeof xdefault !== 'undefined') {
739
+ payload['default'] = xdefault;
740
+ }
741
+
742
+ if (typeof array !== 'undefined') {
743
+ payload['array'] = array;
744
+ }
745
+
746
+ return await this.client.call('post', path, {
747
+ 'content-type': 'application/json',
748
+ }, payload);
749
+ }
750
+
751
+ /**
752
+ * Update Enum Attribute
753
+ *
754
+ * Update an enum attribute. Changing the `default` value will not update
755
+ * already existing documents.
756
+ *
757
+ *
758
+ * @param {string} databaseId
759
+ * @param {string} collectionId
760
+ * @param {string} key
761
+ * @param {string[]} elements
762
+ * @param {boolean} required
763
+ * @param {string} xdefault
764
+ * @throws {AppwriteException}
765
+ * @returns {Promise}
766
+ */
767
+ async updateEnumAttribute(databaseId, collectionId, key, elements, required, xdefault) {
768
+ let path = '/databases/{databaseId}/collections/{collectionId}/attributes/enum/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key);
769
+ let payload = {};
770
+ if (typeof databaseId === 'undefined') {
771
+ throw new AppwriteException('Missing required parameter: "databaseId"');
772
+ }
773
+
774
+ if (typeof collectionId === 'undefined') {
775
+ throw new AppwriteException('Missing required parameter: "collectionId"');
776
+ }
777
+
778
+ if (typeof key === 'undefined') {
779
+ throw new AppwriteException('Missing required parameter: "key"');
780
+ }
781
+
782
+ if (typeof elements === 'undefined') {
783
+ throw new AppwriteException('Missing required parameter: "elements"');
784
+ }
785
+
786
+ if (typeof required === 'undefined') {
787
+ throw new AppwriteException('Missing required parameter: "required"');
788
+ }
789
+
790
+ if (typeof xdefault === 'undefined') {
791
+ throw new AppwriteException('Missing required parameter: "xdefault"');
792
+ }
793
+
794
+
795
+ if (typeof elements !== 'undefined') {
796
+ payload['elements'] = elements;
797
+ }
798
+
799
+ if (typeof required !== 'undefined') {
800
+ payload['required'] = required;
801
+ }
802
+
803
+ if (typeof xdefault !== 'undefined') {
804
+ payload['default'] = xdefault;
805
+ }
806
+
807
+ return await this.client.call('patch', path, {
808
+ 'content-type': 'application/json',
809
+ }, payload);
810
+ }
811
+
812
+ /**
813
+ * Create Float Attribute
814
+ *
815
+ * Create a float attribute. Optionally, minimum and maximum values can be
816
+ * provided.
817
+ *
818
+ *
819
+ * @param {string} databaseId
820
+ * @param {string} collectionId
821
+ * @param {string} key
822
+ * @param {boolean} required
823
+ * @param {number} min
824
+ * @param {number} max
825
+ * @param {number} xdefault
826
+ * @param {boolean} array
827
+ * @throws {AppwriteException}
828
+ * @returns {Promise}
829
+ */
830
+ async createFloatAttribute(databaseId, collectionId, key, required, min, max, xdefault, array) {
831
+ let path = '/databases/{databaseId}/collections/{collectionId}/attributes/float'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
832
+ let payload = {};
833
+ if (typeof databaseId === 'undefined') {
834
+ throw new AppwriteException('Missing required parameter: "databaseId"');
835
+ }
836
+
837
+ if (typeof collectionId === 'undefined') {
838
+ throw new AppwriteException('Missing required parameter: "collectionId"');
839
+ }
840
+
841
+ if (typeof key === 'undefined') {
842
+ throw new AppwriteException('Missing required parameter: "key"');
843
+ }
844
+
845
+ if (typeof required === 'undefined') {
846
+ throw new AppwriteException('Missing required parameter: "required"');
847
+ }
848
+
849
+
850
+ if (typeof key !== 'undefined') {
851
+ payload['key'] = key;
852
+ }
853
+
854
+ if (typeof required !== 'undefined') {
855
+ payload['required'] = required;
856
+ }
857
+
858
+ if (typeof min !== 'undefined') {
859
+ payload['min'] = min;
860
+ }
861
+
862
+ if (typeof max !== 'undefined') {
863
+ payload['max'] = max;
864
+ }
865
+
866
+ if (typeof xdefault !== 'undefined') {
867
+ payload['default'] = xdefault;
868
+ }
869
+
870
+ if (typeof array !== 'undefined') {
871
+ payload['array'] = array;
872
+ }
873
+
874
+ return await this.client.call('post', path, {
875
+ 'content-type': 'application/json',
876
+ }, payload);
877
+ }
878
+
879
+ /**
880
+ * Update Float Attribute
881
+ *
882
+ * Update a float attribute. Changing the `default` value will not update
883
+ * already existing documents.
884
+ *
885
+ *
886
+ * @param {string} databaseId
887
+ * @param {string} collectionId
888
+ * @param {string} key
889
+ * @param {boolean} required
890
+ * @param {number} min
891
+ * @param {number} max
892
+ * @param {number} xdefault
893
+ * @throws {AppwriteException}
894
+ * @returns {Promise}
895
+ */
896
+ async updateFloatAttribute(databaseId, collectionId, key, required, min, max, xdefault) {
897
+ let path = '/databases/{databaseId}/collections/{collectionId}/attributes/float/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key);
898
+ let payload = {};
899
+ if (typeof databaseId === 'undefined') {
900
+ throw new AppwriteException('Missing required parameter: "databaseId"');
901
+ }
902
+
903
+ if (typeof collectionId === 'undefined') {
904
+ throw new AppwriteException('Missing required parameter: "collectionId"');
905
+ }
906
+
907
+ if (typeof key === 'undefined') {
908
+ throw new AppwriteException('Missing required parameter: "key"');
909
+ }
910
+
911
+ if (typeof required === 'undefined') {
912
+ throw new AppwriteException('Missing required parameter: "required"');
913
+ }
914
+
915
+ if (typeof min === 'undefined') {
916
+ throw new AppwriteException('Missing required parameter: "min"');
917
+ }
918
+
919
+ if (typeof max === 'undefined') {
920
+ throw new AppwriteException('Missing required parameter: "max"');
921
+ }
922
+
923
+ if (typeof xdefault === 'undefined') {
924
+ throw new AppwriteException('Missing required parameter: "xdefault"');
925
+ }
926
+
927
+
928
+ if (typeof required !== 'undefined') {
929
+ payload['required'] = required;
930
+ }
931
+
932
+ if (typeof min !== 'undefined') {
933
+ payload['min'] = min;
934
+ }
935
+
936
+ if (typeof max !== 'undefined') {
937
+ payload['max'] = max;
938
+ }
939
+
940
+ if (typeof xdefault !== 'undefined') {
941
+ payload['default'] = xdefault;
942
+ }
943
+
944
+ return await this.client.call('patch', path, {
945
+ 'content-type': 'application/json',
946
+ }, payload);
947
+ }
948
+
949
+ /**
950
+ * Create Integer Attribute
951
+ *
952
+ * Create an integer attribute. Optionally, minimum and maximum values can be
953
+ * provided.
954
+ *
955
+ *
956
+ * @param {string} databaseId
957
+ * @param {string} collectionId
958
+ * @param {string} key
959
+ * @param {boolean} required
960
+ * @param {number} min
961
+ * @param {number} max
962
+ * @param {number} xdefault
440
963
  * @param {boolean} array
441
964
  * @throws {AppwriteException}
442
965
  * @returns {Promise}
443
966
  */
444
- async createDatetimeAttribute(databaseId, collectionId, key, required, xdefault, array) {
445
- let path = '/databases/{databaseId}/collections/{collectionId}/attributes/datetime'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
967
+ async createIntegerAttribute(databaseId, collectionId, key, required, min, max, xdefault, array) {
968
+ let path = '/databases/{databaseId}/collections/{collectionId}/attributes/integer'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
446
969
  let payload = {};
447
970
  if (typeof databaseId === 'undefined') {
448
971
  throw new AppwriteException('Missing required parameter: "databaseId"');
@@ -469,6 +992,14 @@ class Databases extends Service {
469
992
  payload['required'] = required;
470
993
  }
471
994
 
995
+ if (typeof min !== 'undefined') {
996
+ payload['min'] = min;
997
+ }
998
+
999
+ if (typeof max !== 'undefined') {
1000
+ payload['max'] = max;
1001
+ }
1002
+
472
1003
  if (typeof xdefault !== 'undefined') {
473
1004
  payload['default'] = xdefault;
474
1005
  }
@@ -483,22 +1014,24 @@ class Databases extends Service {
483
1014
  }
484
1015
 
485
1016
  /**
486
- * Create Email Attribute
1017
+ * Update Integer Attribute
487
1018
  *
488
- * Create an email attribute.
1019
+ * Update an integer attribute. Changing the `default` value will not update
1020
+ * already existing documents.
489
1021
  *
490
1022
  *
491
1023
  * @param {string} databaseId
492
1024
  * @param {string} collectionId
493
1025
  * @param {string} key
494
1026
  * @param {boolean} required
495
- * @param {string} xdefault
496
- * @param {boolean} array
1027
+ * @param {number} min
1028
+ * @param {number} max
1029
+ * @param {number} xdefault
497
1030
  * @throws {AppwriteException}
498
1031
  * @returns {Promise}
499
1032
  */
500
- async createEmailAttribute(databaseId, collectionId, key, required, xdefault, array) {
501
- let path = '/databases/{databaseId}/collections/{collectionId}/attributes/email'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
1033
+ async updateIntegerAttribute(databaseId, collectionId, key, required, min, max, xdefault) {
1034
+ let path = '/databases/{databaseId}/collections/{collectionId}/attributes/integer/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key);
502
1035
  let payload = {};
503
1036
  if (typeof databaseId === 'undefined') {
504
1037
  throw new AppwriteException('Missing required parameter: "databaseId"');
@@ -516,43 +1049,57 @@ class Databases extends Service {
516
1049
  throw new AppwriteException('Missing required parameter: "required"');
517
1050
  }
518
1051
 
1052
+ if (typeof min === 'undefined') {
1053
+ throw new AppwriteException('Missing required parameter: "min"');
1054
+ }
1055
+
1056
+ if (typeof max === 'undefined') {
1057
+ throw new AppwriteException('Missing required parameter: "max"');
1058
+ }
519
1059
 
520
- if (typeof key !== 'undefined') {
521
- payload['key'] = key;
1060
+ if (typeof xdefault === 'undefined') {
1061
+ throw new AppwriteException('Missing required parameter: "xdefault"');
522
1062
  }
523
1063
 
1064
+
524
1065
  if (typeof required !== 'undefined') {
525
1066
  payload['required'] = required;
526
1067
  }
527
1068
 
528
- if (typeof xdefault !== 'undefined') {
529
- payload['default'] = xdefault;
1069
+ if (typeof min !== 'undefined') {
1070
+ payload['min'] = min;
530
1071
  }
531
1072
 
532
- if (typeof array !== 'undefined') {
533
- payload['array'] = array;
1073
+ if (typeof max !== 'undefined') {
1074
+ payload['max'] = max;
534
1075
  }
535
1076
 
536
- return await this.client.call('post', path, {
1077
+ if (typeof xdefault !== 'undefined') {
1078
+ payload['default'] = xdefault;
1079
+ }
1080
+
1081
+ return await this.client.call('patch', path, {
537
1082
  'content-type': 'application/json',
538
1083
  }, payload);
539
1084
  }
540
1085
 
541
1086
  /**
542
- * Create Enum Attribute
1087
+ * Create IP Address Attribute
1088
+ *
1089
+ * Create IP address attribute.
1090
+ *
543
1091
  *
544
1092
  * @param {string} databaseId
545
1093
  * @param {string} collectionId
546
1094
  * @param {string} key
547
- * @param {string[]} elements
548
1095
  * @param {boolean} required
549
1096
  * @param {string} xdefault
550
1097
  * @param {boolean} array
551
1098
  * @throws {AppwriteException}
552
1099
  * @returns {Promise}
553
1100
  */
554
- async createEnumAttribute(databaseId, collectionId, key, elements, required, xdefault, array) {
555
- let path = '/databases/{databaseId}/collections/{collectionId}/attributes/enum'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
1101
+ async createIpAttribute(databaseId, collectionId, key, required, xdefault, array) {
1102
+ let path = '/databases/{databaseId}/collections/{collectionId}/attributes/ip'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
556
1103
  let payload = {};
557
1104
  if (typeof databaseId === 'undefined') {
558
1105
  throw new AppwriteException('Missing required parameter: "databaseId"');
@@ -566,10 +1113,6 @@ class Databases extends Service {
566
1113
  throw new AppwriteException('Missing required parameter: "key"');
567
1114
  }
568
1115
 
569
- if (typeof elements === 'undefined') {
570
- throw new AppwriteException('Missing required parameter: "elements"');
571
- }
572
-
573
1116
  if (typeof required === 'undefined') {
574
1117
  throw new AppwriteException('Missing required parameter: "required"');
575
1118
  }
@@ -579,10 +1122,6 @@ class Databases extends Service {
579
1122
  payload['key'] = key;
580
1123
  }
581
1124
 
582
- if (typeof elements !== 'undefined') {
583
- payload['elements'] = elements;
584
- }
585
-
586
1125
  if (typeof required !== 'undefined') {
587
1126
  payload['required'] = required;
588
1127
  }
@@ -601,25 +1140,22 @@ class Databases extends Service {
601
1140
  }
602
1141
 
603
1142
  /**
604
- * Create Float Attribute
1143
+ * Update IP Address Attribute
605
1144
  *
606
- * Create a float attribute. Optionally, minimum and maximum values can be
607
- * provided.
1145
+ * Update an ip attribute. Changing the `default` value will not update
1146
+ * already existing documents.
608
1147
  *
609
1148
  *
610
1149
  * @param {string} databaseId
611
1150
  * @param {string} collectionId
612
1151
  * @param {string} key
613
1152
  * @param {boolean} required
614
- * @param {number} min
615
- * @param {number} max
616
- * @param {number} xdefault
617
- * @param {boolean} array
1153
+ * @param {string} xdefault
618
1154
  * @throws {AppwriteException}
619
1155
  * @returns {Promise}
620
1156
  */
621
- async createFloatAttribute(databaseId, collectionId, key, required, min, max, xdefault, array) {
622
- let path = '/databases/{databaseId}/collections/{collectionId}/attributes/float'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
1157
+ async updateIpAttribute(databaseId, collectionId, key, required, xdefault) {
1158
+ let path = '/databases/{databaseId}/collections/{collectionId}/attributes/ip/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key);
623
1159
  let payload = {};
624
1160
  if (typeof databaseId === 'undefined') {
625
1161
  throw new AppwriteException('Missing required parameter: "databaseId"');
@@ -637,29 +1173,84 @@ class Databases extends Service {
637
1173
  throw new AppwriteException('Missing required parameter: "required"');
638
1174
  }
639
1175
 
640
-
641
- if (typeof key !== 'undefined') {
642
- payload['key'] = key;
1176
+ if (typeof xdefault === 'undefined') {
1177
+ throw new AppwriteException('Missing required parameter: "xdefault"');
643
1178
  }
644
1179
 
1180
+
645
1181
  if (typeof required !== 'undefined') {
646
1182
  payload['required'] = required;
647
1183
  }
648
1184
 
649
- if (typeof min !== 'undefined') {
650
- payload['min'] = min;
1185
+ if (typeof xdefault !== 'undefined') {
1186
+ payload['default'] = xdefault;
651
1187
  }
652
1188
 
653
- if (typeof max !== 'undefined') {
654
- payload['max'] = max;
1189
+ return await this.client.call('patch', path, {
1190
+ 'content-type': 'application/json',
1191
+ }, payload);
1192
+ }
1193
+
1194
+ /**
1195
+ * Create Relationship Attribute
1196
+ *
1197
+ * Create relationship attribute. [Learn more about relationship
1198
+ * attributes](/docs/databases-relationships#relationship-attributes).
1199
+ *
1200
+ *
1201
+ * @param {string} databaseId
1202
+ * @param {string} collectionId
1203
+ * @param {string} relatedCollectionId
1204
+ * @param {string} type
1205
+ * @param {boolean} twoWay
1206
+ * @param {string} key
1207
+ * @param {string} twoWayKey
1208
+ * @param {string} onDelete
1209
+ * @throws {AppwriteException}
1210
+ * @returns {Promise}
1211
+ */
1212
+ async createRelationshipAttribute(databaseId, collectionId, relatedCollectionId, type, twoWay, key, twoWayKey, onDelete) {
1213
+ let path = '/databases/{databaseId}/collections/{collectionId}/attributes/relationship'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
1214
+ let payload = {};
1215
+ if (typeof databaseId === 'undefined') {
1216
+ throw new AppwriteException('Missing required parameter: "databaseId"');
655
1217
  }
656
1218
 
657
- if (typeof xdefault !== 'undefined') {
658
- payload['default'] = xdefault;
1219
+ if (typeof collectionId === 'undefined') {
1220
+ throw new AppwriteException('Missing required parameter: "collectionId"');
659
1221
  }
660
1222
 
661
- if (typeof array !== 'undefined') {
662
- payload['array'] = array;
1223
+ if (typeof relatedCollectionId === 'undefined') {
1224
+ throw new AppwriteException('Missing required parameter: "relatedCollectionId"');
1225
+ }
1226
+
1227
+ if (typeof type === 'undefined') {
1228
+ throw new AppwriteException('Missing required parameter: "type"');
1229
+ }
1230
+
1231
+
1232
+ if (typeof relatedCollectionId !== 'undefined') {
1233
+ payload['relatedCollectionId'] = relatedCollectionId;
1234
+ }
1235
+
1236
+ if (typeof type !== 'undefined') {
1237
+ payload['type'] = type;
1238
+ }
1239
+
1240
+ if (typeof twoWay !== 'undefined') {
1241
+ payload['twoWay'] = twoWay;
1242
+ }
1243
+
1244
+ if (typeof key !== 'undefined') {
1245
+ payload['key'] = key;
1246
+ }
1247
+
1248
+ if (typeof twoWayKey !== 'undefined') {
1249
+ payload['twoWayKey'] = twoWayKey;
1250
+ }
1251
+
1252
+ if (typeof onDelete !== 'undefined') {
1253
+ payload['onDelete'] = onDelete;
663
1254
  }
664
1255
 
665
1256
  return await this.client.call('post', path, {
@@ -668,25 +1259,23 @@ class Databases extends Service {
668
1259
  }
669
1260
 
670
1261
  /**
671
- * Create Integer Attribute
1262
+ * Create String Attribute
672
1263
  *
673
- * Create an integer attribute. Optionally, minimum and maximum values can be
674
- * provided.
1264
+ * Create a string attribute.
675
1265
  *
676
1266
  *
677
1267
  * @param {string} databaseId
678
1268
  * @param {string} collectionId
679
1269
  * @param {string} key
1270
+ * @param {number} size
680
1271
  * @param {boolean} required
681
- * @param {number} min
682
- * @param {number} max
683
- * @param {number} xdefault
1272
+ * @param {string} xdefault
684
1273
  * @param {boolean} array
685
1274
  * @throws {AppwriteException}
686
1275
  * @returns {Promise}
687
1276
  */
688
- async createIntegerAttribute(databaseId, collectionId, key, required, min, max, xdefault, array) {
689
- let path = '/databases/{databaseId}/collections/{collectionId}/attributes/integer'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
1277
+ async createStringAttribute(databaseId, collectionId, key, size, required, xdefault, array) {
1278
+ let path = '/databases/{databaseId}/collections/{collectionId}/attributes/string'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
690
1279
  let payload = {};
691
1280
  if (typeof databaseId === 'undefined') {
692
1281
  throw new AppwriteException('Missing required parameter: "databaseId"');
@@ -700,6 +1289,10 @@ class Databases extends Service {
700
1289
  throw new AppwriteException('Missing required parameter: "key"');
701
1290
  }
702
1291
 
1292
+ if (typeof size === 'undefined') {
1293
+ throw new AppwriteException('Missing required parameter: "size"');
1294
+ }
1295
+
703
1296
  if (typeof required === 'undefined') {
704
1297
  throw new AppwriteException('Missing required parameter: "required"');
705
1298
  }
@@ -709,16 +1302,12 @@ class Databases extends Service {
709
1302
  payload['key'] = key;
710
1303
  }
711
1304
 
712
- if (typeof required !== 'undefined') {
713
- payload['required'] = required;
714
- }
715
-
716
- if (typeof min !== 'undefined') {
717
- payload['min'] = min;
1305
+ if (typeof size !== 'undefined') {
1306
+ payload['size'] = size;
718
1307
  }
719
1308
 
720
- if (typeof max !== 'undefined') {
721
- payload['max'] = max;
1309
+ if (typeof required !== 'undefined') {
1310
+ payload['required'] = required;
722
1311
  }
723
1312
 
724
1313
  if (typeof xdefault !== 'undefined') {
@@ -735,9 +1324,10 @@ class Databases extends Service {
735
1324
  }
736
1325
 
737
1326
  /**
738
- * Create IP Address Attribute
1327
+ * Update String Attribute
739
1328
  *
740
- * Create IP address attribute.
1329
+ * Update a string attribute. Changing the `default` value will not update
1330
+ * already existing documents.
741
1331
  *
742
1332
  *
743
1333
  * @param {string} databaseId
@@ -745,12 +1335,11 @@ class Databases extends Service {
745
1335
  * @param {string} key
746
1336
  * @param {boolean} required
747
1337
  * @param {string} xdefault
748
- * @param {boolean} array
749
1338
  * @throws {AppwriteException}
750
1339
  * @returns {Promise}
751
1340
  */
752
- async createIpAttribute(databaseId, collectionId, key, required, xdefault, array) {
753
- let path = '/databases/{databaseId}/collections/{collectionId}/attributes/ip'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
1341
+ async updateStringAttribute(databaseId, collectionId, key, required, xdefault) {
1342
+ let path = '/databases/{databaseId}/collections/{collectionId}/attributes/string/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key);
754
1343
  let payload = {};
755
1344
  if (typeof databaseId === 'undefined') {
756
1345
  throw new AppwriteException('Missing required parameter: "databaseId"');
@@ -768,11 +1357,11 @@ class Databases extends Service {
768
1357
  throw new AppwriteException('Missing required parameter: "required"');
769
1358
  }
770
1359
 
771
-
772
- if (typeof key !== 'undefined') {
773
- payload['key'] = key;
1360
+ if (typeof xdefault === 'undefined') {
1361
+ throw new AppwriteException('Missing required parameter: "xdefault"');
774
1362
  }
775
1363
 
1364
+
776
1365
  if (typeof required !== 'undefined') {
777
1366
  payload['required'] = required;
778
1367
  }
@@ -781,33 +1370,28 @@ class Databases extends Service {
781
1370
  payload['default'] = xdefault;
782
1371
  }
783
1372
 
784
- if (typeof array !== 'undefined') {
785
- payload['array'] = array;
786
- }
787
-
788
- return await this.client.call('post', path, {
1373
+ return await this.client.call('patch', path, {
789
1374
  'content-type': 'application/json',
790
1375
  }, payload);
791
1376
  }
792
1377
 
793
1378
  /**
794
- * Create String Attribute
1379
+ * Create URL Attribute
795
1380
  *
796
- * Create a string attribute.
1381
+ * Create a URL attribute.
797
1382
  *
798
1383
  *
799
1384
  * @param {string} databaseId
800
1385
  * @param {string} collectionId
801
1386
  * @param {string} key
802
- * @param {number} size
803
1387
  * @param {boolean} required
804
1388
  * @param {string} xdefault
805
1389
  * @param {boolean} array
806
1390
  * @throws {AppwriteException}
807
1391
  * @returns {Promise}
808
1392
  */
809
- async createStringAttribute(databaseId, collectionId, key, size, required, xdefault, array) {
810
- let path = '/databases/{databaseId}/collections/{collectionId}/attributes/string'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
1393
+ async createUrlAttribute(databaseId, collectionId, key, required, xdefault, array) {
1394
+ let path = '/databases/{databaseId}/collections/{collectionId}/attributes/url'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
811
1395
  let payload = {};
812
1396
  if (typeof databaseId === 'undefined') {
813
1397
  throw new AppwriteException('Missing required parameter: "databaseId"');
@@ -821,10 +1405,6 @@ class Databases extends Service {
821
1405
  throw new AppwriteException('Missing required parameter: "key"');
822
1406
  }
823
1407
 
824
- if (typeof size === 'undefined') {
825
- throw new AppwriteException('Missing required parameter: "size"');
826
- }
827
-
828
1408
  if (typeof required === 'undefined') {
829
1409
  throw new AppwriteException('Missing required parameter: "required"');
830
1410
  }
@@ -834,10 +1414,6 @@ class Databases extends Service {
834
1414
  payload['key'] = key;
835
1415
  }
836
1416
 
837
- if (typeof size !== 'undefined') {
838
- payload['size'] = size;
839
- }
840
-
841
1417
  if (typeof required !== 'undefined') {
842
1418
  payload['required'] = required;
843
1419
  }
@@ -856,9 +1432,10 @@ class Databases extends Service {
856
1432
  }
857
1433
 
858
1434
  /**
859
- * Create URL Attribute
1435
+ * Update URL Attribute
860
1436
  *
861
- * Create a URL attribute.
1437
+ * Update an url attribute. Changing the `default` value will not update
1438
+ * already existing documents.
862
1439
  *
863
1440
  *
864
1441
  * @param {string} databaseId
@@ -866,12 +1443,11 @@ class Databases extends Service {
866
1443
  * @param {string} key
867
1444
  * @param {boolean} required
868
1445
  * @param {string} xdefault
869
- * @param {boolean} array
870
1446
  * @throws {AppwriteException}
871
1447
  * @returns {Promise}
872
1448
  */
873
- async createUrlAttribute(databaseId, collectionId, key, required, xdefault, array) {
874
- let path = '/databases/{databaseId}/collections/{collectionId}/attributes/url'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
1449
+ async updateUrlAttribute(databaseId, collectionId, key, required, xdefault) {
1450
+ let path = '/databases/{databaseId}/collections/{collectionId}/attributes/url/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key);
875
1451
  let payload = {};
876
1452
  if (typeof databaseId === 'undefined') {
877
1453
  throw new AppwriteException('Missing required parameter: "databaseId"');
@@ -889,11 +1465,11 @@ class Databases extends Service {
889
1465
  throw new AppwriteException('Missing required parameter: "required"');
890
1466
  }
891
1467
 
892
-
893
- if (typeof key !== 'undefined') {
894
- payload['key'] = key;
1468
+ if (typeof xdefault === 'undefined') {
1469
+ throw new AppwriteException('Missing required parameter: "xdefault"');
895
1470
  }
896
1471
 
1472
+
897
1473
  if (typeof required !== 'undefined') {
898
1474
  payload['required'] = required;
899
1475
  }
@@ -902,11 +1478,7 @@ class Databases extends Service {
902
1478
  payload['default'] = xdefault;
903
1479
  }
904
1480
 
905
- if (typeof array !== 'undefined') {
906
- payload['array'] = array;
907
- }
908
-
909
- return await this.client.call('post', path, {
1481
+ return await this.client.call('patch', path, {
910
1482
  'content-type': 'application/json',
911
1483
  }, payload);
912
1484
  }
@@ -971,6 +1543,45 @@ class Databases extends Service {
971
1543
  }, payload);
972
1544
  }
973
1545
 
1546
+ /**
1547
+ * Update Relationship Attribute
1548
+ *
1549
+ * Update relationship attribute. [Learn more about relationship
1550
+ * attributes](/docs/databases-relationships#relationship-attributes).
1551
+ *
1552
+ *
1553
+ * @param {string} databaseId
1554
+ * @param {string} collectionId
1555
+ * @param {string} key
1556
+ * @param {string} onDelete
1557
+ * @throws {AppwriteException}
1558
+ * @returns {Promise}
1559
+ */
1560
+ async updateRelationshipAttribute(databaseId, collectionId, key, onDelete) {
1561
+ let path = '/databases/{databaseId}/collections/{collectionId}/attributes/{key}/relationship'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key);
1562
+ let payload = {};
1563
+ if (typeof databaseId === 'undefined') {
1564
+ throw new AppwriteException('Missing required parameter: "databaseId"');
1565
+ }
1566
+
1567
+ if (typeof collectionId === 'undefined') {
1568
+ throw new AppwriteException('Missing required parameter: "collectionId"');
1569
+ }
1570
+
1571
+ if (typeof key === 'undefined') {
1572
+ throw new AppwriteException('Missing required parameter: "key"');
1573
+ }
1574
+
1575
+
1576
+ if (typeof onDelete !== 'undefined') {
1577
+ payload['onDelete'] = onDelete;
1578
+ }
1579
+
1580
+ return await this.client.call('patch', path, {
1581
+ 'content-type': 'application/json',
1582
+ }, payload);
1583
+ }
1584
+
974
1585
  /**
975
1586
  * List Documents
976
1587
  *
@@ -1066,10 +1677,11 @@ class Databases extends Service {
1066
1677
  * @param {string} databaseId
1067
1678
  * @param {string} collectionId
1068
1679
  * @param {string} documentId
1680
+ * @param {string[]} queries
1069
1681
  * @throws {AppwriteException}
1070
1682
  * @returns {Promise}
1071
1683
  */
1072
- async getDocument(databaseId, collectionId, documentId) {
1684
+ async getDocument(databaseId, collectionId, documentId, queries) {
1073
1685
  let path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId);
1074
1686
  let payload = {};
1075
1687
  if (typeof databaseId === 'undefined') {
@@ -1085,6 +1697,10 @@ class Databases extends Service {
1085
1697
  }
1086
1698
 
1087
1699
 
1700
+ if (typeof queries !== 'undefined') {
1701
+ payload['queries'] = queries;
1702
+ }
1703
+
1088
1704
  return await this.client.call('get', path, {
1089
1705
  'content-type': 'application/json',
1090
1706
  }, payload);