@gudhub/core 1.0.42 → 1.0.43

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.
@@ -128,10 +128,12 @@ export class Auth {
128
128
  async updateUser(userData) {
129
129
  const user = await this.updateUserApi(userData);
130
130
  this.storage.updateUser(user);
131
+ return user;
131
132
  }
132
133
 
133
134
  async updateAvatar(imageData) {
134
135
  const user = await this.avatarUploadApi(imageData);
135
136
  this.storage.updateUser(user);
137
+ return user;
136
138
  }
137
139
  }
@@ -35,4 +35,28 @@ describe("AUTHORIZATION", async function() {
35
35
  user.fullname.should.equal('Vasya Pupkin');
36
36
  })
37
37
 
38
+ it("Update user", async function() {
39
+ const gudhub = new GudHub(auth_key);
40
+
41
+ const dataToUpdate = {
42
+ fullname: 'Vasya Pupkin'
43
+ }
44
+
45
+ const user = await gudhub.updateUser(dataToUpdate);
46
+
47
+ user.fullname.should.equal('Vasya Pupkin');
48
+ })
49
+
50
+ it("Update user avatar", async function() {
51
+ const gudhub = new GudHub(auth_key);
52
+
53
+ const dataToUpdate = {
54
+ avatar: '/9j/4AAQSkZJRgABAQAAAQA'
55
+ }
56
+
57
+ const user = await gudhub.updateUser(dataToUpdate);
58
+
59
+ user.fullname.should.equal('Vasya Pupkin');
60
+ })
61
+
38
62
  });
@@ -46,6 +46,10 @@ export default function(app) {
46
46
  res.status(200).send(data.token);
47
47
  });
48
48
 
49
+ app.post('/auth/updateuser', (req, res) => {
50
+ res.status(200).send(data.token);
51
+ });
52
+
49
53
 
