@mastra/mongodb 0.13.3 → 0.13.6-alpha.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.
@@ -1,43 +0,0 @@
1
- import type { IMastraLogger } from '@mastra/core/logger';
2
-
3
- export function formatDateForMongoDB(date: Date | string): Date {
4
- return typeof date === 'string' ? new Date(date) : date;
5
- }
6
-
7
- export function createExecuteOperationWithRetry({
8
- logger,
9
- maxRetries = 3,
10
- initialBackoffMs = 100,
11
- }: {
12
- logger: IMastraLogger;
13
- maxRetries?: number;
14
- initialBackoffMs?: number;
15
- }) {
16
- return async function executeOperationWithRetry<T>(
17
- operationFn: () => Promise<T>,
18
- operationDescription: string,
19
- ): Promise<T> {
20
- let retries = 0;
21
-
22
- while (true) {
23
- try {
24
- return await operationFn();
25
- } catch (error: any) {
26
- if (
27
- ((error.message && error.message.includes('connection')) || error.code === 'ECONNRESET') &&
28
- retries < maxRetries
29
- ) {
30
- retries++;
31
- const backoffTime = initialBackoffMs * Math.pow(2, retries - 1);
32
- logger.warn(
33
- `MongoDBStore: Encountered connection error during ${operationDescription}. Retrying (${retries}/${maxRetries}) in ${backoffTime}ms...`,
34
- );
35
- await new Promise(resolve => setTimeout(resolve, backoffTime));
36
- } else {
37
- logger.error(`MongoDBStore: Error during ${operationDescription} after ${retries} retries: ${error}`);
38
- throw error;
39
- }
40
- }
41
- }
42
- };
43
- }
@@ -1,196 +0,0 @@
1
- import { ErrorDomain, ErrorCategory, MastraError } from '@mastra/core/error';
2
- import { WorkflowsStorage, TABLE_WORKFLOW_SNAPSHOT, safelyParseJSON } from '@mastra/core/storage';
3
- import type { WorkflowRun, WorkflowRuns } from '@mastra/core/storage';
4
- import type { WorkflowRunState } from '@mastra/core/workflows';
5
- import type { StoreOperationsMongoDB } from '../operations';
6
-
7
- export class WorkflowsStorageMongoDB extends WorkflowsStorage {
8
- private operations: StoreOperationsMongoDB;
9
-
10
- constructor({ operations }: { operations: StoreOperationsMongoDB }) {
11
- super();
12
- this.operations = operations;
13
- }
14
-
15
- async persistWorkflowSnapshot({
16
- workflowName,
17
- runId,
18
- snapshot,
19
- }: {
20
- workflowName: string;
21
- runId: string;
22
- snapshot: WorkflowRunState;
23
- }): Promise<void> {
24
- try {
25
- const collection = await this.operations.getCollection(TABLE_WORKFLOW_SNAPSHOT);
26
- await collection.updateOne(
27
- { workflow_name: workflowName, run_id: runId },
28
- {
29
- $set: {
30
- workflow_name: workflowName,
31
- run_id: runId,
32
- snapshot,
33
- createdAt: new Date(),
34
- updatedAt: new Date(),
35
- },
36
- },
37
- { upsert: true },
38
- );
39
- } catch (error) {
40
- throw new MastraError(
41
- {
42
- id: 'STORAGE_MONGODB_STORE_PERSIST_WORKFLOW_SNAPSHOT_FAILED',
43
- domain: ErrorDomain.STORAGE,
44
- category: ErrorCategory.THIRD_PARTY,
45
- details: { workflowName, runId },
46
- },
47
- error,
48
- );
49
- }
50
- }
51
-
52
- async loadWorkflowSnapshot({
53
- workflowName,
54
- runId,
55
- }: {
56
- workflowName: string;
57
- runId: string;
58
- }): Promise<WorkflowRunState | null> {
59
- try {
60
- const result = await this.operations.load<any[]>({
61
- tableName: TABLE_WORKFLOW_SNAPSHOT,
62
- keys: {
63
- workflow_name: workflowName,
64
- run_id: runId,
65
- },
66
- });
67
-
68
- if (!result?.length) {
69
- return null;
70
- }
71
-
72
- return typeof result[0].snapshot === 'string' ? safelyParseJSON(result[0].snapshot) : result[0].snapshot;
73
- } catch (error) {
74
- throw new MastraError(
75
- {
76
- id: 'STORAGE_MONGODB_STORE_LOAD_WORKFLOW_SNAPSHOT_FAILED',
77
- domain: ErrorDomain.STORAGE,
78
- category: ErrorCategory.THIRD_PARTY,
79
- details: { workflowName, runId },
80
- },
81
- error,
82
- );
83
- }
84
- }
85
-
86
- async getWorkflowRuns(args?: {
87
- workflowName?: string;
88
- fromDate?: Date;
89
- toDate?: Date;
90
- limit?: number;
91
- offset?: number;
92
- resourceId?: string;
93
- }): Promise<WorkflowRuns> {
94
- const options = args || {};
95
- try {
96
- const query: any = {};
97
- if (options.workflowName) {
98
- query['workflow_name'] = options.workflowName;
99
- }
100
- if (options.fromDate) {
101
- query['createdAt'] = { $gte: options.fromDate };
102
- }
103
- if (options.toDate) {
104
- if (query['createdAt']) {
105
- query['createdAt'].$lte = options.toDate;
106
- } else {
107
- query['createdAt'] = { $lte: options.toDate };
108
- }
109
- }
110
- if (options.resourceId) {
111
- query['resourceId'] = options.resourceId;
112
- }
113
-
114
- const collection = await this.operations.getCollection(TABLE_WORKFLOW_SNAPSHOT);
115
- const total = await collection.countDocuments(query);
116
-
117
- let cursor = collection.find(query).sort({ createdAt: -1 });
118
- if (options.offset) {
119
- cursor = cursor.skip(options.offset);
120
- }
121
- if (options.limit) {
122
- cursor = cursor.limit(options.limit);
123
- }
124
-
125
- const results = await cursor.toArray();
126
-
127
- const runs = results.map(row => this.parseWorkflowRun(row));
128
-
129
- return {
130
- runs,
131
- total,
132
- };
133
- } catch (error) {
134
- throw new MastraError(
135
- {
136
- id: 'STORAGE_MONGODB_STORE_GET_WORKFLOW_RUNS_FAILED',
137
- domain: ErrorDomain.STORAGE,
138
- category: ErrorCategory.THIRD_PARTY,
139
- details: { workflowName: options.workflowName || 'unknown' },
140
- },
141
- error,
142
- );
143
- }
144
- }
145
-
146
- async getWorkflowRunById(args: { runId: string; workflowName?: string }): Promise<WorkflowRun | null> {
147
- try {
148
- const query: any = {};
149
- if (args.runId) {
150
- query['run_id'] = args.runId;
151
- }
152
- if (args.workflowName) {
153
- query['workflow_name'] = args.workflowName;
154
- }
155
-
156
- const collection = await this.operations.getCollection(TABLE_WORKFLOW_SNAPSHOT);
157
- const result = await collection.findOne(query);
158
- if (!result) {
159
- return null;
160
- }
161
-
162
- return this.parseWorkflowRun(result);
163
- } catch (error) {
164
- throw new MastraError(
165
- {
166
- id: 'STORAGE_MONGODB_STORE_GET_WORKFLOW_RUN_BY_ID_FAILED',
167
- domain: ErrorDomain.STORAGE,
168
- category: ErrorCategory.THIRD_PARTY,
169
- details: { runId: args.runId },
170
- },
171
- error,
172
- );
173
- }
174
- }
175
-
176
- private parseWorkflowRun(row: any): WorkflowRun {
177
- let parsedSnapshot: WorkflowRunState | string = row.snapshot as string;
178
- if (typeof parsedSnapshot === 'string') {
179
- try {
180
- parsedSnapshot = typeof row.snapshot === 'string' ? safelyParseJSON(row.snapshot as string) : row.snapshot;
181
- } catch (e) {
182
- // If parsing fails, return the raw snapshot string
183
- console.warn(`Failed to parse snapshot for workflow ${row.workflow_name}: ${e}`);
184
- }
185
- }
186
-
187
- return {
188
- workflowName: row.workflow_name as string,
189
- runId: row.run_id as string,
190
- snapshot: parsedSnapshot,
191
- createdAt: new Date(row.createdAt as string),
192
- updatedAt: new Date(row.updatedAt as string),
193
- resourceId: row.resourceId,
194
- };
195
- }
196
- }
@@ -1,62 +0,0 @@
1
- import { createTestSuite } from '@internal/storage-test-utils';
2
- import { describe, expect, it } from 'vitest';
3
- import type { ConnectorHandler } from './connectors/base';
4
- import type { MongoDBConfig } from './types';
5
- import { MongoDBStore } from './index';
6
-
7
- const TEST_CONFIG: MongoDBConfig = {
8
- url: process.env.MONGODB_URL || 'mongodb://localhost:27017',
9
- dbName: process.env.MONGODB_DB_NAME || 'mastra-test-db',
10
- };
11
-
12
- describe('Validation', () => {
13
- describe('with database options', () => {
14
- const validConfig = TEST_CONFIG;
15
- it('throws if url is empty', () => {
16
- expect(() => new MongoDBStore({ ...validConfig, url: '' })).toThrow(/url must be provided and cannot be empty/);
17
- });
18
-
19
- it('throws if dbName is missing or empty', () => {
20
- expect(() => new MongoDBStore({ ...validConfig, dbName: '' })).toThrow(
21
- /dbName must be provided and cannot be empty/,
22
- );
23
- const { dbName, ...rest } = validConfig;
24
- expect(() => new MongoDBStore(rest as any)).toThrow(/dbName must be provided and cannot be empty/);
25
- });
26
-
27
- it('does not throw on valid config (host-based)', () => {
28
- expect(() => new MongoDBStore(validConfig)).not.toThrow();
29
- });
30
- });
31
-
32
- describe('with connection handler', () => {
33
- const validWithConnectionHandlerConfig = {
34
- connectorHandler: {} as ConnectorHandler,
35
- };
36
-
37
- it('not throws if url is empty', () => {
38
- expect(() => new MongoDBStore({ ...validWithConnectionHandlerConfig, url: '' })).not.toThrow(
39
- /url must be provided and cannot be empty/,
40
- );
41
- });
42
-
43
- it('not throws if dbName is missing or empty', () => {
44
- expect(() => new MongoDBStore({ ...validWithConnectionHandlerConfig, dbName: '' })).not.toThrow(
45
- /dbName must be provided and cannot be empty/,
46
- );
47
- const { dbName, ...rest } = validWithConnectionHandlerConfig as any;
48
- expect(() => new MongoDBStore(rest as any)).not.toThrow(/dbName must be provided and cannot be empty/);
49
- });
50
-
51
- it('does not throw on valid config', () => {
52
- expect(() => new MongoDBStore(validWithConnectionHandlerConfig)).not.toThrow();
53
- });
54
-
55
- it('should initialize the stores correctly', () => {
56
- const store = new MongoDBStore(validWithConnectionHandlerConfig);
57
- expect(Object.keys(store.stores)).not.toHaveLength(0);
58
- });
59
- });
60
- });
61
-
62
- createTestSuite(new MongoDBStore(TEST_CONFIG));
@@ -1,406 +0,0 @@
1
- import type { MastraMessageContentV2 } from '@mastra/core/agent';
2
- import { ErrorCategory, ErrorDomain, MastraError } from '@mastra/core/error';
3
- import type { MastraMessageV1, MastraMessageV2, StorageThreadType } from '@mastra/core/memory';
4
- import type { ScoreRowData, ScoringSource } from '@mastra/core/scores';
5
- import type {
6
- EvalRow,
7
- PaginationArgs,
8
- PaginationInfo,
9
- StorageColumn,
10
- StorageDomains,
11
- StorageGetMessagesArg,
12
- StorageGetTracesArg,
13
- StorageGetTracesPaginatedArg,
14
- StoragePagination,
15
- StorageResourceType,
16
- TABLE_NAMES,
17
- WorkflowRun,
18
- WorkflowRuns,
19
- } from '@mastra/core/storage';
20
- import { MastraStorage } from '@mastra/core/storage';
21
- import type { Trace } from '@mastra/core/telemetry';
22
- import type { WorkflowRunState } from '@mastra/core/workflows';
23
- import { MongoDBConnector } from './connectors/MongoDBConnector';
24
- import { LegacyEvalsMongoDB } from './domains/legacy-evals';
25
- import { MemoryStorageMongoDB } from './domains/memory';
26
- import { StoreOperationsMongoDB } from './domains/operations';
27
- import { ScoresStorageMongoDB } from './domains/scores';
28
- import { TracesStorageMongoDB } from './domains/traces';
29
- import { WorkflowsStorageMongoDB } from './domains/workflows';
30
- import type { MongoDBConfig } from './types';
31
-
32
- const loadConnector = (config: MongoDBConfig): MongoDBConnector => {
33
- try {
34
- if ('connectorHandler' in config) {
35
- return MongoDBConnector.fromConnectionHandler(config.connectorHandler);
36
- }
37
- } catch (error) {
38
- throw new MastraError(
39
- {
40
- id: 'STORAGE_MONGODB_STORE_CONSTRUCTOR_FAILED',
41
- domain: ErrorDomain.STORAGE,
42
- category: ErrorCategory.USER,
43
- details: { connectionHandler: true },
44
- },
45
- error,
46
- );
47
- }
48
-
49
- try {
50
- return MongoDBConnector.fromDatabaseConfig({
51
- options: config.options,
52
- url: config.url,
53
- dbName: config.dbName,
54
- });
55
- } catch (error) {
56
- throw new MastraError(
57
- {
58
- id: 'STORAGE_MONGODB_STORE_CONSTRUCTOR_FAILED',
59
- domain: ErrorDomain.STORAGE,
60
- category: ErrorCategory.USER,
61
- details: { url: config?.url, dbName: config?.dbName },
62
- },
63
- error,
64
- );
65
- }
66
- };
67
-
68
- export class MongoDBStore extends MastraStorage {
69
- #connector: MongoDBConnector;
70
-
71
- stores: StorageDomains;
72
-
73
- public get supports(): {
74
- selectByIncludeResourceScope: boolean;
75
- resourceWorkingMemory: boolean;
76
- hasColumn: boolean;
77
- createTable: boolean;
78
- deleteMessages: boolean;
79
- } {
80
- return {
81
- selectByIncludeResourceScope: true,
82
- resourceWorkingMemory: true,
83
- hasColumn: false,
84
- createTable: false,
85
- deleteMessages: false,
86
- };
87
- }
88
-
89
- constructor(config: MongoDBConfig) {
90
- super({ name: 'MongoDBStore' });
91
-
92
- this.stores = {} as StorageDomains;
93
-
94
- this.#connector = loadConnector(config);
95
-
96
- const operations = new StoreOperationsMongoDB({
97
- connector: this.#connector,
98
- });
99
-
100
- const memory = new MemoryStorageMongoDB({
101
- operations,
102
- });
103
-
104
- const traces = new TracesStorageMongoDB({
105
- operations,
106
- });
107
-
108
- const legacyEvals = new LegacyEvalsMongoDB({
109
- operations,
110
- });
111
-
112
- const scores = new ScoresStorageMongoDB({
113
- operations,
114
- });
115
-
116
- const workflows = new WorkflowsStorageMongoDB({
117
- operations,
118
- });
119
-
120
- this.stores = {
121
- operations,
122
- memory,
123
- traces,
124
- legacyEvals,
125
- scores,
126
- workflows,
127
- };
128
- }
129
-
130
- async createTable({
131
- tableName,
132
- schema,
133
- }: {
134
- tableName: TABLE_NAMES;
135
- schema: Record<string, StorageColumn>;
136
- }): Promise<void> {
137
- return this.stores.operations.createTable({ tableName, schema });
138
- }
139
-
140
- async alterTable(_args: {
141
- tableName: TABLE_NAMES;
142
- schema: Record<string, StorageColumn>;
143
- ifNotExists: string[];
144
- }): Promise<void> {
145
- return this.stores.operations.alterTable(_args);
146
- }
147
-
148
- async dropTable({ tableName }: { tableName: TABLE_NAMES }): Promise<void> {
149
- return this.stores.operations.dropTable({ tableName });
150
- }
151
-
152
- async clearTable({ tableName }: { tableName: TABLE_NAMES }): Promise<void> {
153
- return this.stores.operations.clearTable({ tableName });
154
- }
155
-
156
- async insert({ tableName, record }: { tableName: TABLE_NAMES; record: Record<string, any> }): Promise<void> {
157
- return this.stores.operations.insert({ tableName, record });
158
- }
159
-
160
- async batchInsert({ tableName, records }: { tableName: TABLE_NAMES; records: Record<string, any>[] }): Promise<void> {
161
- return this.stores.operations.batchInsert({ tableName, records });
162
- }
163
-
164
- async load<R>({ tableName, keys }: { tableName: TABLE_NAMES; keys: Record<string, string> }): Promise<R | null> {
165
- return this.stores.operations.load({ tableName, keys });
166
- }
167
-
168
- async getThreadById({ threadId }: { threadId: string }): Promise<StorageThreadType | null> {
169
- return this.stores.memory.getThreadById({ threadId });
170
- }
171
-
172
- async getThreadsByResourceId({ resourceId }: { resourceId: string }): Promise<StorageThreadType[]> {
173
- return this.stores.memory.getThreadsByResourceId({ resourceId });
174
- }
175
-
176
- async saveThread({ thread }: { thread: StorageThreadType }): Promise<StorageThreadType> {
177
- return this.stores.memory.saveThread({ thread });
178
- }
179
-
180
- async updateThread({
181
- id,
182
- title,
183
- metadata,
184
- }: {
185
- id: string;
186
- title: string;
187
- metadata: Record<string, unknown>;
188
- }): Promise<StorageThreadType> {
189
- return this.stores.memory.updateThread({ id, title, metadata });
190
- }
191
-
192
- async deleteThread({ threadId }: { threadId: string }): Promise<void> {
193
- return this.stores.memory.deleteThread({ threadId });
194
- }
195
-
196
- public async getMessages(args: StorageGetMessagesArg & { format?: 'v1' }): Promise<MastraMessageV1[]>;
197
- public async getMessages(args: StorageGetMessagesArg & { format: 'v2' }): Promise<MastraMessageV2[]>;
198
- public async getMessages({
199
- threadId,
200
- selectBy,
201
- format,
202
- }: StorageGetMessagesArg & {
203
- format?: 'v1' | 'v2';
204
- }): Promise<MastraMessageV1[] | MastraMessageV2[]> {
205
- return this.stores.memory.getMessages({ threadId, selectBy, format });
206
- }
207
-
208
- async getMessagesById({ messageIds, format }: { messageIds: string[]; format: 'v1' }): Promise<MastraMessageV1[]>;
209
- async getMessagesById({ messageIds, format }: { messageIds: string[]; format?: 'v2' }): Promise<MastraMessageV2[]>;
210
- async getMessagesById({
211
- messageIds,
212
- format,
213
- }: {
214
- messageIds: string[];
215
- format?: 'v1' | 'v2';
216
- }): Promise<MastraMessageV1[] | MastraMessageV2[]> {
217
- return this.stores.memory.getMessagesById({ messageIds, format });
218
- }
219
-
220
- async saveMessages(args: { messages: MastraMessageV1[]; format?: undefined | 'v1' }): Promise<MastraMessageV1[]>;
221
- async saveMessages(args: { messages: MastraMessageV2[]; format: 'v2' }): Promise<MastraMessageV2[]>;
222
- async saveMessages(
223
- args: { messages: MastraMessageV1[]; format?: undefined | 'v1' } | { messages: MastraMessageV2[]; format: 'v2' },
224
- ): Promise<MastraMessageV2[] | MastraMessageV1[]> {
225
- return this.stores.memory.saveMessages(args);
226
- }
227
-
228
- async getThreadsByResourceIdPaginated(_args: {
229
- resourceId: string;
230
- page: number;
231
- perPage: number;
232
- }): Promise<PaginationInfo & { threads: StorageThreadType[] }> {
233
- return this.stores.memory.getThreadsByResourceIdPaginated(_args);
234
- }
235
-
236
- async getMessagesPaginated(
237
- _args: StorageGetMessagesArg,
238
- ): Promise<PaginationInfo & { messages: MastraMessageV1[] | MastraMessageV2[] }> {
239
- return this.stores.memory.getMessagesPaginated(_args);
240
- }
241
-
242
- async updateMessages(_args: {
243
- messages: Partial<Omit<MastraMessageV2, 'createdAt'>> &
244
- {
245
- id: string;
246
- content?: { metadata?: MastraMessageContentV2['metadata']; content?: MastraMessageContentV2['content'] };
247
- }[];
248
- }): Promise<MastraMessageV2[]> {
249
- return this.stores.memory.updateMessages(_args);
250
- }
251
-
252
- async getTraces(args: StorageGetTracesArg): Promise<Trace[]> {
253
- return this.stores.traces.getTraces(args);
254
- }
255
-
256
- async getTracesPaginated(args: StorageGetTracesPaginatedArg): Promise<PaginationInfo & { traces: Trace[] }> {
257
- return this.stores.traces.getTracesPaginated(args);
258
- }
259
-
260
- async getWorkflowRuns(args?: {
261
- workflowName?: string;
262
- fromDate?: Date;
263
- toDate?: Date;
264
- limit?: number;
265
- offset?: number;
266
- resourceId?: string;
267
- }): Promise<WorkflowRuns> {
268
- return this.stores.workflows.getWorkflowRuns(args);
269
- }
270
-
271
- async getEvals(
272
- options: {
273
- agentName?: string;
274
- type?: 'test' | 'live';
275
- } & PaginationArgs = {},
276
- ): Promise<PaginationInfo & { evals: EvalRow[] }> {
277
- return this.stores.legacyEvals.getEvals(options);
278
- }
279
-
280
- async getEvalsByAgentName(agentName: string, type?: 'test' | 'live'): Promise<EvalRow[]> {
281
- return this.stores.legacyEvals.getEvalsByAgentName(agentName, type);
282
- }
283
-
284
- async persistWorkflowSnapshot({
285
- workflowName,
286
- runId,
287
- snapshot,
288
- }: {
289
- workflowName: string;
290
- runId: string;
291
- snapshot: WorkflowRunState;
292
- }): Promise<void> {
293
- return this.stores.workflows.persistWorkflowSnapshot({ workflowName, runId, snapshot });
294
- }
295
-
296
- async loadWorkflowSnapshot({
297
- workflowName,
298
- runId,
299
- }: {
300
- workflowName: string;
301
- runId: string;
302
- }): Promise<WorkflowRunState | null> {
303
- return this.stores.workflows.loadWorkflowSnapshot({ workflowName, runId });
304
- }
305
-
306
- async getWorkflowRunById({
307
- runId,
308
- workflowName,
309
- }: {
310
- runId: string;
311
- workflowName?: string;
312
- }): Promise<WorkflowRun | null> {
313
- return this.stores.workflows.getWorkflowRunById({ runId, workflowName });
314
- }
315
-
316
- async close(): Promise<void> {
317
- try {
318
- await this.#connector.close();
319
- } catch (error) {
320
- throw new MastraError(
321
- {
322
- id: 'STORAGE_MONGODB_STORE_CLOSE_FAILED',
323
- domain: ErrorDomain.STORAGE,
324
- category: ErrorCategory.USER,
325
- },
326
- error,
327
- );
328
- }
329
- }
330
-
331
- /**
332
- * SCORERS
333
- */
334
- async getScoreById({ id }: { id: string }): Promise<ScoreRowData | null> {
335
- return this.stores.scores.getScoreById({ id });
336
- }
337
-
338
- async saveScore(score: Omit<ScoreRowData, 'id' | 'createdAt' | 'updatedAt'>): Promise<{ score: ScoreRowData }> {
339
- return this.stores.scores.saveScore(score);
340
- }
341
-
342
- async getScoresByRunId({
343
- runId,
344
- pagination,
345
- }: {
346
- runId: string;
347
- pagination: StoragePagination;
348
- }): Promise<{ pagination: PaginationInfo; scores: ScoreRowData[] }> {
349
- return this.stores.scores.getScoresByRunId({ runId, pagination });
350
- }
351
-
352
- async getScoresByEntityId({
353
- entityId,
354
- entityType,
355
- pagination,
356
- }: {
357
- pagination: StoragePagination;
358
- entityId: string;
359
- entityType: string;
360
- }): Promise<{ pagination: PaginationInfo; scores: ScoreRowData[] }> {
361
- return this.stores.scores.getScoresByEntityId({ entityId, entityType, pagination });
362
- }
363
-
364
- async getScoresByScorerId({
365
- scorerId,
366
- pagination,
367
- entityId,
368
- entityType,
369
- source,
370
- }: {
371
- scorerId: string;
372
- pagination: StoragePagination;
373
- entityId?: string;
374
- entityType?: string;
375
- source?: ScoringSource;
376
- }): Promise<{ pagination: PaginationInfo; scores: ScoreRowData[] }> {
377
- return this.stores.scores.getScoresByScorerId({ scorerId, pagination, entityId, entityType, source });
378
- }
379
-
380
- /**
381
- * RESOURCES
382
- */
383
- async getResourceById({ resourceId }: { resourceId: string }): Promise<StorageResourceType | null> {
384
- return this.stores.memory.getResourceById({ resourceId });
385
- }
386
-
387
- async saveResource({ resource }: { resource: StorageResourceType }): Promise<StorageResourceType> {
388
- return this.stores.memory.saveResource({ resource });
389
- }
390
-
391
- async updateResource({
392
- resourceId,
393
- workingMemory,
394
- metadata,
395
- }: {
396
- resourceId: string;
397
- workingMemory?: string;
398
- metadata?: Record<string, unknown>;
399
- }): Promise<StorageResourceType> {
400
- return this.stores.memory.updateResource({
401
- resourceId,
402
- workingMemory,
403
- metadata,
404
- });
405
- }
406
- }