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

@oramacloud/client

Package Overview
Dependencies
Maintainers
4
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.21 to 1.0.0-beta.22

./dist/index.cjs

5

dist/index.d.ts

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

import { SearchParams, Results } from '@orama/orama';
import { SearchParams, AnyOrama, Results, AnyDocument } from '@orama/orama';

@@ -32,3 +32,4 @@ interface IOramaClient {

constructor(params: IOramaClient);
search(query: SearchParams, config?: SearchConfig): Promise<Results>;
search(query: SearchParams<AnyOrama>, config?: SearchConfig): Promise<Results<AnyDocument>>;
vectorSearch(query: Pick<SearchParams<AnyOrama>, 'term' | 'threshold' | 'limit'>, config?: SearchConfig): Promise<Pick<Results<AnyDocument>, 'hits' | 'elapsed'>>;
startHeartBeat(config: HeartBeatConfig): void;

@@ -35,0 +36,0 @@ stopHeartBeat(): void;

2

dist/index.global.js

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

"use strict";var OramaClient=(()=>{var Lt=Object.create;var v=Object.defineProperty;var Et=Object.getOwnPropertyDescriptor;var jt=Object.getOwnPropertyNames;var At=Object.getPrototypeOf,Pt=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)v(t,n,{get:e[n],enumerable:!0})},V=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of jt(e))!Pt.call(t,o)&&o!==n&&v(t,o,{get:()=>e[o],enumerable:!(r=Et(e,o))||r.enumerable});return t};var Nt=(t,e,n)=>(n=t!=null?Lt(At(t)):{},V(e||!t||!t.__esModule?v(n,"default",{value:t,enumerable:!0}):n,t)),Ut=t=>V(v({},"__esModule",{value:!0}),t);var tt=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 G(t){if(typeof t!="boolean")throw new Error(`Expected boolean, not ${t}`)}l.bool=G;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 J(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=J;function Z(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=Z;function Q(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=Q;var Rt={number:_,bool:G,bytes:M,hash:J,exists:Z,output:Q};l.default=Rt});var rt=m(f=>{"use strict";Object.defineProperty(f,"__esModule",{value:!0});f.add=f.toBig=f.split=f.fromBig=void 0;var T=BigInt(2**32-1),N=BigInt(32);function U(t,e=!1){return e?{h:Number(t&T),l:Number(t>>N&T)}:{h:Number(t>>N&T)|0,l:Number(t&T)|0}}f.fromBig=U;function et(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}=U(t[o],e);[n[o],r[o]]=[s,i]}return[n,r]}f.split=et;var $t=(t,e)=>BigInt(t>>>0)<<N|BigInt(e>>>0);f.toBig=$t;var Dt=(t,e,n)=>t>>>n,Ft=(t,e,n)=>t<<32-n|e>>>n,qt=(t,e,n)=>t>>>n|e<<32-n,Vt=(t,e,n)=>t<<32-n|e>>>n,Wt=(t,e,n)=>t<<64-n|e>>>n-32,Xt=(t,e,n)=>t>>>n-32|e<<64-n,zt=(t,e)=>e,Kt=(t,e)=>t,Yt=(t,e,n)=>t<<n|e>>>32-n,Gt=(t,e,n)=>e<<n|t>>>32-n,Jt=(t,e,n)=>e<<n-32|t>>>64-n,Zt=(t,e,n)=>t<<n-32|e>>>64-n;function nt(t,e,n,r){let o=(e>>>0)+(r>>>0);return{h:t+n+(o/2**32|0)|0,l:o|0}}f.add=nt;var Qt=(t,e,n)=>(t>>>0)+(e>>>0)+(n>>>0),te=(t,e,n,r)=>e+n+r+(t/2**32|0)|0,ee=(t,e,n,r)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0),ne=(t,e,n,r,o)=>e+n+r+o+(t/2**32|0)|0,re=(t,e,n,r,o)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0)+(o>>>0),oe=(t,e,n,r,o,s)=>e+n+r+o+s+(t/2**32|0)|0,ie={fromBig:U,split:et,toBig:f.toBig,shrSH:Dt,shrSL:Ft,rotrSH:qt,rotrSL:Vt,rotrBH:Wt,rotrBL:Xt,rotr32H:zt,rotr32L:Kt,rotlSH:Yt,rotlSL:Gt,rotlBH:Jt,rotlBL:Zt,add:nt,add3L:Qt,add3H:te,add4L:ee,add4H:ne,add5H:oe,add5L:re};f.default=ie});var ot=m(E=>{"use strict";Object.defineProperty(E,"__esModule",{value:!0});E.crypto=void 0;var L=Ht("node:crypto");E.crypto=L&&typeof L=="object"&&"webcrypto"in L?L.webcrypto:void 0});var st=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 R=ot(),D=t=>t instanceof Uint8Array,se=t=>new Uint8Array(t.buffer,t.byteOffset,t.byteLength);c.u8=se;var ce=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4));c.u32=ce;var ae=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);c.createView=ae;var ue=(t,e)=>t<<32-e|t>>>e;c.rotr=ue;c.isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!c.isLE)throw new Error("Non little-endian hardware is not supported");var le=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function fe(t){if(!D(t))throw new Error("Uint8Array expected");let e="";for(let n=0;n<t.length;n++)e+=le[t[n]];return e}c.bytesToHex=fe;function pe(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=pe;var de=async()=>{};c.nextTick=de;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 it(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}c.utf8ToBytes=it;function j(t){if(typeof t=="string"&&(t=it(t)),!D(t))throw new Error(`expected Uint8Array, got ${typeof t}`);return t}c.toBytes=j;function ge(...t){let e=new Uint8Array(t.reduce((r,o)=>r+o.length,0)),n=0;return t.forEach(r=>{if(!D(r))throw new Error("Uint8Array expected");e.set(r,n),n+=r.length}),e}c.concatBytes=ge;var $=class{clone(){return this._cloneInto()}};c.Hash=$;var ye=t=>Object.prototype.toString.call(t)==="[object Object]"&&t.constructor===Object;function me(t,e){if(e!==void 0&&(typeof e!="object"||!ye(e)))throw new Error("Options should be object or undefined");return Object.assign(t,e)}c.checkOpts=me;function be(t){let e=r=>t().update(j(r)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}c.wrapConstructor=be;function we(t){let e=(r,o)=>t(o).update(j(r)).digest(),n=t({});return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=r=>t(r),e}c.wrapConstructorWithOpts=we;function xe(t){let e=(r,o)=>t(o).update(j(r)).digest(),n=t({});return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=r=>t(r),e}c.wrapXOFConstructorWithOpts=xe;function ke(t=32){if(R.crypto&&typeof R.crypto.getRandomValues=="function")return R.crypto.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}c.randomBytes=ke});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=tt(),k=rt(),x=st(),[ut,lt,ft]=[[],[],[]],Ie=BigInt(0),w=BigInt(1),Oe=BigInt(2),Be=BigInt(7),Ce=BigInt(256),Se=BigInt(113);for(let t=0,e=w,n=1,r=0;t<24;t++){[n,r]=[r,(2*n+3*r)%5],ut.push(2*(5*r+n)),lt.push((t+1)*(t+2)/2%64);let o=Ie;for(let s=0;s<7;s++)e=(e<<w^(e>>Be)*Se)%Ce,e&Oe&&(o^=w<<(w<<BigInt(s))-w);ft.push(o)}var[ve,_e]=k.default.split(ft,!0),ct=(t,e,n)=>n>32?k.default.rotlBH(t,e,n):k.default.rotlSH(t,e,n),at=(t,e,n)=>n>32?k.default.rotlBL(t,e,n):k.default.rotlSL(t,e,n);function pt(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,d=n[p],y=n[p+1],_t=ct(d,y,1)^n[a],Tt=at(d,y,1)^n[a+1];for(let S=0;S<50;S+=10)t[i+S]^=_t,t[i+S+1]^=Tt}let o=t[2],s=t[3];for(let i=0;i<24;i++){let a=lt[i],p=ct(o,s,a),d=at(o,s,a),y=ut[i];o=t[y],s=t[y+1],t[y]=p,t[y+1]=d}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]^=ve[r],t[1]^=_e[r]}n.fill(0)}u.keccakP=pt;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(){pt(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 h=(t,e,n)=>(0,x.wrapConstructor)(()=>new I(e,t,n));u.sha3_224=h(6,144,224/8);u.sha3_256=h(6,136,256/8);u.sha3_384=h(6,104,384/8);u.sha3_512=h(6,72,512/8);u.keccak_224=h(1,144,224/8);u.keccak_256=h(1,136,256/8);u.keccak_384=h(1,104,384/8);u.keccak_512=h(1,72,512/8);var dt=(t,e,n)=>(0,x.wrapXOFConstructorWithOpts)((r={})=>new I(e,t,r.dkLen===void 0?n:r.dkLen,!0));u.shake128=dt(31,168,128/8);u.shake256=dt(31,136,256/8)});var It=m((Je,g)=>{"use strict";var{sha3_512:Te}=ht(),yt=24,O=32,F=(t=4,e=Math.random)=>{let n="";for(;n.length<t;)n=n+Math.floor(e()*36).toString(36);return n};function mt(t){let e=8n,n=0n;for(let r of t.values()){let o=BigInt(r);n=(n<<e)+o}return n}var bt=(t="")=>mt(Te(t)).toString(36).slice(1),gt=Array.from({length:26},(t,e)=>String.fromCharCode(e+97)),Le=t=>gt[Math.floor(t()*gt.length)],wt=({globalObj:t=typeof global<"u"?global:typeof window<"u"?window:{},random:e=Math.random}={})=>{let n=Object.keys(t).toString(),r=n.length?n+F(O,e):F(O,e);return bt(r).substring(0,O)},xt=t=>()=>t++,Ee=476782367,kt=({random:t=Math.random,counter:e=xt(Math.floor(t()*Ee)),length:n=yt,fingerprint:r=wt({random:t})}={})=>function(){let s=Le(t),i=Date.now().toString(36),a=e().toString(36),p=F(n,t),d=`${i+p+a+r}`;return`${s+bt(d).substring(1,n)}`},je=kt(),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:yt,bigLength:O});g.exports.init=kt;g.exports.createId=je;g.exports.bufToBigInt=mt;g.exports.createCounter=xt;g.exports.createFingerprint=wt;g.exports.isCuid=Ae});var Ot=m((Ze,B)=>{"use strict";var{createId:Pe,init:He,getConstants:Me,isCuid:Ne}=It();B.exports.createId=Pe;B.exports.init=He;B.exports.getConstants=Me;B.exports.isCuid=Ne});var Re={};Mt(Re,{OramaClient:()=>q});var De=Date.now().toString().slice(5);var W=BigInt(1e3),X=BigInt(1e6),z=BigInt(1e9);async function K(t){return typeof t=="number"&&(t=BigInt(t)),t<W?`${t}ns`:t<X?`${t/W}\u03BCs`:t<z?`${t/X}ms`:`${t/z}s`}async function Y(t){return{raw:Number(t),formatted:await K(t)}}var vt=Nt(Ot(),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 Ct="1.0.0-beta.20";var St={name:"@oramacloud/client",version:Ct,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",runkitExampleFilename:"./example/runkit.js",exports:{".":{require:"./dist/index.cjs",import:"./dist/index.js",types:"./dist/index.d.ts",browser:"./dist/index.global.js"},"./react":{require:"./dist/react/index.cjs",import:"./dist/react/index.js",types:"./dist/react/index.d.ts"},"./vue":{require:"./dist/vue/index.cjs",import:"./dist/vue/index.js",types:"./dist/vue/index.d.ts"}},scripts:{lint:"ts-standard --fix",build:"npm run build:lib && npm run build:react","build:lib":"tsup --config tsup.lib.js","build:react":"tsup --config tsup.react.js","build:vue":"tsup --config tsup.vue.js",test:"tsx tests/index.test.ts","serve:example":"esbuild src/index.ts --bundle --outfile=example/out.js --format=esm --watch --servedir=example",prepare:"husky install"},keywords:["orama","search engine","sdk"],files:["dist","example/runkit.js"],author:{name:"Michele Riva",email:"michele.riva@oramasearch.com",url:"https://github.com/MicheleRiva"},license:"ISC",dependencies:{"@orama/orama":"^1.0.10","@paralleldrive/cuid2":"^2.2.1",react:"^18.2.0",vue:"^3.3.4"},devDependencies:{"@fastify/formbody":"^7.4.0","@types/node":"^20.3.1","@types/react":"^18.2.14",esbuild:"0.18.5",fastify:"^4.19.2",husky:"^8.0.3","ts-standard":"^12.0.2",tsup:"^7.1.0",tsx:"^3.12.7",typescript:"^5.1.3"},"ts-standard":{ignore:["dist","node_modules"]}};function C(t,e){if(typeof navigator<"u"){navigator.sendBeacon(t,e);return}fetch(t,{method:"POST",body:e,headers:{"Content-Type":"application/json"}}).then(()=>{},n=>console.log(n))}var P=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:St.version,userAgent:typeof navigator<"u"?navigator.userAgent:void 0,events:e};C(this.params.endpoint+`?api-key=${this.config.api_key}`,JSON.stringify(n))}start(){let e=setInterval(this.flush.bind(this),this.config.flushInterval);e.unref!=null&&e.unref()}};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(){C(this.params.endpoint)}};var q=class{id=(0,vt.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=P.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 d=Date.now();s.elapsed=await Y(BigInt(d*1e6-p*1e6)),o=d-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()}getPop(){return this.initPromise.then(e=>e==null?"":e.pop)}init(){this.initPromise=this.fetch("init","GET").then(e=>(this.collector?.setParams({endpoint:e.collectUrl,deploymentID:e.deploymentID,index:e.index}),e)).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=Ct,a.id=this.id,s.body=Object.entries(a).map(([p,d])=>`${p}=${encodeURIComponent(JSON.stringify(d))}`).join("&")}return await(await fetch(`${this.endpoint}/${e}?api-key=${this.api_key}`,s)).json()}};return Ut(Re);})();
"use strict";var OramaClient=(()=>{var Et=Object.create;var B=Object.defineProperty;var Lt=Object.getOwnPropertyDescriptor;var jt=Object.getOwnPropertyNames;var Pt=Object.getPrototypeOf,Dt=Object.prototype.hasOwnProperty;var Nt=(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),Rt=(t,e)=>{for(var n in e)B(t,n,{get:e[n],enumerable:!0})},z=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of jt(e))!Dt.call(t,o)&&o!==n&&B(t,o,{get:()=>e[o],enumerable:!(r=Lt(e,o))||r.enumerable});return t};var Mt=(t,e,n)=>(n=t!=null?Et(Pt(t)):{},z(e||!t||!t.__esModule?B(n,"default",{value:t,enumerable:!0}):n,t)),Ht=t=>z(B({},"__esModule",{value:!0}),t);var et=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(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}l.number=T;function J(t){if(typeof t!="boolean")throw new Error(`Expected boolean, not ${t}`)}l.bool=J;function R(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=R;function Z(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");T(t.outputLen),T(t.blockLen)}l.hash=Z;function Q(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=Q;function tt(t,e){R(t);let n=e.outputLen;if(t.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}l.output=tt;var Ut={number:T,bool:J,bytes:R,hash:Z,exists:Q,output:tt};l.default=Ut});var ot=m(h=>{"use strict";Object.defineProperty(h,"__esModule",{value:!0});h.add=h.toBig=h.split=h.fromBig=void 0;var v=BigInt(2**32-1),M=BigInt(32);function H(t,e=!1){return e?{h:Number(t&v),l:Number(t>>M&v)}:{h:Number(t>>M&v)|0,l:Number(t&v)|0}}h.fromBig=H;function nt(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}=H(t[o],e);[n[o],r[o]]=[s,i]}return[n,r]}h.split=nt;var $t=(t,e)=>BigInt(t>>>0)<<M|BigInt(e>>>0);h.toBig=$t;var Ft=(t,e,n)=>t>>>n,Vt=(t,e,n)=>t<<32-n|e>>>n,qt=(t,e,n)=>t>>>n|e<<32-n,Xt=(t,e,n)=>t<<32-n|e>>>n,zt=(t,e,n)=>t<<64-n|e>>>n-32,Wt=(t,e,n)=>t>>>n-32|e<<64-n,Kt=(t,e)=>e,Yt=(t,e)=>t,Gt=(t,e,n)=>t<<n|e>>>32-n,Jt=(t,e,n)=>e<<n|t>>>32-n,Zt=(t,e,n)=>e<<n-32|t>>>64-n,Qt=(t,e,n)=>t<<n-32|e>>>64-n;function rt(t,e,n,r){let o=(e>>>0)+(r>>>0);return{h:t+n+(o/2**32|0)|0,l:o|0}}h.add=rt;var te=(t,e,n)=>(t>>>0)+(e>>>0)+(n>>>0),ee=(t,e,n,r)=>e+n+r+(t/2**32|0)|0,ne=(t,e,n,r)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0),re=(t,e,n,r,o)=>e+n+r+o+(t/2**32|0)|0,oe=(t,e,n,r,o)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0)+(o>>>0),ie=(t,e,n,r,o,s)=>e+n+r+o+s+(t/2**32|0)|0,se={fromBig:H,split:nt,toBig:h.toBig,shrSH:Ft,shrSL:Vt,rotrSH:qt,rotrSL:Xt,rotrBH:zt,rotrBL:Wt,rotr32H:Kt,rotr32L:Yt,rotlSH:Gt,rotlSL:Jt,rotlBH:Zt,rotlBL:Qt,add:rt,add3L:te,add3H:ee,add4L:ne,add4H:re,add5H:ie,add5L:oe};h.default=se});var it=m(E=>{"use strict";Object.defineProperty(E,"__esModule",{value:!0});E.crypto=void 0;var A=Nt("node:crypto");E.crypto=A&&typeof A=="object"&&"webcrypto"in A?A.webcrypto:void 0});var ct=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=it(),F=t=>t instanceof Uint8Array,ce=t=>new Uint8Array(t.buffer,t.byteOffset,t.byteLength);c.u8=ce;var ae=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4));c.u32=ae;var ue=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);c.createView=ue;var le=(t,e)=>t<<32-e|t>>>e;c.rotr=le;c.isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!c.isLE)throw new Error("Non little-endian hardware is not supported");var fe=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function pe(t){if(!F(t))throw new Error("Uint8Array expected");let e="";for(let n=0;n<t.length;n++)e+=fe[t[n]];return e}c.bytesToHex=pe;function he(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=he;var de=async()=>{};c.nextTick=de;async function ge(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=ge;function st(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}c.utf8ToBytes=st;function L(t){if(typeof t=="string"&&(t=st(t)),!F(t))throw new Error(`expected Uint8Array, got ${typeof t}`);return t}c.toBytes=L;function ye(...t){let e=new Uint8Array(t.reduce((r,o)=>r+o.length,0)),n=0;return t.forEach(r=>{if(!F(r))throw new Error("Uint8Array expected");e.set(r,n),n+=r.length}),e}c.concatBytes=ye;var $=class{clone(){return this._cloneInto()}};c.Hash=$;var me=t=>Object.prototype.toString.call(t)==="[object Object]"&&t.constructor===Object;function be(t,e){if(e!==void 0&&(typeof e!="object"||!me(e)))throw new Error("Options should be object or undefined");return Object.assign(t,e)}c.checkOpts=be;function we(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=we;function xe(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=xe;function Se(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=Se;function Ie(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=Ie});var gt=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=et(),S=ot(),x=ct(),[lt,ft,pt]=[[],[],[]],ke=BigInt(0),w=BigInt(1),Oe=BigInt(2),Ce=BigInt(7),_e=BigInt(256),Be=BigInt(113);for(let t=0,e=w,n=1,r=0;t<24;t++){[n,r]=[r,(2*n+3*r)%5],lt.push(2*(5*r+n)),ft.push((t+1)*(t+2)/2%64);let o=ke;for(let s=0;s<7;s++)e=(e<<w^(e>>Ce)*Be)%_e,e&Oe&&(o^=w<<(w<<BigInt(s))-w);pt.push(o)}var[Te,ve]=S.default.split(pt,!0),at=(t,e,n)=>n>32?S.default.rotlBH(t,e,n):S.default.rotlSH(t,e,n),ut=(t,e,n)=>n>32?S.default.rotlBL(t,e,n):S.default.rotlSL(t,e,n);function ht(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,f=(i+2)%10,p=n[f],y=n[f+1],vt=at(p,y,1)^n[a],At=ut(p,y,1)^n[a+1];for(let _=0;_<50;_+=10)t[i+_]^=vt,t[i+_+1]^=At}let o=t[2],s=t[3];for(let i=0;i<24;i++){let a=ft[i],f=at(o,s,a),p=ut(o,s,a),y=lt[i];o=t[y],s=t[y+1],t[y]=f,t[y+1]=p}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]^=Te[r],t[1]^=ve[r]}n.fill(0)}u.keccakP=ht;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(){ht(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 dt=(t,e,n)=>(0,x.wrapXOFConstructorWithOpts)((r={})=>new I(e,t,r.dkLen===void 0?n:r.dkLen,!0));u.shake128=dt(31,168,128/8);u.shake256=dt(31,136,256/8)});var kt=m((Je,g)=>{"use strict";var{sha3_512:Ae}=gt(),mt=24,k=32,V=(t=4,e=Math.random)=>{let n="";for(;n.length<t;)n=n+Math.floor(e()*36).toString(36);return n};function bt(t){let e=8n,n=0n;for(let r of t.values()){let o=BigInt(r);n=(n<<e)+o}return n}var wt=(t="")=>bt(Ae(t)).toString(36).slice(1),yt=Array.from({length:26},(t,e)=>String.fromCharCode(e+97)),Ee=t=>yt[Math.floor(t()*yt.length)],xt=({globalObj:t=typeof global<"u"?global:typeof window<"u"?window:{},random:e=Math.random}={})=>{let n=Object.keys(t).toString(),r=n.length?n+V(k,e):V(k,e);return wt(r).substring(0,k)},St=t=>()=>t++,Le=476782367,It=({random:t=Math.random,counter:e=St(Math.floor(t()*Le)),length:n=mt,fingerprint:r=xt({random:t})}={})=>function(){let s=Ee(t),i=Date.now().toString(36),a=e().toString(36),f=V(n,t),p=`${i+f+a+r}`;return`${s+wt(p).substring(1,n)}`},je=It(),Pe=(t,{minLength:e=2,maxLength:n=k}={})=>{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:mt,bigLength:k});g.exports.init=It;g.exports.createId=je;g.exports.bufToBigInt=bt;g.exports.createCounter=St;g.exports.createFingerprint=xt;g.exports.isCuid=Pe});var Ot=m((Ze,O)=>{"use strict";var{createId:De,init:Ne,getConstants:Re,isCuid:Me}=kt();O.exports.createId=De;O.exports.init=Ne;O.exports.getConstants=Re;O.exports.isCuid=Me});var He={};Rt(He,{OramaClient:()=>X});var $e=Date.now().toString().slice(5);var W=BigInt(1e3),K=BigInt(1e6),Y=BigInt(1e9);async function G(t){return typeof t=="number"&&(t=BigInt(t)),t<W?`${t}ns`:t<K?`${t/W}\u03BCs`:t<Y?`${t/K}ms`:`${t/Y}s`}async function N(t){return{raw:Number(t),formatted:await G(t)}}var Tt=Mt(Ot(),1);var j=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 _t="1.0.0-beta.21";var Bt={name:"@oramacloud/client",version:_t,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",runkitExampleFilename:"./example/runkit.js",exports:{".":{require:"./dist/index.cjs",import:"./dist/index.js",types:"./dist/index.d.ts",browser:"./dist/index.global.js"},"./react":{require:"./dist/react/index.cjs",import:"./dist/react/index.js",types:"./dist/react/index.d.ts"},"./vue":{require:"./dist/vue/index.cjs",import:"./dist/vue/index.js",types:"./dist/vue/index.d.ts"}},scripts:{lint:"ts-standard --fix",build:"npm run build:lib && npm run build:react","build:lib":"tsup --config tsup.lib.js","build:react":"tsup --config tsup.react.js","build:vue":"tsup --config tsup.vue.js",test:"tsx tests/index.test.ts","serve:example":"esbuild src/index.ts --bundle --outfile=example/out.js --format=esm --watch --servedir=example",prepare:"husky install"},keywords:["orama","search engine","sdk"],files:["dist","example/runkit.js"],author:{name:"Michele Riva",email:"michele.riva@oramasearch.com",url:"https://github.com/MicheleRiva"},license:"ISC",dependencies:{"@orama/orama":"^2.0.0-beta.9","@paralleldrive/cuid2":"^2.2.1",react:"^18.2.0",vue:"^3.3.4"},devDependencies:{"@fastify/formbody":"^7.4.0","@types/node":"^20.3.1","@types/react":"^18.2.14",esbuild:"0.18.5",fastify:"^4.19.2",husky:"^8.0.3","ts-standard":"^12.0.2",tsup:"^7.1.0",tsx:"^3.12.7",typescript:"^5.1.3"},"ts-standard":{ignore:["dist","node_modules"]}};function C(t,e){if(typeof navigator<"u"){navigator.sendBeacon(t,e);return}fetch(t,{method:"POST",body:e,headers:{"Content-Type":"application/json"}}).then(()=>{},n=>console.log(n))}var P=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:Bt.version,userAgent:typeof navigator<"u"?navigator.userAgent:void 0,events:e};C(this.params.endpoint+`?api-key=${this.config.api_key}`,JSON.stringify(n))?.catch(r=>console.log(r))}start(){let e=setInterval(this.flush.bind(this),this.config.flushInterval);e.unref!=null&&e.unref()}};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(){C(this.params.endpoint)?.catch(e=>console.log(e))}};var X=class{id=(0,Tt.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=P.create(n)}if(e.cache!==!1){let n={};this.cache=new j(n)}this.init()}async search(e,n){await this.initPromise;let r="search-"+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 f=Date.now();s=await this.fetch("search","POST",{q:e},n?.abortController);let p=Date.now();s.elapsed=await N(BigInt(p*1e6-f*1e6)),o=p-f,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}async vectorSearch(e,n){await this.initPromise;let r="vectorSearch-"+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 f=Date.now();s=await this.fetch("vector-search2","POST",{q:e},n?.abortController);let p=Date.now();s.elapsed=await N(BigInt(p*1e6-f*1e6)),o=p-f,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 D({...e,endpoint:this.endpoint+`/health?api-key=${this.api_key}`}),this.heartbeat.start()}stopHeartBeat(){this.heartbeat?.stop()}async getPop(){return(await this.initPromise)?.pop??""}init(){this.initPromise=this.fetch("init","GET").then(e=>(this.collector?.setParams({endpoint:e.collectUrl,deploymentID:e.deploymentID,index:e.index}),e)).catch(e=>(console.log(e),null))}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=_t,a.id=this.id,s.body=Object.entries(a).map(([f,p])=>`${f}=${encodeURIComponent(JSON.stringify(p))}`).join("&")}let i=await fetch(`${this.endpoint}/${e}?api-key=${this.api_key}`,s);if(!i.ok){let a=new Error;throw a.httpResponse=i,a}return await i.json()}};return Ht(He);})();
/*! Bundled license information:

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

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

import{formatElapsedTime as C}from"@orama/orama/components";import{createId as b}from"@paralleldrive/cuid2";var d=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 f="1.0.0-beta.20";var v={name:"@oramacloud/client",version:f,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",runkitExampleFilename:"./example/runkit.js",exports:{".":{require:"./dist/index.cjs",import:"./dist/index.js",types:"./dist/index.d.ts",browser:"./dist/index.global.js"},"./react":{require:"./dist/react/index.cjs",import:"./dist/react/index.js",types:"./dist/react/index.d.ts"},"./vue":{require:"./dist/vue/index.cjs",import:"./dist/vue/index.js",types:"./dist/vue/index.d.ts"}},scripts:{lint:"ts-standard --fix",build:"npm run build:lib && npm run build:react","build:lib":"tsup --config tsup.lib.js","build:react":"tsup --config tsup.react.js","build:vue":"tsup --config tsup.vue.js",test:"tsx tests/index.test.ts","serve:example":"esbuild src/index.ts --bundle --outfile=example/out.js --format=esm --watch --servedir=example",prepare:"husky install"},keywords:["orama","search engine","sdk"],files:["dist","example/runkit.js"],author:{name:"Michele Riva",email:"michele.riva@oramasearch.com",url:"https://github.com/MicheleRiva"},license:"ISC",dependencies:{"@orama/orama":"^1.0.10","@paralleldrive/cuid2":"^2.2.1",react:"^18.2.0",vue:"^3.3.4"},devDependencies:{"@fastify/formbody":"^7.4.0","@types/node":"^20.3.1","@types/react":"^18.2.14",esbuild:"0.18.5",fastify:"^4.19.2",husky:"^8.0.3","ts-standard":"^12.0.2",tsup:"^7.1.0",tsx:"^3.12.7",typescript:"^5.1.3"},"ts-standard":{ignore:["dist","node_modules"]}};function n(r,e){if(typeof navigator<"u"){navigator.sendBeacon(r,e);return}fetch(r,{method:"POST",body:e,headers:{"Content-Type":"application/json"}}).then(()=>{},t=>console.log(t))}var p=class r{data;params;config;constructor(e){this.data=[],this.config=e}setParams(e){this.params=e}static create(e){let t=new r(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:v.version,userAgent:typeof navigator<"u"?navigator.userAgent:void 0,events:e};n(this.params.endpoint+`?api-key=${this.config.api_key}`,JSON.stringify(t))}start(){let e=setInterval(this.flush.bind(this),this.config.flushInterval);e.unref!=null&&e.unref()}};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(){n(this.params.endpoint)}};var y=class{id=b();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=p.create(t)}if(e.cache!==!1){let t={};this.cache=new d(t)}this.init()}async search(e,t){await this.initPromise;let s=JSON.stringify(e),a,i,u=!1;if((t?.fresh!==!0&&this.cache?.has(s))===!0&&this.cache!=null)a=0,i=this.cache.get(s),u=!0;else{let c=Date.now();i=await this.fetch("search","POST",{q:e},t?.abortController);let l=Date.now();i.elapsed=await C(BigInt(l*1e6-c*1e6)),a=l-c,this.cache?.set(s,i)}return this.collector!=null&&this.collector.add({rawSearchString:e.term,resultsCount:i.hits.length,roundTripTime:a,query:e,cached:u,searchedAt:new Date}),i}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()}getPop(){return this.initPromise.then(e=>e==null?"":e.pop)}init(){this.initPromise=this.fetch("init","GET").then(e=>(this.collector?.setParams({endpoint:e.collectUrl,deploymentID:e.deploymentID,index:e.index}),e)).catch(e=>console.log(e))}async fetch(e,t,s,a){if(a?.signal.aborted===!0)throw new Error("Request aborted");let i={method:t,headers:{"Content-Type":"application/x-www-form-urlencoded"},signal:a?.signal};if(t==="POST"&&s!==void 0){let o=s;o.version=f,o.id=this.id,i.body=Object.entries(o).map(([c,l])=>`${c}=${encodeURIComponent(JSON.stringify(l))}`).join("&")}return await(await fetch(`${this.endpoint}/${e}?api-key=${this.api_key}`,i)).json()}};export{y as OramaClient};
import{formatElapsedTime as v}from"@orama/orama/components";import{createId as b}from"@paralleldrive/cuid2";var d=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 y="1.0.0-beta.21";var g={name:"@oramacloud/client",version:y,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",runkitExampleFilename:"./example/runkit.js",exports:{".":{require:"./dist/index.cjs",import:"./dist/index.js",types:"./dist/index.d.ts",browser:"./dist/index.global.js"},"./react":{require:"./dist/react/index.cjs",import:"./dist/react/index.js",types:"./dist/react/index.d.ts"},"./vue":{require:"./dist/vue/index.cjs",import:"./dist/vue/index.js",types:"./dist/vue/index.d.ts"}},scripts:{lint:"ts-standard --fix",build:"npm run build:lib && npm run build:react","build:lib":"tsup --config tsup.lib.js","build:react":"tsup --config tsup.react.js","build:vue":"tsup --config tsup.vue.js",test:"tsx tests/index.test.ts","serve:example":"esbuild src/index.ts --bundle --outfile=example/out.js --format=esm --watch --servedir=example",prepare:"husky install"},keywords:["orama","search engine","sdk"],files:["dist","example/runkit.js"],author:{name:"Michele Riva",email:"michele.riva@oramasearch.com",url:"https://github.com/MicheleRiva"},license:"ISC",dependencies:{"@orama/orama":"^2.0.0-beta.9","@paralleldrive/cuid2":"^2.2.1",react:"^18.2.0",vue:"^3.3.4"},devDependencies:{"@fastify/formbody":"^7.4.0","@types/node":"^20.3.1","@types/react":"^18.2.14",esbuild:"0.18.5",fastify:"^4.19.2",husky:"^8.0.3","ts-standard":"^12.0.2",tsup:"^7.1.0",tsx:"^3.12.7",typescript:"^5.1.3"},"ts-standard":{ignore:["dist","node_modules"]}};function h(o,e){if(typeof navigator<"u"){navigator.sendBeacon(o,e);return}fetch(o,{method:"POST",body:e,headers:{"Content-Type":"application/json"}}).then(()=>{},t=>console.log(t))}var p=class o{data;params;config;constructor(e){this.data=[],this.config=e}setParams(e){this.params=e}static create(e){let t=new o(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:g.version,userAgent:typeof navigator<"u"?navigator.userAgent:void 0,events:e};h(this.params.endpoint+`?api-key=${this.config.api_key}`,JSON.stringify(t))?.catch(r=>console.log(r))}start(){let e=setInterval(this.flush.bind(this),this.config.flushInterval);e.unref!=null&&e.unref()}};var u=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(){h(this.params.endpoint)?.catch(e=>console.log(e))}};var C=class{id=b();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=p.create(t)}if(e.cache!==!1){let t={};this.cache=new d(t)}this.init()}async search(e,t){await this.initPromise;let r="search-"+JSON.stringify(e),s,i,a=!1;if((t?.fresh!==!0&&this.cache?.has(r))===!0&&this.cache!=null)s=0,i=this.cache.get(r),a=!0;else{let c=Date.now();i=await this.fetch("search","POST",{q:e},t?.abortController);let l=Date.now();i.elapsed=await v(BigInt(l*1e6-c*1e6)),s=l-c,this.cache?.set(r,i)}return this.collector!=null&&this.collector.add({rawSearchString:e.term,resultsCount:i.hits.length,roundTripTime:s,query:e,cached:a,searchedAt:new Date}),i}async vectorSearch(e,t){await this.initPromise;let r="vectorSearch-"+JSON.stringify(e),s,i,a=!1;if((t?.fresh!==!0&&this.cache?.has(r))===!0&&this.cache!=null)s=0,i=this.cache.get(r),a=!0;else{let c=Date.now();i=await this.fetch("vector-search2","POST",{q:e},t?.abortController);let l=Date.now();i.elapsed=await v(BigInt(l*1e6-c*1e6)),s=l-c,this.cache?.set(r,i)}return this.collector!=null&&this.collector.add({rawSearchString:e.term,resultsCount:i.hits.length,roundTripTime:s,query:e,cached:a,searchedAt:new Date}),i}startHeartBeat(e){this.heartbeat?.stop(),this.heartbeat=new u({...e,endpoint:this.endpoint+`/health?api-key=${this.api_key}`}),this.heartbeat.start()}stopHeartBeat(){this.heartbeat?.stop()}async getPop(){return(await this.initPromise)?.pop??""}init(){this.initPromise=this.fetch("init","GET").then(e=>(this.collector?.setParams({endpoint:e.collectUrl,deploymentID:e.deploymentID,index:e.index}),e)).catch(e=>(console.log(e),null))}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 n=r;n.version=y,n.id=this.id,i.body=Object.entries(n).map(([c,l])=>`${c}=${encodeURIComponent(JSON.stringify(l))}`).join("&")}let a=await fetch(`${this.endpoint}/${e}?api-key=${this.api_key}`,i);if(!a.ok){let n=new Error;throw n.httpResponse=a,n}return await a.json()}};export{C as OramaClient};
//# sourceMappingURL=index.js.map

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

import { SearchParams, Nullable, Results } from '@orama/orama';
import { SearchParams, AnyOrama, Nullable, Results, AnyDocument } from '@orama/orama';
import React from 'react';

@@ -6,3 +6,3 @@

ready: boolean;
results: Nullable<Results>;
results: Nullable<Results<AnyDocument>>;
error: Nullable<Error>;

@@ -15,4 +15,4 @@ }

}) => JSX.Element;
declare function useSearch(query: SearchParams): UseSearch;
declare function useSearch(query: SearchParams<AnyOrama>): UseSearch;
export { OramaCloud, useSearch };

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

import T,{useState as f,useEffect as g,createContext as R,useContext as E}from"react";import{formatElapsedTime as I}from"@orama/orama/components";import{createId as O}from"@paralleldrive/cuid2";var p=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 C="1.0.0-beta.20";var v={name:"@oramacloud/client",version:C,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",runkitExampleFilename:"./example/runkit.js",exports:{".":{require:"./dist/index.cjs",import:"./dist/index.js",types:"./dist/index.d.ts",browser:"./dist/index.global.js"},"./react":{require:"./dist/react/index.cjs",import:"./dist/react/index.js",types:"./dist/react/index.d.ts"},"./vue":{require:"./dist/vue/index.cjs",import:"./dist/vue/index.js",types:"./dist/vue/index.d.ts"}},scripts:{lint:"ts-standard --fix",build:"npm run build:lib && npm run build:react","build:lib":"tsup --config tsup.lib.js","build:react":"tsup --config tsup.react.js","build:vue":"tsup --config tsup.vue.js",test:"tsx tests/index.test.ts","serve:example":"esbuild src/index.ts --bundle --outfile=example/out.js --format=esm --watch --servedir=example",prepare:"husky install"},keywords:["orama","search engine","sdk"],files:["dist","example/runkit.js"],author:{name:"Michele Riva",email:"michele.riva@oramasearch.com",url:"https://github.com/MicheleRiva"},license:"ISC",dependencies:{"@orama/orama":"^1.0.10","@paralleldrive/cuid2":"^2.2.1",react:"^18.2.0",vue:"^3.3.4"},devDependencies:{"@fastify/formbody":"^7.4.0","@types/node":"^20.3.1","@types/react":"^18.2.14",esbuild:"0.18.5",fastify:"^4.19.2",husky:"^8.0.3","ts-standard":"^12.0.2",tsup:"^7.1.0",tsx:"^3.12.7",typescript:"^5.1.3"},"ts-standard":{ignore:["dist","node_modules"]}};function d(i,e){if(typeof navigator<"u"){navigator.sendBeacon(i,e);return}fetch(i,{method:"POST",body:e,headers:{"Content-Type":"application/json"}}).then(()=>{},t=>console.log(t))}var u=class i{data;params;config;constructor(e){this.data=[],this.config=e}setParams(e){this.params=e}static create(e){let t=new i(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:v.version,userAgent:typeof navigator<"u"?navigator.userAgent:void 0,events:e};d(this.params.endpoint+`?api-key=${this.config.api_key}`,JSON.stringify(t))}start(){let e=setInterval(this.flush.bind(this),this.config.flushInterval);e.unref!=null&&e.unref()}};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(){d(this.params.endpoint)}};var m=class{id=O();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=u.create(t)}if(e.cache!==!1){let t={};this.cache=new p(t)}this.init()}async search(e,t){await this.initPromise;let s=JSON.stringify(e),a,r,c=!1;if((t?.fresh!==!0&&this.cache?.has(s))===!0&&this.cache!=null)a=0,r=this.cache.get(s),c=!0;else{let o=Date.now();r=await this.fetch("search","POST",{q:e},t?.abortController);let l=Date.now();r.elapsed=await I(BigInt(l*1e6-o*1e6)),a=l-o,this.cache?.set(s,r)}return this.collector!=null&&this.collector.add({rawSearchString:e.term,resultsCount:r.hits.length,roundTripTime:a,query:e,cached:c,searchedAt:new Date}),r}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()}getPop(){return this.initPromise.then(e=>e==null?"":e.pop)}init(){this.initPromise=this.fetch("init","GET").then(e=>(this.collector?.setParams({endpoint:e.collectUrl,deploymentID:e.deploymentID,index:e.index}),e)).catch(e=>console.log(e))}async fetch(e,t,s,a){if(a?.signal.aborted===!0)throw new Error("Request aborted");let r={method:t,headers:{"Content-Type":"application/x-www-form-urlencoded"},signal:a?.signal};if(t==="POST"&&s!==void 0){let n=s;n.version=C,n.id=this.id,r.body=Object.entries(n).map(([o,l])=>`${o}=${encodeURIComponent(JSON.stringify(l))}`).join("&")}return await(await fetch(`${this.endpoint}/${e}?api-key=${this.api_key}`,r)).json()}};var b=R({endpoint:"",apiKey:""}),J=({children:i,endpoint:e,apiKey:t})=>T.createElement(b.Provider,{value:{endpoint:e,apiKey:t}},i);function Y(i){let{apiKey:e,endpoint:t}=E(b),[s,a]=f(!1),[r,c]=f(null),[n,o]=f(null),[l,x]=f(null);return g(()=>{c(new m({api_key:e,endpoint:t})),a(!0)},[]),g(()=>{r!==null&&r.search(i).then(o).catch(x)},[r,i]),{ready:s,results:n,error:l}}export{J as OramaCloud,Y as useSearch};
import R,{useState as f,useEffect as S,createContext as E,useContext as I}from"react";import{formatElapsedTime as b}from"@orama/orama/components";import{createId as w}from"@paralleldrive/cuid2";var u=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 g="1.0.0-beta.21";var v={name:"@oramacloud/client",version:g,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",runkitExampleFilename:"./example/runkit.js",exports:{".":{require:"./dist/index.cjs",import:"./dist/index.js",types:"./dist/index.d.ts",browser:"./dist/index.global.js"},"./react":{require:"./dist/react/index.cjs",import:"./dist/react/index.js",types:"./dist/react/index.d.ts"},"./vue":{require:"./dist/vue/index.cjs",import:"./dist/vue/index.js",types:"./dist/vue/index.d.ts"}},scripts:{lint:"ts-standard --fix",build:"npm run build:lib && npm run build:react","build:lib":"tsup --config tsup.lib.js","build:react":"tsup --config tsup.react.js","build:vue":"tsup --config tsup.vue.js",test:"tsx tests/index.test.ts","serve:example":"esbuild src/index.ts --bundle --outfile=example/out.js --format=esm --watch --servedir=example",prepare:"husky install"},keywords:["orama","search engine","sdk"],files:["dist","example/runkit.js"],author:{name:"Michele Riva",email:"michele.riva@oramasearch.com",url:"https://github.com/MicheleRiva"},license:"ISC",dependencies:{"@orama/orama":"^2.0.0-beta.9","@paralleldrive/cuid2":"^2.2.1",react:"^18.2.0",vue:"^3.3.4"},devDependencies:{"@fastify/formbody":"^7.4.0","@types/node":"^20.3.1","@types/react":"^18.2.14",esbuild:"0.18.5",fastify:"^4.19.2",husky:"^8.0.3","ts-standard":"^12.0.2",tsup:"^7.1.0",tsx:"^3.12.7",typescript:"^5.1.3"},"ts-standard":{ignore:["dist","node_modules"]}};function h(s,e){if(typeof navigator<"u"){navigator.sendBeacon(s,e);return}fetch(s,{method:"POST",body:e,headers:{"Content-Type":"application/json"}}).then(()=>{},t=>console.log(t))}var d=class s{data;params;config;constructor(e){this.data=[],this.config=e}setParams(e){this.params=e}static create(e){let t=new s(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:v.version,userAgent:typeof navigator<"u"?navigator.userAgent:void 0,events:e};h(this.params.endpoint+`?api-key=${this.config.api_key}`,JSON.stringify(t))?.catch(i=>console.log(i))}start(){let e=setInterval(this.flush.bind(this),this.config.flushInterval);e.unref!=null&&e.unref()}};var p=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(){h(this.params.endpoint)?.catch(e=>console.log(e))}};var m=class{id=w();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=d.create(t)}if(e.cache!==!1){let t={};this.cache=new u(t)}this.init()}async search(e,t){await this.initPromise;let i="search-"+JSON.stringify(e),a,r,n=!1;if((t?.fresh!==!0&&this.cache?.has(i))===!0&&this.cache!=null)a=0,r=this.cache.get(i),n=!0;else{let c=Date.now();r=await this.fetch("search","POST",{q:e},t?.abortController);let l=Date.now();r.elapsed=await b(BigInt(l*1e6-c*1e6)),a=l-c,this.cache?.set(i,r)}return this.collector!=null&&this.collector.add({rawSearchString:e.term,resultsCount:r.hits.length,roundTripTime:a,query:e,cached:n,searchedAt:new Date}),r}async vectorSearch(e,t){await this.initPromise;let i="vectorSearch-"+JSON.stringify(e),a,r,n=!1;if((t?.fresh!==!0&&this.cache?.has(i))===!0&&this.cache!=null)a=0,r=this.cache.get(i),n=!0;else{let c=Date.now();r=await this.fetch("vector-search2","POST",{q:e},t?.abortController);let l=Date.now();r.elapsed=await b(BigInt(l*1e6-c*1e6)),a=l-c,this.cache?.set(i,r)}return this.collector!=null&&this.collector.add({rawSearchString:e.term,resultsCount:r.hits.length,roundTripTime:a,query:e,cached:n,searchedAt:new Date}),r}startHeartBeat(e){this.heartbeat?.stop(),this.heartbeat=new p({...e,endpoint:this.endpoint+`/health?api-key=${this.api_key}`}),this.heartbeat.start()}stopHeartBeat(){this.heartbeat?.stop()}async getPop(){return(await this.initPromise)?.pop??""}init(){this.initPromise=this.fetch("init","GET").then(e=>(this.collector?.setParams({endpoint:e.collectUrl,deploymentID:e.deploymentID,index:e.index}),e)).catch(e=>(console.log(e),null))}async fetch(e,t,i,a){if(a?.signal.aborted===!0)throw new Error("Request aborted");let r={method:t,headers:{"Content-Type":"application/x-www-form-urlencoded"},signal:a?.signal};if(t==="POST"&&i!==void 0){let o=i;o.version=g,o.id=this.id,r.body=Object.entries(o).map(([c,l])=>`${c}=${encodeURIComponent(JSON.stringify(l))}`).join("&")}let n=await fetch(`${this.endpoint}/${e}?api-key=${this.api_key}`,r);if(!n.ok){let o=new Error;throw o.httpResponse=n,o}return await n.json()}};var x=E({endpoint:"",apiKey:""}),q=({children:s,endpoint:e,apiKey:t})=>R.createElement(x.Provider,{value:{endpoint:e,apiKey:t}},s);function Y(s){let{apiKey:e,endpoint:t}=I(x),[i,a]=f(!1),[r,n]=f(null),[o,c]=f(null),[l,O]=f(null);return S(()=>{n(new m({api_key:e,endpoint:t})),a(!0)},[]),S(()=>{r!==null&&r.search(s).then(c).catch(O)},[r,s]),{ready:i,results:o,error:l}}export{q as OramaCloud,Y as useSearch};
//# sourceMappingURL=index.js.map

@@ -9,5 +9,5 @@ const { OramaClient } = require('@oramacloud/client')

const results = await client.search({
term: 'red leather shoes',
term: 'red leather shoes'
})
console.log(results)
{
"name": "@oramacloud/client",
"version": "1.0.0-beta.21",
"version": "1.0.0-beta.22",
"description": "Orama SDK for Node.js, Deno, and Browsers",

@@ -29,12 +29,2 @@ "type": "module",

},
"scripts": {
"lint": "ts-standard --fix",
"build": "npm run build:lib && npm run build:react",
"build:lib": "tsup --config tsup.lib.js",
"build:react": "tsup --config tsup.react.js",
"build:vue": "tsup --config tsup.vue.js",
"test": "tsx tests/index.test.ts",
"serve:example": "esbuild src/index.ts --bundle --outfile=example/out.js --format=esm --watch --servedir=example",
"prepare": "husky install"
},
"keywords": [

@@ -56,3 +46,3 @@ "orama",

"dependencies": {
"@orama/orama": "^1.0.10",
"@orama/orama": "^2.0.0-beta.9",
"@paralleldrive/cuid2": "^2.2.1",

@@ -79,3 +69,12 @@ "react": "^18.2.0",

]
},
"scripts": {
"lint": "ts-standard --fix",
"build": "npm run build:lib && npm run build:react",
"build:lib": "tsup --config tsup.lib.js",
"build:react": "tsup --config tsup.react.js",
"build:vue": "tsup --config tsup.vue.js",
"test": "tsx tests/index.test.ts",
"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

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