vkontakte-api
Advanced tools
Comparing version 1.4.0 to 1.4.1
@@ -5,2 +5,10 @@ # Changelog | ||
### [1.4.1](https://github.com/wolframdeus/vk-api/compare/v1.4.0...v1.4.1) (2020-06-17) | ||
### Bug Fixes | ||
* **messages.send:** generate randomId for user if not passed ([0e8ab33](https://github.com/wolframdeus/vk-api/commit/0e8ab339deb10cfa593866adf124bdfce9b4c6a0)) | ||
* **requests-queue:** add promise which correctly releases processor ([75e62c1](https://github.com/wolframdeus/vk-api/commit/75e62c1ebbf9b564309d4e5585004ae57a6e0874)) | ||
## [1.4.0](https://github.com/wolframdeus/vk-api/compare/v1.3.9...v1.4.0) (2020-06-17) | ||
@@ -7,0 +15,0 @@ |
@@ -1,1 +0,1 @@ | ||
"use strict";var __extends=this&&this.__extends||function(){var e=function(t,o){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var o in t)t.hasOwnProperty(o)&&(e[o]=t[o])})(t,o)};return function(t,o){function r(){this.constructor=t}e(t,o),t.prototype=null===o?Object.create(o):(r.prototype=o.prototype,new r)}}();Object.defineProperty(exports,"__esModule",{value:!0});var Repository_1=require("../Repository"),MessagesRepository=function(e){function t(t){var o=e.call(this,"messages",t)||this;return o.send=function(e){return o.sendRequest({method:"send",params:e})},o}return __extends(t,e),t}(Repository_1.Repository);exports.MessagesRepository=MessagesRepository; | ||
"use strict";var __extends=this&&this.__extends||function(){var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(e,r)};return function(e,r){function o(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(o.prototype=r.prototype,new o)}}(),__assign=this&&this.__assign||function(){return(__assign=Object.assign||function(t){for(var e,r=1,o=arguments.length;r<o;r++)for(var n in e=arguments[r])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t}).apply(this,arguments)},__rest=this&&this.__rest||function(t,e){var r={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&e.indexOf(o)<0&&(r[o]=t[o]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(o=Object.getOwnPropertySymbols(t);n<o.length;n++)e.indexOf(o[n])<0&&Object.prototype.propertyIsEnumerable.call(t,o[n])&&(r[o[n]]=t[o[n]])}return r};Object.defineProperty(exports,"__esModule",{value:!0});var Repository_1=require("../Repository"),MessagesRepository=function(t){function e(e){var r=t.call(this,"messages",e)||this;return r.send=function(t){var e=t.randomId,o=__rest(t,["randomId"]);return r.sendRequest({method:"send",params:__assign(__assign({},o),{randomId:e||Math.floor(1e7*Math.random())})})},r}return __extends(e,t),e}(Repository_1.Repository);exports.MessagesRepository=MessagesRepository; |
@@ -1,1 +0,1 @@ | ||
"use strict";var __assign=this&&this.__assign||function(){return(__assign=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;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,n){return new(r||(r=Promise))(function(i,s){function o(e){try{a(n.next(e))}catch(e){s(e)}}function u(e){try{a(n.throw(e))}catch(e){s(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((n=n.apply(e,t||[])).next())})},__generator=this&&this.__generator||function(e,t){var r,n,i,s,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function u(s){return function(u){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;o;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,n=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(i=(i=o.trys).length>0&&i[i.length-1])&&(6===s[0]||2===s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],n=0}finally{r=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,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,n,i,s;return __generator(this,function(o){switch(o.label){case 0:return t=e.method,r=e.params,n=utils_1.recursiveToSnakeCase(__assign({v:this.v,accessToken:this.accessToken,lang:this.lang},r)),i=Object.entries(n).map(function(e){var t=e[0],r=e[1],n="object"==typeof r?JSON.stringify(r):String(r);return encodeURIComponent(t)+"="+encodeURIComponent(n)}).join("&"),[4,isomorphic_fetch_1.default("https://api.vk.com/method/"+t,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded;charset=UTF-8"},body:i})];case 1:return[4,o.sent().json()];case 2:if((s=o.sent()).error)throw new VKError_1.VKError(utils_1.recursiveToCamelCase(s.error));return[2,utils_1.recursiveToCamelCase(s.response)]}})})},this.addRequestToQueue=function(e){var r=Symbol();t.queue.push({config:e,ref:r});var n=new Promise(function(e,n){var i=function(s,o,u){if(r===s){if(t.eventEmitter.off("request-performed",i),o)return n(o);e(u)}};t.eventEmitter.on("request-performed",i)});return t.processQueue(),n};var r=e.rps,n=void 0===r?3:r,i=e.accessToken,s=e.v,o=void 0===s?"5.110":s,u=e.lang,a=void 0===u?"ru":u;this.accessToken=i||null,this.v=o,this.lang=a,this.timeout=Math.ceil(1e3/n),this.users=new repositories_1.UsersRepository(this.addRequestToQueue),this.messages=new repositories_1.MessagesRepository(this.addRequestToQueue),this.notifications=new repositories_1.NotificationsRepository(this.addRequestToQueue)}return e.prototype.processQueue=function(){return __awaiter(this,void 0,void 0,function(){var e=this;return __generator(this,function(t){switch(t.label){case 0:return this.isQueueProcessing||0===this.queue.length?[2]:(this.isQueueProcessing=!0,[4,Promise.all(this.queue.map(function(t,r){return new Promise(function(n){setTimeout(function(){return __awaiter(e,void 0,void 0,function(){var e,r,i,s,o;return __generator(this,function(u){switch(u.label){case 0:e=t.config,r=t.ref,i=null,s=null,u.label=1;case 1:return u.trys.push([1,3,,4]),[4,this.sendRequest(e)];case 2:return s=u.sent(),[3,4];case 3:return o=u.sent(),i=o,[3,4];case 4:return this.eventEmitter.emit("request-performed",r,i,s),this.queue.splice(this.queue.indexOf(t),1),n(),[2]}})})},r*e.timeout)})}))]);case 1:return t.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,n=arguments.length;r<n;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,n){return new(r||(r=Promise))(function(i,s){function o(e){try{a(n.next(e))}catch(e){s(e)}}function u(e){try{a(n.throw(e))}catch(e){s(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((n=n.apply(e,t||[])).next())})},__generator=this&&this.__generator||function(e,t){var r,n,i,s,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function u(s){return function(u){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;o;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,n=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(i=(i=o.trys).length>0&&i[i.length-1])&&(6===s[0]||2===s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],n=0}finally{r=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,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,n,i,s;return __generator(this,function(o){switch(o.label){case 0:return t=e.method,r=e.params,n=utils_1.recursiveToSnakeCase(__assign({v:this.v,accessToken:this.accessToken,lang:this.lang},r)),i=Object.entries(n).map(function(e){var t=e[0],r=e[1],n="object"==typeof r?JSON.stringify(r):String(r);return encodeURIComponent(t)+"="+encodeURIComponent(n)}).join("&"),[4,isomorphic_fetch_1.default("https://api.vk.com/method/"+t,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded;charset=UTF-8"},body:i})];case 1:return[4,o.sent().json()];case 2:if((s=o.sent()).error)throw new VKError_1.VKError(utils_1.recursiveToCamelCase(s.error));return[2,utils_1.recursiveToCamelCase(s.response)]}})})},this.addRequestToQueue=function(e){var r=Symbol();t.queue.push({config:e,ref:r});var n=new Promise(function(e,n){var i=function(s,o,u){if(r===s){if(t.eventEmitter.off("request-performed",i),o)return n(o);e(u)}};t.eventEmitter.on("request-performed",i)});return t.processQueue(),n};var r=e.rps,n=void 0===r?3:r,i=e.accessToken,s=e.v,o=void 0===s?"5.110":s,u=e.lang,a=void 0===u?"ru":u;this.accessToken=i||null,this.v=o,this.lang=a,this.timeout=Math.ceil(1e3/n),this.users=new repositories_1.UsersRepository(this.addRequestToQueue),this.messages=new repositories_1.MessagesRepository(this.addRequestToQueue),this.notifications=new repositories_1.NotificationsRepository(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(n){setTimeout(function(){return __awaiter(t,void 0,void 0,function(){var t,r,i,s,o;return __generator(this,function(u){switch(u.label){case 0:t=e.config,r=e.ref,i=null,s=null,u.label=1;case 1:return u.trys.push([1,3,,4]),[4,this.sendRequest(t)];case 2:return s=u.sent(),[3,4];case 3:return o=u.sent(),i=o,[3,4];case 4:return this.eventEmitter.emit("request-performed",r,i,s),this.queue.splice(this.queue.indexOf(e),1),n(),[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.4.0", | ||
"version": "1.4.1", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "types": "dist/index.d.ts", |
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
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
64594