ncloudchat 0.0.19-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/LICENSE.md +21 -0
- package/README.md +69 -0
- package/esm/CloudChat.d.ts +38 -0
- package/esm/CloudChat.js +592 -0
- package/esm/CloudChat.js.map +1 -0
- package/esm/CoreManager.d.ts +5 -0
- package/esm/CoreManager.js +27 -0
- package/esm/CoreManager.js.map +1 -0
- package/esm/Dispatcher.d.ts +21 -0
- package/esm/Dispatcher.js +78 -0
- package/esm/Dispatcher.js.map +1 -0
- package/esm/Type.d.ts +35 -0
- package/esm/Type.js +12 -0
- package/esm/Type.js.map +1 -0
- package/esm/index.d.ts +2 -0
- package/esm/index.js +3 -0
- package/esm/index.js.map +1 -0
- package/esm/logger.d.ts +4 -0
- package/esm/logger.js +11 -0
- package/esm/logger.js.map +1 -0
- package/esm/mutations/channel.d.ts +4 -0
- package/esm/mutations/channel.js +162 -0
- package/esm/mutations/channel.js.map +1 -0
- package/esm/mutations/friend.d.ts +5 -0
- package/esm/mutations/friend.js +146 -0
- package/esm/mutations/friend.js.map +1 -0
- package/esm/mutations/index.d.ts +14 -0
- package/esm/mutations/index.js +15 -0
- package/esm/mutations/index.js.map +1 -0
- package/esm/mutations/invite.d.ts +1 -0
- package/esm/mutations/invite.js +71 -0
- package/esm/mutations/invite.js.map +1 -0
- package/esm/mutations/memberinvitation.d.ts +2 -0
- package/esm/mutations/memberinvitation.js +103 -0
- package/esm/mutations/memberinvitation.js.map +1 -0
- package/esm/mutations/memberreport.d.ts +10 -0
- package/esm/mutations/memberreport.js +110 -0
- package/esm/mutations/memberreport.js.map +1 -0
- package/esm/mutations/message.d.ts +2 -0
- package/esm/mutations/message.js +97 -0
- package/esm/mutations/message.js.map +1 -0
- package/esm/mutations/messageread.d.ts +1 -0
- package/esm/mutations/messageread.js +69 -0
- package/esm/mutations/messageread.js.map +1 -0
- package/esm/mutations/subscription.d.ts +4 -0
- package/esm/mutations/subscription.js +139 -0
- package/esm/mutations/subscription.js.map +1 -0
- package/esm/mutations/user.d.ts +1 -0
- package/esm/mutations/user.js +74 -0
- package/esm/mutations/user.js.map +1 -0
- package/esm/queries/channel.d.ts +2 -0
- package/esm/queries/channel.js +119 -0
- package/esm/queries/channel.js.map +1 -0
- package/esm/queries/friend.d.ts +1 -0
- package/esm/queries/friend.js +80 -0
- package/esm/queries/friend.js.map +1 -0
- package/esm/queries/index.d.ts +7 -0
- package/esm/queries/index.js +8 -0
- package/esm/queries/index.js.map +1 -0
- package/esm/queries/memberinvitation.d.ts +2 -0
- package/esm/queries/memberinvitation.js +110 -0
- package/esm/queries/memberinvitation.js.map +1 -0
- package/esm/queries/message.d.ts +2 -0
- package/esm/queries/message.js +117 -0
- package/esm/queries/message.js.map +1 -0
- package/esm/queries/messageread.d.ts +1 -0
- package/esm/queries/messageread.js +74 -0
- package/esm/queries/messageread.js.map +1 -0
- package/esm/queries/project.d.ts +1 -0
- package/esm/queries/project.js +74 -0
- package/esm/queries/project.js.map +1 -0
- package/esm/queries/subscription.d.ts +2 -0
- package/esm/queries/subscription.js +112 -0
- package/esm/queries/subscription.js.map +1 -0
- package/lib/CloudChat.js +1032 -0
- package/lib/CoreManager.js +35 -0
- package/lib/Dispatcher.js +109 -0
- package/lib/Type.js +25 -0
- package/lib/index.js +18 -0
- package/lib/logger.js +27 -0
- package/lib/mutations/channel.js +324 -0
- package/lib/mutations/friend.js +319 -0
- package/lib/mutations/index.js +128 -0
- package/lib/mutations/invite.js +208 -0
- package/lib/mutations/memberinvitation.js +271 -0
- package/lib/mutations/memberreport.js +272 -0
- package/lib/mutations/message.js +246 -0
- package/lib/mutations/messageread.js +215 -0
- package/lib/mutations/subscription.js +299 -0
- package/lib/mutations/user.js +207 -0
- package/lib/queries/channel.js +274 -0
- package/lib/queries/friend.js +220 -0
- package/lib/queries/index.js +102 -0
- package/lib/queries/memberinvitation.js +273 -0
- package/lib/queries/message.js +267 -0
- package/lib/queries/messageread.js +219 -0
- package/lib/queries/project.js +217 -0
- package/lib/queries/subscription.js +264 -0
- package/ncloudchat_javascript.md +290 -0
- package/package copy.json +74 -0
- package/package.json +76 -0
- package/tsconfig.json +31 -0
- package/types/exif.d.ts +10 -0
- package/types/window.d.ts +5 -0
|
@@ -0,0 +1,35 @@
|
|
|
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["default"] = void 0;
|
|
10
|
+
var config = {
|
|
11
|
+
// Defaults
|
|
12
|
+
IS_NODE: typeof process !== 'undefined' && !!process.versions && !!process.versions.node,
|
|
13
|
+
REQUEST_ATTEMPT_LIMIT: 5,
|
|
14
|
+
REQUEST_BATCH_SIZE: 20,
|
|
15
|
+
REQUEST_HEADERS: {},
|
|
16
|
+
TOKEN: "",
|
|
17
|
+
SERVER_URL: "https://cloudchat.apigw.ntruss.com/gpapps/v1",
|
|
18
|
+
SOCKET_URL: "https://socs.cloudchat.ntruss.com",
|
|
19
|
+
VERSION: 'js' + require('../package.json').version,
|
|
20
|
+
PROJECT_ID: null
|
|
21
|
+
};
|
|
22
|
+
var CoreManager = {
|
|
23
|
+
get: function get(key) {
|
|
24
|
+
if (config.hasOwnProperty(key)) {
|
|
25
|
+
return config[key];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
throw new Error('Configuration key not found: ' + key);
|
|
29
|
+
},
|
|
30
|
+
set: function set(key, value) {
|
|
31
|
+
config[key] = value;
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
var _default = CoreManager;
|
|
35
|
+
exports["default"] = _default;
|
|
@@ -0,0 +1,109 @@
|
|
|
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["default"] = void 0;
|
|
10
|
+
|
|
11
|
+
require("core-js/modules/es6.array.for-each");
|
|
12
|
+
|
|
13
|
+
require("core-js/modules/es6.array.index-of");
|
|
14
|
+
|
|
15
|
+
require("core-js/modules/es7.array.includes");
|
|
16
|
+
|
|
17
|
+
require("core-js/modules/es6.string.includes");
|
|
18
|
+
|
|
19
|
+
var DispatcherEvent =
|
|
20
|
+
/** @class */
|
|
21
|
+
function () {
|
|
22
|
+
function DispatcherEvent() {
|
|
23
|
+
this.callbacks = [];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
DispatcherEvent.prototype.getCallbacks = function () {
|
|
27
|
+
return this.callbacks;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
DispatcherEvent.prototype.register = function (cb) {
|
|
31
|
+
if (!this.callbacks.includes(cb)) {
|
|
32
|
+
this.callbacks.push(cb);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
DispatcherEvent.prototype.unregister = function (cb) {
|
|
37
|
+
var index = this.callbacks.indexOf(cb);
|
|
38
|
+
|
|
39
|
+
if (index > -1) {
|
|
40
|
+
this.callbacks.splice(index, 1);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
DispatcherEvent.prototype.execute = function (param1, param2, param3, param4, param5, param6) {
|
|
45
|
+
if (this.callbacks.length > 0) {
|
|
46
|
+
this.callbacks.slice(0).forEach(function (callback) {
|
|
47
|
+
if (!param2) callback(param1);else if (!param3) callback(param1, param2);else if (!param4) callback(param1, param2, param3);else if (!param5) callback(param1, param2, param3, param4);else if (!param6) callback(param1, param2, param3, param4, param5);else callback(param1, param2, param3, param4, param5, param6);
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
return DispatcherEvent;
|
|
53
|
+
}();
|
|
54
|
+
|
|
55
|
+
var Dispatcher =
|
|
56
|
+
/** @class */
|
|
57
|
+
function () {
|
|
58
|
+
function Dispatcher() {
|
|
59
|
+
this.eventProvider = {};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
Dispatcher.prototype.getProvider = function () {
|
|
63
|
+
return this.eventProvider;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
Dispatcher.prototype.dispatch = function (name, param1, param2, param3, param4, param5, param6) {
|
|
67
|
+
var event = this.eventProvider[name];
|
|
68
|
+
|
|
69
|
+
if (event) {
|
|
70
|
+
event.execute(param1, param2, param3, param4, param5, param6);
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
Dispatcher.prototype.on = function (name, callback) {
|
|
75
|
+
var event = this.eventProvider[name];
|
|
76
|
+
|
|
77
|
+
if (!event) {
|
|
78
|
+
event = new DispatcherEvent();
|
|
79
|
+
this.eventProvider[name] = event;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
event.register(callback);
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
Dispatcher.prototype.off = function (name, callback) {
|
|
86
|
+
var event = this.eventProvider[name];
|
|
87
|
+
|
|
88
|
+
if (event) {
|
|
89
|
+
event.unregister(callback);
|
|
90
|
+
|
|
91
|
+
if (event.getCallbacks().length === 0) {
|
|
92
|
+
delete this.eventProvider[name];
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
Dispatcher.prototype.offall = function (name) {
|
|
98
|
+
var event = this.eventProvider[name];
|
|
99
|
+
|
|
100
|
+
if (event) {
|
|
101
|
+
delete this.eventProvider[name];
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
return Dispatcher;
|
|
106
|
+
}();
|
|
107
|
+
|
|
108
|
+
var _default = Dispatcher;
|
|
109
|
+
exports["default"] = _default;
|
package/lib/Type.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
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.MessageType = exports.ChannelType = void 0;
|
|
10
|
+
var ChannelType;
|
|
11
|
+
exports.ChannelType = ChannelType;
|
|
12
|
+
|
|
13
|
+
(function (ChannelType) {
|
|
14
|
+
ChannelType["PRIVATE"] = "PRIVATE";
|
|
15
|
+
ChannelType["PUBLIC"] = "PUBLIC";
|
|
16
|
+
})(ChannelType || (exports.ChannelType = ChannelType = {}));
|
|
17
|
+
|
|
18
|
+
var MessageType;
|
|
19
|
+
exports.MessageType = MessageType;
|
|
20
|
+
|
|
21
|
+
(function (MessageType) {
|
|
22
|
+
MessageType["text"] = "text";
|
|
23
|
+
MessageType["photo"] = "photo";
|
|
24
|
+
MessageType["file"] = "file";
|
|
25
|
+
})(MessageType || (exports.MessageType = MessageType = {}));
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
|
|
6
|
+
|
|
7
|
+
_Object$defineProperty(exports, "__esModule", {
|
|
8
|
+
value: true
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
_Object$defineProperty(exports, "Chat", {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function get() {
|
|
14
|
+
return _CloudChat["default"];
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
var _CloudChat = _interopRequireDefault(require("./CloudChat"));
|
package/lib/logger.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
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.info = exports.error = exports.debug = void 0;
|
|
10
|
+
|
|
11
|
+
var debug = function debug(value) {
|
|
12
|
+
return console.log(value);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
exports.debug = debug;
|
|
16
|
+
|
|
17
|
+
var error = function error(value) {
|
|
18
|
+
return console.error(value);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
exports.error = error;
|
|
22
|
+
|
|
23
|
+
var info = function info(value) {
|
|
24
|
+
return console.log(value);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
exports.info = info;
|
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
|
|
6
|
+
|
|
7
|
+
_Object$defineProperty(exports, "__esModule", {
|
|
8
|
+
value: true
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
exports.deleteChannel = exports.updateChannel = exports.createChannel = void 0;
|
|
12
|
+
|
|
13
|
+
require("core-js/modules/es6.function.name");
|
|
14
|
+
|
|
15
|
+
var _stringify = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/json/stringify"));
|
|
16
|
+
|
|
17
|
+
var _iterator = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/symbol/iterator"));
|
|
18
|
+
|
|
19
|
+
var _symbol = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/symbol"));
|
|
20
|
+
|
|
21
|
+
var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
|
|
22
|
+
|
|
23
|
+
var _CoreManager = _interopRequireDefault(require("../CoreManager"));
|
|
24
|
+
|
|
25
|
+
var __awaiter = void 0 && (void 0).__awaiter || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) {
|
|
27
|
+
return value instanceof P ? value : new P(function (resolve) {
|
|
28
|
+
resolve(value);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return new (P || (P = _promise["default"]))(function (resolve, reject) {
|
|
33
|
+
function fulfilled(value) {
|
|
34
|
+
try {
|
|
35
|
+
step(generator.next(value));
|
|
36
|
+
} catch (e) {
|
|
37
|
+
reject(e);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function rejected(value) {
|
|
42
|
+
try {
|
|
43
|
+
step(generator["throw"](value));
|
|
44
|
+
} catch (e) {
|
|
45
|
+
reject(e);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function step(result) {
|
|
50
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
var __generator = void 0 && (void 0).__generator || function (thisArg, body) {
|
|
58
|
+
var _ = {
|
|
59
|
+
label: 0,
|
|
60
|
+
sent: function sent() {
|
|
61
|
+
if (t[0] & 1) throw t[1];
|
|
62
|
+
return t[1];
|
|
63
|
+
},
|
|
64
|
+
trys: [],
|
|
65
|
+
ops: []
|
|
66
|
+
},
|
|
67
|
+
f,
|
|
68
|
+
y,
|
|
69
|
+
t,
|
|
70
|
+
g;
|
|
71
|
+
return g = {
|
|
72
|
+
next: verb(0),
|
|
73
|
+
"throw": verb(1),
|
|
74
|
+
"return": verb(2)
|
|
75
|
+
}, typeof _symbol["default"] === "function" && (g[_iterator["default"]] = function () {
|
|
76
|
+
return this;
|
|
77
|
+
}), g;
|
|
78
|
+
|
|
79
|
+
function verb(n) {
|
|
80
|
+
return function (v) {
|
|
81
|
+
return step([n, v]);
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function step(op) {
|
|
86
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
87
|
+
|
|
88
|
+
while (_) {
|
|
89
|
+
try {
|
|
90
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
91
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
92
|
+
|
|
93
|
+
switch (op[0]) {
|
|
94
|
+
case 0:
|
|
95
|
+
case 1:
|
|
96
|
+
t = op;
|
|
97
|
+
break;
|
|
98
|
+
|
|
99
|
+
case 4:
|
|
100
|
+
_.label++;
|
|
101
|
+
return {
|
|
102
|
+
value: op[1],
|
|
103
|
+
done: false
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
case 5:
|
|
107
|
+
_.label++;
|
|
108
|
+
y = op[1];
|
|
109
|
+
op = [0];
|
|
110
|
+
continue;
|
|
111
|
+
|
|
112
|
+
case 7:
|
|
113
|
+
op = _.ops.pop();
|
|
114
|
+
|
|
115
|
+
_.trys.pop();
|
|
116
|
+
|
|
117
|
+
continue;
|
|
118
|
+
|
|
119
|
+
default:
|
|
120
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
121
|
+
_ = 0;
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
126
|
+
_.label = op[1];
|
|
127
|
+
break;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
131
|
+
_.label = t[1];
|
|
132
|
+
t = op;
|
|
133
|
+
break;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if (t && _.label < t[2]) {
|
|
137
|
+
_.label = t[2];
|
|
138
|
+
|
|
139
|
+
_.ops.push(op);
|
|
140
|
+
|
|
141
|
+
break;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (t[2]) _.ops.pop();
|
|
145
|
+
|
|
146
|
+
_.trys.pop();
|
|
147
|
+
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
op = body.call(thisArg, _);
|
|
152
|
+
} catch (e) {
|
|
153
|
+
op = [6, e];
|
|
154
|
+
y = 0;
|
|
155
|
+
} finally {
|
|
156
|
+
f = t = 0;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
if (op[0] & 5) throw op[1];
|
|
161
|
+
return {
|
|
162
|
+
value: op[0] ? op[1] : void 0,
|
|
163
|
+
done: true
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
var createChannel = function createChannel(channel) {
|
|
169
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
170
|
+
var token, projectId, endpoint, query;
|
|
171
|
+
return __generator(this, function (_a) {
|
|
172
|
+
switch (_a.label) {
|
|
173
|
+
case 0:
|
|
174
|
+
token = _CoreManager["default"].get("TOKEN");
|
|
175
|
+
projectId = _CoreManager["default"].get("PROJECT_ID");
|
|
176
|
+
endpoint = _CoreManager["default"].get('SERVER_URL') + '/graphql';
|
|
177
|
+
if (!channel.members) channel.members = [];
|
|
178
|
+
query = "\n mutation (\n $projectId: String!, \n $name: String!, \n $type: String!,\n $uniqueId: String,\n $translation: Boolean,\n $push: Boolean,\n $linkUrl: String,\n $imageUrl: String,\n $id: String,\n $members: [String]\n ) {\n createChannel(\n input: { \n projectId: $projectId, \n name: $name, \n type: $type,\n id: $id,\n members: $members,\n uniqueId: $uniqueId,\n translation:$translation,\n push:$push,\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 ";
|
|
179
|
+
return [4
|
|
180
|
+
/*yield*/
|
|
181
|
+
, fetch(endpoint, {
|
|
182
|
+
method: 'POST',
|
|
183
|
+
headers: {
|
|
184
|
+
'Authorization': 'Bearer ' + token,
|
|
185
|
+
'Content-Type': 'application/json',
|
|
186
|
+
'Accept': 'application/json'
|
|
187
|
+
},
|
|
188
|
+
body: (0, _stringify["default"])({
|
|
189
|
+
query: query,
|
|
190
|
+
variables: {
|
|
191
|
+
projectId: projectId,
|
|
192
|
+
id: channel.id,
|
|
193
|
+
type: channel.type,
|
|
194
|
+
name: channel.name,
|
|
195
|
+
members: channel.members,
|
|
196
|
+
push: channel.push,
|
|
197
|
+
link_url: channel.linkUrl,
|
|
198
|
+
image_url: channel.imageUrl,
|
|
199
|
+
translation: channel.translation
|
|
200
|
+
}
|
|
201
|
+
})
|
|
202
|
+
}).then(function (res) {
|
|
203
|
+
return res.json();
|
|
204
|
+
}).then(function (data) {
|
|
205
|
+
if (data.errors) {
|
|
206
|
+
throw data.errors[0];
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
return data.data.createChannel.channel;
|
|
210
|
+
})];
|
|
211
|
+
|
|
212
|
+
case 1:
|
|
213
|
+
return [2
|
|
214
|
+
/*return*/
|
|
215
|
+
, _a.sent()];
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
});
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
exports.createChannel = createChannel;
|
|
222
|
+
|
|
223
|
+
var updateChannel = function updateChannel(channelId, channel) {
|
|
224
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
225
|
+
var token, projectId, endpoint, query;
|
|
226
|
+
return __generator(this, function (_a) {
|
|
227
|
+
switch (_a.label) {
|
|
228
|
+
case 0:
|
|
229
|
+
token = _CoreManager["default"].get("TOKEN");
|
|
230
|
+
projectId = _CoreManager["default"].get("PROJECT_ID");
|
|
231
|
+
endpoint = _CoreManager["default"].get('SERVER_URL') + '/graphql';
|
|
232
|
+
if (!channel.members) channel.members = [];
|
|
233
|
+
console.log(channel);
|
|
234
|
+
query = "\n mutation (\n $projectId: String!, \n $name: String!, \n $type: String!,\n $uniqueId: String,\n $translation: Boolean,\n $push: Boolean,\n $linkUrl: String,\n $imageUrl: String,\n $id: String,\n $members: [String]\n ) {\n updateChannel(\n input: { \n projectId: $projectId, \n name: $name, \n type: $type,\n id: $id,\n members: $members,\n uniqueId: $uniqueId,\n translation:$translation,\n push:$push,\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
|
+
return [4
|
|
236
|
+
/*yield*/
|
|
237
|
+
, fetch(endpoint, {
|
|
238
|
+
method: 'POST',
|
|
239
|
+
headers: {
|
|
240
|
+
'Authorization': 'Bearer ' + token,
|
|
241
|
+
'Content-Type': 'application/json',
|
|
242
|
+
'Accept': 'application/json'
|
|
243
|
+
},
|
|
244
|
+
body: (0, _stringify["default"])({
|
|
245
|
+
query: query,
|
|
246
|
+
variables: {
|
|
247
|
+
projectId: projectId,
|
|
248
|
+
id: channelId,
|
|
249
|
+
type: channel.type,
|
|
250
|
+
name: channel.name,
|
|
251
|
+
members: channel.members,
|
|
252
|
+
push: channel.push,
|
|
253
|
+
link_url: channel.linkUrl,
|
|
254
|
+
image_url: channel.imageUrl,
|
|
255
|
+
translation: channel.translation
|
|
256
|
+
}
|
|
257
|
+
})
|
|
258
|
+
}).then(function (res) {
|
|
259
|
+
return res.json();
|
|
260
|
+
}).then(function (data) {
|
|
261
|
+
if (data.errors) {
|
|
262
|
+
throw data.errors[0];
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
return data.data.createChannel.channel;
|
|
266
|
+
})];
|
|
267
|
+
|
|
268
|
+
case 1:
|
|
269
|
+
return [2
|
|
270
|
+
/*return*/
|
|
271
|
+
, _a.sent()];
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
});
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
exports.updateChannel = updateChannel;
|
|
278
|
+
|
|
279
|
+
var deleteChannel = function deleteChannel(channelId) {
|
|
280
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
281
|
+
var token, projectId, endpoint, query;
|
|
282
|
+
return __generator(this, function (_a) {
|
|
283
|
+
switch (_a.label) {
|
|
284
|
+
case 0:
|
|
285
|
+
token = _CoreManager["default"].get("TOKEN");
|
|
286
|
+
projectId = _CoreManager["default"].get("PROJECT_ID");
|
|
287
|
+
endpoint = _CoreManager["default"].get('SERVER_URL') + '/graphql';
|
|
288
|
+
query = "\n mutation (\n $projectId: String!, \n $id: ID!\n ) {\n deleteChannel(\n input: { \n projectId: $projectId, \n id: $id,\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 ";
|
|
289
|
+
return [4
|
|
290
|
+
/*yield*/
|
|
291
|
+
, fetch(endpoint, {
|
|
292
|
+
method: 'POST',
|
|
293
|
+
headers: {
|
|
294
|
+
'Authorization': 'Bearer ' + token,
|
|
295
|
+
'Content-Type': 'application/json',
|
|
296
|
+
'Accept': 'application/json'
|
|
297
|
+
},
|
|
298
|
+
body: (0, _stringify["default"])({
|
|
299
|
+
query: query,
|
|
300
|
+
variables: {
|
|
301
|
+
projectId: projectId,
|
|
302
|
+
id: channelId
|
|
303
|
+
}
|
|
304
|
+
})
|
|
305
|
+
}).then(function (res) {
|
|
306
|
+
return res.json();
|
|
307
|
+
}).then(function (data) {
|
|
308
|
+
if (data.errors) {
|
|
309
|
+
throw data.errors[0];
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
return data.data.deleteChannel.channel;
|
|
313
|
+
})];
|
|
314
|
+
|
|
315
|
+
case 1:
|
|
316
|
+
return [2
|
|
317
|
+
/*return*/
|
|
318
|
+
, _a.sent()];
|
|
319
|
+
}
|
|
320
|
+
});
|
|
321
|
+
});
|
|
322
|
+
};
|
|
323
|
+
|
|
324
|
+
exports.deleteChannel = deleteChannel;
|