@mastra/mongodb 1.11.1 → 1.12.0-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.
- package/CHANGELOG.md +27 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/docs-memory-working-memory.md +2 -0
- package/dist/docs/references/docs-rag-retrieval.md +2 -0
- package/dist/docs/references/docs-rag-vector-databases.md +2 -0
- package/dist/docs/references/reference-storage-mongodb.md +2 -0
- package/dist/docs/references/reference-vectors-mongodb.md +2 -0
- package/dist/index.cjs +302 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +303 -3
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/background-tasks/index.d.ts +13 -0
- package/dist/storage/domains/background-tasks/index.d.ts.map +1 -1
- package/dist/storage/domains/experiments/index.d.ts +22 -1
- package/dist/storage/domains/experiments/index.d.ts.map +1 -1
- package/dist/storage/domains/memory/index.d.ts +14 -1
- package/dist/storage/domains/memory/index.d.ts.map +1 -1
- package/dist/storage/domains/notifications/index.d.ts +5 -1
- package/dist/storage/domains/notifications/index.d.ts.map +1 -1
- package/dist/storage/domains/observability/index.d.ts +5 -1
- package/dist/storage/domains/observability/index.d.ts.map +1 -1
- package/dist/storage/domains/schedules/index.d.ts +11 -1
- package/dist/storage/domains/schedules/index.d.ts.map +1 -1
- package/dist/storage/domains/scores/index.d.ts +5 -1
- package/dist/storage/domains/scores/index.d.ts.map +1 -1
- package/dist/storage/domains/workflows/index.d.ts +8 -1
- package/dist/storage/domains/workflows/index.d.ts.map +1 -1
- package/dist/storage/retention.d.ts +121 -0
- package/dist/storage/retention.d.ts.map +1 -0
- package/dist/storage/types.d.ts +21 -0
- package/dist/storage/types.d.ts.map +1 -1
- package/package.json +4 -4
|
@@ -1,11 +1,24 @@
|
|
|
1
1
|
import type { BackgroundTask, TaskFilter, TaskListResult, UpdateBackgroundTask } from '@mastra/core/background-tasks';
|
|
2
2
|
import { BackgroundTasksStorage } from '@mastra/core/storage';
|
|
3
|
+
import type { PruneOptions, PruneResult, RetentionTablesDescriptor, TableRetentionPolicy } from '@mastra/core/storage';
|
|
3
4
|
import type { MongoDBDomainConfig, MongoDBIndexConfig } from '../../types.js';
|
|
4
5
|
export declare class BackgroundTasksStorageMongoDB extends BackgroundTasksStorage {
|
|
5
6
|
#private;
|
|
6
7
|
static readonly MANAGED_COLLECTIONS: readonly ["mastra_background_tasks"];
|
|
8
|
+
/**
|
|
9
|
+
* Anchor is `completedAt`, so age is measured from task completion; it stays
|
|
10
|
+
* `null` while a task is in-flight, and `null $lt cutoff` never matches, so
|
|
11
|
+
* pending/running tasks are never pruned regardless of age.
|
|
12
|
+
*/
|
|
13
|
+
static readonly retentionTables: RetentionTablesDescriptor;
|
|
7
14
|
constructor(config: MongoDBDomainConfig);
|
|
8
15
|
private getCollection;
|
|
16
|
+
/**
|
|
17
|
+
* Delete tasks completed longer ago than the policy's `maxAge`, batched.
|
|
18
|
+
* `completedAt` is stored as an ISO-8601 string (see `toDoc`), so the cutoff
|
|
19
|
+
* uses the `iso` encoding — lexicographic `$lt` on ISO strings is time-ordered.
|
|
20
|
+
*/
|
|
21
|
+
prune(policies: Record<string, TableRetentionPolicy>, options?: PruneOptions): Promise<PruneResult[]>;
|
|
9
22
|
getDefaultIndexDefinitions(): MongoDBIndexConfig[];
|
|
10
23
|
createDefaultIndexes(): Promise<void>;
|
|
11
24
|
createCustomIndexes(): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/background-tasks/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EAEd,UAAU,EACV,cAAc,EACd,oBAAoB,EACrB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,sBAAsB,EAA0B,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","source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;IAuDtD,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAKzC,WAAW,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IAmC9C,eAAe,IAAI,OAAO,CAAC,MAAM,CAAC;IAKlC,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAI/D"}
|
|
@@ -1,11 +1,32 @@
|
|
|
1
1
|
import { ExperimentsStorage } from '@mastra/core/storage';
|
|
2
|
-
import type { Experiment, ExperimentResult, CreateExperimentInput, UpdateExperimentInput, AddExperimentResultInput, UpdateExperimentResultInput, ListExperimentsInput, ListExperimentsOutput, ListExperimentResultsInput, ListExperimentResultsOutput, ExperimentReviewCounts } from '@mastra/core/storage';
|
|
2
|
+
import type { Experiment, ExperimentResult, CreateExperimentInput, UpdateExperimentInput, AddExperimentResultInput, UpdateExperimentResultInput, ListExperimentsInput, ListExperimentsOutput, ListExperimentResultsInput, ListExperimentResultsOutput, ExperimentReviewCounts, PruneOptions, PruneResult, RetentionTablesDescriptor, TableRetentionPolicy } from '@mastra/core/storage';
|
|
3
3
|
import type { MongoDBDomainConfig, MongoDBIndexConfig } from '../../types.js';
|
|
4
4
|
export declare class MongoDBExperimentsStorage extends ExperimentsStorage {
|
|
5
5
|
#private;
|
|
6
6
|
static readonly MANAGED_COLLECTIONS: readonly ["mastra_experiments", "mastra_experiment_results"];
|
|
7
|
+
/**
|
|
8
|
+
* Experiments prune as whole units: an experiment and its results are only
|
|
9
|
+
* deleted together, once the experiment itself is old (anchored on the
|
|
10
|
+
* parent's `completedAt`, a BSON date that stays `null` while running).
|
|
11
|
+
* `results` is intentionally not an independent retention key.
|
|
12
|
+
*/
|
|
13
|
+
static readonly retentionTables: RetentionTablesDescriptor;
|
|
7
14
|
constructor(config: MongoDBDomainConfig);
|
|
8
15
|
private getCollection;
|
|
16
|
+
/**
|
|
17
|
+
* Prune whole experiments older than the `experiments` policy's `maxAge`.
|
|
18
|
+
*
|
|
19
|
+
* Each batch collects up to `batchSize` aged experiment ids
|
|
20
|
+
* (`completedAt < cutoff`; BSON type bracketing means `null` — still
|
|
21
|
+
* running — never matches), then deletes their `experiment_results` rows and
|
|
22
|
+
* the experiment rows for exactly that id set inside
|
|
23
|
+
* `connector.withTransaction()` — atomic on replica sets, sequential
|
|
24
|
+
* children-first on standalone — mirroring `deleteExperiment`. Hitting
|
|
25
|
+
* `maxBatches`/`maxRows` or the abort signal between batches therefore never
|
|
26
|
+
* leaves a run hollow (parent kept, results gone). Bounds count whole
|
|
27
|
+
* experiments, not rows.
|
|
28
|
+
*/
|
|
29
|
+
prune(policies: Record<string, TableRetentionPolicy>, options?: PruneOptions): Promise<PruneResult[]>;
|
|
9
30
|
getDefaultIndexDefinitions(): MongoDBIndexConfig[];
|
|
10
31
|
createDefaultIndexes(): Promise<void>;
|
|
11
32
|
createCustomIndexes(): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/experiments/index.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,kBAAkB,EAOnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EACV,UAAU,EACV,gBAAgB,EAEhB,qBAAqB,EACrB,qBAAqB,EACrB,wBAAwB,EACxB,2BAA2B,EAC3B,oBAAoB,EACpB,qBAAqB,EACrB,0BAA0B,EAC1B,2BAA2B,EAC3B,sBAAsB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/experiments/index.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,kBAAkB,EAOnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EACV,UAAU,EACV,gBAAgB,EAEhB,qBAAqB,EACrB,qBAAqB,EACrB,wBAAwB,EACxB,2BAA2B,EAC3B,oBAAoB,EACpB,qBAAqB,EACrB,0BAA0B,EAC1B,2BAA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,sBAAsB,CAAC,KAAK,EAAE,2BAA2B,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAqDrF,uBAAuB,CAAC,EAAE,EAAE,EAAE,EAAE;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;IAmBjF,qBAAqB,CAAC,IAAI,EAAE,0BAA0B,GAAG,OAAO,CAAC,2BAA2B,CAAC;IA8D7F,uBAAuB,CAAC,EAAE,YAAY,EAAE,EAAE;QAAE,YAAY,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAqBlF,gBAAgB,IAAI,OAAO,CAAC,sBAAsB,EAAE,CAAC;IAsCrD,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC;CAU3C"}
|
|
@@ -1,16 +1,29 @@
|
|
|
1
1
|
import type { MastraMessageContentV2 } from '@mastra/core/agent';
|
|
2
2
|
import type { MastraDBMessage, StorageThreadType } from '@mastra/core/memory';
|
|
3
3
|
import { MemoryStorage } from '@mastra/core/storage';
|
|
4
|
-
import type { StorageResourceType, StorageListMessagesInput, StorageListMessagesByResourceIdInput, StorageListMessagesOutput, StorageListThreadsInput, StorageListThreadsOutput, StorageCloneThreadInput, StorageCloneThreadOutput, ObservationalMemoryRecord, ObservationalMemoryHistoryOptions, CreateObservationalMemoryInput, UpdateActiveObservationsInput, UpdateBufferedObservationsInput, SwapBufferedToActiveInput, SwapBufferedToActiveResult, UpdateBufferedReflectionInput, SwapBufferedReflectionToActiveInput, CreateReflectionGenerationInput, UpdateObservationalMemoryConfigInput } from '@mastra/core/storage';
|
|
4
|
+
import type { PruneOptions, PruneResult, RetentionTablesDescriptor, TableRetentionPolicy, StorageResourceType, StorageListMessagesInput, StorageListMessagesByResourceIdInput, StorageListMessagesOutput, StorageListThreadsInput, StorageListThreadsOutput, StorageCloneThreadInput, StorageCloneThreadOutput, ObservationalMemoryRecord, ObservationalMemoryHistoryOptions, CreateObservationalMemoryInput, UpdateActiveObservationsInput, UpdateBufferedObservationsInput, SwapBufferedToActiveInput, SwapBufferedToActiveResult, UpdateBufferedReflectionInput, SwapBufferedReflectionToActiveInput, CreateReflectionGenerationInput, UpdateObservationalMemoryConfigInput } from '@mastra/core/storage';
|
|
5
5
|
import type { MongoDBDomainConfig, MongoDBIndexConfig } from '../../types.js';
|
|
6
6
|
export declare class MemoryStorageMongoDB extends MemoryStorage {
|
|
7
7
|
#private;
|
|
8
8
|
readonly supportsObservationalMemory = true;
|
|
9
9
|
/** Collections managed by this domain */
|
|
10
10
|
static readonly MANAGED_COLLECTIONS: readonly ["mastra_threads", "mastra_messages", "mastra_resources", "mastra_observational_memory"];
|
|
11
|
+
/**
|
|
12
|
+
* Retention-eligible collections. The observational-memory collection is
|
|
13
|
+
* excluded: it has no timestamp anchor to age on. All anchors are BSON dates.
|
|
14
|
+
*/
|
|
15
|
+
static readonly retentionTables: RetentionTablesDescriptor;
|
|
11
16
|
constructor(config: MongoDBDomainConfig);
|
|
12
17
|
private getCollection;
|
|
13
18
|
init(): Promise<void>;
|
|
19
|
+
/**
|
|
20
|
+
* Delete memory rows older than each table's `maxAge`, batched. Order is
|
|
21
|
+
* messages → resources → threads so child rows never outlive the delete of
|
|
22
|
+
* their thread. Like `deleteThread()`, this does not sweep vector-store
|
|
23
|
+
* embeddings — semantic-recall vectors live in a separate vector store the
|
|
24
|
+
* memory domain cannot reach; cleaning those up is the operator's concern.
|
|
25
|
+
*/
|
|
26
|
+
prune(policies: Record<string, TableRetentionPolicy>, options?: PruneOptions): Promise<PruneResult[]>;
|
|
14
27
|
/**
|
|
15
28
|
* Returns default index definitions for the memory domain collections.
|
|
16
29
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/memory/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAEjE,OAAO,KAAK,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E,OAAO,EAAE,oBAAoB,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAuC3G,0BAA0B,CAAC,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAiC3E,wBAAwB,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAkBpF,uBAAuB,CAAC,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA8CtE,+BAA+B,CAAC,KAAK,EAAE,oCAAoC,GAAG,OAAO,CAAC,IAAI,CAAC;IAyC3F,0BAA0B,CAAC,KAAK,EAAE,+BAA+B,GAAG,OAAO,CAAC,IAAI,CAAC;IA4DjF,oBAAoB,CAAC,KAAK,EAAE,yBAAyB,GAAG,OAAO,CAAC,0BAA0B,CAAC;IAoM3F,wBAAwB,CAAC,KAAK,EAAE,6BAA6B,GAAG,OAAO,CAAC,IAAI,CAAC;IA+D7E,8BAA8B,CAAC,KAAK,EAAE,mCAAmC,GAAG,OAAO,CAAC,yBAAyB,CAAC;CAgFrH"}
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { NotificationsStorage } from '@mastra/core/storage';
|
|
2
|
-
import type { CreateNotificationInput, ListDueNotificationsInput, ListNotificationsInput, NotificationRecord, UpdateNotificationInput } from '@mastra/core/storage';
|
|
2
|
+
import type { CreateNotificationInput, ListDueNotificationsInput, ListNotificationsInput, NotificationRecord, PruneOptions, PruneResult, RetentionTablesDescriptor, TableRetentionPolicy, UpdateNotificationInput } from '@mastra/core/storage';
|
|
3
3
|
import type { MongoDBDomainConfig, MongoDBIndexConfig } from '../../types.js';
|
|
4
4
|
export declare class NotificationsMongoDB extends NotificationsStorage {
|
|
5
5
|
#private;
|
|
6
6
|
static readonly MANAGED_COLLECTIONS: readonly ["mastra_notifications"];
|
|
7
|
+
/** Anchor is the notification's creation time, stored as a BSON date. */
|
|
8
|
+
static readonly retentionTables: RetentionTablesDescriptor;
|
|
7
9
|
constructor(config: MongoDBDomainConfig);
|
|
8
10
|
private getCollection;
|
|
11
|
+
/** Delete notifications older than the policy's `maxAge`, batched. */
|
|
12
|
+
prune(policies: Record<string, TableRetentionPolicy>, options?: PruneOptions): Promise<PruneResult[]>;
|
|
9
13
|
init(): Promise<void>;
|
|
10
14
|
getDefaultIndexDefinitions(): MongoDBIndexConfig[];
|
|
11
15
|
createDefaultIndexes(): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/notifications/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAuB,MAAM,sBAAsB,CAAC;AACjF,OAAO,KAAK,EACV,uBAAuB,EACvB,yBAAyB,EACzB,sBAAsB,EAEtB,kBAAkB,EAGlB,uBAAuB,EACxB,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/notifications/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAuB,MAAM,sBAAsB,CAAC;AACjF,OAAO,KAAK,EACV,uBAAuB,EACvB,yBAAyB,EACzB,sBAAsB,EAEtB,kBAAkB,EAGlB,YAAY,EACZ,WAAW,EACX,yBAAyB,EACzB,oBAAoB,EACpB,uBAAuB,EACxB,MAAM,sBAAsB,CAAC;AAM9B,OAAO,KAAK,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAkH3E,qBAAa,oBAAqB,SAAQ,oBAAoB;;IAK5D,MAAM,CAAC,QAAQ,CAAC,mBAAmB,oCAAkC;IAErE,yEAAyE;IACzE,gBAAyB,eAAe,EAAE,yBAAyB,CAEjE;gBAEU,MAAM,EAAE,mBAAmB;YASzB,aAAa;IAI3B,sEAAsE;IAChE,KAAK,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IASrG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAK3B,0BAA0B,IAAI,kBAAkB,EAAE;IAY5C,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC;IAYrC,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC;IAYpC,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC;IAKpC,kBAAkB,CAAC,KAAK,EAAE,uBAAuB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAgE/E,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,GAAG,OAAO,CAAC,kBAAkB,EAAE,CAAC;IAmB/E,oBAAoB,CAAC,KAAK,EAAE,yBAAyB,GAAG,OAAO,CAAC,kBAAkB,EAAE,CAAC;IAgBrF,eAAe,CAAC,KAAK,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC;IAM5F,kBAAkB,CAAC,KAAK,EAAE,uBAAuB,GAAG,OAAO,CAAC,kBAAkB,CAAC;YAkCvE,eAAe;CAoB9B"}
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import { ObservabilityStorage } from '@mastra/core/storage';
|
|
2
|
-
import type { ListTracesArgs, ListTracesResponse, TracingStorageStrategy, UpdateSpanArgs, BatchDeleteTracesArgs, BatchCreateSpansArgs, BatchUpdateSpansArgs, CreateSpanArgs, GetSpanArgs, GetSpanResponse, GetRootSpanArgs, GetRootSpanResponse, GetTraceArgs, GetTraceResponse, GetTraceLightResponse } from '@mastra/core/storage';
|
|
2
|
+
import type { PruneOptions, PruneResult, RetentionTablesDescriptor, TableRetentionPolicy, ListTracesArgs, ListTracesResponse, TracingStorageStrategy, UpdateSpanArgs, BatchDeleteTracesArgs, BatchCreateSpansArgs, BatchUpdateSpansArgs, CreateSpanArgs, GetSpanArgs, GetSpanResponse, GetRootSpanArgs, GetRootSpanResponse, GetTraceArgs, GetTraceResponse, GetTraceLightResponse } from '@mastra/core/storage';
|
|
3
3
|
import type { MongoDBDomainConfig, MongoDBIndexConfig } from '../../types.js';
|
|
4
4
|
export declare class ObservabilityMongoDB extends ObservabilityStorage {
|
|
5
5
|
#private;
|
|
6
6
|
/** Collections managed by this domain */
|
|
7
7
|
static readonly MANAGED_COLLECTIONS: readonly ["mastra_ai_spans"];
|
|
8
|
+
/** Anchor is the span's start time, stored as a BSON date. */
|
|
9
|
+
static readonly retentionTables: RetentionTablesDescriptor;
|
|
8
10
|
constructor(config: MongoDBDomainConfig);
|
|
9
11
|
private getCollection;
|
|
12
|
+
/** Delete spans older than the `spans` policy's `maxAge`, batched. */
|
|
13
|
+
prune(policies: Record<string, TableRetentionPolicy>, options?: PruneOptions): Promise<PruneResult[]>;
|
|
10
14
|
/**
|
|
11
15
|
* Returns default index definitions for the observability domain collections.
|
|
12
16
|
* These indexes optimize common query patterns for span and trace lookups.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/observability/index.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,oBAAoB,EAIrB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/observability/index.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,oBAAoB,EAIrB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EACV,YAAY,EACZ,WAAW,EACX,yBAAyB,EACzB,oBAAoB,EAGpB,cAAc,EACd,kBAAkB,EAClB,sBAAsB,EACtB,cAAc,EACd,qBAAqB,EACrB,oBAAoB,EACpB,oBAAoB,EACpB,cAAc,EACd,WAAW,EACX,eAAe,EACf,eAAe,EACf,mBAAmB,E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AK1C,IAAoB,eAAe,IAAI;QACrC,SAAS,EAAE,sBAAsB,CAAC;QAClC,SAAS,EAAE,sBAAsB,EAAE,CAAC;KACrC,CAKA;IAED,OAAO,CAAC,wBAAwB;IA8B1B,UAAU,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAmC/C,OAAO,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC;IA0B3D,WAAW,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC;IA0BvE,QAAQ,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;IA8B9D,aAAa,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,qBAAqB,GAAG,IAAI,CAAC;IA6CxE,UAAU,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAmC/C,UAAU,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,kBAAkB,CAAC;IA8R7D,gBAAgB,CAAC,IAAI,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;IA0C3D,gBAAgB,CAAC,IAAI,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;IA4C3D,iBAAiB,CAAC,IAAI,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC;IAmBnE;;OAEG;IACH,OAAO,CAAC,sBAAsB;CAoB/B"}
|
|
@@ -1,12 +1,22 @@
|
|
|
1
|
-
import type { Schedule, ScheduleFilter, ScheduleTrigger, ScheduleTriggerListOptions, ScheduleUpdate } from '@mastra/core/storage';
|
|
1
|
+
import type { PruneOptions, PruneResult, RetentionTablesDescriptor, Schedule, ScheduleFilter, ScheduleTrigger, ScheduleTriggerListOptions, ScheduleUpdate, TableRetentionPolicy } from '@mastra/core/storage';
|
|
2
2
|
import { SchedulesStorage } from '@mastra/core/storage';
|
|
3
3
|
import type { MongoDBDomainConfig, MongoDBIndexConfig } from '../../types.js';
|
|
4
4
|
export declare class SchedulesMongoDB extends SchedulesStorage {
|
|
5
5
|
#private;
|
|
6
6
|
static readonly MANAGED_COLLECTIONS: readonly ["mastra_schedules", "mastra_schedule_triggers"];
|
|
7
|
+
/**
|
|
8
|
+
* Only trigger (fire-history) rows are retention-eligible — schedule
|
|
9
|
+
* definitions are config, not growth. Anchor `actual_fire_at` is stored as a
|
|
10
|
+
* raw epoch-ms number, so `anchorType: 'epoch-ms'` keeps the cutoff numeric.
|
|
11
|
+
* The default composite index `(schedule_id, actual_fire_at)` can't serve a
|
|
12
|
+
* bare `actual_fire_at` range scan, hence the lazy single-field anchor index.
|
|
13
|
+
*/
|
|
14
|
+
static readonly retentionTables: RetentionTablesDescriptor;
|
|
7
15
|
constructor(config: MongoDBDomainConfig);
|
|
8
16
|
private getSchedulesCollection;
|
|
9
17
|
private getTriggersCollection;
|
|
18
|
+
/** Delete trigger (fire-history) rows older than the `triggers` policy's `maxAge`, batched. */
|
|
19
|
+
prune(policies: Record<string, TableRetentionPolicy>, options?: PruneOptions): Promise<PruneResult[]>;
|
|
10
20
|
getDefaultIndexDefinitions(): MongoDBIndexConfig[];
|
|
11
21
|
createDefaultIndexes(): Promise<void>;
|
|
12
22
|
createCustomIndexes(): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/schedules/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,EACR,cAAc,EAGd,eAAe,EACf,0BAA0B,EAC1B,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/schedules/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,WAAW,EACX,yBAAyB,EACzB,QAAQ,EACR,cAAc,EAGd,eAAe,EACf,0BAA0B,EAC1B,cAAc,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AAE,MAAM,EACV,kBAAkB,EAAE,MAAM,EAC1B,aAAa,EAAE,MAAM,EACrB,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,OAAO,CAAC;IAgBb,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IASzC,aAAa,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAKtD,YAAY,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,0BAA0B,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;CAkBtG"}
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import type { ListScoresResponse, SaveScorePayload, ScoreRowData, ScoringSource } from '@mastra/core/evals';
|
|
2
2
|
import { ScoresStorage } from '@mastra/core/storage';
|
|
3
|
-
import type { StoragePagination } from '@mastra/core/storage';
|
|
3
|
+
import type { PruneOptions, PruneResult, RetentionTablesDescriptor, StoragePagination, TableRetentionPolicy } from '@mastra/core/storage';
|
|
4
4
|
import type { MongoDBDomainConfig, MongoDBIndexConfig } from '../../types.js';
|
|
5
5
|
export declare class ScoresStorageMongoDB extends ScoresStorage {
|
|
6
6
|
#private;
|
|
7
7
|
/** Collections managed by this domain */
|
|
8
8
|
static readonly MANAGED_COLLECTIONS: readonly ["mastra_scorers"];
|
|
9
|
+
/** Anchor is the score row's creation time, stored as a BSON date. */
|
|
10
|
+
static readonly retentionTables: RetentionTablesDescriptor;
|
|
9
11
|
constructor(config: MongoDBDomainConfig);
|
|
10
12
|
private getCollection;
|
|
13
|
+
/** Delete scorer results older than the `scorers` policy's `maxAge`, batched. */
|
|
14
|
+
prune(policies: Record<string, TableRetentionPolicy>, options?: PruneOptions): Promise<PruneResult[]>;
|
|
11
15
|
/**
|
|
12
16
|
* Returns default index definitions for the scores domain collections.
|
|
13
17
|
* These indexes optimize common query patterns for score lookups.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/scores/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAE5G,OAAO,EAEL,aAAa,EAMd,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/scores/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAE5G,OAAO,EAEL,aAAa,EAMd,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EACV,YAAY,EACZ,WAAW,EACX,yBAAyB,EACzB,iBAAiB,EACjB,oBAAoB,EACrB,MAAM,sBAAsB,CAAC;AAI9B,OAAO,KAAK,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAY3E,qBAAa,oBAAqB,SAAQ,aAAa;;IAKrD,yCAAyC;IACzC,MAAM,CAAC,QAAQ,CAAC,mBAAmB,8BAA4B;IAE/D,sEAAsE;IACtE,gBAAyB,eAAe,EAAE,yBAAyB,CAEjE;gBAEU,MAAM,EAAE,mBAAmB;YAUzB,aAAa;IAI3B,iFAAiF;IAC3E,KAAK,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IAS3G;;;OAGG;IACH,0BAA0B,IAAI,kBAAkB,EAAE;IAY5C,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC;IAe3C;;OAEG;IACG,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC;IAepC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAKrB,mBAAmB,IAAI,OAAO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, UpdateWorkflowStateOptions } from '@mastra/core/storage';
|
|
2
|
+
import type { PruneOptions, PruneResult, RetentionTablesDescriptor, TableRetentionPolicy, WorkflowRun, WorkflowRuns, StorageListWorkflowRunsInput, UpdateWorkflowStateOptions } from '@mastra/core/storage';
|
|
3
3
|
import type { StepResult, WorkflowRunState } from '@mastra/core/workflows';
|
|
4
4
|
import type { MongoDBDomainConfig, MongoDBIndexConfig } from '../../types.js';
|
|
5
5
|
export declare class WorkflowsStorageMongoDB extends WorkflowsStorage {
|
|
6
6
|
#private;
|
|
7
7
|
/** Collections managed by this domain */
|
|
8
8
|
static readonly MANAGED_COLLECTIONS: readonly ["mastra_workflow_snapshot"];
|
|
9
|
+
/**
|
|
10
|
+
* Anchor is `updatedAt` (BSON date), so the policy reads as inactivity:
|
|
11
|
+
* a run is pruned only after its snapshot has not been touched for `maxAge`.
|
|
12
|
+
*/
|
|
13
|
+
static readonly retentionTables: RetentionTablesDescriptor;
|
|
9
14
|
constructor(config: MongoDBDomainConfig);
|
|
15
|
+
/** Delete workflow snapshots idle for longer than the policy's `maxAge`, batched. */
|
|
16
|
+
prune(policies: Record<string, TableRetentionPolicy>, options?: PruneOptions): Promise<PruneResult[]>;
|
|
10
17
|
supportsConcurrentUpdates(): boolean;
|
|
11
18
|
private getCollection;
|
|
12
19
|
init(): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/workflows/index.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,gBAAgB,EAIjB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EACV,WAAW,EACX,YAAY,EACZ,4BAA4B,EAC5B,0BAA0B,EAC3B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/workflows/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,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAiB5G,OAAO,CAAC,gBAAgB;CAoBzB"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import type { TABLE_NAMES, PruneOptions, PruneResult, TableRetentionPolicy } from '@mastra/core/storage';
|
|
2
|
+
import type { MongoDBConnector } from './connectors/MongoDBConnector.js';
|
|
3
|
+
export declare const DEFAULT_PRUNE_BATCH_SIZE = 1000;
|
|
4
|
+
/**
|
|
5
|
+
* How a collection physically stores its anchor value. MongoDB is schemaless,
|
|
6
|
+
* so the cutoff bound must match the stored representation exactly or the
|
|
7
|
+
* `$lt` comparison silently matches nothing (query operators are
|
|
8
|
+
* type-bracketed):
|
|
9
|
+
* - `date` (default): a BSON `Date` (memory, scores, notifications, workflows, spans).
|
|
10
|
+
* - `iso`: an ISO-8601 string, e.g. `background_tasks.completedAt` is written
|
|
11
|
+
* via `toISOString()`. Lexicographic `$lt` on ISO strings is time-ordered.
|
|
12
|
+
* - `epoch-ms`: a raw millisecond number, e.g. `schedule_triggers.actual_fire_at`.
|
|
13
|
+
*/
|
|
14
|
+
export type AnchorEncoding = 'date' | 'iso' | 'epoch-ms';
|
|
15
|
+
/** One collection to prune, resolved from a policy + the domain's descriptor. */
|
|
16
|
+
export interface PruneTarget {
|
|
17
|
+
/** Physical collection name. */
|
|
18
|
+
table: TABLE_NAMES;
|
|
19
|
+
/** Anchor field for the age comparison. */
|
|
20
|
+
column: string;
|
|
21
|
+
/** Stored representation of the anchor field (decides the cutoff's type). */
|
|
22
|
+
encoding: AnchorEncoding;
|
|
23
|
+
/** Whether the anchor field should get a supporting index before pruning. */
|
|
24
|
+
indexed: boolean;
|
|
25
|
+
/** Retention policy (maxAge + optional batchSize). */
|
|
26
|
+
policy: TableRetentionPolicy;
|
|
27
|
+
}
|
|
28
|
+
type RetentionLogger = {
|
|
29
|
+
warn?: (msg: string, err?: unknown) => void;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Lazily create the single-field anchor index a prune target relies on.
|
|
33
|
+
* Called from the prune path (not init) so only deployments that actually
|
|
34
|
+
* configure retention pay the index's write/disk overhead. Intentionally
|
|
35
|
+
* ignores `skipDefaultIndexes`: retention is an explicit opt-in feature, so
|
|
36
|
+
* its index is not part of the default set. Best-effort: a failure is logged
|
|
37
|
+
* and pruning proceeds (correct, just slower). `createIndex` is idempotent,
|
|
38
|
+
* so anchors already covered by a default single-field index are a no-op.
|
|
39
|
+
*/
|
|
40
|
+
export declare function ensureAnchorIndex(connector: MongoDBConnector, target: Pick<PruneTarget, 'table' | 'column' | 'indexed'>, logger?: RetentionLogger): Promise<void>;
|
|
41
|
+
/**
|
|
42
|
+
* Convert a policy's `maxAge` into a cutoff bound matching the anchor's stored
|
|
43
|
+
* representation (see {@link AnchorEncoding}).
|
|
44
|
+
*/
|
|
45
|
+
export declare function cutoffFor(policy: TableRetentionPolicy, encoding: AnchorEncoding, now?: number): string | number | Date;
|
|
46
|
+
/**
|
|
47
|
+
* Delete up to `limit` documents whose anchor field is older than `cutoff`.
|
|
48
|
+
*
|
|
49
|
+
* `deleteMany` has no limit clause, so each batch first collects `_id`s with a
|
|
50
|
+
* bounded `find`, then deletes exactly that set — the Mongo equivalent of the
|
|
51
|
+
* SQL stores' `DELETE ... WHERE rowid/ctid IN (SELECT ... LIMIT n)` pattern.
|
|
52
|
+
*/
|
|
53
|
+
export declare function pruneCollectionBatch({ connector, table, column, cutoff, limit, }: {
|
|
54
|
+
connector: MongoDBConnector;
|
|
55
|
+
table: TABLE_NAMES;
|
|
56
|
+
column: string;
|
|
57
|
+
cutoff: Date | string | number;
|
|
58
|
+
limit: number;
|
|
59
|
+
}): Promise<number>;
|
|
60
|
+
/**
|
|
61
|
+
* Run the bounded/cancellable batched-delete loop for a single logical target,
|
|
62
|
+
* delegating the actual delete of up to `limit` rows to `deleteBatch`. Returns
|
|
63
|
+
* `{ deleted, done }`; `done: false` means the loop stopped on a bound or the
|
|
64
|
+
* abort signal and eligible rows may remain.
|
|
65
|
+
*/
|
|
66
|
+
export declare function runBatchedDelete({ deleteBatch, batchSize, options, }: {
|
|
67
|
+
deleteBatch: (limit: number) => Promise<number>;
|
|
68
|
+
batchSize: number;
|
|
69
|
+
options?: PruneOptions;
|
|
70
|
+
}): Promise<{
|
|
71
|
+
deleted: number;
|
|
72
|
+
done: boolean;
|
|
73
|
+
}>;
|
|
74
|
+
/**
|
|
75
|
+
* Runs the bounded, batched, cancellable delete loop for a set of collections
|
|
76
|
+
* in the given order (callers pass children before parents for cascade-safe
|
|
77
|
+
* pruning), and returns one {@link PruneResult} per collection.
|
|
78
|
+
*
|
|
79
|
+
* The loop:
|
|
80
|
+
* - deletes in chunks of `batchSize` (default 1000), each a bounded
|
|
81
|
+
* `find(_id)` + `deleteMany(_id $in ...)` pair;
|
|
82
|
+
* - stops a collection's loop when a batch deletes fewer rows than requested
|
|
83
|
+
* (drained), or when `maxBatches`/`maxRows` is hit, or the `signal` aborts —
|
|
84
|
+
* the latter three leave `done: false` so the caller can resume;
|
|
85
|
+
* - pauses `pauseMs` between batches when set, to avoid starving live traffic.
|
|
86
|
+
*
|
|
87
|
+
* `prune()` only deletes documents; it never reclaims disk. WiredTiger reuses
|
|
88
|
+
* freed space for subsequent writes, so collections stop growing. Returning
|
|
89
|
+
* disk to the OS (e.g. `compact`) is left to the operator.
|
|
90
|
+
*/
|
|
91
|
+
export declare function runPrune({ connector, domain, targets, options, logger, }: {
|
|
92
|
+
connector: MongoDBConnector;
|
|
93
|
+
domain: string;
|
|
94
|
+
targets: PruneTarget[];
|
|
95
|
+
options?: PruneOptions;
|
|
96
|
+
logger?: RetentionLogger;
|
|
97
|
+
}): Promise<PruneResult[]>;
|
|
98
|
+
/**
|
|
99
|
+
* Resolve a domain's `{ tableKey: policy }` map plus its descriptor into an
|
|
100
|
+
* ordered list of {@link PruneTarget}s. `order` lists table keys children-first
|
|
101
|
+
* so cascade-dependent rows are removed before their parents. Table keys not in
|
|
102
|
+
* `policies` are skipped (unset = keep forever).
|
|
103
|
+
*
|
|
104
|
+
* `encodings` overrides the stored anchor representation per table key when it
|
|
105
|
+
* differs from what the core descriptor's `anchorType` implies (`epoch-ms` →
|
|
106
|
+
* `epoch-ms`, otherwise a BSON `date`). MongoDB-only concern: e.g.
|
|
107
|
+
* `background_tasks.completedAt` is stored as an ISO string.
|
|
108
|
+
*/
|
|
109
|
+
export declare function resolveTargets({ policies, descriptor, order, encodings, }: {
|
|
110
|
+
policies: Record<string, TableRetentionPolicy>;
|
|
111
|
+
descriptor: Record<string, {
|
|
112
|
+
table: string;
|
|
113
|
+
column: string;
|
|
114
|
+
anchorType?: 'timestamp' | 'epoch-ms';
|
|
115
|
+
indexed?: boolean;
|
|
116
|
+
}>;
|
|
117
|
+
order: string[];
|
|
118
|
+
encodings?: Record<string, AnchorEncoding>;
|
|
119
|
+
}): PruneTarget[];
|
|
120
|
+
export {};
|
|
121
|
+
//# sourceMappingURL=retention.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retention.d.ts","sourceRoot":"","sources":["../../src/storage/retention.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAEzG,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAEtE,eAAO,MAAM,wBAAwB,OAAO,CAAC;AAE7C;;;;;;;;;GASG;AACH,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,KAAK,GAAG,UAAU,CAAC;AAEzD,iFAAiF;AACjF,MAAM,WAAW,WAAW;IAC1B,gCAAgC;IAChC,KAAK,EAAE,WAAW,CAAC;IACnB,2CAA2C;IAC3C,MAAM,EAAE,MAAM,CAAC;IACf,6EAA6E;IAC7E,QAAQ,EAAE,cAAc,CAAC;IACzB,6EAA6E;IAC7E,OAAO,EAAE,OA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,QAAQ,CAAC,EAC7B,SAAS,EACT,MAAM,EACN,OAAO,EACP,OAAO,EACP,MAAM,GACP,EAAE;IACD,SAAS,EAAE,gBAAgB,CAAC;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,WAAW,EAAE,CAAC;IACvB,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,MAAM,CAAC,EAAE,eAAe,CAAC;CAC1B,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CA0BzB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,EAC7B,QAAQ,EACR,UAAU,EACV,KAAK,EACL,SAAS,GACV,EAAE;IACD,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;IAC/C,UAAU,EAAE,MAAM,CAChB,MAAM,EACN;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,WAAW,GAAG,UAAU,CAAC;QAAC,OAAO,CAAC,EAAE,OAAO,CAAA;KAAE,CAC5F,CAAC;IACF,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;CAC5C,GAAG,WAAW,EAAE,CAehB"}
|
package/dist/storage/types.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { RetentionConfig } from '@mastra/core/storage';
|
|
1
2
|
import type { MongoClientOptions, IndexSpecification, CreateIndexesOptions } from 'mongodb';
|
|
2
3
|
import type { ConnectorHandler } from './connectors/base.js';
|
|
3
4
|
import type { MongoDBConnector } from './connectors/MongoDBConnector.js';
|
|
@@ -56,6 +57,26 @@ export type MongoDBBaseConfig = {
|
|
|
56
57
|
* ```
|
|
57
58
|
*/
|
|
58
59
|
indexes?: MongoDBIndexConfig[];
|
|
60
|
+
/**
|
|
61
|
+
* Opt-in retention policies, keyed by domain then table. Rows older than a
|
|
62
|
+
* table's `maxAge` are deleted when `prune()` is called — nothing is deleted
|
|
63
|
+
* automatically; wire `prune()` to your own scheduler. Unset tables are kept
|
|
64
|
+
* forever.
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```typescript
|
|
68
|
+
* const store = new MongoDBStore({
|
|
69
|
+
* url: 'mongodb://localhost:27017',
|
|
70
|
+
* dbName: 'mastra',
|
|
71
|
+
* retention: {
|
|
72
|
+
* memory: { messages: { maxAge: '90d' } },
|
|
73
|
+
* observability: { spans: { maxAge: '30d' } },
|
|
74
|
+
* },
|
|
75
|
+
* });
|
|
76
|
+
* await store.prune();
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
retention?: RetentionConfig;
|
|
59
80
|
};
|
|
60
81
|
export type MongoDBConfig = DatabaseConfig | (MongoDBBaseConfig & {
|
|
61
82
|
connectorHandler: ConnectorHandler;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/storage/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAC5F,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAEtE;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX;;;;;;;;;;;;;;;;;;OAkBG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;;;;;;OAQG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B;;;;;;;;;;;;;;;;;;OAkBG;IACH,OAAO,CAAC,EAAE,kBAAkB,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/storage/types.ts"],"names":[],"mappings":"AAAA,OAAO,KA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CAAC;IAC7B,OAAO,CAAC,EAAE,kBAAkB,EAAE,CAAC;CAChC,GACD;IACE,gCAAgC;IAChC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,kBAAkB,CAAC;IAC7B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,OAAO,CAAC,EAAE,kBAAkB,EAAE,CAAC;CAChC,CAAC;AAEN;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,sBAAsB;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,+EAA+E;IAC/E,IAAI,EAAE,kBAAkB,CAAC;IACzB,6CAA6C;IAC7C,OAAO,CAAC,EAAE,oBAAoB,CAAC;CAChC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/mongodb",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.12.0-alpha.0",
|
|
4
4
|
"description": "MongoDB provider for Mastra - includes vector store capabilities",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -33,9 +33,9 @@
|
|
|
33
33
|
"typescript": "^6.0.3",
|
|
34
34
|
"vitest": "4.1.8",
|
|
35
35
|
"@internal/lint": "0.0.110",
|
|
36
|
-
"@
|
|
36
|
+
"@internal/types-builder": "0.0.85",
|
|
37
37
|
"@internal/storage-test-utils": "0.0.106",
|
|
38
|
-
"@
|
|
38
|
+
"@mastra/core": "1.49.0-alpha.3"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
41
|
"@mastra/core": ">=1.42.1-0 <2.0.0-0"
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"scripts": {
|
|
60
60
|
"build:lib": "tsup --silent --config tsup.config.ts",
|
|
61
61
|
"build:watch": "tsup --watch --silent --config tsup.config.ts",
|
|
62
|
-
"pretest": "docker compose up -d --wait",
|
|
62
|
+
"pretest": "docker compose up -d --wait || (echo '--- docker compose up failed; dumping diagnostics ---' && docker compose ps -a && docker compose logs && df -h && exit 1)",
|
|
63
63
|
"test": "vitest run",
|
|
64
64
|
"posttest": "docker compose down -v",
|
|
65
65
|
"pretest:watch": "docker compose up -d",
|