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

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/README.md CHANGED
@@ -33,7 +33,7 @@ When these environment variables are set, the client constructor does not requir
33
33
  ```typescript
34
34
  import { fromEnv } from "@upstash/vector";
35
35
 
36
- const index = fromEnv();
36
+ const index = new Index();
37
37
  ```
38
38
 
39
39
  #### Using a configuration object
@@ -54,24 +54,20 @@ const index = new Index({
54
54
 
55
55
  Upstash vector indexes support operations for working with vector data using operations such as upsert, query, fetch, and delete.
56
56
 
57
- ### Targeting an index
57
+ ### Accessing an index
58
58
 
59
- To perform data operations on an index, you target it using the `index` method.
59
+ To perform data operations on an index, access it using the `index` method.
60
60
 
61
61
  ```typescript
62
- const index = new Index();
63
-
64
62
  // Now perform index operations
65
63
  await index.fetch([1, 2, 3], { includeMetadata: true, includeVectors: true });
66
64
  ```
67
65
 
68
- ### Targeting an index, with metadata typing
66
+ ### Accesing an index, with metadata typing
69
67
 
70
68
  If you are storing metadata alongside your vector values, you can pass a type parameter to `index()` in order to get proper TypeScript typechecking.
71
69
 
72
70
  ```typescript
73
- const index = new Index();
74
-
75
71
  type Metadata = {
76
72
  title: string,
77
73
  genre: 'sci-fi' | 'fantasy' | 'horror' | 'action'
@@ -118,11 +114,11 @@ type UpstashRecord = {
118
114
  };
119
115
  ```
120
116
 
117
+ #### Upsert many
118
+
121
119
  To upsert some records, you can use the client like so:
122
120
 
123
121
  ```typescript
124
- const index = new Index();
125
-
126
122
  // Prepare your data. The length of each array
127
123
  // of vector values must match the dimension of
128
124
  // the index where you plan to store them.
@@ -141,6 +137,20 @@ const records = [
141
137
  await index.upsert(records);
142
138
  ```
143
139
 
140
+ #### Upsert one
141
+
142
+ ```typescript
143
+ // Prepare your data. The length of each array
144
+ // of vector values must match the dimension of
145
+ // the index where you plan to store them.
146
+ const record = {
147
+ id: "1",
148
+ vector: [0.236, 0.971, 0.559],
149
+ };
150
+ // Upsert the data into your index
151
+ await index.upsert(record);
152
+ ```
153
+
144
154
  ### Querying
145
155
 
146
156
  #### Querying with vector values
@@ -219,3 +229,37 @@ await index.delete("id-to-delete");
219
229
  ```typescript
220
230
  await index.delete(["id-1", "id-2", "id-3"]);
221
231
  ```
232
+
233
+ ### Stats
234
+
235
+ To get statistics of your index, you can use the client like so:
236
+
237
+ ```typescript
238
+ await index.stats(["id-1", "id-2", "id-3"]);
239
+ ```
240
+
241
+ ## Contributing
242
+
243
+ ## Preparing the environment
244
+
245
+ This project uses [Bun](https://bun.sh/) for packaging and dependency management. Make sure you have the relevant dependencies.
246
+
247
+ You will also need a vector database on [Upstash](https://console.upstash.com/).
248
+
249
+ ```commandline
250
+ curl -fsSL https://bun.sh/install | bash
251
+ ```
252
+
253
+ ## Code Formatting
254
+
255
+ ```bash
256
+ bun run fmt
257
+ ```
258
+
259
+ ## Running tests
260
+
261
+ To run all the tests, make sure you have the relevant environment variables.
262
+
263
+ ```bash
264
+ bun run test
265
+ ```
package/dist/index.d.mts CHANGED
@@ -42,7 +42,7 @@ type RequesterConfig = {
42
42
  cache?: CacheSetting;
43
43
  };
44
44
 
45
- declare const ENDPOINTS: readonly ["upsert", "query", "delete", "fetch", "reset", "range"];
45
+ declare const ENDPOINTS: readonly ["upsert", "query", "delete", "fetch", "reset", "range", "stats"];
46
46
  type EndpointVariants = (typeof ENDPOINTS)[number];
47
47
  /**
48
48
  * TResult is the raw data returned from upstash, which may need to be transformed or parsed.
@@ -63,6 +63,14 @@ declare class DeleteCommand extends Command<{
63
63
  constructor(id: (number[] | string[]) | number | string);
64
64
  }
65
65
 
66
+ type Vector<TMetadata = Record<string, unknown>> = {
67
+ id: string;
68
+ vector: number[];
69
+ metadata?: TMetadata;
70
+ };
71
+
72
+ type FetchResult<TMetadata = Record<string, unknown>> = Vector<TMetadata> | null;
73
+
66
74
  type QueryCommandPayload = {
67
75
  vector: number[];
68
76
  topK: number;
@@ -88,14 +96,6 @@ declare class UpsertCommand extends Command<string> {
88
96
  constructor(payload: UpsertCommandPayload | UpsertCommandPayload[]);
89
97
  }
90
98
 
91
- type Vector<TMetadata> = {
92
- id: string;
93
- vector: number[];
94
- metadata?: TMetadata;
95
- };
96
-
97
- type FetchResult<TMetadata = Record<string, unknown>> = Vector<TMetadata> | null;
98
-
99
99
  type RangeCommandPayload = {
100
100
  cursor: number | string;
101
101
  limit: number;
@@ -110,6 +110,12 @@ declare class RangeCommand<TMetadata> extends Command<RangeResult<TMetadata>> {
110
110
  constructor(payload: RangeCommandPayload);
111
111
  }
112
112
 
113
+ type StatsResult = {
114
+ vectorCount: number;
115
+ pendingVectorCount: number;
116
+ indexSize: number;
117
+ };
118
+
113
119
  type CommandArgs<TCommand extends new (_args: any) => any> = ConstructorParameters<TCommand>[0];
114
120
  /**
115
121
  * Serverless vector client for upstash vector db.
@@ -244,6 +250,18 @@ declare class Index$1 {
244
250
  * @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
251
  */
246
252
  range: (args: CommandArgs<typeof RangeCommand>) => Promise<RangeResult<unknown>>;
253
+ /**
254
+ * Retrieves stats from the index.
255
+ *
256
+ * @example
257
+ * ```js
258
+ * const statResults = await index.stats();
259
+ * console.log(statResults); // Outputs the result of the stats operation
260
+ * ```
261
+ *
262
+ * @returns {Promise<RangeReturnResponse<TMetadata>>} A promise that resolves with the response containing the vectorCount, pendingVectorCount, indexSize after the command is executed.
263
+ */
264
+ stats: () => Promise<StatsResult>;
247
265
  }
248
266
 
249
267
  /**
@@ -279,6 +297,11 @@ declare class Index extends Index$1 {
279
297
  * token: "<UPSTASH_VECTOR_REST_TOKEN>",
280
298
  * });
281
299
  * ```
300
+ * OR
301
+ * This will automatically get environment variables from .env file
302
+ * ```typescript
303
+ * const index = new Index();
304
+ * ```
282
305
  */
283
306
  constructor(config: IndexConfig);
284
307
  /**
@@ -311,4 +334,4 @@ declare class Index extends Index$1 {
311
334
  static fromEnv(config?: Omit<IndexConfig, "url" | "token">): Index;
312
335
  }
313
336
 
314
- export { type FetchResult, Index, type IndexConfig, type QueryResult, type RangeResult, type Requester, type UpstashRequest, type UpstashResponse, type Vector };
337
+ export { type FetchResult, Index, type IndexConfig, type QueryResult, type RangeResult, type Requester, type StatsResult, type UpstashRequest, type UpstashResponse, type Vector };
package/dist/index.d.ts CHANGED
@@ -42,7 +42,7 @@ type RequesterConfig = {
42
42
  cache?: CacheSetting;
43
43
  };
44
44
 
45
- declare const ENDPOINTS: readonly ["upsert", "query", "delete", "fetch", "reset", "range"];
45
+ declare const ENDPOINTS: readonly ["upsert", "query", "delete", "fetch", "reset", "range", "stats"];
46
46
  type EndpointVariants = (typeof ENDPOINTS)[number];
47
47
  /**
48
48
  * TResult is the raw data returned from upstash, which may need to be transformed or parsed.
@@ -63,6 +63,14 @@ declare class DeleteCommand extends Command<{
63
63
  constructor(id: (number[] | string[]) | number | string);
64
64
  }
65
65
 
66
+ type Vector<TMetadata = Record<string, unknown>> = {
67
+ id: string;
68
+ vector: number[];
69
+ metadata?: TMetadata;
70
+ };
71
+
72
+ type FetchResult<TMetadata = Record<string, unknown>> = Vector<TMetadata> | null;
73
+
66
74
  type QueryCommandPayload = {
67
75
  vector: number[];
68
76
  topK: number;
@@ -88,14 +96,6 @@ declare class UpsertCommand extends Command<string> {
88
96
  constructor(payload: UpsertCommandPayload | UpsertCommandPayload[]);
89
97
  }
90
98
 
91
- type Vector<TMetadata> = {
92
- id: string;
93
- vector: number[];
94
- metadata?: TMetadata;
95
- };
96
-
97
- type FetchResult<TMetadata = Record<string, unknown>> = Vector<TMetadata> | null;
98
-
99
99
  type RangeCommandPayload = {
100
100
  cursor: number | string;
101
101
  limit: number;
@@ -110,6 +110,12 @@ declare class RangeCommand<TMetadata> extends Command<RangeResult<TMetadata>> {
110
110
  constructor(payload: RangeCommandPayload);
111
111
  }
112
112
 
113
+ type StatsResult = {
114
+ vectorCount: number;
115
+ pendingVectorCount: number;
116
+ indexSize: number;
117
+ };
118
+
113
119
  type CommandArgs<TCommand extends new (_args: any) => any> = ConstructorParameters<TCommand>[0];
114
120
  /**
115
121
  * Serverless vector client for upstash vector db.
@@ -244,6 +250,18 @@ declare class Index$1 {
244
250
  * @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
251
  */
246
252
  range: (args: CommandArgs<typeof RangeCommand>) => Promise<RangeResult<unknown>>;
253
+ /**
254
+ * Retrieves stats from the index.
255
+ *
256
+ * @example
257
+ * ```js
258
+ * const statResults = await index.stats();
259
+ * console.log(statResults); // Outputs the result of the stats operation
260
+ * ```
261
+ *
262
+ * @returns {Promise<RangeReturnResponse<TMetadata>>} A promise that resolves with the response containing the vectorCount, pendingVectorCount, indexSize after the command is executed.
263
+ */
264
+ stats: () => Promise<StatsResult>;
247
265
  }
248
266
 
249
267
  /**
@@ -279,6 +297,11 @@ declare class Index extends Index$1 {
279
297
  * token: "<UPSTASH_VECTOR_REST_TOKEN>",
280
298
  * });
281
299
  * ```
300
+ * OR
301
+ * This will automatically get environment variables from .env file
302
+ * ```typescript
303
+ * const index = new Index();
304
+ * ```
282
305
  */
283
306
  constructor(config: IndexConfig);
284
307
  /**
@@ -311,4 +334,4 @@ declare class Index extends Index$1 {
311
334
  static fromEnv(config?: Omit<IndexConfig, "url" | "token">): Index;
312
335
  }
313
336
 
314
- export { type FetchResult, Index, type IndexConfig, type QueryResult, type RangeResult, type Requester, type UpstashRequest, type UpstashResponse, type Vector };
337
+ export { type FetchResult, Index, type IndexConfig, type QueryResult, type RangeResult, type Requester, type StatsResult, 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},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})}};
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})}};
4
4
 
5
- exports.Index = R;
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 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})}};
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})}};
2
2
 
3
- export { R as Index };
3
+ export { x as Index };
package/package.json CHANGED
@@ -1,34 +1 @@
1
- {
2
- "name": "@upstash/vector",
3
- "description": "An HTTP/REST based Vector DB client built on top of Upstash REST API.",
4
- "module": "./dist/index.mjs",
5
- "main": "./dist/index.js",
6
- "types": "./dist/index.d.ts",
7
- "version": "v0.1.0-alpha-8",
8
- "keywords": [
9
- "vector",
10
- "upstash",
11
- "db"
12
- ],
13
- "author": "Oguzhan Olguncu <oguzhan@upstash.com>",
14
- "license": "MIT",
15
- "files": [
16
- "dist"
17
- ],
18
- "bugs": {
19
- "url": "https://github.com/upstash/vector/issues"
20
- },
21
- "scripts": {
22
- "test": "bun test src --coverage --bail --coverageSkipTestFiles=[test-utils.ts]",
23
- "fmt": "bunx biome check --apply ./src",
24
- "build": "tsup",
25
- "prepare": "husky install"
26
- },
27
- "devDependencies": {
28
- "typescript": "^5.0.0",
29
- "@biomejs/biome": "^1.4.1",
30
- "bun-types": "latest",
31
- "husky": "^8.0.3",
32
- "tsup": "latest"
33
- }
34
- }
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" } }