@upstash/vector 1.2.1 → 1.2.2

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.
@@ -31,13 +31,15 @@ var HttpClient = class {
31
31
  };
32
32
  }
33
33
  async request(req) {
34
+ const signal = this.options.signal;
35
+ const isSignalFunction = typeof signal === "function";
34
36
  const requestOptions = {
35
37
  cache: this.options.cache,
36
38
  method: "POST",
37
39
  headers: this.headers,
38
40
  body: JSON.stringify(req.body),
39
41
  keepalive: true,
40
- signal: this.options.signal
42
+ signal: isSignalFunction ? signal() : signal
41
43
  };
42
44
  let res = null;
43
45
  let error = null;
@@ -46,13 +48,15 @@ var HttpClient = class {
46
48
  res = await fetch([this.baseUrl, ...req.path ?? []].join("/"), requestOptions);
47
49
  break;
48
50
  } catch (error_) {
49
- if (this.options.signal?.aborted) {
51
+ if (requestOptions.signal?.aborted && isSignalFunction) {
52
+ throw error_;
53
+ } else if (requestOptions.signal?.aborted) {
50
54
  const myBlob = new Blob([
51
- JSON.stringify({ result: this.options.signal.reason ?? "Aborted" })
55
+ JSON.stringify({ result: requestOptions.signal.reason ?? "Aborted" })
52
56
  ]);
53
57
  const myOptions = {
54
58
  status: 200,
55
- statusText: this.options.signal.reason ?? "Aborted"
59
+ statusText: requestOptions.signal.reason ?? "Aborted"
56
60
  };
57
61
  res = new Response(myBlob, myOptions);
58
62
  break;
@@ -855,7 +859,7 @@ var Index = class {
855
859
  };
856
860
 
857
861
  // version.ts
858
- var VERSION = "v1.2.1";
862
+ var VERSION = "v1.2.2";
859
863
 
860
864
  export {
861
865
  HttpClient,
@@ -1,5 +1,5 @@
1
- import { R as RequesterConfig, D as Dict, I as Index$1 } from './vector-1qEMEEQL.mjs';
2
- export { d as FetchResult, F as FusionAlgorithm, f as InfoResult, Q as QueryMode, e as QueryResult, c as RangeResult, a as Requester, S as SparseVector, U as UpstashRequest, b as UpstashResponse, V as Vector, W as WeightingStrategy } from './vector-1qEMEEQL.mjs';
1
+ import { H as HttpClientConfig, R as RequesterConfig, D as Dict, I as Index$1 } from './vector-7jBuY6ad.mjs';
2
+ export { d as FetchResult, F as FusionAlgorithm, f as InfoResult, Q as QueryMode, e as QueryResult, c as RangeResult, a as Requester, S as SparseVector, U as UpstashRequest, b as UpstashResponse, V as Vector, W as WeightingStrategy } from './vector-7jBuY6ad.mjs';
3
3
 
4
4
  /**
5
5
  * Connection credentials for upstash vector.
@@ -18,7 +18,7 @@ type IndexConfig = {
18
18
  * The signal will allow aborting requests on the fly.
19
19
  * For more check: https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal
20
20
  */
21
- signal?: AbortSignal;
21
+ signal?: HttpClientConfig["signal"];
22
22
  /**
23
23
  * Enable telemetry to help us improve the SDK.
24
24
  * The sdk will send the sdk version, platform and node version as telemetry headers.
@@ -1,5 +1,5 @@
1
- import { R as RequesterConfig, D as Dict, I as Index$1 } from './vector-1qEMEEQL.js';
2
- export { d as FetchResult, F as FusionAlgorithm, f as InfoResult, Q as QueryMode, e as QueryResult, c as RangeResult, a as Requester, S as SparseVector, U as UpstashRequest, b as UpstashResponse, V as Vector, W as WeightingStrategy } from './vector-1qEMEEQL.js';
1
+ import { H as HttpClientConfig, R as RequesterConfig, D as Dict, I as Index$1 } from './vector-7jBuY6ad.js';
2
+ export { d as FetchResult, F as FusionAlgorithm, f as InfoResult, Q as QueryMode, e as QueryResult, c as RangeResult, a as Requester, S as SparseVector, U as UpstashRequest, b as UpstashResponse, V as Vector, W as WeightingStrategy } from './vector-7jBuY6ad.js';
3
3
 
4
4
  /**
5
5
  * Connection credentials for upstash vector.
@@ -18,7 +18,7 @@ type IndexConfig = {
18
18
  * The signal will allow aborting requests on the fly.
19
19
  * For more check: https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal
20
20
  */
21
- signal?: AbortSignal;
21
+ signal?: HttpClientConfig["signal"];
22
22
  /**
23
23
  * Enable telemetry to help us improve the SDK.
24
24
  * The sdk will send the sdk version, platform and node version as telemetry headers.
@@ -60,13 +60,15 @@ var HttpClient = class {
60
60
  };
61
61
  }
62
62
  async request(req) {
63
+ const signal = this.options.signal;
64
+ const isSignalFunction = typeof signal === "function";
63
65
  const requestOptions = {
64
66
  cache: this.options.cache,
65
67
  method: "POST",
66
68
  headers: this.headers,
67
69
  body: JSON.stringify(req.body),
68
70
  keepalive: true,
69
- signal: this.options.signal
71
+ signal: isSignalFunction ? signal() : signal
70
72
  };
71
73
  let res = null;
72
74
  let error = null;
@@ -75,13 +77,15 @@ var HttpClient = class {
75
77
  res = await fetch([this.baseUrl, ...req.path ?? []].join("/"), requestOptions);
76
78
  break;
77
79
  } catch (error_) {
78
- if (this.options.signal?.aborted) {
80
+ if (requestOptions.signal?.aborted && isSignalFunction) {
81
+ throw error_;
82
+ } else if (requestOptions.signal?.aborted) {
79
83
  const myBlob = new Blob([
80
- JSON.stringify({ result: this.options.signal.reason ?? "Aborted" })
84
+ JSON.stringify({ result: requestOptions.signal.reason ?? "Aborted" })
81
85
  ]);
82
86
  const myOptions = {
83
87
  status: 200,
84
- statusText: this.options.signal.reason ?? "Aborted"
88
+ statusText: requestOptions.signal.reason ?? "Aborted"
85
89
  };
86
90
  res = new Response(myBlob, myOptions);
87
91
  break;
@@ -884,7 +888,7 @@ var Index = class {
884
888
  };
885
889
 
886
890
  // version.ts
887
- var VERSION = "v1.2.1";
891
+ var VERSION = "v1.2.2";
888
892
 
889
893
  // src/platforms/cloudflare.ts
890
894
  var Index2 = class _Index extends Index {
@@ -5,7 +5,7 @@ import {
5
5
  QueryMode,
6
6
  VERSION,
7
7
  WeightingStrategy
8
- } from "./chunk-HESEGT2A.mjs";
8
+ } from "./chunk-MQ3XJEJ2.mjs";
9
9
 
10
10
  // src/platforms/cloudflare.ts
11
11
  var Index2 = class _Index extends Index {
package/dist/nodejs.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { R as RequesterConfig, D as Dict, I as Index$1, a as Requester } from './vector-1qEMEEQL.mjs';
2
- export { d as FetchResult, F as FusionAlgorithm, f as InfoResult, Q as QueryMode, e as QueryResult, c as RangeResult, S as SparseVector, U as UpstashRequest, b as UpstashResponse, V as Vector, W as WeightingStrategy } from './vector-1qEMEEQL.mjs';
1
+ import { H as HttpClientConfig, R as RequesterConfig, D as Dict, I as Index$1, a as Requester } from './vector-7jBuY6ad.mjs';
2
+ export { d as FetchResult, F as FusionAlgorithm, f as InfoResult, Q as QueryMode, e as QueryResult, c as RangeResult, S as SparseVector, U as UpstashRequest, b as UpstashResponse, V as Vector, W as WeightingStrategy } from './vector-7jBuY6ad.mjs';
3
3
 
4
4
  /**
5
5
  * Connection credentials for upstash vector.
@@ -18,7 +18,7 @@ type IndexConfig = {
18
18
  * The signal will allow aborting requests on the fly.
19
19
  * For more check: https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal
20
20
  */
21
- signal?: AbortSignal;
21
+ signal?: HttpClientConfig["signal"];
22
22
  /**
23
23
  * Enable telemetry to help us improve the SDK.
24
24
  * The sdk will send the sdk version, platform and node version as telemetry headers.
package/dist/nodejs.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { R as RequesterConfig, D as Dict, I as Index$1, a as Requester } from './vector-1qEMEEQL.js';
2
- export { d as FetchResult, F as FusionAlgorithm, f as InfoResult, Q as QueryMode, e as QueryResult, c as RangeResult, S as SparseVector, U as UpstashRequest, b as UpstashResponse, V as Vector, W as WeightingStrategy } from './vector-1qEMEEQL.js';
1
+ import { H as HttpClientConfig, R as RequesterConfig, D as Dict, I as Index$1, a as Requester } from './vector-7jBuY6ad.js';
2
+ export { d as FetchResult, F as FusionAlgorithm, f as InfoResult, Q as QueryMode, e as QueryResult, c as RangeResult, S as SparseVector, U as UpstashRequest, b as UpstashResponse, V as Vector, W as WeightingStrategy } from './vector-7jBuY6ad.js';
3
3
 
4
4
  /**
5
5
  * Connection credentials for upstash vector.
@@ -18,7 +18,7 @@ type IndexConfig = {
18
18
  * The signal will allow aborting requests on the fly.
19
19
  * For more check: https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal
20
20
  */
21
- signal?: AbortSignal;
21
+ signal?: HttpClientConfig["signal"];
22
22
  /**
23
23
  * Enable telemetry to help us improve the SDK.
24
24
  * The sdk will send the sdk version, platform and node version as telemetry headers.
package/dist/nodejs.js CHANGED
@@ -60,13 +60,15 @@ var HttpClient = class {
60
60
  };
61
61
  }
62
62
  async request(req) {
63
+ const signal = this.options.signal;
64
+ const isSignalFunction = typeof signal === "function";
63
65
  const requestOptions = {
64
66
  cache: this.options.cache,
65
67
  method: "POST",
66
68
  headers: this.headers,
67
69
  body: JSON.stringify(req.body),
68
70
  keepalive: true,
69
- signal: this.options.signal
71
+ signal: isSignalFunction ? signal() : signal
70
72
  };
71
73
  let res = null;
72
74
  let error = null;
@@ -75,13 +77,15 @@ var HttpClient = class {
75
77
  res = await fetch([this.baseUrl, ...req.path ?? []].join("/"), requestOptions);
76
78
  break;
77
79
  } catch (error_) {
78
- if (this.options.signal?.aborted) {
80
+ if (requestOptions.signal?.aborted && isSignalFunction) {
81
+ throw error_;
82
+ } else if (requestOptions.signal?.aborted) {
79
83
  const myBlob = new Blob([
80
- JSON.stringify({ result: this.options.signal.reason ?? "Aborted" })
84
+ JSON.stringify({ result: requestOptions.signal.reason ?? "Aborted" })
81
85
  ]);
82
86
  const myOptions = {
83
87
  status: 200,
84
- statusText: this.options.signal.reason ?? "Aborted"
88
+ statusText: requestOptions.signal.reason ?? "Aborted"
85
89
  };
86
90
  res = new Response(myBlob, myOptions);
87
91
  break;
@@ -884,7 +888,7 @@ var Index = class {
884
888
  };
885
889
 
886
890
  // version.ts
887
- var VERSION = "v1.2.1";
891
+ var VERSION = "v1.2.2";
888
892
 
889
893
  // src/utils/get-runtime.ts
890
894
  function getRuntime() {
package/dist/nodejs.mjs CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  QueryMode,
6
6
  VERSION,
7
7
  WeightingStrategy
8
- } from "./chunk-HESEGT2A.mjs";
8
+ } from "./chunk-MQ3XJEJ2.mjs";
9
9
 
10
10
  // src/utils/get-runtime.ts
11
11
  function getRuntime() {
@@ -41,6 +41,12 @@ type RequesterConfig = {
41
41
  */
42
42
  cache?: CacheSetting;
43
43
  };
44
+ type HttpClientConfig = {
45
+ headers?: Record<string, string>;
46
+ baseUrl: string;
47
+ retry?: RetryConfig;
48
+ signal?: AbortSignal | (() => AbortSignal);
49
+ } & RequesterConfig;
44
50
 
45
51
  type Vector<TMetadata = Dict> = {
46
52
  id: string;
@@ -905,4 +911,4 @@ declare class Index<TIndexMetadata extends Dict = Dict> {
905
911
  deleteNamespace: (namespace: string) => Promise<string>;
906
912
  }
907
913
 
908
- export { type Dict as D, FusionAlgorithm as F, Index as I, QueryMode as Q, type RequesterConfig as R, type SparseVector as S, type UpstashRequest as U, type Vector as V, WeightingStrategy as W, type Requester as a, type UpstashResponse as b, type RangeResult as c, type FetchResult as d, type QueryResult as e, type InfoResult as f };
914
+ export { type Dict as D, FusionAlgorithm as F, type HttpClientConfig as H, Index as I, QueryMode as Q, type RequesterConfig as R, type SparseVector as S, type UpstashRequest as U, type Vector as V, WeightingStrategy as W, type Requester as a, type UpstashResponse as b, type RangeResult as c, type FetchResult as d, type QueryResult as e, type InfoResult as f };
@@ -41,6 +41,12 @@ type RequesterConfig = {
41
41
  */
42
42
  cache?: CacheSetting;
43
43
  };
44
+ type HttpClientConfig = {
45
+ headers?: Record<string, string>;
46
+ baseUrl: string;
47
+ retry?: RetryConfig;
48
+ signal?: AbortSignal | (() => AbortSignal);
49
+ } & RequesterConfig;
44
50
 
45
51
  type Vector<TMetadata = Dict> = {
46
52
  id: string;
@@ -905,4 +911,4 @@ declare class Index<TIndexMetadata extends Dict = Dict> {
905
911
  deleteNamespace: (namespace: string) => Promise<string>;
906
912
  }
907
913
 
908
- export { type Dict as D, FusionAlgorithm as F, Index as I, QueryMode as Q, type RequesterConfig as R, type SparseVector as S, type UpstashRequest as U, type Vector as V, WeightingStrategy as W, type Requester as a, type UpstashResponse as b, type RangeResult as c, type FetchResult as d, type QueryResult as e, type InfoResult as f };
914
+ export { type Dict as D, FusionAlgorithm as F, type HttpClientConfig as H, Index as I, QueryMode as Q, type RequesterConfig as R, type SparseVector as S, type UpstashRequest as U, type Vector as V, WeightingStrategy as W, type Requester as a, type UpstashResponse as b, type RangeResult as c, type FetchResult as d, type QueryResult as e, type InfoResult as f };
package/package.json CHANGED
@@ -1 +1 @@
1
- { "name": "@upstash/vector", "version": "v1.2.1", "author": "Oguzhan Olguncu <oguzhan@upstash.com>", "repository": { "type": "git", "url": "https://github.com/upstash/vector-js" }, "exports": { ".": { "import": "./dist/nodejs.mjs", "require": "./dist/nodejs.js" }, "./cloudflare": { "import": "./dist/cloudflare.mjs", "require": "./dist/cloudflare.js" }, "./nodejs": { "import": "./dist/nodejs.mjs", "require": "./dist/nodejs.js" } }, "main": "./dist/nodejs.js", "module": "./dist/nodejs.mjs", "types": "./dist/nodejs.d.ts", "devDependencies": { "@commitlint/cli": "^18.6.0", "@commitlint/config-conventional": "^18.6.0", "@typescript-eslint/eslint-plugin": "^8.4.0", "bun-types": "latest", "eslint": "9.10.0", "eslint-plugin-unicorn": "^55.0.0", "husky": "^8.0.3", "prettier": "^3.3.3", "tsup": "latest", "typescript": "^5.0.0", "vitest": "^1.2.2" }, "bugs": { "url": "https://github.com/upstash/vector/issues" }, "description": "An HTTP/REST based Vector DB client built on top of Upstash REST API.", "files": [ "dist" ], "homepage": "https://upstash.com/vector", "keywords": [ "vector", "upstash", "db" ], "license": "MIT", "scripts": { "test": "bun test src --coverage --bail --coverageSkipTestFiles=[test-utils.ts] --timeout 20000", "fmt": "prettier --write .", "lint": "tsc && eslint \"src/**/*.{js,ts,tsx}\" --quiet --fix", "build": "tsup ", "prepare": "husky install" } }
1
+ { "name": "@upstash/vector", "version": "v1.2.2", "author": "Oguzhan Olguncu <oguzhan@upstash.com>", "repository": { "type": "git", "url": "https://github.com/upstash/vector-js" }, "exports": { ".": { "import": "./dist/nodejs.mjs", "require": "./dist/nodejs.js" }, "./cloudflare": { "import": "./dist/cloudflare.mjs", "require": "./dist/cloudflare.js" }, "./nodejs": { "import": "./dist/nodejs.mjs", "require": "./dist/nodejs.js" } }, "main": "./dist/nodejs.js", "module": "./dist/nodejs.mjs", "types": "./dist/nodejs.d.ts", "devDependencies": { "@commitlint/cli": "^18.6.0", "@commitlint/config-conventional": "^18.6.0", "@typescript-eslint/eslint-plugin": "^8.4.0", "bun-types": "latest", "eslint": "9.10.0", "eslint-plugin-unicorn": "^55.0.0", "husky": "^8.0.3", "prettier": "^3.3.3", "tsup": "latest", "typescript": "^5.0.0", "vitest": "^1.2.2" }, "bugs": { "url": "https://github.com/upstash/vector/issues" }, "description": "An HTTP/REST based Vector DB client built on top of Upstash REST API.", "files": [ "dist" ], "homepage": "https://upstash.com/vector", "keywords": [ "vector", "upstash", "db" ], "license": "MIT", "scripts": { "test": "bun test src --coverage --bail --coverageSkipTestFiles=[test-utils.ts] --timeout 20000", "fmt": "prettier --write .", "lint": "tsc && eslint \"src/**/*.{js,ts,tsx}\" --quiet --fix", "build": "tsup ", "prepare": "husky install" } }