@supabase/storage-js 2.79.1-canary.1 → 2.80.0
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.
- package/README.md +920 -12
- package/dist/main/StorageClient.d.ts +28 -0
- package/dist/main/StorageClient.d.ts.map +1 -1
- package/dist/main/StorageClient.js +38 -5
- package/dist/main/StorageClient.js.map +1 -1
- package/dist/main/index.d.ts +2 -0
- package/dist/main/index.d.ts.map +1 -1
- package/dist/main/index.js +7 -17
- package/dist/main/index.js.map +1 -1
- package/dist/main/lib/constants.d.ts.map +1 -1
- package/dist/main/lib/constants.js +3 -1
- package/dist/main/lib/constants.js.map +1 -1
- package/dist/main/lib/fetch.d.ts.map +1 -1
- package/dist/main/lib/fetch.js +16 -17
- package/dist/main/lib/fetch.js.map +1 -1
- package/dist/main/lib/helpers.d.ts +1 -1
- package/dist/main/lib/helpers.d.ts.map +1 -1
- package/dist/main/lib/helpers.js +4 -57
- package/dist/main/lib/helpers.js.map +1 -1
- package/dist/main/lib/index.d.ts +1 -0
- package/dist/main/lib/index.d.ts.map +1 -1
- package/dist/main/lib/index.js +6 -18
- package/dist/main/lib/index.js.map +1 -1
- package/dist/main/lib/types.d.ts +74 -4
- package/dist/main/lib/types.d.ts.map +1 -1
- package/dist/main/lib/vectors/StorageVectorsClient.d.ts +310 -0
- package/dist/main/lib/vectors/StorageVectorsClient.d.ts.map +1 -0
- package/dist/main/lib/vectors/StorageVectorsClient.js +366 -0
- package/dist/main/lib/vectors/StorageVectorsClient.js.map +1 -0
- package/dist/main/lib/vectors/VectorBucketApi.d.ts +129 -0
- package/dist/main/lib/vectors/VectorBucketApi.d.ts.map +1 -0
- package/dist/main/lib/vectors/VectorBucketApi.js +199 -0
- package/dist/main/lib/vectors/VectorBucketApi.js.map +1 -0
- package/dist/main/lib/vectors/VectorDataApi.d.ts +221 -0
- package/dist/main/lib/vectors/VectorDataApi.d.ts.map +1 -0
- package/dist/main/lib/vectors/VectorDataApi.js +336 -0
- package/dist/main/lib/vectors/VectorDataApi.js.map +1 -0
- package/dist/main/lib/vectors/VectorIndexApi.d.ts +157 -0
- package/dist/main/lib/vectors/VectorIndexApi.d.ts.map +1 -0
- package/dist/main/lib/vectors/VectorIndexApi.js +218 -0
- package/dist/main/lib/vectors/VectorIndexApi.js.map +1 -0
- package/dist/main/lib/vectors/constants.d.ts +5 -0
- package/dist/main/lib/vectors/constants.d.ts.map +1 -0
- package/dist/main/lib/vectors/constants.js +9 -0
- package/dist/main/lib/vectors/constants.js.map +1 -0
- package/dist/main/lib/vectors/errors.d.ts +55 -0
- package/dist/main/lib/vectors/errors.d.ts.map +1 -0
- package/dist/main/lib/vectors/errors.js +76 -0
- package/dist/main/lib/vectors/errors.js.map +1 -0
- package/dist/main/lib/vectors/fetch.d.ts +57 -0
- package/dist/main/lib/vectors/fetch.d.ts.map +1 -0
- package/dist/main/lib/vectors/fetch.js +167 -0
- package/dist/main/lib/vectors/fetch.js.map +1 -0
- package/dist/main/lib/vectors/helpers.d.ts +46 -0
- package/dist/main/lib/vectors/helpers.d.ts.map +1 -0
- package/dist/main/lib/vectors/helpers.js +74 -0
- package/dist/main/lib/vectors/helpers.js.map +1 -0
- package/dist/main/lib/vectors/index.d.ts +11 -0
- package/dist/main/lib/vectors/index.d.ts.map +1 -0
- package/dist/main/lib/vectors/index.js +31 -0
- package/dist/main/lib/vectors/index.js.map +1 -0
- package/dist/main/lib/vectors/types.d.ts +277 -0
- package/dist/main/lib/vectors/types.d.ts.map +1 -0
- package/dist/main/lib/vectors/types.js +3 -0
- package/dist/main/lib/vectors/types.js.map +1 -0
- package/dist/main/lib/version.d.ts +1 -1
- package/dist/main/lib/version.d.ts.map +1 -1
- package/dist/main/lib/version.js +1 -1
- package/dist/main/lib/version.js.map +1 -1
- package/dist/main/packages/BlobDownloadBuilder.d.ts +6 -1
- package/dist/main/packages/BlobDownloadBuilder.d.ts.map +1 -1
- package/dist/main/packages/BlobDownloadBuilder.js +20 -15
- package/dist/main/packages/BlobDownloadBuilder.js.map +1 -1
- package/dist/main/packages/StorageAnalyticsApi.d.ts +123 -0
- package/dist/main/packages/StorageAnalyticsApi.d.ts.map +1 -0
- package/dist/main/packages/StorageAnalyticsApi.js +164 -0
- package/dist/main/packages/StorageAnalyticsApi.js.map +1 -0
- package/dist/main/packages/StorageBucketApi.d.ts +3 -2
- package/dist/main/packages/StorageBucketApi.d.ts.map +1 -1
- package/dist/main/packages/StorageBucketApi.js +34 -18
- package/dist/main/packages/StorageBucketApi.js.map +1 -1
- package/dist/main/packages/StorageFileApi.d.ts.map +1 -1
- package/dist/main/packages/StorageFileApi.js +28 -29
- package/dist/main/packages/StorageFileApi.js.map +1 -1
- package/dist/main/packages/StreamDownloadBuilder.js +2 -10
- package/dist/main/packages/StreamDownloadBuilder.js.map +1 -1
- package/dist/module/StorageClient.d.ts +28 -0
- package/dist/module/StorageClient.d.ts.map +1 -1
- package/dist/module/StorageClient.js +35 -0
- package/dist/module/StorageClient.js.map +1 -1
- package/dist/module/index.d.ts +2 -0
- package/dist/module/index.d.ts.map +1 -1
- package/dist/module/index.js +2 -0
- package/dist/module/index.js.map +1 -1
- package/dist/module/lib/constants.d.ts.map +1 -1
- package/dist/module/lib/constants.js +3 -1
- package/dist/module/lib/constants.js.map +1 -1
- package/dist/module/lib/fetch.d.ts.map +1 -1
- package/dist/module/lib/fetch.js +9 -10
- package/dist/module/lib/fetch.js.map +1 -1
- package/dist/module/lib/helpers.d.ts +1 -1
- package/dist/module/lib/helpers.d.ts.map +1 -1
- package/dist/module/lib/helpers.js +4 -24
- package/dist/module/lib/helpers.js.map +1 -1
- package/dist/module/lib/index.d.ts +1 -0
- package/dist/module/lib/index.d.ts.map +1 -1
- package/dist/module/lib/index.js +1 -0
- package/dist/module/lib/index.js.map +1 -1
- package/dist/module/lib/types.d.ts +74 -4
- package/dist/module/lib/types.d.ts.map +1 -1
- package/dist/module/lib/vectors/StorageVectorsClient.d.ts +310 -0
- package/dist/module/lib/vectors/StorageVectorsClient.d.ts.map +1 -0
- package/dist/module/lib/vectors/StorageVectorsClient.js +360 -0
- package/dist/module/lib/vectors/StorageVectorsClient.js.map +1 -0
- package/dist/module/lib/vectors/VectorBucketApi.d.ts +129 -0
- package/dist/module/lib/vectors/VectorBucketApi.d.ts.map +1 -0
- package/dist/module/lib/vectors/VectorBucketApi.js +196 -0
- package/dist/module/lib/vectors/VectorBucketApi.js.map +1 -0
- package/dist/module/lib/vectors/VectorDataApi.d.ts +221 -0
- package/dist/module/lib/vectors/VectorDataApi.d.ts.map +1 -0
- package/dist/module/lib/vectors/VectorDataApi.js +333 -0
- package/dist/module/lib/vectors/VectorDataApi.js.map +1 -0
- package/dist/module/lib/vectors/VectorIndexApi.d.ts +157 -0
- package/dist/module/lib/vectors/VectorIndexApi.d.ts.map +1 -0
- package/dist/module/lib/vectors/VectorIndexApi.js +215 -0
- package/dist/module/lib/vectors/VectorIndexApi.js.map +1 -0
- package/dist/module/lib/vectors/constants.d.ts +5 -0
- package/dist/module/lib/vectors/constants.d.ts.map +1 -0
- package/dist/module/lib/vectors/constants.js +6 -0
- package/dist/module/lib/vectors/constants.js.map +1 -0
- package/dist/module/lib/vectors/errors.d.ts +55 -0
- package/dist/module/lib/vectors/errors.d.ts.map +1 -0
- package/dist/module/lib/vectors/errors.js +69 -0
- package/dist/module/lib/vectors/errors.js.map +1 -0
- package/dist/module/lib/vectors/fetch.d.ts +57 -0
- package/dist/module/lib/vectors/fetch.d.ts.map +1 -0
- package/dist/module/lib/vectors/fetch.js +161 -0
- package/dist/module/lib/vectors/fetch.js.map +1 -0
- package/dist/module/lib/vectors/helpers.d.ts +46 -0
- package/dist/module/lib/vectors/helpers.d.ts.map +1 -0
- package/dist/module/lib/vectors/helpers.js +66 -0
- package/dist/module/lib/vectors/helpers.js.map +1 -0
- package/dist/module/lib/vectors/index.d.ts +11 -0
- package/dist/module/lib/vectors/index.d.ts.map +1 -0
- package/dist/module/lib/vectors/index.js +11 -0
- package/dist/module/lib/vectors/index.js.map +1 -0
- package/dist/module/lib/vectors/types.d.ts +277 -0
- package/dist/module/lib/vectors/types.d.ts.map +1 -0
- package/dist/module/lib/vectors/types.js +2 -0
- package/dist/module/lib/vectors/types.js.map +1 -0
- package/dist/module/lib/version.d.ts +1 -1
- package/dist/module/lib/version.d.ts.map +1 -1
- package/dist/module/lib/version.js +1 -1
- package/dist/module/lib/version.js.map +1 -1
- package/dist/module/packages/BlobDownloadBuilder.d.ts +6 -1
- package/dist/module/packages/BlobDownloadBuilder.d.ts.map +1 -1
- package/dist/module/packages/BlobDownloadBuilder.js +20 -11
- package/dist/module/packages/BlobDownloadBuilder.js.map +1 -1
- package/dist/module/packages/StorageAnalyticsApi.d.ts +123 -0
- package/dist/module/packages/StorageAnalyticsApi.d.ts.map +1 -0
- package/dist/module/packages/StorageAnalyticsApi.js +161 -0
- package/dist/module/packages/StorageAnalyticsApi.js.map +1 -0
- package/dist/module/packages/StorageBucketApi.d.ts +3 -2
- package/dist/module/packages/StorageBucketApi.d.ts.map +1 -1
- package/dist/module/packages/StorageBucketApi.js +28 -12
- package/dist/module/packages/StorageBucketApi.js.map +1 -1
- package/dist/module/packages/StorageFileApi.d.ts.map +1 -1
- package/dist/module/packages/StorageFileApi.js +13 -11
- package/dist/module/packages/StorageFileApi.js.map +1 -1
- package/dist/module/packages/StreamDownloadBuilder.js +1 -9
- package/dist/module/packages/StreamDownloadBuilder.js.map +1 -1
- package/dist/tsconfig.module.tsbuildinfo +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/umd/supabase.js +1 -1
- package/package.json +6 -13
- package/src/StorageClient.ts +37 -0
- package/src/index.ts +2 -0
- package/src/lib/constants.ts +3 -1
- package/src/lib/fetch.ts +5 -1
- package/src/lib/helpers.ts +3 -14
- package/src/lib/index.ts +1 -0
- package/src/lib/types.ts +83 -2
- package/src/lib/vectors/StorageVectorsClient.ts +405 -0
- package/src/lib/vectors/VectorBucketApi.ts +217 -0
- package/src/lib/vectors/VectorDataApi.ts +341 -0
- package/src/lib/vectors/VectorIndexApi.ts +245 -0
- package/src/lib/vectors/constants.ts +5 -0
- package/src/lib/vectors/errors.ts +78 -0
- package/src/lib/vectors/fetch.ts +218 -0
- package/src/lib/vectors/helpers.ts +79 -0
- package/src/lib/vectors/index.ts +66 -0
- package/src/lib/vectors/types.ts +299 -0
- package/src/lib/version.ts +1 -1
- package/src/packages/BlobDownloadBuilder.ts +22 -2
- package/src/packages/StorageAnalyticsApi.ts +199 -0
- package/src/packages/StorageBucketApi.ts +29 -4
- package/src/packages/StorageFileApi.ts +15 -2
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { Fetch } from './fetch';
|
|
2
|
+
import { ApiResponse, VectorBucket, ListVectorBucketsOptions, ListVectorBucketsResponse } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* API class for managing Vector Buckets
|
|
5
|
+
* Provides methods for creating, reading, listing, and deleting vector buckets
|
|
6
|
+
*/
|
|
7
|
+
export default class VectorBucketApi {
|
|
8
|
+
protected url: string;
|
|
9
|
+
protected headers: {
|
|
10
|
+
[key: string]: string;
|
|
11
|
+
};
|
|
12
|
+
protected fetch: Fetch;
|
|
13
|
+
protected shouldThrowOnError: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Creates a new VectorBucketApi instance
|
|
16
|
+
* @param url - The base URL for the storage vectors API
|
|
17
|
+
* @param headers - HTTP headers to include in requests
|
|
18
|
+
* @param fetch - Optional custom fetch implementation
|
|
19
|
+
*/
|
|
20
|
+
constructor(url: string, headers?: {
|
|
21
|
+
[key: string]: string;
|
|
22
|
+
}, fetch?: Fetch);
|
|
23
|
+
/**
|
|
24
|
+
* Enable throwing errors instead of returning them in the response
|
|
25
|
+
* When enabled, failed operations will throw instead of returning { data: null, error }
|
|
26
|
+
*
|
|
27
|
+
* @returns This instance for method chaining
|
|
28
|
+
* @example
|
|
29
|
+
* ```typescript
|
|
30
|
+
* const client = new VectorBucketApi(url, headers)
|
|
31
|
+
* client.throwOnError()
|
|
32
|
+
* const { data } = await client.createBucket('my-bucket') // throws on error
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
throwOnError(): this;
|
|
36
|
+
/**
|
|
37
|
+
* Creates a new vector bucket
|
|
38
|
+
* Vector buckets are containers for vector indexes and their data
|
|
39
|
+
*
|
|
40
|
+
* @param vectorBucketName - Unique name for the vector bucket
|
|
41
|
+
* @returns Promise with empty response on success or error
|
|
42
|
+
*
|
|
43
|
+
* @throws {StorageVectorsApiError} With code:
|
|
44
|
+
* - `S3VectorConflictException` if bucket already exists (HTTP 409)
|
|
45
|
+
* - `S3VectorMaxBucketsExceeded` if quota exceeded (HTTP 400)
|
|
46
|
+
* - `InternalError` for server errors (HTTP 500)
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```typescript
|
|
50
|
+
* const { data, error } = await client.createBucket('embeddings-prod')
|
|
51
|
+
* if (error) {
|
|
52
|
+
* console.error('Failed to create bucket:', error.message)
|
|
53
|
+
* }
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
createBucket(vectorBucketName: string): Promise<ApiResponse<undefined>>;
|
|
57
|
+
/**
|
|
58
|
+
* Retrieves metadata for a specific vector bucket
|
|
59
|
+
* Returns bucket configuration including encryption settings and creation time
|
|
60
|
+
*
|
|
61
|
+
* @param vectorBucketName - Name of the vector bucket to retrieve
|
|
62
|
+
* @returns Promise with bucket metadata or error
|
|
63
|
+
*
|
|
64
|
+
* @throws {StorageVectorsApiError} With code:
|
|
65
|
+
* - `S3VectorNotFoundException` if bucket doesn't exist (HTTP 404)
|
|
66
|
+
* - `InternalError` for server errors (HTTP 500)
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```typescript
|
|
70
|
+
* const { data, error } = await client.getBucket('embeddings-prod')
|
|
71
|
+
* if (data) {
|
|
72
|
+
* console.log('Bucket created at:', new Date(data.vectorBucket.creationTime! * 1000))
|
|
73
|
+
* }
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
getBucket(vectorBucketName: string): Promise<ApiResponse<{
|
|
77
|
+
vectorBucket: VectorBucket;
|
|
78
|
+
}>>;
|
|
79
|
+
/**
|
|
80
|
+
* Lists vector buckets with optional filtering and pagination
|
|
81
|
+
* Supports prefix-based filtering and paginated results
|
|
82
|
+
*
|
|
83
|
+
* @param options - Listing options
|
|
84
|
+
* @param options.prefix - Filter buckets by name prefix
|
|
85
|
+
* @param options.maxResults - Maximum results per page (default: 100)
|
|
86
|
+
* @param options.nextToken - Pagination token from previous response
|
|
87
|
+
* @returns Promise with list of buckets and pagination token
|
|
88
|
+
*
|
|
89
|
+
* @throws {StorageVectorsApiError} With code:
|
|
90
|
+
* - `InternalError` for server errors (HTTP 500)
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```typescript
|
|
94
|
+
* // List all buckets with prefix 'prod-'
|
|
95
|
+
* const { data, error } = await client.listBuckets({ prefix: 'prod-' })
|
|
96
|
+
* if (data) {
|
|
97
|
+
* console.log('Found buckets:', data.buckets.length)
|
|
98
|
+
* // Fetch next page if available
|
|
99
|
+
* if (data.nextToken) {
|
|
100
|
+
* const next = await client.listBuckets({ nextToken: data.nextToken })
|
|
101
|
+
* }
|
|
102
|
+
* }
|
|
103
|
+
* ```
|
|
104
|
+
*/
|
|
105
|
+
listBuckets(options?: ListVectorBucketsOptions): Promise<ApiResponse<ListVectorBucketsResponse>>;
|
|
106
|
+
/**
|
|
107
|
+
* Deletes a vector bucket
|
|
108
|
+
* Bucket must be empty before deletion (all indexes must be removed first)
|
|
109
|
+
*
|
|
110
|
+
* @param vectorBucketName - Name of the vector bucket to delete
|
|
111
|
+
* @returns Promise with empty response on success or error
|
|
112
|
+
*
|
|
113
|
+
* @throws {StorageVectorsApiError} With code:
|
|
114
|
+
* - `S3VectorBucketNotEmpty` if bucket contains indexes (HTTP 400)
|
|
115
|
+
* - `S3VectorNotFoundException` if bucket doesn't exist (HTTP 404)
|
|
116
|
+
* - `InternalError` for server errors (HTTP 500)
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* ```typescript
|
|
120
|
+
* // Delete all indexes first, then delete bucket
|
|
121
|
+
* const { error } = await client.deleteBucket('old-bucket')
|
|
122
|
+
* if (error?.statusCode === 'S3VectorBucketNotEmpty') {
|
|
123
|
+
* console.error('Must delete all indexes first')
|
|
124
|
+
* }
|
|
125
|
+
* ```
|
|
126
|
+
*/
|
|
127
|
+
deleteBucket(vectorBucketName: string): Promise<ApiResponse<undefined>>;
|
|
128
|
+
}
|
|
129
|
+
//# sourceMappingURL=VectorBucketApi.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VectorBucketApi.d.ts","sourceRoot":"","sources":["../../../../src/lib/vectors/VectorBucketApi.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAQ,MAAM,SAAS,CAAA;AAErC,OAAO,EACL,WAAW,EACX,YAAY,EACZ,wBAAwB,EACxB,yBAAyB,EAC1B,MAAM,SAAS,CAAA;AAEhB;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,eAAe;IAClC,SAAS,CAAC,GAAG,EAAE,MAAM,CAAA;IACrB,SAAS,CAAC,OAAO,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAA;IAC5C,SAAS,CAAC,KAAK,EAAE,KAAK,CAAA;IACtB,SAAS,CAAC,kBAAkB,UAAQ;IAEpC;;;;;OAKG;gBACS,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAO,EAAE,KAAK,CAAC,EAAE,KAAK;IAM/E;;;;;;;;;;;OAWG;IACI,YAAY,IAAI,IAAI;IAK3B;;;;;;;;;;;;;;;;;;;OAmBG;IACG,YAAY,CAAC,gBAAgB,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;IAoB7E;;;;;;;;;;;;;;;;;;OAkBG;IACG,SAAS,CACb,gBAAgB,EAAE,MAAM,GACvB,OAAO,CAAC,WAAW,CAAC;QAAE,YAAY,EAAE,YAAY,CAAA;KAAE,CAAC,CAAC;IAoBvD;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACG,WAAW,CACf,OAAO,GAAE,wBAA6B,GACrC,OAAO,CAAC,WAAW,CAAC,yBAAyB,CAAC,CAAC;IAiBlD;;;;;;;;;;;;;;;;;;;;OAoBG;IACG,YAAY,CAAC,gBAAgB,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;CAmB9E"}
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const constants_1 = require("./constants");
|
|
5
|
+
const errors_1 = require("./errors");
|
|
6
|
+
const fetch_1 = require("./fetch");
|
|
7
|
+
const helpers_1 = require("./helpers");
|
|
8
|
+
/**
|
|
9
|
+
* API class for managing Vector Buckets
|
|
10
|
+
* Provides methods for creating, reading, listing, and deleting vector buckets
|
|
11
|
+
*/
|
|
12
|
+
class VectorBucketApi {
|
|
13
|
+
/**
|
|
14
|
+
* Creates a new VectorBucketApi instance
|
|
15
|
+
* @param url - The base URL for the storage vectors API
|
|
16
|
+
* @param headers - HTTP headers to include in requests
|
|
17
|
+
* @param fetch - Optional custom fetch implementation
|
|
18
|
+
*/
|
|
19
|
+
constructor(url, headers = {}, fetch) {
|
|
20
|
+
this.shouldThrowOnError = false;
|
|
21
|
+
this.url = url.replace(/\/$/, '');
|
|
22
|
+
this.headers = Object.assign(Object.assign({}, constants_1.DEFAULT_HEADERS), headers);
|
|
23
|
+
this.fetch = (0, helpers_1.resolveFetch)(fetch);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Enable throwing errors instead of returning them in the response
|
|
27
|
+
* When enabled, failed operations will throw instead of returning { data: null, error }
|
|
28
|
+
*
|
|
29
|
+
* @returns This instance for method chaining
|
|
30
|
+
* @example
|
|
31
|
+
* ```typescript
|
|
32
|
+
* const client = new VectorBucketApi(url, headers)
|
|
33
|
+
* client.throwOnError()
|
|
34
|
+
* const { data } = await client.createBucket('my-bucket') // throws on error
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
throwOnError() {
|
|
38
|
+
this.shouldThrowOnError = true;
|
|
39
|
+
return this;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Creates a new vector bucket
|
|
43
|
+
* Vector buckets are containers for vector indexes and their data
|
|
44
|
+
*
|
|
45
|
+
* @param vectorBucketName - Unique name for the vector bucket
|
|
46
|
+
* @returns Promise with empty response on success or error
|
|
47
|
+
*
|
|
48
|
+
* @throws {StorageVectorsApiError} With code:
|
|
49
|
+
* - `S3VectorConflictException` if bucket already exists (HTTP 409)
|
|
50
|
+
* - `S3VectorMaxBucketsExceeded` if quota exceeded (HTTP 400)
|
|
51
|
+
* - `InternalError` for server errors (HTTP 500)
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```typescript
|
|
55
|
+
* const { data, error } = await client.createBucket('embeddings-prod')
|
|
56
|
+
* if (error) {
|
|
57
|
+
* console.error('Failed to create bucket:', error.message)
|
|
58
|
+
* }
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
createBucket(vectorBucketName) {
|
|
62
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
63
|
+
try {
|
|
64
|
+
const data = yield (0, fetch_1.post)(this.fetch, `${this.url}/CreateVectorBucket`, { vectorBucketName }, { headers: this.headers });
|
|
65
|
+
return { data: data || {}, error: null };
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
if (this.shouldThrowOnError) {
|
|
69
|
+
throw error;
|
|
70
|
+
}
|
|
71
|
+
if ((0, errors_1.isStorageVectorsError)(error)) {
|
|
72
|
+
return { data: null, error };
|
|
73
|
+
}
|
|
74
|
+
throw error;
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Retrieves metadata for a specific vector bucket
|
|
80
|
+
* Returns bucket configuration including encryption settings and creation time
|
|
81
|
+
*
|
|
82
|
+
* @param vectorBucketName - Name of the vector bucket to retrieve
|
|
83
|
+
* @returns Promise with bucket metadata or error
|
|
84
|
+
*
|
|
85
|
+
* @throws {StorageVectorsApiError} With code:
|
|
86
|
+
* - `S3VectorNotFoundException` if bucket doesn't exist (HTTP 404)
|
|
87
|
+
* - `InternalError` for server errors (HTTP 500)
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* ```typescript
|
|
91
|
+
* const { data, error } = await client.getBucket('embeddings-prod')
|
|
92
|
+
* if (data) {
|
|
93
|
+
* console.log('Bucket created at:', new Date(data.vectorBucket.creationTime! * 1000))
|
|
94
|
+
* }
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
getBucket(vectorBucketName) {
|
|
98
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
99
|
+
try {
|
|
100
|
+
const data = yield (0, fetch_1.post)(this.fetch, `${this.url}/GetVectorBucket`, { vectorBucketName }, { headers: this.headers });
|
|
101
|
+
return { data, error: null };
|
|
102
|
+
}
|
|
103
|
+
catch (error) {
|
|
104
|
+
if (this.shouldThrowOnError) {
|
|
105
|
+
throw error;
|
|
106
|
+
}
|
|
107
|
+
if ((0, errors_1.isStorageVectorsError)(error)) {
|
|
108
|
+
return { data: null, error };
|
|
109
|
+
}
|
|
110
|
+
throw error;
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Lists vector buckets with optional filtering and pagination
|
|
116
|
+
* Supports prefix-based filtering and paginated results
|
|
117
|
+
*
|
|
118
|
+
* @param options - Listing options
|
|
119
|
+
* @param options.prefix - Filter buckets by name prefix
|
|
120
|
+
* @param options.maxResults - Maximum results per page (default: 100)
|
|
121
|
+
* @param options.nextToken - Pagination token from previous response
|
|
122
|
+
* @returns Promise with list of buckets and pagination token
|
|
123
|
+
*
|
|
124
|
+
* @throws {StorageVectorsApiError} With code:
|
|
125
|
+
* - `InternalError` for server errors (HTTP 500)
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
* ```typescript
|
|
129
|
+
* // List all buckets with prefix 'prod-'
|
|
130
|
+
* const { data, error } = await client.listBuckets({ prefix: 'prod-' })
|
|
131
|
+
* if (data) {
|
|
132
|
+
* console.log('Found buckets:', data.buckets.length)
|
|
133
|
+
* // Fetch next page if available
|
|
134
|
+
* if (data.nextToken) {
|
|
135
|
+
* const next = await client.listBuckets({ nextToken: data.nextToken })
|
|
136
|
+
* }
|
|
137
|
+
* }
|
|
138
|
+
* ```
|
|
139
|
+
*/
|
|
140
|
+
listBuckets() {
|
|
141
|
+
return tslib_1.__awaiter(this, arguments, void 0, function* (options = {}) {
|
|
142
|
+
try {
|
|
143
|
+
const data = yield (0, fetch_1.post)(this.fetch, `${this.url}/ListVectorBuckets`, options, {
|
|
144
|
+
headers: this.headers,
|
|
145
|
+
});
|
|
146
|
+
return { data, error: null };
|
|
147
|
+
}
|
|
148
|
+
catch (error) {
|
|
149
|
+
if (this.shouldThrowOnError) {
|
|
150
|
+
throw error;
|
|
151
|
+
}
|
|
152
|
+
if ((0, errors_1.isStorageVectorsError)(error)) {
|
|
153
|
+
return { data: null, error };
|
|
154
|
+
}
|
|
155
|
+
throw error;
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Deletes a vector bucket
|
|
161
|
+
* Bucket must be empty before deletion (all indexes must be removed first)
|
|
162
|
+
*
|
|
163
|
+
* @param vectorBucketName - Name of the vector bucket to delete
|
|
164
|
+
* @returns Promise with empty response on success or error
|
|
165
|
+
*
|
|
166
|
+
* @throws {StorageVectorsApiError} With code:
|
|
167
|
+
* - `S3VectorBucketNotEmpty` if bucket contains indexes (HTTP 400)
|
|
168
|
+
* - `S3VectorNotFoundException` if bucket doesn't exist (HTTP 404)
|
|
169
|
+
* - `InternalError` for server errors (HTTP 500)
|
|
170
|
+
*
|
|
171
|
+
* @example
|
|
172
|
+
* ```typescript
|
|
173
|
+
* // Delete all indexes first, then delete bucket
|
|
174
|
+
* const { error } = await client.deleteBucket('old-bucket')
|
|
175
|
+
* if (error?.statusCode === 'S3VectorBucketNotEmpty') {
|
|
176
|
+
* console.error('Must delete all indexes first')
|
|
177
|
+
* }
|
|
178
|
+
* ```
|
|
179
|
+
*/
|
|
180
|
+
deleteBucket(vectorBucketName) {
|
|
181
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
182
|
+
try {
|
|
183
|
+
const data = yield (0, fetch_1.post)(this.fetch, `${this.url}/DeleteVectorBucket`, { vectorBucketName }, { headers: this.headers });
|
|
184
|
+
return { data: data || {}, error: null };
|
|
185
|
+
}
|
|
186
|
+
catch (error) {
|
|
187
|
+
if (this.shouldThrowOnError) {
|
|
188
|
+
throw error;
|
|
189
|
+
}
|
|
190
|
+
if ((0, errors_1.isStorageVectorsError)(error)) {
|
|
191
|
+
return { data: null, error };
|
|
192
|
+
}
|
|
193
|
+
throw error;
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
exports.default = VectorBucketApi;
|
|
199
|
+
//# sourceMappingURL=VectorBucketApi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VectorBucketApi.js","sourceRoot":"","sources":["../../../../src/lib/vectors/VectorBucketApi.ts"],"names":[],"mappings":";;;AAAA,2CAA6C;AAC7C,qCAAgD;AAChD,mCAAqC;AACrC,uCAAwC;AAQxC;;;GAGG;AACH,MAAqB,eAAe;IAMlC;;;;;OAKG;IACH,YAAY,GAAW,EAAE,UAAqC,EAAE,EAAE,KAAa;QARrE,uBAAkB,GAAG,KA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GAAG,qBAAqB,EAChC,EAAE,gBAAgB,EAAE,EACpB,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAC1B,CAAA;gBACD,OAAO,EAAE,IAAI,EAAE,IAAI,IAAI,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAA;YAC1C,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,IAAI,IAAI,CAAC,kBAAkB,EAAE,CAAC;oBAC5B,MAAM,KAAK,CAAA;gBACb,CAAC;gBACD,IAAI,IAAA,8BAAqB,EAAC,KAAK,CAAC,EAAE,CAAC;oBACjC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAA;gBAC9B,CAAC;gBACD,MAAM,KAAK,CAAA;YACb,CAAC;QACH,CAAC;KAAA;CACF;AAzMD,kCAyMC"}
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import { Fetch } from './fetch';
|
|
2
|
+
import { ApiResponse, PutVectorsOptions, GetVectorsOptions, GetVectorsResponse, DeleteVectorsOptions, ListVectorsOptions, ListVectorsResponse, QueryVectorsOptions, QueryVectorsResponse } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* API class for managing Vector Data within Vector Indexes
|
|
5
|
+
* Provides methods for inserting, querying, listing, and deleting vector embeddings
|
|
6
|
+
*/
|
|
7
|
+
export default class VectorDataApi {
|
|
8
|
+
protected url: string;
|
|
9
|
+
protected headers: {
|
|
10
|
+
[key: string]: string;
|
|
11
|
+
};
|
|
12
|
+
protected fetch: Fetch;
|
|
13
|
+
protected shouldThrowOnError: boolean;
|
|
14
|
+
constructor(url: string, headers?: {
|
|
15
|
+
[key: string]: string;
|
|
16
|
+
}, fetch?: Fetch);
|
|
17
|
+
/**
|
|
18
|
+
* Enable throwing errors instead of returning them in the response
|
|
19
|
+
* When enabled, failed operations will throw instead of returning { data: null, error }
|
|
20
|
+
*
|
|
21
|
+
* @returns This instance for method chaining
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* const client = new VectorDataApi(url, headers)
|
|
25
|
+
* client.throwOnError()
|
|
26
|
+
* const { data } = await client.putVectors(options) // throws on error
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
throwOnError(): this;
|
|
30
|
+
/**
|
|
31
|
+
* Inserts or updates vectors in batch (upsert operation)
|
|
32
|
+
* Accepts 1-500 vectors per request. Larger batches should be split
|
|
33
|
+
*
|
|
34
|
+
* @param options - Vector insertion options
|
|
35
|
+
* @param options.vectorBucketName - Name of the parent vector bucket
|
|
36
|
+
* @param options.indexName - Name of the target index
|
|
37
|
+
* @param options.vectors - Array of vectors to insert/update (1-500 items)
|
|
38
|
+
* @returns Promise with empty response on success or error
|
|
39
|
+
*
|
|
40
|
+
* @throws {StorageVectorsApiError} With code:
|
|
41
|
+
* - `S3VectorConflictException` if duplicate key conflict occurs (HTTP 409)
|
|
42
|
+
* - `S3VectorNotFoundException` if bucket or index doesn't exist (HTTP 404)
|
|
43
|
+
* - `InternalError` for server errors (HTTP 500)
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```typescript
|
|
47
|
+
* const { data, error } = await client.putVectors({
|
|
48
|
+
* vectorBucketName: 'embeddings-prod',
|
|
49
|
+
* indexName: 'documents-openai-small',
|
|
50
|
+
* vectors: [
|
|
51
|
+
* {
|
|
52
|
+
* key: 'doc-1',
|
|
53
|
+
* data: { float32: [0.1, 0.2, 0.3, ...] }, // 1536 dimensions
|
|
54
|
+
* metadata: { title: 'Introduction', page: 1 }
|
|
55
|
+
* },
|
|
56
|
+
* {
|
|
57
|
+
* key: 'doc-2',
|
|
58
|
+
* data: { float32: [0.4, 0.5, 0.6, ...] },
|
|
59
|
+
* metadata: { title: 'Conclusion', page: 42 }
|
|
60
|
+
* }
|
|
61
|
+
* ]
|
|
62
|
+
* })
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
putVectors(options: PutVectorsOptions): Promise<ApiResponse<undefined>>;
|
|
66
|
+
/**
|
|
67
|
+
* Retrieves vectors by their keys in batch
|
|
68
|
+
* Optionally includes vector data and/or metadata in response
|
|
69
|
+
* Additional permissions required when returning data or metadata
|
|
70
|
+
*
|
|
71
|
+
* @param options - Vector retrieval options
|
|
72
|
+
* @param options.vectorBucketName - Name of the parent vector bucket
|
|
73
|
+
* @param options.indexName - Name of the index
|
|
74
|
+
* @param options.keys - Array of vector keys to retrieve
|
|
75
|
+
* @param options.returnData - Whether to include vector embeddings (requires permission)
|
|
76
|
+
* @param options.returnMetadata - Whether to include metadata (requires permission)
|
|
77
|
+
* @returns Promise with array of vectors or error
|
|
78
|
+
*
|
|
79
|
+
* @throws {StorageVectorsApiError} With code:
|
|
80
|
+
* - `S3VectorNotFoundException` if bucket or index doesn't exist (HTTP 404)
|
|
81
|
+
* - `InternalError` for server errors (HTTP 500)
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```typescript
|
|
85
|
+
* const { data, error } = await client.getVectors({
|
|
86
|
+
* vectorBucketName: 'embeddings-prod',
|
|
87
|
+
* indexName: 'documents-openai-small',
|
|
88
|
+
* keys: ['doc-1', 'doc-2', 'doc-3'],
|
|
89
|
+
* returnData: false, // Don't return embeddings
|
|
90
|
+
* returnMetadata: true // Return metadata only
|
|
91
|
+
* })
|
|
92
|
+
* if (data) {
|
|
93
|
+
* data.vectors.forEach(v => console.log(v.key, v.metadata))
|
|
94
|
+
* }
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
getVectors(options: GetVectorsOptions): Promise<ApiResponse<GetVectorsResponse>>;
|
|
98
|
+
/**
|
|
99
|
+
* Lists/scans vectors in an index with pagination
|
|
100
|
+
* Supports parallel scanning via segment configuration for high-throughput scenarios
|
|
101
|
+
* Additional permissions required when returning data or metadata
|
|
102
|
+
*
|
|
103
|
+
* @param options - Vector listing options
|
|
104
|
+
* @param options.vectorBucketName - Name of the parent vector bucket
|
|
105
|
+
* @param options.indexName - Name of the index
|
|
106
|
+
* @param options.maxResults - Maximum results per page (default: 500, max: 1000)
|
|
107
|
+
* @param options.nextToken - Pagination token from previous response
|
|
108
|
+
* @param options.returnData - Whether to include vector embeddings (requires permission)
|
|
109
|
+
* @param options.returnMetadata - Whether to include metadata (requires permission)
|
|
110
|
+
* @param options.segmentCount - Total parallel segments (1-16) for distributed scanning
|
|
111
|
+
* @param options.segmentIndex - Zero-based segment index (0 to segmentCount-1)
|
|
112
|
+
* @returns Promise with array of vectors, pagination token, or error
|
|
113
|
+
*
|
|
114
|
+
* @throws {StorageVectorsApiError} With code:
|
|
115
|
+
* - `S3VectorNotFoundException` if bucket or index doesn't exist (HTTP 404)
|
|
116
|
+
* - `InternalError` for server errors (HTTP 500)
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* ```typescript
|
|
120
|
+
* // Simple pagination
|
|
121
|
+
* let nextToken: string | undefined
|
|
122
|
+
* do {
|
|
123
|
+
* const { data, error } = await client.listVectors({
|
|
124
|
+
* vectorBucketName: 'embeddings-prod',
|
|
125
|
+
* indexName: 'documents-openai-small',
|
|
126
|
+
* maxResults: 500,
|
|
127
|
+
* nextToken,
|
|
128
|
+
* returnMetadata: true
|
|
129
|
+
* })
|
|
130
|
+
* if (error) break
|
|
131
|
+
* console.log('Batch:', data.vectors.length)
|
|
132
|
+
* nextToken = data.nextToken
|
|
133
|
+
* } while (nextToken)
|
|
134
|
+
*
|
|
135
|
+
* // Parallel scanning (4 concurrent workers)
|
|
136
|
+
* const workers = [0, 1, 2, 3].map(async (segmentIndex) => {
|
|
137
|
+
* const { data } = await client.listVectors({
|
|
138
|
+
* vectorBucketName: 'embeddings-prod',
|
|
139
|
+
* indexName: 'documents-openai-small',
|
|
140
|
+
* segmentCount: 4,
|
|
141
|
+
* segmentIndex,
|
|
142
|
+
* returnMetadata: true
|
|
143
|
+
* })
|
|
144
|
+
* return data?.vectors || []
|
|
145
|
+
* })
|
|
146
|
+
* const results = await Promise.all(workers)
|
|
147
|
+
* ```
|
|
148
|
+
*/
|
|
149
|
+
listVectors(options: ListVectorsOptions): Promise<ApiResponse<ListVectorsResponse>>;
|
|
150
|
+
/**
|
|
151
|
+
* Queries for similar vectors using approximate nearest neighbor (ANN) search
|
|
152
|
+
* Returns top-K most similar vectors based on the configured distance metric
|
|
153
|
+
* Supports optional metadata filtering (requires GetVectors permission)
|
|
154
|
+
*
|
|
155
|
+
* @param options - Query options
|
|
156
|
+
* @param options.vectorBucketName - Name of the parent vector bucket
|
|
157
|
+
* @param options.indexName - Name of the index
|
|
158
|
+
* @param options.queryVector - Query embedding to find similar vectors
|
|
159
|
+
* @param options.topK - Number of nearest neighbors to return (default: 10)
|
|
160
|
+
* @param options.filter - Optional JSON filter for metadata (requires GetVectors permission)
|
|
161
|
+
* @param options.returnDistance - Whether to include similarity distances
|
|
162
|
+
* @param options.returnMetadata - Whether to include metadata (requires GetVectors permission)
|
|
163
|
+
* @returns Promise with array of similar vectors ordered by distance
|
|
164
|
+
*
|
|
165
|
+
* @throws {StorageVectorsApiError} With code:
|
|
166
|
+
* - `S3VectorNotFoundException` if bucket or index doesn't exist (HTTP 404)
|
|
167
|
+
* - `InternalError` for server errors (HTTP 500)
|
|
168
|
+
*
|
|
169
|
+
* @example
|
|
170
|
+
* ```typescript
|
|
171
|
+
* // Semantic search with filtering
|
|
172
|
+
* const { data, error } = await client.queryVectors({
|
|
173
|
+
* vectorBucketName: 'embeddings-prod',
|
|
174
|
+
* indexName: 'documents-openai-small',
|
|
175
|
+
* queryVector: { float32: [0.1, 0.2, 0.3, ...] }, // 1536 dimensions
|
|
176
|
+
* topK: 5,
|
|
177
|
+
* filter: {
|
|
178
|
+
* category: 'technical',
|
|
179
|
+
* published: true
|
|
180
|
+
* },
|
|
181
|
+
* returnDistance: true,
|
|
182
|
+
* returnMetadata: true
|
|
183
|
+
* })
|
|
184
|
+
* if (data) {
|
|
185
|
+
* data.matches.forEach(match => {
|
|
186
|
+
* console.log(`${match.key}: distance=${match.distance}`)
|
|
187
|
+
* console.log('Metadata:', match.metadata)
|
|
188
|
+
* })
|
|
189
|
+
* }
|
|
190
|
+
* ```
|
|
191
|
+
*/
|
|
192
|
+
queryVectors(options: QueryVectorsOptions): Promise<ApiResponse<QueryVectorsResponse>>;
|
|
193
|
+
/**
|
|
194
|
+
* Deletes vectors by their keys in batch
|
|
195
|
+
* Accepts 1-500 keys per request
|
|
196
|
+
*
|
|
197
|
+
* @param options - Vector deletion options
|
|
198
|
+
* @param options.vectorBucketName - Name of the parent vector bucket
|
|
199
|
+
* @param options.indexName - Name of the index
|
|
200
|
+
* @param options.keys - Array of vector keys to delete (1-500 items)
|
|
201
|
+
* @returns Promise with empty response on success or error
|
|
202
|
+
*
|
|
203
|
+
* @throws {StorageVectorsApiError} With code:
|
|
204
|
+
* - `S3VectorNotFoundException` if bucket or index doesn't exist (HTTP 404)
|
|
205
|
+
* - `InternalError` for server errors (HTTP 500)
|
|
206
|
+
*
|
|
207
|
+
* @example
|
|
208
|
+
* ```typescript
|
|
209
|
+
* const { error } = await client.deleteVectors({
|
|
210
|
+
* vectorBucketName: 'embeddings-prod',
|
|
211
|
+
* indexName: 'documents-openai-small',
|
|
212
|
+
* keys: ['doc-1', 'doc-2', 'doc-3']
|
|
213
|
+
* })
|
|
214
|
+
* if (!error) {
|
|
215
|
+
* console.log('Vectors deleted successfully')
|
|
216
|
+
* }
|
|
217
|
+
* ```
|
|
218
|
+
*/
|
|
219
|
+
deleteVectors(options: DeleteVectorsOptions): Promise<ApiResponse<undefined>>;
|
|
220
|
+
}
|
|
221
|
+
//# sourceMappingURL=VectorDataApi.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VectorDataApi.d.ts","sourceRoot":"","sources":["../../../../src/lib/vectors/VectorDataApi.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAQ,MAAM,SAAS,CAAA;AAErC,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,oBA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