@supabase/storage-js 2.75.1 → 2.75.2-canary.1

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.
Files changed (176) hide show
  1. package/README.md +917 -12
  2. package/dist/main/StorageClient.d.ts +28 -0
  3. package/dist/main/StorageClient.d.ts.map +1 -1
  4. package/dist/main/StorageClient.js +38 -5
  5. package/dist/main/StorageClient.js.map +1 -1
  6. package/dist/main/index.d.ts +2 -0
  7. package/dist/main/index.d.ts.map +1 -1
  8. package/dist/main/index.js +7 -17
  9. package/dist/main/index.js.map +1 -1
  10. package/dist/main/lib/constants.d.ts.map +1 -1
  11. package/dist/main/lib/constants.js +3 -1
  12. package/dist/main/lib/constants.js.map +1 -1
  13. package/dist/main/lib/fetch.js +8 -16
  14. package/dist/main/lib/fetch.js.map +1 -1
  15. package/dist/main/lib/helpers.js +4 -45
  16. package/dist/main/lib/helpers.js.map +1 -1
  17. package/dist/main/lib/index.d.ts +1 -0
  18. package/dist/main/lib/index.d.ts.map +1 -1
  19. package/dist/main/lib/index.js +6 -18
  20. package/dist/main/lib/index.js.map +1 -1
  21. package/dist/main/lib/types.d.ts +36 -4
  22. package/dist/main/lib/types.d.ts.map +1 -1
  23. package/dist/main/lib/vectors/StorageVectorsClient.d.ts +310 -0
  24. package/dist/main/lib/vectors/StorageVectorsClient.d.ts.map +1 -0
  25. package/dist/main/lib/vectors/StorageVectorsClient.js +366 -0
  26. package/dist/main/lib/vectors/StorageVectorsClient.js.map +1 -0
  27. package/dist/main/lib/vectors/VectorBucketApi.d.ts +129 -0
  28. package/dist/main/lib/vectors/VectorBucketApi.d.ts.map +1 -0
  29. package/dist/main/lib/vectors/VectorBucketApi.js +199 -0
  30. package/dist/main/lib/vectors/VectorBucketApi.js.map +1 -0
  31. package/dist/main/lib/vectors/VectorDataApi.d.ts +221 -0
  32. package/dist/main/lib/vectors/VectorDataApi.d.ts.map +1 -0
  33. package/dist/main/lib/vectors/VectorDataApi.js +336 -0
  34. package/dist/main/lib/vectors/VectorDataApi.js.map +1 -0
  35. package/dist/main/lib/vectors/VectorIndexApi.d.ts +157 -0
  36. package/dist/main/lib/vectors/VectorIndexApi.d.ts.map +1 -0
  37. package/dist/main/lib/vectors/VectorIndexApi.js +218 -0
  38. package/dist/main/lib/vectors/VectorIndexApi.js.map +1 -0
  39. package/dist/main/lib/vectors/constants.d.ts +5 -0
  40. package/dist/main/lib/vectors/constants.d.ts.map +1 -0
  41. package/dist/main/lib/vectors/constants.js +9 -0
  42. package/dist/main/lib/vectors/constants.js.map +1 -0
  43. package/dist/main/lib/vectors/errors.d.ts +55 -0
  44. package/dist/main/lib/vectors/errors.d.ts.map +1 -0
  45. package/dist/main/lib/vectors/errors.js +76 -0
  46. package/dist/main/lib/vectors/errors.js.map +1 -0
  47. package/dist/main/lib/vectors/fetch.d.ts +57 -0
  48. package/dist/main/lib/vectors/fetch.d.ts.map +1 -0
  49. package/dist/main/lib/vectors/fetch.js +167 -0
  50. package/dist/main/lib/vectors/fetch.js.map +1 -0
  51. package/dist/main/lib/vectors/helpers.d.ts +49 -0
  52. package/dist/main/lib/vectors/helpers.d.ts.map +1 -0
  53. package/dist/main/lib/vectors/helpers.js +89 -0
  54. package/dist/main/lib/vectors/helpers.js.map +1 -0
  55. package/dist/main/lib/vectors/index.d.ts +11 -0
  56. package/dist/main/lib/vectors/index.d.ts.map +1 -0
  57. package/dist/main/lib/vectors/index.js +31 -0
  58. package/dist/main/lib/vectors/index.js.map +1 -0
  59. package/dist/main/lib/vectors/types.d.ts +277 -0
  60. package/dist/main/lib/vectors/types.d.ts.map +1 -0
  61. package/dist/main/lib/vectors/types.js +3 -0
  62. package/dist/main/lib/vectors/types.js.map +1 -0
  63. package/dist/main/lib/version.d.ts +1 -1
  64. package/dist/main/lib/version.d.ts.map +1 -1
  65. package/dist/main/lib/version.js +1 -1
  66. package/dist/main/lib/version.js.map +1 -1
  67. package/dist/main/packages/BlobDownloadBuilder.js +3 -14
  68. package/dist/main/packages/BlobDownloadBuilder.js.map +1 -1
  69. package/dist/main/packages/StorageAnalyticsApi.d.ts +123 -0
  70. package/dist/main/packages/StorageAnalyticsApi.d.ts.map +1 -0
  71. package/dist/main/packages/StorageAnalyticsApi.js +168 -0
  72. package/dist/main/packages/StorageAnalyticsApi.js.map +1 -0
  73. package/dist/main/packages/StorageBucketApi.js +7 -15
  74. package/dist/main/packages/StorageBucketApi.js.map +1 -1
  75. package/dist/main/packages/StorageFileApi.js +16 -27
  76. package/dist/main/packages/StorageFileApi.js.map +1 -1
  77. package/dist/main/packages/StreamDownloadBuilder.js +2 -10
  78. package/dist/main/packages/StreamDownloadBuilder.js.map +1 -1
  79. package/dist/module/StorageClient.d.ts +28 -0
  80. package/dist/module/StorageClient.d.ts.map +1 -1
  81. package/dist/module/StorageClient.js +35 -0
  82. package/dist/module/StorageClient.js.map +1 -1
  83. package/dist/module/index.d.ts +2 -0
  84. package/dist/module/index.d.ts.map +1 -1
  85. package/dist/module/index.js +2 -0
  86. package/dist/module/index.js.map +1 -1
  87. package/dist/module/lib/constants.d.ts.map +1 -1
  88. package/dist/module/lib/constants.js +3 -1
  89. package/dist/module/lib/constants.js.map +1 -1
  90. package/dist/module/lib/fetch.js +1 -9
  91. package/dist/module/lib/fetch.js.map +1 -1
  92. package/dist/module/lib/helpers.js +1 -9
  93. package/dist/module/lib/helpers.js.map +1 -1
  94. package/dist/module/lib/index.d.ts +1 -0
  95. package/dist/module/lib/index.d.ts.map +1 -1
  96. package/dist/module/lib/index.js +1 -0
  97. package/dist/module/lib/index.js.map +1 -1
  98. package/dist/module/lib/types.d.ts +36 -4
  99. package/dist/module/lib/types.d.ts.map +1 -1
  100. package/dist/module/lib/vectors/StorageVectorsClient.d.ts +310 -0
  101. package/dist/module/lib/vectors/StorageVectorsClient.d.ts.map +1 -0
  102. package/dist/module/lib/vectors/StorageVectorsClient.js +360 -0
  103. package/dist/module/lib/vectors/StorageVectorsClient.js.map +1 -0
  104. package/dist/module/lib/vectors/VectorBucketApi.d.ts +129 -0
  105. package/dist/module/lib/vectors/VectorBucketApi.d.ts.map +1 -0
  106. package/dist/module/lib/vectors/VectorBucketApi.js +196 -0
  107. package/dist/module/lib/vectors/VectorBucketApi.js.map +1 -0
  108. package/dist/module/lib/vectors/VectorDataApi.d.ts +221 -0
  109. package/dist/module/lib/vectors/VectorDataApi.d.ts.map +1 -0
  110. package/dist/module/lib/vectors/VectorDataApi.js +333 -0
  111. package/dist/module/lib/vectors/VectorDataApi.js.map +1 -0
  112. package/dist/module/lib/vectors/VectorIndexApi.d.ts +157 -0
  113. package/dist/module/lib/vectors/VectorIndexApi.d.ts.map +1 -0
  114. package/dist/module/lib/vectors/VectorIndexApi.js +215 -0
  115. package/dist/module/lib/vectors/VectorIndexApi.js.map +1 -0
  116. package/dist/module/lib/vectors/constants.d.ts +5 -0
  117. package/dist/module/lib/vectors/constants.d.ts.map +1 -0
  118. package/dist/module/lib/vectors/constants.js +6 -0
  119. package/dist/module/lib/vectors/constants.js.map +1 -0
  120. package/dist/module/lib/vectors/errors.d.ts +55 -0
  121. package/dist/module/lib/vectors/errors.d.ts.map +1 -0
  122. package/dist/module/lib/vectors/errors.js +69 -0
  123. package/dist/module/lib/vectors/errors.js.map +1 -0
  124. package/dist/module/lib/vectors/fetch.d.ts +57 -0
  125. package/dist/module/lib/vectors/fetch.d.ts.map +1 -0
  126. package/dist/module/lib/vectors/fetch.js +161 -0
  127. package/dist/module/lib/vectors/fetch.js.map +1 -0
  128. package/dist/module/lib/vectors/helpers.d.ts +49 -0
  129. package/dist/module/lib/vectors/helpers.d.ts.map +1 -0
  130. package/dist/module/lib/vectors/helpers.js +81 -0
  131. package/dist/module/lib/vectors/helpers.js.map +1 -0
  132. package/dist/module/lib/vectors/index.d.ts +11 -0
  133. package/dist/module/lib/vectors/index.d.ts.map +1 -0
  134. package/dist/module/lib/vectors/index.js +11 -0
  135. package/dist/module/lib/vectors/index.js.map +1 -0
  136. package/dist/module/lib/vectors/types.d.ts +277 -0
  137. package/dist/module/lib/vectors/types.d.ts.map +1 -0
  138. package/dist/module/lib/vectors/types.js +2 -0
  139. package/dist/module/lib/vectors/types.js.map +1 -0
  140. package/dist/module/lib/version.d.ts +1 -1
  141. package/dist/module/lib/version.d.ts.map +1 -1
  142. package/dist/module/lib/version.js +1 -1
  143. package/dist/module/lib/version.js.map +1 -1
  144. package/dist/module/packages/BlobDownloadBuilder.js +1 -9
  145. package/dist/module/packages/BlobDownloadBuilder.js.map +1 -1
  146. package/dist/module/packages/StorageAnalyticsApi.d.ts +123 -0
  147. package/dist/module/packages/StorageAnalyticsApi.d.ts.map +1 -0
  148. package/dist/module/packages/StorageAnalyticsApi.js +165 -0
  149. package/dist/module/packages/StorageAnalyticsApi.js.map +1 -0
  150. package/dist/module/packages/StorageBucketApi.js +1 -9
  151. package/dist/module/packages/StorageBucketApi.js.map +1 -1
  152. package/dist/module/packages/StorageFileApi.js +1 -9
  153. package/dist/module/packages/StorageFileApi.js.map +1 -1
  154. package/dist/module/packages/StreamDownloadBuilder.js +1 -9
  155. package/dist/module/packages/StreamDownloadBuilder.js.map +1 -1
  156. package/dist/tsconfig.module.tsbuildinfo +1 -0
  157. package/dist/tsconfig.tsbuildinfo +1 -0
  158. package/dist/umd/supabase.js +1 -1
  159. package/package.json +2 -2
  160. package/src/StorageClient.ts +37 -0
  161. package/src/index.ts +2 -0
  162. package/src/lib/constants.ts +3 -1
  163. package/src/lib/index.ts +1 -0
  164. package/src/lib/types.ts +39 -2
  165. package/src/lib/vectors/StorageVectorsClient.ts +405 -0
  166. package/src/lib/vectors/VectorBucketApi.ts +217 -0
  167. package/src/lib/vectors/VectorDataApi.ts +341 -0
  168. package/src/lib/vectors/VectorIndexApi.ts +245 -0
  169. package/src/lib/vectors/constants.ts +5 -0
  170. package/src/lib/vectors/errors.ts +78 -0
  171. package/src/lib/vectors/fetch.ts +218 -0
  172. package/src/lib/vectors/helpers.ts +93 -0
  173. package/src/lib/vectors/index.ts +66 -0
  174. package/src/lib/vectors/types.ts +299 -0
  175. package/src/lib/version.ts +1 -1
  176. package/src/packages/StorageAnalyticsApi.ts +202 -0
