@upstash/vector 1.0.6 → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- type CacheSetting = "default" | "force-cache" | "no-cache" | "no-store" | "only-if-cached" | "reload";
1
+ type CacheSetting = "default" | "force-cache" | "no-cache" | "no-store" | "only-if-cached" | "reload" | false;
2
2
  type UpstashRequest = {
3
3
  path?: string[];
4
4
  /**
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- type CacheSetting = "default" | "force-cache" | "no-cache" | "no-store" | "only-if-cached" | "reload";
1
+ type CacheSetting = "default" | "force-cache" | "no-cache" | "no-store" | "only-if-cached" | "reload" | false;
2
2
  type UpstashRequest = {
3
3
  path?: string[];
4
4
  /**
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var x=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var M=Object.prototype.hasOwnProperty;var S=(n,e)=>{for(var t in e)x(n,t,{get:e[t],enumerable:!0})},U=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of E(e))!M.call(n,a)&&a!==t&&x(n,a,{get:()=>e[a],enumerable:!(r=w(e,a))||r.enumerable});return n};var _=n=>U(x({},"__esModule",{value:!0}),n);var P={};S(P,{Index:()=>g});module.exports=_(P);var s=class extends Error{constructor(e){super(e),this.name="UpstashError"}};var i=class{baseUrl;headers;options;retry;constructor(e){this.options={cache:e.cache,signal:e.signal},this.baseUrl=e.baseUrl.replace(/\/$/,""),this.headers={"Content-Type":"application/json",...e.headers},typeof e?.retry=="boolean"&&e?.retry===!1?this.retry={attempts:1,backoff:()=>0}:this.retry={attempts:e?.retry?.retries??5,backoff:e?.retry?.backoff??(t=>Math.exp(t)*50)}}async request(e){let t={cache:this.options.cache,method:"POST",headers:this.headers,body:JSON.stringify(e.body),keepalive:!0,signal:this.options.signal},r=null,a=null;for(let y=0;y<=this.retry.attempts;y++)try{r=await fetch([this.baseUrl,...e.path??[]].join("/"),t);break}catch(b){if(this.options.signal?.aborted){let R=new Blob([JSON.stringify({result:this.options.signal.reason??"Aborted"})]),C={status:200,statusText:this.options.signal.reason??"Aborted"};r=new Response(R,C);break}a=b,await new Promise(R=>setTimeout(R,this.retry.backoff(y)))}if(!r)throw a??new Error("Exhausted all retries");let T=await r.json();if(!r.ok)throw new s(`${T.error}`);return{result:T.result,error:T.error}}};var o=class{payload;endpoint;constructor(e,t){this.payload=e,this.endpoint=t}async exec(e){let{result:t,error:r}=await e.request({body:this.payload,path:[this.endpoint]});if(r)throw new s(r);if(typeof t>"u")throw new Error("Request did not return a result");return t}};var d=class extends o{constructor(e){let t=[];Array.isArray(e)?t.push(...e):t.push(e),super(t,"delete")}};var c=class extends o{constructor(e){let t="query";"data"in e&&(t="query-data"),super(e,t)}};var p=class extends o{constructor(e){let t="upsert";if(Array.isArray(e)){if(e.some(a=>"data"in a&&a.data)){t="upsert-data";for(let a of e)!("metadata"in a)&&"data"in a&&(a.metadata={data:a.data})}}else"data"in e&&(t="upsert-data","metadata"in e||(e.metadata={data:e.data}));super(e,t)}};var u=class extends o{constructor([e,t]){super({ids:e,...t},"fetch")}};var m=class extends o{constructor(e){super(e,"range")}};var l=class extends o{constructor(){super([],"reset")}};var f=class extends o{constructor(){super([],"info")}};var h=class{client;constructor(e){this.client=e}delete=e=>new d(e).exec(this.client);query=e=>new c(e).exec(this.client);upsert=e=>new p(e).exec(this.client);fetch=(...e)=>new u(e).exec(this.client);reset=()=>new l().exec(this.client);range=e=>new m(e).exec(this.client);info=()=>new f().exec(this.client)};var g=class n extends h{constructor(e){if(typeof e<"u"&&"request"in e){super(e);return}let t=e?.token??process.env.NEXT_PUBLIC_UPSTASH_VECTOR_REST_TOKEN??process.env.UPSTASH_VECTOR_REST_TOKEN,r=e?.url??process.env.NEXT_PUBLIC_UPSTASH_VECTOR_REST_URL??process.env.UPSTASH_VECTOR_REST_URL;if(!t)throw new Error("UPSTASH_VECTOR_REST_TOKEN is missing!");if(!r)throw new Error("UPSTASH_VECTOR_REST_URL is missing!");(r.startsWith(" ")||r.endsWith(" ")||/\r|\n/.test(r))&&console.warn("The vector url contains whitespace or newline, which can cause errors!"),(t.startsWith(" ")||t.endsWith(" ")||/\r|\n/.test(t))&&console.warn("The vector token contains whitespace or newline, which can cause errors!");let a=new i({baseUrl:r,retry:e?.retry,headers:{authorization:`Bearer ${t}`},cache:e?.cache||"no-store",signal:e?.signal});super(a)}static fromEnv(e){let t=process?.env.UPSTASH_VECTOR_REST_URL;if(!t)throw new Error("Unable to find environment variable: `UPSTASH_VECTOR_REST_URL`");let r=process?.env.UPSTASH_VECTOR_REST_TOKEN;if(!r)throw new Error("Unable to find environment variable: `UPSTASH_VECTOR_REST_TOKEN`");return new n({...e,url:t,token:r})}};0&&(module.exports={Index});
1
+ "use strict";var x=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var M=Object.prototype.hasOwnProperty;var S=(a,e)=>{for(var t in e)x(a,t,{get:e[t],enumerable:!0})},U=(a,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of E(e))!M.call(a,n)&&n!==t&&x(a,n,{get:()=>e[n],enumerable:!(r=w(e,n))||r.enumerable});return a};var _=a=>U(x({},"__esModule",{value:!0}),a);var P={};S(P,{Index:()=>g});module.exports=_(P);var s=class extends Error{constructor(e){super(e),this.name="UpstashError"}};var i=class{baseUrl;headers;options;retry;constructor(e){this.options={cache:e.cache,signal:e.signal},this.baseUrl=e.baseUrl.replace(/\/$/,""),this.headers={"Content-Type":"application/json",...e.headers},typeof e?.retry=="boolean"&&e?.retry===!1?this.retry={attempts:1,backoff:()=>0}:this.retry={attempts:e?.retry?.retries??5,backoff:e?.retry?.backoff??(t=>Math.exp(t)*50)}}async request(e){let t={cache:this.options.cache,method:"POST",headers:this.headers,body:JSON.stringify(e.body),keepalive:!0,signal:this.options.signal},r=null,n=null;for(let y=0;y<=this.retry.attempts;y++)try{r=await fetch([this.baseUrl,...e.path??[]].join("/"),t);break}catch(b){if(this.options.signal?.aborted){let R=new Blob([JSON.stringify({result:this.options.signal.reason??"Aborted"})]),C={status:200,statusText:this.options.signal.reason??"Aborted"};r=new Response(R,C);break}n=b,await new Promise(R=>setTimeout(R,this.retry.backoff(y)))}if(!r)throw n??new Error("Exhausted all retries");let T=await r.json();if(!r.ok)throw new s(`${T.error}`);return{result:T.result,error:T.error}}};var o=class{payload;endpoint;constructor(e,t){this.payload=e,this.endpoint=t}async exec(e){let{result:t,error:r}=await e.request({body:this.payload,path:[this.endpoint]});if(r)throw new s(r);if(typeof t>"u")throw new Error("Request did not return a result");return t}};var d=class extends o{constructor(e){let t=[];Array.isArray(e)?t.push(...e):t.push(e),super(t,"delete")}};var c=class extends o{constructor(e){let t="query";"data"in e&&(t="query-data"),super(e,t)}};var p=class extends o{constructor(e){let t="upsert";if(Array.isArray(e)){if(e.some(n=>"data"in n&&n.data)){t="upsert-data";for(let n of e)!("metadata"in n)&&"data"in n&&(n.metadata={data:n.data})}}else"data"in e&&(t="upsert-data","metadata"in e||(e.metadata={data:e.data}));super(e,t)}};var u=class extends o{constructor([e,t]){super({ids:e,...t},"fetch")}};var l=class extends o{constructor(e){super(e,"range")}};var m=class extends o{constructor(){super([],"reset")}};var f=class extends o{constructor(){super([],"info")}};var h=class{client;constructor(e){this.client=e}delete=e=>new d(e).exec(this.client);query=e=>new c(e).exec(this.client);upsert=e=>new p(e).exec(this.client);fetch=(...e)=>new u(e).exec(this.client);reset=()=>new m().exec(this.client);range=e=>new l(e).exec(this.client);info=()=>new f().exec(this.client)};var g=class a extends h{constructor(e){if(typeof e<"u"&&"request"in e){super(e);return}let t=e?.token??process.env.NEXT_PUBLIC_UPSTASH_VECTOR_REST_TOKEN??process.env.UPSTASH_VECTOR_REST_TOKEN,r=e?.url??process.env.NEXT_PUBLIC_UPSTASH_VECTOR_REST_URL??process.env.UPSTASH_VECTOR_REST_URL;if(!t)throw new Error("UPSTASH_VECTOR_REST_TOKEN is missing!");if(!r)throw new Error("UPSTASH_VECTOR_REST_URL is missing!");(r.startsWith(" ")||r.endsWith(" ")||/\r|\n/.test(r))&&console.warn("The vector url contains whitespace or newline, which can cause errors!"),(t.startsWith(" ")||t.endsWith(" ")||/\r|\n/.test(t))&&console.warn("The vector token contains whitespace or newline, which can cause errors!");let n=new i({baseUrl:r,retry:e?.retry,headers:{authorization:`Bearer ${t}`},cache:e?.cache===!1?void 0:e?.cache||"no-store",signal:e?.signal});super(n)}static fromEnv(e){let t=process?.env.UPSTASH_VECTOR_REST_URL;if(!t)throw new Error("Unable to find environment variable: `UPSTASH_VECTOR_REST_URL`");let r=process?.env.UPSTASH_VECTOR_REST_TOKEN;if(!r)throw new Error("Unable to find environment variable: `UPSTASH_VECTOR_REST_TOKEN`");return new a({...e,url:t,token:r})}};0&&(module.exports={Index});
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- var s=class extends Error{constructor(e){super(e),this.name="UpstashError"}};var i=class{baseUrl;headers;options;retry;constructor(e){this.options={cache:e.cache,signal:e.signal},this.baseUrl=e.baseUrl.replace(/\/$/,""),this.headers={"Content-Type":"application/json",...e.headers},typeof e?.retry=="boolean"&&e?.retry===!1?this.retry={attempts:1,backoff:()=>0}:this.retry={attempts:e?.retry?.retries??5,backoff:e?.retry?.backoff??(t=>Math.exp(t)*50)}}async request(e){let t={cache:this.options.cache,method:"POST",headers:this.headers,body:JSON.stringify(e.body),keepalive:!0,signal:this.options.signal},r=null,o=null;for(let y=0;y<=this.retry.attempts;y++)try{r=await fetch([this.baseUrl,...e.path??[]].join("/"),t);break}catch(g){if(this.options.signal?.aborted){let R=new Blob([JSON.stringify({result:this.options.signal.reason??"Aborted"})]),b={status:200,statusText:this.options.signal.reason??"Aborted"};r=new Response(R,b);break}o=g,await new Promise(R=>setTimeout(R,this.retry.backoff(y)))}if(!r)throw o??new Error("Exhausted all retries");let T=await r.json();if(!r.ok)throw new s(`${T.error}`);return{result:T.result,error:T.error}}};var n=class{payload;endpoint;constructor(e,t){this.payload=e,this.endpoint=t}async exec(e){let{result:t,error:r}=await e.request({body:this.payload,path:[this.endpoint]});if(r)throw new s(r);if(typeof t>"u")throw new Error("Request did not return a result");return t}};var d=class extends n{constructor(e){let t=[];Array.isArray(e)?t.push(...e):t.push(e),super(t,"delete")}};var c=class extends n{constructor(e){let t="query";"data"in e&&(t="query-data"),super(e,t)}};var p=class extends n{constructor(e){let t="upsert";if(Array.isArray(e)){if(e.some(o=>"data"in o&&o.data)){t="upsert-data";for(let o of e)!("metadata"in o)&&"data"in o&&(o.metadata={data:o.data})}}else"data"in e&&(t="upsert-data","metadata"in e||(e.metadata={data:e.data}));super(e,t)}};var u=class extends n{constructor([e,t]){super({ids:e,...t},"fetch")}};var m=class extends n{constructor(e){super(e,"range")}};var l=class extends n{constructor(){super([],"reset")}};var f=class extends n{constructor(){super([],"info")}};var h=class{client;constructor(e){this.client=e}delete=e=>new d(e).exec(this.client);query=e=>new c(e).exec(this.client);upsert=e=>new p(e).exec(this.client);fetch=(...e)=>new u(e).exec(this.client);reset=()=>new l().exec(this.client);range=e=>new m(e).exec(this.client);info=()=>new f().exec(this.client)};var x=class a extends h{constructor(e){if(typeof e<"u"&&"request"in e){super(e);return}let t=e?.token??process.env.NEXT_PUBLIC_UPSTASH_VECTOR_REST_TOKEN??process.env.UPSTASH_VECTOR_REST_TOKEN,r=e?.url??process.env.NEXT_PUBLIC_UPSTASH_VECTOR_REST_URL??process.env.UPSTASH_VECTOR_REST_URL;if(!t)throw new Error("UPSTASH_VECTOR_REST_TOKEN is missing!");if(!r)throw new Error("UPSTASH_VECTOR_REST_URL is missing!");(r.startsWith(" ")||r.endsWith(" ")||/\r|\n/.test(r))&&console.warn("The vector url contains whitespace or newline, which can cause errors!"),(t.startsWith(" ")||t.endsWith(" ")||/\r|\n/.test(t))&&console.warn("The vector token contains whitespace or newline, which can cause errors!");let o=new i({baseUrl:r,retry:e?.retry,headers:{authorization:`Bearer ${t}`},cache:e?.cache||"no-store",signal:e?.signal});super(o)}static fromEnv(e){let t=process?.env.UPSTASH_VECTOR_REST_URL;if(!t)throw new Error("Unable to find environment variable: `UPSTASH_VECTOR_REST_URL`");let r=process?.env.UPSTASH_VECTOR_REST_TOKEN;if(!r)throw new Error("Unable to find environment variable: `UPSTASH_VECTOR_REST_TOKEN`");return new a({...e,url:t,token:r})}};export{x as Index};
1
+ var s=class extends Error{constructor(e){super(e),this.name="UpstashError"}};var i=class{baseUrl;headers;options;retry;constructor(e){this.options={cache:e.cache,signal:e.signal},this.baseUrl=e.baseUrl.replace(/\/$/,""),this.headers={"Content-Type":"application/json",...e.headers},typeof e?.retry=="boolean"&&e?.retry===!1?this.retry={attempts:1,backoff:()=>0}:this.retry={attempts:e?.retry?.retries??5,backoff:e?.retry?.backoff??(t=>Math.exp(t)*50)}}async request(e){let t={cache:this.options.cache,method:"POST",headers:this.headers,body:JSON.stringify(e.body),keepalive:!0,signal:this.options.signal},r=null,o=null;for(let y=0;y<=this.retry.attempts;y++)try{r=await fetch([this.baseUrl,...e.path??[]].join("/"),t);break}catch(g){if(this.options.signal?.aborted){let R=new Blob([JSON.stringify({result:this.options.signal.reason??"Aborted"})]),b={status:200,statusText:this.options.signal.reason??"Aborted"};r=new Response(R,b);break}o=g,await new Promise(R=>setTimeout(R,this.retry.backoff(y)))}if(!r)throw o??new Error("Exhausted all retries");let T=await r.json();if(!r.ok)throw new s(`${T.error}`);return{result:T.result,error:T.error}}};var a=class{payload;endpoint;constructor(e,t){this.payload=e,this.endpoint=t}async exec(e){let{result:t,error:r}=await e.request({body:this.payload,path:[this.endpoint]});if(r)throw new s(r);if(typeof t>"u")throw new Error("Request did not return a result");return t}};var d=class extends a{constructor(e){let t=[];Array.isArray(e)?t.push(...e):t.push(e),super(t,"delete")}};var c=class extends a{constructor(e){let t="query";"data"in e&&(t="query-data"),super(e,t)}};var p=class extends a{constructor(e){let t="upsert";if(Array.isArray(e)){if(e.some(o=>"data"in o&&o.data)){t="upsert-data";for(let o of e)!("metadata"in o)&&"data"in o&&(o.metadata={data:o.data})}}else"data"in e&&(t="upsert-data","metadata"in e||(e.metadata={data:e.data}));super(e,t)}};var u=class extends a{constructor([e,t]){super({ids:e,...t},"fetch")}};var l=class extends a{constructor(e){super(e,"range")}};var m=class extends a{constructor(){super([],"reset")}};var f=class extends a{constructor(){super([],"info")}};var h=class{client;constructor(e){this.client=e}delete=e=>new d(e).exec(this.client);query=e=>new c(e).exec(this.client);upsert=e=>new p(e).exec(this.client);fetch=(...e)=>new u(e).exec(this.client);reset=()=>new m().exec(this.client);range=e=>new l(e).exec(this.client);info=()=>new f().exec(this.client)};var x=class n extends h{constructor(e){if(typeof e<"u"&&"request"in e){super(e);return}let t=e?.token??process.env.NEXT_PUBLIC_UPSTASH_VECTOR_REST_TOKEN??process.env.UPSTASH_VECTOR_REST_TOKEN,r=e?.url??process.env.NEXT_PUBLIC_UPSTASH_VECTOR_REST_URL??process.env.UPSTASH_VECTOR_REST_URL;if(!t)throw new Error("UPSTASH_VECTOR_REST_TOKEN is missing!");if(!r)throw new Error("UPSTASH_VECTOR_REST_URL is missing!");(r.startsWith(" ")||r.endsWith(" ")||/\r|\n/.test(r))&&console.warn("The vector url contains whitespace or newline, which can cause errors!"),(t.startsWith(" ")||t.endsWith(" ")||/\r|\n/.test(t))&&console.warn("The vector token contains whitespace or newline, which can cause errors!");let o=new i({baseUrl:r,retry:e?.retry,headers:{authorization:`Bearer ${t}`},cache:e?.cache===!1?void 0:e?.cache||"no-store",signal:e?.signal});super(o)}static fromEnv(e){let t=process?.env.UPSTASH_VECTOR_REST_URL;if(!t)throw new Error("Unable to find environment variable: `UPSTASH_VECTOR_REST_URL`");let r=process?.env.UPSTASH_VECTOR_REST_TOKEN;if(!r)throw new Error("Unable to find environment variable: `UPSTASH_VECTOR_REST_TOKEN`");return new n({...e,url:t,token:r})}};export{x as Index};
package/package.json CHANGED
@@ -1 +1 @@
1
- { "name": "@upstash/vector", "version": "v1.0.6", "author": "Oguzhan Olguncu <oguzhan@upstash.com>", "repository": { "type": "git", "url": "https://github.com/upstash/vector-js" }, "main": "./dist/index.js", "module": "./dist/index.mjs", "devDependencies": { "@biomejs/biome": "^1.4.1", "@commitlint/cli": "^18.6.0", "@commitlint/config-conventional": "^18.6.0", "bun-types": "latest", "husky": "^8.0.3", "tsup": "latest", "typescript": "^5.0.0", "vitest": "^1.2.2" }, "bugs": { "url": "https://github.com/upstash/vector/issues" }, "description": "An HTTP/REST based Vector DB client built on top of Upstash REST API.", "files": [ "dist" ], "homepage": "https://upstash.com/vector", "keywords": [ "vector", "upstash", "db" ], "license": "MIT", "scripts": { "test": "bun test src --coverage --bail --coverageSkipTestFiles=[test-utils.ts] --timeout 20000 && vitest run --typecheck", "fmt": "bunx biome check --apply ./src", "build": "tsup", "prepare": "husky install" }, "types": "./dist/index.d.ts" }
1
+ { "name": "@upstash/vector", "version": "v1.0.7", "author": "Oguzhan Olguncu <oguzhan@upstash.com>", "repository": { "type": "git", "url": "https://github.com/upstash/vector-js" }, "main": "./dist/index.js", "module": "./dist/index.mjs", "devDependencies": { "@biomejs/biome": "^1.4.1", "@commitlint/cli": "^18.6.0", "@commitlint/config-conventional": "^18.6.0", "bun-types": "latest", "husky": "^8.0.3", "tsup": "latest", "typescript": "^5.0.0", "vitest": "^1.2.2" }, "bugs": { "url": "https://github.com/upstash/vector/issues" }, "description": "An HTTP/REST based Vector DB client built on top of Upstash REST API.", "files": [ "dist" ], "homepage": "https://upstash.com/vector", "keywords": [ "vector", "upstash", "db" ], "license": "MIT", "scripts": { "test": "bun test src --coverage --bail --coverageSkipTestFiles=[test-utils.ts] --timeout 20000 && vitest run --typecheck", "fmt": "bunx biome check --apply ./src", "build": "tsup", "prepare": "husky install" }, "types": "./dist/index.d.ts" }