@upstash/vector 1.2.2 → 1.2.3

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.
@@ -123,6 +123,7 @@ var Command = class {
123
123
 
124
124
  // src/commands/client/query/query-many/index.ts
125
125
  var QueryManyCommand = class extends Command {
126
+ queryCount;
126
127
  constructor(payload, options) {
127
128
  let endpoint = "query";
128
129
  const hasData = payload.some((p) => p.data);
@@ -131,6 +132,21 @@ var QueryManyCommand = class extends Command {
131
132
  endpoint = `${endpoint}/${options.namespace}`;
132
133
  }
133
134
  super(payload, endpoint);
135
+ this.queryCount = payload.length;
136
+ }
137
+ /**
138
+ * Override exec to normalize the API response.
139
+ *
140
+ * When a single query is sent via queryMany, the API returns a flat
141
+ * array of results instead of a nested array. This ensures the return
142
+ * type is always QueryResult<TMetadata>[][] regardless of query count.
143
+ */
144
+ async exec(client) {
145
+ const result = await super.exec(client);
146
+ if (this.queryCount === 1 && result.length > 0 && !Array.isArray(result[0])) {
147
+ return [result];
148
+ }
149
+ return result;
134
150
  }
135
151
  };
136
152
 
@@ -859,7 +875,7 @@ var Index = class {
859
875
  };
860
876
 
861
877
  // version.ts
862
- var VERSION = "v1.2.2";
878
+ var VERSION = "1.2.3";
863
879
 
864
880
  export {
865
881
  HttpClient,
@@ -1,5 +1,5 @@
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';
1
+ import { H as HttpClientConfig, R as RequesterConfig, D as Dict, I as Index$1 } from './vector-3yYKIF78.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-3yYKIF78.mjs';
3
3
 
4
4
  /**
5
5
  * Connection credentials for upstash vector.
@@ -1,5 +1,5 @@
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';
1
+ import { H as HttpClientConfig, R as RequesterConfig, D as Dict, I as Index$1 } from './vector-3yYKIF78.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-3yYKIF78.js';
3
3
 
4
4
  /**
5
5
  * Connection credentials for upstash vector.
@@ -162,6 +162,7 @@ var DeleteCommand = class extends Command {
162
162
 
163
163
  // src/commands/client/query/query-many/index.ts
164
164
  var QueryManyCommand = class extends Command {
165
+ queryCount;
165
166
  constructor(payload, options) {
166
167
  let endpoint = "query";
167
168
  const hasData = payload.some((p) => p.data);
@@ -170,6 +171,21 @@ var QueryManyCommand = class extends Command {
170
171
  endpoint = `${endpoint}/${options.namespace}`;
171
172
  }
172
173
  super(payload, endpoint);
174
+ this.queryCount = payload.length;
175
+ }
176
+ /**
177
+ * Override exec to normalize the API response.
178
+ *
179
+ * When a single query is sent via queryMany, the API returns a flat
180
+ * array of results instead of a nested array. This ensures the return
181
+ * type is always QueryResult<TMetadata>[][] regardless of query count.
182
+ */
183
+ async exec(client) {
184
+ const result = await super.exec(client);
185
+ if (this.queryCount === 1 && result.length > 0 && !Array.isArray(result[0])) {
186
+ return [result];
187
+ }
188
+ return result;
173
189
  }
174
190
  };
175
191
 
@@ -888,7 +904,7 @@ var Index = class {
888
904
  };
889
905
 
890
906
  // version.ts
891
- var VERSION = "v1.2.2";
907
+ var VERSION = "1.2.3";
892
908
 
893
909
  // src/platforms/cloudflare.ts
894
910
  var Index2 = class _Index extends Index {
@@ -5,7 +5,7 @@ import {
5
5
  QueryMode,
6
6
  VERSION,
7
7
  WeightingStrategy
8
- } from "./chunk-MQ3XJEJ2.mjs";
8
+ } from "./chunk-VZUGHHBV.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 { 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';
1
+ import { H as HttpClientConfig, R as RequesterConfig, D as Dict, I as Index$1, a as Requester } from './vector-3yYKIF78.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-3yYKIF78.mjs';
3
3
 
4
4
  /**
5
5
  * Connection credentials for upstash vector.
package/dist/nodejs.d.ts CHANGED
@@ -1,5 +1,5 @@
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';
1
+ import { H as HttpClientConfig, R as RequesterConfig, D as Dict, I as Index$1, a as Requester } from './vector-3yYKIF78.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-3yYKIF78.js';
3
3
 
4
4
  /**
5
5
  * Connection credentials for upstash vector.
package/dist/nodejs.js CHANGED
@@ -162,6 +162,7 @@ var DeleteCommand = class extends Command {
162
162
 
163
163
  // src/commands/client/query/query-many/index.ts
164
164
  var QueryManyCommand = class extends Command {
165
+ queryCount;
165
166
  constructor(payload, options) {
166
167
  let endpoint = "query";
167
168
  const hasData = payload.some((p) => p.data);
@@ -170,6 +171,21 @@ var QueryManyCommand = class extends Command {
170
171
  endpoint = `${endpoint}/${options.namespace}`;
171
172
  }
172
173
  super(payload, endpoint);
174
+ this.queryCount = payload.length;
175
+ }
176
+ /**
177
+ * Override exec to normalize the API response.
178
+ *
179
+ * When a single query is sent via queryMany, the API returns a flat
180
+ * array of results instead of a nested array. This ensures the return
181
+ * type is always QueryResult<TMetadata>[][] regardless of query count.
182
+ */
183
+ async exec(client) {
184
+ const result = await super.exec(client);
185
+ if (this.queryCount === 1 && result.length > 0 && !Array.isArray(result[0])) {
186
+ return [result];
187
+ }
188
+ return result;
173
189
  }
174
190
  };
