@upstash/vector 0.1.0-alpha-2 → 0.1.0-alpha-3

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
@@ -311,4 +311,4 @@ declare class Index extends Index$1 {
311
311
  static fromEnv(config?: Omit<IndexConfig, "url" | "token">): Index;
312
312
  }
313
313
 
314
- export { Index, type IndexConfig, type Requester, type UpstashRequest, type UpstashResponse };
314
+ export { type FetchReturnResponse, Index, type IndexConfig, type QueryReturnResponse, type RangeReturnResponse, type Requester, type UpstashRequest, type UpstashResponse, type Vector };
package/dist/index.d.ts CHANGED
@@ -311,4 +311,4 @@ declare class Index extends Index$1 {
311
311
  static fromEnv(config?: Omit<IndexConfig, "url" | "token">): Index;
312
312
  }
313
313
 
314
- export { Index, type IndexConfig, type Requester, type UpstashRequest, type UpstashResponse };
314
+ export { type FetchReturnResponse, Index, type IndexConfig, type QueryReturnResponse, type RangeReturnResponse, type Requester, type UpstashRequest, type UpstashResponse, type Vector };
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  'use strict';
2
2
 
3
- var n=class extends Error{constructor(e){super(e),this.name="UpstashError";}};var a=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},o=null,f=null;for(let y=0;y<=this.retry.attempts;y++)try{o=await fetch([this.baseUrl,...e.path??[]].join("/"),t);break}catch(g){if(this.options.signal?.aborted){let b=new Blob([JSON.stringify({result:this.options.signal.reason??"Aborted"})]),x={status:200,statusText:this.options.signal.reason??"Aborted"};o=new Response(b,x);break}f=g,await new Promise(b=>setTimeout(b,this.retry.backoff(y)));}if(!o)throw f??new Error("Exhausted all retries");let h=await o.json();if(!o.ok)throw new n(`${h.error}, command was: ${JSON.stringify(e.body)}`);return {result:h.result,error:h.error}}};var r=class{payload;endpoint;constructor(e,t){this.payload=e,this.endpoint=t;}async exec(e){let{result:t,error:o}=await e.request({body:this.payload,path:[this.endpoint]});if(o)throw new n(o);if(typeof t>"u")throw new Error("Request did not return a result");return t}};var i=class extends r{constructor(e){let t=[];Array.isArray(e)?t.push(...e):t.push(e),super(t,"delete");}};var p=class extends r{constructor(e){super(e,"query");}};var c=class extends r{constructor(e){super(e,"upsert");}};var u=class extends r{constructor([e,t]){super({ids:e,...t},"fetch");}};var l=class extends r{constructor(e){super(e,"range");}};var m=class extends r{constructor(){super([],"reset");}};var d=class{client;constructor(e){this.client=e;}delete=e=>new i(e).exec(this.client);query=e=>new p(e).exec(this.client);upsert=e=>new c(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)};var R=class s extends d{constructor(e){if("request"in e){super(e);return}(e.url.startsWith(" ")||e.url.endsWith(" ")||/\r|\n/.test(e.url))&&console.warn("The vector url contains whitespace or newline, which can cause errors!"),(e.token.startsWith(" ")||e.token.endsWith(" ")||/\r|\n/.test(e.token))&&console.warn("The vector token contains whitespace or newline, which can cause errors!");let t=new a({baseUrl:e.url,retry:e.retry,headers:{authorization:`Bearer ${e.token}`},cache:e.cache||"no-store",signal:e.signal});super(t);}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 o=process?.env.UPSTASH_VECTOR_REST_TOKEN;if(!o)throw new Error("Unable to find environment variable: `UPSTASH_VECTOR_REST_TOKEN`");return new s({...e,url:t,token:o})}};
3
+ var n=class extends Error{constructor(e){super(e),this.name="UpstashError";}};var a=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},o=null,f=null;for(let y=0;y<=this.retry.attempts;y++)try{o=await fetch([this.baseUrl,...e.path??[]].join("/"),t);break}catch(x){if(this.options.signal?.aborted){let b=new Blob([JSON.stringify({result:this.options.signal.reason??"Aborted"})]),g={status:200,statusText:this.options.signal.reason??"Aborted"};o=new Response(b,g);break}f=x,await new Promise(b=>setTimeout(b,this.retry.backoff(y)));}if(!o)throw f??new Error("Exhausted all retries");let h=await o.json();if(!o.ok)throw new n(`${h.error}, command was: ${JSON.stringify(e.body)}`);return {result:h.result,error:h.error}}};var r=class{payload;endpoint;constructor(e,t){this.payload=e,this.endpoint=t;}async exec(e){let{result:t,error:o}=await e.request({body:this.payload,path:[this.endpoint]});if(o)throw new n(o);if(typeof t>"u")throw new Error("Request did not return a result");return t}};var i=class extends r{constructor(e){let t=[];Array.isArray(e)?t.push(...e):t.push(e),super(t,"delete");}};var p=class extends r{constructor(e){super(e,"query");}};var c=class extends r{constructor(e){super(e,"upsert");}};var u=class extends r{constructor([e,t]){super({ids:e,...t},"fetch");}};var l=class extends r{constructor(e){super(e,"range");}};var m=class extends r{constructor(){super([],"reset");}};var d=class{client;constructor(e){this.client=e;}delete=e=>new i(e).exec(this.client);query=e=>new p(e).exec(this.client);upsert=e=>new c(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)};var R=class s extends d{constructor(e){if("request"in e){super(e);return}(e.url.startsWith(" ")||e.url.endsWith(" ")||/\r|\n/.test(e.url))&&console.warn("The vector url contains whitespace or newline, which can cause errors!"),(e.token.startsWith(" ")||e.token.endsWith(" ")||/\r|\n/.test(e.token))&&console.warn("The vector token contains whitespace or newline, which can cause errors!");let t=new a({baseUrl:e.url,retry:e.retry,headers:{authorization:`Bearer ${e.token}`},cache:e.cache||"no-store",signal:e.signal});super(t);}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 o=process?.env.UPSTASH_VECTOR_REST_TOKEN;if(!o)throw new Error("Unable to find environment variable: `UPSTASH_VECTOR_REST_TOKEN`");return new s({...e,url:t,token:o})}};
4
4
 
