@upstash/vector 0.1.0-alpha-6 → 0.1.0-alpha-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
@@ -75,7 +75,7 @@ type QueryResult<TMetadata> = {
75
75
  vector: number[];
76
76
  metadata?: TMetadata;
77
77
  };
78
- declare class QueryCommand<TMetadata> extends Command<QueryResult<TMetadata>[]> {
78
+ declare class QueryCommand<TMetadata = Record<string, unknown>> extends Command<QueryResult<TMetadata>[]> {
79
79
  constructor(payload: QueryCommandPayload);
80
80
  }
81
81
 
@@ -106,7 +106,7 @@ type RangeResult<TMetadata> = {
106
106
  nextCursor: string;
107
107
  vectors: Vector<TMetadata>[];
108
108
  };
109
- declare class RangeCommand<TMetadata> extends Command<RangeResult<TMetadata>> {
109
+ declare class RangeCommand<TMetadata = Record<string, unknown>> extends Command<RangeResult<TMetadata>> {
110
110
  constructor(payload: RangeCommandPayload);
111
111
  }
112
112
 
@@ -160,7 +160,7 @@ declare class Index$1 {
160
160
  *
161
161
  * @returns A promise that resolves with an array of query result objects when the request to query the index is completed.
162
162
  */
163
- query: (args: CommandArgs<typeof QueryCommand>) => Promise<QueryResult<unknown>[]>;
163
+ query: (args: CommandArgs<typeof QueryCommand>) => Promise<QueryResult<Record<string, unknown>>[]>;
164
164
  /**
165
165
  * Upserts (Updates and Inserts) specific items into the index.
166
166
  * It's used for adding new items to the index or updating existing ones.
@@ -207,7 +207,7 @@ declare class Index$1 {
207
207
  fetch: (ids: string[] | number[], opts: {
208
208
  includeMetadata?: boolean | undefined;
209
209
  includeVectors?: boolean | undefined;
210
- }) => Promise<FetchResult<unknown>[]>;
210
+ }) => Promise<FetchResult<Record<string, unknown>>[]>;
211
211
  /**
212
212
  * It's used for wiping an entire index.
213
213
  *
@@ -243,7 +243,7 @@ declare class Index$1 {
243
243
  *
244
244
  * @returns {Promise<RangeReturnResponse<TMetadata>>} A promise that resolves with the response containing the next cursor and an array of vectors, after the command is executed.
245
245
  */
246
- range: (args: CommandArgs<typeof RangeCommand>) => Promise<RangeResult<unknown>>;
246
+ range: (args: CommandArgs<typeof RangeCommand>) => Promise<RangeResult<Record<string, unknown>>>;
247
247
  }
248
248
 
249
249
  /**
package/dist/index.d.ts CHANGED
@@ -75,7 +75,7 @@ type QueryResult<TMetadata> = {
75
75
  vector: number[];
76
76
  metadata?: TMetadata;
77
77
  };
78
- declare class QueryCommand<TMetadata> extends Command<QueryResult<TMetadata>[]> {
78
+ declare class QueryCommand<TMetadata = Record<string, unknown>> extends Command<QueryResult<TMetadata>[]> {
79
79
  constructor(payload: QueryCommandPayload);
80
80
  }
81
81
 
@@ -106,7 +106,7 @@ type RangeResult<TMetadata> = {
106
106
  nextCursor: string;
107
107
  vectors: Vector<TMetadata>[];
108
108
  };
109
- declare class RangeCommand<TMetadata> extends Command<RangeResult<TMetadata>> {
109
+ declare class RangeCommand<TMetadata = Record<string, unknown>> extends Command<RangeResult<TMetadata>> {
110
110
  constructor(payload: RangeCommandPayload);
111
111
  }
112
112
 
@@ -160,7 +160,7 @@ declare class Index$1 {
160
160
  *
161
161
  * @returns A promise that resolves with an array of query result objects when the request to query the index is completed.
162
162
  */
163
- query: (args: CommandArgs<typeof QueryCommand>) => Promise<QueryResult<unknown>[]>;
163
+ query: (args: CommandArgs<typeof QueryCommand>) => Promise<QueryResult<Record<string, unknown>>[]>;
164
164
  /**
165
165
  * Upserts (Updates and Inserts) specific items into the index.
166
166
  * It's used for adding new items to the index or updating existing ones.
@@ -207,7 +207,7 @@ declare class Index$1 {
207
207
  fetch: (ids: string[] | number[], opts: {
208
208
  includeMetadata?: boolean | undefined;
209
209
  includeVectors?: boolean | undefined;
210
- }) => Promise<FetchResult<unknown>[]>;
210
+ }) => Promise<FetchResult<Record<string, unknown>>[]>;
211
211
  /**
212
212
  * It's used for wiping an entire index.
213
213
  *
@@ -243,7 +243,7 @@ declare class Index$1 {
243
243
  *
244
244
  * @returns {Promise<RangeReturnResponse<TMetadata>>} A promise that resolves with the response containing the next cursor and an array of vectors, after the command is executed.
245
245
  */
246
- range: (args: CommandArgs<typeof RangeCommand>) => Promise<RangeResult<unknown>>;
246
+ range: (args: CommandArgs<typeof RangeCommand>) => Promise<RangeResult<Record<string, unknown>>>;
247
247
  }
248
248
 
249
249
  /**
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(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 l=class extends r{constructor(e){super(e,"upsert");}};var c=class extends r{constructor([e,t]){super({ids:e,...t},"fetch");}};var u=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 l(e).exec(this.client);fetch=(...e)=>new c(e).exec(this.client);reset=()=>new m().exec(this.client);range=e=>new u(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},s=null,f=null;for(let y=0;y<=this.retry.attempts;y++)try{s=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"};s=new Response(b,x);break}f=g,await new Promise(b=>setTimeout(b,this.retry.backoff(y)));}if(!s)throw f??new Error("Exhausted all retries");let h=await s.json();if(!s.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:s}=await e.request({body:this.payload,path:[this.endpoint]});if(s)throw new n(s);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 l=class extends r{constructor([e,t]){super({ids:e,...t},"fetch");}};var u=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 l(e).exec(this.client);reset=()=>new m().exec(this.client);range=e=>new u(e).exec(this.client)};var R=class o 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 s=process?.env.UPSTASH_VECTOR_REST_TOKEN;if(!s)throw new Error("Unable to find environment variable: `UPSTASH_VECTOR_REST_TOKEN`");return new o({...e,url:t,token:s})}};
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(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 l=class extends r{constructor(e){super(e,"upsert");}};var c=class extends r{constructor([e,t]){super({ids:e,...t},"fetch");}};var u=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 l(e).exec(this.client);fetch=(...e)=>new c(e).exec(this.client);reset=()=>new m().exec(this.client);range=e=>new u(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},s=null,f=null;for(let y=0;y<=this.retry.attempts;y++)try{s=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"};s=new Response(b,x);break}f=g,await new Promise(b=>setTimeout(b,this.retry.backoff(y)));}if(!s)throw f??new Error("Exhausted all retries");let h=await s.json();if(!s.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:s}=await e.request({body:this.payload,path:[this.endpoint]});if(s)throw new n(s);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 l=class extends r{constructor([e,t]){super({ids:e,...t},"fetch");}};var u=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 l(e).exec(this.client);reset=()=>new m().exec(this.client);range=e=>new u(e).exec(this.client)};var R=class o 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 s=process?.env.UPSTASH_VECTOR_REST_TOKEN;if(!s)throw new Error("Unable to find environment variable: `UPSTASH_VECTOR_REST_TOKEN`");return new o({...e,url:t,token:s})}};
2
2
 
3
3
  export { R as Index };
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "module": "./dist/index.mjs",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
7
- "version": "v0.1.0-alpha-6",
7
+ "version": "v0.1.0-alpha-7",
8
8
  "keywords": [
9
9
  "vector",
10
10
  "upstash",