@upstash/vector 0.1.0-alpha-7 → 0.1.0-alpha-9
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 +26 -0
- package/dist/index.d.mts +35 -17
- package/dist/index.d.ts +35 -17
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -34
package/README.md
CHANGED
|
@@ -118,6 +118,8 @@ type UpstashRecord = {
|
|
|
118
118
|
};
|
|
119
119
|
```
|
|
120
120
|
|
|
121
|
+
#### Upsert many
|
|
122
|
+
|
|
121
123
|
To upsert some records, you can use the client like so:
|
|
122
124
|
|
|
123
125
|
```typescript
|
|
@@ -141,6 +143,22 @@ const records = [
|
|
|
141
143
|
await index.upsert(records);
|
|
142
144
|
```
|
|
143
145
|
|
|
146
|
+
#### Upsert one
|
|
147
|
+
|
|
148
|
+
```typescript
|
|
149
|
+
const index = new Index();
|
|
150
|
+
|
|
151
|
+
// Prepare your data. The length of each array
|
|
152
|
+
// of vector values must match the dimension of
|
|
153
|
+
// the index where you plan to store them.
|
|
154
|
+
const record = {
|
|
155
|
+
id: "1",
|
|
156
|
+
vector: [0.236, 0.971, 0.559],
|
|
157
|
+
};
|
|
158
|
+
// Upsert the data into your index
|
|
159
|
+
await index.upsert(record);
|
|
160
|
+
```
|
|
161
|
+
|
|
144
162
|
### Querying
|
|
145
163
|
|
|
146
164
|
#### Querying with vector values
|
|
@@ -219,3 +237,11 @@ await index.delete("id-to-delete");
|
|
|
219
237
|
```typescript
|
|
220
238
|
await index.delete(["id-1", "id-2", "id-3"]);
|
|
221
239
|
```
|
|
240
|
+
|
|
241
|
+
### Stats
|
|
242
|
+
|
|
243
|
+
To get statistics of your index, you can use the client like so:
|
|
244
|
+
|
|
245
|
+
```typescript
|
|
246
|
+
await index.stats(["id-1", "id-2", "id-3"]);
|
|
247
|
+
```
|
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,19 +63,27 @@ 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;
|
|
69
77
|
includeVectors?: boolean;
|
|
70
78
|
includeMetadata?: boolean;
|
|
71
79
|
};
|
|
72
|
-
type QueryResult<TMetadata
|
|
80
|
+
type QueryResult<TMetadata = Record<string, unknown>> = {
|
|
73
81
|
id: number | string;
|
|
74
82
|
score: number;
|
|
75
83
|
vector: number[];
|
|
76
84
|
metadata?: TMetadata;
|
|
77
85
|
};
|
|
78
|
-
declare class QueryCommand<TMetadata
|
|
86
|
+
declare class QueryCommand<TMetadata> extends Command<QueryResult<TMetadata>[]> {
|
|
79
87
|
constructor(payload: QueryCommandPayload);
|
|
80
88
|
}
|
|
81
89
|
|
|
@@ -88,28 +96,26 @@ 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> = Vector<TMetadata> | null;
|
|
98
|
-
|
|
99
99
|
type RangeCommandPayload = {
|
|
100
100
|
cursor: number | string;
|
|
101
101
|
limit: number;
|
|
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
|
};
|
|
109
|
-
declare class RangeCommand<TMetadata
|
|
109
|
+
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.
|
|
@@ -160,7 +166,7 @@ declare class Index$1 {
|
|
|
160
166
|
*
|
|
161
167
|
* @returns A promise that resolves with an array of query result objects when the request to query the index is completed.
|
|
162
168
|
*/
|
|
163
|
-
query: (args: CommandArgs<typeof QueryCommand>) => Promise<QueryResult<
|
|
169
|
+
query: (args: CommandArgs<typeof QueryCommand>) => Promise<QueryResult<unknown>[]>;
|
|
164
170
|
/**
|
|
165
171
|
* Upserts (Updates and Inserts) specific items into the index.
|
|
166
172
|
* It's used for adding new items to the index or updating existing ones.
|
|
@@ -207,7 +213,7 @@ declare class Index$1 {
|
|
|
207
213
|
fetch: (ids: string[] | number[], opts: {
|
|
208
214
|
includeMetadata?: boolean | undefined;
|
|
209
215
|
includeVectors?: boolean | undefined;
|
|
210
|
-
}) => Promise<FetchResult<
|
|
216
|
+
}) => Promise<FetchResult<unknown>[]>;
|
|
211
217
|
/**
|
|
212
218
|
* It's used for wiping an entire index.
|
|
213
219
|
*
|
|
@@ -243,7 +249,19 @@ declare class Index$1 {
|
|
|
243
249
|
*
|
|
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
|
-
range: (args: CommandArgs<typeof RangeCommand>) => Promise<RangeResult<
|
|
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
|
/**
|
|
@@ -311,4 +329,4 @@ declare class Index extends Index$1 {
|
|
|
311
329
|
static fromEnv(config?: Omit<IndexConfig, "url" | "token">): Index;
|
|
312
330
|
}
|
|
313
331
|
|
|
314
|
-
export { type FetchResult, Index, type IndexConfig, type QueryResult, type RangeResult, type Requester, type UpstashRequest, type UpstashResponse, type Vector };
|
|
332
|
+
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,19 +63,27 @@ 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;
|
|
69
77
|
includeVectors?: boolean;
|
|
70
78
|
includeMetadata?: boolean;
|
|
71
79
|
};
|
|
72
|
-
type QueryResult<TMetadata
|
|
80
|
+
type QueryResult<TMetadata = Record<string, unknown>> = {
|
|
73
81
|
id: number | string;
|
|
74
82
|
score: number;
|
|
75
83
|
vector: number[];
|
|
76
84
|
metadata?: TMetadata;
|
|
77
85
|
};
|
|
78
|
-
declare class QueryCommand<TMetadata
|
|
86
|
+
declare class QueryCommand<TMetadata> extends Command<QueryResult<TMetadata>[]> {
|
|
79
87
|
constructor(payload: QueryCommandPayload);
|
|
80
88
|
}
|
|
81
89
|
|
|
@@ -88,28 +96,26 @@ 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> = Vector<TMetadata> | null;
|
|
98
|
-
|
|
99
99
|
type RangeCommandPayload = {
|
|
100
100
|
cursor: number | string;
|
|
101
101
|
limit: number;
|
|
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
|
};
|
|
109
|
-
declare class RangeCommand<TMetadata
|
|
109
|
+
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.
|
|
@@ -160,7 +166,7 @@ declare class Index$1 {
|
|
|
160
166
|
*
|
|
161
167
|
* @returns A promise that resolves with an array of query result objects when the request to query the index is completed.
|
|
162
168
|
*/
|
|
163
|
-
query: (args: CommandArgs<typeof QueryCommand>) => Promise<QueryResult<
|
|
169
|
+
query: (args: CommandArgs<typeof QueryCommand>) => Promise<QueryResult<unknown>[]>;
|
|
164
170
|
/**
|
|
165
171
|
* Upserts (Updates and Inserts) specific items into the index.
|
|
166
172
|
* It's used for adding new items to the index or updating existing ones.
|
|
@@ -207,7 +213,7 @@ declare class Index$1 {
|
|
|
207
213
|
fetch: (ids: string[] | number[], opts: {
|
|
208
214
|
includeMetadata?: boolean | undefined;
|
|
209
215
|
includeVectors?: boolean | undefined;
|
|
210
|
-
}) => Promise<FetchResult<
|
|
216
|
+
}) => Promise<FetchResult<unknown>[]>;
|
|
211
217
|
/**
|
|
212
218
|
* It's used for wiping an entire index.
|
|
213
219
|
*
|
|
@@ -243,7 +249,19 @@ declare class Index$1 {
|
|
|
243
249
|
*
|
|
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
|
-
range: (args: CommandArgs<typeof RangeCommand>) => Promise<RangeResult<
|
|
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
|
/**
|
|
@@ -311,4 +329,4 @@ declare class Index extends Index$1 {
|
|
|
311
329
|
static fromEnv(config?: Omit<IndexConfig, "url" | "token">): Index;
|
|
312
330
|
}
|
|
313
331
|
|
|
314
|
-
export { type FetchResult, Index, type IndexConfig, type QueryResult, type RangeResult, type Requester, type UpstashRequest, type UpstashResponse, type Vector };
|
|
332
|
+
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,
|
|
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,x=null;for(let f=0;f<=this.retry.attempts;f++)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"})]),C={status:200,statusText:this.options.signal.reason??"Aborted"};s=new Response(b,C);break}x=g,await new Promise(b=>setTimeout(b,this.retry.backoff(f)));}if(!s)throw x??new Error("Exhausted all retries");let y=await s.json();if(!s.ok)throw new n(`${y.error}, command was: ${JSON.stringify(e.body)}`);return {result:y.result,error:y.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 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 extends r{constructor(){super([],"stats");}};var h=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);stats=()=>new d().exec(this.client)};var R=class o extends h{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},s=null,
|
|
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,x=null;for(let f=0;f<=this.retry.attempts;f++)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"})]),C={status:200,statusText:this.options.signal.reason??"Aborted"};s=new Response(b,C);break}x=g,await new Promise(b=>setTimeout(b,this.retry.backoff(f)));}if(!s)throw x??new Error("Exhausted all retries");let y=await s.json();if(!s.ok)throw new n(`${y.error}, command was: ${JSON.stringify(e.body)}`);return {result:y.result,error:y.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 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 extends r{constructor(){super([],"stats");}};var h=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);stats=()=>new d().exec(this.client)};var R=class o extends h{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
|
@@ -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-7",
|
|
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-9", "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" } }
|