50
54
  app.post('/api/items/update', (req, res) => {
51
55
  let result = null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gudhub/core",
3
- "version": "1.0.42",
3
+ "version": "1.0.43",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -135,7 +135,7 @@ var e,t=arguments[3],n=require("process");!function(n){if("object"==typeof expor
135
135
  },{}],"mWlG":[function(require,module,exports) {
136
136
  "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Utils=void 0;var e=require("./filter/filterPreparation.js"),t=v(require("./filter/filter.js")),r=require("./json_to_items/json_to_items.js"),n=require("./merge_compare_items/merge_compare_items.js"),i=require("./filter/group.js"),u=require("./filter/utils.js"),o=v(require("./populate_items/populate_items.js")),s=require("./get_date/get_date.js"),a=require("./merge_objects/merge_objects.js"),l=require("./merge_chunks/merge_chunks.js"),c=require("./interpretation/interpretation.js"),f=require("./nested_list/nested_list.js"),p=require("./compare_items_lists_worker/compare_items_lists.worker.js"),m=require("./json_constructor/json_constructor.js");function v(e){return e&&e.__esModule?e:{default:e}}function h(e){return _(e)||y(e)||d(e)||g()}function g(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function d(e,t){if(e){if("string"==typeof e)return j(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?j(e,t):void 0}}function y(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function _(e){if(Array.isArray(e))return j(e)}function j(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function k(e,t,r,n,i,u,o){try{var s=e[u](o),a=s.value}catch(l){return void r(l)}s.done?t(a):Promise.resolve(a).then(n,i)}function b(e){return function(){var t=this,r=arguments;return new Promise(function(n,i){var u=e.apply(t,r);function o(e){k(u,n,i,o,s,"next",e)}function s(e){k(u,n,i,o,s,"throw",e)}o(void 0)})}}function w(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function I(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function q(e,t,r){return t&&I(e.prototype,t),r&&I(e,r),e}var A=function(){function v(e){w(this,v),this.gudhub=e}return q(v,[{key:"prefilter",value:function(t,r,n,i){var u=arguments.length>4&&void 0!==arguments[4]?arguments[4]:[];return(0,e.filterPreparation)(t,r,n,i,this.gudhub.storage,this.gudhub.pipeService,u)}},{key:"filter",value:function(e,r){return(0,t.default)(e,r)}},{key:"group",value:function(e,t){return(0,i.group)(e,t)}},{key:"getFilteredItems",value:function(){var e=b(regeneratorRuntime.mark(function e(){var t,r,n,i,o,s,a,l,c,f,p,m=arguments;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return t=m.length>0&&void 0!==m[0]?m[0]:[],r=m.length>1&&void 0!==m[1]?m[1]:[],n=m.length>2?m[2]:void 0,i=m.length>3?m[3]:void 0,o=m.length>4?m[4]:void 0,s=m.length>5&&void 0!==m[5]?m[5]:"",a=m.length>6?m[6]:void 0,l=m.length>7?m[7]:void 0,e.next=10,this.prefilter(r,n,i,o);case 10:return c=e.sent,f=this.filter(t,[].concat(h(r),h(c))),p=this.group(s,f),e.abrupt("return",p.filter(function(e){return!a||1===(0,u.searchValue)([e],a).length}).filter(function(e){return!l||1===(0,u.searchValue)([e],l).length}));case 14:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"jsonToItems",value:function(e,t){return(0,r.jsonToItems)(e,t)}},{key:"getDate",value:function(e){return(0,s.getDate)(e)}},{key:"populateItems",value:function(e,t,r){return(0,o.default)(e,t,r)}},{key:"getInterpretedValue",value:function(e,t,r){return(0,c.getInterpretedValue)(this.gudhub,e,t,r)}},{key:"populateWithDate",value:function(e,t){return(0,s.populateWithDate)(e,t)}},{key:"populateWithItemRef",value:function(e,t,r,i,u,o){return(0,n.populateWithItemRef)(e,t,r,i,u,o)}},{key:"compareItems",value:function(e,t,r){return(0,n.compareItems)(e,t,r)}},{key:"mergeItems",value:function(e,t,r){return(0,n.mergeItems)(e,t,r)}},{key:"mergeObjects",value:function(e,t,r){return(0,a.mergeObjects)(e,t,r)}},{key:"makeNestedList",value:function(e,t,r,n,i){return(0,f.makeNestedList)(e,t,r,n,i)}},{key:"mergeChunks",value:function(e){return(0,l.mergeChunks)(e)}},{key:"jsonConstructor",value:function(e,t,r){return(0,m.compiler)(e,t,this,r)}},{key:"compareAppsItemsLists",value:function(e,t,r){var n=new Blob([(0,p.compare_items_lists_Worker)()],{type:"application/javascript"});this.worker=new Worker(URL.createObjectURL(n)),this.worker.postMessage({items_list1:e,items_list2:t}),this.worker.addEventListener("message",function(e){var t=e.data.diff;r(t)})}}]),v}();exports.Utils=A;
137
137
  },{"./filter/filterPreparation.js":"DvAj","./filter/filter.js":"mbGN","./json_to_items/json_to_items.js":"UCDv","./merge_compare_items/merge_compare_items.js":"xDLX","./filter/group.js":"VgUi","./filter/utils.js":"zsiC","./populate_items/populate_items.js":"EzAv","./get_date/get_date.js":"VzfS","./merge_objects/merge_objects.js":"EE1j","./merge_chunks/merge_chunks.js":"AMYJ","./interpretation/interpretation.js":"pMyP","./nested_list/nested_list.js":"S7Iy","./compare_items_lists_worker/compare_items_lists.worker.js":"xR4c","./json_constructor/json_constructor.js":"nKaW"}],"rK64":[function(require,module,exports) {
138
- "use strict";function e(e,t,r,n,u,a,s){try{var i=e[a](s),o=i.value}catch(c){return void r(c)}i.done?t(o):Promise.resolve(o).then(n,u)}function t(t){return function(){var r=this,n=arguments;return new Promise(function(u,a){var s=t.apply(r,n);function i(t){e(s,u,a,i,o,"next",t)}function o(t){e(s,u,a,i,o,"throw",t)}i(void 0)})}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function u(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),e}Object.defineProperty(exports,"__esModule",{value:!0}),exports.Auth=void 0;var a=function(){function e(t,n){r(this,e),this.req=t,this.storage=n}return u(e,[{key:"login",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.username,r=e.password;return this.req.simplePost({url:"/auth/login",form:{username:t,password:r}})}},{key:"logout",value:function(e){return this.req.post({url:"/auth/logout",form:{token:e}})}},{key:"signup",value:function(e){return this.req.simplePost({url:"/auth/singup",form:{user:JSON.stringify(e)}})}},{key:"getUsersList",value:function(e){return this.req.get({url:"/auth/userlist",params:{keyword:e}})}},{key:"updateUserApi",value:function(e){return this.req.post({url:"/auth/updateuser",form:{user:JSON.stringify(e)}})}},{key:"updateToken",value:function(e){return this.req.simplePost({url:"/auth/login",form:{auth_key:e}})}},{key:"avatarUploadApi",value:function(e){return this.req.post({url:"/auth/avatar-upload",form:{image:e}})}},{key:"getUserByIdApi",value:function(e){return this.req.get({url:"/auth/getuserbyid",params:{id:e}})}},{key:"getVersion",value:function(){return this.req.get({url:"/version"})}},{key:"getUserFromStorage",value:function(e){return this.storage.getUsersList().find(function(t){return t.user_id==e})}},{key:"saveUserToStorage",value:function(e){var t=this.storage.getUsersList(),r=t.find(function(t){return t.user_id==e.user_id});return r||(t.push(e),e)}},{key:"getUserById",value:function(){var e=t(regeneratorRuntime.mark(function e(t){var r,n;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(r=this.getUserFromStorage(t)){e.next=9;break}return e.next=4,this.getUserByIdApi(t);case 4:if(n=e.sent){e.next=7;break}return e.abrupt("return",null);case 7:(r=this.getUserFromStorage(t))||(this.saveUserToStorage(n),r=n);case 9:return e.abrupt("return",r);case 10:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"getToken",value:function(){var e=t(regeneratorRuntime.mark(function e(){var t,r,n,u;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t=new Date(this.storage.getUser().expirydate),r=new Date,n=this.storage.getUser().accesstoken,!(t<r)&&n){e.next=9;break}return e.next=6,this.updateToken(this.storage.getUser().auth_key);case 6:u=e.sent,this.storage.updateUser(u),n=u.accesstoken;case 9:return e.abrupt("return",n);case 10:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"updateUser",value:function(){var e=t(regeneratorRuntime.mark(function e(t){var r;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.updateUserApi(t);case 2:r=e.sent,this.storage.updateUser(r);case 4:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"updateAvatar",value:function(){var e=t(regeneratorRuntime.mark(function e(t){var r;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.avatarUploadApi(t);case 2:r=e.sent,this.storage.updateUser(r);case 4:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()}]),e}();exports.Auth=a;
138
+ "use strict";function e(e,r,t,n,u,a,s){try{var i=e[a](s),o=i.value}catch(c){return void t(c)}i.done?r(o):Promise.resolve(o).then(n,u)}function r(r){return function(){var t=this,n=arguments;return new Promise(function(u,a){var s=r.apply(t,n);function i(r){e(s,u,a,i,o,"next",r)}function o(r){e(s,u,a,i,o,"throw",r)}i(void 0)})}}function t(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}function n(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function u(e,r,t){return r&&n(e.prototype,r),t&&n(e,t),e}Object.defineProperty(exports,"__esModule",{value:!0}),exports.Auth=void 0;var a=function(){function e(r,n){t(this,e),this.req=r,this.storage=n}return u(e,[{key:"login",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.username,t=e.password;return this.req.simplePost({url:"/auth/login",form:{username:r,password:t}})}},{key:"logout",value:function(e){return this.req.post({url:"/auth/logout",form:{token:e}})}},{key:"signup",value:function(e){return this.req.simplePost({url:"/auth/singup",form:{user:JSON.stringify(e)}})}},{key:"getUsersList",value:function(e){return this.req.get({url:"/auth/userlist",params:{keyword:e}})}},{key:"updateUserApi",value:function(e){return this.req.post({url:"/auth/updateuser",form:{user:JSON.stringify(e)}})}},{key:"updateToken",value:function(e){return this.req.simplePost({url:"/auth/login",form:{auth_key:e}})}},{key:"avatarUploadApi",value:function(e){return this.req.post({url:"/auth/avatar-upload",form:{image:e}})}},{key:"getUserByIdApi",value:function(e){return this.req.get({url:"/auth/getuserbyid",params:{id:e}})}},{key:"getVersion",value:function(){return this.req.get({url:"/version"})}},{key:"getUserFromStorage",value:function(e){return this.storage.getUsersList().find(function(r){return r.user_id==e})}},{key:"saveUserToStorage",value:function(e){var r=this.storage.getUsersList(),t=r.find(function(r){return r.user_id==e.user_id});return t||(r.push(e),e)}},{key:"getUserById",value:function(){var e=r(regeneratorRuntime.mark(function e(r){var t,n;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this.getUserFromStorage(r)){e.next=9;break}return e.next=4,this.getUserByIdApi(r);case 4:if(n=e.sent){e.next=7;break}return e.abrupt("return",null);case 7:(t=this.getUserFromStorage(r))||(this.saveUserToStorage(n),t=n);case 9:return e.abrupt("return",t);case 10:case"end":return e.stop()}},e,this)}));return function(r){return e.apply(this,arguments)}}()},{key:"getToken",value:function(){var e=r(regeneratorRuntime.mark(function e(){var r,t,n,u;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(r=new Date(this.storage.getUser().expirydate),t=new Date,n=this.storage.getUser().accesstoken,!(r<t)&&n){e.next=9;break}return e.next=6,this.updateToken(this.storage.getUser().auth_key);case 6:u=e.sent,this.storage.updateUser(u),n=u.accesstoken;case 9:return e.abrupt("return",n);case 10:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"updateUser",value:function(){var e=r(regeneratorRuntime.mark(function e(r){var t;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.updateUserApi(r);case 2:return t=e.sent,this.storage.updateUser(t),e.abrupt("return",t);case 5:case"end":return e.stop()}},e,this)}));return function(r){return e.apply(this,arguments)}}()},{key:"updateAvatar",value:function(){var e=r(regeneratorRuntime.mark(function e(r){var t;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.avatarUploadApi(r);case 2:return t=e.sent,this.storage.updateUser(t),e.abrupt("return",t);case 5:case"end":return e.stop()}},e,this)}));return function(r){return e.apply(this,arguments)}}()}]),e}();exports.Auth=a;
139
139
  },{}],"UV2u":[function(require,module,exports) {
140
140
  "use strict";function e(o){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(o)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.IS_WEB=void 0;var o=!["undefined"==typeof window?"undefined":e(window),"undefined"==typeof document?"undefined":e(document)].includes("undefined");exports.IS_WEB=o;
141
141
  },{}],"I3sf":[function(require,module,exports) {