Skip to content

Commit a7221a8

Browse files
committed
chore(storage): docs and deno test setup
1 parent 1937a43 commit a7221a8

File tree

6 files changed

+90
-15
lines changed

6 files changed

+90
-15
lines changed

packages/core/storage-js/README.md

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -202,19 +202,26 @@ Supabase Storage provides built-in support for storing and querying high-dimensi
202202

203203
### Quick Start
204204

205+
#### Using with StorageClient (Recommended)
206+
207+
If you already have a `StorageClient` instance for regular file operations, access vector functionality through the `vectors` property:
208+
205209
```typescript
206-
import { StorageVectorsClient } from '@supabase/storage-js'
210+
import { StorageClient } from '@supabase/storage-js'
207211

208-
// Initialize client
209-
const vectorClient = new StorageVectorsClient('https://your-project.supabase.co/storage/v1', {
210-
headers: { Authorization: 'Bearer YOUR_TOKEN' },
212+
const storageClient = new StorageClient('https://your-project.supabase.co/storage/v1', {
213+
apikey: 'YOUR_API_KEY',
214+
Authorization: 'Bearer YOUR_TOKEN',
211215
})
212216

217+
// Access vector operations
218+
const vectors = storageClient.vectors
219+
213220
// Create a vector bucket
214-
await vectorClient.createVectorBucket('embeddings-prod')
221+
await vectors.createVectorBucket('embeddings-prod')
215222

216223
// Create an index
217-
const bucket = vectorClient.from('embeddings-prod')
224+
const bucket = vectors.from('embeddings-prod')
218225
await bucket.createIndex({
219226
indexName: 'documents-openai',
220227
dataType: 'float32',
@@ -250,6 +257,28 @@ if (data) {
250257
}
251258
```
252259

260+
#### Standalone Usage
261+
262+
For vector-only applications that don't need regular file storage operations, you can create a dedicated vector client:
263+
264+
```typescript
265+
import { StorageVectorsClient } from '@supabase/storage-js'
266+
267+
// Initialize standalone vector client
268+
const vectorClient = new StorageVectorsClient('https://your-project.supabase.co/storage/v1', {
269+
headers: { Authorization: 'Bearer YOUR_TOKEN' },
270+
})
271+
272+
// Use the same API as shown above
273+
await vectorClient.createVectorBucket('embeddings-prod')
274+
const bucket = vectorClient.from('embeddings-prod')
275+
// ... rest of operations
276+
```
277+
278+
> **When to use each pattern:**
279+
> - Use `storageClient.vectors` when working with both files and vectors in the same application
280+
> - Use `new StorageVectorsClient()` for applications that only need vector operations without file storage
281+
253282
### API Reference
254283

255284
#### Client Initialization

packages/integrations/storage-vectors-js/package.json

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,28 @@
22
"name": "@supabase/storage-vectors-js",
33
"version": "0.0.0",
44
"private": true,
5-
"main": "./dist/index.js",
6-
"types": "./dist/index.d.ts",
5+
"main": "./dist/main/index.js",
6+
"module": "./dist/module/index.js",
7+
"types": "./dist/module/index.d.ts",
78
"exports": {
89
"./package.json": "./package.json",
910
".": {
1011
"@supabase-js/source": "./src/index.ts",
11-
"types": "./dist/index.d.ts",
12-
"require": "./dist/index.js",
13-
"default": "./dist/index.js"
12+
"types": "./dist/module/index.d.ts",
13+
"require": "./dist/main/index.js",
14+
"import": "./dist/module/index.js",
15+
"default": "./dist/module/index.js"
1416
}
1517
},
1618
"files": [
1719
"dist",
1820
"!**/*.tsbuildinfo"
1921
],
2022
"scripts": {
23+
"clean": "rimraf dist",
24+
"build": "npm run clean && npm run build:main && npm run build:module",
25+
"build:main": "tsc -p tsconfig.lib.json",
26+
"build:module": "tsc -p tsconfig.module.json",
2127
"test": "jest",
2228
"test:watch": "jest --watch",
2329
"test:coverage": "jest --coverage",
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "storage-vectors-js",
3+
"$schema": "../../../node_modules/nx/schemas/project-schema.json",
4+
"sourceRoot": "packages/integrations/storage-vectors-js/src",
5+
"projectType": "library",
6+
"targets": {
7+
"build": {
8+
"executor": "nx:run-script",
9+
"options": {
10+
"script": "build"
11+
},
12+
"dependsOn": ["^build"],
13+
"inputs": ["production", "^production"],
14+
"outputs": ["{projectRoot}/dist"],
15+
"cache": true
16+
}
17+
}
18+
}

packages/integrations/storage-vectors-js/src/lib/StorageVectorsClient.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,24 @@ export interface StorageVectorsClientOptions {
3030
* Main client for interacting with S3 Vectors API
3131
* Provides access to bucket, index, and vector data operations
3232
*
33-
* @example
33+
* **Usage Patterns:**
34+
*
35+
* 1. **Via StorageClient (recommended for most use cases):**
36+
* ```typescript
37+
* import { StorageClient } from '@supabase/storage-js'
38+
*
39+
* const storageClient = new StorageClient(url, headers)
40+
* const vectors = storageClient.vectors
41+
*
42+
* // Use vector operations
43+
* await vectors.createVectorBucket('embeddings-prod')
44+
* const bucket = vectors.from('embeddings-prod')
45+
* await bucket.createIndex({ ... })
46+
* ```
47+
*
48+
* 2. **Standalone (for vector-only applications):**
3449
* ```typescript
35-
* import { StorageVectorsClient } from '@supabase/storage'
50+
* import { StorageVectorsClient } from '@supabase/storage-js'
3651
*
3752
* const client = new StorageVectorsClient('https://api.example.com', {
3853
* headers: { 'Authorization': 'Bearer token' }
@@ -42,7 +57,7 @@ export interface StorageVectorsClientOptions {
4257
* await client.createVectorBucket('embeddings-prod')
4358
*
4459
* // Access index operations via buckets
45-
* const bucket = client.bucket('embeddings-prod')
60+
* const bucket = client.from('embeddings-prod')
4661
* await bucket.createIndex({
4762
* indexName: 'documents',
4863
* dataType: 'float32',

packages/integrations/storage-vectors-js/tsconfig.lib.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"compilerOptions": {
44
"baseUrl": ".",
55
"rootDir": "src",
6-
"outDir": "dist",
6+
"outDir": "dist/main",
77
"target": "ES2017",
88
"module": "CommonJS",
99
"moduleResolution": "Node",
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"extends": "./tsconfig.lib.json",
3+
"compilerOptions": {
4+
"module": "ES2020",
5+
"outDir": "dist/module"
6+
}
7+
}

0 commit comments

Comments
 (0)