@supabase/storage-js 2.79.1-canary.1 → 2.80.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/README.md +920 -12
- package/dist/main/StorageClient.d.ts +28 -0
- package/dist/main/StorageClient.d.ts.map +1 -1
- package/dist/main/StorageClient.js +38 -5
- package/dist/main/StorageClient.js.map +1 -1
- package/dist/main/index.d.ts +2 -0
- package/dist/main/index.d.ts.map +1 -1
- package/dist/main/index.js +7 -17
- package/dist/main/index.js.map +1 -1
- package/dist/main/lib/constants.d.ts.map +1 -1
- package/dist/main/lib/constants.js +3 -1
- package/dist/main/lib/constants.js.map +1 -1
- package/dist/main/lib/fetch.d.ts.map +1 -1
- package/dist/main/lib/fetch.js +16 -17
- package/dist/main/lib/fetch.js.map +1 -1
- package/dist/main/lib/helpers.d.ts +1 -1
- package/dist/main/lib/helpers.d.ts.map +1 -1
- package/dist/main/lib/helpers.js +4 -57
- package/dist/main/lib/helpers.js.map +1 -1
- package/dist/main/lib/index.d.ts +1 -0
- package/dist/main/lib/index.d.ts.map +1 -1
- package/dist/main/lib/index.js +6 -18
- package/dist/main/lib/index.js.map +1 -1
- package/dist/main/lib/types.d.ts +74 -4
- package/dist/main/lib/types.d.ts.map +1 -1
- package/dist/main/lib/vectors/StorageVectorsClient.d.ts +310 -0
- package/dist/main/lib/vectors/StorageVectorsClient.d.ts.map +1 -0
- package/dist/main/lib/vectors/StorageVectorsClient.js +366 -0
- package/dist/main/lib/vectors/StorageVectorsClient.js.map +1 -0
- package/dist/main/lib/vectors/VectorBucketApi.d.ts +129 -0
- package/dist/main/lib/vectors/VectorBucketApi.d.ts.map +1 -0
- package/dist/main/lib/vectors/VectorBucketApi.js +199 -0
- package/dist/main/lib/vectors/VectorBucketApi.js.map +1 -0
- package/dist/main/lib/vectors/VectorDataApi.d.ts +221 -0
- package/dist/main/lib/vectors/VectorDataApi.d.ts.map +1 -0
- package/dist/main/lib/vectors/VectorDataApi.js +336 -0
- package/dist/main/lib/vectors/VectorDataApi.js.map +1 -0
- package/dist/main/lib/vectors/VectorIndexApi.d.ts +157 -0
- package/dist/main/lib/vectors/VectorIndexApi.d.ts.map +1 -0
- package/dist/main/lib/vectors/VectorIndexApi.js +218 -0
- package/dist/main/lib/vectors/VectorIndexApi.js.map +1 -0
- package/dist/main/lib/vectors/constants.d.ts +5 -0
- package/dist/main/lib/vectors/constants.d.ts.map +1 -0
- package/dist/main/lib/vectors/constants.js +9 -0
- package/dist/main/lib/vectors/constants.js.map +1 -0
- package/dist/main/lib/vectors/errors.d.ts +55 -0
- package/dist/main/lib/vectors/errors.d.ts.map +1 -0
- package/dist/main/lib/vectors/errors.js +76 -0
- package/dist/main/lib/vectors/errors.js.map +1 -0
- package/dist/main/lib/vectors/fetch.d.ts +57 -0
- package/dist/main/lib/vectors/fetch.d.ts.map +1 -0
- package/dist/main/lib/vectors/fetch.js +167 -0
- package/dist/main/lib/vectors/fetch.js.map +1 -0
- package/dist/main/lib/vectors/helpers.d.ts +46 -0
- package/dist/main/lib/vectors/helpers.d.ts.map +1 -0
- package/dist/main/lib/vectors/helpers.js +74 -0
- package/dist/main/lib/vectors/helpers.js.map +1 -0
- package/dist/main/lib/vectors/index.d.ts +11 -0
- package/dist/main/lib/vectors/index.d.ts.map +1 -0
- package/dist/main/lib/vectors/index.js +31 -0
- package/dist/main/lib/vectors/index.js.map +1 -0
- package/dist/main/lib/vectors/types.d.ts +277 -0
- package/dist/main/lib/vectors/types.d.ts.map +1 -0
- package/dist/main/lib/vectors/types.js +3 -0
- package/dist/main/lib/vectors/types.js.map +1 -0
- 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/BlobDownloadBuilder.d.ts +6 -1
- package/dist/main/packages/BlobDownloadBuilder.d.ts.map +1 -1
- package/dist/main/packages/BlobDownloadBuilder.js +20 -15
- package/dist/main/packages/BlobDownloadBuilder.js.map +1 -1
- package/dist/main/packages/StorageAnalyticsApi.d.ts +123 -0
- package/dist/main/packages/StorageAnalyticsApi.d.ts.map +1 -0
- package/dist/main/packages/StorageAnalyticsApi.js +164 -0
- package/dist/main/packages/StorageAnalyticsApi.js.map +1 -0
- package/dist/main/packages/StorageBucketApi.d.ts +3 -2
- package/dist/main/packages/StorageBucketApi.d.ts.map +1 -1
- package/dist/main/packages/StorageBucketApi.js +34 -18
- package/dist/main/packages/StorageBucketApi.js.map +1 -1
- package/dist/main/packages/StorageFileApi.d.ts.map +1 -1
- package/dist/main/packages/StorageFileApi.js +28 -29
- package/dist/main/packages/StorageFileApi.js.map +1 -1
- package/dist/main/packages/StreamDownloadBuilder.js +2 -10
- package/dist/main/packages/StreamDownloadBuilder.js.map +1 -1
- package/dist/module/StorageClient.d.ts +28 -0
- package/dist/module/StorageClient.d.ts.map +1 -1
- package/dist/module/StorageClient.js +35 -0
- package/dist/module/StorageClient.js.map +1 -1
- package/dist/module/index.d.ts +2 -0
- package/dist/module/index.d.ts.map +1 -1
- package/dist/module/index.js +2 -0
- package/dist/module/index.js.map +1 -1
- package/dist/module/lib/constants.d.ts.map +1 -1
- package/dist/module/lib/constants.js +3 -1
- package/dist/module/lib/constants.js.map +1 -1
- package/dist/module/lib/fetch.d.ts.map +1 -1
- package/dist/module/lib/fetch.js +9 -10
- package/dist/module/lib/fetch.js.map +1 -1
- package/dist/module/lib/helpers.d.ts +1 -1
- package/dist/module/lib/helpers.d.ts.map +1 -1
- package/dist/module/lib/helpers.js +4 -24
- package/dist/module/lib/helpers.js.map +1 -1
- package/dist/module/lib/index.d.ts +1 -0
- package/dist/module/lib/index.d.ts.map +1 -1
- package/dist/module/lib/index.js +1 -0
- package/dist/module/lib/index.js.map +1 -1
- package/dist/module/lib/types.d.ts +74 -4
- package/dist/module/lib/types.d.ts.map +1 -1
- package/dist/module/lib/vectors/StorageVectorsClient.d.ts +310 -0
- package/dist/module/lib/vectors/StorageVectorsClient.d.ts.map +1 -0
- package/dist/module/lib/vectors/StorageVectorsClient.js +360 -0
- package/dist/module/lib/vectors/StorageVectorsClient.js.map +1 -0
- package/dist/module/lib/vectors/VectorBucketApi.d.ts +129 -0
- package/dist/module/lib/vectors/VectorBucketApi.d.ts.map +1 -0
- package/dist/module/lib/vectors/VectorBucketApi.js +196 -0
- package/dist/module/lib/vectors/VectorBucketApi.js.map +1 -0
- package/dist/module/lib/vectors/VectorDataApi.d.ts +221 -0
- package/dist/module/lib/vectors/VectorDataApi.d.ts.map +1 -0
- package/dist/module/lib/vectors/VectorDataApi.js +333 -0
- package/dist/module/lib/vectors/VectorDataApi.js.map +1 -0
- package/dist/module/lib/vectors/VectorIndexApi.d.ts +157 -0
- package/dist/module/lib/vectors/VectorIndexApi.d.ts.map +1 -0
- package/dist/module/lib/vectors/VectorIndexApi.js +215 -0
- package/dist/module/lib/vectors/VectorIndexApi.js.map +1 -0
- package/dist/module/lib/vectors/constants.d.ts +5 -0
- package/dist/module/lib/vectors/constants.d.ts.map +1 -0
- package/dist/module/lib/vectors/constants.js +6 -0
- package/dist/module/lib/vectors/constants.js.map +1 -0
- package/dist/module/lib/vectors/errors.d.ts +55 -0
- package/dist/module/lib/vectors/errors.d.ts.map +1 -0
- package/dist/module/lib/vectors/errors.js +69 -0
- package/dist/module/lib/vectors/errors.js.map +1 -0
- package/dist/module/lib/vectors/fetch.d.ts +57 -0
- package/dist/module/lib/vectors/fetch.d.ts.map +1 -0
- package/dist/module/lib/vectors/fetch.js +161 -0
- package/dist/module/lib/vectors/fetch.js.map +1 -0
- package/dist/module/lib/vectors/helpers.d.ts +46 -0
- package/dist/module/lib/vectors/helpers.d.ts.map +1 -0
- package/dist/module/lib/vectors/helpers.js +66 -0
- package/dist/module/lib/vectors/helpers.js.map +1 -0
- package/dist/module/lib/vectors/index.d.ts +11 -0
- package/dist/module/lib/vectors/index.d.ts.map +1 -0
- package/dist/module/lib/vectors/index.js +11 -0
- package/dist/module/lib/vectors/index.js.map +1 -0
- package/dist/module/lib/vectors/types.d.ts +277 -0
- package/dist/module/lib/vectors/types.d.ts.map +1 -0
- package/dist/module/lib/vectors/types.js +2 -0
- package/dist/module/lib/vectors/types.js.map +1 -0
- 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/BlobDownloadBuilder.d.ts +6 -1
- package/dist/module/packages/BlobDownloadBuilder.d.ts.map +1 -1
- package/dist/module/packages/BlobDownloadBuilder.js +20 -11
- package/dist/module/packages/BlobDownloadBuilder.js.map +1 -1
- package/dist/module/packages/StorageAnalyticsApi.d.ts +123 -0
- package/dist/module/packages/StorageAnalyticsApi.d.ts.map +1 -0
- package/dist/module/packages/StorageAnalyticsApi.js +161 -0
- package/dist/module/packages/StorageAnalyticsApi.js.map +1 -0
- package/dist/module/packages/StorageBucketApi.d.ts +3 -2
- package/dist/module/packages/StorageBucketApi.d.ts.map +1 -1
- package/dist/module/packages/StorageBucketApi.js +28 -12
- package/dist/module/packages/StorageBucketApi.js.map +1 -1
- package/dist/module/packages/StorageFileApi.d.ts.map +1 -1
- package/dist/module/packages/StorageFileApi.js +13 -11
- package/dist/module/packages/StorageFileApi.js.map +1 -1
- package/dist/module/packages/StreamDownloadBuilder.js +1 -9
- package/dist/module/packages/StreamDownloadBuilder.js.map +1 -1
- package/dist/tsconfig.module.tsbuildinfo +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/umd/supabase.js +1 -1
- package/package.json +6 -13
- package/src/StorageClient.ts +37 -0
- package/src/index.ts +2 -0
- package/src/lib/constants.ts +3 -1
- package/src/lib/fetch.ts +5 -1
- package/src/lib/helpers.ts +3 -14
- package/src/lib/index.ts +1 -0
- package/src/lib/types.ts +83 -2
- package/src/lib/vectors/StorageVectorsClient.ts +405 -0
- package/src/lib/vectors/VectorBucketApi.ts +217 -0
- package/src/lib/vectors/VectorDataApi.ts +341 -0
- package/src/lib/vectors/VectorIndexApi.ts +245 -0
- package/src/lib/vectors/constants.ts +5 -0
- package/src/lib/vectors/errors.ts +78 -0
- package/src/lib/vectors/fetch.ts +218 -0
- package/src/lib/vectors/helpers.ts +79 -0
- package/src/lib/vectors/index.ts +66 -0
- package/src/lib/vectors/types.ts +299 -0
- package/src/lib/version.ts +1 -1
- package/src/packages/BlobDownloadBuilder.ts +22 -2
- package/src/packages/StorageAnalyticsApi.ts +199 -0
- package/src/packages/StorageBucketApi.ts +29 -4
- package/src/packages/StorageFileApi.ts +15 -2
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
import VectorIndexApi, { CreateIndexOptions } from './VectorIndexApi';
|
|
2
|
+
import VectorDataApi from './VectorDataApi';
|
|
3
|
+
import { Fetch } from './fetch';
|
|
4
|
+
import VectorBucketApi from './VectorBucketApi';
|
|
5
|
+
import { DeleteVectorsOptions, GetVectorsOptions, ListIndexesOptions, ListVectorsOptions, PutVectorsOptions, QueryVectorsOptions } from './types';
|
|
6
|
+
/**
|
|
7
|
+
* Configuration options for the Storage Vectors client
|
|
8
|
+
*/
|
|
9
|
+
export interface StorageVectorsClientOptions {
|
|
10
|
+
/**
|
|
11
|
+
* Custom headers to include in all requests
|
|
12
|
+
*/
|
|
13
|
+
headers?: {
|
|
14
|
+
[key: string]: string;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Custom fetch implementation (optional)
|
|
18
|
+
* Useful for testing or custom request handling
|
|
19
|
+
*/
|
|
20
|
+
fetch?: Fetch;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Main client for interacting with S3 Vectors API
|
|
24
|
+
* Provides access to bucket, index, and vector data operations
|
|
25
|
+
*
|
|
26
|
+
* **Usage Patterns:**
|
|
27
|
+
*
|
|
28
|
+
* 1. **Via StorageClient (recommended for most use cases):**
|
|
29
|
+
* ```typescript
|
|
30
|
+
* import { StorageClient } from '@supabase/storage-js'
|
|
31
|
+
*
|
|
32
|
+
* const storageClient = new StorageClient(url, headers)
|
|
33
|
+
* const vectors = storageClient.vectors
|
|
34
|
+
*
|
|
35
|
+
* // Use vector operations
|
|
36
|
+
* await vectors.createBucket('embeddings-prod')
|
|
37
|
+
* const bucket = vectors.from('embeddings-prod')
|
|
38
|
+
* await bucket.createIndex({ ... })
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* 2. **Standalone (for vector-only applications):**
|
|
42
|
+
* ```typescript
|
|
43
|
+
* import { StorageVectorsClient } from '@supabase/storage-js'
|
|
44
|
+
*
|
|
45
|
+
* const vectorsClient = new StorageVectorsClient('https://api.example.com', {
|
|
46
|
+
* headers: { 'Authorization': 'Bearer token' }
|
|
47
|
+
* })
|
|
48
|
+
*
|
|
49
|
+
* // Access bucket operations
|
|
50
|
+
* await vectorsClient.createBucket('embeddings-prod')
|
|
51
|
+
*
|
|
52
|
+
* // Access index operations via buckets
|
|
53
|
+
* const bucket = vectorsClient.from('embeddings-prod')
|
|
54
|
+
* await bucket.createIndex({
|
|
55
|
+
* indexName: 'documents',
|
|
56
|
+
* dataType: 'float32',
|
|
57
|
+
* dimension: 1536,
|
|
58
|
+
* distanceMetric: 'cosine'
|
|
59
|
+
* })
|
|
60
|
+
*
|
|
61
|
+
* // Access vector operations via index
|
|
62
|
+
* const index = bucket.index('documents')
|
|
63
|
+
* await index.putVectors({
|
|
64
|
+
* vectors: [
|
|
65
|
+
* { key: 'doc-1', data: { float32: [...] }, metadata: { title: 'Intro' } }
|
|
66
|
+
* ]
|
|
67
|
+
* })
|
|
68
|
+
*
|
|
69
|
+
* // Query similar vectors
|
|
70
|
+
* const { data } = await index.queryVectors({
|
|
71
|
+
* queryVector: { float32: [...] },
|
|
72
|
+
* topK: 5,
|
|
73
|
+
* returnDistance: true
|
|
74
|
+
* })
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
export declare class StorageVectorsClient extends VectorBucketApi {
|
|
78
|
+
constructor(url: string, options?: StorageVectorsClientOptions);
|
|
79
|
+
/**
|
|
80
|
+
* Access operations for a specific vector bucket
|
|
81
|
+
* Returns a scoped client for index and vector operations within the bucket
|
|
82
|
+
*
|
|
83
|
+
* @param vectorBucketName - Name of the vector bucket
|
|
84
|
+
* @returns Bucket-scoped client with index and vector operations
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* ```typescript
|
|
88
|
+
* const bucket = client.bucket('embeddings-prod')
|
|
89
|
+
*
|
|
90
|
+
* // Create an index in this bucket
|
|
91
|
+
* await bucket.createIndex({
|
|
92
|
+
* indexName: 'documents-openai',
|
|
93
|
+
* dataType: 'float32',
|
|
94
|
+
* dimension: 1536,
|
|
95
|
+
* distanceMetric: 'cosine'
|
|
96
|
+
* })
|
|
97
|
+
*
|
|
98
|
+
* // List indexes in this bucket
|
|
99
|
+
* const { data } = await bucket.listIndexes()
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
from(vectorBucketName: string): VectorBucketScope;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Scoped client for operations within a specific vector bucket
|
|
106
|
+
* Provides index management and access to vector operations
|
|
107
|
+
*/
|
|
108
|
+
export declare class VectorBucketScope extends VectorIndexApi {
|
|
109
|
+
private vectorBucketName;
|
|
110
|
+
constructor(url: string, headers: {
|
|
111
|
+
[key: string]: string;
|
|
112
|
+
}, vectorBucketName: string, fetch?: Fetch);
|
|
113
|
+
/**
|
|
114
|
+
* Creates a new vector index in this bucket
|
|
115
|
+
* Convenience method that automatically includes the bucket name
|
|
116
|
+
*
|
|
117
|
+
* @param options - Index configuration (vectorBucketName is automatically set)
|
|
118
|
+
* @returns Promise with empty response on success or error
|
|
119
|
+
*
|
|
120
|
+
* @example
|
|
121
|
+
* ```typescript
|
|
122
|
+
* const bucket = client.bucket('embeddings-prod')
|
|
123
|
+
* await bucket.createIndex({
|
|
124
|
+
* indexName: 'documents-openai',
|
|
125
|
+
* dataType: 'float32',
|
|
126
|
+
* dimension: 1536,
|
|
127
|
+
* distanceMetric: 'cosine',
|
|
128
|
+
* metadataConfiguration: {
|
|
129
|
+
* nonFilterableMetadataKeys: ['raw_text']
|
|
130
|
+
* }
|
|
131
|
+
* })
|
|
132
|
+
* ```
|
|
133
|
+
*/
|
|
134
|
+
createIndex(options: Omit<CreateIndexOptions, 'vectorBucketName'>): Promise<import("./types").ApiResponse<undefined>>;
|
|
135
|
+
/**
|
|
136
|
+
* Lists indexes in this bucket
|
|
137
|
+
* Convenience method that automatically includes the bucket name
|
|
138
|
+
*
|
|
139
|
+
* @param options - Listing options (vectorBucketName is automatically set)
|
|
140
|
+
* @returns Promise with list of indexes or error
|
|
141
|
+
*
|
|
142
|
+
* @example
|
|
143
|
+
* ```typescript
|
|
144
|
+
* const bucket = client.bucket('embeddings-prod')
|
|
145
|
+
* const { data } = await bucket.listIndexes({ prefix: 'documents-' })
|
|
146
|
+
* ```
|
|
147
|
+
*/
|
|
148
|
+
listIndexes(options?: Omit<ListIndexesOptions, 'vectorBucketName'>): Promise<import("./types").ApiResponse<import("./types").ListIndexesResponse>>;
|
|
149
|
+
/**
|
|
150
|
+
* Retrieves metadata for a specific index in this bucket
|
|
151
|
+
* Convenience method that automatically includes the bucket name
|
|
152
|
+
*
|
|
153
|
+
* @param indexName - Name of the index to retrieve
|
|
154
|
+
* @returns Promise with index metadata or error
|
|
155
|
+
*
|
|
156
|
+
* @example
|
|
157
|
+
* ```typescript
|
|
158
|
+
* const bucket = client.bucket('embeddings-prod')
|
|
159
|
+
* const { data } = await bucket.getIndex('documents-openai')
|
|
160
|
+
* console.log('Dimension:', data?.index.dimension)
|
|
161
|
+
* ```
|
|
162
|
+
*/
|
|
163
|
+
getIndex(indexName: string): Promise<import("./types").ApiResponse<{
|
|
164
|
+
index: import("./types").VectorIndex;
|
|
165
|
+
}>>;
|
|
166
|
+
/**
|
|
167
|
+
* Deletes an index from this bucket
|
|
168
|
+
* Convenience method that automatically includes the bucket name
|
|
169
|
+
*
|
|
170
|
+
* @param indexName - Name of the index to delete
|
|
171
|
+
* @returns Promise with empty response on success or error
|
|
172
|
+
*
|
|
173
|
+
* @example
|
|
174
|
+
* ```typescript
|
|
175
|
+
* const bucket = client.bucket('embeddings-prod')
|
|
176
|
+
* await bucket.deleteIndex('old-index')
|
|
177
|
+
* ```
|
|
178
|
+
*/
|
|
179
|
+
deleteIndex(indexName: string): Promise<import("./types").ApiResponse<undefined>>;
|
|
180
|
+
/**
|
|
181
|
+
* Access operations for a specific index within this bucket
|
|
182
|
+
* Returns a scoped client for vector data operations
|
|
183
|
+
*
|
|
184
|
+
* @param indexName - Name of the index
|
|
185
|
+
* @returns Index-scoped client with vector data operations
|
|
186
|
+
*
|
|
187
|
+
* @example
|
|
188
|
+
* ```typescript
|
|
189
|
+
* const index = client.bucket('embeddings-prod').index('documents-openai')
|
|
190
|
+
*
|
|
191
|
+
* // Insert vectors
|
|
192
|
+
* await index.putVectors({
|
|
193
|
+
* vectors: [
|
|
194
|
+
* { key: 'doc-1', data: { float32: [...] }, metadata: { title: 'Intro' } }
|
|
195
|
+
* ]
|
|
196
|
+
* })
|
|
197
|
+
*
|
|
198
|
+
* // Query similar vectors
|
|
199
|
+
* const { data } = await index.queryVectors({
|
|
200
|
+
* queryVector: { float32: [...] },
|
|
201
|
+
* topK: 5
|
|
202
|
+
* })
|
|
203
|
+
* ```
|
|
204
|
+
*/
|
|
205
|
+
index(indexName: string): VectorIndexScope;
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Scoped client for operations within a specific vector index
|
|
209
|
+
* Provides vector data operations (put, get, list, query, delete)
|
|
210
|
+
*/
|
|
211
|
+
export declare class VectorIndexScope extends VectorDataApi {
|
|
212
|
+
private vectorBucketName;
|
|
213
|
+
private indexName;
|
|
214
|
+
constructor(url: string, headers: {
|
|
215
|
+
[key: string]: string;
|
|
216
|
+
}, vectorBucketName: string, indexName: string, fetch?: Fetch);
|
|
217
|
+
/**
|
|
218
|
+
* Inserts or updates vectors in this index
|
|
219
|
+
* Convenience method that automatically includes bucket and index names
|
|
220
|
+
*
|
|
221
|
+
* @param options - Vector insertion options (bucket and index names automatically set)
|
|
222
|
+
* @returns Promise with empty response on success or error
|
|
223
|
+
*
|
|
224
|
+
* @example
|
|
225
|
+
* ```typescript
|
|
226
|
+
* const index = client.bucket('embeddings-prod').index('documents-openai')
|
|
227
|
+
* await index.putVectors({
|
|
228
|
+
* vectors: [
|
|
229
|
+
* {
|
|
230
|
+
* key: 'doc-1',
|
|
231
|
+
* data: { float32: [0.1, 0.2, ...] },
|
|
232
|
+
* metadata: { title: 'Introduction', page: 1 }
|
|
233
|
+
* }
|
|
234
|
+
* ]
|
|
235
|
+
* })
|
|
236
|
+
* ```
|
|
237
|
+
*/
|
|
238
|
+
putVectors(options: Omit<PutVectorsOptions, 'vectorBucketName' | 'indexName'>): Promise<import("./types").ApiResponse<undefined>>;
|
|
239
|
+
/**
|
|
240
|
+
* Retrieves vectors by keys from this index
|
|
241
|
+
* Convenience method that automatically includes bucket and index names
|
|
242
|
+
*
|
|
243
|
+
* @param options - Vector retrieval options (bucket and index names automatically set)
|
|
244
|
+
* @returns Promise with array of vectors or error
|
|
245
|
+
*
|
|
246
|
+
* @example
|
|
247
|
+
* ```typescript
|
|
248
|
+
* const index = client.bucket('embeddings-prod').index('documents-openai')
|
|
249
|
+
* const { data } = await index.getVectors({
|
|
250
|
+
* keys: ['doc-1', 'doc-2'],
|
|
251
|
+
* returnMetadata: true
|
|
252
|
+
* })
|
|
253
|
+
* ```
|
|
254
|
+
*/
|
|
255
|
+
getVectors(options: Omit<GetVectorsOptions, 'vectorBucketName' | 'indexName'>): Promise<import("./types").ApiResponse<import("./types").GetVectorsResponse>>;
|
|
256
|
+
/**
|
|
257
|
+
* Lists vectors in this index with pagination
|
|
258
|
+
* Convenience method that automatically includes bucket and index names
|
|
259
|
+
*
|
|
260
|
+
* @param options - Listing options (bucket and index names automatically set)
|
|
261
|
+
* @returns Promise with array of vectors and pagination token
|
|
262
|
+
*
|
|
263
|
+
* @example
|
|
264
|
+
* ```typescript
|
|
265
|
+
* const index = client.bucket('embeddings-prod').index('documents-openai')
|
|
266
|
+
* const { data } = await index.listVectors({
|
|
267
|
+
* maxResults: 500,
|
|
268
|
+
* returnMetadata: true
|
|
269
|
+
* })
|
|
270
|
+
* ```
|
|
271
|
+
*/
|
|
272
|
+
listVectors(options?: Omit<ListVectorsOptions, 'vectorBucketName' | 'indexName'>): Promise<import("./types").ApiResponse<import("./types").ListVectorsResponse>>;
|
|
273
|
+
/**
|
|
274
|
+
* Queries for similar vectors in this index
|
|
275
|
+
* Convenience method that automatically includes bucket and index names
|
|
276
|
+
*
|
|
277
|
+
* @param options - Query options (bucket and index names automatically set)
|
|
278
|
+
* @returns Promise with array of similar vectors ordered by distance
|
|
279
|
+
*
|
|
280
|
+
* @example
|
|
281
|
+
* ```typescript
|
|
282
|
+
* const index = client.bucket('embeddings-prod').index('documents-openai')
|
|
283
|
+
* const { data } = await index.queryVectors({
|
|
284
|
+
* queryVector: { float32: [0.1, 0.2, ...] },
|
|
285
|
+
* topK: 5,
|
|
286
|
+
* filter: { category: 'technical' },
|
|
287
|
+
* returnDistance: true,
|
|
288
|
+
* returnMetadata: true
|
|
289
|
+
* })
|
|
290
|
+
* ```
|
|
291
|
+
*/
|
|
292
|
+
queryVectors(options: Omit<QueryVectorsOptions, 'vectorBucketName' | 'indexName'>): Promise<import("./types").ApiResponse<import("./types").QueryVectorsResponse>>;
|
|
293
|
+
/**
|
|
294
|
+
* Deletes vectors by keys from this index
|
|
295
|
+
* Convenience method that automatically includes bucket and index names
|
|
296
|
+
*
|
|
297
|
+
* @param options - Deletion options (bucket and index names automatically set)
|
|
298
|
+
* @returns Promise with empty response on success or error
|
|
299
|
+
*
|
|
300
|
+
* @example
|
|
301
|
+
* ```typescript
|
|
302
|
+
* const index = client.bucket('embeddings-prod').index('documents-openai')
|
|
303
|
+
* await index.deleteVectors({
|
|
304
|
+
* keys: ['doc-1', 'doc-2', 'doc-3']
|
|
305
|
+
* })
|
|
306
|
+
* ```
|
|
307
|
+
*/
|
|
308
|
+
deleteVectors(options: Omit<DeleteVectorsOptions, 'vectorBucketName' | 'indexName'>): Promise<import("./types").ApiResponse<undefined>>;
|
|
309
|
+
}
|
|
310
|
+
//# sourceMappingURL=StorageVectorsClient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StorageVectorsClient.d.ts","sourceRoot":"","sources":["../../../../src/lib/vectors/StorageVectorsClient.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,EAAE,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AACrE,OAAO,aAAa,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,OAAO,eAAe,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,mBAAmB,EACpB,MAAM,SAAS,CAAA;AAEhB;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC1C;;OAEG;IACH,OAAO,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAA;IACnC;;;OAGG;IACH,KAAK,CAAC,EAAE,KAAK,CAAA;CACd;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,qBAAa,oBAAqB,SAAQ,eAAe;gBAC3C,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE,2BAAgC;IAIlE;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,IAAI,CAAC,gBAAgB,EAAE,MAAM,GAAG,iBAAiB;CAGlD;AAED;;;GAGG;AACH,qBAAa,iBAAkB,SAAQ,cAAc;IACnD,OAAO,CAAC,gBAAgB,CAAQ;gBAG9B,GAAG,EAAE,MAAM,EACX,OAAO,EAAE;QA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E,IAAI,CAAC,mBAAmB,EAAE,kBAAkB,GAAG,WAAW,CAAC;IAStE;;;;;;;;;;;;;;OAcG;IACY,aAAa,CAC1B,OAAO,EAAE,IAAI,CAAC,oBAAoB,EAAE,kBAAkB,GAAG,WAAW,CAAC;CAQxE"}
|
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VectorIndexScope = exports.VectorBucketScope = exports.StorageVectorsClient = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const VectorIndexApi_1 = tslib_1.__importDefault(require("./VectorIndexApi"));
|
|
6
|
+
const VectorDataApi_1 = tslib_1.__importDefault(require("./VectorDataApi"));
|
|
7
|
+
const VectorBucketApi_1 = tslib_1.__importDefault(require("./VectorBucketApi"));
|
|
8
|
+
/**
|
|
9
|
+
* Main client for interacting with S3 Vectors API
|
|
10
|
+
* Provides access to bucket, index, and vector data operations
|
|
11
|
+
*
|
|
12
|
+
* **Usage Patterns:**
|
|
13
|
+
*
|
|
14
|
+
* 1. **Via StorageClient (recommended for most use cases):**
|
|
15
|
+
* ```typescript
|
|
16
|
+
* import { StorageClient } from '@supabase/storage-js'
|
|
17
|
+
*
|
|
18
|
+
* const storageClient = new StorageClient(url, headers)
|
|
19
|
+
* const vectors = storageClient.vectors
|
|
20
|
+
*
|
|
21
|
+
* // Use vector operations
|
|
22
|
+
* await vectors.createBucket('embeddings-prod')
|
|
23
|
+
* const bucket = vectors.from('embeddings-prod')
|
|
24
|
+
* await bucket.createIndex({ ... })
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* 2. **Standalone (for vector-only applications):**
|
|
28
|
+
* ```typescript
|
|
29
|
+
* import { StorageVectorsClient } from '@supabase/storage-js'
|
|
30
|
+
*
|
|
31
|
+
* const vectorsClient = new StorageVectorsClient('https://api.example.com', {
|
|
32
|
+
* headers: { 'Authorization': 'Bearer token' }
|
|
33
|
+
* })
|
|
34
|
+
*
|
|
35
|
+
* // Access bucket operations
|
|
36
|
+
* await vectorsClient.createBucket('embeddings-prod')
|
|
37
|
+
*
|
|
38
|
+
* // Access index operations via buckets
|
|
39
|
+
* const bucket = vectorsClient.from('embeddings-prod')
|
|
40
|
+
* await bucket.createIndex({
|
|
41
|
+
* indexName: 'documents',
|
|
42
|
+
* dataType: 'float32',
|
|
43
|
+
* dimension: 1536,
|
|
44
|
+
* distanceMetric: 'cosine'
|
|
45
|
+
* })
|
|
46
|
+
*
|
|
47
|
+
* // Access vector operations via index
|
|
48
|
+
* const index = bucket.index('documents')
|
|
49
|
+
* await index.putVectors({
|
|
50
|
+
* vectors: [
|
|
51
|
+
* { key: 'doc-1', data: { float32: [...] }, metadata: { title: 'Intro' } }
|
|
52
|
+
* ]
|
|
53
|
+
* })
|
|
54
|
+
*
|
|
55
|
+
* // Query similar vectors
|
|
56
|
+
* const { data } = await index.queryVectors({
|
|
57
|
+
* queryVector: { float32: [...] },
|
|
58
|
+
* topK: 5,
|
|
59
|
+
* returnDistance: true
|
|
60
|
+
* })
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
class StorageVectorsClient extends VectorBucketApi_1.default {
|
|
64
|
+
constructor(url, options = {}) {
|
|
65
|
+
super(url, options.headers || {}, options.fetch);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Access operations for a specific vector bucket
|
|
69
|
+
* Returns a scoped client for index and vector operations within the bucket
|
|
70
|
+
*
|
|
71
|
+
* @param vectorBucketName - Name of the vector bucket
|
|
72
|
+
* @returns Bucket-scoped client with index and vector operations
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```typescript
|
|
76
|
+
* const bucket = client.bucket('embeddings-prod')
|
|
77
|
+
*
|
|
78
|
+
* // Create an index in this bucket
|
|
79
|
+
* await bucket.createIndex({
|
|
80
|
+
* indexName: 'documents-openai',
|
|
81
|
+
* dataType: 'float32',
|
|
82
|
+
* dimension: 1536,
|
|
83
|
+
* distanceMetric: 'cosine'
|
|
84
|
+
* })
|
|
85
|
+
*
|
|
86
|
+
* // List indexes in this bucket
|
|
87
|
+
* const { data } = await bucket.listIndexes()
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
from(vectorBucketName) {
|
|
91
|
+
return new VectorBucketScope(this.url, this.headers, vectorBucketName, this.fetch);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
exports.StorageVectorsClient = StorageVectorsClient;
|
|
95
|
+
/**
|
|
96
|
+
* Scoped client for operations within a specific vector bucket
|
|
97
|
+
* Provides index management and access to vector operations
|
|
98
|
+
*/
|
|
99
|
+
class VectorBucketScope extends VectorIndexApi_1.default {
|
|
100
|
+
constructor(url, headers, vectorBucketName, fetch) {
|
|
101
|
+
super(url, headers, fetch);
|
|
102
|
+
this.vectorBucketName = vectorBucketName;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Creates a new vector index in this bucket
|
|
106
|
+
* Convenience method that automatically includes the bucket name
|
|
107
|
+
*
|
|
108
|
+
* @param options - Index configuration (vectorBucketName is automatically set)
|
|
109
|
+
* @returns Promise with empty response on success or error
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* ```typescript
|
|
113
|
+
* const bucket = client.bucket('embeddings-prod')
|
|
114
|
+
* await bucket.createIndex({
|
|
115
|
+
* indexName: 'documents-openai',
|
|
116
|
+
* dataType: 'float32',
|
|
117
|
+
* dimension: 1536,
|
|
118
|
+
* distanceMetric: 'cosine',
|
|
119
|
+
* metadataConfiguration: {
|
|
120
|
+
* nonFilterableMetadataKeys: ['raw_text']
|
|
121
|
+
* }
|
|
122
|
+
* })
|
|
123
|
+
* ```
|
|
124
|
+
*/
|
|
125
|
+
createIndex(options) {
|
|
126
|
+
const _super = Object.create(null, {
|
|
127
|
+
createIndex: { get: () => super.createIndex }
|
|
128
|
+
});
|
|
129
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
130
|
+
return _super.createIndex.call(this, Object.assign(Object.assign({}, options), { vectorBucketName: this.vectorBucketName }));
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Lists indexes in this bucket
|
|
135
|
+
* Convenience method that automatically includes the bucket name
|
|
136
|
+
*
|
|
137
|
+
* @param options - Listing options (vectorBucketName is automatically set)
|
|
138
|
+
* @returns Promise with list of indexes or error
|
|
139
|
+
*
|
|
140
|
+
* @example
|
|
141
|
+
* ```typescript
|
|
142
|
+
* const bucket = client.bucket('embeddings-prod')
|
|
143
|
+
* const { data } = await bucket.listIndexes({ prefix: 'documents-' })
|
|
144
|
+
* ```
|
|
145
|
+
*/
|
|
146
|
+
listIndexes() {
|
|
147
|
+
const _super = Object.create(null, {
|
|
148
|
+
listIndexes: { get: () => super.listIndexes }
|
|
149
|
+
});
|
|
150
|
+
return tslib_1.__awaiter(this, arguments, void 0, function* (options = {}) {
|
|
151
|
+
return _super.listIndexes.call(this, Object.assign(Object.assign({}, options), { vectorBucketName: this.vectorBucketName }));
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Retrieves metadata for a specific index in this bucket
|
|
156
|
+
* Convenience method that automatically includes the bucket name
|
|
157
|
+
*
|
|
158
|
+
* @param indexName - Name of the index to retrieve
|
|
159
|
+
* @returns Promise with index metadata or error
|
|
160
|
+
*
|
|
161
|
+
* @example
|
|
162
|
+
* ```typescript
|
|
163
|
+
* const bucket = client.bucket('embeddings-prod')
|
|
164
|
+
* const { data } = await bucket.getIndex('documents-openai')
|
|
165
|
+
* console.log('Dimension:', data?.index.dimension)
|
|
166
|
+
* ```
|
|
167
|
+
*/
|
|
168
|
+
getIndex(indexName) {
|
|
169
|
+
const _super = Object.create(null, {
|
|
170
|
+
getIndex: { get: () => super.getIndex }
|
|
171
|
+
});
|
|
172
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
173
|
+
return _super.getIndex.call(this, this.vectorBucketName, indexName);
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Deletes an index from this bucket
|
|
178
|
+
* Convenience method that automatically includes the bucket name
|
|
179
|
+
*
|
|
180
|
+
* @param indexName - Name of the index to delete
|
|
181
|
+
* @returns Promise with empty response on success or error
|
|
182
|
+
*
|
|
183
|
+
* @example
|
|
184
|
+
* ```typescript
|
|
185
|
+
* const bucket = client.bucket('embeddings-prod')
|
|
186
|
+
* await bucket.deleteIndex('old-index')
|
|
187
|
+
* ```
|
|
188
|
+
*/
|
|
189
|
+
deleteIndex(indexName) {
|
|
190
|
+
const _super = Object.create(null, {
|
|
191
|
+
deleteIndex: { get: () => super.deleteIndex }
|
|
192
|
+
});
|
|
193
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
194
|
+
return _super.deleteIndex.call(this, this.vectorBucketName, indexName);
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Access operations for a specific index within this bucket
|
|
199
|
+
* Returns a scoped client for vector data operations
|
|
200
|
+
*
|
|
201
|
+
* @param indexName - Name of the index
|
|
202
|
+
* @returns Index-scoped client with vector data operations
|
|
203
|
+
*
|
|
204
|
+
* @example
|
|
205
|
+
* ```typescript
|
|
206
|
+
* const index = client.bucket('embeddings-prod').index('documents-openai')
|
|
207
|
+
*
|
|
208
|
+
* // Insert vectors
|
|
209
|
+
* await index.putVectors({
|
|
210
|
+
* vectors: [
|
|
211
|
+
* { key: 'doc-1', data: { float32: [...] }, metadata: { title: 'Intro' } }
|
|
212
|
+
* ]
|
|
213
|
+
* })
|
|
214
|
+
*
|
|
215
|
+
* // Query similar vectors
|
|
216
|
+
* const { data } = await index.queryVectors({
|
|
217
|
+
* queryVector: { float32: [...] },
|
|
218
|
+
* topK: 5
|
|
219
|
+
* })
|
|
220
|
+
* ```
|
|
221
|
+
*/
|
|
222
|
+
index(indexName) {
|
|
223
|
+
return new VectorIndexScope(this.url, this.headers, this.vectorBucketName, indexName, this.fetch);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
exports.VectorBucketScope = VectorBucketScope;
|
|
227
|
+
/**
|
|
228
|
+
* Scoped client for operations within a specific vector index
|
|
229
|
+
* Provides vector data operations (put, get, list, query, delete)
|
|
230
|
+
*/
|
|
231
|
+
class VectorIndexScope extends VectorDataApi_1.default {
|
|
232
|
+
constructor(url, headers, vectorBucketName, indexName, fetch) {
|
|
233
|
+
super(url, headers, fetch);
|
|
234
|
+
this.vectorBucketName = vectorBucketName;
|
|
235
|
+
this.indexName = indexName;
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Inserts or updates vectors in this index
|
|
239
|
+
* Convenience method that automatically includes bucket and index names
|
|
240
|
+
*
|
|
241
|
+
* @param options - Vector insertion options (bucket and index names automatically set)
|
|
242
|
+
* @returns Promise with empty response on success or error
|
|
243
|
+
*
|
|
244
|
+
* @example
|
|
245
|
+
* ```typescript
|
|
246
|
+
* const index = client.bucket('embeddings-prod').index('documents-openai')
|
|
247
|
+
* await index.putVectors({
|
|
248
|
+
* vectors: [
|
|
249
|
+
* {
|
|
250
|
+
* key: 'doc-1',
|
|
251
|
+
* data: { float32: [0.1, 0.2, ...] },
|
|
252
|
+
* metadata: { title: 'Introduction', page: 1 }
|
|
253
|
+
* }
|
|
254
|
+
* ]
|
|
255
|
+
* })
|
|
256
|
+
* ```
|
|
257
|
+
*/
|
|
258
|
+
putVectors(options) {
|
|
259
|
+
const _super = Object.create(null, {
|
|
260
|
+
putVectors: { get: () => super.putVectors }
|
|
261
|
+
});
|
|
262
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
263
|
+
return _super.putVectors.call(this, Object.assign(Object.assign({}, options), { vectorBucketName: this.vectorBucketName, indexName: this.indexName }));
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Retrieves vectors by keys from this index
|
|
268
|
+
* Convenience method that automatically includes bucket and index names
|
|
269
|
+
*
|
|
270
|
+
* @param options - Vector retrieval options (bucket and index names automatically set)
|
|
271
|
+
* @returns Promise with array of vectors or error
|
|
272
|
+
*
|
|
273
|
+
* @example
|
|
274
|
+
* ```typescript
|
|
275
|
+
* const index = client.bucket('embeddings-prod').index('documents-openai')
|
|
276
|
+
* const { data } = await index.getVectors({
|
|
277
|
+
* keys: ['doc-1', 'doc-2'],
|
|
278
|
+
* returnMetadata: true
|
|
279
|
+
* })
|
|
280
|
+
* ```
|
|
281
|
+
*/
|
|
282
|
+
getVectors(options) {
|
|
283
|
+
const _super = Object.create(null, {
|
|
284
|
+
getVectors: { get: () => super.getVectors }
|
|
285
|
+
});
|
|
286
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
287
|
+
return _super.getVectors.call(this, Object.assign(Object.assign({}, options), { vectorBucketName: this.vectorBucketName, indexName: this.indexName }));
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Lists vectors in this index with pagination
|
|
292
|
+
* Convenience method that automatically includes bucket and index names
|
|
293
|
+
*
|
|
294
|
+
* @param options - Listing options (bucket and index names automatically set)
|
|
295
|
+
* @returns Promise with array of vectors and pagination token
|
|
296
|
+
*
|
|
297
|
+
* @example
|
|
298
|
+
* ```typescript
|
|
299
|
+
* const index = client.bucket('embeddings-prod').index('documents-openai')
|
|
300
|
+
* const { data } = await index.listVectors({
|
|
301
|
+
* maxResults: 500,
|
|
302
|
+
* returnMetadata: true
|
|
303
|
+
* })
|
|
304
|
+
* ```
|
|
305
|
+
*/
|
|
306
|
+
listVectors() {
|
|
307
|
+
const _super = Object.create(null, {
|
|
308
|
+
listVectors: { get: () => super.listVectors }
|
|
309
|
+
});
|
|
310
|
+
return tslib_1.__awaiter(this, arguments, void 0, function* (options = {}) {
|
|
311
|
+
return _super.listVectors.call(this, Object.assign(Object.assign({}, options), { vectorBucketName: this.vectorBucketName, indexName: this.indexName }));
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Queries for similar vectors in this index
|
|
316
|
+
* Convenience method that automatically includes bucket and index names
|
|
317
|
+
*
|
|
318
|
+
* @param options - Query options (bucket and index names automatically set)
|
|
319
|
+
* @returns Promise with array of similar vectors ordered by distance
|
|
320
|
+
*
|
|
321
|
+
* @example
|
|
322
|
+
* ```typescript
|
|
323
|
+
* const index = client.bucket('embeddings-prod').index('documents-openai')
|
|
324
|
+
* const { data } = await index.queryVectors({
|
|
325
|
+
* queryVector: { float32: [0.1, 0.2, ...] },
|
|
326
|
+
* topK: 5,
|
|
327
|
+
* filter: { category: 'technical' },
|
|
328
|
+
* returnDistance: true,
|
|
329
|
+
* returnMetadata: true
|
|
330
|
+
* })
|
|
331
|
+
* ```
|
|
332
|
+
*/
|
|
333
|
+
queryVectors(options) {
|
|
334
|
+
const _super = Object.create(null, {
|
|
335
|
+
queryVectors: { get: () => super.queryVectors }
|
|
336
|
+
});
|
|
337
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
338
|
+
return _super.queryVectors.call(this, Object.assign(Object.assign({}, options), { vectorBucketName: this.vectorBucketName, indexName: this.indexName }));
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* Deletes vectors by keys from this index
|
|
343
|
+
* Convenience method that automatically includes bucket and index names
|
|
344
|
+
*
|
|
345
|
+
* @param options - Deletion options (bucket and index names automatically set)
|
|
346
|
+
* @returns Promise with empty response on success or error
|
|
347
|
+
*
|
|
348
|
+
* @example
|
|
349
|
+
* ```typescript
|
|
350
|
+
* const index = client.bucket('embeddings-prod').index('documents-openai')
|
|
351
|
+
* await index.deleteVectors({
|
|
352
|
+
* keys: ['doc-1', 'doc-2', 'doc-3']
|
|
353
|
+
* })
|
|
354
|
+
* ```
|
|
355
|
+
*/
|
|
356
|
+
deleteVectors(options) {
|
|
357
|
+
const _super = Object.create(null, {
|
|
358
|
+
deleteVectors: { get: () => super.deleteVectors }
|
|
359
|
+
});
|
|
360
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
361
|
+
return _super.deleteVectors.call(this, Object.assign(Object.assign({}, options), { vectorBucketName: this.vectorBucketName, indexName: this.indexName }));
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
exports.VectorIndexScope = VectorIndexScope;
|
|
366
|
+
//# sourceMappingURL=StorageVectorsClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StorageVectorsClient.js","sourceRoot":"","sources":["../../../../src/lib/vectors/StorageVectorsClient.ts"],"names":[],"mappings":";;;;AAAA,8EAAqE;AACrE,4EAA2C;AAE3C,gFAA+C;AAyB/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,MAAa,oBAAqB,SAAQ,yBAAe;IACvD,YAAY,GAAW,EAAE,UAAuC,EAAE;QAChE,KAAK,CAAC,GAAG,EAAE,OAAO,CAAC,OAAO,IAAI,EAAE,EAAE,OAAO,CAAC,KAAK,CAAC,CAAA;IAClD,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,IAAI,CAAC,gBAAwB;QAC3B,OAAO,IAAI,iBAAiB,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,OAAO,EAAE,gBAAgB,EAAE,IAAI,CAAC,KAAK,CAAC,CAAA;IACpF,CAAC;CACF;AA/BD,oDA+BC;AAED;;;GAGG;AACH,MAAa,iBAAkB,SAAQ,wBAAc;IAGnD,YACE,GAAW,EACX,OAAkC,EAClC,gBAAwB,EACxB,KAAa;QAEb,KAAK,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,CAAC,CAAA;QAC1B,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAA;IAC1C,CAAC;IAED;;;;;;;;;;;;;;;;;;;;OAoBG;IACY,WAAW,CAAC,OAAqD;;;;;YAC9E,OAAO,OAAM,WAAW,4CACnB,OAAO,KACV,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