@supabase/storage-js 2.84.0 → 2.84.1-canary.0
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/main/StorageClient.d.ts +1 -15
- package/dist/main/StorageClient.d.ts.map +1 -1
- package/dist/main/StorageClient.js +1 -15
- package/dist/main/StorageClient.js.map +1 -1
- package/dist/main/lib/vectors/StorageVectorsClient.d.ts +18 -47
- package/dist/main/lib/vectors/StorageVectorsClient.d.ts.map +1 -1
- package/dist/main/lib/vectors/StorageVectorsClient.js +18 -47
- package/dist/main/lib/vectors/StorageVectorsClient.js.map +1 -1
- package/dist/main/lib/vectors/VectorBucketApi.d.ts +9 -153
- package/dist/main/lib/vectors/VectorBucketApi.d.ts.map +1 -1
- package/dist/main/lib/vectors/VectorBucketApi.js +9 -153
- package/dist/main/lib/vectors/VectorBucketApi.js.map +1 -1
- package/dist/main/lib/vectors/VectorDataApi.d.ts +10 -258
- package/dist/main/lib/vectors/VectorDataApi.d.ts.map +1 -1
- package/dist/main/lib/vectors/VectorDataApi.js +10 -258
- package/dist/main/lib/vectors/VectorDataApi.js.map +1 -1
- package/dist/main/lib/vectors/VectorIndexApi.d.ts +9 -177
- package/dist/main/lib/vectors/VectorIndexApi.d.ts.map +1 -1
- package/dist/main/lib/vectors/VectorIndexApi.js +9 -176
- package/dist/main/lib/vectors/VectorIndexApi.js.map +1 -1
- package/dist/main/lib/version.d.ts +1 -1
- package/dist/main/lib/version.d.ts.map +1 -1
- package/dist/main/lib/version.js +1 -1
- package/dist/main/lib/version.js.map +1 -1
- package/dist/main/packages/StorageAnalyticsClient.d.ts +6 -2
- package/dist/main/packages/StorageAnalyticsClient.d.ts.map +1 -1
- package/dist/main/packages/StorageAnalyticsClient.js +6 -2
- package/dist/main/packages/StorageAnalyticsClient.js.map +1 -1
- package/dist/module/StorageClient.d.ts +1 -15
- package/dist/module/StorageClient.d.ts.map +1 -1
- package/dist/module/StorageClient.js +1 -15
- package/dist/module/StorageClient.js.map +1 -1
- package/dist/module/lib/vectors/StorageVectorsClient.d.ts +18 -47
- package/dist/module/lib/vectors/StorageVectorsClient.d.ts.map +1 -1
- package/dist/module/lib/vectors/StorageVectorsClient.js +18 -47
- package/dist/module/lib/vectors/StorageVectorsClient.js.map +1 -1
- package/dist/module/lib/vectors/VectorBucketApi.d.ts +9 -153
- package/dist/module/lib/vectors/VectorBucketApi.d.ts.map +1 -1
- package/dist/module/lib/vectors/VectorBucketApi.js +9 -153
- package/dist/module/lib/vectors/VectorBucketApi.js.map +1 -1
- package/dist/module/lib/vectors/VectorDataApi.d.ts +10 -258
- package/dist/module/lib/vectors/VectorDataApi.d.ts.map +1 -1
- package/dist/module/lib/vectors/VectorDataApi.js +10 -258
- package/dist/module/lib/vectors/VectorDataApi.js.map +1 -1
- package/dist/module/lib/vectors/VectorIndexApi.d.ts +9 -177
- package/dist/module/lib/vectors/VectorIndexApi.d.ts.map +1 -1
- package/dist/module/lib/vectors/VectorIndexApi.js +9 -176
- package/dist/module/lib/vectors/VectorIndexApi.js.map +1 -1
- package/dist/module/lib/version.d.ts +1 -1
- package/dist/module/lib/version.d.ts.map +1 -1
- package/dist/module/lib/version.js +1 -1
- package/dist/module/lib/version.js.map +1 -1
- package/dist/module/packages/StorageAnalyticsClient.d.ts +6 -2
- package/dist/module/packages/StorageAnalyticsClient.d.ts.map +1 -1
- package/dist/module/packages/StorageAnalyticsClient.js +6 -2
- package/dist/module/packages/StorageAnalyticsClient.js.map +1 -1
- package/dist/tsconfig.module.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/umd/supabase.js +1 -1
- package/package.json +1 -1
- package/src/StorageClient.ts +1 -15
- package/src/lib/vectors/StorageVectorsClient.ts +18 -47
- package/src/lib/vectors/VectorBucketApi.ts +9 -153
- package/src/lib/vectors/VectorDataApi.ts +10 -258
- package/src/lib/vectors/VectorIndexApi.ts +9 -177
- package/src/lib/version.ts +1 -1
- package/src/packages/StorageAnalyticsClient.ts +6 -2
|
@@ -15,13 +15,9 @@ import {
|
|
|
15
15
|
} from './types'
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* API class for managing Vector Data within Vector Indexes
|
|
22
|
-
* Provides methods for inserting, querying, listing, and deleting vector embeddings
|
|
23
|
-
*
|
|
24
|
-
* **Public alpha:** This API is part of a public alpha release and may not be available to your account type.
|
|
18
|
+
* @hidden
|
|
19
|
+
* Base implementation for vector data operations.
|
|
20
|
+
* Use {@link VectorIndexScope} via `supabase.storage.vectors.from('bucket').index('idx')` instead.
|
|
25
21
|
*/
|
|
26
22
|
export default class VectorDataApi {
|
|
27
23
|
protected url: string
|
|
@@ -29,94 +25,20 @@ export default class VectorDataApi {
|
|
|
29
25
|
protected fetch: Fetch
|
|
30
26
|
protected shouldThrowOnError = false
|
|
31
27
|
|
|
32
|
-
/**
|
|
33
|
-
*
|
|
34
|
-
* @alpha
|
|
35
|
-
*
|
|
36
|
-
* Creates a VectorDataApi bound to a Storage Vectors deployment.
|
|
37
|
-
*
|
|
38
|
-
* **Public alpha:** This API is part of a public alpha release and may not be available to your account type.
|
|
39
|
-
*
|
|
40
|
-
* @category Vector Buckets
|
|
41
|
-
* @param url - Base URL for the Storage Vectors API.
|
|
42
|
-
* @param headers - Default headers (for example authentication tokens).
|
|
43
|
-
* @param fetch - Optional custom `fetch` implementation for non-browser runtimes.
|
|
44
|
-
*
|
|
45
|
-
* @example
|
|
46
|
-
* ```typescript
|
|
47
|
-
* const client = new VectorDataApi(url, headers)
|
|
48
|
-
* ```
|
|
49
|
-
*/
|
|
28
|
+
/** Creates a new VectorDataApi instance */
|
|
50
29
|
constructor(url: string, headers: { [key: string]: string } = {}, fetch?: Fetch) {
|
|
51
30
|
this.url = url.replace(/\/$/, '')
|
|
52
31
|
this.headers = { ...DEFAULT_HEADERS, ...headers }
|
|
53
32
|
this.fetch = resolveFetch(fetch)
|
|
54
33
|
}
|
|
55
34
|
|
|
56
|
-
/**
|
|
57
|
-
*
|
|
58
|
-
* @alpha
|
|
59
|
-
*
|
|
60
|
-
* Enable throwing errors instead of returning them in the response
|
|
61
|
-
* When enabled, failed operations will throw instead of returning { data: null, error }
|
|
62
|
-
*
|
|
63
|
-
* **Public alpha:** This API is part of a public alpha release and may not be available to your account type.
|
|
64
|
-
*
|
|
65
|
-
* @category Vector Buckets
|
|
66
|
-
* @returns This instance for method chaining
|
|
67
|
-
* @example
|
|
68
|
-
* ```typescript
|
|
69
|
-
* const client = new VectorDataApi(url, headers)
|
|
70
|
-
* client.throwOnError()
|
|
71
|
-
* const { data } = await client.putVectors(options) // throws on error
|
|
72
|
-
* ```
|
|
73
|
-
*/
|
|
35
|
+
/** Enable throwing errors instead of returning them in the response */
|
|
74
36
|
public throwOnError(): this {
|
|
75
37
|
this.shouldThrowOnError = true
|
|
76
38
|
return this
|
|
77
39
|
}
|
|
78
40
|
|
|
79
|
-
/**
|
|
80
|
-
*
|
|
81
|
-
* @alpha
|
|
82
|
-
*
|
|
83
|
-
* Inserts or updates vectors in batch (upsert operation)
|
|
84
|
-
* Accepts 1-500 vectors per request. Larger batches should be split
|
|
85
|
-
*
|
|
86
|
-
* **Public alpha:** This API is part of a public alpha release and may not be available to your account type.
|
|
87
|
-
*
|
|
88
|
-
* @category Vector Buckets
|
|
89
|
-
* @param options - Vector insertion options
|
|
90
|
-
* @param options.vectorBucketName - Name of the parent vector bucket
|
|
91
|
-
* @param options.indexName - Name of the target index
|
|
92
|
-
* @param options.vectors - Array of vectors to insert/update (1-500 items)
|
|
93
|
-
* @returns Promise with empty response on success or error
|
|
94
|
-
*
|
|
95
|
-
* @throws {StorageVectorsApiError} With code:
|
|
96
|
-
* - `S3VectorConflictException` if duplicate key conflict occurs (HTTP 409)
|
|
97
|
-
* - `S3VectorNotFoundException` if bucket or index doesn't exist (HTTP 404)
|
|
98
|
-
* - `InternalError` for server errors (HTTP 500)
|
|
99
|
-
*
|
|
100
|
-
* @example
|
|
101
|
-
* ```typescript
|
|
102
|
-
* const { data, error } = await client.putVectors({
|
|
103
|
-
* vectorBucketName: 'embeddings-prod',
|
|
104
|
-
* indexName: 'documents-openai-small',
|
|
105
|
-
* vectors: [
|
|
106
|
-
* {
|
|
107
|
-
* key: 'doc-1',
|
|
108
|
-
* data: { float32: [0.1, 0.2, 0.3, ...] }, // 1536 dimensions
|
|
109
|
-
* metadata: { title: 'Introduction', page: 1 }
|
|
110
|
-
* },
|
|
111
|
-
* {
|
|
112
|
-
* key: 'doc-2',
|
|
113
|
-
* data: { float32: [0.4, 0.5, 0.6, ...] },
|
|
114
|
-
* metadata: { title: 'Conclusion', page: 42 }
|
|
115
|
-
* }
|
|
116
|
-
* ]
|
|
117
|
-
* })
|
|
118
|
-
* ```
|
|
119
|
-
*/
|
|
41
|
+
/** Inserts or updates vectors in batch (1-500 per request) */
|
|
120
42
|
async putVectors(options: PutVectorsOptions): Promise<ApiResponse<undefined>> {
|
|
121
43
|
try {
|
|
122
44
|
// Validate batch size
|
|
@@ -139,43 +61,7 @@ export default class VectorDataApi {
|
|
|
139
61
|
}
|
|
140
62
|
}
|
|
141
63
|
|
|
142
|
-
/**
|
|
143
|
-
*
|
|
144
|
-
* @alpha
|
|
145
|
-
*
|
|
146
|
-
* Retrieves vectors by their keys in batch
|
|
147
|
-
* Optionally includes vector data and/or metadata in response
|
|
148
|
-
* Additional permissions required when returning data or metadata
|
|
149
|
-
*
|
|
150
|
-
* **Public alpha:** This API is part of a public alpha release and may not be available to your account type.
|
|
151
|
-
*
|
|
152
|
-
* @category Vector Buckets
|
|
153
|
-
* @param options - Vector retrieval options
|
|
154
|
-
* @param options.vectorBucketName - Name of the parent vector bucket
|
|
155
|
-
* @param options.indexName - Name of the index
|
|
156
|
-
* @param options.keys - Array of vector keys to retrieve
|
|
157
|
-
* @param options.returnData - Whether to include vector embeddings (requires permission)
|
|
158
|
-
* @param options.returnMetadata - Whether to include metadata (requires permission)
|
|
159
|
-
* @returns Promise with array of vectors or error
|
|
160
|
-
*
|
|
161
|
-
* @throws {StorageVectorsApiError} With code:
|
|
162
|
-
* - `S3VectorNotFoundException` if bucket or index doesn't exist (HTTP 404)
|
|
163
|
-
* - `InternalError` for server errors (HTTP 500)
|
|
164
|
-
*
|
|
165
|
-
* @example
|
|
166
|
-
* ```typescript
|
|
167
|
-
* const { data, error } = await client.getVectors({
|
|
168
|
-
* vectorBucketName: 'embeddings-prod',
|
|
169
|
-
* indexName: 'documents-openai-small',
|
|
170
|
-
* keys: ['doc-1', 'doc-2', 'doc-3'],
|
|
171
|
-
* returnData: false, // Don't return embeddings
|
|
172
|
-
* returnMetadata: true // Return metadata only
|
|
173
|
-
* })
|
|
174
|
-
* if (data) {
|
|
175
|
-
* data.vectors.forEach(v => console.log(v.key, v.metadata))
|
|
176
|
-
* }
|
|
177
|
-
* ```
|
|
178
|
-
*/
|
|
64
|
+
/** Retrieves vectors by their keys in batch */
|
|
179
65
|
async getVectors(options: GetVectorsOptions): Promise<ApiResponse<GetVectorsResponse>> {
|
|
180
66
|
try {
|
|
181
67
|
const data = await post(this.fetch, `${this.url}/GetVectors`, options, {
|
|
@@ -193,63 +79,7 @@ export default class VectorDataApi {
|
|
|
193
79
|
}
|
|
194
80
|
}
|
|
195
81
|
|
|
196
|
-
/**
|
|
197
|
-
*
|
|
198
|
-
* @alpha
|
|
199
|
-
*
|
|
200
|
-
* Lists/scans vectors in an index with pagination
|
|
201
|
-
* Supports parallel scanning via segment configuration for high-throughput scenarios
|
|
202
|
-
* Additional permissions required when returning data or metadata
|
|
203
|
-
*
|
|
204
|
-
* **Public alpha:** This API is part of a public alpha release and may not be available to your account type.
|
|
205
|
-
*
|
|
206
|
-
* @category Vector Buckets
|
|
207
|
-
* @param options - Vector listing options
|
|
208
|
-
* @param options.vectorBucketName - Name of the parent vector bucket
|
|
209
|
-
* @param options.indexName - Name of the index
|
|
210
|
-
* @param options.maxResults - Maximum results per page (default: 500, max: 1000)
|
|
211
|
-
* @param options.nextToken - Pagination token from previous response
|
|
212
|
-
* @param options.returnData - Whether to include vector embeddings (requires permission)
|
|
213
|
-
* @param options.returnMetadata - Whether to include metadata (requires permission)
|
|
214
|
-
* @param options.segmentCount - Total parallel segments (1-16) for distributed scanning
|
|
215
|
-
* @param options.segmentIndex - Zero-based segment index (0 to segmentCount-1)
|
|
216
|
-
* @returns Promise with array of vectors, pagination token, or error
|
|
217
|
-
*
|
|
218
|
-
* @throws {StorageVectorsApiError} With code:
|
|
219
|
-
* - `S3VectorNotFoundException` if bucket or index doesn't exist (HTTP 404)
|
|
220
|
-
* - `InternalError` for server errors (HTTP 500)
|
|
221
|
-
*
|
|
222
|
-
* @example
|
|
223
|
-
* ```typescript
|
|
224
|
-
* // Simple pagination
|
|
225
|
-
* let nextToken: string | undefined
|
|
226
|
-
* do {
|
|
227
|
-
* const { data, error } = await client.listVectors({
|
|
228
|
-
* vectorBucketName: 'embeddings-prod',
|
|
229
|
-
* indexName: 'documents-openai-small',
|
|
230
|
-
* maxResults: 500,
|
|
231
|
-
* nextToken,
|
|
232
|
-
* returnMetadata: true
|
|
233
|
-
* })
|
|
234
|
-
* if (error) break
|
|
235
|
-
* console.log('Batch:', data.vectors.length)
|
|
236
|
-
* nextToken = data.nextToken
|
|
237
|
-
* } while (nextToken)
|
|
238
|
-
*
|
|
239
|
-
* // Parallel scanning (4 concurrent workers)
|
|
240
|
-
* const workers = [0, 1, 2, 3].map(async (segmentIndex) => {
|
|
241
|
-
* const { data } = await client.listVectors({
|
|
242
|
-
* vectorBucketName: 'embeddings-prod',
|
|
243
|
-
* indexName: 'documents-openai-small',
|
|
244
|
-
* segmentCount: 4,
|
|
245
|
-
* segmentIndex,
|
|
246
|
-
* returnMetadata: true
|
|
247
|
-
* })
|
|
248
|
-
* return data?.vectors || []
|
|
249
|
-
* })
|
|
250
|
-
* const results = await Promise.all(workers)
|
|
251
|
-
* ```
|
|
252
|
-
*/
|
|
82
|
+
/** Lists vectors in an index with pagination */
|
|
253
83
|
async listVectors(options: ListVectorsOptions): Promise<ApiResponse<ListVectorsResponse>> {
|
|
254
84
|
try {
|
|
255
85
|
// Validate segment configuration
|
|
@@ -279,54 +109,7 @@ export default class VectorDataApi {
|
|
|
279
109
|
}
|
|
280
110
|
}
|
|
281
111
|
|
|
282
|
-
/**
|
|
283
|
-
*
|
|
284
|
-
* @alpha
|
|
285
|
-
*
|
|
286
|
-
* Queries for similar vectors using approximate nearest neighbor (ANN) search
|
|
287
|
-
* Returns top-K most similar vectors based on the configured distance metric
|
|
288
|
-
* Supports optional metadata filtering (requires GetVectors permission)
|
|
289
|
-
*
|
|
290
|
-
* **Public alpha:** This API is part of a public alpha release and may not be available to your account type.
|
|
291
|
-
*
|
|
292
|
-
* @category Vector Buckets
|
|
293
|
-
* @param options - Query options
|
|
294
|
-
* @param options.vectorBucketName - Name of the parent vector bucket
|
|
295
|
-
* @param options.indexName - Name of the index
|
|
296
|
-
* @param options.queryVector - Query embedding to find similar vectors
|
|
297
|
-
* @param options.topK - Number of nearest neighbors to return (default: 10)
|
|
298
|
-
* @param options.filter - Optional JSON filter for metadata (requires GetVectors permission)
|
|
299
|
-
* @param options.returnDistance - Whether to include similarity distances
|
|
300
|
-
* @param options.returnMetadata - Whether to include metadata (requires GetVectors permission)
|
|
301
|
-
* @returns Promise with array of similar vectors ordered by distance
|
|
302
|
-
*
|
|
303
|
-
* @throws {StorageVectorsApiError} With code:
|
|
304
|
-
* - `S3VectorNotFoundException` if bucket or index doesn't exist (HTTP 404)
|
|
305
|
-
* - `InternalError` for server errors (HTTP 500)
|
|
306
|
-
*
|
|
307
|
-
* @example
|
|
308
|
-
* ```typescript
|
|
309
|
-
* // Semantic search with filtering
|
|
310
|
-
* const { data, error } = await client.queryVectors({
|
|
311
|
-
* vectorBucketName: 'embeddings-prod',
|
|
312
|
-
* indexName: 'documents-openai-small',
|
|
313
|
-
* queryVector: { float32: [0.1, 0.2, 0.3, ...] }, // 1536 dimensions
|
|
314
|
-
* topK: 5,
|
|
315
|
-
* filter: {
|
|
316
|
-
* category: 'technical',
|
|
317
|
-
* published: true
|
|
318
|
-
* },
|
|
319
|
-
* returnDistance: true,
|
|
320
|
-
* returnMetadata: true
|
|
321
|
-
* })
|
|
322
|
-
* if (data) {
|
|
323
|
-
* data.matches.forEach(match => {
|
|
324
|
-
* console.log(`${match.key}: distance=${match.distance}`)
|
|
325
|
-
* console.log('Metadata:', match.metadata)
|
|
326
|
-
* })
|
|
327
|
-
* }
|
|
328
|
-
* ```
|
|
329
|
-
*/
|
|
112
|
+
/** Queries for similar vectors using approximate nearest neighbor search */
|
|
330
113
|
async queryVectors(options: QueryVectorsOptions): Promise<ApiResponse<QueryVectorsResponse>> {
|
|
331
114
|
try {
|
|
332
115
|
const data = await post(this.fetch, `${this.url}/QueryVectors`, options, {
|
|
@@ -344,38 +127,7 @@ export default class VectorDataApi {
|
|
|
344
127
|
}
|
|
345
128
|
}
|
|
346
129
|
|
|
347
|
-
/**
|
|
348
|
-
*
|
|
349
|
-
* @alpha
|
|
350
|
-
*
|
|
351
|
-
* Deletes vectors by their keys in batch
|
|
352
|
-
* Accepts 1-500 keys per request
|
|
353
|
-
*
|
|
354
|
-
* **Public alpha:** This API is part of a public alpha release and may not be available to your account type.
|
|
355
|
-
*
|
|
356
|
-
* @category Vector Buckets
|
|
357
|
-
* @param options - Vector deletion options
|
|
358
|
-
* @param options.vectorBucketName - Name of the parent vector bucket
|
|
359
|
-
* @param options.indexName - Name of the index
|
|
360
|
-
* @param options.keys - Array of vector keys to delete (1-500 items)
|
|
361
|
-
* @returns Promise with empty response on success or error
|
|
362
|
-
*
|
|
363
|
-
* @throws {StorageVectorsApiError} With code:
|
|
364
|
-
* - `S3VectorNotFoundException` if bucket or index doesn't exist (HTTP 404)
|
|
365
|
-
* - `InternalError` for server errors (HTTP 500)
|
|
366
|
-
*
|
|
367
|
-
* @example
|
|
368
|
-
* ```typescript
|
|
369
|
-
* const { error } = await client.deleteVectors({
|
|
370
|
-
* vectorBucketName: 'embeddings-prod',
|
|
371
|
-
* indexName: 'documents-openai-small',
|
|
372
|
-
* keys: ['doc-1', 'doc-2', 'doc-3']
|
|
373
|
-
* })
|
|
374
|
-
* if (!error) {
|
|
375
|
-
* console.log('Vectors deleted successfully')
|
|
376
|
-
* }
|
|
377
|
-
* ```
|
|
378
|
-
*/
|
|
130
|
+
/** Deletes vectors by their keys in batch (1-500 per request) */
|
|
379
131
|
async deleteVectors(options: DeleteVectorsOptions): Promise<ApiResponse<undefined>> {
|
|
380
132
|
try {
|
|
381
133
|
// Validate batch size
|
|
@@ -13,7 +13,6 @@ import {
|
|
|
13
13
|
} from './types'
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
|
-
*
|
|
17
16
|
* @alpha
|
|
18
17
|
*
|
|
19
18
|
* Options for creating a vector index
|
|
@@ -30,13 +29,9 @@ export interface CreateIndexOptions {
|
|
|
30
29
|
}
|
|
31
30
|
|
|
32
31
|
/**
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
* API class for managing Vector Indexes within Vector Buckets
|
|
37
|
-
* Provides methods for creating, reading, listing, and deleting vector indexes
|
|
38
|
-
*
|
|
39
|
-
* **Public alpha:** This API is part of a public alpha release and may not be available to your account type.
|
|
32
|
+
* @hidden
|
|
33
|
+
* Base implementation for vector index operations.
|
|
34
|
+
* Use {@link VectorBucketScope} via `supabase.storage.vectors.from('bucket')` instead.
|
|
40
35
|
*/
|
|
41
36
|
export default class VectorIndexApi {
|
|
42
37
|
protected url: string
|
|
@@ -44,92 +39,20 @@ export default class VectorIndexApi {
|
|
|
44
39
|
protected fetch: Fetch
|
|
45
40
|
protected shouldThrowOnError = false
|
|
46
41
|
|
|
47
|
-
/**
|
|
48
|
-
*
|
|
49
|
-
* @alpha
|
|
50
|
-
*
|
|
51
|
-
* Creates an API client for managing vector indexes.
|
|
52
|
-
*
|
|
53
|
-
* **Public alpha:** This API is part of a public alpha release and may not be available to your account type.
|
|
54
|
-
*
|
|
55
|
-
* @category Vector Buckets
|
|
56
|
-
* @param url - Base URL for the Storage Vectors API.
|
|
57
|
-
* @param headers - Default headers sent with each request.
|
|
58
|
-
* @param fetch - Optional custom `fetch` implementation for non-browser runtimes.
|
|
59
|
-
*
|
|
60
|
-
* @example
|
|
61
|
-
* ```typescript
|
|
62
|
-
* const client = new VectorIndexApi(url, headers)
|
|
63
|
-
* ```
|
|
64
|
-
*/
|
|
42
|
+
/** Creates a new VectorIndexApi instance */
|
|
65
43
|
constructor(url: string, headers: { [key: string]: string } = {}, fetch?: Fetch) {
|
|
66
44
|
this.url = url.replace(/\/$/, '')
|
|
67
45
|
this.headers = { ...DEFAULT_HEADERS, ...headers }
|
|
68
46
|
this.fetch = resolveFetch(fetch)
|
|
69
47
|
}
|
|
70
48
|
|
|
71
|
-
/**
|
|
72
|
-
*
|
|
73
|
-
* @alpha
|
|
74
|
-
*
|
|
75
|
-
* Enable throwing errors instead of returning them in the response
|
|
76
|
-
* When enabled, failed operations will throw instead of returning { data: null, error }
|
|
77
|
-
*
|
|
78
|
-
* **Public alpha:** This API is part of a public alpha release and may not be available to your account type.
|
|
79
|
-
*
|
|
80
|
-
* @category Vector Buckets
|
|
81
|
-
* @returns This instance for method chaining
|
|
82
|
-
* @example
|
|
83
|
-
* ```typescript
|
|
84
|
-
* const client = new VectorIndexApi(url, headers)
|
|
85
|
-
* client.throwOnError()
|
|
86
|
-
* const { data } = await client.createIndex(options) // throws on error
|
|
87
|
-
* ```
|
|
88
|
-
*/
|
|
49
|
+
/** Enable throwing errors instead of returning them in the response */
|
|
89
50
|
public throwOnError(): this {
|
|
90
51
|
this.shouldThrowOnError = true
|
|
91
52
|
return this
|
|
92
53
|
}
|
|
93
54
|
|
|
94
|
-
/**
|
|
95
|
-
*
|
|
96
|
-
* @alpha
|
|
97
|
-
*
|
|
98
|
-
* Creates a new vector index within a bucket
|
|
99
|
-
* Defines the schema for vectors including dimensionality, distance metric, and metadata config
|
|
100
|
-
*
|
|
101
|
-
* **Public alpha:** This API is part of a public alpha release and may not be available to your account type.
|
|
102
|
-
*
|
|
103
|
-
* @category Vector Buckets
|
|
104
|
-
* @param options - Index configuration
|
|
105
|
-
* @param options.vectorBucketName - Name of the parent vector bucket
|
|
106
|
-
* @param options.indexName - Unique name for the index within the bucket
|
|
107
|
-
* @param options.dataType - Data type for vector components (currently only 'float32')
|
|
108
|
-
* @param options.dimension - Dimensionality of vectors (e.g., 384, 768, 1536)
|
|
109
|
-
* @param options.distanceMetric - Similarity metric ('cosine', 'euclidean', 'dotproduct')
|
|
110
|
-
* @param options.metadataConfiguration - Optional config for non-filterable metadata keys
|
|
111
|
-
* @returns Promise with empty response on success or error
|
|
112
|
-
*
|
|
113
|
-
* @throws {StorageVectorsApiError} With code:
|
|
114
|
-
* - `S3VectorConflictException` if index already exists (HTTP 409)
|
|
115
|
-
* - `S3VectorMaxIndexesExceeded` if quota exceeded (HTTP 400)
|
|
116
|
-
* - `S3VectorNotFoundException` if bucket doesn't exist (HTTP 404)
|
|
117
|
-
* - `InternalError` for server errors (HTTP 500)
|
|
118
|
-
*
|
|
119
|
-
* @example
|
|
120
|
-
* ```typescript
|
|
121
|
-
* const { data, error } = await client.createIndex({
|
|
122
|
-
* vectorBucketName: 'embeddings-prod',
|
|
123
|
-
* indexName: 'documents-openai-small',
|
|
124
|
-
* dataType: 'float32',
|
|
125
|
-
* dimension: 1536,
|
|
126
|
-
* distanceMetric: 'cosine',
|
|
127
|
-
* metadataConfiguration: {
|
|
128
|
-
* nonFilterableMetadataKeys: ['raw_text', 'internal_id']
|
|
129
|
-
* }
|
|
130
|
-
* })
|
|
131
|
-
* ```
|
|
132
|
-
*/
|
|
55
|
+
/** Creates a new vector index within a bucket */
|
|
133
56
|
async createIndex(options: CreateIndexOptions): Promise<ApiResponse<undefined>> {
|
|
134
57
|
try {
|
|
135
58
|
const data = await post(this.fetch, `${this.url}/CreateIndex`, options, {
|
|
@@ -147,33 +70,7 @@ export default class VectorIndexApi {
|
|
|
147
70
|
}
|
|
148
71
|
}
|
|
149
72
|
|
|
150
|
-
/**
|
|
151
|
-
*
|
|
152
|
-
* @alpha
|
|
153
|
-
*
|
|
154
|
-
* Retrieves metadata for a specific vector index
|
|
155
|
-
* Returns index configuration including dimension, distance metric, and metadata settings
|
|
156
|
-
*
|
|
157
|
-
* **Public alpha:** This API is part of a public alpha release and may not be available to your account type.
|
|
158
|
-
*
|
|
159
|
-
* @category Vector Buckets
|
|
160
|
-
* @param vectorBucketName - Name of the parent vector bucket
|
|
161
|
-
* @param indexName - Name of the index to retrieve
|
|
162
|
-
* @returns Promise with index metadata or error
|
|
163
|
-
*
|
|
164
|
-
* @throws {StorageVectorsApiError} With code:
|
|
165
|
-
* - `S3VectorNotFoundException` if index or bucket doesn't exist (HTTP 404)
|
|
166
|
-
* - `InternalError` for server errors (HTTP 500)
|
|
167
|
-
*
|
|
168
|
-
* @example
|
|
169
|
-
* ```typescript
|
|
170
|
-
* const { data, error } = await client.getIndex('embeddings-prod', 'documents-openai-small')
|
|
171
|
-
* if (data) {
|
|
172
|
-
* console.log('Index dimension:', data.index.dimension)
|
|
173
|
-
* console.log('Distance metric:', data.index.distanceMetric)
|
|
174
|
-
* }
|
|
175
|
-
* ```
|
|
176
|
-
*/
|
|
73
|
+
/** Retrieves metadata for a specific vector index */
|
|
177
74
|
async getIndex(
|
|
178
75
|
vectorBucketName: string,
|
|
179
76
|
indexName: string
|
|
@@ -197,46 +94,7 @@ export default class VectorIndexApi {
|
|
|
197
94
|
}
|
|
198
95
|
}
|
|
199
96
|
|
|
200
|
-
/**
|
|
201
|
-
*
|
|
202
|
-
* @alpha
|
|
203
|
-
*
|
|
204
|
-
* Lists vector indexes within a bucket with optional filtering and pagination
|
|
205
|
-
* Supports prefix-based filtering and paginated results
|
|
206
|
-
*
|
|
207
|
-
* **Public alpha:** This API is part of a public alpha release and may not be available to your account type.
|
|
208
|
-
*
|
|
209
|
-
* @category Vector Buckets
|
|
210
|
-
* @param options - Listing options
|
|
211
|
-
* @param options.vectorBucketName - Name of the parent vector bucket
|
|
212
|
-
* @param options.prefix - Filter indexes by name prefix
|
|
213
|
-
* @param options.maxResults - Maximum results per page (default: 100)
|
|
214
|
-
* @param options.nextToken - Pagination token from previous response
|
|
215
|
-
* @returns Promise with list of indexes and pagination token
|
|
216
|
-
*
|
|
217
|
-
* @throws {StorageVectorsApiError} With code:
|
|
218
|
-
* - `S3VectorNotFoundException` if bucket doesn't exist (HTTP 404)
|
|
219
|
-
* - `InternalError` for server errors (HTTP 500)
|
|
220
|
-
*
|
|
221
|
-
* @example
|
|
222
|
-
* ```typescript
|
|
223
|
-
* // List all indexes in a bucket
|
|
224
|
-
* const { data, error } = await client.listIndexes({
|
|
225
|
-
* vectorBucketName: 'embeddings-prod',
|
|
226
|
-
* prefix: 'documents-'
|
|
227
|
-
* })
|
|
228
|
-
* if (data) {
|
|
229
|
-
* console.log('Found indexes:', data.indexes.map(i => i.indexName))
|
|
230
|
-
* // Fetch next page if available
|
|
231
|
-
* if (data.nextToken) {
|
|
232
|
-
* const next = await client.listIndexes({
|
|
233
|
-
* vectorBucketName: 'embeddings-prod',
|
|
234
|
-
* nextToken: data.nextToken
|
|
235
|
-
* })
|
|
236
|
-
* }
|
|
237
|
-
* }
|
|
238
|
-
* ```
|
|
239
|
-
*/
|
|
97
|
+
/** Lists vector indexes within a bucket with optional filtering and pagination */
|
|
240
98
|
async listIndexes(options: ListIndexesOptions): Promise<ApiResponse<ListIndexesResponse>> {
|
|
241
99
|
try {
|
|
242
100
|
const data = await post(this.fetch, `${this.url}/ListIndexes`, options, {
|
|
@@ -254,33 +112,7 @@ export default class VectorIndexApi {
|
|
|
254
112
|
}
|
|
255
113
|
}
|
|
256
114
|
|
|
257
|
-
/**
|
|
258
|
-
*
|
|
259
|
-
* @alpha
|
|
260
|
-
*
|
|
261
|
-
* Deletes a vector index and all its data
|
|
262
|
-
* This operation removes the index schema and all vectors stored in the index
|
|
263
|
-
*
|
|
264
|
-
* **Public alpha:** This API is part of a public alpha release and may not be available to your account type.
|
|
265
|
-
*
|
|
266
|
-
* @category Vector Buckets
|
|
267
|
-
* @param vectorBucketName - Name of the parent vector bucket
|
|
268
|
-
* @param indexName - Name of the index to delete
|
|
269
|
-
* @returns Promise with empty response on success or error
|
|
270
|
-
*
|
|
271
|
-
* @throws {StorageVectorsApiError} With code:
|
|
272
|
-
* - `S3VectorNotFoundException` if index or bucket doesn't exist (HTTP 404)
|
|
273
|
-
* - `InternalError` for server errors (HTTP 500)
|
|
274
|
-
*
|
|
275
|
-
* @example
|
|
276
|
-
* ```typescript
|
|
277
|
-
* // Delete an index and all its vectors
|
|
278
|
-
* const { error } = await client.deleteIndex('embeddings-prod', 'old-index')
|
|
279
|
-
* if (!error) {
|
|
280
|
-
* console.log('Index deleted successfully')
|
|
281
|
-
* }
|
|
282
|
-
* ```
|
|
283
|
-
*/
|
|
115
|
+
/** Deletes a vector index and all its data */
|
|
284
116
|
async deleteIndex(vectorBucketName: string, indexName: string): Promise<ApiResponse<undefined>> {
|
|
285
117
|
try {
|
|
286
118
|
const data = await post(
|
package/src/lib/version.ts
CHANGED
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
// - Debugging and support (identifying which version is running)
|
|
5
5
|
// - Telemetry and logging (version reporting in errors/analytics)
|
|
6
6
|
// - Ensuring build artifacts match the published package version
|
|
7
|
-
export const version = '2.84.0'
|
|
7
|
+
export const version = '2.84.1-canary.0'
|
|
@@ -77,7 +77,11 @@ export default class StorageAnalyticsClient {
|
|
|
77
77
|
* ```json
|
|
78
78
|
* {
|
|
79
79
|
* "data": {
|
|
80
|
-
* "name": "analytics-data"
|
|
80
|
+
* "name": "analytics-data",
|
|
81
|
+
* "type": "ANALYTICS",
|
|
82
|
+
* "format": "iceberg",
|
|
83
|
+
* "created_at": "2024-05-22T22:26:05.100Z",
|
|
84
|
+
* "updated_at": "2024-05-22T22:26:05.100Z"
|
|
81
85
|
* },
|
|
82
86
|
* "error": null
|
|
83
87
|
* }
|
|
@@ -143,9 +147,9 @@ export default class StorageAnalyticsClient {
|
|
|
143
147
|
* {
|
|
144
148
|
* "data": [
|
|
145
149
|
* {
|
|
146
|
-
* "id": "analytics-data",
|
|
147
150
|
* "name": "analytics-data",
|
|
148
151
|
* "type": "ANALYTICS",
|
|
152
|
+
* "format": "iceberg",
|
|
149
153
|
* "created_at": "2024-05-22T22:26:05.100Z",
|
|
150
154
|
* "updated_at": "2024-05-22T22:26:05.100Z"
|
|
151
155
|
* }
|