Skip to content

Commit cba5d5e

Browse files
committed
chore(repo): ran nx format
1 parent a37503f commit cba5d5e

File tree

19 files changed

+168
-163
lines changed

19 files changed

+168
-163
lines changed

packages/core/storage-js/src/StorageClient.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,4 @@ export class StorageClient extends StorageBucketApi {
6161
get analytics(): StorageAnalyticsApi {
6262
return new StorageAnalyticsApi(this.url + '/iceberg', this.headers, this.fetch)
6363
}
64-
}
64+
}

packages/core/storage-js/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ export type { StorageClientOptions } from './StorageClient'
33
export { default as StorageAnalyticsApi } from './packages/StorageAnalyticsApi'
44
export * from './lib/types'
55
export * from './lib/errors'
6-
export * from '@supabase/storage-vectors-js'
6+
export * from '@supabase/storage-vectors-js'

packages/core/storage-js/src/lib/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export interface Bucket {
1616

1717
export interface AnalyticBucket {
1818
id: string
19-
type: "ANALYTICS"
19+
type: 'ANALYTICS'
2020
format: string
2121
created_at: string
2222
updated_at: string

packages/core/storage-js/src/packages/StorageAnalyticsApi.ts

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,9 @@ export default class StorageAnalyticsApi {
4848
* }
4949
* ```
5050
*/
51-
async createBucket(
52-
name: string
53-
): Promise<
51+
async createBucket(name: string): Promise<
5452
| {
55-
data: AnalyticBucket,
53+
data: AnalyticBucket
5654
error: null
5755
}
5856
| {
@@ -61,12 +59,7 @@ export default class StorageAnalyticsApi {
6159
}
6260
> {
6361
try {
64-
const data = await post(
65-
this.fetch,
66-
`${this.url}/bucket`,
67-
{ name },
68-
{ headers: this.headers }
69-
)
62+
const data = await post(this.fetch, `${this.url}/bucket`, { name }, { headers: this.headers })
7063
return { data, error: null }
7164
} catch (error) {
7265
if (this.shouldThrowOnError) {
@@ -200,4 +193,4 @@ export default class StorageAnalyticsApi {
200193
throw error
201194
}
202195
}
203-
}
196+
}

packages/integrations/storage-vectors-js/README.md

Lines changed: 62 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import { StorageVectorsClient } from '@supabase/storage-vectors-js'
2727

2828
// Initialize client
2929
const client = new StorageVectorsClient('https://api.example.com', {
30-
headers: { 'Authorization': 'Bearer YOUR_TOKEN' }
30+
headers: { Authorization: 'Bearer YOUR_TOKEN' },
3131
})
3232

3333
// Create a vector bucket
@@ -39,7 +39,7 @@ await bucket.createIndex({
3939
indexName: 'documents-openai',
4040
dataType: 'float32',
4141
dimension: 1536,
42-
distanceMetric: 'cosine'
42+
distanceMetric: 'cosine',
4343
})
4444

4545
// Insert vectors
@@ -48,22 +48,22 @@ await index.putVectors({
4848
vectors: [
4949
{
5050
key: 'doc-1',
51-
data: { float32: [0.1, 0.2, 0.3, /* ...1536 dimensions */] },
52-
metadata: { title: 'Introduction', category: 'docs' }
53-
}
54-
]
51+
data: { float32: [0.1, 0.2, 0.3 /* ...1536 dimensions */] },
52+
metadata: { title: 'Introduction', category: 'docs' },
53+
},
54+
],
5555
})
5656

5757
// Query similar vectors
5858
const { data, error } = await index.queryVectors({
59-
queryVector: { float32: [0.15, 0.25, 0.35, /* ...1536 dimensions */] },
59+
queryVector: { float32: [0.15, 0.25, 0.35 /* ...1536 dimensions */] },
6060
topK: 5,
6161
returnDistance: true,
62-
returnMetadata: true
62+
returnMetadata: true,
6363
})
6464

6565
if (data) {
66-
data.matches.forEach(match => {
66+
data.matches.forEach((match) => {
6767
console.log(`${match.key}: distance=${match.distance}`)
6868
console.log('Metadata:', match.metadata)
6969
})
@@ -79,6 +79,7 @@ const client = new StorageVectorsClient(url, options?)
7979
```
8080
8181
**Options:**
82+
8283
- `headers?: Record<string, string>` - Custom HTTP headers (e.g., Authorization)
8384
- `fetch?: Fetch` - Custom fetch implementation
8485
@@ -104,7 +105,7 @@ console.log('Created at:', new Date(data.vectorBucket.creationTime! * 1000))
104105
```typescript
105106
const { data, error } = await client.listVectorBuckets({
106107
prefix: 'prod-',
107-
maxResults: 100
108+
maxResults: 100,
108109
})
109110

110111
// Pagination
@@ -135,12 +136,13 @@ await bucket.createIndex({
135136
dimension: 1536,
136137
distanceMetric: 'cosine', // 'cosine' | 'euclidean' | 'dotproduct'
137138
metadataConfiguration: {
138-
nonFilterableMetadataKeys: ['raw_text', 'internal_id']
139-
}
139+
nonFilterableMetadataKeys: ['raw_text', 'internal_id'],
140+
},
140141
})
141142
```
142143
143144
**Distance Metrics:**
145+
144146
- `cosine` - Cosine similarity (normalized dot product)
145147
- `euclidean` - Euclidean distance (L2 norm)
146148
- `dotproduct` - Dot product similarity
@@ -158,7 +160,7 @@ console.log('Distance metric:', data?.index.distanceMetric)
158160
```typescript
159161
const { data, error } = await bucket.listIndexes({
160162
prefix: 'documents-',
161-
maxResults: 100
163+
maxResults: 100,
162164
})
163165
```
164166
@@ -180,19 +182,24 @@ await index.putVectors({
180182
vectors: [
181183
{
182184
key: 'unique-id-1',
183-
data: { float32: [/* 1536 numbers */] },
185+
data: {
186+
float32: [
187+
/* 1536 numbers */
188+
],
189+
},
184190
metadata: {
185191
title: 'Document Title',
186192
category: 'technical',
187-
page: 1
188-
}
193+
page: 1,
194+
},
189195
},
190196
// ... up to 500 vectors per request
191-
]
197+
],
192198
})
193199
```
194200
195201
**Limitations:**
202+
196203
- 1-500 vectors per request
197204
- Vectors must match index dimension
198205
- Keys must be unique within index
@@ -202,11 +209,11 @@ await index.putVectors({
202209
```typescript
203210
const { data, error } = await index.getVectors({
204211
keys: ['doc-1', 'doc-2', 'doc-3'],
205-
returnData: true, // Include embeddings (requires permission)
206-
returnMetadata: true // Include metadata (requires permission)
212+
returnData: true, // Include embeddings (requires permission)
213+
returnMetadata: true, // Include metadata (requires permission)
207214
})
208215

