@mastra/mongodb 1.18.9-alpha.0 → 1.18.9-alpha.2

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/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { v4 } from "@lukeed/uuid";
2
2
  import { ErrorCategory, ErrorDomain, MastraError } from "@mastra/core/error";
3
- import { AgentsStorage, BackgroundTasksStorage, BlobStore, DatasetsStorage, ExperimentsStorage, KnowledgeConflictError, KnowledgeNotFoundError, KnowledgeStorage, MCPClientsStorage, MCPServersStorage, MastraCompositeStore, MemoryStorage, NotificationsStorage, ObservabilityStorage, PromptBlocksStorage, SchedulesStorage, ScorerDefinitionsStorage, ScoresStorage, SkillsStorage, TABLE_AGENTS, TABLE_AGENT_VERSIONS, TABLE_BACKGROUND_TASKS, TABLE_DATASETS, TABLE_DATASET_ITEMS, TABLE_DATASET_VERSIONS, TABLE_EXPERIMENTS, TABLE_EXPERIMENT_RESULTS, TABLE_KNOWLEDGE_ACTIVITY, TABLE_KNOWLEDGE_CURSORS, TABLE_KNOWLEDGE_MENTIONS, TABLE_KNOWLEDGE_NODES, TABLE_KNOWLEDGE_RECORDS, TABLE_KNOWLEDGE_SEMANTIC_OUTBOX, TABLE_MCP_CLIENTS, TABLE_MCP_CLIENT_VERSIONS, TABLE_MCP_SERVERS, TABLE_MCP_SERVER_VERSIONS, TABLE_MESSAGES, TABLE_NOTIFICATIONS, TABLE_PROMPT_BLOCKS, TABLE_PROMPT_BLOCK_VERSIONS, TABLE_RESOURCES, TABLE_SCHEDULES, TABLE_SCHEDULE_TRIGGERS, TABLE_SCORERS, TABLE_SCORER_DEFINITIONS, TABLE_SCORER_DEFINITION_VERSIONS, TABLE_SKILLS, TABLE_SKILL_BLOBS, TABLE_SKILL_VERSIONS, TABLE_SPANS, TABLE_THREADS, TABLE_WORKFLOW_DEFINITIONS, TABLE_WORKFLOW_SNAPSHOT, TABLE_WORKSPACES, TABLE_WORKSPACE_VERSIONS, TraceStatus, WorkflowDefinitionsStorage, WorkflowsStorage, WorkspacesStorage, assertKnowledgeCeilingRaised, assertKnowledgeScopeWithinCeiling, calculatePagination, canonicalizeKnowledgeScope, createKnowledgeUlid, createStorageErrorId, createVectorErrorId, ensureDate, hasErrorCode, isKnowledgeScopeVisible, knowledgeScopeKey, knowledgeSemanticDocumentId, knowledgeSemanticIdempotencyKey, listTracesArgsSchema, normalizePerPage, normalizeScheduleTarget, parseDuration, parseKnowledgeNodeCursor, parseKnowledgeWikilinks, safelyParseJSON, storageMessageMatchesMetadataFilter, toTraceSpans, transformScoreRow, validateStorageMetadataFilter } from "@mastra/core/storage";
3
+ import { AgentsStorage, BackgroundTasksStorage, BlobStore, DatasetsStorage, ExperimentsStorage, KnowledgeConflictError, KnowledgeNotFoundError, KnowledgeStorage, MCPClientsStorage, MCPServersStorage, MastraCompositeStore, MemoryStorage, NotificationsStorage, ObservabilityStorage, PromptBlocksStorage, SchedulesStorage, ScorerDefinitionsStorage, ScoresStorage, SkillsStorage, TABLE_AGENTS, TABLE_AGENT_VERSIONS, TABLE_BACKGROUND_TASKS, TABLE_DATASETS, TABLE_DATASET_ITEMS, TABLE_DATASET_VERSIONS, TABLE_EXPERIMENTS, TABLE_EXPERIMENT_RESULTS, TABLE_KNOWLEDGE_ACTIVITY, TABLE_KNOWLEDGE_CURSORS, TABLE_KNOWLEDGE_MENTIONS, TABLE_KNOWLEDGE_NODES, TABLE_KNOWLEDGE_RECORDS, TABLE_KNOWLEDGE_SEMANTIC_OUTBOX, TABLE_MCP_CLIENTS, TABLE_MCP_CLIENT_VERSIONS, TABLE_MCP_SERVERS, TABLE_MCP_SERVER_VERSIONS, TABLE_MESSAGES, TABLE_NOTIFICATIONS, TABLE_PROMPT_BLOCKS, TABLE_PROMPT_BLOCK_VERSIONS, TABLE_RESOURCES, TABLE_SCHEDULES, TABLE_SCHEDULE_TRIGGERS, TABLE_SCORERS, TABLE_SCORER_DEFINITIONS, TABLE_SCORER_DEFINITION_VERSIONS, TABLE_SKILLS, TABLE_SKILL_BLOBS, TABLE_SKILL_VERSIONS, TABLE_SPANS, TABLE_THREADS, TABLE_WORKFLOW_DEFINITIONS, TABLE_WORKFLOW_SNAPSHOT, TABLE_WORKSPACES, TABLE_WORKSPACE_VERSIONS, TraceStatus, WorkflowDefinitionsStorage, WorkflowsStorage, WorkspacesStorage, assertKnowledgeCeilingRaised, assertKnowledgeScopeWithinCeiling, calculatePagination, canonicalizeKnowledgeScope, createKnowledgeUlid, createStorageErrorId, createVectorErrorId, ensureDate, hasErrorCode, isKnowledgeScopeVisible, knowledgeScopeKey, knowledgeSemanticDocumentId, knowledgeSemanticIdempotencyKey, listTracesArgsSchema, normalizePerPage, normalizeScheduleTarget, parseDuration, parseKnowledgeNodeCursor, parseKnowledgeWikilinks, resolveListOrderBy, safelyParseJSON, storageMessageMatchesMetadataFilter, toTraceSpans, transformScoreRow, validateStorageMetadataFilter } from "@mastra/core/storage";
4
4
  import { MastraVector, validateUpsertInput, validateVectorValues } from "@mastra/core/vector";
