Skip to content

Commit 7053e54

Browse files
fenosmandarini
authored andcommitted
fix(storage): endpoint calls
1 parent 0d12232 commit 7053e54

File tree

8 files changed

+53
-54
lines changed

8 files changed

+53
-54
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ describe('VectorBucketApi Integration Tests', () => {
3333
const response = await client.createVectorBucket(bucketName)
3434

3535
const error = assertErrorResponse(response)
36-
assertErrorCode(error, 'S3VectorConflictException')
36+
assertErrorCode(error, 409)
3737
expect(error.message).toContain('already exists')
3838
})
3939

@@ -70,7 +70,7 @@ describe('VectorBucketApi Integration Tests', () => {
7070
const response = await client.getVectorBucket('non-existent-bucket')
7171

7272
const error = assertErrorResponse(response)
73-
assertErrorCode(error, 'S3VectorNotFoundException')
73+
assertErrorCode(error, 404)
7474
expect(error.message).toContain('not found')
7575
})
7676

@@ -177,7 +177,7 @@ describe('VectorBucketApi Integration Tests', () => {
177177
const response = await client.deleteVectorBucket('non-existent-bucket')
178178

179179
const error = assertErrorResponse(response)
180-
assertErrorCode(error, 'S3VectorNotFoundException')
180+
assertErrorCode(error, 409)
181181
})
182182