@@ -0,0 +1,218 @@
1
+ import { StorageVectorsApiError, StorageVectorsUnknownError } from './errors'
2
+ import { isPlainObject, resolveResponse } from './helpers'
3
+ import { VectorFetchParameters } from './types'
4
+
5
+ export type Fetch = typeof fetch
6
+
7
+ /**
8
+ * Options for fetch requests
9
+ * @property headers - Custom HTTP headers
10
+ * @property noResolveJson - If true, return raw Response instead of parsing JSON
11
+ */
12
+ export interface FetchOptions {
13
+ headers?: {
14
+ [key: string]: string
15
+ }
16
+ noResolveJson?: boolean
17
+ }
18
+
19
+ /**
20
+ * HTTP methods supported by the API
21
+ */
22
+ export type RequestMethodType = 'GET' | 'POST' | 'PUT' | 'DELETE'
23
+
24
+ /**
25
+ * Extracts error message from various error response formats
26
+ * @param err - Error object from API
27
+ * @returns Human-readable error message
28
+ */
29
+ const _getErrorMessage = (err: any): string =>
30
+ err.msg || err.message || err.error_description || err.error || JSON.stringify(err)
31
+
32
+ /**
33
+ * Handles fetch errors and converts them to StorageVectors error types
34
+ * @param error - The error caught from fetch
35
+ * @param reject - Promise rejection function
36
+ * @param options - Fetch options that may affect error handling
37
+ */
38
+ const handleError = async (
39
+ error: unknown,
40
+ reject: (reason?: any) => void,
41
+ options?: FetchOptions
42
+ ) => {
43
+ // Check if error is a Response-like object (has status and ok properties)
44
+ // This is more reliable than instanceof which can fail across realms
45
+ const isResponseLike =
46
+ error &&
47
+ typeof error === 'object' &&
48
+ 'status' in error &&
49
+ 'ok' in error &&
50
+ typeof (error as any).status === 'number'
51
+
52
+ if (isResponseLike && !options?.noResolveJson) {
53
+ const status = (error as any).status || 500
54
+ const responseError = error as any
55
+
56
+ // Try to parse JSON body if available
57
+ if (typeof responseError.json === 'function') {
58
+ responseError
59
+ .json()
60
+ .then((err: any) => {
61
+ const statusCode = err?.statusCode || err?.code || status + ''
62
+ reject(new StorageVectorsApiError(_getErrorMessage(err), status, statusCode))
63
+ })
64
+ .catch(() => {
65
+ // If JSON parsing fails, create an ApiError with the HTTP status code
66
+ const statusCode = status + ''
67
+ const message = responseError.statusText || `HTTP ${status} error`
68
+ reject(new StorageVectorsApiError(message, status, statusCode))
69
+ })
70
+ } else {
71
+ // No json() method available, create error from status
72
+ const statusCode = status + ''
73
+ const message = responseError.statusText || `HTTP ${status} error`
74
+ reject(new StorageVectorsApiError(message, status, statusCode))
75
+ }
76
+ } else {
77
+ reject(new StorageVectorsUnknownError(_getErrorMessage(error), error))
78
+ }
79
+ }
80
+
81
+ /**
82
+ * Builds request parameters for fetch calls
83
+ * @param method - HTTP method
84
+ * @param options - Custom fetch options
85
+ * @param parameters - Additional fetch parameters like AbortSignal
86
+ * @param body - Request body (will be JSON stringified if plain object)
87
+ * @returns Complete fetch request parameters
88
+ */
89
+ const _getRequestParams = (
90
+ method: RequestMethodType,
91
+ options?: FetchOptions,
92
+ parameters?: VectorFetchParameters,
93
+ body?: object
94
+ ) => {
95
+ const params: { [k: string]: any } = { method, headers: options?.headers || {} }
96
+
97
+ if (method === 'GET' || !body) {
98
+ return params
99
+ }
100
+
101
+ if (isPlainObject(body)) {
102
+ params.headers = { 'Content-Type': 'application/json', ...options?.headers }
103
+ params.body = JSON.stringify(body)
104
+ } else {
105
+ params.body = body
106
+ }
107
+
108
+ return { ...params, ...parameters }
109
+ }
110
+
111
+ /**
112
+ * Internal request handler that wraps fetch with error handling
113
+ * @param fetcher - Fetch function to use
114
+ * @param method - HTTP method
115
+ * @param url - Request URL
116
+ * @param options - Custom fetch options
117
+ * @param parameters - Additional fetch parameters
118
+ * @param body - Request body
119
+ * @returns Promise with parsed response or error
120
+ */
121
+ async function _handleRequest(
122
+ fetcher: Fetch,
123
+ method: RequestMethodType,
124
+ url: string,
125
+ options?: FetchOptions,
126
+ parameters?: VectorFetchParameters,
127
+ body?: object
128
+ ): Promise<any> {
129
+ return new Promise((resolve, reject) => {
130
+ fetcher(url, _getRequestParams(method, options, parameters, body))
131
+ .then((result) => {
132
+ if (!result.ok) throw result
133
+ if (options?.noResolveJson) return result
134
+ // Handle empty responses (204, empty body)
135
+ const contentType = result.headers.get('content-type')
136
+ if (!contentType || !contentType.includes('application/json')) {
137
+ return {}
138
+ }
139
+ return result.json()
140
+ })
141
+ .then((data) => resolve(data))
142
+ .catch((error) => handleError(error, reject, options))
143
+ })
144
+ }
145
+
146
+ /**
147
+ * Performs a GET request
148
+ * @param fetcher - Fetch function to use
149
+ * @param url - Request URL
150
+ * @param options - Custom fetch options
151
+ * @param parameters - Additional fetch parameters
152
+ * @returns Promise with parsed response
153
+ */
154
+ export async function get(
155
+ fetcher: Fetch,
156
+ url: string,
157
+ options?: FetchOptions,
158
+ parameters?: VectorFetchParameters
159
+ ): Promise<any> {
160
+ return _handleRequest(fetcher, 'GET', url, options, parameters)
161
+ }
162
+
163
+ /**
164
+ * Performs a POST request
165
+ * @param fetcher - Fetch function to use
166
+ * @param url - Request URL
167
+ * @param body - Request body to be JSON stringified
168
+ * @param options - Custom fetch options
169
+ * @param parameters - Additional fetch parameters
170
+ * @returns Promise with parsed response
171
+ */
172
+ export async function post(
173
+ fetcher: Fetch,
174
+ url: string,
175
+ body: object,
176
+ options?: FetchOptions,
177
+ parameters?: VectorFetchParameters
178
+ ): Promise<any> {
179
+ return _handleRequest(fetcher, 'POST', url, options, parameters, body)
180
+ }
181
+
182
+ /**
183
+ * Performs a PUT request
184
+ * @param fetcher - Fetch function to use
185
+ * @param url - Request URL
186
+ * @param body - Request body to be JSON stringified
187
+ * @param options - Custom fetch options
188
+ * @param parameters - Additional fetch parameters
189
+ * @returns Promise with parsed response
190
+ */
191
+ export async function put(
192
+ fetcher: Fetch,
193
+ url: string,
194
+ body: object,
195
+ options?: FetchOptions,
196
+ parameters?: VectorFetchParameters
197
+ ): Promise<any> {
198
+ return _handleRequest(fetcher, 'PUT', url, options, parameters, body)
199
+ }
200
+
201
+ /**
202
+ * Performs a DELETE request
203
+ * @param fetcher - Fetch function to use
204
+ * @param url - Request URL
205
+ * @param body - Request body to be JSON stringified
206
+ * @param options - Custom fetch options
207
+ * @param parameters - Additional fetch parameters
208
+ * @returns Promise with parsed response
209
+ */
210
+ export async function remove(
211
+ fetcher: Fetch,
212
+ url: string,
213
+ body: object,
214
+ options?: FetchOptions,
215
+ parameters?: VectorFetchParameters
216
+ ): Promise<any> {
217
+ return _handleRequest(fetcher, 'DELETE', url, options, parameters, body)
218
+ }
@@ -0,0 +1,93 @@
1
+ type Fetch = typeof fetch
2
+
3
+ /**
4
+ * Resolves the fetch implementation to use
5
+ * Uses custom fetch if provided, otherwise falls back to:
6
+ * - Native fetch in browser/modern environments
7
+ * - @supabase/node-fetch polyfill in Node.js environments without fetch
8
+ *
9
+ * @param customFetch - Optional custom fetch implementation
10
+ * @returns Resolved fetch function
11
+ */
12
+ export const resolveFetch = (customFetch?: Fetch): Fetch => {
13
+ let _fetch: Fetch
14
+ if (customFetch) {
15
+ _fetch = customFetch
16
+ } else if (typeof fetch === 'undefined') {
17
+ _fetch = (...args) =>
18
+ import('@supabase/node-fetch' as any).then(({ default: fetch }) => fetch(...args))
19
+ } else {
20
+ _fetch = fetch
21
+ }
22
+ return (...args) => _fetch(...args)
23
+ }
24
+
25
+ /**
26
+ * Resolves the Response constructor to use
27
+ * Uses native Response in browser/modern environments
28
+ * Falls back to @supabase/node-fetch polyfill in Node.js environments
29
+ *
30
+ * @returns Response constructor
31
+ */
32
+ export const resolveResponse = async (): Promise<typeof Response> => {
33
+ if (typeof Response === 'undefined') {
34
+ // @ts-ignore
35
+ return (await import('@supabase/node-fetch' as any)).Response
36
+ }
37
+
38
+ return Response
39
+ }
40
+
41
+ /**
42
+ * Determine if input is a plain object
43
+ * An object is plain if it's created by either {}, new Object(), or Object.create(null)
44
+ *
45
+ * @param value - Value to check
46
+ * @returns True if value is a plain object
47
+ * @source https://github.com/sindresorhus/is-plain-obj
48
+ */
49
+ export const isPlainObject = (value: object): boolean => {
50
+ if (typeof value !== 'object' || value === null) {
51
+ return false
52
+ }
53
+
54
+ const prototype = Object.getPrototypeOf(value)
55
+ return (
56
+ (prototype === null ||
57
+ prototype === Object.prototype ||
58
+ Object.getPrototypeOf(prototype) === null) &&
59
+ !(Symbol.toStringTag in value) &&
60
+ !(Symbol.iterator in value)
61
+ )
62
+ }
63
+
64
+ /**
65
+ * Normalizes a number array to float32 format
66
+ * Ensures all vector values are valid 32-bit floats
67
+ *
68
+ * @param values - Array of numbers to normalize
69
+ * @returns Normalized float32 array
70
+ */
71
+ export const normalizeToFloat32 = (values: number[]): number[] => {
72
+ // Use Float32Array to ensure proper precision
73
+ return Array.from(new Float32Array(values))
74
+ }
75
+
76
+ /**
77
+ * Validates vector dimensions match expected dimension
78
+ * Throws error if dimensions don't match
79
+ *
80
+ * @param vector - Vector data to validate
81
+ * @param expectedDimension - Expected vector dimension
82
+ * @throws Error if dimensions don't match
83
+ */
84
+ export const validateVectorDimension = (
85
+ vector: { float32: number[] },
86
+ expectedDimension?: number
87
+ ): void => {
88
+ if (expectedDimension !== undefined && vector.float32.length !== expectedDimension) {
89
+ throw new Error(
90
+ `Vector dimension mismatch: expected ${expectedDimension}, got ${vector.float32.length}`
91
+ )
92
+ }
93
+ }
@@ -0,0 +1,66 @@
1
+ // Main client
2
+ export { StorageVectorsClient, VectorBucketScope, VectorIndexScope } from './StorageVectorsClient'
3
+ export type { StorageVectorsClientOptions } from './StorageVectorsClient'
4
+
5
+ // API classes (for advanced usage)
6
+ export { default as VectorBucketApi } from './VectorBucketApi'
7
+ export { default as VectorIndexApi } from './VectorIndexApi'
8
+ export { default as VectorDataApi } from './VectorDataApi'
9
+ export type { CreateIndexOptions } from './VectorIndexApi'
10
+
11
+ // Types
12
+ export type {
13
+ // Core types
14
+ VectorBucket,
15
+ VectorIndex,
16
+ VectorData,
17
+ VectorMetadata,
18
+ VectorObject,
19
+ VectorMatch,
20
+ EncryptionConfiguration,
21
+ MetadataConfiguration,
22
+ VectorDataType,
23
+ DistanceMetric,
24
+ VectorFilter,
25
+
26
+ // Request/Response types
27
+ ListVectorBucketsOptions,
28
+ ListVectorBucketsResponse,
29
+ ListIndexesOptions,
30
+ ListIndexesResponse,
31
+ PutVectorsOptions,
32
+ GetVectorsOptions,
33
+ GetVectorsResponse,
34
+ DeleteVectorsOptions,
35
+ ListVectorsOptions,
36
+ ListVectorsResponse,
37
+ QueryVectorsOptions,
38
+ QueryVectorsResponse,
39
+
40
+ // Response wrappers
41
+ ApiResponse,
42
+ SuccessResponse,
43
+ ErrorResponse,
44
+ VectorFetchParameters,
45
+ } from './types'
46
+
47
+ // Errors
48
+ export {
49
+ StorageVectorsError,
50
+ StorageVectorsApiError,
51
+ StorageVectorsUnknownError,
52
+ StorageVectorsErrorCode,
53
+ isStorageVectorsError,
54
+ } from './errors'
55
+
56
+ // Fetch utilities (for custom implementations)
57
+ export type { Fetch, FetchOptions, RequestMethodType } from './fetch'
58
+
59
+ // Helper utilities
60
+ export {
61
+ resolveFetch,
62
+ resolveResponse,
63
+ isPlainObject,
64
+ normalizeToFloat32,
65
+ validateVectorDimension,
66
+ } from './helpers'
@@ -0,0 +1,299 @@
1
+ import { StorageVectorsError } from './errors'
2
+
3
+ /**
4
+ * Configuration for encryption at rest
5
+ * @property kmsKeyArn - ARN of the KMS key used for encryption
6
+ * @property sseType - Server-side encryption type (e.g., 'KMS')
7
+ */
8
+ export interface EncryptionConfiguration {
9
+ kmsKeyArn?: string
10
+ sseType?: string
11
+ }
12
+
13
+ /**
14
+ * Vector bucket metadata
15
+ * @property vectorBucketName - Unique name of the vector bucket
16
+ * @property creationTime - Unix timestamp of when the bucket was created
17
+ * @property encryptionConfiguration - Optional encryption settings
18
+ */
19
+ export interface VectorBucket {
20
+ vectorBucketName: string
21
+ creationTime?: number
22
+ encryptionConfiguration?: EncryptionConfiguration
23
+ }
24
+
25
+ /**
26
+ * Metadata configuration for vector index
27
+ * Defines which metadata keys should not be indexed for filtering
28
+ * @property nonFilterableMetadataKeys - Array of metadata keys that cannot be used in filters
29
+ */
30
+ export interface MetadataConfiguration {
31
+ nonFilterableMetadataKeys?: string[]
32
+ }
33
+
34
+ /**
35
+ * Supported data types for vectors
36
+ * Currently only float32 is supported
37
+ */
38
+ export type VectorDataType = 'float32'
39
+
40
+ /**
41
+ * Distance metrics for vector similarity search
42
+ */
43
+ export type DistanceMetric = 'cosine' | 'euclidean' | 'dotproduct'
44
+
45
+ /**
46
+ * Vector index configuration and metadata
47
+ * @property indexName - Unique name of the index within the bucket
48
+ * @property vectorBucketName - Name of the parent vector bucket
49
+ * @property dataType - Data type of vector components (currently only 'float32')
50
+ * @property dimension - Dimensionality of vectors (e.g., 384, 768, 1536)
51
+ * @property distanceMetric - Similarity metric used for queries
52
+ * @property metadataConfiguration - Configuration for metadata filtering
53
+ * @property creationTime - Unix timestamp of when the index was created
54
+ */
55
+ export interface VectorIndex {
56
+ indexName: string
57
+ vectorBucketName: string
58
+ dataType: VectorDataType
59
+ dimension: number
60
+ distanceMetric: DistanceMetric
61
+ metadataConfiguration?: MetadataConfiguration
62
+ creationTime?: number
63
+ }
64
+
65
+ /**
66
+ * Vector data representation
67
+ * Vectors must be float32 arrays with dimensions matching the index
68
+ * @property float32 - Array of 32-bit floating point numbers
69
+ */
70
+ export interface VectorData {
71
+ float32: number[]
72
+ }
73
+
74
+ /**
75
+ * Arbitrary JSON metadata attached to vectors
76
+ * Keys configured as non-filterable in the index can be stored but not queried
77
+ */
78
+ export type VectorMetadata = Record<string, any>
79
+
80
+ /**
81
+ * Single vector object for insertion/update
82
+ * @property key - Unique identifier for the vector
83
+ * @property data - Vector embedding data
84
+ * @property metadata - Optional arbitrary metadata
85
+ */
86
+ export interface VectorObject {
87
+ key: string
88
+ data: VectorData
89
+ metadata?: VectorMetadata
90
+ }
91
+
92
+ /**
93
+ * Vector object returned from queries with optional distance
94
+ * @property key - Unique identifier for the vector
95
+ * @property data - Vector embedding data (if requested)
96
+ * @property metadata - Arbitrary metadata (if requested)
97
+ * @property distance - Similarity distance from query vector (if requested)
98
+ */
99
+ export interface VectorMatch {
100
+ key: string
101
+ data?: VectorData
102
+ metadata?: VectorMetadata
103
+ distance?: number
104
+ }
105
+
106
+ /**
107
+ * Options for fetching vector buckets
108
+ * @property prefix - Filter buckets by name prefix
109
+ * @property maxResults - Maximum number of results to return (default: 100)
110
+ * @property nextToken - Token for pagination from previous response
111
+ */
112
+ export interface ListVectorBucketsOptions {
113
+ prefix?: string
114
+ maxResults?: number
115
+ nextToken?: string
116
+ }
117
+
118
+ /**
119
+ * Response from listing vector buckets
120
+ * @property vectorBuckets - Array of bucket names
121
+ * @property nextToken - Token for fetching next page (if more results exist)
122
+ */
123
+ export interface ListVectorBucketsResponse {
124
+ vectorBuckets: { vectorBucketName: string }[]
125
+ nextToken?: string
126
+ }
127
+
128
+ /**
129
+ * Options for listing indexes within a bucket
130
+ * @property vectorBucketName - Name of the parent vector bucket
131
+ * @property prefix - Filter indexes by name prefix
132
+ * @property maxResults - Maximum number of results to return (default: 100)
133
+ * @property nextToken - Token for pagination from previous response
134
+ */
135
+ export interface ListIndexesOptions {
136
+ vectorBucketName: string
137
+ prefix?: string
138
+ maxResults?: number
139
+ nextToken?: string
140
+ }
141
+
142
+ /**
143
+ * Response from listing indexes
144
+ * @property indexes - Array of index names
145
+ * @property nextToken - Token for fetching next page (if more results exist)
146
+ */
147
+ export interface ListIndexesResponse {
148
+ indexes: { indexName: string }[]
149
+ nextToken?: string
150
+ }
151
+
152
+ /**
153
+ * Options for batch reading vectors
154
+ * @property vectorBucketName - Name of the vector bucket
155
+ * @property indexName - Name of the index
156
+ * @property keys - Array of vector keys to retrieve
157
+ * @property returnData - Whether to include vector data in response
158
+ * @property returnMetadata - Whether to include metadata in response
159
+ */
160
+ export interface GetVectorsOptions {
161
+ vectorBucketName: string
162
+ indexName: string
163
+ keys: string[]
164
+ returnData?: boolean
165
+ returnMetadata?: boolean
166
+ }
167
+
168
+ /**
169
+ * Response from getting vectors
170
+ * @property vectors - Array of retrieved vector objects
171
+ */
172
+ export interface GetVectorsResponse {
173
+ vectors: VectorMatch[]
174
+ }
175
+
176
+ /**
177
+ * Options for batch inserting/updating vectors
178
+ * @property vectorBucketName - Name of the vector bucket
179
+ * @property indexName - Name of the index
180
+ * @property vectors - Array of vectors to insert/upsert (1-500 items)
181
+ */
182
+ export interface PutVectorsOptions {
183
+ vectorBucketName: string
184
+ indexName: string
185
+ vectors: VectorObject[]
186
+ }
187
+
188
+ /**
189
+ * Options for batch deleting vectors
190
+ * @property vectorBucketName - Name of the vector bucket
191
+ * @property indexName - Name of the index
192
+ * @property keys - Array of vector keys to delete (1-500 items)
193
+ */
194
+ export interface DeleteVectorsOptions {
195
+ vectorBucketName: string
196
+ indexName: string
197
+ keys: string[]
198
+ }
199
+
200
+ /**
201
+ * Options for listing/scanning vectors in an index
202
+ * Supports parallel scanning via segment configuration
203
+ * @property vectorBucketName - Name of the vector bucket
204
+ * @property indexName - Name of the index
205
+ * @property maxResults - Maximum number of results to return (default: 500, max: 1000)
206
+ * @property nextToken - Token for pagination from previous response
207
+ * @property returnData - Whether to include vector data in response
208
+ * @property returnMetadata - Whether to include metadata in response
209
+ * @property segmentCount - Total number of parallel segments (1-16)
210
+ * @property segmentIndex - Zero-based index of this segment (0 to segmentCount-1)
211
+ */
212
+ export interface ListVectorsOptions {
213
+ vectorBucketName: string
214
+ indexName: string
215
+ maxResults?: number
216
+ nextToken?: string
217
+ returnData?: boolean
218
+ returnMetadata?: boolean
219
+ segmentCount?: number
220
+ segmentIndex?: number
221
+ }
222
+
223
+ /**
224
+ * Response from listing vectors
225
+ * @property vectors - Array of vector objects
226
+ * @property nextToken - Token for fetching next page (if more results exist)
227
+ */
228
+ export interface ListVectorsResponse {
229
+ vectors: VectorMatch[]
230
+ nextToken?: string
231
+ }
232
+
233
+ /**
234
+ * JSON filter expression for metadata filtering
235
+ * Format and syntax depend on the S3 Vectors service implementation
236
+ */
237
+ export type VectorFilter = Record<string, any>
238
+
239
+ /**
240
+ * Options for querying similar vectors (ANN search)
241
+ * @property vectorBucketName - Name of the vector bucket
242
+ * @property indexName - Name of the index
243
+ * @property queryVector - Query vector to find similar vectors
244
+ * @property topK - Number of nearest neighbors to return (default: 10)
245
+ * @property filter - Optional JSON filter for metadata
246
+ * @property returnDistance - Whether to include distance scores
247
+ * @property returnMetadata - Whether to include metadata in results
248
+ */
249
+ export interface QueryVectorsOptions {
250
+ vectorBucketName: string
251
+ indexName: string
252
+ queryVector: VectorData
253
+ topK?: number
254
+ filter?: VectorFilter
255
+ returnDistance?: boolean
256
+ returnMetadata?: boolean
257
+ }
258
+
259
+ /**
260
+ * Response from vector similarity query
261
+ * @property matches - Array of similar vectors ordered by distance
262
+ */
263
+ export interface QueryVectorsResponse {
264
+ matches: VectorMatch[]
265
+ }
266
+
267
+ /**
268
+ * Fetch-specific parameters like abort signals
269
+ * @property signal - AbortSignal for cancelling requests
270
+ */
271
+ export interface VectorFetchParameters {
272
+ signal?: AbortSignal
273
+ }
274
+
275
+ /**
276
+ * Standard response wrapper for successful operations
277
+ * @property data - Response data of type T
278
+ * @property error - Null on success
279
+ */
280
+ export interface SuccessResponse<T> {
281
+ data: T
282
+ error: null
283
+ }
284
+
285
+ /**
286
+ * Standard response wrapper for failed operations
287
+ * @property data - Null on error
288
+ * @property error - StorageVectorsError with details
289
+ */
290
+ export interface ErrorResponse {
291
+ data: null
292
+ error: StorageVectorsError
293
+ }
294
+
295
+ /**
296
+ * Union type for all API responses
297
+ * Follows the pattern: { data: T, error: null } | { data: null, error: Error }
298
+ */
299
+ export type ApiResponse<T> = SuccessResponse<T> | ErrorResponse
@@ -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.75.1'
7
+ export const version = '2.75.2-canary.1'