5
5
  exports.Index = R;
package/dist/index.mjs CHANGED
@@ -1,3 +1,3 @@
1
- var n=class extends Error{constructor(e){super(e),this.name="UpstashError";}};var a=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},o=null,f=null;for(let y=0;y<=this.retry.attempts;y++)try{o=await fetch([this.baseUrl,...e.path??[]].join("/"),t);break}catch(g){if(this.options.signal?.aborted){let b=new Blob([JSON.stringify({result:this.options.signal.reason??"Aborted"})]),x={status:200,statusText:this.options.signal.reason??"Aborted"};o=new Response(b,x);break}f=g,await new Promise(b=>setTimeout(b,this.retry.backoff(y)));}if(!o)throw f??new Error("Exhausted all retries");let h=await o.json();if(!o.ok)throw new n(`${h.error}, command was: ${JSON.stringify(e.body)}`);return {result:h.result,error:h.error}}};var r=class{payload;endpoint;constructor(e,t){this.payload=e,this.endpoint=t;}async exec(e){let{result:t,error:o}=await e.request({body:this.payload,path:[this.endpoint]});if(o)throw new n(o);if(typeof t>"u")throw new Error("Request did not return a result");return t}};var i=class extends r{constructor(e){let t=[];Array.isArray(e)?t.push(...e):t.push(e),super(t,"delete");}};var p=class extends r{constructor(e){super(e,"query");}};var c=class extends r{constructor(e){super(e,"upsert");}};var u=class extends r{constructor([e,t]){super({ids:e,...t},"fetch");}};var l=class extends r{constructor(e){super(e,"range");}};var m=class extends r{constructor(){super([],"reset");}};var d=class{client;constructor(e){this.client=e;}delete=e=>new i(e).exec(this.client);query=e=>new p(e).exec(this.client);upsert=e=>new c(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)};var R=class s extends d{constructor(e){if("request"in e){super(e);return}(e.url.startsWith(" ")||e.url.endsWith(" ")||/\r|\n/.test(e.url))&&console.warn("The vector url contains whitespace or newline, which can cause errors!"),(e.token.startsWith(" ")||e.token.endsWith(" ")||/\r|\n/.test(e.token))&&console.warn("The vector token contains whitespace or newline, which can cause errors!");let t=new a({baseUrl:e.url,retry:e.retry,headers:{authorization:`Bearer ${e.token}`},cache:e.cache||"no-store",signal:e.signal});super(t);}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 o=process?.env.UPSTASH_VECTOR_REST_TOKEN;if(!o)throw new Error("Unable to find environment variable: `UPSTASH_VECTOR_REST_TOKEN`");return new s({...e,url:t,token:o})}};
1
+ var n=class extends Error{constructor(e){super(e),this.name="UpstashError";}};var a=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},o=null,f=null;for(let y=0;y<=this.retry.attempts;y++)try{o=await fetch([this.baseUrl,...e.path??[]].join("/"),t);break}catch(x){if(this.options.signal?.aborted){let b=new Blob([JSON.stringify({result:this.options.signal.reason??"Aborted"})]),g={status:200,statusText:this.options.signal.reason??"Aborted"};o=new Response(b,g);break}f=x,await new Promise(b=>setTimeout(b,this.retry.backoff(y)));}if(!o)throw f??new Error("Exhausted all retries");let h=await o.json();if(!o.ok)throw new n(`${h.error}, command was: ${JSON.stringify(e.body)}`);return {result:h.result,error:h.error}}};var r=class{payload;endpoint;constructor(e,t){this.payload=e,this.endpoint=t;}async exec(e){let{result:t,error:o}=await e.request({body:this.payload,path:[this.endpoint]});if(o)throw new n(o);if(typeof t>"u")throw new Error("Request did not return a result");return t}};var i=class extends r{constructor(e){let t=[];Array.isArray(e)?t.push(...e):t.push(e),super(t,"delete");}};var p=class extends r{constructor(e){super(e,"query");}};var c=class extends r{constructor(e){super(e,"upsert");}};var u=class extends r{constructor([e,t]){super({ids:e,...t},"fetch");}};var l=class extends r{constructor(e){super(e,"range");}};var m=class extends r{constructor(){super([],"reset");}};var d=class{client;constructor(e){this.client=e;}delete=e=>new i(e).exec(this.client);query=e=>new p(e).exec(this.client);upsert=e=>new c(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)};var R=class s extends d{constructor(e){if("request"in e){super(e);return}(e.url.startsWith(" ")||e.url.endsWith(" ")||/\r|\n/.test(e.url))&&console.warn("The vector url contains whitespace or newline, which can cause errors!"),(e.token.startsWith(" ")||e.token.endsWith(" ")||/\r|\n/.test(e.token))&&console.warn("The vector token contains whitespace or newline, which can cause errors!");let t=new a({baseUrl:e.url,retry:e.retry,headers:{authorization:`Bearer ${e.token}`},cache:e.cache||"no-store",signal:e.signal});super(t);}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 o=process?.env.UPSTASH_VECTOR_REST_TOKEN;if(!o)throw new Error("Unable to find environment variable: `UPSTASH_VECTOR_REST_TOKEN`");return new s({...e,url:t,token:o})}};
2
2
 
3
3
  export { R as Index };
package/package.json CHANGED
@@ -3,8 +3,20 @@
3
3
  "description": "An HTTP/REST based Vector DB client built on top of Upstash REST API.",
4
4
  "module": "./dist/index.mjs",
5
5
  "main": "./dist/index.js",
6
- "types": "./dist/index.d.ts",
7
- "version": "v0.1.0-alpha-2",
6
+ "version": "v0.1.0-alpha-3",
7
+ "exports": {
8
+ ".": {
9
+ "import": "./nodejs.js",
10
+ "require": "./nodejs.mjs"
11
+ },
12
+ "./node": {
13
+ "import": "./nodejs.js",
14
+ "require": "./nodejs.mjs"
15
+ },
16
+ "./node.js": "./node.js",
17
+ "./node.mjs": "./node.mjs"
18
+ },
19
+ "types": "./nodejs.d.ts",
8
20
  "keywords": [
9
21
  "vector",
10
22
  "upstash",