183183
it('should return error when bucket is not empty', async () => {
@@ -198,7 +198,7 @@ describe('VectorBucketApi Integration Tests', () => {
198198
const response = await client.deleteVectorBucket(bucketName)
199199

200200
const error = assertErrorResponse(response)
201-
assertErrorCode(error, 'S3VectorBucketNotEmpty')
201+
assertErrorCode(error, 409)
202202
expect(error.message).toContain('not empty')
203203
})
204204

packages/integrations/storage-vectors-js/src/__tests__/helpers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@ export async function retry<T>(
9696
/**
9797
* Assert that an error has a specific status code
9898
*/
99-
export function assertErrorCode(error: any, expectedCode: string) {
99+
export function assertErrorCode(error: any, expectedCode: number) {
100100
expect(error).toBeTruthy()
101-
expect(error.statusCode).toBe(expectedCode)
101+
expect(error.statusCode.toString()).toBe(expectedCode.toString())
102102
}
103103

104104
/**

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ describe('VectorIndexApi Integration Tests', () => {
9898
})
9999

100100
const error = assertErrorResponse(response)
101-
assertErrorCode(error, 'S3VectorConflictException')
101+
assertErrorCode(error, 409)
102102
expect(error.message).toContain('already exists')
103103
})
104104

@@ -113,7 +113,7 @@ describe('VectorIndexApi Integration Tests', () => {
113113
})
114114

115115
const error = assertErrorResponse(response)
116-
assertErrorCode(error, 'S3VectorNotFoundException')
116+
assertErrorCode(error, 404)
117117
})
118118

119119
it('should create multiple indexes in the same bucket', async () => {
@@ -208,15 +208,15 @@ describe('VectorIndexApi Integration Tests', () => {
208208
const response = await bucket.getIndex('non-existent-index')
209209

210210
const error = assertErrorResponse(response)
211-
assertErrorCode(error, 'S3VectorNotFoundException')
211+
assertErrorCode(error, 404)
212212
})
213213

214214
it('should return not found error when bucket does not exist', async () => {
215215
const bucket = client.from('non-existent-bucket')
216216
const response = await bucket.getIndex('test-index')
217217

218218
const error = assertErrorResponse(response)
219-
assertErrorCode(error, 'S3VectorNotFoundException')
219+
assertErrorCode(error, 404)
220220
})
221221
})
222222

@@ -330,7 +330,7 @@ describe('VectorIndexApi Integration Tests', () => {
330330
const response = await bucket.listIndexes()
331331

332332
const error = assertErrorResponse(response)
333-
assertErrorCode(error, 'S3VectorNotFoundException')
333+
assertErrorCode(error, 404)
334334
})
335335
})
336336

@@ -387,15 +387,15 @@ describe('VectorIndexApi Integration Tests', () => {
387387
const response = await bucket.deleteIndex('non-existent-index')
388388

389389
const error = assertErrorResponse(response)
390-
assertErrorCode(error, 'S3VectorNotFoundException')
390+
assertErrorCode(error, 404)
391391
})
392392

393393
it('should return not found error when bucket does not exist', async () => {
394394
const bucket = client.from('non-existent-bucket')
395395
const response = await bucket.deleteIndex('test-index')
396396

397397
const error = assertErrorResponse(response)
398-
assertErrorCode(error, 'S3VectorNotFoundException')
398+
assertErrorCode(error, 404)
399399
})
400400
})
401401

packages/integrations/storage-vectors-js/src/__tests__/mock-server.ts

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ interface MockResponse {
1212
status: number
1313
data?: any
1414
error?: {
15-
statusCode: string
15+
statusCode: number
1616
error: string
1717
message: string
1818
}
@@ -186,7 +186,7 @@ export function createMockFetch(): Fetch {
186186
response = {
187187
status: 500,
188188
error: {
189-
statusCode: 'InternalError',
189+
statusCode: 500,
190190
error: 'Internal Server Error',
191191
message: error.message,
192192
},
@@ -257,7 +257,7 @@ async function handleRequest(
257257
return {
258258
status: 404,
259259
error: {
260-
statusCode: 'NotFound',
260+
statusCode: 404,
261261
error: 'Not Found',
262262
message: `Endpoint not found: ${endpoint}`,
263263
},
@@ -272,7 +272,7 @@ function handleCreateBucket(body: any): MockResponse {
272272
return {
273273
status: 409,
274274
error: {
275-
statusCode: 'S3VectorConflictException',
275+
statusCode: 409,
276276
error: 'Conflict',
277277
message: `Bucket '${vectorBucketName}' already exists`,
278278
},
@@ -290,7 +290,7 @@ function handleGetBucket(body: any): MockResponse {
290290
return {
291291
status: 404,
292292
error: {
293-
statusCode: 'S3VectorNotFoundException',
293+
statusCode: 404,
294294
error: 'Not Found',
295295
message: `Bucket '${vectorBucketName}' not found`,
296296
},
@@ -328,7 +328,7 @@ function handleDeleteBucket(body: any): MockResponse {
328328
return {
329329
status: 404,
330330
error: {
331-
statusCode: 'S3VectorNotFoundException',
331+
statusCode: 409,
332332
error: 'Not Found',
333333
message: `Bucket '${vectorBucketName}' not found`,
334334
},
@@ -340,7 +340,7 @@ function handleDeleteBucket(body: any): MockResponse {
340340
return {
341341
status: 400,
342342
error: {
343-
statusCode: 'S3VectorBucketNotEmpty',
343+
statusCode: 409,
344344
error: 'Bad Request',
345345
message: `Bucket '${vectorBucketName}' is not empty`,
346346
},
@@ -359,7 +359,7 @@ function handleCreateIndex(body: any): MockResponse {
359359
return {
360360
status: 404,
361361
error: {
362-
statusCode: 'S3VectorNotFoundException',
362+
statusCode: 409,
363363
error: 'Not Found',
364364
message: `Bucket '${vectorBucketName}' not found`,
365365
},
@@ -370,7 +370,7 @@ function handleCreateIndex(body: any): MockResponse {
370370
return {
371371
status: 409,
372372
error: {
373-
statusCode: 'S3VectorConflictException',
373+
statusCode: 409,
374374
error: 'Conflict',
375375
message: `Index '${indexName}' already exists`,
376376
},
@@ -392,7 +392,7 @@ function handleGetIndex(body: any): MockResponse {
392392
return {
393393
status: 404,
394394
error: {
395-
statusCode: 'S3VectorNotFoundException',
395+
statusCode: 409,
396396
error: 'Not Found',
397397
message: `Bucket '${vectorBucketName}' not found`,
398398
},
@@ -404,7 +404,7 @@ function handleGetIndex(body: any): MockResponse {
404404
return {
405405
status: 404,
406406
error: {
407-
statusCode: 'S3VectorNotFoundException',
407+
statusCode: 409,
408408
error: 'Not Found',
409409
message: `Index '${indexName}' not found`,
410410
},
@@ -424,7 +424,7 @@ function handleListIndexes(body: any): MockResponse {
424424
return {
425425
status: 404,
426426
error: {
427-
statusCode: 'S3VectorNotFoundException',
427+
statusCode: 409,
428428
error: 'Not Found',
429429
message: `Bucket '${vectorBucketName}' not found`,
430430
},
@@ -449,7 +449,7 @@ function handleDeleteIndex(body: any): MockResponse {
449449
return {
450450
status: 404,
451451
error: {
452-
statusCode: 'S3VectorNotFoundException',
452+
statusCode: 409,
453453
error: 'Not Found',
454454
message: `Bucket '${vectorBucketName}' not found`,
455455
},
@@ -460,7 +460,7 @@ function handleDeleteIndex(body: any): MockResponse {
460460
return {
461461
status: 404,
462462
error: {
463-
statusCode: 'S3VectorNotFoundException',
463+
statusCode: 409,
464464
error: 'Not Found',
465465
message: `Index '${indexName}' not found`,
466466
},
@@ -479,7 +479,7 @@ function handlePutVectors(body: any): MockResponse {
479479
return {
480480
status: 404,
481481
error: {
482-
statusCode: 'S3VectorNotFoundException',
482+
statusCode: 404,
483483
error: 'Not Found',
484484
message: `Bucket '${vectorBucketName}' not found`,
485485
},
@@ -490,7 +490,7 @@ function handlePutVectors(body: any): MockResponse {
490490
return {
491491
status: 404,
492492
error: {
493-
statusCode: 'S3VectorNotFoundException',
493+
statusCode: 404,
494494
error: 'Not Found',
495495
message: `Index '${indexName}' not found`,
496496
},
@@ -511,7 +511,7 @@ function handleGetVectors(body: any): MockResponse {
511511
return {
512512
status: 404,
513513
error: {
514-
statusCode: 'S3VectorNotFoundException',
514+
statusCode: 404,
515515
error: 'Not Found',
516516
message: `Bucket '${vectorBucketName}' not found`,
517517
},
@@ -522,7 +522,7 @@ function handleGetVectors(body: any): MockResponse {
522522
return {
523523
status: 404,
524524
error: {
525-
statusCode: 'S3VectorNotFoundException',
525+
statusCode: 404,
526526
error: 'Not Found',
527527
message: `Index '${indexName}' not found`,
528528
},
@@ -555,7 +555,7 @@ function handleListVectors(body: any): MockResponse {
555555
return {
556556
status: 404,
557557
error: {
558-
statusCode: 'S3VectorNotFoundException',
558+
statusCode: 404,
559559
error: 'Not Found',
560560
message: `Bucket '${vectorBucketName}' not found`,
561561
},
@@ -566,7 +566,7 @@ function handleListVectors(body: any): MockResponse {
566566
return {
567567
status: 404,
568568
error: {
569-
statusCode: 'S3VectorNotFoundException',
569+
statusCode: 404,
570570
error: 'Not Found',
571571
message: `Index '${indexName}' not found`,
572572
},
@@ -596,7 +596,6 @@ function handleQueryVectors(body: any): MockResponse {
596596
const {
597597
vectorBucketName,
598598
indexName,
599-
queryVector,
600599
topK = 10,
601600
filter,
602601
returnDistance = false,
@@ -607,7 +606,7 @@ function handleQueryVectors(body: any): MockResponse {
607606
return {
608607
status: 404,
609608
error: {
610-
statusCode: 'S3VectorNotFoundException',
609+
statusCode: 409,
611610
error: 'Not Found',
612611
message: `Bucket '${vectorBucketName}' not found`,
613612
},
@@ -618,7 +617,7 @@ function handleQueryVectors(body: any): MockResponse {
618617
return {
619618
status: 404,
620619
error: {
621-
statusCode: 'S3VectorNotFoundException',
620+
statusCode: 404,
622621
error: 'Not Found',
623622
message: `Index '${indexName}' not found`,
624623
},
@@ -662,7 +661,7 @@ function handleDeleteVectors(body: any): MockResponse {
662661
return {
663662
status: 404,
664663
error: {
665-
statusCode: 'S3VectorNotFoundException',
664+
statusCode: 404,
666665
error: 'Not Found',
667666
message: `Bucket '${vectorBucketName}' not found`,
668667
},
@@ -673,7 +672,7 @@ function handleDeleteVectors(body: any): MockResponse {
673672
return {
674673
status: 404,
675674
error: {
676-
statusCode: 'S3VectorNotFoundException',
675+
statusCode: 404,
677676
error: 'Not Found',
678677
message: `Index '${indexName}' not found`,
679678
},

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ describe('VectorDataApi Integration Tests', () => {
145145
})
146146

147147
const error = assertErrorResponse(response)
148-
assertErrorCode(error, 'S3VectorNotFoundException')
148+
assertErrorCode(error, 404)
149149
})
150150

151151
it('should return not found error when index does not exist', async () => {
@@ -156,7 +156,7 @@ describe('VectorDataApi Integration Tests', () => {
156156
})
157157

158158
const error = assertErrorResponse(response)
159-
assertErrorCode(error, 'S3VectorNotFoundException')
159+
assertErrorCode(error, 404)
160160
})
161161

162162
it('should handle batch size limits', async () => {
@@ -608,7 +608,7 @@ describe('VectorDataApi Integration Tests', () => {
608608
const response = await index.deleteVectors({ keys: ['vec-1'] })
609609

610610
const error = assertErrorResponse(response)
611-
assertErrorCode(error, 'S3VectorNotFoundException')
611+
assertErrorCode(error, 404)
612612
})
613613

614614
it('should return not found error when index does not exist', async () => {
@@ -617,7 +617,7 @@ describe('VectorDataApi Integration Tests', () => {
617617
const response = await index.deleteVectors({ keys: ['vec-1'] })
618618

619619
const error = assertErrorResponse(response)
620-
assertErrorCode(error, 'S3VectorNotFoundException')
620+
assertErrorCode(error, 404)
621621
})
622622
})
623623

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { DEFAULT_HEADERS } from './constants'
22
import { isStorageVectorsError } from './errors'
3-
import { Fetch, post, remove } from './fetch'
3+
import { Fetch, post } from './fetch'
44
import { resolveFetch } from './helpers'
55
import {
66
ApiResponse,
@@ -62,7 +62,7 @@ export default class VectorBucketApi {
6262
* }
6363
* ```
6464
*/
65-
async createVectorBucket(vectorBucketName: string): Promise<ApiResponse<{}>> {
65+
async createVectorBucket(vectorBucketName: string): Promise<ApiResponse<undefined>> {
6666
try {
6767
const data = await post(
6868
this.fetch,
@@ -190,9 +190,9 @@ export default class VectorBucketApi {
190190
* }
191191
* ```
192192
*/
193-
async deleteVectorBucket(vectorBucketName: string): Promise<ApiResponse<{}>> {
193+
async deleteVectorBucket(vectorBucketName: string): Promise<ApiResponse<undefined>> {
194194
try {
195-
const data = await remove(
195+
const data = await post(
196196
this.fetch,
197197
`${this.url}/DeleteVectorBucket`,
198198
{ vectorBucketName },

0 commit comments

Comments
 (0)