@ixo/data-store 1.0.1

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.
Files changed (61) hide show
  1. package/.eslintrc.js +9 -0
  2. package/.prettierignore +3 -0
  3. package/.prettierrc.js +4 -0
  4. package/.turbo/turbo-build.log +4 -0
  5. package/CHANGELOG.md +7 -0
  6. package/README.md +276 -0
  7. package/dist/airtable-store/index.d.ts +42 -0
  8. package/dist/airtable-store/index.d.ts.map +1 -0
  9. package/dist/airtable-store/index.js +79 -0
  10. package/dist/chroma/chroma-data-store.d.ts +74 -0
  11. package/dist/chroma/chroma-data-store.d.ts.map +1 -0
  12. package/dist/chroma/chroma-data-store.js +196 -0
  13. package/dist/chroma/chroma-data-store.test.d.ts +2 -0
  14. package/dist/chroma/chroma-data-store.test.d.ts.map +1 -0
  15. package/dist/chroma/chroma-data-store.test.js +176 -0
  16. package/dist/chroma/chroma.types.d.ts +24 -0
  17. package/dist/chroma/chroma.types.d.ts.map +1 -0
  18. package/dist/chroma/chroma.types.js +2 -0
  19. package/dist/chroma/embedding-function.d.ts +14 -0
  20. package/dist/chroma/embedding-function.d.ts.map +1 -0
  21. package/dist/chroma/embedding-function.js +26 -0
  22. package/dist/chroma/index.d.ts +3 -0
  23. package/dist/chroma/index.d.ts.map +1 -0
  24. package/dist/chroma/index.js +18 -0
  25. package/dist/chroma/utils.d.ts +6 -0
  26. package/dist/chroma/utils.d.ts.map +1 -0
  27. package/dist/chroma/utils.js +31 -0
  28. package/dist/index.d.ts +4 -0
  29. package/dist/index.d.ts.map +1 -0
  30. package/dist/index.js +19 -0
  31. package/dist/types/index.d.ts +3 -0
  32. package/dist/types/index.d.ts.map +1 -0
  33. package/dist/types/index.js +18 -0
  34. package/dist/types/structured-data-store.d.ts +24 -0
  35. package/dist/types/structured-data-store.d.ts.map +1 -0
  36. package/dist/types/structured-data-store.js +2 -0
  37. package/dist/types/vector-db-data-store.d.ts +58 -0
  38. package/dist/types/vector-db-data-store.d.ts.map +1 -0
  39. package/dist/types/vector-db-data-store.js +10 -0
  40. package/dist/utils/index.d.ts +2 -0
  41. package/dist/utils/index.d.ts.map +1 -0
  42. package/dist/utils/index.js +17 -0
  43. package/dist/utils/with-report-error.d.ts +5 -0
  44. package/dist/utils/with-report-error.d.ts.map +1 -0
  45. package/dist/utils/with-report-error.js +21 -0
  46. package/jest.config.js +6 -0
  47. package/package.json +49 -0
  48. package/src/airtable-store/index.ts +141 -0
  49. package/src/chroma/chroma-data-store.test.ts +210 -0
  50. package/src/chroma/chroma-data-store.ts +254 -0
  51. package/src/chroma/chroma.types.ts +28 -0
  52. package/src/chroma/embedding-function.ts +26 -0
  53. package/src/chroma/index.ts +2 -0
  54. package/src/chroma/utils.ts +40 -0
  55. package/src/index.ts +4 -0
  56. package/src/types/index.ts +2 -0
  57. package/src/types/structured-data-store.ts +34 -0
  58. package/src/types/vector-db-data-store.ts +78 -0
  59. package/src/utils/index.ts +1 -0
  60. package/src/utils/with-report-error.ts +18 -0
  61. package/tsconfig.json +7 -0
