ncloudchat 0.0.19-beta → 0.0.20-beta
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.
- package/esm/CloudChat.d.ts +5 -1
- package/esm/CloudChat.js +138 -45
- package/esm/CloudChat.js.map +1 -1
- package/esm/Type.d.ts +0 -1
- package/esm/Type.js.map +1 -1
- package/esm/Util.d.ts +2 -0
- package/esm/Util.js +7 -0
- package/esm/Util.js.map +1 -0
- package/esm/mutations/channel.js +3 -7
- package/esm/mutations/channel.js.map +1 -1
- package/esm/mutations/message.d.ts +1 -1
- package/esm/mutations/message.js +2 -1
- package/esm/mutations/message.js.map +1 -1
- package/esm/queries/channel.d.ts +1 -1
- package/esm/queries/channel.js +16 -15
- package/esm/queries/channel.js.map +1 -1
- package/esm/queries/index.d.ts +1 -0
- package/esm/queries/index.js +1 -0
- package/esm/queries/index.js.map +1 -1
- package/esm/queries/member.d.ts +1 -0
- package/esm/queries/member.js +79 -0
- package/esm/queries/member.js.map +1 -0
- package/esm/queries/message.d.ts +1 -0
- package/esm/queries/message.js +38 -0
- package/esm/queries/message.js.map +1 -1
- package/esm/queries/project.js.map +1 -1
- package/esm/queries/subscription.d.ts +1 -1
- package/esm/queries/subscription.js +13 -10
- package/esm/queries/subscription.js.map +1 -1
- package/lib/CloudChat.js +204 -47
- package/lib/Util.js +18 -0
- package/lib/mutations/channel.js +3 -7
- package/lib/mutations/message.js +2 -1
- package/lib/queries/channel.js +20 -19
- package/lib/queries/index.js +13 -0
- package/lib/queries/member.js +219 -0
- package/lib/queries/message.js +52 -2
- package/lib/queries/subscription.js +16 -13
- package/package.json +1 -1
package/lib/CloudChat.js
CHANGED
|
@@ -351,9 +351,13 @@ function () {
|
|
|
351
351
|
_this.dp.dispatch("onDisconnected", reason);
|
|
352
352
|
});
|
|
353
353
|
this.socket.on("message", function (payload) {
|
|
354
|
-
|
|
354
|
+
try {
|
|
355
|
+
var message = JSON.parse(payload);
|
|
355
356
|
|
|
356
|
-
|
|
357
|
+
_this.dp.dispatch("onMessageReceived", message.channel_id, message);
|
|
358
|
+
} catch (e) {
|
|
359
|
+
console.error(e);
|
|
360
|
+
}
|
|
357
361
|
});
|
|
358
362
|
this.socket.on("event", function (payload) {
|
|
359
363
|
var message = JSON.parse(payload);
|
|
@@ -403,6 +407,7 @@ function () {
|
|
|
403
407
|
|
|
404
408
|
case 2:
|
|
405
409
|
subscription = _a.sent();
|
|
410
|
+
if (subscription) subscription.id = this.ObjectId(subscription.id);
|
|
406
411
|
return [2
|
|
407
412
|
/*return*/
|
|
408
413
|
, subscription];
|
|
@@ -542,7 +547,7 @@ function () {
|
|
|
542
547
|
});
|
|
543
548
|
};
|
|
544
549
|
|
|
545
|
-
NCloudChat.prototype.sendImage = function (
|
|
550
|
+
NCloudChat.prototype.sendImage = function (channelId, file) {
|
|
546
551
|
return __awaiter(this, void 0, void 0, function () {
|
|
547
552
|
var user, result;
|
|
548
553
|
return __generator(this, function (_a) {
|
|
@@ -555,25 +560,14 @@ function () {
|
|
|
555
560
|
user = _CoreManager["default"].get("USER");
|
|
556
561
|
return [4
|
|
557
562
|
/*yield*/
|
|
558
|
-
, (0, _mutations.upload)(
|
|
563
|
+
, (0, _mutations.upload)(channelId, file)];
|
|
559
564
|
|
|
560
565
|
case 1:
|
|
561
566
|
result = _a.sent();
|
|
562
567
|
if (!result.status) throw Error(result.message);
|
|
563
|
-
return [4
|
|
564
|
-
/*yield*/
|
|
565
|
-
, this.sendMessage(channel, {
|
|
566
|
-
type: "file",
|
|
567
|
-
message: result.url,
|
|
568
|
-
file: result
|
|
569
|
-
})];
|
|
570
|
-
|
|
571
|
-
case 2:
|
|
572
|
-
_a.sent();
|
|
573
|
-
|
|
574
568
|
return [2
|
|
575
569
|
/*return*/
|
|
576
|
-
];
|
|
570
|
+
, result];
|
|
577
571
|
}
|
|
578
572
|
});
|
|
579
573
|
});
|
|
@@ -655,7 +649,7 @@ function () {
|
|
|
655
649
|
return atob(id).split(":")[1];
|
|
656
650
|
};
|
|
657
651
|
|
|
658
|
-
NCloudChat.prototype.
|
|
652
|
+
NCloudChat.prototype.getMembers = function (filter, sort, option) {
|
|
659
653
|
if (sort === void 0) {
|
|
660
654
|
sort = {};
|
|
661
655
|
}
|
|
@@ -665,7 +659,7 @@ function () {
|
|
|
665
659
|
}
|
|
666
660
|
|
|
667
661
|
return __awaiter(this, void 0, void 0, function () {
|
|
668
|
-
var entries,
|
|
662
|
+
var entries, members, e_5;
|
|
669
663
|
|
|
670
664
|
var _this = this;
|
|
671
665
|
|
|
@@ -683,20 +677,20 @@ function () {
|
|
|
683
677
|
|
|
684
678
|
return [4
|
|
685
679
|
/*yield*/
|
|
686
|
-
, (0, _queries.
|
|
680
|
+
, (0, _queries.getMembers)((0, _stringify["default"])(filter), (0, _stringify["default"])(sort), (0, _stringify["default"])(option))];
|
|
687
681
|
|
|
688
682
|
case 2:
|
|
689
683
|
entries = _a.sent();
|
|
690
684
|
|
|
691
685
|
if (entries) {
|
|
692
|
-
|
|
686
|
+
members = entries.map(function (item) {
|
|
693
687
|
return __assign(__assign({}, item.node), {
|
|
694
688
|
id: _this.ObjectId(item.node.id)
|
|
695
689
|
});
|
|
696
690
|
});
|
|
697
691
|
return [2
|
|
698
692
|
/*return*/
|
|
699
|
-
,
|
|
693
|
+
, members];
|
|
700
694
|
}
|
|
701
695
|
|
|
702
696
|
return [2
|
|
@@ -716,9 +710,20 @@ function () {
|
|
|
716
710
|
});
|
|
717
711
|
};
|
|
718
712
|
|
|
719
|
-
NCloudChat.prototype.
|
|
713
|
+
NCloudChat.prototype.getChannels = function (filter, sort, option) {
|
|
714
|
+
if (sort === void 0) {
|
|
715
|
+
sort = {};
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
if (option === void 0) {
|
|
719
|
+
option = {};
|
|
720
|
+
}
|
|
721
|
+
|
|
720
722
|
return __awaiter(this, void 0, void 0, function () {
|
|
721
|
-
var
|
|
723
|
+
var entries, channels, e_6;
|
|
724
|
+
|
|
725
|
+
var _this = this;
|
|
726
|
+
|
|
722
727
|
return __generator(this, function (_a) {
|
|
723
728
|
switch (_a.label) {
|
|
724
729
|
case 0:
|
|
@@ -733,21 +738,25 @@ function () {
|
|
|
733
738
|
|
|
734
739
|
return [4
|
|
735
740
|
/*yield*/
|
|
736
|
-
, (0, _queries.
|
|
741
|
+
, (0, _queries.getChannels)((0, _stringify["default"])(filter), (0, _stringify["default"])(sort), (0, _stringify["default"])(option))];
|
|
737
742
|
|
|
738
743
|
case 2:
|
|
739
|
-
|
|
744
|
+
entries = _a.sent();
|
|
740
745
|
|
|
741
|
-
if (
|
|
742
|
-
|
|
746
|
+
if (entries) {
|
|
747
|
+
channels = entries.map(function (item) {
|
|
748
|
+
return __assign(__assign({}, item.node), {
|
|
749
|
+
id: _this.ObjectId(item.node.id)
|
|
750
|
+
});
|
|
751
|
+
});
|
|
743
752
|
return [2
|
|
744
753
|
/*return*/
|
|
745
|
-
,
|
|
754
|
+
, channels];
|
|
746
755
|
}
|
|
747
756
|
|
|
748
757
|
return [2
|
|
749
758
|
/*return*/
|
|
750
|
-
,
|
|
759
|
+
, entries];
|
|
751
760
|
|
|
752
761
|
case 3:
|
|
753
762
|
e_6 = _a.sent();
|
|
@@ -762,9 +771,120 @@ function () {
|
|
|
762
771
|
});
|
|
763
772
|
};
|
|
764
773
|
|
|
774
|
+
NCloudChat.prototype.countUnread = function (channelId) {
|
|
775
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
776
|
+
var e_7;
|
|
777
|
+
return __generator(this, function (_a) {
|
|
778
|
+
switch (_a.label) {
|
|
779
|
+
case 0:
|
|
780
|
+
if (!this.isConnected()) {
|
|
781
|
+
throw Error("You are not connected.");
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
_a.label = 1;
|
|
785
|
+
|
|
786
|
+
case 1:
|
|
787
|
+
_a.trys.push([1, 3,, 4]);
|
|
788
|
+
|
|
789
|
+
return [4
|
|
790
|
+
/*yield*/
|
|
791
|
+
, (0, _queries.unreadCount)(channelId)];
|
|
792
|
+
|
|
793
|
+
case 2:
|
|
794
|
+
return [2
|
|
795
|
+
/*return*/
|
|
796
|
+
, _a.sent()];
|
|
797
|
+
|
|
798
|
+
case 3:
|
|
799
|
+
e_7 = _a.sent();
|
|
800
|
+
throw e_7;
|
|
801
|
+
|
|
802
|
+
case 4:
|
|
803
|
+
return [2
|
|
804
|
+
/*return*/
|
|
805
|
+
, null];
|
|
806
|
+
}
|
|
807
|
+
});
|
|
808
|
+
});
|
|
809
|
+
};
|
|
810
|
+
|
|
811
|
+
NCloudChat.prototype.getSubscription = function (channelId, id) {
|
|
812
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
813
|
+
var e_8;
|
|
814
|
+
return __generator(this, function (_a) {
|
|
815
|
+
switch (_a.label) {
|
|
816
|
+
case 0:
|
|
817
|
+
if (!this.isConnected()) {
|
|
818
|
+
throw Error("You are not connected.");
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
_a.label = 1;
|
|
822
|
+
|
|
823
|
+
case 1:
|
|
824
|
+
_a.trys.push([1, 3,, 4]);
|
|
825
|
+
|
|
826
|
+
return [4
|
|
827
|
+
/*yield*/
|
|
828
|
+
, (0, _queries.getSubscription)(channelId, id)];
|
|
829
|
+
|
|
830
|
+
case 2:
|
|
831
|
+
return [2
|
|
832
|
+
/*return*/
|
|
833
|
+
, _a.sent()];
|
|
834
|
+
|
|
835
|
+
case 3:
|
|
836
|
+
e_8 = _a.sent();
|
|
837
|
+
throw e_8;
|
|
838
|
+
|
|
839
|
+
case 4:
|
|
840
|
+
return [2
|
|
841
|
+
/*return*/
|
|
842
|
+
, null];
|
|
843
|
+
}
|
|
844
|
+
});
|
|
845
|
+
});
|
|
846
|
+
};
|
|
847
|
+
|
|
848
|
+
NCloudChat.prototype.getChannel = function (channelId) {
|
|
849
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
850
|
+
var e_9;
|
|
851
|
+
return __generator(this, function (_a) {
|
|
852
|
+
switch (_a.label) {
|
|
853
|
+
case 0:
|
|
854
|
+
if (!this.isConnected()) {
|
|
855
|
+
throw Error("You are not connected.");
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
_a.label = 1;
|
|
859
|
+
|
|
860
|
+
case 1:
|
|
861
|
+
_a.trys.push([1, 3,, 4]);
|
|
862
|
+
|
|
863
|
+
return [4
|
|
864
|
+
/*yield*/
|
|
865
|
+
, (0, _queries.getChannel)(channelId)];
|
|
866
|
+
|
|
867
|
+
case 2:
|
|
868
|
+
return [2
|
|
869
|
+
/*return*/
|
|
870
|
+
, _a.sent()];
|
|
871
|
+
|
|
872
|
+
case 3:
|
|
873
|
+
e_9 = _a.sent();
|
|
874
|
+
throw e_9;
|
|
875
|
+
|
|
876
|
+
case 4:
|
|
877
|
+
return [2
|
|
878
|
+
/*return*/
|
|
879
|
+
, null];
|
|
880
|
+
}
|
|
881
|
+
});
|
|
882
|
+
});
|
|
883
|
+
};
|
|
884
|
+
|
|
765
885
|
NCloudChat.prototype.getMessage = function (channelId, messageId) {
|
|
766
886
|
return __awaiter(this, void 0, void 0, function () {
|
|
767
|
-
var entry,
|
|
887
|
+
var entry, e_10;
|
|
768
888
|
return __generator(this, function (_a) {
|
|
769
889
|
switch (_a.label) {
|
|
770
890
|
case 0:
|
|
@@ -796,8 +916,8 @@ function () {
|
|
|
796
916
|
, null];
|
|
797
917
|
|
|
798
918
|
case 3:
|
|
799
|
-
|
|
800
|
-
throw
|
|
919
|
+
e_10 = _a.sent();
|
|
920
|
+
throw e_10;
|
|
801
921
|
|
|
802
922
|
case 4:
|
|
803
923
|
return [2
|
|
@@ -810,7 +930,7 @@ function () {
|
|
|
810
930
|
|
|
811
931
|
NCloudChat.prototype.getMessages = function (filter, sort, option) {
|
|
812
932
|
return __awaiter(this, void 0, void 0, function () {
|
|
813
|
-
var entries, messages,
|
|
933
|
+
var entries, messages, e_11;
|
|
814
934
|
|
|
815
935
|
var _this = this;
|
|
816
936
|
|
|
@@ -849,8 +969,8 @@ function () {
|
|
|
849
969
|
, entries];
|
|
850
970
|
|
|
851
971
|
case 3:
|
|
852
|
-
|
|
853
|
-
throw
|
|
972
|
+
e_11 = _a.sent();
|
|
973
|
+
throw e_11;
|
|
854
974
|
|
|
855
975
|
case 4:
|
|
856
976
|
return [2
|
|
@@ -863,7 +983,7 @@ function () {
|
|
|
863
983
|
|
|
864
984
|
NCloudChat.prototype.getSubscriptions = function (filter, sort, option) {
|
|
865
985
|
return __awaiter(this, void 0, void 0, function () {
|
|
866
|
-
var entries, subscribes,
|
|
986
|
+
var entries, subscribes, e_12;
|
|
867
987
|
|
|
868
988
|
var _this = this;
|
|
869
989
|
|
|
@@ -902,8 +1022,8 @@ function () {
|
|
|
902
1022
|
, entries];
|
|
903
1023
|
|
|
904
1024
|
case 3:
|
|
905
|
-
|
|
906
|
-
throw
|
|
1025
|
+
e_12 = _a.sent();
|
|
1026
|
+
throw e_12;
|
|
907
1027
|
|
|
908
1028
|
case 4:
|
|
909
1029
|
return [2
|
|
@@ -916,7 +1036,7 @@ function () {
|
|
|
916
1036
|
|
|
917
1037
|
NCloudChat.prototype.createChannel = function (channel) {
|
|
918
1038
|
return __awaiter(this, void 0, void 0, function () {
|
|
919
|
-
var
|
|
1039
|
+
var e_13;
|
|
920
1040
|
return __generator(this, function (_a) {
|
|
921
1041
|
switch (_a.label) {
|
|
922
1042
|
case 0:
|
|
@@ -939,8 +1059,45 @@ function () {
|
|
|
939
1059
|
, _a.sent()];
|
|
940
1060
|
|
|
941
1061
|
case 3:
|
|
942
|
-
|
|
943
|
-
throw
|
|
1062
|
+
e_13 = _a.sent();
|
|
1063
|
+
throw e_13;
|
|
1064
|
+
|
|
1065
|
+
case 4:
|
|
1066
|
+
return [2
|
|
1067
|
+
/*return*/
|
|
1068
|
+
];
|
|
1069
|
+
}
|
|
1070
|
+
});
|
|
1071
|
+
});
|
|
1072
|
+
};
|
|
1073
|
+
|
|
1074
|
+
NCloudChat.prototype.updateChannel = function (channelId, channel) {
|
|
1075
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1076
|
+
var e_14;
|
|
1077
|
+
return __generator(this, function (_a) {
|
|
1078
|
+
switch (_a.label) {
|
|
1079
|
+
case 0:
|
|
1080
|
+
if (!this.isConnected()) {
|
|
1081
|
+
throw Error("You are not connected.");
|
|
1082
|
+
}
|
|
1083
|
+
|
|
1084
|
+
_a.label = 1;
|
|
1085
|
+
|
|
1086
|
+
case 1:
|
|
1087
|
+
_a.trys.push([1, 3,, 4]);
|
|
1088
|
+
|
|
1089
|
+
return [4
|
|
1090
|
+
/*yield*/
|
|
1091
|
+
, (0, _mutations.updateChannel)(channelId, channel)];
|
|
1092
|
+
|
|
1093
|
+
case 2:
|
|
1094
|
+
return [2
|
|
1095
|
+
/*return*/
|
|
1096
|
+
, _a.sent()];
|
|
1097
|
+
|
|
1098
|
+
case 3:
|
|
1099
|
+
e_14 = _a.sent();
|
|
1100
|
+
throw e_14;
|
|
944
1101
|
|
|
945
1102
|
case 4:
|
|
946
1103
|
return [2
|
|
@@ -953,7 +1110,7 @@ function () {
|
|
|
953
1110
|
|
|
954
1111
|
NCloudChat.prototype.deleteChannel = function (channelId) {
|
|
955
1112
|
return __awaiter(this, void 0, void 0, function () {
|
|
956
|
-
var
|
|
1113
|
+
var e_15;
|
|
957
1114
|
return __generator(this, function (_a) {
|
|
958
1115
|
switch (_a.label) {
|
|
959
1116
|
case 0:
|
|
@@ -976,8 +1133,8 @@ function () {
|
|
|
976
1133
|
, _a.sent()];
|
|
977
1134
|
|
|
978
1135
|
case 3:
|
|
979
|
-
|
|
980
|
-
throw
|
|
1136
|
+
e_15 = _a.sent();
|
|
1137
|
+
throw e_15;
|
|
981
1138
|
|
|
982
1139
|
case 4:
|
|
983
1140
|
return [2
|
|
@@ -990,7 +1147,7 @@ function () {
|
|
|
990
1147
|
|
|
991
1148
|
NCloudChat.prototype.markRead = function (channelId, mark) {
|
|
992
1149
|
return __awaiter(this, void 0, void 0, function () {
|
|
993
|
-
var
|
|
1150
|
+
var e_16;
|
|
994
1151
|
return __generator(this, function (_a) {
|
|
995
1152
|
switch (_a.label) {
|
|
996
1153
|
case 0:
|
|
@@ -1013,8 +1170,8 @@ function () {
|
|
|
1013
1170
|
, _a.sent()];
|
|
1014
1171
|
|
|
1015
1172
|
case 3:
|
|
1016
|
-
|
|
1017
|
-
throw
|
|
1173
|
+
e_16 = _a.sent();
|
|
1174
|
+
throw e_16;
|
|
1018
1175
|
|
|
1019
1176
|
case 4:
|
|
1020
1177
|
return [2
|
package/lib/Util.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
|
|
4
|
+
|
|
5
|
+
_Object$defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
exports.ObjectId = void 0;
|
|
10
|
+
|
|
11
|
+
require("core-js/modules/es6.regexp.split");
|
|
12
|
+
|
|
13
|
+
var ObjectId = function ObjectId(id) {
|
|
14
|
+
if (!id) return "";
|
|
15
|
+
return atob(id).split(":")[1];
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
exports.ObjectId = ObjectId;
|
package/lib/mutations/channel.js
CHANGED
|
@@ -231,7 +231,7 @@ var updateChannel = function updateChannel(channelId, channel) {
|
|
|
231
231
|
endpoint = _CoreManager["default"].get('SERVER_URL') + '/graphql';
|
|
232
232
|
if (!channel.members) channel.members = [];
|
|
233
233
|
console.log(channel);
|
|
234
|
-
query = "\n mutation (\n $projectId: String!, \n $name: String!, \n $
|
|
234
|
+
query = "\n mutation (\n $projectId: String!, \n $name: String!, \n $translation: Boolean,\n $linkUrl: String,\n $imageUrl: String,\n $id: ID!,\n ) {\n updateChannel(\n input: { \n projectId: $projectId, \n name: $name, \n id: $id,\n translation:$translation,\n linkUrl:$linkUrl,\n imageUrl:$imageUrl\n }\n ) {\n channel {\n id\n project_id\n name\n user_id\n unique_id\n is_private\n translation\n members\n push\n link_url\n image_url \n created_at\n updated_at\n }\n }\n } \n ";
|
|
235
235
|
return [4
|
|
236
236
|
/*yield*/
|
|
237
237
|
, fetch(endpoint, {
|
|
@@ -246,13 +246,9 @@ var updateChannel = function updateChannel(channelId, channel) {
|
|
|
246
246
|
variables: {
|
|
247
247
|
projectId: projectId,
|
|
248
248
|
id: channelId,
|
|
249
|
-
type: channel.type,
|
|
250
249
|
name: channel.name,
|
|
251
|
-
members: channel.members,
|
|
252
|
-
push: channel.push,
|
|
253
250
|
link_url: channel.linkUrl,
|
|
254
|
-
image_url: channel.imageUrl
|
|
255
|
-
translation: channel.translation
|
|
251
|
+
image_url: channel.imageUrl
|
|
256
252
|
}
|
|
257
253
|
})
|
|
258
254
|
}).then(function (res) {
|
|
@@ -262,7 +258,7 @@ var updateChannel = function updateChannel(channelId, channel) {
|
|
|
262
258
|
throw data.errors[0];
|
|
263
259
|
}
|
|
264
260
|
|
|
265
|
-
return data.data.
|
|
261
|
+
return data.data.updateChannel.channel;
|
|
266
262
|
})];
|
|
267
263
|
|
|
268
264
|
case 1:
|
package/lib/mutations/message.js
CHANGED
|
@@ -208,7 +208,7 @@ var translate = function translate(source, target, message) {
|
|
|
208
208
|
|
|
209
209
|
exports.translate = translate;
|
|
210
210
|
|
|
211
|
-
var upload = function upload(
|
|
211
|
+
var upload = function upload(channelId, file) {
|
|
212
212
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
213
213
|
var token, projectId, endpoint, form, result;
|
|
214
214
|
return __generator(this, function (_a) {
|
|
@@ -219,6 +219,7 @@ var upload = function upload(channel, file) {
|
|
|
219
219
|
endpoint = _CoreManager["default"].get('SERVER_URL') + '/upload';
|
|
220
220
|
form = new FormData();
|
|
221
221
|
form.append('file', file);
|
|
222
|
+
form.append('channelId', channelId);
|
|
222
223
|
form.append('upload', '1');
|
|
223
224
|
return [4
|
|
224
225
|
/*yield*/
|
package/lib/queries/channel.js
CHANGED
|
@@ -8,7 +8,7 @@ _Object$defineProperty(exports, "__esModule", {
|
|
|
8
8
|
value: true
|
|
9
9
|
});
|
|
10
10
|
|
|
11
|
-
exports.
|
|
11
|
+
exports.getChannels = exports.getChannel = void 0;
|
|
12
12
|
|
|
13
13
|
var _stringify = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/json/stringify"));
|
|
14
14
|
|
|
@@ -20,6 +20,8 @@ var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/pr
|
|
|
20
20
|
|
|
21
21
|
var _CoreManager = _interopRequireDefault(require("../CoreManager"));
|
|
22
22
|
|
|
23
|
+
var _Util = require("../Util");
|
|
24
|
+
|
|
23
25
|
var __awaiter = void 0 && (void 0).__awaiter || function (thisArg, _arguments, P, generator) {
|
|
24
26
|
function adopt(value) {
|
|
25
27
|
return value instanceof P ? value : new P(function (resolve) {
|
|
@@ -163,7 +165,7 @@ var __generator = void 0 && (void 0).__generator || function (thisArg, body) {
|
|
|
163
165
|
}
|
|
164
166
|
};
|
|
165
167
|
|
|
166
|
-
var
|
|
168
|
+
var getChannel = function getChannel(id) {
|
|
167
169
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
168
170
|
var token, projectId, endpoint, query;
|
|
169
171
|
return __generator(this, function (_a) {
|
|
@@ -178,7 +180,7 @@ var getChannels = function getChannels(filter, sort, option) {
|
|
|
178
180
|
/*return*/
|
|
179
181
|
, null];
|
|
180
182
|
endpoint = _CoreManager["default"].get('SERVER_URL') + '/graphql';
|
|
181
|
-
query = "\n query
|
|
183
|
+
query = "\n query channel ($projectId: String!, $id: String!) {\n channel(projectId: $projectId, id:$id) {\n id\n project_id\n name\n user_id\n unique_id\n is_private\n translation\n members\n push\n link_url\n image_url \n created_at\n updated_at\n }\n }\n ";
|
|
182
184
|
return [4
|
|
183
185
|
/*yield*/
|
|
184
186
|
, fetch(endpoint, {
|
|
@@ -192,19 +194,18 @@ var getChannels = function getChannels(filter, sort, option) {
|
|
|
192
194
|
query: query,
|
|
193
195
|
variables: {
|
|
194
196
|
projectId: projectId,
|
|
195
|
-
|
|
196
|
-
sort: sort,
|
|
197
|
-
option: option
|
|
197
|
+
id: id
|
|
198
198
|
}
|
|
199
199
|
})
|
|
200
200
|
}).then(function (res) {
|
|
201
201
|
return res.json();
|
|
202
202
|
}).then(function (data) {
|
|
203
|
-
if (data.data.
|
|
204
|
-
|
|
203
|
+
if (data.data.channel) {
|
|
204
|
+
data.data.channel.id = (0, _Util.ObjectId)(data.data.channel.id);
|
|
205
|
+
return data.data.channel;
|
|
205
206
|
}
|
|
206
207
|
|
|
207
|
-
return
|
|
208
|
+
return false;
|
|
208
209
|
})];
|
|
209
210
|
|
|
210
211
|
case 1:
|
|
@@ -216,9 +217,9 @@ var getChannels = function getChannels(filter, sort, option) {
|
|
|
216
217
|
});
|
|
217
218
|
};
|
|
218
219
|
|
|
219
|
-
exports.
|
|
220
|
+
exports.getChannel = getChannel;
|
|
220
221
|
|
|
221
|
-
var
|
|
222
|
+
var getChannels = function getChannels(filter, sort, option) {
|
|
222
223
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
223
224
|
var token, projectId, endpoint, query;
|
|
224
225
|
return __generator(this, function (_a) {
|
|
@@ -233,7 +234,7 @@ var getChannel = function getChannel(id) {
|
|
|
233
234
|
/*return*/
|
|
234
235
|
, null];
|
|
235
236
|
endpoint = _CoreManager["default"].get('SERVER_URL') + '/graphql';
|
|
236
|
-
query = "\n query
|
|
237
|
+
query = "\n query channels ($projectId: String!, $filter: String!, $sort: String, $option:String) {\n channels(projectId: $projectId, filter:$filter, sort:$sort, option:$option) {\n totalCount\n edges {\n node {\n id\n project_id\n name\n user_id\n unique_id\n is_private\n translation\n members\n push\n link_url\n image_url \n created_at\n updated_at\n }\n }\n }\n }\n ";
|
|
237
238
|
return [4
|
|
238
239
|
/*yield*/
|
|
239
240
|
, fetch(endpoint, {
|
|
@@ -247,19 +248,19 @@ var getChannel = function getChannel(id) {
|
|
|
247
248
|
query: query,
|
|
248
249
|
variables: {
|
|
249
250
|
projectId: projectId,
|
|
250
|
-
|
|
251
|
+
filter: filter,
|
|
252
|
+
sort: sort,
|
|
253
|
+
option: option
|
|
251
254
|
}
|
|
252
255
|
})
|
|
253
256
|
}).then(function (res) {
|
|
254
257
|
return res.json();
|
|
255
258
|
}).then(function (data) {
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
if (data.data.channel) {
|
|
259
|
-
return data.data.channel;
|
|
259
|
+
if (data.data.channels) {
|
|
260
|
+
return data.data.channels.edges;
|
|
260
261
|
}
|
|
261
262
|
|
|
262
|
-
return
|
|
263
|
+
return [];
|
|
263
264
|
})];
|
|
264
265
|
|
|
265
266
|
case 1:
|
|
@@ -271,4 +272,4 @@ var getChannel = function getChannel(id) {
|
|
|
271
272
|
});
|
|
272
273
|
};
|
|
273
274
|
|
|
274
|
-
exports.
|
|
275
|
+
exports.getChannels = getChannels;
|
package/lib/queries/index.js
CHANGED
|
@@ -75,6 +75,19 @@ _Object$keys(_friend).forEach(function (key) {
|
|
|
75
75
|
});
|
|
76
76
|
});
|
|
77
77
|
|
|
78
|
+
var _member = require("./member");
|
|
79
|
+
|
|
80
|
+
_Object$keys(_member).forEach(function (key) {
|
|
81
|
+
if (key === "default" || key === "__esModule") return;
|
|
82
|
+
|
|
83
|
+
_Object$defineProperty(exports, key, {
|
|
84
|
+
enumerable: true,
|
|
85
|
+
get: function get() {
|
|
86
|
+
return _member[key];
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
|
|
78
91
|
var _messageread = require("./messageread");
|
|
79
92
|
|
|
80
93
|
_Object$keys(_messageread).forEach(function (key) {
|