Skip to content

Commit 2ab882b

Browse files
authored
docs(storage): cleanup docs - consolidate examples (#1893)
1 parent 1bb9f82 commit 2ab882b

File tree

6 files changed

+53
-652
lines changed

6 files changed

+53
-652
lines changed

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

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export class StorageClient extends StorageBucketApi {
4040
*
4141
* @example
4242
* ```typescript
43-
* const avatars = storage.from('avatars')
43+
* const avatars = supabase.storage.from('avatars')
4444
* ```
4545
*/
4646
from(id: string): StorageFileApi {
@@ -75,20 +75,6 @@ export class StorageClient extends StorageBucketApi {
7575
*
7676
* @category Analytics Buckets
7777
* @returns A StorageAnalyticsClient instance configured with the current storage settings.
78-
* @example
79-
* ```typescript
80-
* const client = createClient(url, key)
81-
* const analytics = client.storage.analytics
82-
*
83-
* // Create an analytics bucket
84-
* await analytics.createBucket('my-analytics-bucket')
85-
*
86-
* // List all analytics buckets
87-
* const { data: buckets } = await analytics.listBuckets()
88-
*
89-
* // Delete an analytics bucket
90-
* await analytics.deleteBucket('old-analytics-bucket')
91-
* ```
9278
*/
9379
get analytics(): StorageAnalyticsClient {
9480
return new StorageAnalyticsClient(this.url + '/iceberg', this.headers, this.fetch)

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

Lines changed: 18 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -42,32 +42,14 @@ export interface StorageVectorsClientOptions {
4242
*
4343
* **Usage Patterns:**
4444
*
45-
* 1. **Via StorageClient (recommended for most use cases):**
4645
* ```typescript
47-
* import { StorageClient } from '@supabase/storage-js'
48-
*
49-
* const storageClient = new StorageClient(url, headers)
50-
* const vectors = storageClient.vectors
51-
*
52-
* // Use vector operations
53-
* await vectors.createBucket('embeddings-prod')
54-
* const bucket = vectors.from('embeddings-prod')
55-
* await bucket.createIndex({ ... })
56-
* ```
57-
*
58-
* 2. **Standalone (for vector-only applications):**
59-
* ```typescript
60-
* import { StorageVectorsClient } from '@supabase/storage-js'
61-
*
62-
* const vectorsClient = new StorageVectorsClient('https://api.example.com', {
63-
* headers: { 'Authorization': 'Bearer token' }
64-
* })
65-
*
66-
* // Access bucket operations
67-
* await vectorsClient.createBucket('embeddings-prod')
46+
* const { data, error } = await supabase
47+
* .storage
48+
* .vectors
49+
* .createBucket('embeddings-prod')
6850
*
6951
* // Access index operations via buckets
70-
* const bucket = vectorsClient.from('embeddings-prod')
52+
* const bucket = supabase.storage.vectors.from('embeddings-prod')
7153
* await bucket.createIndex({
7254
* indexName: 'documents',
7355
* dataType: 'float32',
@@ -128,18 +110,7 @@ export class StorageVectorsClient extends VectorBucketApi {
128110
*
129111
* @example
130112
* ```typescript
131-
* const bucket = client.bucket('embeddings-prod')
132-
*
133-
* // Create an index in this bucket
134-
* await bucket.createIndex({
135-
* indexName: 'documents-openai',
136-
* dataType: 'float32',
137-
* dimension: 1536,
138-
* distanceMetric: 'cosine'
139-
* })
140-
*
141-
* // List indexes in this bucket
142-
* const { data } = await bucket.listIndexes()
113+
* const bucket = supabase.storage.vectors.from('embeddings-prod')
143114
* ```
144115
*/
145116
from(vectorBucketName: string): VectorBucketScope {
@@ -169,7 +140,7 @@ export class VectorBucketScope extends VectorIndexApi {
169140
* @category Vector Buckets
170141
* @example
171142
* ```typescript
172-
* const bucket = client.bucket('embeddings-prod')
143+
* const bucket = supabase.storage.vectors.from('embeddings-prod')
173144
* ```
174145
*/
175146
constructor(
@@ -197,7 +168,7 @@ export class VectorBucketScope extends VectorIndexApi {
197168
*
198169
* @example
199170
* ```typescript
200-
* const bucket = client.bucket('embeddings-prod')
171+
* const bucket = supabase.storage.vectors.from('embeddings-prod')
201172
* await bucket.createIndex({
202173
* indexName: 'documents-openai',
203174
* dataType: 'float32',
@@ -231,7 +202,7 @@ export class VectorBucketScope extends VectorIndexApi {
231202
*
232203
* @example
233204
* ```typescript
234-
* const bucket = client.bucket('embeddings-prod')
205+
* const bucket = supabase.storage.vectors.from('embeddings-prod')
235206
* const { data } = await bucket.listIndexes({ prefix: 'documents-' })
236207
* ```
237208
*/
@@ -257,7 +228,7 @@ export class VectorBucketScope extends VectorIndexApi {
257228
*
258229
* @example
259230
* ```typescript
260-
* const bucket = client.bucket('embeddings-prod')
231+
* const bucket = supabase.storage.vectors.from('embeddings-prod')
261232
* const { data } = await bucket.getIndex('documents-openai')
262233
* console.log('Dimension:', data?.index.dimension)
263234
* ```
@@ -281,7 +252,7 @@ export class VectorBucketScope extends VectorIndexApi {
281252
*
282253
* @example
283254
* ```typescript
284-
* const bucket = client.bucket('embeddings-prod')
255+
* const bucket = supabase.storage.vectors.from('embeddings-prod')
285256
* await bucket.deleteIndex('old-index')
286257
* ```
287258
*/
@@ -304,7 +275,7 @@ export class VectorBucketScope extends VectorIndexApi {
304275
*
305276
* @example
306277
* ```typescript
307-
* const index = client.bucket('embeddings-prod').index('documents-openai')
278+
* const index = supabase.storage.vectors.from('embeddings-prod').index('documents-openai')
308279
*
309280
* // Insert vectors
310281
* await index.putVectors({
@@ -355,7 +326,7 @@ export class VectorIndexScope extends VectorDataApi {
355326
* @category Vector Buckets
356327
* @example
357328
* ```typescript
358-
* const index = client.bucket('embeddings-prod').index('documents-openai')
329+
* const index = supabase.storage.vectors.from('embeddings-prod').index('documents-openai')
359330
* ```
360331
*/
361332
constructor(
@@ -385,7 +356,7 @@ export class VectorIndexScope extends VectorDataApi {
385356
*
386357
* @example
387358
* ```typescript
388-
* const index = client.bucket('embeddings-prod').index('documents-openai')
359+
* const index = supabase.storage.vectors.from('embeddings-prod').index('documents-openai')
389360
* await index.putVectors({
390361
* vectors: [
391362
* {
@@ -420,7 +391,7 @@ export class VectorIndexScope extends VectorDataApi {
420391
*
421392
* @example
422393
* ```typescript
423-
* const index = client.bucket('embeddings-prod').index('documents-openai')
394+
* const index = supabase.storage.vectors.from('embeddings-prod').index('documents-openai')
424395
* const { data } = await index.getVectors({
425396
* keys: ['doc-1', 'doc-2'],
426397
* returnMetadata: true
@@ -450,7 +421,7 @@ export class VectorIndexScope extends VectorDataApi {
450421
*
451422
* @example
452423
* ```typescript
453-
* const index = client.bucket('embeddings-prod').index('documents-openai')
424+
* const index = supabase.storage.vectors.from('embeddings-prod').index('documents-openai')
454425
* const { data } = await index.listVectors({
455426
* maxResults: 500,
456427
* returnMetadata: true
@@ -482,7 +453,7 @@ export class VectorIndexScope extends VectorDataApi {
482453
*
483454
* @example
484455
* ```typescript
485-
* const index = client.bucket('embeddings-prod').index('documents-openai')
456+
* const index = supabase.storage.vectors.from('embeddings-prod').index('documents-openai')
486457
* const { data } = await index.queryVectors({
487458
* queryVector: { float32: [0.1, 0.2, ...] },
488459
* topK: 5,
@@ -517,7 +488,7 @@ export class VectorIndexScope extends VectorDataApi {
517488
*
518489
* @example
519490
* ```typescript
520-
* const index = client.bucket('embeddings-prod').index('documents-openai')
491+
* const index = supabase.storage.vectors.from('embeddings-prod').index('documents-openai')
521492
* await index.deleteVectors({
522493
* keys: ['doc-1', 'doc-2', 'doc-3']
523494
* })

0 commit comments

Comments
 (0)