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

@oramacloud/client

Package Overview
Dependencies
Maintainers
2
Versions
78
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@oramacloud/client - npm Package Compare versions

Comparing version 1.0.0-beta.10 to 1.0.0-beta.11

2

dist/index.global.js

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

"use strict";(()=>{var vt=Object.create;var D=Object.defineProperty;var Tt=Object.getOwnPropertyDescriptor;var Lt=Object.getOwnPropertyNames;var Et=Object.getPrototypeOf,At=Object.prototype.hasOwnProperty;var jt=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,n)=>(typeof require<"u"?require:e)[n]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw new Error('Dynamic require of "'+t+'" is not supported')});var m=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var Ht=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Lt(e))!At.call(t,o)&&o!==n&&D(t,o,{get:()=>e[o],enumerable:!(r=Tt(e,o))||r.enumerable});return t};var Mt=(t,e,n)=>(n=t!=null?vt(Et(t)):{},Ht(e||!t||!t.__esModule?D(n,"default",{value:t,enumerable:!0}):n,t));var J=m(l=>{"use strict";Object.defineProperty(l,"__esModule",{value:!0});l.output=l.exists=l.hash=l.bytes=l.bool=l.number=void 0;function S(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}l.number=S;function z(t){if(typeof t!="boolean")throw new Error(`Expected boolean, not ${t}`)}l.bool=z;function H(t,...e){if(!(t instanceof Uint8Array))throw new Error("Expected Uint8Array");if(e.length>0&&!e.includes(t.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}l.bytes=H;function K(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");S(t.outputLen),S(t.blockLen)}l.hash=K;function Y(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}l.exists=Y;function G(t,e){H(t);let n=e.outputLen;if(t.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}l.output=G;var Pt={number:S,bool:z,bytes:H,hash:K,exists:Y,output:G};l.default=Pt});var tt=m(f=>{"use strict";Object.defineProperty(f,"__esModule",{value:!0});f.add=f.toBig=f.split=f.fromBig=void 0;var _=BigInt(2**32-1),M=BigInt(32);function P(t,e=!1){return e?{h:Number(t&_),l:Number(t>>M&_)}:{h:Number(t>>M&_)|0,l:Number(t&_)|0}}f.fromBig=P;function Z(t,e=!1){let n=new Uint32Array(t.length),r=new Uint32Array(t.length);for(let o=0;o<t.length;o++){let{h:s,l:i}=P(t[o],e);[n[o],r[o]]=[s,i]}return[n,r]}f.split=Z;var Nt=(t,e)=>BigInt(t>>>0)<<M|BigInt(e>>>0);f.toBig=Nt;var Ut=(t,e,n)=>t>>>n,$t=(t,e,n)=>t<<32-n|e>>>n,Rt=(t,e,n)=>t>>>n|e<<32-n,Dt=(t,e,n)=>t<<32-n|e>>>n,Ft=(t,e,n)=>t<<64-n|e>>>n-32,qt=(t,e,n)=>t>>>n-32|e<<64-n,Vt=(t,e)=>e,Wt=(t,e)=>t,Xt=(t,e,n)=>t<<n|e>>>32-n,zt=(t,e,n)=>e<<n|t>>>32-n,Kt=(t,e,n)=>e<<n-32|t>>>64-n,Yt=(t,e,n)=>t<<n-32|e>>>64-n;function Q(t,e,n,r){let o=(e>>>0)+(r>>>0);return{h:t+n+(o/2**32|0)|0,l:o|0}}f.add=Q;var Gt=(t,e,n)=>(t>>>0)+(e>>>0)+(n>>>0),Jt=(t,e,n,r)=>e+n+r+(t/2**32|0)|0,Zt=(t,e,n,r)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0),Qt=(t,e,n,r,o)=>e+n+r+o+(t/2**32|0)|0,te=(t,e,n,r,o)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0)+(o>>>0),ee=(t,e,n,r,o,s)=>e+n+r+o+s+(t/2**32|0)|0,ne={fromBig:P,split:Z,toBig:f.toBig,shrSH:Ut,shrSL:$t,rotrSH:Rt,rotrSL:Dt,rotrBH:Ft,rotrBL:qt,rotr32H:Vt,rotr32L:Wt,rotlSH:Xt,rotlSL:zt,rotlBH:Kt,rotlBL:Yt,add:Q,add3L:Gt,add3H:Jt,add4L:Zt,add4H:Qt,add5H:ee,add5L:te};f.default=ne});var et=m(T=>{"use strict";Object.defineProperty(T,"__esModule",{value:!0});T.crypto=void 0;var v=jt("node:crypto");T.crypto=v&&typeof v=="object"&&"webcrypto"in v?v.webcrypto:void 0});var rt=m(c=>{"use strict";Object.defineProperty(c,"__esModule",{value:!0});c.randomBytes=c.wrapXOFConstructorWithOpts=c.wrapConstructorWithOpts=c.wrapConstructor=c.checkOpts=c.Hash=c.concatBytes=c.toBytes=c.utf8ToBytes=c.asyncLoop=c.nextTick=c.hexToBytes=c.bytesToHex=c.isLE=c.rotr=c.createView=c.u32=c.u8=void 0;var N=et(),$=t=>t instanceof Uint8Array,re=t=>new Uint8Array(t.buffer,t.byteOffset,t.byteLength);c.u8=re;var oe=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4));c.u32=oe;var ie=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);c.createView=ie;var se=(t,e)=>t<<32-e|t>>>e;c.rotr=se;c.isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!c.isLE)throw new Error("Non little-endian hardware is not supported");var ce=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function ae(t){if(!$(t))throw new Error("Uint8Array expected");let e="";for(let n=0;n<t.length;n++)e+=ce[t[n]];return e}c.bytesToHex=ae;function ue(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);let e=t.length;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(e/2);for(let r=0;r<n.length;r++){let o=r*2,s=t.slice(o,o+2),i=Number.parseInt(s,16);if(Number.isNaN(i)||i<0)throw new Error("Invalid byte sequence");n[r]=i}return n}c.hexToBytes=ue;var le=async()=>{};c.nextTick=le;async function fe(t,e,n){let r=Date.now();for(let o=0;o<t;o++){n(o);let s=Date.now()-r;s>=0&&s<e||(await(0,c.nextTick)(),r+=s)}}c.asyncLoop=fe;function nt(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}c.utf8ToBytes=nt;function L(t){if(typeof t=="string"&&(t=nt(t)),!$(t))throw new Error(`expected Uint8Array, got ${typeof t}`);return t}c.toBytes=L;function pe(...t){let e=new Uint8Array(t.reduce((r,o)=>r+o.length,0)),n=0;return t.forEach(r=>{if(!$(r))throw new Error("Uint8Array expected");e.set(r,n),n+=r.length}),e}c.concatBytes=pe;var U=class{clone(){return this._cloneInto()}};c.Hash=U;var he=t=>Object.prototype.toString.call(t)==="[object Object]"&&t.constructor===Object;function de(t,e){if(e!==void 0&&(typeof e!="object"||!he(e)))throw new Error("Options should be object or undefined");return Object.assign(t,e)}c.checkOpts=de;function ge(t){let e=r=>t().update(L(r)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}c.wrapConstructor=ge;function ye(t){let e=(r,o)=>t(o).update(L(r)).digest(),n=t({});return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=r=>t(r),e}c.wrapConstructorWithOpts=ye;function me(t){let e=(r,o)=>t(o).update(L(r)).digest(),n=t({});return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=r=>t(r),e}c.wrapXOFConstructorWithOpts=me;function be(t=32){if(N.crypto&&typeof N.crypto.getRandomValues=="function")return N.crypto.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}c.randomBytes=be});var ft=m(u=>{"use strict";Object.defineProperty(u,"__esModule",{value:!0});u.shake256=u.shake128=u.keccak_512=u.keccak_384=u.keccak_256=u.keccak_224=u.sha3_512=u.sha3_384=u.sha3_256=u.sha3_224=u.Keccak=u.keccakP=void 0;var b=J(),k=tt(),x=rt(),[st,ct,at]=[[],[],[]],we=BigInt(0),w=BigInt(1),xe=BigInt(2),ke=BigInt(7),Ie=BigInt(256),Oe=BigInt(113);for(let t=0,e=w,n=1,r=0;t<24;t++){[n,r]=[r,(2*n+3*r)%5],st.push(2*(5*r+n)),ct.push((t+1)*(t+2)/2%64);let o=we;for(let s=0;s<7;s++)e=(e<<w^(e>>ke)*Oe)%Ie,e&xe&&(o^=w<<(w<<BigInt(s))-w);at.push(o)}var[Be,Ce]=k.default.split(at,!0),ot=(t,e,n)=>n>32?k.default.rotlBH(t,e,n):k.default.rotlSH(t,e,n),it=(t,e,n)=>n>32?k.default.rotlBL(t,e,n):k.default.rotlSL(t,e,n);function ut(t,e=24){let n=new Uint32Array(10);for(let r=24-e;r<24;r++){for(let i=0;i<10;i++)n[i]=t[i]^t[i+10]^t[i+20]^t[i+30]^t[i+40];for(let i=0;i<10;i+=2){let a=(i+8)%10,p=(i+2)%10,h=n[p],y=n[p+1],St=ot(h,y,1)^n[a],_t=it(h,y,1)^n[a+1];for(let C=0;C<50;C+=10)t[i+C]^=St,t[i+C+1]^=_t}let o=t[2],s=t[3];for(let i=0;i<24;i++){let a=ct[i],p=ot(o,s,a),h=it(o,s,a),y=st[i];o=t[y],s=t[y+1],t[y]=p,t[y+1]=h}for(let i=0;i<50;i+=10){for(let a=0;a<10;a++)n[a]=t[i+a];for(let a=0;a<10;a++)t[i+a]^=~n[(a+2)%10]&n[(a+4)%10]}t[0]^=Be[r],t[1]^=Ce[r]}n.fill(0)}u.keccakP=ut;var I=class t extends x.Hash{constructor(e,n,r,o=!1,s=24){if(super(),this.blockLen=e,this.suffix=n,this.outputLen=r,this.enableXOF=o,this.rounds=s,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,b.default.number(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=(0,x.u32)(this.state)}keccak(){ut(this.state32,this.rounds),this.posOut=0,this.pos=0}update(e){b.default.exists(this);let{blockLen:n,state:r}=this;e=(0,x.toBytes)(e);let o=e.length;for(let s=0;s<o;){let i=Math.min(n-this.pos,o-s);for(let a=0;a<i;a++)r[this.pos++]^=e[s++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:e,suffix:n,pos:r,blockLen:o}=this;e[r]^=n,n&128&&r===o-1&&this.keccak(),e[o-1]^=128,this.keccak()}writeInto(e){b.default.exists(this,!1),b.default.bytes(e),this.finish();let n=this.state,{blockLen:r}=this;for(let o=0,s=e.length;o<s;){this.posOut>=r&&this.keccak();let i=Math.min(r-this.posOut,s-o);e.set(n.subarray(this.posOut,this.posOut+i),o),this.posOut+=i,o+=i}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return b.default.number(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(b.default.output(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){let{blockLen:n,suffix:r,outputLen:o,rounds:s,enableXOF:i}=this;return e||(e=new t(n,r,o,i,s)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=s,e.suffix=r,e.outputLen=o,e.enableXOF=i,e.destroyed=this.destroyed,e}};u.Keccak=I;var d=(t,e,n)=>(0,x.wrapConstructor)(()=>new I(e,t,n));u.sha3_224=d(6,144,224/8);u.sha3_256=d(6,136,256/8);u.sha3_384=d(6,104,384/8);u.sha3_512=d(6,72,512/8);u.keccak_224=d(1,144,224/8);u.keccak_256=d(1,136,256/8);u.keccak_384=d(1,104,384/8);u.keccak_512=d(1,72,512/8);var lt=(t,e,n)=>(0,x.wrapXOFConstructorWithOpts)((r={})=>new I(e,t,r.dkLen===void 0?n:r.dkLen,!0));u.shake128=lt(31,168,128/8);u.shake256=lt(31,136,256/8)});var wt=m((ze,g)=>{"use strict";var{sha3_512:Se}=ft(),ht=24,O=32,R=(t=4,e=Math.random)=>{let n="";for(;n.length<t;)n=n+Math.floor(e()*36).toString(36);return n};function dt(t){let e=8n,n=0n;for(let r of t.values()){let o=BigInt(r);n=(n<<e)+o}return n}var gt=(t="")=>dt(Se(t)).toString(36).slice(1),pt=Array.from({length:26},(t,e)=>String.fromCharCode(e+97)),_e=t=>pt[Math.floor(t()*pt.length)],yt=({globalObj:t=typeof global<"u"?global:typeof window<"u"?window:{},random:e=Math.random}={})=>{let n=Object.keys(t).toString(),r=n.length?n+R(O,e):R(O,e);return gt(r).substring(0,O)},mt=t=>()=>t++,ve=476782367,bt=({random:t=Math.random,counter:e=mt(Math.floor(t()*ve)),length:n=ht,fingerprint:r=yt({random:t})}={})=>function(){let s=_e(t),i=Date.now().toString(36),a=e().toString(36),p=R(n,t),h=`${i+p+a+r}`;return`${s+gt(h).substring(1,n)}`},Te=bt(),Le=(t,{minLength:e=2,maxLength:n=O}={})=>{let r=t.length,o=/^[0-9a-z]+$/;try{if(typeof t=="string"&&r>=e&&r<=n&&o.test(t))return!0}finally{}return!1};g.exports.getConstants=()=>({defaultLength:ht,bigLength:O});g.exports.init=bt;g.exports.createId=Te;g.exports.bufToBigInt=dt;g.exports.createCounter=mt;g.exports.createFingerprint=yt;g.exports.isCuid=Le});var xt=m((Ke,B)=>{"use strict";var{createId:Ee,init:Ae,getConstants:je,isCuid:He}=wt();B.exports.createId=Ee;B.exports.init=Ae;B.exports.getConstants=je;B.exports.isCuid=He});var Ne=Date.now().toString().slice(5);var F=BigInt(1e3),q=BigInt(1e6),V=BigInt(1e9);async function W(t){return typeof t=="number"&&(t=BigInt(t)),t<F?`${t}ns`:t<q?`${t/F}\u03BCs`:t<V?`${t/q}ms`:`${t/V}s`}async function X(t){return{raw:Number(t),formatted:await W(t)}}var Ct=Mt(xt(),1);var E=class{cache;config;constructor(e){this.cache=new Map,this.config=e}set(e,n){this.cache.set(e,n)}get(e){return this.cache.get(e)}has(e){return this.cache.has(e)}delete(e){return this.cache.delete(e)}clear(){this.cache.clear()}size(){return this.cache.size}};var It="1.0.0-beta.8";var Ot={name:"@oramacloud/client",version:It,description:"Orama SDK for Node.js, Deno, and Browsers",type:"module",sideEffects:!1,main:"./dist/index.cjs",module:"./dist/esm/index.mjs",types:"./dist/index.d.ts",".":{require:"./dist/index.cjs",import:"./dist/esm/index.mjs",types:"./dist/index.d.ts",browsers:"./dist/iife/index.js"},scripts:{lint:"ts-standard --fix",build:"tsup src/index.ts --format cjs,esm,iife --dts --minify --sourcemap --clean",test:'echo "Error: no test specified" && exit 1',"serve:example":"esbuild src/index.ts --bundle --outfile=example/out.js --format=esm --watch --servedir=example"},keywords:["orama","search engine","sdk"],files:["dist"],author:{name:"Michele Riva",email:"michele.riva@oramasearch.com",url:"https://github.com/MicheleRiva"},license:"ISC",dependencies:{"@orama/orama":"^1.0.8","@paralleldrive/cuid2":"^2.2.1"},devDependencies:{"@types/node":"^20.3.1",concurrently:"^8.2.0",esbuild:"0.18.5","ts-standard":"^12.0.2",tsup:"^7.1.0",typescript:"^5.1.3"}};var A=class t{data;params;config;constructor(e){this.data=[],this.config=e}setParams(e){this.params=e}static create(e){let n=new t(e);return n.start(),n}add(e){this.data.push({rawSearchString:e.rawSearchString,query:e.query,resultsCount:e.resultsCount,roundTripTime:e.roundTripTime,searchedAt:e.searchedAt,referer:typeof location<"u"?location.toString():void 0}),this.params!=null&&this.data.length>=this.config.flushSize&&this.flush()}flush(){if(this.params==null||this.data.length===0)return;let e=this.data;this.data=[];let n={source:"fe",deploymentID:this.params.deploymentID,index:this.params.index,oramaId:this.config.id,oramaVersion:Ot.version,userAgent:typeof navigator<"u"?navigator.userAgent:void 0,events:e};navigator.sendBeacon?.(this.params.endpoint+`?api-key=${this.config.api_key}`,JSON.stringify(n))}start(){setInterval(this.flush.bind(this),this.config.flushInterval)}};var j=class{constructor(e){this.params=e}intervalId;start(){this.stop(),this.intervalId=setInterval(this.beat.bind(this),this.params.frequency)}stop(){this.intervalId!==void 0&&clearInterval(this.intervalId)}beat(){navigator.sendBeacon?.(this.params.endpoint)}};var Bt=class{id=(0,Ct.createId)();api_key;endpoint;collector;cache;heartbeat;initPromise;constructor(e){if(this.api_key=e.api_key,this.endpoint=e.endpoint,e.telemetry!==!1){let n={id:this.id,api_key:this.api_key,flushInterval:e.telemetry?.flushInterval??5e3,flushSize:e.telemetry?.flushSize??25};this.collector=A.create(n)}if(e.cache!==!1){let n={};this.cache=new E(n)}this.init()}async search(e,n){await this.initPromise;let r=JSON.stringify(e),o,s,i=!1;if((n?.fresh!==!0&&this.cache?.has(r))===!0&&this.cache!=null)o=0,s=this.cache.get(r),i=!0;else{let p=Date.now();s=await this.fetch("search","POST",{q:e},n?.abortController);let h=Date.now();s.elapsed=await X(BigInt(h*1e6-p*1e6)),o=h-p,this.cache?.set(r,s)}return this.collector!=null&&this.collector.add({rawSearchString:e.term,resultsCount:s.hits.length,roundTripTime:o,query:e,cached:i,searchedAt:new Date}),s}startHeartBeat(e){this.heartbeat?.stop(),this.heartbeat=new j({...e,endpoint:this.endpoint+`/health?api-key=${this.api_key}`}),this.heartbeat.start()}stopHeartBeat(){this.heartbeat?.stop()}init(){this.initPromise=this.fetch("init","GET").then(e=>{this.collector?.setParams({endpoint:e.collectUrl,deploymentID:e.deploymentID,index:e.index})}).catch(e=>console.log(e))}async fetch(e,n,r,o){if(o?.signal.aborted===!0)throw new Error("Request aborted");let s={method:n,headers:{"Content-Type":"application/x-www-form-urlencoded"},signal:o?.signal};if(n==="POST"&&r!==void 0){let a=r;a.version=It,a.id=this.id,s.body=Object.entries(a).map(([p,h])=>`${p}=${encodeURIComponent(JSON.stringify(h))}`).join("&")}return await(await fetch(`${this.endpoint}/${e}?api-key=${this.api_key}`,s)).json()}};})();
"use strict";var OramaClient=(()=>{var Tt=Object.create;var S=Object.defineProperty;var Lt=Object.getOwnPropertyDescriptor;var Et=Object.getOwnPropertyNames;var At=Object.getPrototypeOf,jt=Object.prototype.hasOwnProperty;var Ht=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,n)=>(typeof require<"u"?require:e)[n]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw new Error('Dynamic require of "'+t+'" is not supported')});var m=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Mt=(t,e)=>{for(var n in e)S(t,n,{get:e[n],enumerable:!0})},q=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Et(e))!jt.call(t,o)&&o!==n&&S(t,o,{get:()=>e[o],enumerable:!(r=Lt(e,o))||r.enumerable});return t};var Pt=(t,e,n)=>(n=t!=null?Tt(At(t)):{},q(e||!t||!t.__esModule?S(n,"default",{value:t,enumerable:!0}):n,t)),Nt=t=>q(S({},"__esModule",{value:!0}),t);var Q=m(l=>{"use strict";Object.defineProperty(l,"__esModule",{value:!0});l.output=l.exists=l.hash=l.bytes=l.bool=l.number=void 0;function _(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}l.number=_;function Y(t){if(typeof t!="boolean")throw new Error(`Expected boolean, not ${t}`)}l.bool=Y;function M(t,...e){if(!(t instanceof Uint8Array))throw new Error("Expected Uint8Array");if(e.length>0&&!e.includes(t.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}l.bytes=M;function G(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");_(t.outputLen),_(t.blockLen)}l.hash=G;function J(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}l.exists=J;function Z(t,e){M(t);let n=e.outputLen;if(t.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}l.output=Z;var Ut={number:_,bool:Y,bytes:M,hash:G,exists:J,output:Z};l.default=Ut});var nt=m(f=>{"use strict";Object.defineProperty(f,"__esModule",{value:!0});f.add=f.toBig=f.split=f.fromBig=void 0;var v=BigInt(2**32-1),P=BigInt(32);function N(t,e=!1){return e?{h:Number(t&v),l:Number(t>>P&v)}:{h:Number(t>>P&v)|0,l:Number(t&v)|0}}f.fromBig=N;function tt(t,e=!1){let n=new Uint32Array(t.length),r=new Uint32Array(t.length);for(let o=0;o<t.length;o++){let{h:s,l:i}=N(t[o],e);[n[o],r[o]]=[s,i]}return[n,r]}f.split=tt;var $t=(t,e)=>BigInt(t>>>0)<<P|BigInt(e>>>0);f.toBig=$t;var Rt=(t,e,n)=>t>>>n,Dt=(t,e,n)=>t<<32-n|e>>>n,Ft=(t,e,n)=>t>>>n|e<<32-n,qt=(t,e,n)=>t<<32-n|e>>>n,Vt=(t,e,n)=>t<<64-n|e>>>n-32,Wt=(t,e,n)=>t>>>n-32|e<<64-n,Xt=(t,e)=>e,zt=(t,e)=>t,Kt=(t,e,n)=>t<<n|e>>>32-n,Yt=(t,e,n)=>e<<n|t>>>32-n,Gt=(t,e,n)=>e<<n-32|t>>>64-n,Jt=(t,e,n)=>t<<n-32|e>>>64-n;function et(t,e,n,r){let o=(e>>>0)+(r>>>0);return{h:t+n+(o/2**32|0)|0,l:o|0}}f.add=et;var Zt=(t,e,n)=>(t>>>0)+(e>>>0)+(n>>>0),Qt=(t,e,n,r)=>e+n+r+(t/2**32|0)|0,te=(t,e,n,r)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0),ee=(t,e,n,r,o)=>e+n+r+o+(t/2**32|0)|0,ne=(t,e,n,r,o)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0)+(o>>>0),re=(t,e,n,r,o,s)=>e+n+r+o+s+(t/2**32|0)|0,oe={fromBig:N,split:tt,toBig:f.toBig,shrSH:Rt,shrSL:Dt,rotrSH:Ft,rotrSL:qt,rotrBH:Vt,rotrBL:Wt,rotr32H:Xt,rotr32L:zt,rotlSH:Kt,rotlSL:Yt,rotlBH:Gt,rotlBL:Jt,add:et,add3L:Zt,add3H:Qt,add4L:te,add4H:ee,add5H:re,add5L:ne};f.default=oe});var rt=m(L=>{"use strict";Object.defineProperty(L,"__esModule",{value:!0});L.crypto=void 0;var T=Ht("node:crypto");L.crypto=T&&typeof T=="object"&&"webcrypto"in T?T.webcrypto:void 0});var it=m(c=>{"use strict";Object.defineProperty(c,"__esModule",{value:!0});c.randomBytes=c.wrapXOFConstructorWithOpts=c.wrapConstructorWithOpts=c.wrapConstructor=c.checkOpts=c.Hash=c.concatBytes=c.toBytes=c.utf8ToBytes=c.asyncLoop=c.nextTick=c.hexToBytes=c.bytesToHex=c.isLE=c.rotr=c.createView=c.u32=c.u8=void 0;var U=rt(),R=t=>t instanceof Uint8Array,ie=t=>new Uint8Array(t.buffer,t.byteOffset,t.byteLength);c.u8=ie;var se=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4));c.u32=se;var ce=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);c.createView=ce;var ae=(t,e)=>t<<32-e|t>>>e;c.rotr=ae;c.isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!c.isLE)throw new Error("Non little-endian hardware is not supported");var ue=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function le(t){if(!R(t))throw new Error("Uint8Array expected");let e="";for(let n=0;n<t.length;n++)e+=ue[t[n]];return e}c.bytesToHex=le;function fe(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);let e=t.length;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(e/2);for(let r=0;r<n.length;r++){let o=r*2,s=t.slice(o,o+2),i=Number.parseInt(s,16);if(Number.isNaN(i)||i<0)throw new Error("Invalid byte sequence");n[r]=i}return n}c.hexToBytes=fe;var pe=async()=>{};c.nextTick=pe;async function he(t,e,n){let r=Date.now();for(let o=0;o<t;o++){n(o);let s=Date.now()-r;s>=0&&s<e||(await(0,c.nextTick)(),r+=s)}}c.asyncLoop=he;function ot(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}c.utf8ToBytes=ot;function E(t){if(typeof t=="string"&&(t=ot(t)),!R(t))throw new Error(`expected Uint8Array, got ${typeof t}`);return t}c.toBytes=E;function de(...t){let e=new Uint8Array(t.reduce((r,o)=>r+o.length,0)),n=0;return t.forEach(r=>{if(!R(r))throw new Error("Uint8Array expected");e.set(r,n),n+=r.length}),e}c.concatBytes=de;var $=class{clone(){return this._cloneInto()}};c.Hash=$;var ge=t=>Object.prototype.toString.call(t)==="[object Object]"&&t.constructor===Object;function ye(t,e){if(e!==void 0&&(typeof e!="object"||!ge(e)))throw new Error("Options should be object or undefined");return Object.assign(t,e)}c.checkOpts=ye;function me(t){let e=r=>t().update(E(r)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}c.wrapConstructor=me;function be(t){let e=(r,o)=>t(o).update(E(r)).digest(),n=t({});return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=r=>t(r),e}c.wrapConstructorWithOpts=be;function we(t){let e=(r,o)=>t(o).update(E(r)).digest(),n=t({});return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=r=>t(r),e}c.wrapXOFConstructorWithOpts=we;function xe(t=32){if(U.crypto&&typeof U.crypto.getRandomValues=="function")return U.crypto.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}c.randomBytes=xe});var ht=m(u=>{"use strict";Object.defineProperty(u,"__esModule",{value:!0});u.shake256=u.shake128=u.keccak_512=u.keccak_384=u.keccak_256=u.keccak_224=u.sha3_512=u.sha3_384=u.sha3_256=u.sha3_224=u.Keccak=u.keccakP=void 0;var b=Q(),k=nt(),x=it(),[at,ut,lt]=[[],[],[]],ke=BigInt(0),w=BigInt(1),Ie=BigInt(2),Oe=BigInt(7),Be=BigInt(256),Ce=BigInt(113);for(let t=0,e=w,n=1,r=0;t<24;t++){[n,r]=[r,(2*n+3*r)%5],at.push(2*(5*r+n)),ut.push((t+1)*(t+2)/2%64);let o=ke;for(let s=0;s<7;s++)e=(e<<w^(e>>Oe)*Ce)%Be,e&Ie&&(o^=w<<(w<<BigInt(s))-w);lt.push(o)}var[Se,_e]=k.default.split(lt,!0),st=(t,e,n)=>n>32?k.default.rotlBH(t,e,n):k.default.rotlSH(t,e,n),ct=(t,e,n)=>n>32?k.default.rotlBL(t,e,n):k.default.rotlSL(t,e,n);function ft(t,e=24){let n=new Uint32Array(10);for(let r=24-e;r<24;r++){for(let i=0;i<10;i++)n[i]=t[i]^t[i+10]^t[i+20]^t[i+30]^t[i+40];for(let i=0;i<10;i+=2){let a=(i+8)%10,p=(i+2)%10,h=n[p],y=n[p+1],_t=st(h,y,1)^n[a],vt=ct(h,y,1)^n[a+1];for(let C=0;C<50;C+=10)t[i+C]^=_t,t[i+C+1]^=vt}let o=t[2],s=t[3];for(let i=0;i<24;i++){let a=ut[i],p=st(o,s,a),h=ct(o,s,a),y=at[i];o=t[y],s=t[y+1],t[y]=p,t[y+1]=h}for(let i=0;i<50;i+=10){for(let a=0;a<10;a++)n[a]=t[i+a];for(let a=0;a<10;a++)t[i+a]^=~n[(a+2)%10]&n[(a+4)%10]}t[0]^=Se[r],t[1]^=_e[r]}n.fill(0)}u.keccakP=ft;var I=class t extends x.Hash{constructor(e,n,r,o=!1,s=24){if(super(),this.blockLen=e,this.suffix=n,this.outputLen=r,this.enableXOF=o,this.rounds=s,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,b.default.number(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=(0,x.u32)(this.state)}keccak(){ft(this.state32,this.rounds),this.posOut=0,this.pos=0}update(e){b.default.exists(this);let{blockLen:n,state:r}=this;e=(0,x.toBytes)(e);let o=e.length;for(let s=0;s<o;){let i=Math.min(n-this.pos,o-s);for(let a=0;a<i;a++)r[this.pos++]^=e[s++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:e,suffix:n,pos:r,blockLen:o}=this;e[r]^=n,n&128&&r===o-1&&this.keccak(),e[o-1]^=128,this.keccak()}writeInto(e){b.default.exists(this,!1),b.default.bytes(e),this.finish();let n=this.state,{blockLen:r}=this;for(let o=0,s=e.length;o<s;){this.posOut>=r&&this.keccak();let i=Math.min(r-this.posOut,s-o);e.set(n.subarray(this.posOut,this.posOut+i),o),this.posOut+=i,o+=i}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return b.default.number(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(b.default.output(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){let{blockLen:n,suffix:r,outputLen:o,rounds:s,enableXOF:i}=this;return e||(e=new t(n,r,o,i,s)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=s,e.suffix=r,e.outputLen=o,e.enableXOF=i,e.destroyed=this.destroyed,e}};u.Keccak=I;var d=(t,e,n)=>(0,x.wrapConstructor)(()=>new I(e,t,n));u.sha3_224=d(6,144,224/8);u.sha3_256=d(6,136,256/8);u.sha3_384=d(6,104,384/8);u.sha3_512=d(6,72,512/8);u.keccak_224=d(1,144,224/8);u.keccak_256=d(1,136,256/8);u.keccak_384=d(1,104,384/8);u.keccak_512=d(1,72,512/8);var pt=(t,e,n)=>(0,x.wrapXOFConstructorWithOpts)((r={})=>new I(e,t,r.dkLen===void 0?n:r.dkLen,!0));u.shake128=pt(31,168,128/8);u.shake256=pt(31,136,256/8)});var kt=m((Ge,g)=>{"use strict";var{sha3_512:ve}=ht(),gt=24,O=32,D=(t=4,e=Math.random)=>{let n="";for(;n.length<t;)n=n+Math.floor(e()*36).toString(36);return n};function yt(t){let e=8n,n=0n;for(let r of t.values()){let o=BigInt(r);n=(n<<e)+o}return n}var mt=(t="")=>yt(ve(t)).toString(36).slice(1),dt=Array.from({length:26},(t,e)=>String.fromCharCode(e+97)),Te=t=>dt[Math.floor(t()*dt.length)],bt=({globalObj:t=typeof global<"u"?global:typeof window<"u"?window:{},random:e=Math.random}={})=>{let n=Object.keys(t).toString(),r=n.length?n+D(O,e):D(O,e);return mt(r).substring(0,O)},wt=t=>()=>t++,Le=476782367,xt=({random:t=Math.random,counter:e=wt(Math.floor(t()*Le)),length:n=gt,fingerprint:r=bt({random:t})}={})=>function(){let s=Te(t),i=Date.now().toString(36),a=e().toString(36),p=D(n,t),h=`${i+p+a+r}`;return`${s+mt(h).substring(1,n)}`},Ee=xt(),Ae=(t,{minLength:e=2,maxLength:n=O}={})=>{let r=t.length,o=/^[0-9a-z]+$/;try{if(typeof t=="string"&&r>=e&&r<=n&&o.test(t))return!0}finally{}return!1};g.exports.getConstants=()=>({defaultLength:gt,bigLength:O});g.exports.init=xt;g.exports.createId=Ee;g.exports.bufToBigInt=yt;g.exports.createCounter=wt;g.exports.createFingerprint=bt;g.exports.isCuid=Ae});var It=m((Je,B)=>{"use strict";var{createId:je,init:He,getConstants:Me,isCuid:Pe}=kt();B.exports.createId=je;B.exports.init=He;B.exports.getConstants=Me;B.exports.isCuid=Pe});var Ue={};Mt(Ue,{OramaClient:()=>F});var Re=Date.now().toString().slice(5);var V=BigInt(1e3),W=BigInt(1e6),X=BigInt(1e9);async function z(t){return typeof t=="number"&&(t=BigInt(t)),t<V?`${t}ns`:t<W?`${t/V}\u03BCs`:t<X?`${t/W}ms`:`${t/X}s`}async function K(t){return{raw:Number(t),formatted:await z(t)}}var St=Pt(It(),1);var A=class{cache;config;constructor(e){this.cache=new Map,this.config=e}set(e,n){this.cache.set(e,n)}get(e){return this.cache.get(e)}has(e){return this.cache.has(e)}delete(e){return this.cache.delete(e)}clear(){this.cache.clear()}size(){return this.cache.size}};var Bt="1.0.0-beta.10";var Ct={name:"@oramacloud/client",version:Bt,description:"Orama SDK for Node.js, Deno, and Browsers",type:"module",sideEffects:!1,main:"./dist/index.cjs",module:"./dist/index.js",types:"./dist/index.d.ts",".":{require:"./dist/index.cjs",import:"./dist/index.js",types:"./dist/index.d.ts",browser:"./dist/index.global.js"},scripts:{lint:"ts-standard --fix",build:"tsup src/index.ts --format cjs,esm,iife --dts --minify --sourcemap --clean --global-name OramaClient",test:'echo "Error: no test specified" && exit 1',"serve:example":"esbuild src/index.ts --bundle --outfile=example/out.js --format=esm --watch --servedir=example"},keywords:["orama","search engine","sdk"],files:["dist"],author:{name:"Michele Riva",email:"michele.riva@oramasearch.com",url:"https://github.com/MicheleRiva"},license:"ISC",dependencies:{"@orama/orama":"^1.0.8","@paralleldrive/cuid2":"^2.2.1"},devDependencies:{"@types/node":"^20.3.1",concurrently:"^8.2.0",esbuild:"0.18.5","ts-standard":"^12.0.2",tsup:"^7.1.0",typescript:"^5.1.3"}};var j=class t{data;params;config;constructor(e){this.data=[],this.config=e}setParams(e){this.params=e}static create(e){let n=new t(e);return n.start(),n}add(e){this.data.push({rawSearchString:e.rawSearchString,query:e.query,resultsCount:e.resultsCount,roundTripTime:e.roundTripTime,searchedAt:e.searchedAt,referer:typeof location<"u"?location.toString():void 0}),this.params!=null&&this.data.length>=this.config.flushSize&&this.flush()}flush(){if(this.params==null||this.data.length===0)return;let e=this.data;this.data=[];let n={source:"fe",deploymentID:this.params.deploymentID,index:this.params.index,oramaId:this.config.id,oramaVersion:Ct.version,userAgent:typeof navigator<"u"?navigator.userAgent:void 0,events:e};navigator.sendBeacon?.(this.params.endpoint+`?api-key=${this.config.api_key}`,JSON.stringify(n))}start(){setInterval(this.flush.bind(this),this.config.flushInterval)}};var H=class{constructor(e){this.params=e}intervalId;start(){this.stop(),this.intervalId=setInterval(this.beat.bind(this),this.params.frequency)}stop(){this.intervalId!==void 0&&clearInterval(this.intervalId)}beat(){navigator.sendBeacon?.(this.params.endpoint)}};var F=class{id=(0,St.createId)();api_key;endpoint;collector;cache;heartbeat;initPromise;constructor(e){if(this.api_key=e.api_key,this.endpoint=e.endpoint,e.telemetry!==!1){let n={id:this.id,api_key:this.api_key,flushInterval:e.telemetry?.flushInterval??5e3,flushSize:e.telemetry?.flushSize??25};this.collector=j.create(n)}if(e.cache!==!1){let n={};this.cache=new A(n)}this.init()}async search(e,n){await this.initPromise;let r=JSON.stringify(e),o,s,i=!1;if((n?.fresh!==!0&&this.cache?.has(r))===!0&&this.cache!=null)o=0,s=this.cache.get(r),i=!0;else{let p=Date.now();s=await this.fetch("search","POST",{q:e},n?.abortController);let h=Date.now();s.elapsed=await K(BigInt(h*1e6-p*1e6)),o=h-p,this.cache?.set(r,s)}return this.collector!=null&&this.collector.add({rawSearchString:e.term,resultsCount:s.hits.length,roundTripTime:o,query:e,cached:i,searchedAt:new Date}),s}startHeartBeat(e){this.heartbeat?.stop(),this.heartbeat=new H({...e,endpoint:this.endpoint+`/health?api-key=${this.api_key}`}),this.heartbeat.start()}stopHeartBeat(){this.heartbeat?.stop()}init(){this.initPromise=this.fetch("init","GET").then(e=>{this.collector?.setParams({endpoint:e.collectUrl,deploymentID:e.deploymentID,index:e.index})}).catch(e=>console.log(e))}async fetch(e,n,r,o){if(o?.signal.aborted===!0)throw new Error("Request aborted");let s={method:n,headers:{"Content-Type":"application/x-www-form-urlencoded"},signal:o?.signal};if(n==="POST"&&r!==void 0){let a=r;a.version=Bt,a.id=this.id,s.body=Object.entries(a).map(([p,h])=>`${p}=${encodeURIComponent(JSON.stringify(h))}`).join("&")}return await(await fetch(`${this.endpoint}/${e}?api-key=${this.api_key}`,s)).json()}};return Nt(Ue);})();
/*! Bundled license information:

@@ -3,0 +3,0 @@

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

import{formatElapsedTime as C}from"@orama/orama/components";import{createId as g}from"@paralleldrive/cuid2";var l=class{cache;config;constructor(e){this.cache=new Map,this.config=e}set(e,t){this.cache.set(e,t)}get(e){return this.cache.get(e)}has(e){return this.cache.has(e)}delete(e){return this.cache.delete(e)}clear(){this.cache.clear()}size(){return this.cache.size}};var m="1.0.0-beta.8";var f={name:"@oramacloud/client",version:m,description:"Orama SDK for Node.js, Deno, and Browsers",type:"module",sideEffects:!1,main:"./dist/index.cjs",module:"./dist/esm/index.mjs",types:"./dist/index.d.ts",".":{require:"./dist/index.cjs",import:"./dist/esm/index.mjs",types:"./dist/index.d.ts",browsers:"./dist/iife/index.js"},scripts:{lint:"ts-standard --fix",build:"tsup src/index.ts --format cjs,esm,iife --dts --minify --sourcemap --clean",test:'echo "Error: no test specified" && exit 1',"serve:example":"esbuild src/index.ts --bundle --outfile=example/out.js --format=esm --watch --servedir=example"},keywords:["orama","search engine","sdk"],files:["dist"],author:{name:"Michele Riva",email:"michele.riva@oramasearch.com",url:"https://github.com/MicheleRiva"},license:"ISC",dependencies:{"@orama/orama":"^1.0.8","@paralleldrive/cuid2":"^2.2.1"},devDependencies:{"@types/node":"^20.3.1",concurrently:"^8.2.0",esbuild:"0.18.5","ts-standard":"^12.0.2",tsup:"^7.1.0",typescript:"^5.1.3"}};var h=class a{data;params;config;constructor(e){this.data=[],this.config=e}setParams(e){this.params=e}static create(e){let t=new a(e);return t.start(),t}add(e){this.data.push({rawSearchString:e.rawSearchString,query:e.query,resultsCount:e.resultsCount,roundTripTime:e.roundTripTime,searchedAt:e.searchedAt,referer:typeof location<"u"?location.toString():void 0}),this.params!=null&&this.data.length>=this.config.flushSize&&this.flush()}flush(){if(this.params==null||this.data.length===0)return;let e=this.data;this.data=[];let t={source:"fe",deploymentID:this.params.deploymentID,index:this.params.index,oramaId:this.config.id,oramaVersion:f.version,userAgent:typeof navigator<"u"?navigator.userAgent:void 0,events:e};navigator.sendBeacon?.(this.params.endpoint+`?api-key=${this.config.api_key}`,JSON.stringify(t))}start(){setInterval(this.flush.bind(this),this.config.flushInterval)}};var d=class{constructor(e){this.params=e}intervalId;start(){this.stop(),this.intervalId=setInterval(this.beat.bind(this),this.params.frequency)}stop(){this.intervalId!==void 0&&clearInterval(this.intervalId)}beat(){navigator.sendBeacon?.(this.params.endpoint)}};var v=class{id=g();api_key;endpoint;collector;cache;heartbeat;initPromise;constructor(e){if(this.api_key=e.api_key,this.endpoint=e.endpoint,e.telemetry!==!1){let t={id:this.id,api_key:this.api_key,flushInterval:e.telemetry?.flushInterval??5e3,flushSize:e.telemetry?.flushSize??25};this.collector=h.create(t)}if(e.cache!==!1){let t={};this.cache=new l(t)}this.init()}async search(e,t){await this.initPromise;let r=JSON.stringify(e),s,i,p=!1;if((t?.fresh!==!0&&this.cache?.has(r))===!0&&this.cache!=null)s=0,i=this.cache.get(r),p=!0;else{let n=Date.now();i=await this.fetch("search","POST",{q:e},t?.abortController);let c=Date.now();i.elapsed=await C(BigInt(c*1e6-n*1e6)),s=c-n,this.cache?.set(r,i)}return this.collector!=null&&this.collector.add({rawSearchString:e.term,resultsCount:i.hits.length,roundTripTime:s,query:e,cached:p,searchedAt:new Date}),i}startHeartBeat(e){this.heartbeat?.stop(),this.heartbeat=new d({...e,endpoint:this.endpoint+`/health?api-key=${this.api_key}`}),this.heartbeat.start()}stopHeartBeat(){this.heartbeat?.stop()}init(){this.initPromise=this.fetch("init","GET").then(e=>{this.collector?.setParams({endpoint:e.collectUrl,deploymentID:e.deploymentID,index:e.index})}).catch(e=>console.log(e))}async fetch(e,t,r,s){if(s?.signal.aborted===!0)throw new Error("Request aborted");let i={method:t,headers:{"Content-Type":"application/x-www-form-urlencoded"},signal:s?.signal};if(t==="POST"&&r!==void 0){let o=r;o.version=m,o.id=this.id,i.body=Object.entries(o).map(([n,c])=>`${n}=${encodeURIComponent(JSON.stringify(c))}`).join("&")}return await(await fetch(`${this.endpoint}/${e}?api-key=${this.api_key}`,i)).json()}};export{v as OramaClient};
import{formatElapsedTime as C}from"@orama/orama/components";import{createId as g}from"@paralleldrive/cuid2";var l=class{cache;config;constructor(e){this.cache=new Map,this.config=e}set(e,t){this.cache.set(e,t)}get(e){return this.cache.get(e)}has(e){return this.cache.has(e)}delete(e){return this.cache.delete(e)}clear(){this.cache.clear()}size(){return this.cache.size}};var m="1.0.0-beta.10";var f={name:"@oramacloud/client",version:m,description:"Orama SDK for Node.js, Deno, and Browsers",type:"module",sideEffects:!1,main:"./dist/index.cjs",module:"./dist/index.js",types:"./dist/index.d.ts",".":{require:"./dist/index.cjs",import:"./dist/index.js",types:"./dist/index.d.ts",browser:"./dist/index.global.js"},scripts:{lint:"ts-standard --fix",build:"tsup src/index.ts --format cjs,esm,iife --dts --minify --sourcemap --clean --global-name OramaClient",test:'echo "Error: no test specified" && exit 1',"serve:example":"esbuild src/index.ts --bundle --outfile=example/out.js --format=esm --watch --servedir=example"},keywords:["orama","search engine","sdk"],files:["dist"],author:{name:"Michele Riva",email:"michele.riva@oramasearch.com",url:"https://github.com/MicheleRiva"},license:"ISC",dependencies:{"@orama/orama":"^1.0.8","@paralleldrive/cuid2":"^2.2.1"},devDependencies:{"@types/node":"^20.3.1",concurrently:"^8.2.0",esbuild:"0.18.5","ts-standard":"^12.0.2",tsup:"^7.1.0",typescript:"^5.1.3"}};var h=class a{data;params;config;constructor(e){this.data=[],this.config=e}setParams(e){this.params=e}static create(e){let t=new a(e);return t.start(),t}add(e){this.data.push({rawSearchString:e.rawSearchString,query:e.query,resultsCount:e.resultsCount,roundTripTime:e.roundTripTime,searchedAt:e.searchedAt,referer:typeof location<"u"?location.toString():void 0}),this.params!=null&&this.data.length>=this.config.flushSize&&this.flush()}flush(){if(this.params==null||this.data.length===0)return;let e=this.data;this.data=[];let t={source:"fe",deploymentID:this.params.deploymentID,index:this.params.index,oramaId:this.config.id,oramaVersion:f.version,userAgent:typeof navigator<"u"?navigator.userAgent:void 0,events:e};navigator.sendBeacon?.(this.params.endpoint+`?api-key=${this.config.api_key}`,JSON.stringify(t))}start(){setInterval(this.flush.bind(this),this.config.flushInterval)}};var d=class{constructor(e){this.params=e}intervalId;start(){this.stop(),this.intervalId=setInterval(this.beat.bind(this),this.params.frequency)}stop(){this.intervalId!==void 0&&clearInterval(this.intervalId)}beat(){navigator.sendBeacon?.(this.params.endpoint)}};var v=class{id=g();api_key;endpoint;collector;cache;heartbeat;initPromise;constructor(e){if(this.api_key=e.api_key,this.endpoint=e.endpoint,e.telemetry!==!1){let t={id:this.id,api_key:this.api_key,flushInterval:e.telemetry?.flushInterval??5e3,flushSize:e.telemetry?.flushSize??25};this.collector=h.create(t)}if(e.cache!==!1){let t={};this.cache=new l(t)}this.init()}async search(e,t){await this.initPromise;let r=JSON.stringify(e),s,i,p=!1;if((t?.fresh!==!0&&this.cache?.has(r))===!0&&this.cache!=null)s=0,i=this.cache.get(r),p=!0;else{let n=Date.now();i=await this.fetch("search","POST",{q:e},t?.abortController);let c=Date.now();i.elapsed=await C(BigInt(c*1e6-n*1e6)),s=c-n,this.cache?.set(r,i)}return this.collector!=null&&this.collector.add({rawSearchString:e.term,resultsCount:i.hits.length,roundTripTime:s,query:e,cached:p,searchedAt:new Date}),i}startHeartBeat(e){this.heartbeat?.stop(),this.heartbeat=new d({...e,endpoint:this.endpoint+`/health?api-key=${this.api_key}`}),this.heartbeat.start()}stopHeartBeat(){this.heartbeat?.stop()}init(){this.initPromise=this.fetch("init","GET").then(e=>{this.collector?.setParams({endpoint:e.collectUrl,deploymentID:e.deploymentID,index:e.index})}).catch(e=>console.log(e))}async fetch(e,t,r,s){if(s?.signal.aborted===!0)throw new Error("Request aborted");let i={method:t,headers:{"Content-Type":"application/x-www-form-urlencoded"},signal:s?.signal};if(t==="POST"&&r!==void 0){let o=r;o.version=m,o.id=this.id,i.body=Object.entries(o).map(([n,c])=>`${n}=${encodeURIComponent(JSON.stringify(c))}`).join("&")}return await(await fetch(`${this.endpoint}/${e}?api-key=${this.api_key}`,i)).json()}};export{v as OramaClient};
//# sourceMappingURL=index.js.map
{
"name": "@oramacloud/client",
"version": "1.0.0-beta.10",
"version": "1.0.0-beta.11",
"description": "Orama SDK for Node.js, Deno, and Browsers",

@@ -44,3 +44,3 @@ "type": "module",

"lint": "ts-standard --fix",
"build": "tsup src/index.ts --format cjs,esm,iife --dts --minify --sourcemap --clean",
"build": "tsup src/index.ts --format cjs,esm,iife --dts --minify --sourcemap --clean --global-name OramaClient",
"test": "echo \"Error: no test specified\" && exit 1",

@@ -47,0 +47,0 @@ "serve:example": "esbuild src/index.ts --bundle --outfile=example/out.js --format=esm --watch --servedir=example"

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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