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.2 to 1.0.0-beta.3

2

./dist/index.cjs.js

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

"use strict";var K=Object.create;var p=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var J=Object.getOwnPropertyNames;var Z=Object.getPrototypeOf,W=Object.prototype.hasOwnProperty;var d=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Q=(t,e)=>{for(var n in e)p(t,n,{get:e[n],enumerable:!0})},T=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of J(e))!W.call(t,r)&&r!==n&&p(t,r,{get:()=>e[r],enumerable:!(i=G(e,r))||i.enumerable});return t};var X=(t,e,n)=>(n=t!=null?K(Z(t)):{},T(e||!t||!t.__esModule?p(n,"default",{value:t,enumerable:!0}):n,t)),ee=t=>T(p({},"__esModule",{value:!0}),t);var v=d((ye,A)=>{A.exports=function(e,n){var i="000000000"+e;return i.substr(i.length-n)}});var B=d((be,j)=>{var te=v(),ne=typeof window=="object"?window:self,re=Object.keys(ne).length,ie=navigator.mimeTypes?navigator.mimeTypes.length:0,oe=te((ie+navigator.userAgent.length).toString(36)+re.toString(36),4);j.exports=function(){return oe}});var k=d((ve,N)=>{var S,D=typeof window<"u"&&(window.crypto||window.msCrypto)||typeof self<"u"&&self.crypto;D?(M=Math.pow(2,32)-1,S=function(){return Math.abs(D.getRandomValues(new Uint32Array(1))[0]/M)}):S=Math.random;var M;N.exports=S});var H=d((Se,U)=>{var f=B(),L=v(),se=k(),s=0,x=4,h=36,P=Math.pow(h,x);function C(){return L((se()*P<<0).toString(h),x)}function $(){return s=s<P?s:0,s++,s-1}function a(){var t="c",e=new Date().getTime().toString(h),n=L($().toString(h),x),i=f(),r=C()+C();return t+e+n+i+r}a.slug=function(){var e=new Date().getTime().toString(36),n=$().toString(36).slice(-4),i=f().slice(0,1)+f().slice(-1),r=C().slice(-2);return e.slice(-2)+n+i+r};a.isCuid=function(e){return typeof e!="string"?!1:!!e.startsWith("c")};a.isSlug=function(e){if(typeof e!="string")return!1;var n=e.length;return n>=7&&n<=10};a.fingerprint=f;U.exports=a});var ue={};Q(ue,{OramaClient:()=>w});module.exports=ee(ue);var de=Date.now().toString().slice(5);var E=BigInt(1e3),I=BigInt(1e6),_=BigInt(1e9);async function O(t){return typeof t=="number"&&(t=BigInt(t)),t<E?`${t}ns`:t<I?`${t/E}\u03BCs`:t<_?`${t/I}ms`:`${t/_}s`}async function R(t){return{raw:Number(t),formatted:await O(t)}}var z=X(H(),1);var m=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 V="1.0.0-beta.2";var q={name:"@oramacloud/client",version:V,description:"Orama SDK for Node.js, Deno, and Browsers",type:"module",main:"./dist/index.cjs.js",types:"./dist/src/index.d.ts",exports:{".":{default:"./dist/index.cjs.js",import:"./dist/index.esm.js",node:"./dist/index.cjs.js",require:"./dist/index.cjs.js",types:"./dist/src/index.d.ts"}},scripts:{lint:"ts-standard --fix",build:'rm -rf ./dist && concurrently "npm run build:esm" "npm run build:cjs" "npm run build:ts"',"build:esm":"esbuild ./src/index.ts --bundle --minify --format=esm --outfile=./dist/index.esm.js","build:cjs":"esbuild ./src/index.ts --bundle --minify --format=cjs --outfile=./dist/index.cjs.js","build:ts":"tsc -p . --emitDeclarationOnly",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.6",cuid:"^3.0.0"},devDependencies:{"@types/node":"^20.3.1",concurrently:"^8.2.0",esbuild:"0.18.5","ts-standard":"^12.0.2",typescript:"^5.1.3"}};var g=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:q.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 y=class{constructor(e){this.params=e}intervalId;start(){this.stop(),this.intervalId=setInterval(this.beat.bind(this),this.params.frequency)}stop(){this.intervalId&&clearInterval(this.intervalId)}beat(){navigator.sendBeacon?.(this.params.endpoint)}};var w=class{id=(0,z.default)();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=g.create(n)}if(e.cache!==!1){let n={};this.cache=new m(n)}this.init()}async search(e,n){await this.initPromise;let i=JSON.stringify(e),r,o,b=!1;if(n?.fresh!==!0&&this.cache?.has(i))r=0,o=this.cache.get(i),b=!0;else{let l=Date.now();o=await this.fetch("search","POST",{q:e},n?.abortController);let u=Date.now();o.elapsed=await R(BigInt(u*1e6-l*1e6)),r=u-l,this.cache?.set(i,o)}return this.collector!=null&&this.collector.add({rawSearchString:e.term,resultsCount:o.hits.length,roundTripTime:r,query:e,cached:b,searchedAt:new Date}),o}startHeartBeat(e){this.heartbeat?.stop(),this.heartbeat=new y({...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,i,r){if(r!=null&&r.signal.aborted)throw new Error("Request aborted");let o={method:n,headers:{"Content-Type":"application/x-www-form-urlencoded"},signal:r?.signal};if(n==="POST"&&i!==void 0){let c=i;c.version=V,c.id=this.id,o.body=Object.entries(c).map(([l,u])=>`${l}=${encodeURIComponent(JSON.stringify(u))}`).join("&")}return await(await fetch(`${this.endpoint}/${e}?api-key=${this.api_key}`,o)).json()}};
"use strict";var K=Object.create;var p=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var J=Object.getOwnPropertyNames;var Z=Object.getPrototypeOf,W=Object.prototype.hasOwnProperty;var d=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Q=(t,e)=>{for(var n in e)p(t,n,{get:e[n],enumerable:!0})},T=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of J(e))!W.call(t,r)&&r!==n&&p(t,r,{get:()=>e[r],enumerable:!(i=G(e,r))||i.enumerable});return t};var X=(t,e,n)=>(n=t!=null?K(Z(t)):{},T(e||!t||!t.__esModule?p(n,"default",{value:t,enumerable:!0}):n,t)),ee=t=>T(p({},"__esModule",{value:!0}),t);var S=d((ye,A)=>{A.exports=function(e,n){var i="000000000"+e;return i.substr(i.length-n)}});var B=d((be,j)=>{var te=S(),ne=typeof window=="object"?window:self,re=Object.keys(ne).length,ie=navigator.mimeTypes?navigator.mimeTypes.length:0,oe=te((ie+navigator.userAgent.length).toString(36)+re.toString(36),4);j.exports=function(){return oe}});var k=d((ve,N)=>{var C,D=typeof window<"u"&&(window.crypto||window.msCrypto)||typeof self<"u"&&self.crypto;D?(M=Math.pow(2,32)-1,C=function(){return Math.abs(D.getRandomValues(new Uint32Array(1))[0]/M)}):C=Math.random;var M;N.exports=C});var H=d((Se,U)=>{var f=B(),L=S(),se=k(),s=0,w=4,h=36,P=Math.pow(h,w);function x(){return L((se()*P<<0).toString(h),w)}function $(){return s=s<P?s:0,s++,s-1}function a(){var t="c",e=new Date().getTime().toString(h),n=L($().toString(h),w),i=f(),r=x()+x();return t+e+n+i+r}a.slug=function(){var e=new Date().getTime().toString(36),n=$().toString(36).slice(-4),i=f().slice(0,1)+f().slice(-1),r=x().slice(-2);return e.slice(-2)+n+i+r};a.isCuid=function(e){return typeof e!="string"?!1:!!e.startsWith("c")};a.isSlug=function(e){if(typeof e!="string")return!1;var n=e.length;return n>=7&&n<=10};a.fingerprint=f;U.exports=a});var ue={};Q(ue,{default:()=>b});module.exports=ee(ue);var de=Date.now().toString().slice(5);var E=BigInt(1e3),I=BigInt(1e6),_=BigInt(1e9);async function O(t){return typeof t=="number"&&(t=BigInt(t)),t<E?`${t}ns`:t<I?`${t/E}\u03BCs`:t<_?`${t/I}ms`:`${t/_}s`}async function R(t){return{raw:Number(t),formatted:await O(t)}}var z=X(H(),1);var m=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 V="1.0.0-beta.2";var q={name:"@oramacloud/client",version:V,description:"Orama SDK for Node.js, Deno, and Browsers",type:"module",main:"./dist/index.cjs.js",types:"./dist/src/index.d.ts",exports:{".":{default:"./dist/index.cjs.js",import:"./dist/index.esm.js",node:"./dist/index.cjs.js",require:"./dist/index.cjs.js",types:"./dist/src/index.d.ts"}},scripts:{lint:"ts-standard --fix",build:'rm -rf ./dist && concurrently "npm run build:esm" "npm run build:cjs" "npm run build:ts"',"build:esm":"esbuild ./src/index.ts --bundle --minify --format=esm --outfile=./dist/index.esm.js","build:cjs":"esbuild ./src/index.ts --bundle --minify --format=cjs --outfile=./dist/index.cjs.js","build:ts":"tsc -p . --emitDeclarationOnly",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.6",cuid:"^3.0.0"},devDependencies:{"@types/node":"^20.3.1",concurrently:"^8.2.0",esbuild:"0.18.5","ts-standard":"^12.0.2",typescript:"^5.1.3"}};var g=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:q.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 y=class{constructor(e){this.params=e}intervalId;start(){this.stop(),this.intervalId=setInterval(this.beat.bind(this),this.params.frequency)}stop(){this.intervalId&&clearInterval(this.intervalId)}beat(){navigator.sendBeacon?.(this.params.endpoint)}};var b=class{id=(0,z.default)();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=g.create(n)}if(e.cache!==!1){let n={};this.cache=new m(n)}this.init()}async search(e,n){await this.initPromise;let i=JSON.stringify(e),r,o,v=!1;if(n?.fresh!==!0&&this.cache?.has(i))r=0,o=this.cache.get(i),v=!0;else{let l=Date.now();o=await this.fetch("search","POST",{q:e},n?.abortController);let u=Date.now();o.elapsed=await R(BigInt(u*1e6-l*1e6)),r=u-l,this.cache?.set(i,o)}return this.collector!=null&&this.collector.add({rawSearchString:e.term,resultsCount:o.hits.length,roundTripTime:r,query:e,cached:v,searchedAt:new Date}),o}startHeartBeat(e){this.heartbeat?.stop(),this.heartbeat=new y({...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,i,r){if(r!=null&&r.signal.aborted)throw new Error("Request aborted");let o={method:n,headers:{"Content-Type":"application/x-www-form-urlencoded"},signal:r?.signal};if(n==="POST"&&i!==void 0){let c=i;c.version=V,c.id=this.id,o.body=Object.entries(c).map(([l,u])=>`${l}=${encodeURIComponent(JSON.stringify(u))}`).join("&")}return await(await fetch(`${this.endpoint}/${e}?api-key=${this.api_key}`,o)).json()}};

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

"use strict";var K=Object.create;var p=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var J=Object.getOwnPropertyNames;var Z=Object.getPrototypeOf,W=Object.prototype.hasOwnProperty;var d=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Q=(t,e)=>{for(var n in e)p(t,n,{get:e[n],enumerable:!0})},T=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of J(e))!W.call(t,r)&&r!==n&&p(t,r,{get:()=>e[r],enumerable:!(i=G(e,r))||i.enumerable});return t};var X=(t,e,n)=>(n=t!=null?K(Z(t)):{},T(e||!t||!t.__esModule?p(n,"default",{value:t,enumerable:!0}):n,t)),ee=t=>T(p({},"__esModule",{value:!0}),t);var v=d((ye,A)=>{A.exports=function(e,n){var i="000000000"+e;return i.substr(i.length-n)}});var B=d((be,j)=>{var te=v(),ne=typeof window=="object"?window:self,re=Object.keys(ne).length,ie=navigator.mimeTypes?navigator.mimeTypes.length:0,oe=te((ie+navigator.userAgent.length).toString(36)+re.toString(36),4);j.exports=function(){return oe}});var k=d((ve,N)=>{var S,D=typeof window<"u"&&(window.crypto||window.msCrypto)||typeof self<"u"&&self.crypto;D?(M=Math.pow(2,32)-1,S=function(){return Math.abs(D.getRandomValues(new Uint32Array(1))[0]/M)}):S=Math.random;var M;N.exports=S});var H=d((Se,U)=>{var f=B(),L=v(),se=k(),s=0,x=4,h=36,P=Math.pow(h,x);function C(){return L((se()*P<<0).toString(h),x)}function $(){return s=s<P?s:0,s++,s-1}function a(){var t="c",e=new Date().getTime().toString(h),n=L($().toString(h),x),i=f(),r=C()+C();return t+e+n+i+r}a.slug=function(){var e=new Date().getTime().toString(36),n=$().toString(36).slice(-4),i=f().slice(0,1)+f().slice(-1),r=C().slice(-2);return e.slice(-2)+n+i+r};a.isCuid=function(e){return typeof e!="string"?!1:!!e.startsWith("c")};a.isSlug=function(e){if(typeof e!="string")return!1;var n=e.length;return n>=7&&n<=10};a.fingerprint=f;U.exports=a});var ue={};Q(ue,{OramaClient:()=>w});module.exports=ee(ue);var de=Date.now().toString().slice(5);var E=BigInt(1e3),I=BigInt(1e6),_=BigInt(1e9);async function O(t){return typeof t=="number"&&(t=BigInt(t)),t<E?`${t}ns`:t<I?`${t/E}\u03BCs`:t<_?`${t/I}ms`:`${t/_}s`}async function R(t){return{raw:Number(t),formatted:await O(t)}}var z=X(H(),1);var m=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 V="1.0.0-beta.2";var q={name:"@oramacloud/client",version:V,description:"Orama SDK for Node.js, Deno, and Browsers",type:"module",main:"./dist/index.cjs.js",types:"./dist/src/index.d.ts",exports:{".":{default:"./dist/index.cjs.js",import:"./dist/index.esm.js",node:"./dist/index.cjs.js",require:"./dist/index.cjs.js",types:"./dist/src/index.d.ts"}},scripts:{lint:"ts-standard --fix",build:'rm -rf ./dist && concurrently "npm run build:esm" "npm run build:cjs" "npm run build:ts"',"build:esm":"esbuild ./src/index.ts --bundle --minify --format=esm --outfile=./dist/index.esm.js","build:cjs":"esbuild ./src/index.ts --bundle --minify --format=cjs --outfile=./dist/index.cjs.js","build:ts":"tsc -p . --emitDeclarationOnly",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.6",cuid:"^3.0.0"},devDependencies:{"@types/node":"^20.3.1",concurrently:"^8.2.0",esbuild:"0.18.5","ts-standard":"^12.0.2",typescript:"^5.1.3"}};var g=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:q.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 y=class{constructor(e){this.params=e}intervalId;start(){this.stop(),this.intervalId=setInterval(this.beat.bind(this),this.params.frequency)}stop(){this.intervalId&&clearInterval(this.intervalId)}beat(){navigator.sendBeacon?.(this.params.endpoint)}};var w=class{id=(0,z.default)();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=g.create(n)}if(e.cache!==!1){let n={};this.cache=new m(n)}this.init()}async search(e,n){await this.initPromise;let i=JSON.stringify(e),r,o,b=!1;if(n?.fresh!==!0&&this.cache?.has(i))r=0,o=this.cache.get(i),b=!0;else{let l=Date.now();o=await this.fetch("search","POST",{q:e},n?.abortController);let u=Date.now();o.elapsed=await R(BigInt(u*1e6-l*1e6)),r=u-l,this.cache?.set(i,o)}return this.collector!=null&&this.collector.add({rawSearchString:e.term,resultsCount:o.hits.length,roundTripTime:r,query:e,cached:b,searchedAt:new Date}),o}startHeartBeat(e){this.heartbeat?.stop(),this.heartbeat=new y({...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,i,r){if(r!=null&&r.signal.aborted)throw new Error("Request aborted");let o={method:n,headers:{"Content-Type":"application/x-www-form-urlencoded"},signal:r?.signal};if(n==="POST"&&i!==void 0){let c=i;c.version=V,c.id=this.id,o.body=Object.entries(c).map(([l,u])=>`${l}=${encodeURIComponent(JSON.stringify(u))}`).join("&")}return await(await fetch(`${this.endpoint}/${e}?api-key=${this.api_key}`,o)).json()}};
"use strict";var K=Object.create;var p=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var J=Object.getOwnPropertyNames;var Z=Object.getPrototypeOf,W=Object.prototype.hasOwnProperty;var d=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Q=(t,e)=>{for(var n in e)p(t,n,{get:e[n],enumerable:!0})},T=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of J(e))!W.call(t,r)&&r!==n&&p(t,r,{get:()=>e[r],enumerable:!(i=G(e,r))||i.enumerable});return t};var X=(t,e,n)=>(n=t!=null?K(Z(t)):{},T(e||!t||!t.__esModule?p(n,"default",{value:t,enumerable:!0}):n,t)),ee=t=>T(p({},"__esModule",{value:!0}),t);var S=d((ye,A)=>{A.exports=function(e,n){var i="000000000"+e;return i.substr(i.length-n)}});var B=d((be,j)=>{var te=S(),ne=typeof window=="object"?window:self,re=Object.keys(ne).length,ie=navigator.mimeTypes?navigator.mimeTypes.length:0,oe=te((ie+navigator.userAgent.length).toString(36)+re.toString(36),4);j.exports=function(){return oe}});var k=d((ve,N)=>{var C,D=typeof window<"u"&&(window.crypto||window.msCrypto)||typeof self<"u"&&self.crypto;D?(M=Math.pow(2,32)-1,C=function(){return Math.abs(D.getRandomValues(new Uint32Array(1))[0]/M)}):C=Math.random;var M;N.exports=C});var H=d((Se,U)=>{var f=B(),L=S(),se=k(),s=0,w=4,h=36,P=Math.pow(h,w);function x(){return L((se()*P<<0).toString(h),w)}function $(){return s=s<P?s:0,s++,s-1}function a(){var t="c",e=new Date().getTime().toString(h),n=L($().toString(h),w),i=f(),r=x()+x();return t+e+n+i+r}a.slug=function(){var e=new Date().getTime().toString(36),n=$().toString(36).slice(-4),i=f().slice(0,1)+f().slice(-1),r=x().slice(-2);return e.slice(-2)+n+i+r};a.isCuid=function(e){return typeof e!="string"?!1:!!e.startsWith("c")};a.isSlug=function(e){if(typeof e!="string")return!1;var n=e.length;return n>=7&&n<=10};a.fingerprint=f;U.exports=a});var ue={};Q(ue,{default:()=>b});module.exports=ee(ue);var de=Date.now().toString().slice(5);var E=BigInt(1e3),I=BigInt(1e6),_=BigInt(1e9);async function O(t){return typeof t=="number"&&(t=BigInt(t)),t<E?`${t}ns`:t<I?`${t/E}\u03BCs`:t<_?`${t/I}ms`:`${t/_}s`}async function R(t){return{raw:Number(t),formatted:await O(t)}}var z=X(H(),1);var m=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 V="1.0.0-beta.2";var q={name:"@oramacloud/client",version:V,description:"Orama SDK for Node.js, Deno, and Browsers",type:"module",main:"./dist/index.cjs.js",types:"./dist/src/index.d.ts",exports:{".":{default:"./dist/index.cjs.js",import:"./dist/index.esm.js",node:"./dist/index.cjs.js",require:"./dist/index.cjs.js",types:"./dist/src/index.d.ts"}},scripts:{lint:"ts-standard --fix",build:'rm -rf ./dist && concurrently "npm run build:esm" "npm run build:cjs" "npm run build:ts"',"build:esm":"esbuild ./src/index.ts --bundle --minify --format=esm --outfile=./dist/index.esm.js","build:cjs":"esbuild ./src/index.ts --bundle --minify --format=cjs --outfile=./dist/index.cjs.js","build:ts":"tsc -p . --emitDeclarationOnly",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.6",cuid:"^3.0.0"},devDependencies:{"@types/node":"^20.3.1",concurrently:"^8.2.0",esbuild:"0.18.5","ts-standard":"^12.0.2",typescript:"^5.1.3"}};var g=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:q.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 y=class{constructor(e){this.params=e}intervalId;start(){this.stop(),this.intervalId=setInterval(this.beat.bind(this),this.params.frequency)}stop(){this.intervalId&&clearInterval(this.intervalId)}beat(){navigator.sendBeacon?.(this.params.endpoint)}};var b=class{id=(0,z.default)();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=g.create(n)}if(e.cache!==!1){let n={};this.cache=new m(n)}this.init()}async search(e,n){await this.initPromise;let i=JSON.stringify(e),r,o,v=!1;if(n?.fresh!==!0&&this.cache?.has(i))r=0,o=this.cache.get(i),v=!0;else{let l=Date.now();o=await this.fetch("search","POST",{q:e},n?.abortController);let u=Date.now();o.elapsed=await R(BigInt(u*1e6-l*1e6)),r=u-l,this.cache?.set(i,o)}return this.collector!=null&&this.collector.add({rawSearchString:e.term,resultsCount:o.hits.length,roundTripTime:r,query:e,cached:v,searchedAt:new Date}),o}startHeartBeat(e){this.heartbeat?.stop(),this.heartbeat=new y({...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,i,r){if(r!=null&&r.signal.aborted)throw new Error("Request aborted");let o={method:n,headers:{"Content-Type":"application/x-www-form-urlencoded"},signal:r?.signal};if(n==="POST"&&i!==void 0){let c=i;c.version=V,c.id=this.id,o.body=Object.entries(c).map(([l,u])=>`${l}=${encodeURIComponent(JSON.stringify(u))}`).join("&")}return await(await fetch(`${this.endpoint}/${e}?api-key=${this.api_key}`,o)).json()}};

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

var z=Object.create;var x=Object.defineProperty;var K=Object.getOwnPropertyDescriptor;var G=Object.getOwnPropertyNames;var J=Object.getPrototypeOf,Z=Object.prototype.hasOwnProperty;var p=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var W=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of G(e))!Z.call(t,r)&&r!==n&&x(t,r,{get:()=>e[r],enumerable:!(i=K(e,r))||i.enumerable});return t};var Q=(t,e,n)=>(n=t!=null?z(J(t)):{},W(e||!t||!t.__esModule?x(n,"default",{value:t,enumerable:!0}):n,t));var b=p((he,O)=>{O.exports=function(e,n){var i="000000000"+e;return i.substr(i.length-n)}});var A=p((me,R)=>{var X=b(),ee=typeof window=="object"?window:self,te=Object.keys(ee).length,ne=navigator.mimeTypes?navigator.mimeTypes.length:0,re=X((ne+navigator.userAgent.length).toString(36)+te.toString(36),4);R.exports=function(){return re}});var M=p((ge,D)=>{var v,j=typeof window<"u"&&(window.crypto||window.msCrypto)||typeof self<"u"&&self.crypto;j?(B=Math.pow(2,32)-1,v=function(){return Math.abs(j.getRandomValues(new Uint32Array(1))[0]/B)}):v=Math.random;var B;D.exports=v});var $=p((ye,P)=>{var d=A(),N=b(),ie=M(),s=0,C=4,f=36,k=Math.pow(f,C);function S(){return N((ie()*k<<0).toString(f),C)}function L(){return s=s<k?s:0,s++,s-1}function a(){var t="c",e=new Date().getTime().toString(f),n=N(L().toString(f),C),i=d(),r=S()+S();return t+e+n+i+r}a.slug=function(){var e=new Date().getTime().toString(36),n=L().toString(36).slice(-4),i=d().slice(0,1)+d().slice(-1),r=S().slice(-2);return e.slice(-2)+n+i+r};a.isCuid=function(e){return typeof e!="string"?!1:!!e.startsWith("c")};a.isSlug=function(e){if(typeof e!="string")return!1;var n=e.length;return n>=7&&n<=10};a.fingerprint=d;P.exports=a});var le=Date.now().toString().slice(5);var w=BigInt(1e3),T=BigInt(1e6),E=BigInt(1e9);async function I(t){return typeof t=="number"&&(t=BigInt(t)),t<w?`${t}ns`:t<T?`${t/w}\u03BCs`:t<E?`${t/T}ms`:`${t/E}s`}async function _(t){return{raw:Number(t),formatted:await I(t)}}var Y=Q($(),1);var h=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 H="1.0.0-beta.2";var F={name:"@oramacloud/client",version:H,description:"Orama SDK for Node.js, Deno, and Browsers",type:"module",main:"./dist/index.cjs.js",types:"./dist/src/index.d.ts",exports:{".":{default:"./dist/index.cjs.js",import:"./dist/index.esm.js",node:"./dist/index.cjs.js",require:"./dist/index.cjs.js",types:"./dist/src/index.d.ts"}},scripts:{lint:"ts-standard --fix",build:'rm -rf ./dist && concurrently "npm run build:esm" "npm run build:cjs" "npm run build:ts"',"build:esm":"esbuild ./src/index.ts --bundle --minify --format=esm --outfile=./dist/index.esm.js","build:cjs":"esbuild ./src/index.ts --bundle --minify --format=cjs --outfile=./dist/index.cjs.js","build:ts":"tsc -p . --emitDeclarationOnly",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.6",cuid:"^3.0.0"},devDependencies:{"@types/node":"^20.3.1",concurrently:"^8.2.0",esbuild:"0.18.5","ts-standard":"^12.0.2",typescript:"^5.1.3"}};var m=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: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(n))}start(){setInterval(this.flush.bind(this),this.config.flushInterval)}};var g=class{constructor(e){this.params=e}intervalId;start(){this.stop(),this.intervalId=setInterval(this.beat.bind(this),this.params.frequency)}stop(){this.intervalId&&clearInterval(this.intervalId)}beat(){navigator.sendBeacon?.(this.params.endpoint)}};var q=class{id=(0,Y.default)();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=m.create(n)}if(e.cache!==!1){let n={};this.cache=new h(n)}this.init()}async search(e,n){await this.initPromise;let i=JSON.stringify(e),r,o,y=!1;if(n?.fresh!==!0&&this.cache?.has(i))r=0,o=this.cache.get(i),y=!0;else{let l=Date.now();o=await this.fetch("search","POST",{q:e},n?.abortController);let u=Date.now();o.elapsed=await _(BigInt(u*1e6-l*1e6)),r=u-l,this.cache?.set(i,o)}return this.collector!=null&&this.collector.add({rawSearchString:e.term,resultsCount:o.hits.length,roundTripTime:r,query:e,cached:y,searchedAt:new Date}),o}startHeartBeat(e){this.heartbeat?.stop(),this.heartbeat=new g({...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,i,r){if(r!=null&&r.signal.aborted)throw new Error("Request aborted");let o={method:n,headers:{"Content-Type":"application/x-www-form-urlencoded"},signal:r?.signal};if(n==="POST"&&i!==void 0){let c=i;c.version=H,c.id=this.id,o.body=Object.entries(c).map(([l,u])=>`${l}=${encodeURIComponent(JSON.stringify(u))}`).join("&")}return await(await fetch(`${this.endpoint}/${e}?api-key=${this.api_key}`,o)).json()}};export{q as OramaClient};
var z=Object.create;var w=Object.defineProperty;var K=Object.getOwnPropertyDescriptor;var G=Object.getOwnPropertyNames;var J=Object.getPrototypeOf,Z=Object.prototype.hasOwnProperty;var p=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var W=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of G(e))!Z.call(t,r)&&r!==n&&w(t,r,{get:()=>e[r],enumerable:!(i=K(e,r))||i.enumerable});return t};var Q=(t,e,n)=>(n=t!=null?z(J(t)):{},W(e||!t||!t.__esModule?w(n,"default",{value:t,enumerable:!0}):n,t));var b=p((he,R)=>{R.exports=function(e,n){var i="000000000"+e;return i.substr(i.length-n)}});var j=p((me,A)=>{var X=b(),ee=typeof window=="object"?window:self,te=Object.keys(ee).length,ne=navigator.mimeTypes?navigator.mimeTypes.length:0,re=X((ne+navigator.userAgent.length).toString(36)+te.toString(36),4);A.exports=function(){return re}});var N=p((ge,M)=>{var v,B=typeof window<"u"&&(window.crypto||window.msCrypto)||typeof self<"u"&&self.crypto;B?(D=Math.pow(2,32)-1,v=function(){return Math.abs(B.getRandomValues(new Uint32Array(1))[0]/D)}):v=Math.random;var D;M.exports=v});var U=p((ye,$)=>{var d=j(),k=b(),ie=N(),s=0,C=4,f=36,L=Math.pow(f,C);function S(){return k((ie()*L<<0).toString(f),C)}function P(){return s=s<L?s:0,s++,s-1}function a(){var t="c",e=new Date().getTime().toString(f),n=k(P().toString(f),C),i=d(),r=S()+S();return t+e+n+i+r}a.slug=function(){var e=new Date().getTime().toString(36),n=P().toString(36).slice(-4),i=d().slice(0,1)+d().slice(-1),r=S().slice(-2);return e.slice(-2)+n+i+r};a.isCuid=function(e){return typeof e!="string"?!1:!!e.startsWith("c")};a.isSlug=function(e){if(typeof e!="string")return!1;var n=e.length;return n>=7&&n<=10};a.fingerprint=d;$.exports=a});var le=Date.now().toString().slice(5);var T=BigInt(1e3),E=BigInt(1e6),I=BigInt(1e9);async function _(t){return typeof t=="number"&&(t=BigInt(t)),t<T?`${t}ns`:t<E?`${t/T}\u03BCs`:t<I?`${t/E}ms`:`${t/I}s`}async function O(t){return{raw:Number(t),formatted:await _(t)}}var Y=Q(U(),1);var h=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 F="1.0.0-beta.2";var V={name:"@oramacloud/client",version:F,description:"Orama SDK for Node.js, Deno, and Browsers",type:"module",main:"./dist/index.cjs.js",types:"./dist/src/index.d.ts",exports:{".":{default:"./dist/index.cjs.js",import:"./dist/index.esm.js",node:"./dist/index.cjs.js",require:"./dist/index.cjs.js",types:"./dist/src/index.d.ts"}},scripts:{lint:"ts-standard --fix",build:'rm -rf ./dist && concurrently "npm run build:esm" "npm run build:cjs" "npm run build:ts"',"build:esm":"esbuild ./src/index.ts --bundle --minify --format=esm --outfile=./dist/index.esm.js","build:cjs":"esbuild ./src/index.ts --bundle --minify --format=cjs --outfile=./dist/index.cjs.js","build:ts":"tsc -p . --emitDeclarationOnly",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.6",cuid:"^3.0.0"},devDependencies:{"@types/node":"^20.3.1",concurrently:"^8.2.0",esbuild:"0.18.5","ts-standard":"^12.0.2",typescript:"^5.1.3"}};var m=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:V.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 g=class{constructor(e){this.params=e}intervalId;start(){this.stop(),this.intervalId=setInterval(this.beat.bind(this),this.params.frequency)}stop(){this.intervalId&&clearInterval(this.intervalId)}beat(){navigator.sendBeacon?.(this.params.endpoint)}};var x=class{id=(0,Y.default)();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=m.create(n)}if(e.cache!==!1){let n={};this.cache=new h(n)}this.init()}async search(e,n){await this.initPromise;let i=JSON.stringify(e),r,o,y=!1;if(n?.fresh!==!0&&this.cache?.has(i))r=0,o=this.cache.get(i),y=!0;else{let l=Date.now();o=await this.fetch("search","POST",{q:e},n?.abortController);let u=Date.now();o.elapsed=await O(BigInt(u*1e6-l*1e6)),r=u-l,this.cache?.set(i,o)}return this.collector!=null&&this.collector.add({rawSearchString:e.term,resultsCount:o.hits.length,roundTripTime:r,query:e,cached:y,searchedAt:new Date}),o}startHeartBeat(e){this.heartbeat?.stop(),this.heartbeat=new g({...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,i,r){if(r!=null&&r.signal.aborted)throw new Error("Request aborted");let o={method:n,headers:{"Content-Type":"application/x-www-form-urlencoded"},signal:r?.signal};if(n==="POST"&&i!==void 0){let c=i;c.version=F,c.id=this.id,o.body=Object.entries(c).map(([l,u])=>`${l}=${encodeURIComponent(JSON.stringify(u))}`).join("&")}return await(await fetch(`${this.endpoint}/${e}?api-key=${this.api_key}`,o)).json()}};export{x as default};
import type { IOramaClient, HeartBeatConfig } from './types.js';
import type { SearchParams, Results } from '@orama/orama';
export declare class OramaClient {
export interface SearchConfig {
abortController?: AbortController;
fresh?: boolean;
}
export default class OramaClient {
private readonly id;

@@ -18,5 +22,1 @@ private readonly api_key;

}
export interface SearchConfig {
abortController?: AbortController;
fresh?: boolean;
}
{
"name": "@oramacloud/client",
"version": "1.0.0-beta.2",
"version": "1.0.0-beta.3",
"description": "Orama SDK for Node.js, Deno, and Browsers",

@@ -5,0 +5,0 @@ "type": "module",

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