@upstash/vector 0.1.0-alpha-10 → 0.1.0-alpha-11

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
@@ -272,11 +272,11 @@ type IndexConfig = {
272
272
  /**
273
273
  * UPSTASH_VECTOR_REST_URL
274
274
  */
275
- url: string;
275
+ url?: string;
276
276
  /**
277
277
  * UPSTASH_VECTOR_REST_TOKEN
278
278
  */
279
- token: string;
279
+ token?: string;
280
280
  /**
281
281
  * The signal will allow aborting requests on the fly.
282
282
  * For more check: https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal
@@ -303,7 +303,7 @@ declare class Index extends Index$1 {
303
303
  * const index = new Index();
304
304
  * ```
305
305
  */
306
- constructor(config: IndexConfig);
306
+ constructor(config?: IndexConfig);
307
307
  /**
308
308
  * Create a new vector client by providing a custom `Requester` implementation
309
309
  *
@@ -321,7 +321,7 @@ declare class Index extends Index$1 {
321
321
  * const vector = new vector(requester)
322
322
  * ```
323
323
  */
324
- constructor(requesters: Requester);
324
+ constructor(requesters?: Requester);
325
325
  /**
326
326
  * Create a new Upstash Vector instance from environment variables.
327
327
  *
package/dist/index.d.ts CHANGED
@@ -272,11 +272,11 @@ type IndexConfig = {
272
272
  /**
273
273
  * UPSTASH_VECTOR_REST_URL
274
274
  */
275
- url: string;
275
+ url?: string;
276
276
  /**
277
277
  * UPSTASH_VECTOR_REST_TOKEN
278
278
  */
279
- token: string;
279
+ token?: string;
280
280
  /**
281
281
  * The signal will allow aborting requests on the fly.
282
282
  * For more check: https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal
@@ -303,7 +303,7 @@ declare class Index extends Index$1 {
303
303
  * const index = new Index();
304
304
  * ```
305
305
  */
306
- constructor(config: IndexConfig);
306
+ constructor(config?: IndexConfig);
307
307
  /**
308
308
  * Create a new vector client by providing a custom `Requester` implementation
309
309
  *
@@ -321,7 +321,7 @@ declare class Index extends Index$1 {
321
321
  * const vector = new vector(requester)
322
322
  * ```
323
323
  */
324
- constructor(requesters: Requester);
324
+ constructor(requesters?: Requester);
325
325
  /**
326
326
  * Create a new Upstash Vector instance from environment variables.
327
327
  *
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 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 b=0;b<=this.retry.attempts;b++)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"})]),C={status:200,statusText:this.options.signal.reason??"Aborted"};r=new Response(R,C);break}a=g,await new Promise(R=>setTimeout(R,this.retry.backoff(b)));}if(!r)throw a??new Error("Exhausted all retries");let f=await r.json();if(!r.ok)throw new n(`${f.error}, command was: ${JSON.stringify(e.body)}`);return {result:f.result,error:f.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 n(r);if(typeof t>"u")throw new Error("Request did not return a result");return t}};var p=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){super(e,"query");}};var u=class extends o{constructor(e){super(e,"upsert");}};var l=class extends o{constructor([e,t]){super({ids:e,...t},"fetch");}};var m=class extends o{constructor(e){super(e,"range");}};var d=class extends o{constructor(){super([],"reset");}};var h=class extends o{constructor(){super([],"stats");}};var y=class{client;constructor(e){this.client=e;}delete=e=>new p(e).exec(this.client);query=e=>new c(e).exec(this.client);upsert=e=>new u(e).exec(this.client);fetch=(...e)=>new l(e).exec(this.client);reset=()=>new d().exec(this.client);range=e=>new m(e).exec(this.client);stats=()=>new h().exec(this.client)};var x=class s extends y{constructor(e){if("request"in e){super(e);return}let t=process.env.UPSTASH_VECTOR_TOKEN??e.token,r=process.env.UPSTASH_VECTOR_REST_URL??e.url;(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 s({...e,url:t,token:r})}};
3
+ var n=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 R=0;R<=this.retry.attempts;R++)try{r=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"})]),C={status:200,statusText:this.options.signal.reason??"Aborted"};r=new Response(b,C);break}a=g,await new Promise(b=>setTimeout(b,this.retry.backoff(R)));}if(!r)throw a??new Error("Exhausted all retries");let f=await r.json();if(!r.ok)throw new n(`${f.error}, command was: ${JSON.stringify(e.body)}`);return {result:f.result,error:f.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 n(r);if(typeof t>"u")throw new Error("Request did not return a result");return t}};var p=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){super(e,"query");}};var u=class extends o{constructor(e){super(e,"upsert");}};var m=class extends o{constructor([e,t]){super({ids:e,...t},"fetch");}};var l=class extends o{constructor(e){super(e,"range");}};var d=class extends o{constructor(){super([],"reset");}};var h=class extends o{constructor(){super([],"stats");}};var y=class{client;constructor(e){this.client=e;}delete=e=>new p(e).exec(this.client);query=e=>new c(e).exec(this.client);upsert=e=>new u(e).exec(this.client);fetch=(...e)=>new m(e).exec(this.client);reset=()=>new d().exec(this.client);range=e=>new l(e).exec(this.client);stats=()=>new h().exec(this.client)};var x=class s extends y{constructor(e){if(typeof e<"u"&&"request"in e){super(e);return}let t=process.env.UPSTASH_VECTOR_TOKEN??e?.token,r=process.env.UPSTASH_VECTOR_REST_URL??e?.url;if(!t)throw new Error("UPSTASH_VECTOR_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 s({...e,url:t,token:r})}};
4
4
 
5
5
  exports.Index = x;
package/dist/index.mjs CHANGED
@@ -1,3 +1,3 @@
1
- var n=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 b=0;b<=this.retry.attempts;b++)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"})]),C={status:200,statusText:this.options.signal.reason??"Aborted"};r=new Response(R,C);break}a=g,await new Promise(R=>setTimeout(R,this.retry.backoff(b)));}if(!r)throw a??new Error("Exhausted all retries");let f=await r.json();if(!r.ok)throw new n(`${f.error}, command was: ${JSON.stringify(e.body)}`);return {result:f.result,error:f.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 n(r);if(typeof t>"u")throw new Error("Request did not return a result");return t}};var p=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){super(e,"query");}};var u=class extends o{constructor(e){super(e,"upsert");}};var l=class extends o{constructor([e,t]){super({ids:e,...t},"fetch");}};var m=class extends o{constructor(e){super(e,"range");}};var d=class extends o{constructor(){super([],"reset");}};var h=class extends o{constructor(){super([],"stats");}};var y=class{client;constructor(e){this.client=e;}delete=e=>new p(e).exec(this.client);query=e=>new c(e).exec(this.client);upsert=e=>new u(e).exec(this.client);fetch=(...e)=>new l(e).exec(this.client);reset=()=>new d().exec(this.client);range=e=>new m(e).exec(this.client);stats=()=>new h().exec(this.client)};var x=class s extends y{constructor(e){if("request"in e){super(e);return}let t=process.env.UPSTASH_VECTOR_TOKEN??e.token,r=process.env.UPSTASH_VECTOR_REST_URL??e.url;(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 s({...e,url:t,token:r})}};
1
+ var n=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 R=0;R<=this.retry.attempts;R++)try{r=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"})]),C={status:200,statusText:this.options.signal.reason??"Aborted"};r=new Response(b,C);break}a=g,await new Promise(b=>setTimeout(b,this.retry.backoff(R)));}if(!r)throw a??new Error("Exhausted all retries");let f=await r.json();if(!r.ok)throw new n(`${f.error}, command was: ${JSON.stringify(e.body)}`);return {result:f.result,error:f.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 n(r);if(typeof t>"u")throw new Error("Request did not return a result");return t}};var p=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){super(e,"query");}};var u=class extends o{constructor(e){super(e,"upsert");}};var m=class extends o{constructor([e,t]){super({ids:e,...t},"fetch");}};var l=class extends o{constructor(e){super(e,"range");}};var d=class extends o{constructor(){super([],"reset");}};var h=class extends o{constructor(){super([],"stats");}};var y=class{client;constructor(e){this.client=e;}delete=e=>new p(e).exec(this.client);query=e=>new c(e).exec(this.client);upsert=e=>new u(e).exec(this.client);fetch=(...e)=>new m(e).exec(this.client);reset=()=>new d().exec(this.client);range=e=>new l(e).exec(this.client);stats=()=>new h().exec(this.client)};var x=class s extends y{constructor(e){if(typeof e<"u"&&"request"in e){super(e);return}let t=process.env.UPSTASH_VECTOR_TOKEN??e?.token,r=process.env.UPSTASH_VECTOR_REST_URL??e?.url;if(!t)throw new Error("UPSTASH_VECTOR_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 s({...e,url:t,token:r})}};
2
2
 
3
3
  export { x as Index };
package/package.json CHANGED
@@ -1 +1 @@
1
- { "name": "@upstash/vector", "description": "An HTTP/REST based Vector DB client built on top of Upstash REST API.", "module": "./dist/index.mjs", "main": "./dist/index.js", "types": "./dist/index.d.ts", "version": "v0.1.0-alpha-10", "keywords": [ "vector", "upstash", "db" ], "author": "Oguzhan Olguncu <oguzhan@upstash.com>", "license": "MIT", "files": [ "dist" ], "bugs": { "url": "https://github.com/upstash/vector/issues" }, "scripts": { "test": "bun test src --coverage --bail --coverageSkipTestFiles=[test-utils.ts]", "fmt": "bunx biome check --apply ./src", "build": "tsup", "prepare": "husky install" }, "devDependencies": { "typescript": "^5.0.0", "@biomejs/biome": "^1.4.1", "bun-types": "latest", "husky": "^8.0.3", "tsup": "latest" } }
1
+ { "name": "@upstash/vector", "description": "An HTTP/REST based Vector DB client built on top of Upstash REST API.", "module": "./dist/index.mjs", "main": "./dist/index.js", "types": "./dist/index.d.ts", "version": "v0.1.0-alpha-11", "keywords": [ "vector", "upstash", "db" ], "author": "Oguzhan Olguncu <oguzhan@upstash.com>", "license": "MIT", "files": [ "dist" ], "bugs": { "url": "https://github.com/upstash/vector/issues" }, "scripts": { "test": "bun test src --coverage --bail --coverageSkipTestFiles=[test-utils.ts]", "fmt": "bunx biome check --apply ./src", "build": "tsup", "prepare": "husky install" }, "devDependencies": { "typescript": "^5.0.0", "@biomejs/biome": "^1.4.1", "bun-types": "latest", "husky": "^8.0.3", "tsup": "latest" } }