175
191
 
@@ -888,7 +904,7 @@ var Index = class {
888
904
  };
889
905
 
890
906
  // version.ts
891
- var VERSION = "v1.2.2";
907
+ var VERSION = "1.2.3";
892
908
 
893
909
  // src/utils/get-runtime.ts
894
910
  function getRuntime() {
package/dist/nodejs.mjs CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  QueryMode,
6
6
  VERSION,
7
7
  WeightingStrategy
8
- } from "./chunk-MQ3XJEJ2.mjs";
8
+ } from "./chunk-VZUGHHBV.mjs";
9
9
 
10
10
  // src/utils/get-runtime.ts
11
11
  function getRuntime() {
@@ -239,7 +239,16 @@ declare enum QueryMode {
239
239
  }
240
240
 
241
241
  declare class QueryManyCommand<TMetadata> extends Command<QueryResult<TMetadata>[][]> {
242
+ private queryCount;
242
243
  constructor(payload: QueryCommandPayload[], options?: QueryCommandOptions);
244
+ /**
245
+ * Override exec to normalize the API response.
246
+ *
247
+ * When a single query is sent via queryMany, the API returns a flat
248
+ * array of results instead of a nested array. This ensures the return
249
+ * type is always QueryResult<TMetadata>[][] regardless of query count.
250
+ */
251
+ exec(client: Requester): Promise<QueryResult<TMetadata>[][]>;
243
252
  }
244
253
 
245
254
  declare class QueryCommand<TMetadata> extends Command<QueryResult<TMetadata>[]> {
@@ -239,7 +239,16 @@ declare enum QueryMode {
239
239
  }
240
240
 
241
241
  declare class QueryManyCommand<TMetadata> extends Command<QueryResult<TMetadata>[][]> {
242
+ private queryCount;
242
243
  constructor(payload: QueryCommandPayload[], options?: QueryCommandOptions);
244
+ /**
245
+ * Override exec to normalize the API response.
246
+ *
247
+ * When a single query is sent via queryMany, the API returns a flat
248
+ * array of results instead of a nested array. This ensures the return
249
+ * type is always QueryResult<TMetadata>[][] regardless of query count.
250
+ */
251
+ exec(client: Requester): Promise<QueryResult<TMetadata>[][]>;
243
252
  }
244
253
 
245
254
  declare class QueryCommand<TMetadata> extends Command<QueryResult<TMetadata>[]> {
package/package.json CHANGED
@@ -1 +1 @@
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" } }
1
+ { "name": "@upstash/vector", "version": "1.2.3", "author": "Oguzhan Olguncu <oguzhan@upstash.com>", "repository": { "type": "git", "url": "git@github.com:upstash/vector-js.git" }, "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" } }