5
5
  import { MongoBulkWriteError, MongoClient, ObjectId } from "mongodb";
6
6
  import { BaseFilterTranslator } from "@mastra/core/vector/filter";
@@ -9,7 +9,7 @@ import { MessageList } from "@mastra/core/agent";
9
9
  import { saveScorePayloadSchema } from "@mastra/core/evals";
10
10
  import { skillSnapshotFieldValuesEqual } from "@mastra/core/storage/domains/skills";
11
11
  //#region package.json
12
- var version = "1.18.9-alpha.0";
12
+ var version = "1.18.9-alpha.2";
13
13
  //#endregion
14
14
  //#region src/vector/filter.ts
15
15
  /**
@@ -2960,6 +2960,14 @@ var MongoDBDatasetsStorage = class extends DatasetsStorage {
2960
2960
  }
2961
2961
  async listDatasets(args) {
2962
2962
  try {
2963
+ const orderBy = resolveListOrderBy(args.orderBy, [
2964
+ "createdAt",
2965
+ "updatedAt",
2966
+ "name"
2967
+ ], {
2968
+ field: "createdAt",
2969
+ direction: "DESC"
2970
+ });
2963
2971
  const { page, perPage: perPageInput } = args.pagination;
2964
2972
  const collection = await this.getCollection(TABLE_DATASETS);
2965
2973
  const filter = {};
@@ -2997,7 +3005,7 @@ var MongoDBDatasetsStorage = class extends DatasetsStorage {
2997
3005
  const limitValue = perPageInput === false ? total : perPage;
2998
3006
  return {
2999
3007
  datasets: (await collection.find(filter).sort({
3000
- createdAt: -1,
3008
+ [orderBy.field]: orderBy.direction === "DESC" ? -1 : 1,
3001
3009
  id: 1
3002
3010
  }).skip(offset).limit(limitValue).toArray()).map((row) => this.transformDatasetRow(row)),
3003
3011
  pagination: {
@@ -3607,6 +3615,10 @@ var MongoDBDatasetsStorage = class extends DatasetsStorage {
3607
3615
  }
3608
3616
  async listItems(args) {
3609
3617
  try {
3618
+ const orderBy = resolveListOrderBy(args.orderBy, ["createdAt", "updatedAt"], {
3619
+ field: "createdAt",
3620
+ direction: "DESC"
3621
+ });
3610
3622
  const { page, perPage: perPageInput } = args.pagination;
3611
3623
  const collection = await this.getCollection(TABLE_DATASET_ITEMS);
3612
3624
  const filter = { datasetId: args.datasetId };
@@ -3662,7 +3674,7 @@ var MongoDBDatasetsStorage = class extends DatasetsStorage {
3662
3674
  const limitValue = perPageInput === false ? total : perPage;
3663
3675
  return {
3664
3676
  items: (await collection.find(filter).sort({
3665
- createdAt: -1,
3677
+ [orderBy.field]: orderBy.direction === "DESC" ? -1 : 1,
3666
3678
  id: 1
3667
3679
  }).skip(offset).limit(limitValue).toArray()).map((row) => this.transformItemRow(row)),
3668
3680
  pagination: {
@@ -4134,6 +4146,10 @@ var MongoDBExperimentsStorage = class MongoDBExperimentsStorage extends Experime
4134
4146
  }
4135
4147
  async listExperiments(args) {
4136
4148
  try {
4149
+ const orderBy = resolveListOrderBy(args.orderBy, ["createdAt", "status"], {
4150
+ field: "createdAt",
4151
+ direction: "DESC"
4152
+ });
4137
4153
  const collection = await this.getCollection(TABLE_EXPERIMENTS);
4138
4154
  const { page, perPage: perPageInput } = args.pagination;
4139
4155
  const filter = {};
@@ -4175,7 +4191,7 @@ var MongoDBExperimentsStorage = class MongoDBExperimentsStorage extends Experime
4175
4191
  const limitValue = perPageInput === false ? total : normalizedPerPage;
4176
4192
  return {
4177
4193
  experiments: (await collection.find(filter).sort({
4178
- createdAt: -1,
4194
+ [orderBy.field]: orderBy.direction === "DESC" ? -1 : 1,
4179
4195
  id: 1
4180
4196
  }).skip(offset).limit(limitValue).toArray()).map((d) => transformExperimentRow(d)),
4181
4197
  pagination: {
@@ -4374,6 +4390,10 @@ var MongoDBExperimentsStorage = class MongoDBExperimentsStorage extends Experime
4374
4390
  }
4375
4391
  async listExperimentResults(args) {
4376
4392
  try {
4393
+ const orderBy = resolveListOrderBy(args.orderBy, ["startedAt", "createdAt"], {
4394
+ field: "startedAt",
4395
+ direction: "ASC"
4396
+ });
4377
4397
  const collection = await this.getCollection(TABLE_EXPERIMENT_RESULTS);
4378
4398
  const { page, perPage: perPageInput } = args.pagination;
4379
4399
  const filter = { experimentId: args.experimentId };
@@ -4409,7 +4429,7 @@ var MongoDBExperimentsStorage = class MongoDBExperimentsStorage extends Experime
4409
4429
  const limitValue = perPageInput === false ? total : normalizedPerPage;
4410
4430
  return {
4411
4431
  results: (await collection.find(filter).sort({
4412
- startedAt: 1,
4432
+ [orderBy.field]: orderBy.direction === "DESC" ? -1 : 1,
4413
4433
  id: 1
4414
4434
  }).skip(offset).limit(limitValue).toArray()).map((d) => transformExperimentResultRow(d)),
4415
4435
  pagination: {