Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mfdb

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mfdb - npm Package Compare versions

Comparing version 0.0.11-alpha to 0.0.12-alpha

2

dist/index-node.js

@@ -1,1 +0,1 @@

!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var r=t();for(var n in r)("object"==typeof exports?exports:e)[n]=r[n]}}(global,(function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var a=t[n]={i:n,l:!1,exports:{}};return e[n].call(a.exports,a,a.exports,r),a.l=!0,a.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)r.d(n,a,function(t){return e[t]}.bind(null,a));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=6)}([function(e,t){e.exports=require("fast-json-stable-stringify")},function(e,t){e.exports=require("core-js/stable")},function(e,t){e.exports=require("regenerator-runtime/runtime")},function(e,t){e.exports=require("immutable-sorted")},function(e,t){e.exports=require("it-all")},function(e,t){e.exports=require("it-to-buffer")},function(e,t,r){"use strict";r.r(t),r.d(t,"MFdb",(function(){return S}));r(1),r(2);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)}}var a=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.indexMaps={}}var t,r,a;return t=e,(r=[{key:"cacheIndexMap",value:function(e,t,r,n){this.indexMaps[e]||(this.indexMaps[e]={}),this.indexMaps[e][t]||(this.indexMaps[e][t]={}),this.indexMaps[e][t][r]=n}},{key:"getCachedIndexMap",value:function(e,t,r){if(this.indexMaps&&this.indexMaps[e]&&this.indexMaps[e][t])return this.indexMaps[e][t][r]}}])&&n(t.prototype,r),a&&n(t,a),e}();function i(e,t,r,n,a,i,s){try{var c=e[i](s),o=c.value}catch(e){return void r(e)}c.done?t(o):Promise.resolve(o).then(n,a)}function s(e){return function(){var t=this,r=arguments;return new Promise((function(n,a){var s=e.apply(t,r);function c(e){i(s,n,a,c,o,"next",e)}function o(e){i(s,n,a,c,o,"throw",e)}c(void 0)}))}}function c(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)}}var o=r(5),u=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.ipfs=t}var t,r,n,a,i;return t=e,(r=[{key:"getDatabasePath",value:function(t){return"/".concat(e.MFS_DB,"/").concat(t)}},{key:"getTableDirectoryName",value:function(e,t){return"".concat(this.getDatabasePath(e),"/").concat(t)}},{key:"fileExists",value:(i=s(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this.ipfs.files.stat(t);case 3:return e.abrupt("return",!0);case 6:return e.prev=6,e.t0=e.catch(0),e.abrupt("return",!1);case 9:case"end":return e.stop()}}),e,this,[[0,6]])}))),function(e){return i.apply(this,arguments)})},{key:"getFileContent",value:(a=s(regeneratorRuntime.mark((function e(t){var r,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,o(this.ipfs.files.read(t));case 2:return r=e.sent,n=r.toString(),e.abrupt("return",JSON.parse(n));case 5:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})}])&&c(t.prototype,r),n&&c(t,n),e}();function f(e,t,r,n,a,i,s){try{var c=e[i](s),o=c.value}catch(e){return void r(e)}c.done?t(o):Promise.resolve(o).then(n,a)}function h(e){return function(){var t=this,r=arguments;return new Promise((function(n,a){var i=e.apply(t,r);function s(e){f(i,n,a,s,c,"next",e)}function c(e){f(i,n,a,s,c,"throw",e)}s(void 0)}))}}function p(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)}}u.MFS_DB="mfdb";var l=r(0),v=function(){function e(t,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.pathService=t,this.ipfs=r}var t,r,n,a,i;return t=e,(r=[{key:"saveSchema",value:(i=h(regeneratorRuntime.mark((function t(r){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n="".concat(this.pathService.getTableDirectoryName(r.database,r.name),"/_metadata/").concat(e.SCHEMA_FILENAME),console.debug("Saving schema for table ".concat(r.name," (").concat(r.database,") at ").concat(n)),t.next=4,this.ipfs.files.write(n,l(r.schema),{create:!0,parents:!0,flush:!0});case 4:case"end":return t.stop()}}),t,this)}))),function(e){return i.apply(this,arguments)})},{key:"getSchemaForTable",value:(a=h(regeneratorRuntime.mark((function t(r,n){var a;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,this.pathService.getFileContent("".concat(this.pathService.getTableDirectoryName(r,n),"/_metadata/").concat(e.SCHEMA_FILENAME));case 3:a=t.sent,t.next=8;break;case 6:t.prev=6,t.t0=t.catch(0);case 8:return t.abrupt("return",a);case 9:case"end":return t.stop()}}),t,this,[[0,6]])}))),function(e,t){return a.apply(this,arguments)})}])&&p(t.prototype,r),n&&p(t,n),e}();function d(e,t){var r;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(r=function(e,t){if(!e)return;if("string"==typeof e)return b(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return b(e,t)}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,a=function(){};return{s:a,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,s=!0,c=!1;return{s:function(){r=e[Symbol.iterator]()},n:function(){var e=r.next();return s=e.done,e},e:function(e){c=!0,i=e},f:function(){try{s||null==r.return||r.return()}finally{if(c)throw i}}}}function b(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 x(e,t,r,n,a,i,s){try{var c=e[i](s),o=c.value}catch(e){return void r(e)}c.done?t(o):Promise.resolve(o).then(n,a)}function g(e){return function(){var t=this,r=arguments;return new Promise((function(n,a){var i=e.apply(t,r);function s(e){x(i,n,a,s,c,"next",e)}function c(e){x(i,n,a,s,c,"throw",e)}s(void 0)}))}}function m(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)}}v.SCHEMA_FILENAME="schema.json";var y=r(3).SortedMap,k=r(0),w=r(4),S=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.ipfs=t,this.indexService=new a,this.pathService=new u(this.ipfs),this.schemaService=new v(this.pathService,this.ipfs)}var t,r,n,i,s,c,o,f,h,p,l,b,x,S,D,R,M,T,E,I;return t=e,(r=[{key:"createDatabase",value:(I=g(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.databaseExists(t);case 2:if(!e.sent){e.next=4;break}throw Error("Database already exists");case 4:return console.debug("Creating database ".concat(t," at ").concat(this.pathService.getDatabasePath(t))),e.next=7,this.ipfs.files.mkdir(this.pathService.getDatabasePath(t),{parents:!0});case 7:case"end":return e.stop()}}),e,this)}))),function(e){return I.apply(this,arguments)})},{key:"createTable",value:(E=g(regeneratorRuntime.mark((function e(t){var r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r="".concat(this.pathService.getTableDirectoryName(t.database,t.name),"/_metadata/").concat(v.SCHEMA_FILENAME),console.debug("Saving schema for table ".concat(t.name," (").concat(t.database,") at ").concat(r)),e.next=4,this.ipfs.files.write(r,k(t.schema),{create:!0,parents:!0,flush:!0});case 4:case"end":return e.stop()}}),e,this)}))),function(e){return E.apply(this,arguments)})},{key:"databaseExists",value:(T=g(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.pathService.fileExists(this.pathService.getDatabasePath(t)));case 1:case"end":return e.stop()}}),e,this)}))),function(e){return T.apply(this,arguments)})},{key:"dropDatabase",value:(M=g(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this.ipfs.files.rm(this.pathService.getDatabasePath(t),{recursive:!0});case 3:e.next=7;break;case 5:e.prev=5,e.t0=e.catch(0);case 7:case"end":return e.stop()}}),e,this,[[0,5]])}))),function(e){return M.apply(this,arguments)})},{key:"useDatabase",value:function(e){console.debug("Using database ".concat(e)),this.selectedDatabase=e}},{key:"startTransaction",value:function(){console.debug("Starting new transaction"),this.activeTransaction={changes:[],tables:[]}}},{key:"commit",value:(R=g(regeneratorRuntime.mark((function e(){var t,r,n,a,i,s;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:console.debug("Commiting ".concat(this.activeTransaction.changes.length," changes to: ").concat(this.activeTransaction.tables)),t=d(this.activeTransaction.changes),e.prev=2,t.s();case 4:if((r=t.n()).done){e.next=10;break}return n=r.value,e.next=8,n();case 8:e.next=4;break;case 10:e.next=15;break;case 12:e.prev=12,e.t0=e.catch(2),t.e(e.t0);case 15:return e.prev=15,t.f(),e.finish(15);case 18:a=d(this.activeTransaction.tables),e.prev=19,a.s();case 21:if((i=a.n()).done){e.next=27;break}return s=i.value,e.next=25,this.flushIndexes(s);case 25:e.next=21;break;case 27:e.next=32;break;case 29:e.prev=29,e.t1=e.catch(19),a.e(e.t1);case 32:return e.prev=32,a.f(),e.finish(32);case 35:delete this.activeTransaction;case 36:case"end":return e.stop()}}),e,this,[[2,12,15,18],[19,29,32,35]])}))),function(){return R.apply(this,arguments)})},{key:"put",value:(D=g(regeneratorRuntime.mark((function e(t,r,n){var a=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.selectedDatabase){e.next=2;break}throw Error("No database selected");case 2:if(this.activeTransaction){e.next=4;break}throw Error("No transaction started");case 4:this.queueChange(t,g(regeneratorRuntime.mark((function e(){var i,s,c,o;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i="".concat(a.pathService.getTableDirectoryName(a.selectedDatabase,t),"/").concat(r),e.next=3,a.pathService.fileExists(i);case 3:if(!e.sent){e.next=7;break}return e.next=6,a.get(t,r);case 6:s=e.sent;case 7:return e.next=9,a.schemaService.getSchemaForTable(a.selectedDatabase,t);case 9:c=e.sent,e.t0=regeneratorRuntime.keys(c);case 11:if((e.t1=e.t0()).done){e.next=18;break}return o=e.t1.value,console.debug("Updating ".concat(o," index in ").concat(t)),e.next=16,a.updateIndex(t,o,r,n[o],s?s[o]:void 0);case 16:e.next=11;break;case 18:return e.next=20,a.pathService.fileExists(i);case 20:if(!e.sent){e.next=23;break}return e.next=23,a.ipfs.files.rm(i);case 23:return console.debug("Writing value to MFS at ".concat(i)),e.next=26,a.ipfs.files.write(i,k(n),{create:!0,flush:!0});case 26:case"end":return e.stop()}}),e)}))));case 5:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return D.apply(this,arguments)})},{key:"get",value:(S=g(regeneratorRuntime.mark((function e(t,r){var n,a;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.selectedDatabase){e.next=2;break}throw Error("No database selected");case 2:return a="".concat(this.pathService.getTableDirectoryName(this.selectedDatabase,t),"/").concat(r),e.prev=3,console.debug("Getting value from MFS at ".concat(a)),e.next=7,this.pathService.getFileContent(a);case 7:n=e.sent,e.next=12;break;case 10:e.prev=10,e.t0=e.catch(3);case 12:return e.abrupt("return",n);case 13:case"end":return e.stop()}}),e,this,[[3,10]])}))),function(e,t){return S.apply(this,arguments)})},{key:"getCID",value:(x=g(regeneratorRuntime.mark((function e(t,r){var n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.ipfs.files.stat("".concat(this.pathService.getTableDirectoryName(this.selectedDatabase,t),"/").concat(r));case 2:return n=e.sent,e.abrupt("return",n.cid);case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return x.apply(this,arguments)})},{key:"getByIndex",value:(b=g(regeneratorRuntime.mark((function e(t,r,n,a){var i,s,c,o,u,f,h,p,l,v,b,x,g,m,y,k,w=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=w.length>4&&void 0!==w[4]?w[4]:0,s=w.length>5&&void 0!==w[5]?w[5]:1,this.selectedDatabase){e.next=4;break}throw Error("No database selected");case 4:return e.next=6,this.schemaService.getSchemaForTable(this.selectedDatabase,t);case 6:return c=e.sent,o=c[r],e.next=10,this.getIndexMap(t,r);case 10:if(u=e.sent,c&&o&&u){e.next=13;break}return e.abrupt("return",[]);case 13:if(f=[],h=[],n)if(o.unique)p=u.get(n),h.push(p);else{l=u.get(n),v=d(l);try{for(v.s();!(b=v.n()).done;)x=b.value,h.push(x)}catch(e){v.e(e)}finally{v.f()}}else h=Object.keys(u.toSeq().toJS());h.sort(),"asc"==a&&h.reverse(),g=0,m=d(h),e.prev=20,m.s();case 22:if((y=m.n()).done){e.next=39;break}if(k=y.value,!(f.length>=s)){e.next=26;break}return e.abrupt("break",39);case 26:if(!(g<i)){e.next=31;break}return g++,e.abrupt("continue",37);case 31:g++;case 32:return e.t0=f,e.next=35,this.get(t,k);case 35:e.t1=e.sent,e.t0.push.call(e.t0,e.t1);case 37:e.next=22;break;case 39:e.next=44;break;case 41:e.prev=41,e.t2=e.catch(20),m.e(e.t2);case 44:return e.prev=44,m.f(),e.finish(44);case 47:return e.abrupt("return",f);case 48:case"end":return e.stop()}}),e,this,[[20,41,44,47]])}))),function(e,t,r,n){return b.apply(this,arguments)})},{key:"count",value:(l=g(regeneratorRuntime.mark((function e(t){var r,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.selectedDatabase){e.next=2;break}throw Error("No database selected");case 2:return e.next=4,w(this.ipfs.files.ls("".concat(this.pathService.getTableDirectoryName(this.selectedDatabase,t))));case 4:return r=e.sent,n=r.filter((function(e){return"file"==e.type})).length,e.abrupt("return",n);case 7:case"end":return e.stop()}}),e,this)}))),function(e){return l.apply(this,arguments)})},{key:"delete",value:(p=g(regeneratorRuntime.mark((function e(t,r){var n=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.selectedDatabase){e.next=2;break}throw Error("No database selected");case 2:if(this.activeTransaction){e.next=4;break}throw Error("No transaction started");case 4:this.queueChange(t,g(regeneratorRuntime.mark((function e(){var a,i,s,c;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n.get(t,r);case 2:return a=e.sent,e.next=5,n.schemaService.getSchemaForTable(n.selectedDatabase,t);case 5:i=e.sent,e.t0=regeneratorRuntime.keys(i);case 7:if((e.t1=e.t0()).done){e.next=14;break}return s=e.t1.value,console.debug("Updating ".concat(s," index in ").concat(t)),e.next=12,n.updateIndex(t,s,r,void 0,a?a[s]:void 0);case 12:e.next=7;break;case 14:return c="".concat(n.pathService.getTableDirectoryName(n.selectedDatabase,t),"/").concat(r),console.debug("Removivng file from MFS at ".concat(c)),e.next=18,n.pathService.fileExists(c);case 18:if(!e.sent){e.next=21;break}return e.next=21,n.ipfs.files.rm(c,{flush:!0});case 21:case"end":return e.stop()}}),e)}))));case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return p.apply(this,arguments)})},{key:"getDatabaseCid",value:(h=g(regeneratorRuntime.mark((function e(t){var r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.databaseExists(t)){e.next=2;break}throw Error("Database does not exist");case 2:return e.next=4,this.ipfs.files.stat(this.pathService.getDatabasePath(t));case 4:return r=e.sent,e.abrupt("return",r.cid);case 6:case"end":return e.stop()}}),e,this)}))),function(e){return h.apply(this,arguments)})},{key:"updateFromCid",value:(f=g(regeneratorRuntime.mark((function e(t,r){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return console.log("Updating ".concat(t," from ").concat(r)),e.next=3,this.ipfs.files.rm(this.pathService.getDatabasePath(t),{recursive:!0});case 3:return e.next=5,this.ipfs.files.cp("/ipfs/".concat(r),this.pathService.getDatabasePath(t));case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return f.apply(this,arguments)})},{key:"queueChange",value:function(e,t){this.activeTransaction.changes.push(t),0==this.activeTransaction.tables.filter((function(t){return t==e})).length&&this.activeTransaction.tables.push(e)}},{key:"getDefinitionForIndex",value:(o=g(regeneratorRuntime.mark((function e(t,r){var n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.schemaService.getSchemaForTable(this.selectedDatabase,t);case 2:return n=e.sent,e.abrupt("return",n[r]);case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return o.apply(this,arguments)})},{key:"getIndexMap",value:(c=g(regeneratorRuntime.mark((function e(t,r){var n,a,i,s;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(n=this.indexService.getCachedIndexMap(this.selectedDatabase,t,r))){e.next=3;break}return e.abrupt("return",n);case 3:return e.prev=3,i="".concat(this.pathService.getTableDirectoryName(this.selectedDatabase,t),"/_indexMaps/").concat(r),e.next=7,this.ipfs.files.stat(i);case 7:return e.next=9,this.pathService.getFileContent(i);case 9:s=e.sent,a=y(s),e.next=15;break;case 13:e.prev=13,e.t0=e.catch(3);case 15:return a||(a=y()),this.indexService.cacheIndexMap(this.selectedDatabase,t,r,a),e.abrupt("return",a);case 18:case"end":return e.stop()}}),e,this,[[3,13]])}))),function(e,t){return c.apply(this,arguments)})},{key:"updateIndex",value:(s=g(regeneratorRuntime.mark((function e(t,r,n,a,i){var s,c,o,u,f,h,p;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getIndexMap(t,r);case 2:return s=e.sent,e.next=5,this.getDefinitionForIndex(t,r);case 5:if(c=e.sent,s&&c){e.next=8;break}return e.abrupt("return");case 8:c.unique?a?s=s.set(a,n):i&&(s=s.delete(i)):(o=Boolean(!i)&&Boolean(a),u=!o&&a!=i,i&&u&&(f=s.get(i),(h=f.indexOf(n))>=0&&(f.splice(h,1),s=s.set(i,f))),a&&(u||o)&&((p=s.get(a))||(p=[],s=s.set(a,p)),p.push(n))),this.indexService.cacheIndexMap(this.selectedDatabase,t,r,s);case 10:case"end":return e.stop()}}),e,this)}))),function(e,t,r,n,a){return s.apply(this,arguments)})},{key:"flushIndexes",value:(i=g(regeneratorRuntime.mark((function e(t){var r,n,a,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.schemaService.getSchemaForTable(this.selectedDatabase,t);case 2:r=e.sent,e.t0=regeneratorRuntime.keys(r);case 4:if((e.t1=e.t0()).done){e.next=19;break}if(n=e.t1.value,a="".concat(this.pathService.getTableDirectoryName(this.selectedDatabase,t),"/_indexMaps/").concat(n),!(i=this.indexService.getCachedIndexMap(this.selectedDatabase,t,n))){e.next=17;break}return e.next=11,this.pathService.fileExists(a);case 11:if(!e.sent){e.next=14;break}return e.next=14,this.ipfs.files.rm(a,{flush:!0});case 14:return console.debug("Writing indexMap to MFS at ".concat(a)),e.next=17,this.ipfs.files.write(a,k(i),{create:!0,parents:!0,flush:!0});case 17:e.next=4;break;case 19:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})}])&&m(t.prototype,r),n&&m(t,n),e}()}])}));
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var r=t();for(var n in r)("object"==typeof exports?exports:e)[n]=r[n]}}(global,(function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var a=t[n]={i:n,l:!1,exports:{}};return e[n].call(a.exports,a,a.exports,r),a.l=!0,a.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)r.d(n,a,function(t){return e[t]}.bind(null,a));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=6)}([function(e,t){e.exports=require("fast-json-stable-stringify")},function(e,t){e.exports=require("core-js/stable")},function(e,t){e.exports=require("regenerator-runtime/runtime")},function(e,t){e.exports=require("immutable-sorted")},function(e,t){e.exports=require("it-all")},function(e,t){e.exports=require("it-to-buffer")},function(e,t,r){"use strict";r.r(t),r.d(t,"MFdb",(function(){return S}));r(1),r(2);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)}}var a=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.indexMaps={}}var t,r,a;return t=e,(r=[{key:"cacheIndexMap",value:function(e,t,r,n){this.indexMaps[e]||(this.indexMaps[e]={}),this.indexMaps[e][t]||(this.indexMaps[e][t]={}),this.indexMaps[e][t][r]=n}},{key:"getCachedIndexMap",value:function(e,t,r){if(this.indexMaps&&this.indexMaps[e]&&this.indexMaps[e][t])return this.indexMaps[e][t][r]}}])&&n(t.prototype,r),a&&n(t,a),e}();function i(e,t,r,n,a,i,s){try{var c=e[i](s),o=c.value}catch(e){return void r(e)}c.done?t(o):Promise.resolve(o).then(n,a)}function s(e){return function(){var t=this,r=arguments;return new Promise((function(n,a){var s=e.apply(t,r);function c(e){i(s,n,a,c,o,"next",e)}function o(e){i(s,n,a,c,o,"throw",e)}c(void 0)}))}}function c(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)}}var o=r(5),u=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.ipfs=t}var t,r,n,a,i;return t=e,(r=[{key:"getDatabasePath",value:function(t){return"/".concat(e.MFS_DB,"/").concat(t)}},{key:"getTableDirectoryName",value:function(e,t){return"".concat(this.getDatabasePath(e),"/").concat(t)}},{key:"fileExists",value:(i=s(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this.ipfs.files.stat(t);case 3:return e.abrupt("return",!0);case 6:return e.prev=6,e.t0=e.catch(0),e.abrupt("return",!1);case 9:case"end":return e.stop()}}),e,this,[[0,6]])}))),function(e){return i.apply(this,arguments)})},{key:"getFileContent",value:(a=s(regeneratorRuntime.mark((function e(t){var r,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,o(this.ipfs.files.read(t));case 2:return r=e.sent,n=r.toString(),e.abrupt("return",JSON.parse(n));case 5:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})}])&&c(t.prototype,r),n&&c(t,n),e}();function f(e,t,r,n,a,i,s){try{var c=e[i](s),o=c.value}catch(e){return void r(e)}c.done?t(o):Promise.resolve(o).then(n,a)}function h(e){return function(){var t=this,r=arguments;return new Promise((function(n,a){var i=e.apply(t,r);function s(e){f(i,n,a,s,c,"next",e)}function c(e){f(i,n,a,s,c,"throw",e)}s(void 0)}))}}function p(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)}}u.MFS_DB="mfdb";var l=r(0),v=function(){function e(t,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.pathService=t,this.ipfs=r}var t,r,n,a,i;return t=e,(r=[{key:"saveSchema",value:(i=h(regeneratorRuntime.mark((function t(r){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n="".concat(this.pathService.getTableDirectoryName(r.database,r.name),"/_metadata/").concat(e.SCHEMA_FILENAME),console.debug("Saving schema for table ".concat(r.name," (").concat(r.database,") at ").concat(n)),t.next=4,this.ipfs.files.write(n,l(r.schema),{create:!0,parents:!0,flush:!0});case 4:case"end":return t.stop()}}),t,this)}))),function(e){return i.apply(this,arguments)})},{key:"getSchemaForTable",value:(a=h(regeneratorRuntime.mark((function t(r,n){var a;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,this.pathService.getFileContent("".concat(this.pathService.getTableDirectoryName(r,n),"/_metadata/").concat(e.SCHEMA_FILENAME));case 3:a=t.sent,t.next=8;break;case 6:t.prev=6,t.t0=t.catch(0);case 8:return t.abrupt("return",a);case 9:case"end":return t.stop()}}),t,this,[[0,6]])}))),function(e,t){return a.apply(this,arguments)})}])&&p(t.prototype,r),n&&p(t,n),e}();function d(e,t){var r;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(r=function(e,t){if(!e)return;if("string"==typeof e)return b(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return b(e,t)}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,a=function(){};return{s:a,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,s=!0,c=!1;return{s:function(){r=e[Symbol.iterator]()},n:function(){var e=r.next();return s=e.done,e},e:function(e){c=!0,i=e},f:function(){try{s||null==r.return||r.return()}finally{if(c)throw i}}}}function b(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 x(e,t,r,n,a,i,s){try{var c=e[i](s),o=c.value}catch(e){return void r(e)}c.done?t(o):Promise.resolve(o).then(n,a)}function g(e){return function(){var t=this,r=arguments;return new Promise((function(n,a){var i=e.apply(t,r);function s(e){x(i,n,a,s,c,"next",e)}function c(e){x(i,n,a,s,c,"throw",e)}s(void 0)}))}}function m(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)}}v.SCHEMA_FILENAME="schema.json";var y=r(3).SortedMap,k=r(0),w=r(4),S=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.ipfs=t,this.indexService=new a,this.pathService=new u(this.ipfs),this.schemaService=new v(this.pathService,this.ipfs)}var t,r,n,i,s,c,o,f,h,p,l,b,x,S,D,R,M,T,E,I;return t=e,(r=[{key:"createDatabase",value:(I=g(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.databaseExists(t);case 2:if(!e.sent){e.next=4;break}throw Error("Database already exists");case 4:return console.debug("Creating database ".concat(t," at ").concat(this.pathService.getDatabasePath(t))),e.next=7,this.ipfs.files.mkdir(this.pathService.getDatabasePath(t),{parents:!0});case 7:case"end":return e.stop()}}),e,this)}))),function(e){return I.apply(this,arguments)})},{key:"createTable",value:(E=g(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.schemaService.saveSchema(t);case 2:case"end":return e.stop()}}),e,this)}))),function(e){return E.apply(this,arguments)})},{key:"databaseExists",value:(T=g(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.pathService.fileExists(this.pathService.getDatabasePath(t)));case 1:case"end":return e.stop()}}),e,this)}))),function(e){return T.apply(this,arguments)})},{key:"dropDatabase",value:(M=g(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this.ipfs.files.rm(this.pathService.getDatabasePath(t),{recursive:!0});case 3:e.next=7;break;case 5:e.prev=5,e.t0=e.catch(0);case 7:case"end":return e.stop()}}),e,this,[[0,5]])}))),function(e){return M.apply(this,arguments)})},{key:"useDatabase",value:function(e){console.debug("Using database ".concat(e)),this.selectedDatabase=e}},{key:"startTransaction",value:function(){console.debug("Starting new transaction"),this.activeTransaction={changes:[],tables:[]}}},{key:"commit",value:(R=g(regeneratorRuntime.mark((function e(){var t,r,n,a,i,s;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:console.debug("Commiting ".concat(this.activeTransaction.changes.length," changes to: ").concat(this.activeTransaction.tables)),t=d(this.activeTransaction.changes),e.prev=2,t.s();case 4:if((r=t.n()).done){e.next=10;break}return n=r.value,e.next=8,n();case 8:e.next=4;break;case 10:e.next=15;break;case 12:e.prev=12,e.t0=e.catch(2),t.e(e.t0);case 15:return e.prev=15,t.f(),e.finish(15);case 18:a=d(this.activeTransaction.tables),e.prev=19,a.s();case 21:if((i=a.n()).done){e.next=27;break}return s=i.value,e.next=25,this.flushIndexes(s);case 25:e.next=21;break;case 27:e.next=32;break;case 29:e.prev=29,e.t1=e.catch(19),a.e(e.t1);case 32:return e.prev=32,a.f(),e.finish(32);case 35:delete this.activeTransaction;case 36:case"end":return e.stop()}}),e,this,[[2,12,15,18],[19,29,32,35]])}))),function(){return R.apply(this,arguments)})},{key:"put",value:(D=g(regeneratorRuntime.mark((function e(t,r,n){var a=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.selectedDatabase){e.next=2;break}throw Error("No database selected");case 2:if(this.activeTransaction){e.next=4;break}throw Error("No transaction started");case 4:this.queueChange(t,g(regeneratorRuntime.mark((function e(){var i,s,c,o;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i="".concat(a.pathService.getTableDirectoryName(a.selectedDatabase,t),"/").concat(r),e.next=3,a.pathService.fileExists(i);case 3:if(!e.sent){e.next=7;break}return e.next=6,a.get(t,r);case 6:s=e.sent;case 7:return e.next=9,a.schemaService.getSchemaForTable(a.selectedDatabase,t);case 9:c=e.sent,e.t0=regeneratorRuntime.keys(c);case 11:if((e.t1=e.t0()).done){e.next=18;break}return o=e.t1.value,console.debug("Updating ".concat(o," index in ").concat(t)),e.next=16,a.updateIndex(t,o,r,n[o],s?s[o]:void 0);case 16:e.next=11;break;case 18:return e.next=20,a.pathService.fileExists(i);case 20:if(!e.sent){e.next=23;break}return e.next=23,a.ipfs.files.rm(i);case 23:return console.debug("Writing value to MFS at ".concat(i)),e.next=26,a.ipfs.files.write(i,k(n),{create:!0,flush:!0});case 26:case"end":return e.stop()}}),e)}))));case 5:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return D.apply(this,arguments)})},{key:"get",value:(S=g(regeneratorRuntime.mark((function e(t,r){var n,a;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.selectedDatabase){e.next=2;break}throw Error("No database selected");case 2:return a="".concat(this.pathService.getTableDirectoryName(this.selectedDatabase,t),"/").concat(r),e.prev=3,e.next=6,this.pathService.getFileContent(a);case 6:n=e.sent,e.next=11;break;case 9:e.prev=9,e.t0=e.catch(3);case 11:return e.abrupt("return",n);case 12:case"end":return e.stop()}}),e,this,[[3,9]])}))),function(e,t){return S.apply(this,arguments)})},{key:"getCID",value:(x=g(regeneratorRuntime.mark((function e(t,r){var n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.ipfs.files.stat("".concat(this.pathService.getTableDirectoryName(this.selectedDatabase,t),"/").concat(r));case 2:return n=e.sent,e.abrupt("return",n.cid);case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return x.apply(this,arguments)})},{key:"getByIndex",value:(b=g(regeneratorRuntime.mark((function e(t,r,n,a){var i,s,c,o,u,f,h,p,l,v,b,x,g,m,y,k,w=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=w.length>4&&void 0!==w[4]?w[4]:0,s=w.length>5&&void 0!==w[5]?w[5]:1,this.selectedDatabase){e.next=4;break}throw Error("No database selected");case 4:return e.next=6,this.schemaService.getSchemaForTable(this.selectedDatabase,t);case 6:return c=e.sent,o=c[r],e.next=10,this.getIndexMap(t,r);case 10:if(u=e.sent,c&&o&&u){e.next=13;break}return e.abrupt("return",[]);case 13:if(f=[],h=[],n)if(o.unique)p=u.get(n),h.push(p);else{l=u.get(n),v=d(l);try{for(v.s();!(b=v.n()).done;)x=b.value,h.push(x)}catch(e){v.e(e)}finally{v.f()}}else h=Object.keys(u.toSeq().toJS());h.sort(),"asc"==a&&h.reverse(),g=0,m=d(h),e.prev=20,m.s();case 22:if((y=m.n()).done){e.next=39;break}if(k=y.value,!(f.length>=s)){e.next=26;break}return e.abrupt("break",39);case 26:if(!(g<i)){e.next=31;break}return g++,e.abrupt("continue",37);case 31:g++;case 32:return e.t0=f,e.next=35,this.get(t,k);case 35:e.t1=e.sent,e.t0.push.call(e.t0,e.t1);case 37:e.next=22;break;case 39:e.next=44;break;case 41:e.prev=41,e.t2=e.catch(20),m.e(e.t2);case 44:return e.prev=44,m.f(),e.finish(44);case 47:return e.abrupt("return",f);case 48:case"end":return e.stop()}}),e,this,[[20,41,44,47]])}))),function(e,t,r,n){return b.apply(this,arguments)})},{key:"count",value:(l=g(regeneratorRuntime.mark((function e(t){var r,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.selectedDatabase){e.next=2;break}throw Error("No database selected");case 2:return e.next=4,w(this.ipfs.files.ls("".concat(this.pathService.getTableDirectoryName(this.selectedDatabase,t))));case 4:return r=e.sent,n=r.filter((function(e){return"file"==e.type})).length,e.abrupt("return",n);case 7:case"end":return e.stop()}}),e,this)}))),function(e){return l.apply(this,arguments)})},{key:"delete",value:(p=g(regeneratorRuntime.mark((function e(t,r){var n=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.selectedDatabase){e.next=2;break}throw Error("No database selected");case 2:if(this.activeTransaction){e.next=4;break}throw Error("No transaction started");case 4:this.queueChange(t,g(regeneratorRuntime.mark((function e(){var a,i,s,c;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n.get(t,r);case 2:return a=e.sent,e.next=5,n.schemaService.getSchemaForTable(n.selectedDatabase,t);case 5:i=e.sent,e.t0=regeneratorRuntime.keys(i);case 7:if((e.t1=e.t0()).done){e.next=14;break}return s=e.t1.value,console.debug("Updating ".concat(s," index in ").concat(t)),e.next=12,n.updateIndex(t,s,r,void 0,a?a[s]:void 0);case 12:e.next=7;break;case 14:return c="".concat(n.pathService.getTableDirectoryName(n.selectedDatabase,t),"/").concat(r),console.debug("Removivng file from MFS at ".concat(c)),e.next=18,n.pathService.fileExists(c);case 18:if(!e.sent){e.next=21;break}return e.next=21,n.ipfs.files.rm(c,{flush:!0});case 21:case"end":return e.stop()}}),e)}))));case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return p.apply(this,arguments)})},{key:"getDatabaseCid",value:(h=g(regeneratorRuntime.mark((function e(t){var r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.databaseExists(t)){e.next=2;break}throw Error("Database does not exist");case 2:return e.next=4,this.ipfs.files.stat(this.pathService.getDatabasePath(t));case 4:return r=e.sent,e.abrupt("return",r.cid);case 6:case"end":return e.stop()}}),e,this)}))),function(e){return h.apply(this,arguments)})},{key:"updateFromCid",value:(f=g(regeneratorRuntime.mark((function e(t,r){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return console.log("Updating ".concat(t," from ").concat(r)),e.next=3,this.ipfs.files.rm(this.pathService.getDatabasePath(t),{recursive:!0});case 3:return e.next=5,this.ipfs.files.cp("/ipfs/".concat(r),this.pathService.getDatabasePath(t));case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return f.apply(this,arguments)})},{key:"queueChange",value:function(e,t){this.activeTransaction.changes.push(t),0==this.activeTransaction.tables.filter((function(t){return t==e})).length&&this.activeTransaction.tables.push(e)}},{key:"getDefinitionForIndex",value:(o=g(regeneratorRuntime.mark((function e(t,r){var n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.schemaService.getSchemaForTable(this.selectedDatabase,t);case 2:return n=e.sent,e.abrupt("return",n[r]);case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return o.apply(this,arguments)})},{key:"getIndexMap",value:(c=g(regeneratorRuntime.mark((function e(t,r){var n,a,i,s;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(n=this.indexService.getCachedIndexMap(this.selectedDatabase,t,r))){e.next=3;break}return e.abrupt("return",n);case 3:return e.prev=3,i="".concat(this.pathService.getTableDirectoryName(this.selectedDatabase,t),"/_indexMaps/").concat(r),e.next=7,this.ipfs.files.stat(i);case 7:return e.next=9,this.pathService.getFileContent(i);case 9:s=e.sent,a=y(s),e.next=15;break;case 13:e.prev=13,e.t0=e.catch(3);case 15:return a||(a=y()),this.indexService.cacheIndexMap(this.selectedDatabase,t,r,a),e.abrupt("return",a);case 18:case"end":return e.stop()}}),e,this,[[3,13]])}))),function(e,t){return c.apply(this,arguments)})},{key:"updateIndex",value:(s=g(regeneratorRuntime.mark((function e(t,r,n,a,i){var s,c,o,u,f,h,p;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getIndexMap(t,r);case 2:return s=e.sent,e.next=5,this.getDefinitionForIndex(t,r);case 5:if(c=e.sent,s&&c){e.next=8;break}return e.abrupt("return");case 8:c.unique?a?s=s.set(a,n):i&&(s=s.delete(i)):(o=Boolean(!i)&&Boolean(a),u=!o&&a!=i,i&&u&&(f=s.get(i),(h=f.indexOf(n))>=0&&(f.splice(h,1),s=s.set(i,f))),a&&(u||o)&&((p=s.get(a))||(p=[],s=s.set(a,p)),p.push(n))),this.indexService.cacheIndexMap(this.selectedDatabase,t,r,s);case 10:case"end":return e.stop()}}),e,this)}))),function(e,t,r,n,a){return s.apply(this,arguments)})},{key:"flushIndexes",value:(i=g(regeneratorRuntime.mark((function e(t){var r,n,a,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.schemaService.getSchemaForTable(this.selectedDatabase,t);case 2:r=e.sent,e.t0=regeneratorRuntime.keys(r);case 4:if((e.t1=e.t0()).done){e.next=19;break}if(n=e.t1.value,a="".concat(this.pathService.getTableDirectoryName(this.selectedDatabase,t),"/_indexMaps/").concat(n),!(i=this.indexService.getCachedIndexMap(this.selectedDatabase,t,n))){e.next=17;break}return e.next=11,this.pathService.fileExists(a);case 11:if(!e.sent){e.next=14;break}return e.next=14,this.ipfs.files.rm(a,{flush:!0});case 14:return console.debug("Writing indexMap to MFS at ".concat(a)),e.next=17,this.ipfs.files.write(a,k(i),{create:!0,parents:!0,flush:!0});case 17:e.next=4;break;case 19:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})}])&&m(t.prototype,r),n&&m(t,n),e}()}])}));
{
"name": "mfdb",
"version": "0.0.11-alpha",
"version": "0.0.12-alpha",
"description": "MFdb is a portable P2P database backed by the IPFS Mutable File System.",

@@ -5,0 +5,0 @@ "main": "./dist/index-node.js",

@@ -49,14 +49,3 @@ import { IndexService } from "./service/index-service"

async createTable(definition: TableDefinition) {
let schemaPath = `${this.pathService.getTableDirectoryName(definition.database, definition.name)}/_metadata/${SchemaService.SCHEMA_FILENAME}`
console.debug(`Saving schema for table ${definition.name} (${definition.database}) at ${schemaPath}`)
//Save the schema
await this.ipfs.files.write(schemaPath, stringify(definition.schema), {
create: true,
parents: true,
flush: true
})
await this.schemaService.saveSchema(definition)
}

@@ -157,3 +146,3 @@

try {
console.debug(`Getting value from MFS at ${path}`)
// console.debug(`Getting value from MFS at ${path}`)
value = await this.pathService.getFileContent(path)

@@ -160,0 +149,0 @@ } catch (ex) { }

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc