@mastra/mongodb 0.0.0-vnext-inngest-20250508131921 → 0.0.0-vnextAgentNetwork-20250527091247
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/CHANGELOG.md +172 -2
- package/README.md +50 -0
- package/dist/_tsup-dts-rollup.d.cts +153 -24
- package/dist/_tsup-dts-rollup.d.ts +153 -24
- package/dist/index.cjs +596 -31
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +596 -32
- package/docker-compose.yaml +30 -0
- package/package.json +8 -5
- package/src/index.ts +1 -0
- package/src/storage/index.test.ts +778 -0
- package/src/storage/index.ts +675 -0
- package/src/vector/index.test.ts +26 -13
- package/src/vector/index.ts +89 -48
- package/docker-compose.yml +0 -8
|
@@ -1,16 +1,25 @@
|
|
|
1
1
|
import { BaseFilterTranslator } from '@mastra/core/vector/filter';
|
|
2
2
|
import type { CreateIndexParams } from '@mastra/core/vector';
|
|
3
|
+
import type { DeleteIndexParams } from '@mastra/core/vector';
|
|
4
|
+
import type { DeleteVectorParams } from '@mastra/core/vector';
|
|
5
|
+
import type { DescribeIndexParams } from '@mastra/core/vector';
|
|
6
|
+
import type { EvalRow } from '@mastra/core/storage';
|
|
3
7
|
import type { IndexStats } from '@mastra/core/vector';
|
|
8
|
+
import { MastraStorage } from '@mastra/core/storage';
|
|
4
9
|
import { MastraVector } from '@mastra/core/vector';
|
|
10
|
+
import type { MessageType } from '@mastra/core/memory';
|
|
5
11
|
import type { MongoClientOptions } from 'mongodb';
|
|
6
12
|
import type { OperatorSupport } from '@mastra/core/vector/filter';
|
|
7
|
-
import type { ParamsToArgs } from '@mastra/core/vector';
|
|
8
13
|
import type { QueryResult } from '@mastra/core/vector';
|
|
9
|
-
import type { QueryVectorArgs } from '@mastra/core/vector';
|
|
10
14
|
import type { QueryVectorParams } from '@mastra/core/vector';
|
|
11
|
-
import type {
|
|
15
|
+
import type { StorageGetMessagesArg } from '@mastra/core/storage';
|
|
16
|
+
import type { StorageThreadType } from '@mastra/core/memory';
|
|
17
|
+
import type { TABLE_NAMES } from '@mastra/core/storage';
|
|
18
|
+
import type { UpdateVectorParams } from '@mastra/core/vector';
|
|
12
19
|
import type { UpsertVectorParams } from '@mastra/core/vector';
|
|
13
20
|
import type { VectorFilter } from '@mastra/core/vector/filter';
|
|
21
|
+
import type { WorkflowRun } from '@mastra/core/storage';
|
|
22
|
+
import type { WorkflowRunState } from '@mastra/core/workflows';
|
|
14
23
|
|
|
15
24
|
/**
|
|
16
25
|
* Vector store specific prompt that details supported operators and examples.
|
|
@@ -20,6 +29,14 @@ declare const MONGODB_PROMPT = "When querying MongoDB Vector, you can ONLY use t
|
|
|
20
29
|
export { MONGODB_PROMPT }
|
|
21
30
|
export { MONGODB_PROMPT as MONGODB_PROMPT_alias_1 }
|
|
22
31
|
|
|
32
|
+
declare interface MongoDBConfig {
|
|
33
|
+
url: string;
|
|
34
|
+
dbName: string;
|
|
35
|
+
options?: MongoClientOptions;
|
|
36
|
+
}
|
|
37
|
+
export { MongoDBConfig }
|
|
38
|
+
export { MongoDBConfig as MongoDBConfig_alias_1 }
|
|
39
|
+
|
|
23
40
|
/**
|
|
24
41
|
* Translator for MongoDB filter queries.
|
|
25
42
|
* Maintains MongoDB-compatible syntax while ensuring proper validation
|
|
@@ -33,9 +50,13 @@ export declare class MongoDBFilterTranslator extends BaseFilterTranslator {
|
|
|
33
50
|
isEmpty(filter: any): boolean;
|
|
34
51
|
}
|
|
35
52
|
|
|
36
|
-
declare
|
|
37
|
-
|
|
38
|
-
|
|
53
|
+
declare interface MongoDBIndexReadyParams {
|
|
54
|
+
indexName: string;
|
|
55
|
+
timeoutMs?: number;
|
|
56
|
+
checkIntervalMs?: number;
|
|
57
|
+
}
|
|
58
|
+
export { MongoDBIndexReadyParams }
|
|
59
|
+
export { MongoDBIndexReadyParams as MongoDBIndexReadyParams_alias_1 }
|
|
39
60
|
|
|
40
61
|
declare interface MongoDBQueryVectorParams extends QueryVectorParams {
|
|
41
62
|
documentFilter?: VectorFilter;
|
|
@@ -43,13 +64,93 @@ declare interface MongoDBQueryVectorParams extends QueryVectorParams {
|
|
|
43
64
|
export { MongoDBQueryVectorParams }
|
|
44
65
|
export { MongoDBQueryVectorParams as MongoDBQueryVectorParams_alias_1 }
|
|
45
66
|
|
|
46
|
-
declare
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
67
|
+
declare class MongoDBStore extends MastraStorage {
|
|
68
|
+
#private;
|
|
69
|
+
constructor(config: MongoDBConfig);
|
|
70
|
+
private getConnection;
|
|
71
|
+
private getCollection;
|
|
72
|
+
createTable(): Promise<void>;
|
|
73
|
+
clearTable({ tableName }: {
|
|
74
|
+
tableName: TABLE_NAMES;
|
|
75
|
+
}): Promise<void>;
|
|
76
|
+
insert({ tableName, record }: {
|
|
77
|
+
tableName: TABLE_NAMES;
|
|
78
|
+
record: Record<string, any>;
|
|
79
|
+
}): Promise<void>;
|
|
80
|
+
batchInsert({ tableName, records }: {
|
|
81
|
+
tableName: TABLE_NAMES;
|
|
82
|
+
records: Record<string, any>[];
|
|
83
|
+
}): Promise<void>;
|
|
84
|
+
load<R>({ tableName, keys }: {
|
|
85
|
+
tableName: TABLE_NAMES;
|
|
86
|
+
keys: Record<string, string>;
|
|
87
|
+
}): Promise<R | null>;
|
|
88
|
+
getThreadById({ threadId }: {
|
|
89
|
+
threadId: string;
|
|
90
|
+
}): Promise<StorageThreadType | null>;
|
|
91
|
+
getThreadsByResourceId({ resourceId }: {
|
|
92
|
+
resourceId: string;
|
|
93
|
+
}): Promise<StorageThreadType[]>;
|
|
94
|
+
saveThread({ thread }: {
|
|
95
|
+
thread: StorageThreadType;
|
|
96
|
+
}): Promise<StorageThreadType>;
|
|
97
|
+
updateThread({ id, title, metadata, }: {
|
|
98
|
+
id: string;
|
|
99
|
+
title: string;
|
|
100
|
+
metadata: Record<string, unknown>;
|
|
101
|
+
}): Promise<StorageThreadType>;
|
|
102
|
+
deleteThread({ threadId }: {
|
|
103
|
+
threadId: string;
|
|
104
|
+
}): Promise<void>;
|
|
105
|
+
getMessages<T = unknown>({ threadId, selectBy }: StorageGetMessagesArg): Promise<T[]>;
|
|
106
|
+
saveMessages({ messages }: {
|
|
107
|
+
messages: MessageType[];
|
|
108
|
+
}): Promise<MessageType[]>;
|
|
109
|
+
getTraces({ name, scope, page, perPage, attributes, filters, }?: {
|
|
110
|
+
name?: string;
|
|
111
|
+
scope?: string;
|
|
112
|
+
page: number;
|
|
113
|
+
perPage: number;
|
|
114
|
+
attributes?: Record<string, string>;
|
|
115
|
+
filters?: Record<string, any>;
|
|
116
|
+
}): Promise<any[]>;
|
|
117
|
+
getWorkflowRuns({ workflowName, fromDate, toDate, limit, offset, }?: {
|
|
118
|
+
workflowName?: string;
|
|
119
|
+
fromDate?: Date;
|
|
120
|
+
toDate?: Date;
|
|
121
|
+
limit?: number;
|
|
122
|
+
offset?: number;
|
|
123
|
+
}): Promise<{
|
|
124
|
+
runs: Array<{
|
|
125
|
+
workflowName: string;
|
|
126
|
+
runId: string;
|
|
127
|
+
snapshot: WorkflowRunState | string;
|
|
128
|
+
createdAt: Date;
|
|
129
|
+
updatedAt: Date;
|
|
130
|
+
}>;
|
|
131
|
+
total: number;
|
|
132
|
+
}>;
|
|
133
|
+
getEvalsByAgentName(agentName: string, type?: 'test' | 'live'): Promise<EvalRow[]>;
|
|
134
|
+
persistWorkflowSnapshot({ workflowName, runId, snapshot, }: {
|
|
135
|
+
workflowName: string;
|
|
136
|
+
runId: string;
|
|
137
|
+
snapshot: WorkflowRunState;
|
|
138
|
+
}): Promise<void>;
|
|
139
|
+
loadWorkflowSnapshot({ workflowName, runId, }: {
|
|
140
|
+
workflowName: string;
|
|
141
|
+
runId: string;
|
|
142
|
+
}): Promise<WorkflowRunState | null>;
|
|
143
|
+
getWorkflowRunById({ runId, workflowName, }: {
|
|
144
|
+
runId: string;
|
|
145
|
+
workflowName?: string;
|
|
146
|
+
}): Promise<WorkflowRun | null>;
|
|
147
|
+
private parseWorkflowRun;
|
|
148
|
+
private parseRow;
|
|
149
|
+
private transformEvalRow;
|
|
150
|
+
close(): Promise<void>;
|
|
151
|
+
}
|
|
152
|
+
export { MongoDBStore }
|
|
153
|
+
export { MongoDBStore as MongoDBStore_alias_1 }
|
|
53
154
|
|
|
54
155
|
declare interface MongoDBUpsertVectorParams extends UpsertVectorParams {
|
|
55
156
|
documents?: string[];
|
|
@@ -73,18 +174,46 @@ declare class MongoDBVector extends MastraVector {
|
|
|
73
174
|
});
|
|
74
175
|
connect(): Promise<void>;
|
|
75
176
|
disconnect(): Promise<void>;
|
|
76
|
-
createIndex(
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
177
|
+
createIndex({ indexName, dimension, metric }: CreateIndexParams): Promise<void>;
|
|
178
|
+
/**
|
|
179
|
+
* Waits for the index to be ready.
|
|
180
|
+
*
|
|
181
|
+
* @param {string} indexName - The name of the index to wait for
|
|
182
|
+
* @param {number} timeoutMs - The maximum time in milliseconds to wait for the index to be ready (default: 60000)
|
|
183
|
+
* @param {number} checkIntervalMs - The interval in milliseconds at which to check if the index is ready (default: 2000)
|
|
184
|
+
* @returns A promise that resolves when the index is ready
|
|
185
|
+
*/
|
|
186
|
+
waitForIndexReady({ indexName, timeoutMs, checkIntervalMs, }: MongoDBIndexReadyParams): Promise<void>;
|
|
187
|
+
upsert({ indexName, vectors, metadata, ids, documents }: MongoDBUpsertVectorParams): Promise<string[]>;
|
|
188
|
+
query({ indexName, queryVector, topK, filter, includeVector, documentFilter, }: MongoDBQueryVectorParams): Promise<QueryResult[]>;
|
|
80
189
|
listIndexes(): Promise<string[]>;
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
190
|
+
/**
|
|
191
|
+
* Retrieves statistics about a vector index.
|
|
192
|
+
*
|
|
193
|
+
* @param {string} indexName - The name of the index to describe
|
|
194
|
+
* @returns A promise that resolves to the index statistics including dimension, count and metric
|
|
195
|
+
*/
|
|
196
|
+
describeIndex({ indexName }: DescribeIndexParams): Promise<IndexStats>;
|
|
197
|
+
deleteIndex({ indexName }: DeleteIndexParams): Promise<void>;
|
|
198
|
+
/**
|
|
199
|
+
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
200
|
+
* @param indexName - The name of the index containing the vector.
|
|
201
|
+
* @param id - The ID of the vector to update.
|
|
202
|
+
* @param update - An object containing the vector and/or metadata to update.
|
|
203
|
+
* @param update.vector - An optional array of numbers representing the new vector.
|
|
204
|
+
* @param update.metadata - An optional record containing the new metadata.
|
|
205
|
+
* @returns A promise that resolves when the update is complete.
|
|
206
|
+
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
207
|
+
*/
|
|
208
|
+
updateVector({ indexName, id, update }: UpdateVectorParams): Promise<void>;
|
|
209
|
+
/**
|
|
210
|
+
* Deletes a vector by its ID.
|
|
211
|
+
* @param indexName - The name of the index containing the vector.
|
|
212
|
+
* @param id - The ID of the vector to delete.
|
|
213
|
+
* @returns A promise that resolves when the deletion is complete.
|
|
214
|
+
* @throws Will throw an error if the deletion operation fails.
|
|
215
|
+
*/
|
|
216
|
+
deleteVector({ indexName, id }: DeleteVectorParams): Promise<void>;
|
|
88
217
|
private getCollection;
|
|
89
218
|
private validateVectorDimensions;
|
|
90
219
|
private setIndexDimension;
|