package/.eslintrc.js ADDED
@@ -0,0 +1,9 @@
1
+ /** @type {import("eslint").Linter.Config} */
2
+ module.exports = {
3
+ extends: ['@ixo/eslint-config/nest.js'],
4
+ parserOptions: {
5
+ project: 'tsconfig.json',
6
+ tsconfigRootDir: __dirname,
7
+ sourceType: 'module',
8
+ },
9
+ };
@@ -0,0 +1,3 @@
1
+ pnpm-lock.yaml
2
+
3
+ node_modules
package/.prettierrc.js ADDED
@@ -0,0 +1,4 @@
1
+ /** @type {import("prettier").Config} */
2
+ module.exports = {
3
+ ...require('@ixo/eslint-config/prettier-base'),
4
+ };
@@ -0,0 +1,4 @@
1
+
2
+ > @ixo/data-store@1.0.1 build /home/runner/actions-runner/_work/ixo-oracles-boilerplate/ixo-oracles-boilerplate/packages/data-store
3
+ > tsc
4
+
package/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # @ixo/data-store
2
+
3
+ ## 1.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#53](https://github.com/ixoworld/ixo-oracles-boilerplate/pull/53) [`0a4a5a8`](https://github.com/ixoworld/ixo-oracles-boilerplate/commit/0a4a5a84194acb851e3824e0b74eea54f60c8257) Thanks [@youssefhany-ixo](https://github.com/youssefhany-ixo)! - Upgrade packages and publish events package and preformance upgrades
package/README.md ADDED
@@ -0,0 +1,276 @@
1
+ # @ixo/data-store
2
+
3
+ ## Overview
4
+
5
+ The `@ixo/data-store` package provides abstract interfaces and implementations for both vector and structured data storage in the ixo-oracles ecosystem. It offers a type-safe, consistent API for managing data across different storage backends.
6
+
7
+ ### Key Features
8
+
9
+ - 🔍 Vector database abstraction with ChromaDB implementation
10
+ - 📊 Structured data storage with Airtable implementation
11
+ - 🔐 Type-safe interfaces for data operations
12
+ - 🎯 Flexible query capabilities
13
+ - 🔄 Batch operations support
14
+ - 🏗️ Extensible architecture for custom implementations
15
+
16
+ ## Table of Contents
17
+
18
+ 1. [Getting Started](#getting-started)
19
+ - [Installation](#installation)
20
+ - [Configuration](#configuration)
21
+ 2. [Vector Database Storage](#vector-database-storage)
22
+ - [Implementing Vector Storage](#implementing-vector-storage)
23
+ - [Using ChromaDB Implementation](#using-chromadb-implementation)
24
+ 3. [Structured Data Storage](#structured-data-storage)
25
+ - [Implementing Structured Storage](#implementing-structured-storage)
26
+ - [Using Airtable Implementation](#using-airtable-implementation)
27
+ 4. [Development](#development)
28
+
29
+ ## Getting Started
30
+
31
+ ### Installation
32
+
33
+ ```bash
34
+ # Install using pnpm (recommended)
35
+ pnpm install @ixo/data-store
36
+
37
+ # Or using npm
38
+ npm install @ixo/data-store
39
+
40
+ # Or using yarn
41
+ yarn add @ixo/data-store
42
+ ```
43
+
44
+ ### Configuration
45
+
46
+ #### For ChromaDB Vector Storage
47
+
48
+ ```bash
49
+ OPENAI_API_KEY=your_openai_api_key # Required for embeddings
50
+ ```
51
+
52
+ #### Running Chroma Backend
53
+
54
+ The ChromaDB implementation requires a running Chroma backend. You can easily run it using Docker:
55
+
56
+ ```bash
57
+ # Pull the Chroma image
58
+ docker pull chromadb/chroma
59
+
60
+ # Run the Chroma container
61
+ docker run -p 8000:8000 chromadb/chroma
62
+ ```
63
+
64
+ This will start the Chroma backend server on `http://localhost:8000`.
65
+
66
+ #### For Airtable Structured Storage
67
+
68
+ ```bash
69
+ AIRTABLE_API_KEY=your_airtable_key # Required for Airtable operations
70
+ AIRTABLE_BASE_ID=your_base_id # Required for Airtable operations
71
+ AITABLE_BASE_TABLE_LINK=your_link # Optional, for record links
72
+ ```
73
+
74
+ ## Vector Database Storage
75
+
76
+ The vector database interface provides methods for storing, retrieving, and querying vector embeddings of documents.
77
+
78
+ ### Implementing Vector Storage
79
+
80
+ To create a custom vector storage implementation, extend the `VectorDBDataStore` abstract class:
81
+
82
+ ```typescript
83
+ import {
84
+ VectorDBDataStore,
85
+ IVectorStoreDocument,
86
+ IVectorStoreOptions,
87
+ } from '@ixo/data-store';
88
+
89
+ class CustomVectorStore extends VectorDBDataStore {
90
+ constructor(options: IVectorStoreOptions) {
91
+ super(options);
92
+ }
93
+
94
+ async init(): Promise<void> {
95
+ // Initialize your vector store
96
+ }
97
+
98
+ async upsert(documents: IVectorStoreDocument[]): Promise<void> {
99
+ // Implement document upsertion
100
+ }
101
+
102
+ async delete(ids: string[]): Promise<void> {
103
+ // Implement document deletion
104
+ }
105
+
106
+ async query(
107
+ query: string,
108
+ options?: IVectorStoreQueryOptions,
109
+ ): Promise<IVectorStoreDocument[]> {
110
+ // Implement text-based querying
111
+ }
112
+
113
+ async queryByVector(
114
+ vector: number[],
115
+ options?: IVectorStoreQueryOptions,
116
+ ): Promise<IVectorStoreDocument[]> {
117
+ // Implement vector-based querying
118
+ }
119
+
120
+ async getById(id: string): Promise<IVectorStoreDocument | null> {
121
+ // Implement document retrieval by ID
122
+ }
123
+
124
+ async queryWithSimilarity(
125
+ query: string,
126
+ options?: IVectorStoreQueryOptions & { similarityThreshold: number },
127
+ ): Promise<IVectorStoreDocument[]> {
128
+ // Implement similarity-based querying
129
+ }
130
+ }
131
+ ```
132
+
133
+ ### Using ChromaDB Implementation
134
+
135
+ The package includes a ChromaDB implementation:
136
+
137
+ ```typescript
138
+ import { ChromaDataStore } from '@ixo/data-store';
139
+
140
+ const store = new ChromaDataStore({
141
+ collectionName: 'my-collection',
142
+ url: 'http://localhost:8000',
143
+ });
144
+
145
+ await store.init();
146
+
147
+ // Store documents
148
+ await store.upsert([
149
+ {
150
+ id: '1',
151
+ content: 'Document content',
152
+ metadata: { type: 'article' },
153
+ },
154
+ ]);
155
+
156
+ // Query documents
157
+ const results = await store.query('search query', {
158
+ topK: 5,
159
+ filters: { type: 'article' },
160
+ });
161
+
162
+ // Query with similarity threshold
163
+ const similarDocs = await store.queryWithSimilarity('query', {
164
+ similarityThreshold: 0.8,
165
+ });
166
+ ```
167
+
168
+ ## Structured Data Storage
169
+
170
+ The structured data interface provides CRUD operations for structured data storage.
171
+
172
+ ### Implementing Structured Storage
173
+
174
+ To create a custom structured storage implementation, implement the `IDataStore` interface:
175
+
176
+ ```typescript
177
+ import { IDataStore } from '@ixo/data-store';
178
+
179
+ class CustomDataStore<T> implements IDataStore<T> {
180
+ async getAllRecords(
181
+ tableName: string,
182
+ selectOptions: IQueryParams<T>,
183
+ ): Promise<T[]> {
184
+ // Implement fetching all records
185
+ }
186
+
187
+ async getRecord(tableName: string, recordId: string): Promise<T> {
188
+ // Implement single record retrieval
189
+ }
190
+
191
+ async createRecord(tableName: string, recordData: T): Promise<T> {
192
+ // Implement record creation
193
+ }
194
+
195
+ async updateRecord(
196
+ tableName: string,
197
+ recordId: string,
198
+ recordData: T,
199
+ ): Promise<T> {
200
+ // Implement record update
201
+ }
202
+
203
+ async batchUpdateRecords(
204
+ tableName: string,
205
+ records: { id: string; fields: T }[],
206
+ ): Promise<T[]> {
207
+ // Implement batch update
208
+ }
209
+
210
+ async deleteRecord(tableName: string, recordId: string): Promise<T> {
211
+ // Implement record deletion
212
+ }
213
+
214
+ async getRecordByField(
215
+ tableName: string,
216
+ fieldName: string,
217
+ fieldValue: string,
218
+ ): Promise<T[]> {
219
+ // Implement field-based retrieval
220
+ }
221
+ }
222
+ ```
223
+
224
+ ### Using Airtable Implementation
225
+
226
+ The package includes an Airtable implementation:
227
+
228
+ ```typescript
229
+ import { AirtableDataStore, FieldSet } from '@ixo/data-store';
230
+
231
+ interface MyRecord extends FieldSet {
232
+ name: string;
233
+ description: string;
234
+ }
235
+
236
+ const store = new AirtableDataStore<MyRecord>();
237
+
238
+ // Create a record
239
+ const record = await store.createRecord('tableName', {
240
+ name: 'Test',
241
+ description: 'Description',
242
+ });
243
+
244
+ // Get all records
245
+ const records = await store.getAllRecords('tableName', {
246
+ maxRecords: 100,
247
+ view: 'Grid view',
248
+ });
249
+
250
+ // Update records in batch
251
+ const updated = await store.batchUpdateRecords('tableName', [
252
+ { id: '1', fields: { name: 'Updated' } },
253
+ { id: '2', fields: { name: 'Also Updated' } },
254
+ ]);
255
+ ```
256
+
257
+ ## Development
258
+
259
+ ### Testing
260
+
261
+ ```bash
262
+ # Run tests
263
+ pnpm test
264
+
265
+ ```
266
+
267
+ ### Contributing
268
+
269
+ 1. Implement the appropriate interface (`VectorDBDataStore` or `IDataStore`)
270
+ 2. Add comprehensive tests
271
+ 3. Document your implementation
272
+ 4. Submit a pull request
273
+
274
+ ## License
275
+
276
+ Internal package - All rights reserved.
@@ -0,0 +1,42 @@
1
+ import { type FieldSet } from 'airtable';
2
+ import { type QueryParams } from 'airtable/lib/query_params';
3
+ import { type IDataStore } from '../types';
4
+ /**
5
+ * AirtableDataStore class to interact with Airtable API implementing IDataStore interface
6
+ *
7
+ * Basic CRUD operations
8
+ */
9
+ export declare class AirtableDataStore<TFields extends FieldSet> implements IDataStore<TFields> {
10
+ private readonly base;
11
+ constructor();
12
+ private static withId;
13
+ getAllRecords(tableName: string, selectOptions?: QueryParams<TFields>): Promise<(TFields & {
14
+ id: string;
15
+ })[]>;
16
+ getRecord(tableName: string, recordId: string): Promise<TFields & {
17
+ id: string;
18
+ }>;
19
+ createRecord(tableName: string, recordData: TFields): Promise<TFields & {
20
+ id: string;
21
+ }>;
22
+ updateRecord(tableName: string, recordId: string, recordData: Partial<TFields>): Promise<TFields & {
23
+ id: string;
24
+ }>;
25
+ batchUpdateRecords(tableName: string, records: {
26
+ id: string;
27
+ fields: Partial<TFields & {
28
+ batch?: boolean;
29
+ }>;
30
+ }[]): Promise<(TFields & {
31
+ id: string;
32
+ })[]>;
33
+ deleteRecord(tableName: string, recordId: string): Promise<TFields & {
34
+ id: string;
35
+ }>;
36
+ getRecordByField(tableName: string, fieldName: string, fieldValue: string): Promise<(TFields & {
37
+ id: string;
38
+ })[]>;
39
+ getLinkToRecord(recordId: string): string;
40
+ }
41
+ export type { FieldSet };
42
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/airtable-store/index.ts"],"names":[],"mappings":"AAAA,OAAqB,EAAE,KAAK,QAAQ,EAAE,MAAM,UAAU,CAAC;AACvD,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,UAAU,CAAC;AAG3C;;;;GAIG;AACH,qBAAa,iBAAiB,CAAC,OAAO,SAAS,QAAQ,CACrD,YAAW,UAAU,CAAC,OAAO,CAAC;IAE9B,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAoB;;IAgBzC,OAAO,CAAC,MAAM,CAAC,MAAM;IASf,aAAa,CACjB,SAAS,EAAE,MAAM,EACjB,aAAa,CAAC,EAAE,WAAW,CAAC,OAAO,CAAC,GACnC,OAAO,CAAC,CAAC,OAAO,GAAG;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC,EAAE,CAAC;IAQlC,SAAS,CACb,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,OAAO,GAAG;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC;IAQ9B,YAAY,CAChB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,OAAO,GAClB,OAAO,CAAC,OAAO,GAAG;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC;IAO9B,YAAY,CAChB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,OAAO,CAAC,OAAO,CAAC,GAC3B,OAAO,CAAC,OAAO,GAAG;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC;IAgB9B,kBAAkB,CACtB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE;QACP,EAAE,EAAE,MAAM,CAAC;QACX,MAAM,EAAE,OAAO,CACb,OAAO,GAAG;YACR,KAAK,CAAC,EAAE,OAAO,CAAC;SACjB,CACF,CAAC;KACH,EAAE,GACF,OAAO,CAAC,CAAC,OAAO,GAAG;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC,EAAE,CAAC;IAOlC,YAAY,CAChB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,OAAO,GAAG;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC;IAO9B,gBAAgB,CACpB,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,CAAC,OAAO,GAAG;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC,EAAE,CAAC;IAWjC,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;CAMjD;AAED,YAAY,EAAE,QAAQ,EAAE,CAAC"}
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.AirtableDataStore = void 0;
7
+ const airtable_1 = __importDefault(require("airtable"));
8
+ const utils_1 = require("../utils");
9
+ /**
10
+ * AirtableDataStore class to interact with Airtable API implementing IDataStore interface
11
+ *
12
+ * Basic CRUD operations
13
+ */
14
+ class AirtableDataStore {
15
+ base;
16
+ constructor() {
17
+ if (!process.env.AIRTABLE_API_KEY) {
18
+ throw new Error('AIRTABLE_API_KEY is required');
19
+ }
20
+ if (!process.env.AIRTABLE_BASE_ID) {
21
+ throw new Error('AIRTABLE_BASE_ID is required');
22
+ }
23
+ this.base = new airtable_1.default({ apiKey: process.env.AIRTABLE_API_KEY }).base(process.env.AIRTABLE_BASE_ID);
24
+ }
25
+ static withId(record) {
26
+ return {
27
+ ...record.fields,
28
+ id: record.id,
29
+ };
30
+ }
31
+ async getAllRecords(tableName, selectOptions) {
32
+ const records = await (0, utils_1.withReportError)(this.base(tableName).select(selectOptions).all());
33
+ return records.map((record) => AirtableDataStore.withId(record));
34
+ }
35
+ async getRecord(tableName, recordId) {
36
+ const record = await (0, utils_1.withReportError)(this.base(tableName).find(recordId));
37
+ return AirtableDataStore.withId(record);
38
+ }
39
+ async createRecord(tableName, recordData) {
40
+ const record = await (0, utils_1.withReportError)(this.base(tableName).create(recordData));
41
+ return AirtableDataStore.withId(record);
42
+ }
43
+ async updateRecord(tableName, recordId, recordData) {
44
+ const record = await (0, utils_1.withReportError)(this.base(tableName).update([
45
+ {
46
+ id: recordId,
47
+ fields: recordData,
48
+ },
49
+ ]));
50
+ if (!record[0]) {
51
+ // this error will never be thrown as the airtable sdk will throw an error but to satisfy typescript
52
+ throw new Error('Record not found');
53
+ }
54
+ return AirtableDataStore.withId(record[0]);
55
+ }
56
+ async batchUpdateRecords(tableName, records) {
57
+ const updatedRecords = await (0, utils_1.withReportError)(this.base(tableName).update(records));
58
+ return updatedRecords.map((record) => AirtableDataStore.withId(record));
59
+ }
60
+ async deleteRecord(tableName, recordId) {
61
+ const record = await (0, utils_1.withReportError)(this.base(tableName).destroy(recordId));
62
+ return AirtableDataStore.withId(record);
63
+ }
64
+ async getRecordByField(tableName, fieldName, fieldValue) {
65
+ const records = await (0, utils_1.withReportError)(this.base(tableName)
66
+ .select({
67
+ filterByFormula: `{${fieldName}} = "${fieldValue}"`,
68
+ })
69
+ .all());
70
+ return records.map((record) => AirtableDataStore.withId(record));
71
+ }
72
+ getLinkToRecord(recordId) {
73
+ if (!process.env.AITABLE_BASE_TABLE_LINK) {
74
+ throw new Error('AITABLE_BASE_TABLE_LINK is required');
75
+ }
76
+ return `${process.env.AITABLE_BASE_TABLE_LINK}/${recordId}`;
77
+ }
78
+ }
79
+ exports.AirtableDataStore = AirtableDataStore;
@@ -0,0 +1,74 @@
1
+ import { type Metadata } from 'chromadb';
2
+ import { VectorDBDataStore, type IVectorStoreDocument, type IVectorStoreDocumentWithEmbeddings, type IVectorStoreOptions, type IVectorStoreQueryOptions } from '../types/vector-db-data-store';
3
+ import { type IChromaMetadataFilter } from './chroma.types';
4
+ /**
5
+ * ChromaDataStore class for managing vector storage and retrieval using ChromaDB
6
+ */
7
+ declare class ChromaDataStore extends VectorDBDataStore {
8
+ private readonly client;
9
+ private collection;
10
+ /**
11
+ * Creates a new ChromaDataStore instance
12
+ * @param options - Configuration options for the vector store
13
+ * @throws Error if OPENAI_API_KEY is not set and no embedding function is provided
14
+ */
15
+ constructor(options: IVectorStoreOptions);
16
+ /**
17
+ * Checks if the ChromaDB collection is initialized
18
+ * @throws Error if collection is not initialized
19
+ */
20
+ private checkIsInitialized;
21
+ /**
22
+ * Initializes the ChromaDB collection
23
+ */
24
+ init(): Promise<void>;
25
+ /**
26
+ * Queries the vector store using text
27
+ * @param query - Text query to search for
28
+ * @param options - Query options including filters and top-k results
29
+ * @returns Array of matching documents
30
+ */
31
+ query(query: string, options?: IVectorStoreQueryOptions<IChromaMetadataFilter>): Promise<IVectorStoreDocument[]>;
32
+ /**
33
+ * Queries the vector store and filters results by similarity threshold
34
+ * @param query - Text query to search for
35
+ * @param options - Query options including similarity threshold
36
+ * @returns Array of documents meeting the similarity threshold
37
+ */
38
+ queryWithSimilarity(query: string, options?: IVectorStoreQueryOptions<IChromaMetadataFilter> & {
39
+ similarityThreshold: number;
40
+ }): Promise<IVectorStoreDocument[]>;
41
+ /**
42
+ * Upserts (inserts or updates) documents into the vector store
43
+ * @param documents - Array of documents to upsert
44
+ * @throws Error if any document is missing an ID
45
+ */
46
+ upsert(documents: IVectorStoreDocument[]): Promise<void>;
47
+ addDocumentsWithEmbeddings(documents: IVectorStoreDocumentWithEmbeddings[]): Promise<void>;
48
+ /**
49
+ * Deletes documents from the vector store by their IDs
50
+ * @param ids - Array of document IDs to delete
51
+ */
52
+ delete(ids: string[]): Promise<void>;
53
+ /**
54
+ * Retrieves a document by its ID
55
+ * @param id - Document ID to retrieve
56
+ * @returns The document if found, null otherwise
57
+ */
58
+ getById(id: string): Promise<IVectorStoreDocument | null>;
59
+ /**
60
+ * Queries the vector store using a pre-computed embedding vector
61
+ * @param vector - The embedding vector to search with
62
+ * @param options - Query options including top-k results
63
+ * @returns Array of matching documents
64
+ */
65
+ queryByVector(vector: number[], options?: IVectorStoreQueryOptions): Promise<IVectorStoreDocument[]>;
66
+ /**
67
+ * Updates the metadata for a document by its ID
68
+ * @param ids - Array of document IDs to update
69
+ * @param metadata - Metadata to update
70
+ */
71
+ updateMetadata(ids: string[], metadatas: Metadata[]): Promise<void>;
72
+ }
73
+ export { ChromaDataStore };
74
+ //# sourceMappingURL=chroma-data-store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chroma-data-store.d.ts","sourceRoot":"","sources":["../../src/chroma/chroma-data-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,QAAQ,EAEd,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,iBAAiB,EACjB,KAAK,oBAAoB,EACzB,KAAK,kCAAkC,EACvC,KAAK,mBAAmB,EACxB,KAAK,wBAAwB,EAC9B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,KAAK,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAI5D;;GAEG;AACH,cAAM,eAAgB,SAAQ,iBAAiB;IAC7C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAe;IACtC,OAAO,CAAC,UAAU,CAAa;IAE/B;;;;OAIG;gBACS,OAAO,EAAE,mBAAmB;IA0BxC;;;OAGG;IACH,OAAO,CAAC,kBAAkB;IAM1B;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAW3B;;;;;OAKG;IACG,KAAK,CACT,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,wBAAwB,CAAC,qBAAqB,CAAC,GACxD,OAAO,CAAC,oBAAoB,EAAE,CAAC;IAalC;;;;;OAKG;IACG,mBAAmB,CACvB,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,wBAAwB,CAAC,qBAAqB,CAAC,GAAG;QAC1D,mBAAmB,EAAE,MAAM,CAAC;KAC7B,GACA,OAAO,CAAC,oBAAoB,EAAE,CAAC;IAUlC;;;;OAIG;IACG,MAAM,CAAC,SAAS,EAAE,oBAAoB,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IA0BxD,0BAA0B,CAC9B,SAAS,EAAE,kCAAkC,EAAE,GAC9C,OAAO,CAAC,IAAI,CAAC;IAmChB;;;OAGG;IACG,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAO1C;;;;OAIG;IACG,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC;IAc/D;;;;;OAKG;IACG,aAAa,CACjB,MAAM,EAAE,MAAM,EAAE,EAChB,OAAO,CAAC,EAAE,wBAAwB,GACjC,OAAO,CAAC,oBAAoB,EAAE,CAAC;IASlC;;;;OAIG;IACG,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAO1E;AAED,OAAO,EAAE,eAAe,EAAE,CAAC"}