vkontakte-api
Advanced tools
Comparing version 1.10.0 to 1.11.0
@@ -5,2 +5,9 @@ # Changelog | ||
## [1.11.0](https://github.com/wolframdeus/vk-api/compare/v1.10.0...v1.11.0) (2020-07-10) | ||
### Features | ||
* **statevents:** add statEvents repository ([7a65558](https://github.com/wolframdeus/vk-api/commit/7a65558cac061e73f3c0dec741b028720afa9520)) | ||
## [1.10.0](https://github.com/wolframdeus/vk-api/compare/v1.9.0...v1.10.0) (2020-06-24) | ||
@@ -7,0 +14,0 @@ |
import { VKAPIInterface } from '../../VKAPI'; | ||
import { UsersRepository, MessagesRepository, NotificationsRepository, DatabaseRepository, UtilsRepository, StatsRepository, StreamingRepository, WidgetsRepository } from '../../repositories'; | ||
import { UsersRepository, MessagesRepository, NotificationsRepository, DatabaseRepository, UtilsRepository, StatsRepository, StreamingRepository, WidgetsRepository, StatEventsRepository } from '../../repositories'; | ||
import { SendRequest } from '../../types'; | ||
@@ -13,2 +13,3 @@ import { VKAPISlaveConstructorProps } from './types'; | ||
notifications: NotificationsRepository; | ||
statEvents: StatEventsRepository; | ||
stats: StatsRepository; | ||
@@ -22,3 +23,3 @@ streaming: StreamingRepository; | ||
*/ | ||
private tunnelName; | ||
private readonly tunnelName; | ||
/** | ||
@@ -25,0 +26,0 @@ * Internal request counter. Required to send and get answers from master |
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var utils_1=require("./utils"),repositories_1=require("../../repositories"),VKAPIConsumer=function(){return function(e){var s=this;if(void 0===e&&(e={}),this.requestId="0",this.addRequestToQueue=function(e){if(!process.send)throw new Error('Unable to process VKAPI request from slave due to there is no "process.send" method available. It looks like it was created in main thread, but not in fork');var t=(parseInt(s.requestId)+1).toString(16),o=process.pid,r={tunnelName:s.tunnelName,processId:o,requestId:t,isVKAPIMessage:!0,type:"process-request",config:e};return process.send(r),s.requestId=t,new Promise(function(e,r){var i=function(n){if(utils_1.isVKAPIRequestProcessedMessage(n)&&n.tunnelName===s.tunnelName&&n.requestId===t&&n.processId===o){if(process.off("message",i),n.error)return r(n.error);e(n.data)}};process.on("message",i)})},!process.send)throw new Error('Unable to create VKAPISlave due to there is no "process.send" method available. It looks like it was created in main thread, but not in fork');var t=e.tunnelName,o=void 0===t?"":t;this.tunnelName=o,this.database=new repositories_1.DatabaseRepository(this.addRequestToQueue),this.messages=new repositories_1.MessagesRepository(this.addRequestToQueue),this.notifications=new repositories_1.NotificationsRepository(this.addRequestToQueue),this.stats=new repositories_1.StatsRepository(this.addRequestToQueue),this.streaming=new repositories_1.StreamingRepository(this.addRequestToQueue),this.users=new repositories_1.UsersRepository(this.addRequestToQueue),this.utils=new repositories_1.UtilsRepository(this.addRequestToQueue),this.widgets=new repositories_1.WidgetsRepository(this.addRequestToQueue)}}();exports.VKAPIConsumer=VKAPIConsumer,exports.VKAPISlave=VKAPIConsumer; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var utils_1=require("./utils"),repositories_1=require("../../repositories"),VKAPIConsumer=function(){return function(e){var s=this;if(void 0===e&&(e={}),this.requestId="0",this.addRequestToQueue=function(e){if(!process.send)throw new Error('Unable to process VKAPI request from slave due to there is no "process.send" method available. It looks like it was created in main thread, but not in fork');var t=(parseInt(s.requestId)+1).toString(16),o=process.pid,r={tunnelName:s.tunnelName,processId:o,requestId:t,isVKAPIMessage:!0,type:"process-request",config:e};return process.send(r),s.requestId=t,new Promise(function(e,r){var i=function(n){if(utils_1.isVKAPIRequestProcessedMessage(n)&&n.tunnelName===s.tunnelName&&n.requestId===t&&n.processId===o){if(process.off("message",i),n.error)return r(n.error);e(n.data)}};process.on("message",i)})},!process.send)throw new Error('Unable to create VKAPIConsumer due to there is no "process.send" method available. It looks like it was created in main thread, but not in fork');var t=e.tunnelName,o=void 0===t?"":t;this.tunnelName=o,this.database=new repositories_1.DatabaseRepository(this.addRequestToQueue),this.messages=new repositories_1.MessagesRepository(this.addRequestToQueue),this.notifications=new repositories_1.NotificationsRepository(this.addRequestToQueue),this.statEvents=new repositories_1.StatEventsRepository(this.addRequestToQueue),this.stats=new repositories_1.StatsRepository(this.addRequestToQueue),this.streaming=new repositories_1.StreamingRepository(this.addRequestToQueue),this.users=new repositories_1.UsersRepository(this.addRequestToQueue),this.utils=new repositories_1.UtilsRepository(this.addRequestToQueue),this.widgets=new repositories_1.WidgetsRepository(this.addRequestToQueue)}}();exports.VKAPIConsumer=VKAPIConsumer,exports.VKAPISlave=VKAPIConsumer; |
export * from './DatabaseRepository'; | ||
export * from './MessagesRepository'; | ||
export * from './NotificationsRepository'; | ||
export * from './StatEventsRepository'; | ||
export * from './StatsRepository'; | ||
@@ -5,0 +6,0 @@ export * from './StreamingRepository'; |
@@ -1,1 +0,1 @@ | ||
"use strict";function __export(e){for(var r in e)exports.hasOwnProperty(r)||(exports[r]=e[r])}Object.defineProperty(exports,"__esModule",{value:!0}),__export(require("./DatabaseRepository")),__export(require("./MessagesRepository")),__export(require("./NotificationsRepository")),__export(require("./StatsRepository")),__export(require("./StreamingRepository")),__export(require("./UsersRepository")),__export(require("./UtilsRepository")),__export(require("./WidgetsRepository")); | ||
"use strict";function __export(e){for(var r in e)exports.hasOwnProperty(r)||(exports[r]=e[r])}Object.defineProperty(exports,"__esModule",{value:!0}),__export(require("./DatabaseRepository")),__export(require("./MessagesRepository")),__export(require("./NotificationsRepository")),__export(require("./StatEventsRepository")),__export(require("./StatsRepository")),__export(require("./StreamingRepository")),__export(require("./UsersRepository")),__export(require("./UtilsRepository")),__export(require("./WidgetsRepository")); |
import { RequestConfig, RequestOptionalParams, SendRequest } from '../types'; | ||
import { UsersRepository, StatsRepository, UtilsRepository, NotificationsRepository, MessagesRepository, DatabaseRepository, StreamingRepository } from '../repositories'; | ||
import { UsersRepository, StatsRepository, UtilsRepository, NotificationsRepository, MessagesRepository, DatabaseRepository, StreamingRepository, StatEventsRepository } from '../repositories'; | ||
import { WidgetsRepository } from '../repositories/WidgetsRepository'; | ||
@@ -32,2 +32,3 @@ export interface QueueRequest { | ||
notifications: NotificationsRepository; | ||
statEvents: StatEventsRepository; | ||
stats: StatsRepository; | ||
@@ -34,0 +35,0 @@ streaming: StreamingRepository; |
import { SendRequest } from '../types'; | ||
import { VKAPIInterface, VKAPIConstructorProps } from './types'; | ||
import { UsersRepository, MessagesRepository, NotificationsRepository, StatsRepository, DatabaseRepository, UtilsRepository, StreamingRepository, WidgetsRepository } from '../repositories'; | ||
import { UsersRepository, MessagesRepository, NotificationsRepository, StatsRepository, DatabaseRepository, UtilsRepository, StreamingRepository, WidgetsRepository, StatEventsRepository } from '../repositories'; | ||
/** | ||
@@ -11,2 +11,3 @@ * Class to perform request to VKontakte API | ||
notifications: NotificationsRepository; | ||
statEvents: StatEventsRepository; | ||
stats: StatsRepository; | ||
@@ -13,0 +14,0 @@ streaming: StreamingRepository; |
@@ -1,1 +0,1 @@ | ||
"use strict";var __assign=this&&this.__assign||function(){return(__assign=Object.assign||function(e){for(var t,r=1,i=arguments.length;r<i;r++)for(var s in t=arguments[r])Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e}).apply(this,arguments)},__awaiter=this&&this.__awaiter||function(e,t,r,i){return new(r||(r=Promise))(function(s,n){function o(e){try{a(i.next(e))}catch(e){n(e)}}function u(e){try{a(i.throw(e))}catch(e){n(e)}}function a(e){var t;e.done?s(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(o,u)}a((i=i.apply(e,t||[])).next())})},__generator=this&&this.__generator||function(e,t){var r,i,s,n,o={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return n={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(n[Symbol.iterator]=function(){return this}),n;function u(n){return function(u){return function(n){if(r)throw new TypeError("Generator is already executing.");for(;o;)try{if(r=1,i&&(s=2&n[0]?i.return:n[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,n[1])).done)return s;switch(i=0,s&&(n=[2&n[0],s.value]),n[0]){case 0:case 1:s=n;break;case 4:return o.label++,{value:n[1],done:!1};case 5:o.label++,i=n[1],n=[0];continue;case 7:n=o.ops.pop(),o.trys.pop();continue;default:if(!(s=(s=o.trys).length>0&&s[s.length-1])&&(6===n[0]||2===n[0])){o=0;continue}if(3===n[0]&&(!s||n[1]>s[0]&&n[1]<s[3])){o.label=n[1];break}if(6===n[0]&&o.label<s[1]){o.label=s[1],s=n;break}if(s&&o.label<s[2]){o.label=s[2],o.ops.push(n);break}s[2]&&o.ops.pop(),o.trys.pop();continue}n=t.call(e,o)}catch(e){n=[6,e],i=0}finally{r=s=0}if(5&n[0])throw n[1];return{value:n[0]?n[1]:void 0,done:!0}}([n,u])}}},__importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0});var isomorphic_fetch_1=__importDefault(require("isomorphic-fetch")),VKError_1=require("../VKError"),EventEmitter_1=require("../EventEmitter"),utils_1=require("../utils"),repositories_1=require("../repositories"),VKAPI=function(){function e(e){var t=this;void 0===e&&(e={}),this.queue=[],this.isQueueProcessing=!1,this.eventEmitter=new EventEmitter_1.EventEmitter,this.accessToken=null,this.sendRequest=function(e){return __awaiter(t,void 0,void 0,function(){var t,r,i,s,n,o;return __generator(this,function(u){switch(u.label){case 0:return t=e.method,r=e.params,i=utils_1.recursiveToSnakeCase(__assign({v:this.v,accessToken:this.accessToken,lang:this.lang},r)),s=Object.entries(i).map(function(e){var t=e[0],r=e[1],i="object"==typeof r?JSON.stringify(r):String(r);return encodeURIComponent(t)+"="+encodeURIComponent(i)}).join("&"),n="https://api.vk.com/method/"+t,this.isBrowser?[2,new Promise(function(e,t){var r="__vkapicallback"+Math.random().toString().slice(2),i=document.createElement("script");i.src=n+"?"+s+"&callback="+r,window[r]=function(r){if(document.head.removeChild(i),null==r?void 0:r.response)return e(utils_1.recursiveToCamelCase(r.response));t(new VKError_1.VKError(utils_1.recursiveToCamelCase((null==r?void 0:r.error)||{})))},document.head.appendChild(i)})]:[4,isomorphic_fetch_1.default(n,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded;charset=UTF-8"},body:s})];case 1:return[4,u.sent().json()];case 2:if(null==(o=u.sent())?void 0:o.response)return[2,utils_1.recursiveToCamelCase(o.response)];throw new VKError_1.VKError(utils_1.recursiveToCamelCase((null==o?void 0:o.error)||{}))}})})},this.addRequestToQueue=function(e){var r=Symbol();t.queue.push({config:e,ref:r});var i=new Promise(function(e,i){var s=function(n,o,u){if(r===n){if(t.eventEmitter.off("request-performed",s),o)return i(o);e(u)}};t.eventEmitter.on("request-performed",s)});return t.processQueue(),i};var r=e.rps,i=void 0===r?3:r,s=e.accessToken,n=e.v,o=void 0===n?"5.110":n,u=e.lang,a=void 0===u?"ru":u,c=e.isBrowser,l=void 0!==c&&c;this.accessToken=s||null,this.v=o,this.lang=a,this.timeout=Math.ceil(1e3/i),this.isBrowser=l,this.database=new repositories_1.DatabaseRepository(this.addRequestToQueue),this.messages=new repositories_1.MessagesRepository(this.addRequestToQueue),this.notifications=new repositories_1.NotificationsRepository(this.addRequestToQueue),this.stats=new repositories_1.StatsRepository(this.addRequestToQueue),this.streaming=new repositories_1.StreamingRepository(this.addRequestToQueue),this.users=new repositories_1.UsersRepository(this.addRequestToQueue),this.utils=new repositories_1.UtilsRepository(this.addRequestToQueue),this.widgets=new repositories_1.WidgetsRepository(this.addRequestToQueue)}return e.prototype.processQueue=function(){return __awaiter(this,void 0,void 0,function(){var e,t=this;return __generator(this,function(r){switch(r.label){case 0:return this.isQueueProcessing||0===this.queue.length?[2]:(this.isQueueProcessing=!0,(e=this.queue.map(function(e,r){return new Promise(function(i){setTimeout(function(){return __awaiter(t,void 0,void 0,function(){var t,r,s,n,o;return __generator(this,function(u){switch(u.label){case 0:t=e.config,r=e.ref,s=null,n=null,u.label=1;case 1:return u.trys.push([1,3,,4]),[4,this.sendRequest(t)];case 2:return n=u.sent(),[3,4];case 3:return o=u.sent(),s=o,[3,4];case 4:return this.eventEmitter.emit("request-performed",r,s,n),this.queue.splice(this.queue.indexOf(e),1),i(),[2]}})})},r*t.timeout)})})).push(new Promise(function(e){setTimeout(e,t.queue.length*t.timeout)})),[4,Promise.all(e)]);case 1:return r.sent(),this.isQueueProcessing=!1,this.processQueue(),[2]}})})},e}();exports.VKAPI=VKAPI; | ||
"use strict";var __assign=this&&this.__assign||function(){return(__assign=Object.assign||function(e){for(var t,r=1,s=arguments.length;r<s;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)},__awaiter=this&&this.__awaiter||function(e,t,r,s){return new(r||(r=Promise))(function(i,n){function o(e){try{a(s.next(e))}catch(e){n(e)}}function u(e){try{a(s.throw(e))}catch(e){n(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(o,u)}a((s=s.apply(e,t||[])).next())})},__generator=this&&this.__generator||function(e,t){var r,s,i,n,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return n={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(n[Symbol.iterator]=function(){return this}),n;function u(n){return function(u){return function(n){if(r)throw new TypeError("Generator is already executing.");for(;o;)try{if(r=1,s&&(i=2&n[0]?s.return:n[0]?s.throw||((i=s.return)&&i.call(s),0):s.next)&&!(i=i.call(s,n[1])).done)return i;switch(s=0,i&&(n=[2&n[0],i.value]),n[0]){case 0:case 1:i=n;break;case 4:return o.label++,{value:n[1],done:!1};case 5:o.label++,s=n[1],n=[0];continue;case 7:n=o.ops.pop(),o.trys.pop();continue;default:if(!(i=(i=o.trys).length>0&&i[i.length-1])&&(6===n[0]||2===n[0])){o=0;continue}if(3===n[0]&&(!i||n[1]>i[0]&&n[1]<i[3])){o.label=n[1];break}if(6===n[0]&&o.label<i[1]){o.label=i[1],i=n;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(n);break}i[2]&&o.ops.pop(),o.trys.pop();continue}n=t.call(e,o)}catch(e){n=[6,e],s=0}finally{r=i=0}if(5&n[0])throw n[1];return{value:n[0]?n[1]:void 0,done:!0}}([n,u])}}},__importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0});var isomorphic_fetch_1=__importDefault(require("isomorphic-fetch")),VKError_1=require("../VKError"),EventEmitter_1=require("../EventEmitter"),utils_1=require("../utils"),repositories_1=require("../repositories"),VKAPI=function(){function e(e){var t=this;void 0===e&&(e={}),this.queue=[],this.isQueueProcessing=!1,this.eventEmitter=new EventEmitter_1.EventEmitter,this.accessToken=null,this.sendRequest=function(e){return __awaiter(t,void 0,void 0,function(){var t,r,s,i,n,o;return __generator(this,function(u){switch(u.label){case 0:return t=e.method,r=e.params,s=utils_1.recursiveToSnakeCase(__assign({v:this.v,accessToken:this.accessToken,lang:this.lang},r)),i=Object.entries(s).map(function(e){var t=e[0],r=e[1],s="object"==typeof r?JSON.stringify(r):String(r);return encodeURIComponent(t)+"="+encodeURIComponent(s)}).join("&"),n="https://api.vk.com/method/"+t,this.isBrowser?[2,new Promise(function(e,t){var r="__vkapicallback"+Math.random().toString().slice(2),s=document.createElement("script");s.src=n+"?"+i+"&callback="+r,window[r]=function(r){if(document.head.removeChild(s),null==r?void 0:r.response)return e(utils_1.recursiveToCamelCase(r.response));t(new VKError_1.VKError(utils_1.recursiveToCamelCase((null==r?void 0:r.error)||{})))},document.head.appendChild(s)})]:[4,isomorphic_fetch_1.default(n,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded;charset=UTF-8"},body:i})];case 1:return[4,u.sent().json()];case 2:if(null==(o=u.sent())?void 0:o.response)return[2,utils_1.recursiveToCamelCase(o.response)];throw new VKError_1.VKError(utils_1.recursiveToCamelCase((null==o?void 0:o.error)||{}))}})})},this.addRequestToQueue=function(e){var r=Symbol();t.queue.push({config:e,ref:r});var s=new Promise(function(e,s){var i=function(n,o,u){if(r===n){if(t.eventEmitter.off("request-performed",i),o)return s(o);e(u)}};t.eventEmitter.on("request-performed",i)});return t.processQueue(),s};var r=e.rps,s=void 0===r?3:r,i=e.accessToken,n=e.v,o=void 0===n?"5.110":n,u=e.lang,a=void 0===u?"ru":u,c=e.isBrowser,l=void 0!==c&&c;this.accessToken=i||null,this.v=o,this.lang=a,this.timeout=Math.ceil(1e3/s),this.isBrowser=l,this.database=new repositories_1.DatabaseRepository(this.addRequestToQueue),this.messages=new repositories_1.MessagesRepository(this.addRequestToQueue),this.notifications=new repositories_1.NotificationsRepository(this.addRequestToQueue),this.statEvents=new repositories_1.StatEventsRepository(this.addRequestToQueue),this.stats=new repositories_1.StatsRepository(this.addRequestToQueue),this.streaming=new repositories_1.StreamingRepository(this.addRequestToQueue),this.users=new repositories_1.UsersRepository(this.addRequestToQueue),this.utils=new repositories_1.UtilsRepository(this.addRequestToQueue),this.widgets=new repositories_1.WidgetsRepository(this.addRequestToQueue)}return e.prototype.processQueue=function(){return __awaiter(this,void 0,void 0,function(){var e,t=this;return __generator(this,function(r){switch(r.label){case 0:return this.isQueueProcessing||0===this.queue.length?[2]:(this.isQueueProcessing=!0,(e=this.queue.map(function(e,r){return new Promise(function(s){setTimeout(function(){return __awaiter(t,void 0,void 0,function(){var t,r,i,n,o;return __generator(this,function(u){switch(u.label){case 0:t=e.config,r=e.ref,i=null,n=null,u.label=1;case 1:return u.trys.push([1,3,,4]),[4,this.sendRequest(t)];case 2:return n=u.sent(),[3,4];case 3:return o=u.sent(),i=o,[3,4];case 4:return this.eventEmitter.emit("request-performed",r,i,n),this.queue.splice(this.queue.indexOf(e),1),s(),[2]}})})},r*t.timeout)})})).push(new Promise(function(e){setTimeout(e,t.queue.length*t.timeout)})),[4,Promise.all(e)]);case 1:return r.sent(),this.isQueueProcessing=!1,this.processQueue(),[2]}})})},e}();exports.VKAPI=VKAPI; |
{ | ||
"name": "vkontakte-api", | ||
"version": "1.10.0", | ||
"version": "1.11.0", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "types": "dist/index.d.ts", |
@@ -64,3 +64,3 @@ [npm-badge]: https://img.shields.io/npm/v/vkontakte-api.svg | ||
outer code flow. If this value is not passed, requests will be executed | ||
in usual mode, by on the browser side they will fail due to VK's CORS. | ||
in usual mode and on the browser side they will fail due to VK's CORS. | ||
@@ -67,0 +67,0 @@ ```typescript |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 2 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
122600
149
2150
34