@upstash/vector 0.1.0-alpha-6 → 0.1.0-alpha-8
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 +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -69,7 +69,7 @@ type QueryCommandPayload = {
|
|
|
69
69
|
includeVectors?: boolean;
|
|
70
70
|
includeMetadata?: boolean;
|
|
71
71
|
};
|
|
72
|
-
type QueryResult<TMetadata
|
|
72
|
+
type QueryResult<TMetadata = Record<string, unknown>> = {
|
|
73
73
|
id: number | string;
|
|
74
74
|
score: number;
|
|
75
75
|
vector: number[];
|
|
@@ -94,7 +94,7 @@ type Vector<TMetadata> = {
|
|
|
94
94
|
metadata?: TMetadata;
|
|
95
95
|
};
|
|
96
96
|
|
|
97
|
-
type FetchResult<TMetadata
|
|
97
|
+
type FetchResult<TMetadata = Record<string, unknown>> = Vector<TMetadata> | null;
|
|
98
98
|
|
|
99
99
|
type RangeCommandPayload = {
|
|
100
100
|
cursor: number | string;
|
|
@@ -102,7 +102,7 @@ type RangeCommandPayload = {
|
|
|
102
102
|
includeVectors?: boolean;
|
|
103
103
|
includeMetadata?: boolean;
|
|
104
104
|
};
|
|
105
|
-
type RangeResult<TMetadata
|
|
105
|
+
type RangeResult<TMetadata = Record<string, unknown>> = {
|
|
106
106
|
nextCursor: string;
|
|
107
107
|
vectors: Vector<TMetadata>[];
|
|
108
108
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -69,7 +69,7 @@ type QueryCommandPayload = {
|
|
|
69
69
|
includeVectors?: boolean;
|
|
70
70
|
includeMetadata?: boolean;
|
|
71
71
|
};
|
|
72
|
-
type QueryResult<TMetadata
|
|
72
|
+
type QueryResult<TMetadata = Record<string, unknown>> = {
|
|
73
73
|
id: number | string;
|
|
74
74
|
score: number;
|
|
75
75
|
vector: number[];
|
|
@@ -94,7 +94,7 @@ type Vector<TMetadata> = {
|
|
|
94
94
|
metadata?: TMetadata;
|
|
95
95
|
};
|
|
96
96
|
|
|
97
|
-
type FetchResult<TMetadata
|
|
97
|
+
type FetchResult<TMetadata = Record<string, unknown>> = Vector<TMetadata> | null;
|
|
98
98
|
|
|
99
99
|
type RangeCommandPayload = {
|
|
100
100
|
cursor: number | string;
|
|
@@ -102,7 +102,7 @@ type RangeCommandPayload = {
|
|
|
102
102
|
includeVectors?: boolean;
|
|
103
103
|
includeMetadata?: boolean;
|
|
104
104
|
};
|
|
105
|
-
type RangeResult<TMetadata
|
|
105
|
+
type RangeResult<TMetadata = Record<string, unknown>> = {
|
|
106
106
|
nextCursor: string;
|
|
107
107
|
vectors: Vector<TMetadata>[];
|
|
108
108
|
};
|
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},
|
|
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},
|
|
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 };
|