genosdb 0.8.3 → 0.8.4

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.
@@ -1 +1 @@
1
- function G(E){const B={},K=E.worker,Q=`${E.name}_inverted_index.json`,R=E.encode,W=E.decode,U=E.pako,X=((q,A)=>{let H;return(...L)=>{clearTimeout(H),H=setTimeout(()=>q.apply(null,L),A)}})(()=>Z(),200);async function Y(){try{const q=await new Promise((A,H)=>{const L=(J)=>{if(J.data.type==="loaded"&&J.data.name===Q)K.removeEventListener("message",L),A(new Uint8Array(J.data.data));else if(J.data.type==="error")K.removeEventListener("message",L),H(new Error(J.data.message))};K.addEventListener("message",L),K.postMessage({type:"load",name:Q})});if(q.byteLength>0){if(!W||!U)throw new Error("InvertedIndexer: decode y pako deben estar en options");const A=U.inflate(q),H=W(A);return Object.assign(B,H),!0}}catch{}return!1}async function Z(){try{if(!R||!U)throw new Error("InvertedIndexer: encode y pako deben estar en options");const q=R(B),A=U.deflate(q);await new Promise((H,L)=>{const J=(C)=>{if(C.data.type==="saved"&&C.data.name===Q)K.removeEventListener("message",J),H();else if(C.data.type==="error")K.removeEventListener("message",J),L(new Error(C.data.message))};K.addEventListener("message",J),K.postMessage({type:"save",name:Q,content:A})})}catch{}}async function _(){(typeof E.graph?.getAllNodes==="function"?await E.graph.getAllNodes():Object.values(E.graph.nodes)).forEach((A)=>V(A.id,A.value,"insert",!1)),X()}function $(){E.map({realtime:!0},(q)=>{if(q.action==="added"||q.action==="updated")V(q.id,q.value,"insert",!0);else if(q.action==="removed")V(q.id,q.value,"remove",!0)})}function V(q,A,H="insert",L=!0){const J=z(A);if(H==="insert")J.forEach((C)=>{if(!B[C])B[C]=[];if(!B[C].includes(q))B[C].push(q)});else if(H==="remove")J.forEach((C)=>{if(B[C]){if(B[C]=B[C].filter((T)=>T!==q),B[C].length===0)delete B[C]}});if(L)X()}function z(q){if(typeof q==="string")return Array.from({length:q.length},(A,H)=>q.substring(0,H+1));if(typeof q==="number")return[String(q)];if(typeof q==="object"&&q!==null)return Object.keys(q);return[]}function S(q){return Object.keys(B).filter((A)=>A.startsWith(q)).flatMap((A)=>B[A])}return{ready:Y().then((q)=>{if(!q)_();$()}),updateIndex:V,searchAllByPrefix:S}}var P=(E)=>{console.log("\uD83C\uDF33 InvertedIndexer module loaded.");const B=G(E);return E.searchByPrefix=async(K)=>{return await B.ready,B.searchAllByPrefix(K).map((R)=>E.graph.get(R))},E};export{P as init,G as InvertedIndexer};
1
+ function O(H){const C={},Q=H.worker,T=H.indexFileName||"inverted_index.msgpack",U=H.encode,X=H.decode,V=H.pako,Y=((L,q)=>{let J;return(...R)=>{clearTimeout(J),J=setTimeout(()=>L.apply(null,R),q)}})(()=>_(),200);async function Z(){try{const L=await new Promise((q,J)=>{const R=(K)=>{if(K.data.type==="loaded"&&K.data.name===T)Q.removeEventListener("message",R),q(new Uint8Array(K.data.data));else if(K.data.type==="error")Q.removeEventListener("message",R),J(new Error(K.data.message))};Q.addEventListener("message",R),Q.postMessage({type:"load",name:T})});if(L.byteLength>0){if(!X||!V)throw new Error("InvertedIndexer: decode y pako deben estar en options");const q=V.inflate(L),J=X(q);return Object.assign(C,J),!0}}catch{}return!1}async function _(){try{if(!U||!V)throw new Error("InvertedIndexer: encode y pako deben estar en options");const L=U(C),q=V.deflate(L);await new Promise((J,R)=>{const K=(E)=>{if(E.data.type==="saved"&&E.data.name===T)Q.removeEventListener("message",K),J();else if(E.data.type==="error")Q.removeEventListener("message",K),R(new Error(E.data.message))};Q.addEventListener("message",K),Q.postMessage({type:"save",name:T,content:q})})}catch{}}async function $(){(typeof H.graph?.getAllNodes==="function"?await H.graph.getAllNodes():Object.values(H.graph.nodes)).forEach((q)=>W(q.id,q.value,"insert",!1)),Y()}function z(){H.map({realtime:!0},(L)=>{if(L.action==="added"||L.action==="updated")W(L.id,L.value,"insert",!0);else if(L.action==="removed")W(L.id,L.value,"remove",!0)})}function W(L,q,J="insert",R=!0){const K=A(q);if(J==="insert")K.forEach((E)=>{if(!C[E])C[E]=[];if(!C[E].includes(L))C[E].push(L)});else if(J==="remove")K.forEach((E)=>{if(C[E]){if(C[E]=C[E].filter((G)=>G!==L),C[E].length===0)delete C[E]}});if(R)Y()}function A(L){if(typeof L==="string")return Array.from({length:L.length},(q,J)=>L.substring(0,J+1));if(typeof L==="number")return[String(L)];if(typeof L==="object"&&L!==null)return Object.keys(L);return[]}function B(L){return Object.keys(C).filter((q)=>q.startsWith(L)).flatMap((q)=>C[q])}return{ready:Z().then((L)=>{if(!L)$();z()}),updateIndex:W,searchAllByPrefix:B}}var D=(H)=>{console.log("\uD83C\uDF33 InvertedIndexer module loaded.");const C=O(H);return H.searchByPrefix=async(Q)=>{return await C.ready,C.searchAllByPrefix(Q).map((U)=>H.graph.get(U))},H};export{D as init,O as InvertedIndexer};
Binary file
@@ -1 +1 @@
1
- function R(H={}){let q={},Y={};const A=H.maxSize||1048576,G=H.encode,K=H.decode,L=H.pako;function Z(C,E){if(_(E).forEach((Q)=>{if(!q[Q])q[Q]=[];if(!q[Q].includes(C))q[Q].push(C)}),JSON.stringify(q).length>A)O()}function X(C,E){_(E).forEach((Q)=>{if(q[Q]){if(q[Q]=q[Q].filter(($)=>$!==C),q[Q].length===0)delete q[Q]}})}function _(C){const E=[];if(typeof C==="string")for(let J=1;J<=C.length;J++)E.push(C.substring(0,J));else if(typeof C==="number")E.push(String(C));else if(typeof C==="object"&&C!==null)Object.keys(C).forEach((J)=>{E.push(J.toString());const Q=C[J];if(typeof Q==="string"||typeof Q==="number")E.push(`${J}:${Q}`)});return E}function O(){const C=Object.keys(q),E=Math.ceil(C.length/2),J={},Q={};C.slice(0,E).forEach(($)=>{J[$]=q[$]}),C.slice(E).forEach(($)=>{Q[$]=q[$]}),Y.fragment1=J,Y.fragment2=Q,q={}}function T(){for(let C of Object.values(Y))Object.assign(q,C);Y={}}function B(C){return q[C]||[]}function V(C){return Object.keys(q).filter((E)=>E.startsWith(C)).flatMap((E)=>q[E])}function D(){if(!G||!L)throw new Error("Radix: encode y pako deben estar en options");const C={index:q,fragmentedIndexes:Y};return L.deflate(G(C))}function U(C){if(!K||!L)throw new Error("Radix: decode y pako deben estar en options");const E=L.inflate(new Uint8Array(C)),J=K(E);q=J.index||{},Y=J.fragmentedIndexes||{}}function W(){if(JSON.stringify(q).length>A)throw new Error("Index too large");if(!q||typeof q!=="object")q={}}return{upsert:Z,remove:X,extractPrefixes:_,splitIndex:O,mergeFragments:T,searchByPrefix:B,searchAllByPrefix:V,serialize:D,deserialize:U,validateIndex:W}}function j(H){const{worker:q,encode:Y,decode:A,pako:G}=H,K=R({maxSize:H.maxSize||1048576,encode:Y,decode:A,pako:G}),L=H.indexFileName||"graph_radix_index.json",X=((U,W)=>{let C;return(...E)=>{clearTimeout(C),C=setTimeout(()=>U.apply(null,E),W)}})(()=>O(),200);async function _(){try{const U=await new Promise((W,C)=>{const E=(J)=>{if(J.data.type==="loaded"&&J.data.name===L)q.removeEventListener("message",E),W(new Uint8Array(J.data.data));else if(J.data.type==="error")q.removeEventListener("message",E),C(new Error(J.data.message||"Error loading the Radix index"))};q.addEventListener("message",E),q.postMessage({type:"load",name:L})});if(U.byteLength>0)K.deserialize(U)}catch{}}async function O(){try{const U=K.serialize();await new Promise((W,C)=>{const E=(J)=>{if(J.data.type==="saved"&&J.data.name===L)q.removeEventListener("message",E),W();else if(J.data.type==="error")q.removeEventListener("message",E),C(new Error(J.data.message||"Error saving the Radix index"))};q.addEventListener("message",E),q.postMessage({type:"save",name:L,content:U})})}catch{}}async function T(){try{K.validateIndex(),(typeof H.graph?.getAllNodes==="function"?await H.graph.getAllNodes():Object.values(H.graph.nodes)).forEach((W)=>{K.upsert(W.id,W.value)})}catch{}}async function B(U,W,C="insert"){switch(C){case"insert":K.upsert(U,W);break;case"remove":K.remove(U,W);break}X()}function V(U){return K.searchAllByPrefix(U)}return{ready:_().then(T),updateIndex:B,searchByPrefix:V}}function z(H){const q=j(H),Y=H.put;H.put=async function(K,L){const Z=L?this.graph.get(L):null,X=await Y.call(this,K,L);if(Z)await q.updateIndex(X,Z.value,"remove");return await q.updateIndex(X,K,"insert"),X};const A=H.remove;H.remove=async function(K){const L=this.graph.get(K);if(await A.call(this,K),L)await q.updateIndex(K,L.value,"remove")};const G=H.map;return H.map=async function(...K){const L=await G.call(this,...K),Z=K.find((X)=>typeof X==="object");if(Z?.query?.id?.$startsWith){const X=Z.query.id.$startsWith,_=q.searchByPrefix(X);return L.filter((O)=>_.includes(O.id))}return L},H.searchByPrefix=async function(K){return q.searchByPrefix(K).map((Z)=>this.graph.get(Z))},H}var h=(H)=>{return console.log("\uD83C\uDF33 RadixIndexer module loaded."),z(H)};export{z as withModule,h as init,j as RadixIndexer};
1
+ function S(H={}){let q={},Y={};const A=H.maxSize||1048576,G=H.encode,K=H.decode,L=H.pako;function Z(C,E){if(_(E).forEach((Q)=>{if(!q[Q])q[Q]=[];if(!q[Q].includes(C))q[Q].push(C)}),JSON.stringify(q).length>A)T()}function X(C,E){_(E).forEach((Q)=>{if(q[Q]){if(q[Q]=q[Q].filter(($)=>$!==C),q[Q].length===0)delete q[Q]}})}function _(C){const E=[];if(typeof C==="string")for(let J=1;J<=C.length;J++)E.push(C.substring(0,J));else if(typeof C==="number")E.push(String(C));else if(typeof C==="object"&&C!==null)Object.keys(C).forEach((J)=>{E.push(J.toString());const Q=C[J];if(typeof Q==="string"||typeof Q==="number")E.push(`${J}:${Q}`)});return E}function T(){const C=Object.keys(q),E=Math.ceil(C.length/2),J={},Q={};C.slice(0,E).forEach(($)=>{J[$]=q[$]}),C.slice(E).forEach(($)=>{Q[$]=q[$]}),Y.fragment1=J,Y.fragment2=Q,q={}}function B(){for(let C of Object.values(Y))Object.assign(q,C);Y={}}function O(C){return q[C]||[]}function V(C){return Object.keys(q).filter((E)=>E.startsWith(C)).flatMap((E)=>q[E])}function D(){if(!G||!L)throw new Error("Radix: encode y pako deben estar en options");const C={index:q,fragmentedIndexes:Y};return L.deflate(G(C))}function U(C){if(!K||!L)throw new Error("Radix: decode y pako deben estar en options");const E=L.inflate(new Uint8Array(C)),J=K(E);q=J.index||{},Y=J.fragmentedIndexes||{}}function W(){if(JSON.stringify(q).length>A)throw new Error("Index too large");if(!q||typeof q!=="object")q={}}return{upsert:Z,remove:X,extractPrefixes:_,splitIndex:T,mergeFragments:B,searchByPrefix:O,searchAllByPrefix:V,serialize:D,deserialize:U,validateIndex:W}}function z(H){const{worker:q,encode:Y,decode:A,pako:G}=H,K=S({maxSize:H.maxSize||1048576,encode:Y,decode:A,pako:G}),L=H.indexFileName||"graph_radix_index.msgpack",X=((U,W)=>{let C;return(...E)=>{clearTimeout(C),C=setTimeout(()=>U.apply(null,E),W)}})(()=>T(),200);async function _(){try{const U=await new Promise((W,C)=>{const E=(J)=>{if(J.data.type==="loaded"&&J.data.name===L)q.removeEventListener("message",E),W(new Uint8Array(J.data.data));else if(J.data.type==="error")q.removeEventListener("message",E),C(new Error(J.data.message||"Error loading the Radix index"))};q.addEventListener("message",E),q.postMessage({type:"load",name:L})});if(U.byteLength>0)K.deserialize(U)}catch{}}async function T(){try{const U=K.serialize();await new Promise((W,C)=>{const E=(J)=>{if(J.data.type==="saved"&&J.data.name===L)q.removeEventListener("message",E),W();else if(J.data.type==="error")q.removeEventListener("message",E),C(new Error(J.data.message||"Error saving the Radix index"))};q.addEventListener("message",E),q.postMessage({type:"save",name:L,content:U})})}catch{}}async function B(){try{K.validateIndex(),(typeof H.graph?.getAllNodes==="function"?await H.graph.getAllNodes():Object.values(H.graph.nodes)).forEach((W)=>{K.upsert(W.id,W.value)})}catch{}}async function O(U,W,C="insert"){switch(C){case"insert":K.upsert(U,W);break;case"remove":K.remove(U,W);break}X()}function V(U){return K.searchAllByPrefix(U)}return{ready:_().then(B),updateIndex:O,searchByPrefix:V}}function R(H){const q=z(H),Y=H.put;H.put=async function(K,L){const Z=L?this.graph.get(L):null,X=await Y.call(this,K,L);if(Z)await q.updateIndex(X,Z.value,"remove");return await q.updateIndex(X,K,"insert"),X};const A=H.remove;H.remove=async function(K){const L=this.graph.get(K);if(await A.call(this,K),L)await q.updateIndex(K,L.value,"remove")};const G=H.map;return H.map=async function(...K){const L=await G.call(this,...K),Z=K.find((X)=>typeof X==="object");if(Z?.query?.id?.$startsWith){const X=Z.query.id.$startsWith,_=q.searchByPrefix(X);return L.filter((T)=>_.includes(T.id))}return L},H.searchByPrefix=async function(K){return q.searchByPrefix(K).map((Z)=>this.graph.get(Z))},H}var w=(H)=>{return console.log("\uD83C\uDF33 RadixIndexer module loaded."),R(H)};export{R as withModule,w as init,z as RadixIndexer};
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "genosdb",
3
- "version": "0.8.3",
3
+ "version": "0.8.4",
4
4
  "description": "GenosDB (GDB): distributed graph database in real-time, peer-to-peer, scalable storage - efficient querying of complex relationships.",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",