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.8 to 1.0.0-beta.9

./dist/index.cjs

2

dist/index.js

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

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

@@ -43,3 +44,3 @@ "keywords": [

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

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

Sorry, the diff of this file is not supported yet

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