@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 @@
|
|
|
1
|
+
{"version":3,"file":"VectorBucketApi.js","sourceRoot":"","sources":["../../../../src/lib/vectors/VectorBucketApi.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAA;AAChD,OAAO,EAAS,IAAI,EAAE,MAAM,SAAS,CAAA;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAQxC;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,eAAe;IAMlC;;;;;OAKG;IACH,YAAY,GAAW,EAAE,UAAqC,EAAE,EAAE,KAAa;QARrE,uBAAkB,GAAG,KAAK,CAAA;QASlC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAA;QACjC,IAAI,CAAC,OAAO,mCAAQ,eAAe,GAAK,OAAO,CAAE,CAAA;QACjD,IAAI,CAAC,KAAK,GAAG,YAAY,CAAC,KAAK,CAAC,CAAA;IAClC,CAAC;IAED;;;;;;;;;;;OAWG;IACI,YAAY;QACjB,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAA;QAC9B,OAAO,IAAI,CAAA;IACb,CAAC;IAED;;;;;;;;;;;;;;;;;;;OAmBG;IACG,YAAY,CAAC,gBAAwB;;YACzC,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AA;YACb,CAAC;QACH,CAAC;KAAA;CACF"}
|
|
@@ -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,oBAAoB,EACpB,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EACnB,oBAAoB,EACrB,MAAM,SAAS,CAAA;AAEhB;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,aAAa;IAChC,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;gBAExB,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAkCG;IACG,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;IAsB7E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;IACG,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,WAAW,CAAC,kBAAkB,CAAC,CAAC;IAiBtF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAkDG;IACG,WAAW,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,WAAW,CAAC,mBAAmB,CAAC,CAAC;IA6BzF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAyCG;IACG,YAAY,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,WAAW,CAAC,oBAAoB,CAAC,CAAC;IAiB5F;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACG,aAAa,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;CAqBpF"}
|
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
import { DEFAULT_HEADERS } from './constants';
|
|
3
|
+
import { isStorageVectorsError } from './errors';
|
|
4
|
+
import { post } from './fetch';
|
|
5
|
+
import { resolveFetch } from './helpers';
|
|
6
|
+
/**
|
|
7
|
+
* API class for managing Vector Data within Vector Indexes
|
|
8
|
+
* Provides methods for inserting, querying, listing, and deleting vector embeddings
|
|
9
|
+
*/
|
|
10
|
+
export default class VectorDataApi {
|
|
11
|
+
constructor(url, headers = {}, fetch) {
|
|
12
|
+
this.shouldThrowOnError = false;
|
|
13
|
+
this.url = url.replace(/\/$/, '');
|
|
14
|
+
this.headers = Object.assign(Object.assign({}, DEFAULT_HEADERS), headers);
|
|
15
|
+
this.fetch = resolveFetch(fetch);
|
|
16
|
+
}
|
|
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() {
|
|
30
|
+
this.shouldThrowOnError = true;
|
|
31
|
+
return this;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Inserts or updates vectors in batch (upsert operation)
|
|
35
|
+
* Accepts 1-500 vectors per request. Larger batches should be split
|
|
36
|
+
*
|
|
37
|
+
* @param options - Vector insertion options
|
|
38
|
+
* @param options.vectorBucketName - Name of the parent vector bucket
|
|
39
|
+
* @param options.indexName - Name of the target index
|
|
40
|
+
* @param options.vectors - Array of vectors to insert/update (1-500 items)
|
|
41
|
+
* @returns Promise with empty response on success or error
|
|
42
|
+
*
|
|
43
|
+
* @throws {StorageVectorsApiError} With code:
|
|
44
|
+
* - `S3VectorConflictException` if duplicate key conflict occurs (HTTP 409)
|
|
45
|
+
* - `S3VectorNotFoundException` if bucket or index doesn't exist (HTTP 404)
|
|
46
|
+
* - `InternalError` for server errors (HTTP 500)
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```typescript
|
|
50
|
+
* const { data, error } = await client.putVectors({
|
|
51
|
+
* vectorBucketName: 'embeddings-prod',
|
|
52
|
+
* indexName: 'documents-openai-small',
|
|
53
|
+
* vectors: [
|
|
54
|
+
* {
|
|
55
|
+
* key: 'doc-1',
|
|
56
|
+
* data: { float32: [0.1, 0.2, 0.3, ...] }, // 1536 dimensions
|
|
57
|
+
* metadata: { title: 'Introduction', page: 1 }
|
|
58
|
+
* },
|
|
59
|
+
* {
|
|
60
|
+
* key: 'doc-2',
|
|
61
|
+
* data: { float32: [0.4, 0.5, 0.6, ...] },
|
|
62
|
+
* metadata: { title: 'Conclusion', page: 42 }
|
|
63
|
+
* }
|
|
64
|
+
* ]
|
|
65
|
+
* })
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
putVectors(options) {
|
|
69
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
70
|
+
try {
|
|
71
|
+
// Validate batch size
|
|
72
|
+
if (options.vectors.length < 1 || options.vectors.length > 500) {
|
|
73
|
+
throw new Error('Vector batch size must be between 1 and 500 items');
|
|
74
|
+
}
|
|
75
|
+
const data = yield post(this.fetch, `${this.url}/PutVectors`, options, {
|
|
76
|
+
headers: this.headers,
|
|
77
|
+
});
|
|
78
|
+
return { data: data || {}, error: null };
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
if (this.shouldThrowOnError) {
|
|
82
|
+
throw error;
|
|
83
|
+
}
|
|
84
|
+
if (isStorageVectorsError(error)) {
|
|
85
|
+
return { data: null, error };
|
|
86
|
+
}
|
|
87
|
+
throw error;
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Retrieves vectors by their keys in batch
|
|
93
|
+
* Optionally includes vector data and/or metadata in response
|
|
94
|
+
* Additional permissions required when returning data or metadata
|
|
95
|
+
*
|
|
96
|
+
* @param options - Vector retrieval options
|
|
97
|
+
* @param options.vectorBucketName - Name of the parent vector bucket
|
|
98
|
+
* @param options.indexName - Name of the index
|
|
99
|
+
* @param options.keys - Array of vector keys to retrieve
|
|
100
|
+
* @param options.returnData - Whether to include vector embeddings (requires permission)
|
|
101
|
+
* @param options.returnMetadata - Whether to include metadata (requires permission)
|
|
102
|
+
* @returns Promise with array of vectors or error
|
|
103
|
+
*
|
|
104
|
+
* @throws {StorageVectorsApiError} With code:
|
|
105
|
+
* - `S3VectorNotFoundException` if bucket or index doesn't exist (HTTP 404)
|
|
106
|
+
* - `InternalError` for server errors (HTTP 500)
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* ```typescript
|
|
110
|
+
* const { data, error } = await client.getVectors({
|
|
111
|
+
* vectorBucketName: 'embeddings-prod',
|
|
112
|
+
* indexName: 'documents-openai-small',
|
|
113
|
+
* keys: ['doc-1', 'doc-2', 'doc-3'],
|
|
114
|
+
* returnData: false, // Don't return embeddings
|
|
115
|
+
* returnMetadata: true // Return metadata only
|
|
116
|
+
* })
|
|
117
|
+
* if (data) {
|
|
118
|
+
* data.vectors.forEach(v => console.log(v.key, v.metadata))
|
|
119
|
+
* }
|
|
120
|
+
* ```
|
|
121
|
+
*/
|
|
122
|
+
getVectors(options) {
|
|
123
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
124
|
+
try {
|
|
125
|
+
const data = yield post(this.fetch, `${this.url}/GetVectors`, options, {
|
|
126
|
+
headers: this.headers,
|
|
127
|
+
});
|
|
128
|
+
return { data, error: null };
|
|
129
|
+
}
|
|
130
|
+
catch (error) {
|
|
131
|
+
if (this.shouldThrowOnError) {
|
|
132
|
+
throw error;
|
|
133
|
+
}
|
|
134
|
+
if (isStorageVectorsError(error)) {
|
|
135
|
+
return { data: null, error };
|
|
136
|
+
}
|
|
137
|
+
throw error;
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Lists/scans vectors in an index with pagination
|
|
143
|
+
* Supports parallel scanning via segment configuration for high-throughput scenarios
|
|
144
|
+
* Additional permissions required when returning data or metadata
|
|
145
|
+
*
|
|
146
|
+
* @param options - Vector listing options
|
|
147
|
+
* @param options.vectorBucketName - Name of the parent vector bucket
|
|
148
|
+
* @param options.indexName - Name of the index
|
|
149
|
+
* @param options.maxResults - Maximum results per page (default: 500, max: 1000)
|
|
150
|
+
* @param options.nextToken - Pagination token from previous response
|
|
151
|
+
* @param options.returnData - Whether to include vector embeddings (requires permission)
|
|
152
|
+
* @param options.returnMetadata - Whether to include metadata (requires permission)
|
|
153
|
+
* @param options.segmentCount - Total parallel segments (1-16) for distributed scanning
|
|
154
|
+
* @param options.segmentIndex - Zero-based segment index (0 to segmentCount-1)
|
|
155
|
+
* @returns Promise with array of vectors, pagination token, or error
|
|
156
|
+
*
|
|
157
|
+
* @throws {StorageVectorsApiError} With code:
|
|
158
|
+
* - `S3VectorNotFoundException` if bucket or index doesn't exist (HTTP 404)
|
|
159
|
+
* - `InternalError` for server errors (HTTP 500)
|
|
160
|
+
*
|
|
161
|
+
* @example
|
|
162
|
+
* ```typescript
|
|
163
|
+
* // Simple pagination
|
|
164
|
+
* let nextToken: string | undefined
|
|
165
|
+
* do {
|
|
166
|
+
* const { data, error } = await client.listVectors({
|
|
167
|
+
* vectorBucketName: 'embeddings-prod',
|
|
168
|
+
* indexName: 'documents-openai-small',
|
|
169
|
+
* maxResults: 500,
|
|
170
|
+
* nextToken,
|
|
171
|
+
* returnMetadata: true
|
|
172
|
+
* })
|
|
173
|
+
* if (error) break
|
|
174
|
+
* console.log('Batch:', data.vectors.length)
|
|
175
|
+
* nextToken = data.nextToken
|
|
176
|
+
* } while (nextToken)
|
|
177
|
+
*
|
|
178
|
+
* // Parallel scanning (4 concurrent workers)
|
|
179
|
+
* const workers = [0, 1, 2, 3].map(async (segmentIndex) => {
|
|
180
|
+
* const { data } = await client.listVectors({
|
|
181
|
+
* vectorBucketName: 'embeddings-prod',
|
|
182
|
+
* indexName: 'documents-openai-small',
|
|
183
|
+
* segmentCount: 4,
|
|
184
|
+
* segmentIndex,
|
|
185
|
+
* returnMetadata: true
|
|
186
|
+
* })
|
|
187
|
+
* return data?.vectors || []
|
|
188
|
+
* })
|
|
189
|
+
* const results = await Promise.all(workers)
|
|
190
|
+
* ```
|
|
191
|
+
*/
|
|
192
|
+
listVectors(options) {
|
|
193
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
194
|
+
try {
|
|
195
|
+
// Validate segment configuration
|
|
196
|
+
if (options.segmentCount !== undefined) {
|
|
197
|
+
if (options.segmentCount < 1 || options.segmentCount > 16) {
|
|
198
|
+
throw new Error('segmentCount must be between 1 and 16');
|
|
199
|
+
}
|
|
200
|
+
if (options.segmentIndex !== undefined) {
|
|
201
|
+
if (options.segmentIndex < 0 || options.segmentIndex >= options.segmentCount) {
|
|
202
|
+
throw new Error(`segmentIndex must be between 0 and ${options.segmentCount - 1}`);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
const data = yield post(this.fetch, `${this.url}/ListVectors`, options, {
|
|
207
|
+
headers: this.headers,
|
|
208
|
+
});
|
|
209
|
+
return { data, error: null };
|
|
210
|
+
}
|
|
211
|
+
catch (error) {
|
|
212
|
+
if (this.shouldThrowOnError) {
|
|
213
|
+
throw error;
|
|
214
|
+
}
|
|
215
|
+
if (isStorageVectorsError(error)) {
|
|
216
|
+
return { data: null, error };
|
|
217
|
+
}
|
|
218
|
+
throw error;
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Queries for similar vectors using approximate nearest neighbor (ANN) search
|
|
224
|
+
* Returns top-K most similar vectors based on the configured distance metric
|
|
225
|
+
* Supports optional metadata filtering (requires GetVectors permission)
|
|
226
|
+
*
|
|
227
|
+
* @param options - Query options
|
|
228
|
+
* @param options.vectorBucketName - Name of the parent vector bucket
|
|
229
|
+
* @param options.indexName - Name of the index
|
|
230
|
+
* @param options.queryVector - Query embedding to find similar vectors
|
|
231
|
+
* @param options.topK - Number of nearest neighbors to return (default: 10)
|
|
232
|
+
* @param options.filter - Optional JSON filter for metadata (requires GetVectors permission)
|
|
233
|
+
* @param options.returnDistance - Whether to include similarity distances
|
|
234
|
+
* @param options.returnMetadata - Whether to include metadata (requires GetVectors permission)
|
|
235
|
+
* @returns Promise with array of similar vectors ordered by distance
|
|
236
|
+
*
|
|
237
|
+
* @throws {StorageVectorsApiError} With code:
|
|
238
|
+
* - `S3VectorNotFoundException` if bucket or index doesn't exist (HTTP 404)
|
|
239
|
+
* - `InternalError` for server errors (HTTP 500)
|
|
240
|
+
*
|
|
241
|
+
* @example
|
|
242
|
+
* ```typescript
|
|
243
|
+
* // Semantic search with filtering
|
|
244
|
+
* const { data, error } = await client.queryVectors({
|
|
245
|
+
* vectorBucketName: 'embeddings-prod',
|
|
246
|
+
* indexName: 'documents-openai-small',
|
|
247
|
+
* queryVector: { float32: [0.1, 0.2, 0.3, ...] }, // 1536 dimensions
|
|
248
|
+
* topK: 5,
|
|
249
|
+
* filter: {
|
|
250
|
+
* category: 'technical',
|
|
251
|
+
* published: true
|
|
252
|
+
* },
|
|
253
|
+
* returnDistance: true,
|
|
254
|
+
* returnMetadata: true
|
|
255
|
+
* })
|
|
256
|
+
* if (data) {
|
|
257
|
+
* data.matches.forEach(match => {
|
|
258
|
+
* console.log(`${match.key}: distance=${match.distance}`)
|
|
259
|
+
* console.log('Metadata:', match.metadata)
|
|
260
|
+
* })
|
|
261
|
+
* }
|
|
262
|
+
* ```
|
|
263
|
+
*/
|
|
264
|
+
queryVectors(options) {
|
|
265
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
266
|
+
try {
|
|
267
|
+
const data = yield post(this.fetch, `${this.url}/QueryVectors`, options, {
|
|
268
|
+
headers: this.headers,
|
|
269
|
+
});
|
|
270
|
+
return { data, error: null };
|
|
271
|
+
}
|
|
272
|
+
catch (error) {
|
|
273
|
+
if (this.shouldThrowOnError) {
|
|
274
|
+
throw error;
|
|
275
|
+
}
|
|
276
|
+
if (isStorageVectorsError(error)) {
|
|
277
|
+
return { data: null, error };
|
|
278
|
+
}
|
|
279
|
+
throw error;
|
|
280
|
+
}
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Deletes vectors by their keys in batch
|
|
285
|
+
* Accepts 1-500 keys per request
|
|
286
|
+
*
|
|
287
|
+
* @param options - Vector deletion options
|
|
288
|
+
* @param options.vectorBucketName - Name of the parent vector bucket
|
|
289
|
+
* @param options.indexName - Name of the index
|
|
290
|
+
* @param options.keys - Array of vector keys to delete (1-500 items)
|
|
291
|
+
* @returns Promise with empty response on success or error
|
|
292
|
+
*
|
|
293
|
+
* @throws {StorageVectorsApiError} With code:
|
|
294
|
+
* - `S3VectorNotFoundException` if bucket or index doesn't exist (HTTP 404)
|
|
295
|
+
* - `InternalError` for server errors (HTTP 500)
|
|
296
|
+
*
|
|
297
|
+
* @example
|
|
298
|
+
* ```typescript
|
|
299
|
+
* const { error } = await client.deleteVectors({
|
|
300
|
+
* vectorBucketName: 'embeddings-prod',
|
|
301
|
+
* indexName: 'documents-openai-small',
|
|
302
|
+
* keys: ['doc-1', 'doc-2', 'doc-3']
|
|
303
|
+
* })
|
|
304
|
+
* if (!error) {
|
|
305
|
+
* console.log('Vectors deleted successfully')
|
|
306
|
+
* }
|
|
307
|
+
* ```
|
|
308
|
+
*/
|
|
309
|
+
deleteVectors(options) {
|
|
310
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
311
|
+
try {
|
|
312
|
+
// Validate batch size
|
|
313
|
+
if (options.keys.length < 1 || options.keys.length > 500) {
|
|
314
|
+
throw new Error('Keys batch size must be between 1 and 500 items');
|
|
315
|
+
}
|
|
316
|
+
const data = yield post(this.fetch, `${this.url}/DeleteVectors`, options, {
|
|
317
|
+
headers: this.headers,
|
|
318
|
+
});
|
|
319
|
+
return { data: data || {}, error: null };
|
|
320
|
+
}
|
|
321
|
+
catch (error) {
|
|
322
|
+
if (this.shouldThrowOnError) {
|
|
323
|
+
throw error;
|
|
324
|
+
}
|
|
325
|
+
if (isStorageVectorsError(error)) {
|
|
326
|
+
return { data: null, error };
|
|
327
|
+
}
|
|
328
|
+
throw error;
|
|
329
|
+
}
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
//# sourceMappingURL=VectorDataApi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+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