|
@ -14,4 +14,71 @@ class Channel { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
module.exports = { Channel } |
|
|
|
|
|
|
|
|
class ChannelAPI { |
|
|
|
|
|
/** |
|
|
|
|
|
* Call `channels(filter)` query |
|
|
|
|
|
* |
|
|
|
|
|
* @param {{logged:boolean, eventName:string, locationName:string}} filter |
|
|
|
|
|
* @returns {Promise<Channel[]>} |
|
|
|
|
|
*/ |
|
|
|
|
|
list(filter = {}) { |
|
|
|
|
|
return query(`
|
|
|
|
|
|
query ListChannel($filter: ChannelsFilter) { |
|
|
|
|
|
channels(filter: $filter) { |
|
|
|
|
|
name |
|
|
|
|
|
logged |
|
|
|
|
|
hub |
|
|
|
|
|
eventName |
|
|
|
|
|
locationName |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
`, {filter}).then(({channels}) => {
|
|
|
|
|
|
return channels.map(d => Channel.fromData(d)) |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* Call `channels(filter)` query |
|
|
|
|
|
* |
|
|
|
|
|
* @param {{name:string, logged:boolean, eventName:string, locationName:string}} filter |
|
|
|
|
|
* @returns {Promise<Channel>} |
|
|
|
|
|
*/ |
|
|
|
|
|
add(input = {}) { |
|
|
|
|
|
return query(`
|
|
|
|
|
|
mutation AddChannel($input: ChannelAddInput!) { |
|
|
|
|
|
addChannel(input: $input) { |
|
|
|
|
|
name |
|
|
|
|
|
hub |
|
|
|
|
|
logged |
|
|
|
|
|
eventName |
|
|
|
|
|
locationName |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
`, {input}, {permissions: ["channel.add"]}).then(({addChannel}) => {
|
|
|
|
|
|
return Channel.fromData(addChannel) |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* Call `channels(filter)` query |
|
|
|
|
|
* |
|
|
|
|
|
* @param {{name:string, logged:boolean, eventName:string, locationName:string}} filter |
|
|
|
|
|
* @returns {Promise<{name:string, logged:boolean, eventName:string, locationName:string}>} |
|
|
|
|
|
*/ |
|
|
|
|
|
edit(input = {}) { |
|
|
|
|
|
return query(`
|
|
|
|
|
|
mutation EditChannel($input: ChannelEditInput!) { |
|
|
|
|
|
editChannel(input: $input) { |
|
|
|
|
|
name |
|
|
|
|
|
logged |
|
|
|
|
|
eventName |
|
|
|
|
|
locationName |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
`, {input}, {permissions: ["channel.edit"]}).then(({editChannel}) => {
|
|
|
|
|
|
return editChannel |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
module.exports = { Channel, channelApi: new ChannelAPI } |