UNPKG

2.89 kBJavaScriptView Raw
1const events = require('./config/events');
2
3const VkBotSdkApi = require('./api');
4const VkBotSdkClient = require('./client');
5const VkBotSdkCallback = require('./callback');
6
7const {
8 Context, Keyboard, Attachment,
9 Button, TextButton, LinkButton, LocationButton, VKPayButton, VKAppButton
10} = require('./interfaces');
11
12const {
13 redisStorage
14} = require('./middlewares');
15
16/**
17 * @typedef {{
18 * type: AttachmentType,
19 * ?photo: Object,
20 * ?video: Object,
21 * ?audio: Object,
22 * ?doc: Object,
23 * ?link: Object,
24 * ?market: Object,
25 * ?market_album: Object,
26 * ?wall: Object,
27 * ?wall_reply: Object,
28 * ?sticker: Object,
29 * ?gift: Object
30 * }} APIAttachmentObject
31 *
32 * @typedef {(
33 * 'default' | 'primary' | 'positive' | 'negative'
34 * )} ButtonColor
35 *
36 * @typedef {(
37 * 'photo' | 'video' | 'audio' | 'doc' | 'link' | 'market' | 'market_album' |
38 * 'wall' | 'wall_reply' | 'sticker' | 'gift'
39 * )} AttachmentType
40 *
41 * @typedef {Function<Context, Function>} CtxCallback
42 * @typedef {Function<Error, Context, Function>} CtxErrorCallback
43 * @typedef {Function<Context, Object, Function>} CtxParamsCallback
44 */
45
46
47/**
48 * CLass VkBotSdk
49 *
50 * @property {VkBotSdkClient} client
51 * @property {VkBotSdkApi} api
52 * @property {VkBotSdkCallback} callback
53 */
54class VkBotSdk {
55 constructor(options = {}) {
56 this.client = new VkBotSdkClient(options);
57 this.api = new VkBotSdkApi(this.client);
58 this.callback = new VkBotSdkCallback(this.client);
59 }
60
61 /**
62 * getApi()
63 * @returns {VkBotSdkApi}
64 */
65 getApi() {
66 return this.api;
67 }
68
69 /**
70 * getCallback()
71 * @returns {VkBotSdkCallback}
72 */
73 getCallback() {
74 return this.callback;
75 }
76
77 /**
78 * getClient()
79 * @returns {VkBotSdkClient}
80 */
81 getClient() {
82 return this.client;
83 }
84}
85
86// Sdk exporting
87module.exports = VkBotSdk;
88module.exports.VkBotSdk = VkBotSdk;
89
90// Interfaces exporting
91module.exports.events = events;
92module.exports.context = Context;
93module.exports.keyboard = Keyboard;
94module.exports.attachment = Attachment;
95module.exports.button = Button;
96module.exports.textButton = TextButton;
97module.exports.linkButton = LinkButton;
98module.exports.locationButton = LocationButton;
99module.exports.vkpayButton = VKPayButton;
100module.exports.vkappButton = VKAppButton;
101
102// Interfaces exporting
103module.exports.Events = events;
104module.exports.Context = Context;
105module.exports.Keyboard = Keyboard;
106module.exports.Attachment = Attachment;
107module.exports.Button = Button;
108module.exports.TextButton = TextButton;
109module.exports.LinkButton = LinkButton;
110module.exports.LocationButton = LocationButton;
111module.exports.VKPayButton = VKPayButton;
112module.exports.VKAppButton = VKAppButton;
113
114// Middlewares exporting
115module.exports.redisStorage = redisStorage;