ncloudchat 0.0.19-beta → 0.0.22-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 +7 -1
- package/esm/CloudChat.js +172 -49
- 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.d.ts +1 -0
- package/esm/mutations/channel.js +39 -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 +253 -52
- package/lib/Util.js +18 -0
- package/lib/mutations/channel.js +53 -9
- 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
|
@@ -250,6 +250,10 @@ function () {
|
|
|
250
250
|
return _CoreManager["default"].set("PROJECT_ID", projectId);
|
|
251
251
|
};
|
|
252
252
|
|
|
253
|
+
NCloudChat.prototype.setToken = function (token) {
|
|
254
|
+
return _CoreManager["default"].set("TOKEN", token);
|
|
255
|
+
};
|
|
256
|
+
|
|
253
257
|
NCloudChat.prototype.setUser = function (user) {
|
|
254
258
|
_CoreManager["default"].set("USER", user);
|
|
255
259
|
};
|
|
@@ -351,9 +355,13 @@ function () {
|
|
|
351
355
|
_this.dp.dispatch("onDisconnected", reason);
|
|
352
356
|
});
|
|
353
357
|
this.socket.on("message", function (payload) {
|
|
354
|
-
|
|
358
|
+
try {
|
|
359
|
+
var message = JSON.parse(payload);
|
|
355
360
|
|
|
356
|
-
|
|
361
|
+
_this.dp.dispatch("onMessageReceived", message.channel_id, message);
|
|
362
|
+
} catch (e) {
|
|
363
|
+
console.error(e);
|
|
364
|
+
}
|
|
357
365
|
});
|
|
358
366
|
this.socket.on("event", function (payload) {
|
|
359
367
|
var message = JSON.parse(payload);
|
|
@@ -403,6 +411,7 @@ function () {
|
|
|
403
411
|
|
|
404
412
|
case 2:
|
|
405
413
|
subscription = _a.sent();
|
|
414
|
+
if (subscription) subscription.id = this.ObjectId(subscription.id);
|
|
406
415
|
return [2
|
|
407
416
|
/*return*/
|
|
408
417
|
, subscription];
|
|
@@ -460,9 +469,49 @@ function () {
|
|
|
460
469
|
});
|
|
461
470
|
};
|
|
462
471
|
|
|
472
|
+
NCloudChat.prototype.inviteMembers = function (channelId, memberIds) {
|
|
473
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
474
|
+
var user, channel, e_4;
|
|
475
|
+
return __generator(this, function (_a) {
|
|
476
|
+
switch (_a.label) {
|
|
477
|
+
case 0:
|
|
478
|
+
if (!this.isConnected()) {
|
|
479
|
+
throw Error("You are not connected.");
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
_a.label = 1;
|
|
483
|
+
|
|
484
|
+
case 1:
|
|
485
|
+
_a.trys.push([1, 3,, 4]);
|
|
486
|
+
|
|
487
|
+
user = _CoreManager["default"].get("USER");
|
|
488
|
+
if (!user.id) throw Error("unauthorized");
|
|
489
|
+
return [4
|
|
490
|
+
/*yield*/
|
|
491
|
+
, (0, _mutations.createInviteMember)(channelId, memberIds)];
|
|
492
|
+
|
|
493
|
+
case 2:
|
|
494
|
+
channel = _a.sent();
|
|
495
|
+
return [2
|
|
496
|
+
/*return*/
|
|
497
|
+
, channel];
|
|
498
|
+
|
|
499
|
+
case 3:
|
|
500
|
+
e_4 = _a.sent();
|
|
501
|
+
throw e_4;
|
|
502
|
+
|
|
503
|
+
case 4:
|
|
504
|
+
return [2
|
|
505
|
+
/*return*/
|
|
506
|
+
, null];
|
|
507
|
+
}
|
|
508
|
+
});
|
|
509
|
+
});
|
|
510
|
+
};
|
|
511
|
+
|
|
463
512
|
NCloudChat.prototype.translateMessage = function (source, target, message) {
|
|
464
513
|
return __awaiter(this, void 0, void 0, function () {
|
|
465
|
-
var user, result,
|
|
514
|
+
var user, result, e_5;
|
|
466
515
|
return __generator(this, function (_a) {
|
|
467
516
|
switch (_a.label) {
|
|
468
517
|
case 0:
|
|
@@ -487,8 +536,8 @@ function () {
|
|
|
487
536
|
, result];
|
|
488
537
|
|
|
489
538
|
case 3:
|
|
490
|
-
|
|
491
|
-
throw
|
|
539
|
+
e_5 = _a.sent();
|
|
540
|
+
throw e_5;
|
|
492
541
|
|
|
493
542
|
case 4:
|
|
494
543
|
return [2
|
|
@@ -542,7 +591,7 @@ function () {
|
|
|
542
591
|
});
|
|
543
592
|
};
|
|
544
593
|
|
|
545
|
-
NCloudChat.prototype.sendImage = function (
|
|
594
|
+
NCloudChat.prototype.sendImage = function (channelId, file) {
|
|
546
595
|
return __awaiter(this, void 0, void 0, function () {
|
|
547
596
|
var user, result;
|
|
548
597
|
return __generator(this, function (_a) {
|
|
@@ -555,25 +604,14 @@ function () {
|
|
|
555
604
|
user = _CoreManager["default"].get("USER");
|
|
556
605
|
return [4
|
|
557
606
|
/*yield*/
|
|
558
|
-
, (0, _mutations.upload)(
|
|
607
|
+
, (0, _mutations.upload)(channelId, file)];
|
|
559
608
|
|
|
560
609
|
case 1:
|
|
561
610
|
result = _a.sent();
|
|
562
611
|
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
612
|
return [2
|
|
575
613
|
/*return*/
|
|
576
|
-
];
|
|
614
|
+
, result];
|
|
577
615
|
}
|
|
578
616
|
});
|
|
579
617
|
});
|
|
@@ -655,6 +693,67 @@ function () {
|
|
|
655
693
|
return atob(id).split(":")[1];
|
|
656
694
|
};
|
|
657
695
|
|
|
696
|
+
NCloudChat.prototype.getMembers = function (filter, sort, option) {
|
|
697
|
+
if (sort === void 0) {
|
|
698
|
+
sort = {};
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
if (option === void 0) {
|
|
702
|
+
option = {};
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
706
|
+
var entries, members, e_6;
|
|
707
|
+
|
|
708
|
+
var _this = this;
|
|
709
|
+
|
|
710
|
+
return __generator(this, function (_a) {
|
|
711
|
+
switch (_a.label) {
|
|
712
|
+
case 0:
|
|
713
|
+
if (!this.isConnected()) {
|
|
714
|
+
throw Error("You are not connected.");
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
_a.label = 1;
|
|
718
|
+
|
|
719
|
+
case 1:
|
|
720
|
+
_a.trys.push([1, 3,, 4]);
|
|
721
|
+
|
|
722
|
+
return [4
|
|
723
|
+
/*yield*/
|
|
724
|
+
, (0, _queries.getMembers)((0, _stringify["default"])(filter), (0, _stringify["default"])(sort), (0, _stringify["default"])(option))];
|
|
725
|
+
|
|
726
|
+
case 2:
|
|
727
|
+
entries = _a.sent();
|
|
728
|
+
|
|
729
|
+
if (entries) {
|
|
730
|
+
members = entries.map(function (item) {
|
|
731
|
+
return __assign(__assign({}, item.node), {
|
|
732
|
+
id: _this.ObjectId(item.node.id)
|
|
733
|
+
});
|
|
734
|
+
});
|
|
735
|
+
return [2
|
|
736
|
+
/*return*/
|
|
737
|
+
, members];
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
return [2
|
|
741
|
+
/*return*/
|
|
742
|
+
, entries];
|
|
743
|
+
|
|
744
|
+
case 3:
|
|
745
|
+
e_6 = _a.sent();
|
|
746
|
+
throw e_6;
|
|
747
|
+
|
|
748
|
+
case 4:
|
|
749
|
+
return [2
|
|
750
|
+
/*return*/
|
|
751
|
+
];
|
|
752
|
+
}
|
|
753
|
+
});
|
|
754
|
+
});
|
|
755
|
+
};
|
|
756
|
+
|
|
658
757
|
NCloudChat.prototype.getChannels = function (filter, sort, option) {
|
|
659
758
|
if (sort === void 0) {
|
|
660
759
|
sort = {};
|
|
@@ -665,7 +764,7 @@ function () {
|
|
|
665
764
|
}
|
|
666
765
|
|
|
667
766
|
return __awaiter(this, void 0, void 0, function () {
|
|
668
|
-
var entries, channels,
|
|
767
|
+
var entries, channels, e_7;
|
|
669
768
|
|
|
670
769
|
var _this = this;
|
|
671
770
|
|
|
@@ -704,8 +803,8 @@ function () {
|
|
|
704
803
|
, entries];
|
|
705
804
|
|
|
706
805
|
case 3:
|
|
707
|
-
|
|
708
|
-
throw
|
|
806
|
+
e_7 = _a.sent();
|
|
807
|
+
throw e_7;
|
|
709
808
|
|
|
710
809
|
case 4:
|
|
711
810
|
return [2
|
|
@@ -716,9 +815,9 @@ function () {
|
|
|
716
815
|
});
|
|
717
816
|
};
|
|
718
817
|
|
|
719
|
-
NCloudChat.prototype.
|
|
818
|
+
NCloudChat.prototype.countUnread = function (channelId) {
|
|
720
819
|
return __awaiter(this, void 0, void 0, function () {
|
|
721
|
-
var
|
|
820
|
+
var e_8;
|
|
722
821
|
return __generator(this, function (_a) {
|
|
723
822
|
switch (_a.label) {
|
|
724
823
|
case 0:
|
|
@@ -733,30 +832,95 @@ function () {
|
|
|
733
832
|
|
|
734
833
|
return [4
|
|
735
834
|
/*yield*/
|
|
736
|
-
, (0, _queries.
|
|
835
|
+
, (0, _queries.unreadCount)(channelId)];
|
|
737
836
|
|
|
738
837
|
case 2:
|
|
739
|
-
|
|
838
|
+
return [2
|
|
839
|
+
/*return*/
|
|
840
|
+
, _a.sent()];
|
|
740
841
|
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
842
|
+
case 3:
|
|
843
|
+
e_8 = _a.sent();
|
|
844
|
+
throw e_8;
|
|
845
|
+
|
|
846
|
+
case 4:
|
|
847
|
+
return [2
|
|
848
|
+
/*return*/
|
|
849
|
+
, null];
|
|
850
|
+
}
|
|
851
|
+
});
|
|
852
|
+
});
|
|
853
|
+
};
|
|
854
|
+
|
|
855
|
+
NCloudChat.prototype.getSubscription = function (channelId, id) {
|
|
856
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
857
|
+
var e_9;
|
|
858
|
+
return __generator(this, function (_a) {
|
|
859
|
+
switch (_a.label) {
|
|
860
|
+
case 0:
|
|
861
|
+
if (!this.isConnected()) {
|
|
862
|
+
throw Error("You are not connected.");
|
|
746
863
|
}
|
|
747
864
|
|
|
865
|
+
_a.label = 1;
|
|
866
|
+
|
|
867
|
+
case 1:
|
|
868
|
+
_a.trys.push([1, 3,, 4]);
|
|
869
|
+
|
|
870
|
+
return [4
|
|
871
|
+
/*yield*/
|
|
872
|
+
, (0, _queries.getSubscription)(channelId, id)];
|
|
873
|
+
|
|
874
|
+
case 2:
|
|
875
|
+
return [2
|
|
876
|
+
/*return*/
|
|
877
|
+
, _a.sent()];
|
|
878
|
+
|
|
879
|
+
case 3:
|
|
880
|
+
e_9 = _a.sent();
|
|
881
|
+
throw e_9;
|
|
882
|
+
|
|
883
|
+
case 4:
|
|
748
884
|
return [2
|
|
749
885
|
/*return*/
|
|
750
886
|
, null];
|
|
887
|
+
}
|
|
888
|
+
});
|
|
889
|
+
});
|
|
890
|
+
};
|
|
891
|
+
|
|
892
|
+
NCloudChat.prototype.getChannel = function (channelId) {
|
|
893
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
894
|
+
var e_10;
|
|
895
|
+
return __generator(this, function (_a) {
|
|
896
|
+
switch (_a.label) {
|
|
897
|
+
case 0:
|
|
898
|
+
if (!this.isConnected()) {
|
|
899
|
+
throw Error("You are not connected.");
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
_a.label = 1;
|
|
903
|
+
|
|
904
|
+
case 1:
|
|
905
|
+
_a.trys.push([1, 3,, 4]);
|
|
906
|
+
|
|
907
|
+
return [4
|
|
908
|
+
/*yield*/
|
|
909
|
+
, (0, _queries.getChannel)(channelId)];
|
|
910
|
+
|
|
911
|
+
case 2:
|
|
912
|
+
return [2
|
|
913
|
+
/*return*/
|
|
914
|
+
, _a.sent()];
|
|
751
915
|
|
|
752
916
|
case 3:
|
|
753
|
-
|
|
754
|
-
throw
|
|
917
|
+
e_10 = _a.sent();
|
|
918
|
+
throw e_10;
|
|
755
919
|
|
|
756
920
|
case 4:
|
|
757
921
|
return [2
|
|
758
922
|
/*return*/
|
|
759
|
-
];
|
|
923
|
+
, null];
|
|
760
924
|
}
|
|
761
925
|
});
|
|
762
926
|
});
|
|
@@ -764,7 +928,7 @@ function () {
|
|
|
764
928
|
|
|
765
929
|
NCloudChat.prototype.getMessage = function (channelId, messageId) {
|
|
766
930
|
return __awaiter(this, void 0, void 0, function () {
|
|
767
|
-
var entry,
|
|
931
|
+
var entry, e_11;
|
|
768
932
|
return __generator(this, function (_a) {
|
|
769
933
|
switch (_a.label) {
|
|
770
934
|
case 0:
|
|
@@ -796,8 +960,8 @@ function () {
|
|
|
796
960
|
, null];
|
|
797
961
|
|
|
798
962
|
case 3:
|
|
799
|
-
|
|
800
|
-
throw
|
|
963
|
+
e_11 = _a.sent();
|
|
964
|
+
throw e_11;
|
|
801
965
|
|
|
802
966
|
case 4:
|
|
803
967
|
return [2
|
|
@@ -810,7 +974,7 @@ function () {
|
|
|
810
974
|
|
|
811
975
|
NCloudChat.prototype.getMessages = function (filter, sort, option) {
|
|
812
976
|
return __awaiter(this, void 0, void 0, function () {
|
|
813
|
-
var entries, messages,
|
|
977
|
+
var entries, messages, e_12;
|
|
814
978
|
|
|
815
979
|
var _this = this;
|
|
816
980
|
|
|
@@ -849,8 +1013,8 @@ function () {
|
|
|
849
1013
|
, entries];
|
|
850
1014
|
|
|
851
1015
|
case 3:
|
|
852
|
-
|
|
853
|
-
throw
|
|
1016
|
+
e_12 = _a.sent();
|
|
1017
|
+
throw e_12;
|
|
854
1018
|
|
|
855
1019
|
case 4:
|
|
856
1020
|
return [2
|
|
@@ -863,7 +1027,7 @@ function () {
|
|
|
863
1027
|
|
|
864
1028
|
NCloudChat.prototype.getSubscriptions = function (filter, sort, option) {
|
|
865
1029
|
return __awaiter(this, void 0, void 0, function () {
|
|
866
|
-
var entries, subscribes,
|
|
1030
|
+
var entries, subscribes, e_13;
|
|
867
1031
|
|
|
868
1032
|
var _this = this;
|
|
869
1033
|
|
|
@@ -902,8 +1066,8 @@ function () {
|
|
|
902
1066
|
, entries];
|
|
903
1067
|
|
|
904
1068
|
case 3:
|
|
905
|
-
|
|
906
|
-
throw
|
|
1069
|
+
e_13 = _a.sent();
|
|
1070
|
+
throw e_13;
|
|
907
1071
|
|
|
908
1072
|
case 4:
|
|
909
1073
|
return [2
|
|
@@ -916,7 +1080,7 @@ function () {
|
|
|
916
1080
|
|
|
917
1081
|
NCloudChat.prototype.createChannel = function (channel) {
|
|
918
1082
|
return __awaiter(this, void 0, void 0, function () {
|
|
919
|
-
var
|
|
1083
|
+
var e_14;
|
|
920
1084
|
return __generator(this, function (_a) {
|
|
921
1085
|
switch (_a.label) {
|
|
922
1086
|
case 0:
|
|
@@ -939,8 +1103,45 @@ function () {
|
|
|
939
1103
|
, _a.sent()];
|
|
940
1104
|
|
|
941
1105
|
case 3:
|
|
942
|
-
|
|
943
|
-
throw
|
|
1106
|
+
e_14 = _a.sent();
|
|
1107
|
+
throw e_14;
|
|
1108
|
+
|
|
1109
|
+
case 4:
|
|
1110
|
+
return [2
|
|
1111
|
+
/*return*/
|
|
1112
|
+
];
|
|
1113
|
+
}
|
|
1114
|
+
});
|
|
1115
|
+
});
|
|
1116
|
+
};
|
|
1117
|
+
|
|
1118
|
+
NCloudChat.prototype.updateChannel = function (channelId, channel) {
|
|
1119
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1120
|
+
var e_15;
|
|
1121
|
+
return __generator(this, function (_a) {
|
|
1122
|
+
switch (_a.label) {
|
|
1123
|
+
case 0:
|
|
1124
|
+
if (!this.isConnected()) {
|
|
1125
|
+
throw Error("You are not connected.");
|
|
1126
|
+
}
|
|
1127
|
+
|
|
1128
|
+
_a.label = 1;
|
|
1129
|
+
|
|
1130
|
+
case 1:
|
|
1131
|
+
_a.trys.push([1, 3,, 4]);
|
|
1132
|
+
|
|
1133
|
+
return [4
|
|
1134
|
+
/*yield*/
|
|
1135
|
+
, (0, _mutations.updateChannel)(channelId, channel)];
|
|
1136
|
+
|
|
1137
|
+
case 2:
|
|
1138
|
+
return [2
|
|
1139
|
+
/*return*/
|
|
1140
|
+
, _a.sent()];
|
|
1141
|
+
|
|
1142
|
+
case 3:
|
|
1143
|
+
e_15 = _a.sent();
|
|
1144
|
+
throw e_15;
|
|
944
1145
|
|
|
945
1146
|
case 4:
|
|
946
1147
|
return [2
|
|
@@ -953,7 +1154,7 @@ function () {
|
|
|
953
1154
|
|
|
954
1155
|
NCloudChat.prototype.deleteChannel = function (channelId) {
|
|
955
1156
|
return __awaiter(this, void 0, void 0, function () {
|
|
956
|
-
var
|
|
1157
|
+
var e_16;
|
|
957
1158
|
return __generator(this, function (_a) {
|
|
958
1159
|
switch (_a.label) {
|
|
959
1160
|
case 0:
|
|
@@ -976,8 +1177,8 @@ function () {
|
|
|
976
1177
|
, _a.sent()];
|
|
977
1178
|
|
|
978
1179
|
case 3:
|
|
979
|
-
|
|
980
|
-
throw
|
|
1180
|
+
e_16 = _a.sent();
|
|
1181
|
+
throw e_16;
|
|
981
1182
|
|
|
982
1183
|
case 4:
|
|
983
1184
|
return [2
|
|
@@ -990,7 +1191,7 @@ function () {
|
|
|
990
1191
|
|
|
991
1192
|
NCloudChat.prototype.markRead = function (channelId, mark) {
|
|
992
1193
|
return __awaiter(this, void 0, void 0, function () {
|
|
993
|
-
var
|
|
1194
|
+
var e_17;
|
|
994
1195
|
return __generator(this, function (_a) {
|
|
995
1196
|
switch (_a.label) {
|
|
996
1197
|
case 0:
|
|
@@ -1013,8 +1214,8 @@ function () {
|
|
|
1013
1214
|
, _a.sent()];
|
|
1014
1215
|
|
|
1015
1216
|
case 3:
|
|
1016
|
-
|
|
1017
|
-
throw
|
|
1217
|
+
e_17 = _a.sent();
|
|
1218
|
+
throw e_17;
|
|
1018
1219
|
|
|
1019
1220
|
case 4:
|
|
1020
1221
|
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
|
@@ -8,7 +8,7 @@ _Object$defineProperty(exports, "__esModule", {
|
|
|
8
8
|
value: true
|
|
9
9
|
});
|
|
10
10
|
|
|
11
|
-
exports.deleteChannel = exports.updateChannel = exports.createChannel = void 0;
|
|
11
|
+
exports.createInviteMember = exports.deleteChannel = exports.updateChannel = exports.createChannel = void 0;
|
|
12
12
|
|
|
13
13
|
require("core-js/modules/es6.function.name");
|
|
14
14
|
|
|
@@ -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:
|
|
@@ -321,4 +317,52 @@ var deleteChannel = function deleteChannel(channelId) {
|
|
|
321
317
|
});
|
|
322
318
|
};
|
|
323
319
|
|
|
324
|
-
exports.deleteChannel = deleteChannel;
|
|
320
|
+
exports.deleteChannel = deleteChannel;
|
|
321
|
+
|
|
322
|
+
var createInviteMember = function createInviteMember(channelId, memberIds) {
|
|
323
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
324
|
+
var token, projectId, endpoint, query;
|
|
325
|
+
return __generator(this, function (_a) {
|
|
326
|
+
switch (_a.label) {
|
|
327
|
+
case 0:
|
|
328
|
+
token = _CoreManager["default"].get("TOKEN");
|
|
329
|
+
projectId = _CoreManager["default"].get("PROJECT_ID");
|
|
330
|
+
endpoint = _CoreManager["default"].get('SERVER_URL') + '/graphql';
|
|
331
|
+
query = "\n mutation ($projectId: String!, $channelId: String!, $memberIds: [String]!) {\n createInviteMember(input: {projectId: $projectId, channelId: $channelId, memberIds:$memberIds }) {\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 ";
|
|
332
|
+
return [4
|
|
333
|
+
/*yield*/
|
|
334
|
+
, fetch(endpoint, {
|
|
335
|
+
method: 'POST',
|
|
336
|
+
headers: {
|
|
337
|
+
'Authorization': 'Bearer ' + token,
|
|
338
|
+
'Content-Type': 'application/json',
|
|
339
|
+
'Accept': 'application/json'
|
|
340
|
+
},
|
|
341
|
+
body: (0, _stringify["default"])({
|
|
342
|
+
query: query,
|
|
343
|
+
variables: {
|
|
344
|
+
projectId: projectId,
|
|
345
|
+
channelId: channelId,
|
|
346
|
+
memberIds: memberIds
|
|
347
|
+
}
|
|
348
|
+
})
|
|
349
|
+
}).then(function (res) {
|
|
350
|
+
return res.json();
|
|
351
|
+
}).then(function (data) {
|
|
352
|
+
if (data.errors) {
|
|
353
|
+
throw data.errors[0];
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
return data.data.createInviteMember.channel;
|
|
357
|
+
})];
|
|
358
|
+
|
|
359
|
+
case 1:
|
|
360
|
+
return [2
|
|
361
|
+
/*return*/
|
|
362
|
+
, _a.sent()];
|
|
363
|
+
}
|
|
364
|
+
});
|
|
365
|
+
});
|
|
366
|
+
};
|
|
367
|
+
|
|
368
|
+
exports.createInviteMember = createInviteMember;
|
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*/
|