209-
data?.vectors.forEach(v => {
216+
data?.vectors.forEach((v) => {
210217
console.log(v.key, v.metadata)
211218
})
212219
```
@@ -215,18 +222,22 @@ data?.vectors.forEach(v => {
215222
216223
```typescript
217224
const { data, error } = await index.queryVectors({
218-
queryVector: { float32: [/* 1536 numbers */] },
225+
queryVector: {
226+
float32: [
227+
/* 1536 numbers */
228+
],
229+
},
219230
topK: 10,
220231
filter: {
221232
category: 'technical',
222-
published: true
233+
published: true,
223234
},
224235
returnDistance: true,
225-
returnMetadata: true
236+
returnMetadata: true,
226237
})
227238

228239
// Results ordered by similarity
229-
data?.matches.forEach(match => {
240+
data?.matches.forEach((match) => {
230241
console.log(`${match.key}: distance=${match.distance}`)
231242
})
232243
```
@@ -243,7 +254,7 @@ do {
243254
const { data } = await index.listVectors({
244255
maxResults: 500,
245256
nextToken,
246-
returnMetadata: true
257+
returnMetadata: true,
247258
})
248259

249260
console.log('Batch:', data?.vectors.length)
@@ -255,7 +266,7 @@ const workers = [0, 1, 2, 3].map(async (segmentIndex) => {
255266
const { data } = await index.listVectors({
256267
segmentCount: 4,
257268
segmentIndex,
258-
returnMetadata: true
269+
returnMetadata: true,
259270
})
260271
return data?.vectors || []
261272
})
@@ -265,6 +276,7 @@ const allVectors = results.flat()
265276
```
266277
267278
**Limitations:**
279+
268280
- `maxResults`: 1-1000 (default: 500)
269281
- `segmentCount`: 1-16
270282
- Response may be limited by 1MB size
@@ -273,7 +285,7 @@ const allVectors = results.flat()
273285
274286
```typescript
275287
await index.deleteVectors({
276-
keys: ['doc-1', 'doc-2', 'doc-3']
288+
keys: ['doc-1', 'doc-2', 'doc-3'],
277289
// ... up to 500 keys per request
278290
})
279291
```
@@ -294,14 +306,14 @@ if (error) {
294306
295307
### Error Codes
296308
297-
| Code | HTTP | Description |
298-
|------|------|-------------|
299-
| `InternalError` | 500 | Internal server error |
300-
| `S3VectorConflictException` | 409 | Resource already exists |
301-
| `S3VectorNotFoundException` | 404 | Resource not found |
302-
| `S3VectorBucketNotEmpty` | 400 | Bucket contains indexes |
303-
| `S3VectorMaxBucketsExceeded` | 400 | Bucket quota exceeded |
304-
| `S3VectorMaxIndexesExceeded` | 400 | Index quota exceeded |
309+
| Code | HTTP | Description |
310+
| ---------------------------- | ---- | ----------------------- |
311+
| `InternalError` | 500 | Internal server error |
312+
| `S3VectorConflictException` | 409 | Resource already exists |
313+
| `S3VectorNotFoundException` | 404 | Resource not found |
314+
| `S3VectorBucketNotEmpty` | 400 | Bucket contains indexes |
315+
| `S3VectorMaxBucketsExceeded` | 400 | Bucket quota exceeded |
316+
| `S3VectorMaxIndexesExceeded` | 400 | Index quota exceeded |
305317
306318
### Throwing Errors
307319
@@ -330,13 +342,19 @@ Create scoped clients for cleaner code:
330342
```typescript
331343
// Bucket-scoped operations
332344
const bucket = client.bucket('embeddings-prod')
333-
await bucket.createIndex({ /* ... */ })
345+
await bucket.createIndex({
346+
/* ... */
347+
})
334348
await bucket.listIndexes()
335349

336350
// Index-scoped operations
337351
const index = bucket.index('documents-openai')
338-
await index.putVectors({ /* ... */ })
339-
await index.queryVectors({ /* ... */ })
352+
await index.putVectors({
353+
/* ... */
354+
})
355+
await index.queryVectors({
356+
/* ... */
357+
})
340358
```
341359
342360
### Custom Fetch
@@ -348,7 +366,9 @@ import { StorageVectorsClient } from '@supabase/storage-vectors-js'
348366

349367
const client = new StorageVectorsClient(url, {
350368
fetch: customFetch,
351-
headers: { /* ... */ }
369+
headers: {
370+
/* ... */
371+
},
352372
})
353373
```
354374
@@ -375,7 +395,7 @@ Ensure vectors are properly normalized to float32:
375395
```typescript
376396
import { normalizeToFloat32 } from '@supabase/storage-vectors-js'
377397

378-
const vector = normalizeToFloat32([0.1, 0.2, 0.3, /* ... */])
398+
const vector = normalizeToFloat32([0.1, 0.2, 0.3 /* ... */])
379399
```
380400
381401
## Type Definitions
@@ -392,11 +412,11 @@ import type {
392412
VectorMetadata,
393413
DistanceMetric,
394414
ApiResponse,
395-
StorageVectorsError
415+
StorageVectorsError,
396416
} from '@supabase/storage-vectors-js'
397417
```
398418
399419
## Requirements
400420
401421
- Node.js 14+ or modern browser with fetch support
402-
- TypeScript 4.5+ (for type checking)
422+
- TypeScript 4.5+ (for type checking)

packages/integrations/storage-vectors-js/src/__tests__/bucket-api.spec.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,14 @@
33
* Tests all bucket operations: create, get, list, delete
44
*/
55

6-
import { createTestClient, setupTest, generateTestName, assertSuccessResponse, assertErrorResponse, assertErrorCode } from './helpers'
6+
import {
7+
createTestClient,
8+
setupTest,
9+
generateTestName,
10+
assertSuccessResponse,
11+
assertErrorResponse,
12+
assertErrorCode,
13+
} from './helpers'
714

815
describe('VectorBucketApi Integration Tests', () => {
916
let client: ReturnType<typeof createTestClient>
@@ -103,7 +110,7 @@ describe('VectorBucketApi Integration Tests', () => {
103110
expect(Array.isArray(data.buckets)).toBe(true)
104111
expect(data.buckets.length).toBeGreaterThanOrEqual(2)
105112

106-
const bucketNames = data.buckets.map(b => b.vectorBucketName)
113+
const bucketNames = data.buckets.map((b) => b.vectorBucketName)
107114
expect(bucketNames).toContain(bucket1)
108115
expect(bucketNames).toContain(bucket2)
109116
})
@@ -123,14 +130,14 @@ describe('VectorBucketApi Integration Tests', () => {
123130
const data = assertSuccessResponse(response)
124131
expect(data.buckets.length).toBeGreaterThanOrEqual(2)
125132

126-
const bucketNames = data.buckets.map(b => b.vectorBucketName)
133+
const bucketNames = data.buckets.map((b) => b.vectorBucketName)
127134
expect(bucketNames).toContain(bucket1)
128135
expect(bucketNames).toContain(bucket2)
129136
// bucket3 should not be included as it doesn't match prefix
130-
const hasOtherBucket = bucketNames.some(name => name.includes('other-bucket'))
137+
const hasOtherBucket = bucketNames.some((name) => name.includes('other-bucket'))
131138
if (hasOtherBucket) {
132139
// If other buckets exist, they should match the prefix
133-
expect(bucketNames.every(name => name.startsWith(prefix))).toBe(true)
140+
expect(bucketNames.every((name) => name.startsWith(prefix))).toBe(true)
134141
}
135142
})
136143

packages/integrations/storage-vectors-js/src/__tests__/e2e-workflow.spec.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -391,14 +391,11 @@ describe('End-to-End Workflow Tests', () => {
391391
const batchSize = 500
392392

393393
for (let i = 0; i < totalVectors; i += batchSize) {
394-
const batch = Array.from(
395-
{ length: Math.min(batchSize, totalVectors - i) },
396-
(_, j) => ({
397-
key: `vector-${i + j}`,
398-
data: { float32: generateRandomVector(64) },
399-
metadata: { batch: Math.floor((i + j) / batchSize), index: i + j },
400-
})
401-
)
394+
const batch = Array.from({ length: Math.min(batchSize, totalVectors - i) }, (_, j) => ({
395+
key: `vector-${i + j}`,
396+
data: { float32: generateRandomVector(64) },
397+
metadata: { batch: Math.floor((i + j) / batchSize), index: i + j },
398+
}))
402399

403400
const response = await index.putVectors({ vectors: batch })
404401
assertSuccessResponse(response)

0 commit comments

Comments
 (0)