@mastra/mongodb 1.19.0 → 1.20.0-alpha.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.
@@ -3,7 +3,7 @@ name: mastra-mongodb
3
3
  description: Documentation for @mastra/mongodb. Use when working with @mastra/mongodb APIs, configuration, or implementation.
4
4
  metadata:
5
5
  package: "@mastra/mongodb"
6
- version: "1.19.0"
6
+ version: "1.20.0-alpha.1"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.19.0",
2
+ "version": "1.20.0-alpha.1",
3
3
  "package": "@mastra/mongodb",
4
4
  "exports": {},
5
5
  "modules": {}
package/dist/index.cjs CHANGED
@@ -10,7 +10,7 @@ let _mastra_core_agent = require("@mastra/core/agent");
10
10
  let _mastra_core_evals = require("@mastra/core/evals");
11
11
  let _mastra_core_storage_domains_skills = require("@mastra/core/storage/domains/skills");
12
12
  //#region package.json
13
- var version = "1.19.0";
13
+ var version = "1.20.0-alpha.1";
14
14
  //#endregion
15
15
  //#region src/vector/filter.ts
16
16
  /**
@@ -2378,7 +2378,9 @@ function toDoc(task) {
2378
2378
  createdAt: task.createdAt.toISOString(),
2379
2379
  startedAt: task.startedAt?.toISOString() ?? null,
2380
2380
  suspendedAt: task.suspendedAt?.toISOString() ?? null,
2381
- completedAt: task.completedAt?.toISOString() ?? null
2381
+ completedAt: task.completedAt?.toISOString() ?? null,
2382
+ ownerId: task.ownerId ?? null,
2383
+ leaseExpiresAt: task.leaseExpiresAt?.toISOString() ?? null
2382
2384
  };
2383
2385
  }
2384
2386
  function fromDoc(doc) {
@@ -2401,7 +2403,9 @@ function fromDoc(doc) {
2401
2403
  createdAt: new Date(doc.createdAt),
2402
2404
  startedAt: doc.startedAt ? new Date(doc.startedAt) : void 0,
2403
2405
  suspendedAt: doc.suspendedAt ? new Date(doc.suspendedAt) : void 0,
2404
- completedAt: doc.completedAt ? new Date(doc.completedAt) : void 0
2406
+ completedAt: doc.completedAt ? new Date(doc.completedAt) : void 0,
2407
+ ownerId: doc.ownerId ?? void 0,
2408
+ leaseExpiresAt: doc.leaseExpiresAt ? new Date(doc.leaseExpiresAt) : void 0
2405
2409
  };
2406
2410
  }
2407
2411
  var BackgroundTasksStorageMongoDB = class BackgroundTasksStorageMongoDB extends _mastra_core_storage.BackgroundTasksStorage {
@@ -2518,11 +2522,14 @@ var BackgroundTasksStorageMongoDB = class BackgroundTasksStorageMongoDB extends
2518
2522
  if ("startedAt" in update) $set.startedAt = update.startedAt?.toISOString() ?? null;
2519
2523
  if ("suspendedAt" in update) $set.suspendedAt = update.suspendedAt?.toISOString() ?? null;
2520
2524
  if ("completedAt" in update) $set.completedAt = update.completedAt?.toISOString() ?? null;
2525
+ if ("ownerId" in update) $set.ownerId = update.ownerId ?? null;
2526
+ if ("leaseExpiresAt" in update) $set.leaseExpiresAt = update.leaseExpiresAt?.toISOString() ?? null;
2521
2527
  if (Object.keys($set).length === 0) return false;
2522
- return (await (await this.getCollection()).updateOne({
2523
- id: taskId,
2524
- ...options?.expectedStatus ? { status: options.expectedStatus } : {}
2525
- }, { $set })).matchedCount > 0;
2528
+ const filter = { id: taskId };
2529
+ if (options?.expectedStatus) filter.status = options.expectedStatus;
2530
+ if (options?.expectedOwnerId !== void 0) filter.ownerId = options.expectedOwnerId;
2531
+ if (options?.expectedLeaseExpiresAt !== void 0) filter.leaseExpiresAt = options.expectedLeaseExpiresAt?.toISOString() ?? null;
2532
+ return (await (await this.getCollection()).updateOne(filter, { $set })).matchedCount > 0;
2526
2533
  }
2527
2534
  async getTask(taskId) {
2528
2535
  const doc = await (await this.getCollection()).findOne({ id: taskId });
@@ -11015,7 +11022,7 @@ var MongoDBSkillsStorage = class MongoDBSkillsStorage extends _mastra_core_stora
11015
11022
  }
11016
11023
  async list(args) {
11017
11024
  try {
11018
- const { page = 0, perPage: perPageInput, orderBy, authorId, visibility, metadata } = args || {};
11025
+ const { page = 0, perPage: perPageInput, orderBy, authorId, visibility, metadata, status, entityIds } = args || {};
11019
11026
  const { field, direction } = this.parseOrderBy(orderBy);
11020
11027
  if (page < 0) throw new _mastra_core_error.MastraError({
11021
11028
  id: (0, _mastra_core_storage.createStorageErrorId)("MONGODB", "LIST_SKILLS", "INVALID_PAGE"),
@@ -11025,8 +11032,17 @@ var MongoDBSkillsStorage = class MongoDBSkillsStorage extends _mastra_core_stora
11025
11032
  }, /* @__PURE__ */ new Error("page must be >= 0"));
11026
11033
  const perPage = (0, _mastra_core_storage.normalizePerPage)(perPageInput, 100);
11027
11034
  const { offset, perPage: perPageForResponse } = (0, _mastra_core_storage.calculatePagination)(page, perPageInput, perPage);
11035
+ if (entityIds && entityIds.length === 0) return {
11036
+ skills: [],
11037
+ total: 0,
11038
+ page,
11039
+ perPage: perPageForResponse,
11040
+ hasMore: false
11041
+ };
11028
11042
  const collection = await this.getCollection(_mastra_core_storage.TABLE_SKILLS);
11029
11043
  const filter = {};
11044
+ if (entityIds && entityIds.length > 0) filter.id = { $in: entityIds };
11045
+ if (status) filter.status = status;
11030
11046
  if (authorId) filter.authorId = authorId;
11031
11047
  if (visibility) filter.visibility = visibility;
11032
11048
  if (metadata) for (const [key, value] of Object.entries(metadata)) filter[`metadata.${key}`] = value;