@mastra/mongodb 1.8.1 → 1.9.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 CHANGED
@@ -1,5 +1,33 @@
1
1
  # @mastra/mongodb
2
2
 
3
+ ## 1.9.0-alpha.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Added favorites support to storage adapters so callers can favorite/unfavorite stored agents and skills, query favorite state alongside list results, and filter listings by visibility. ([#16580](https://github.com/mastra-ai/mastra/pull/16580))
8
+
9
+ **Example**
10
+
11
+ ```ts
12
+ const storage = new LibSQLStore({
13
+ /* config */
14
+ });
15
+ const favorites = await storage.getStore('favorites');
16
+
17
+ await favorites?.favorite({
18
+ userId: 'user-1',
19
+ entityType: 'agent',
20
+ entityId: 'agent-42',
21
+ });
22
+ ```
23
+
24
+ ### Patch Changes
25
+
26
+ - Bumped `@mastra/core` peer dependency floor to `>=1.34.0-0` so the new `@mastra/core/storage/domains/favorites` subpath is available. Older `@mastra/core` versions don't ship the `FavoritesStorage` base class these adapters now extend. ([#16580](https://github.com/mastra-ai/mastra/pull/16580))
27
+
28
+ - Updated dependencies [[`816b974`](https://github.com/mastra-ai/mastra/commit/816b974b424e4a1bfae3af30cc41263b6f1c0344), [`816b974`](https://github.com/mastra-ai/mastra/commit/816b974b424e4a1bfae3af30cc41263b6f1c0344), [`b32ba5f`](https://github.com/mastra-ai/mastra/commit/b32ba5fde524b46a4ff1bdf38e30d62a2bb29b04)]:
29
+ - @mastra/core@1.35.0-alpha.2
30
+
3
31
  ## 1.8.1
4
32
 
5
33
  ### Patch Changes
@@ -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.8.1"
6
+ version: "1.9.0-alpha.0"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.8.1",
2
+ "version": "1.9.0-alpha.0",
3
3
  "package": "@mastra/mongodb",
4
4
  "exports": {},
5
5
  "modules": {}
package/dist/index.cjs CHANGED
@@ -14,7 +14,7 @@ var evals = require('@mastra/core/evals');
14
14
 
15
15
  // package.json
16
16
  var package_default = {
17
- version: "1.8.1"};
17
+ version: "1.9.0-alpha.0"};
18
18
  var MongoDBFilterTranslator = class extends filter.BaseFilterTranslator {
19
19
  getSupportedOperators() {
20
20
  return {
@@ -922,7 +922,8 @@ var SNAPSHOT_FIELDS = [
922
922
  "requestContextSchema",
923
923
  "workspace",
924
924
  "skills",
925
- "skillsFormat"
925
+ "skillsFormat",
926
+ "browser"
926
927
  ];
927
928
  var MongoDBAgentsStorage = class _MongoDBAgentsStorage extends storage.AgentsStorage {
928
929
  #connector;
@@ -1065,17 +1066,20 @@ var MongoDBAgentsStorage = class _MongoDBAgentsStorage extends storage.AgentsSto
1065
1066
  });
1066
1067
  }
1067
1068
  const now = /* @__PURE__ */ new Date();
1069
+ const visibility = agent.visibility ?? (agent.authorId ? "private" : void 0);
1068
1070
  const newAgent = {
1069
1071
  id: agent.id,
1070
1072
  status: "draft",
1071
1073
  activeVersionId: void 0,
1072
1074
  authorId: agent.authorId,
1075
+ visibility,
1073
1076
  metadata: agent.metadata,
1077
+ favoriteCount: 0,
1074
1078
  createdAt: now,
1075
1079
  updatedAt: now
1076
1080
  };
1077
1081
  await collection.insertOne(this.serializeAgent(newAgent));
1078
- const { id: _id, authorId: _authorId, metadata: _metadata, ...snapshotConfig } = agent;
1082
+ const { id: _id, authorId: _authorId, visibility: _visibility, metadata: _metadata, ...snapshotConfig } = agent;
1079
1083
  const versionId = crypto$1.randomUUID();
1080
1084
  await this.createVersion({
1081
1085
  id: versionId,
@@ -1121,6 +1125,7 @@ var MongoDBAgentsStorage = class _MongoDBAgentsStorage extends storage.AgentsSto
1121
1125
  const metadataFields = {
1122
1126
  authorId: updates.authorId,
1123
1127
  activeVersionId: updates.activeVersionId,
1128
+ visibility: updates.visibility,
1124
1129
  metadata: updates.metadata,
1125
1130
  status: updates.status
1126
1131
  };
@@ -1128,6 +1133,9 @@ var MongoDBAgentsStorage = class _MongoDBAgentsStorage extends storage.AgentsSto
1128
1133
  if (metadataFields.activeVersionId !== void 0) {
1129
1134
  updateDoc.activeVersionId = metadataFields.activeVersionId;
1130
1135
  }
1136
+ if (metadataFields.visibility !== void 0) {
1137
+ updateDoc.visibility = metadataFields.visibility;
1138
+ }
1131
1139
  if (metadataFields.status !== void 0) {
1132
1140
  updateDoc.status = metadataFields.status;
1133
1141
  }
@@ -1181,7 +1189,7 @@ var MongoDBAgentsStorage = class _MongoDBAgentsStorage extends storage.AgentsSto
1181
1189
  }
1182
1190
  async list(args) {
1183
1191
  try {
1184
- const { page = 0, perPage: perPageInput, orderBy, authorId, metadata, status } = args || {};
1192
+ const { page = 0, perPage: perPageInput, orderBy, authorId, visibility, metadata, status } = args || {};
1185
1193
  const { field, direction } = this.parseOrderBy(orderBy);
1186
1194
  if (page < 0) {
1187
1195
  throw new error.MastraError(
@@ -1204,6 +1212,9 @@ var MongoDBAgentsStorage = class _MongoDBAgentsStorage extends storage.AgentsSto
1204
1212
  if (authorId) {
1205
1213
  filter.authorId = authorId;
1206
1214
  }
1215
+ if (visibility) {
1216
+ filter.visibility = visibility;
1217
+ }
1207
1218
  if (metadata) {
1208
1219
  for (const [key, value] of Object.entries(metadata)) {
1209
1220
  filter[`metadata.${key}`] = value;
@@ -1258,7 +1269,9 @@ var MongoDBAgentsStorage = class _MongoDBAgentsStorage extends storage.AgentsSto
1258
1269
  status: rest.status,
1259
1270
  activeVersionId: rest.activeVersionId,
1260
1271
  authorId: rest.authorId,
1272
+ visibility: rest.visibility ?? void 0,
1261
1273
  metadata: rest.metadata,
1274
+ favoriteCount: rest.favoriteCount === null || rest.favoriteCount === void 0 ? 0 : Number(rest.favoriteCount),
1262
1275
  createdAt: rest.createdAt instanceof Date ? rest.createdAt : new Date(rest.createdAt),
1263
1276
  updatedAt: rest.updatedAt instanceof Date ? rest.updatedAt : new Date(rest.updatedAt)
1264
1277
  };
@@ -1273,7 +1286,9 @@ var MongoDBAgentsStorage = class _MongoDBAgentsStorage extends storage.AgentsSto
1273
1286
  status: agent.status,
1274
1287
  activeVersionId: agent.activeVersionId,
1275
1288
  authorId: agent.authorId,
1289
+ visibility: agent.visibility,
1276
1290
  metadata: agent.metadata,
1291
+ favoriteCount: agent.favoriteCount,
1277
1292
  createdAt: agent.createdAt,
1278
1293
  updatedAt: agent.updatedAt
1279
1294
  };
@@ -8751,6 +8766,7 @@ var SNAPSHOT_FIELDS6 = [
8751
8766
  "references",
8752
8767
  "scripts",
8753
8768
  "assets",
8769
+ "files",
8754
8770
  "metadata",
8755
8771
  "tree"
8756
8772
  ];
@@ -8860,11 +8876,13 @@ var MongoDBSkillsStorage = class _MongoDBSkillsStorage extends storage.SkillsSto
8860
8876
  });
8861
8877
  }
8862
8878
  const now = /* @__PURE__ */ new Date();
8879
+ const visibility = skill.visibility ?? (skill.authorId ? "private" : void 0);
8863
8880
  const newSkill = {
8864
8881
  id,
8865
8882
  status: "draft",
8866
8883
  activeVersionId: void 0,
8867
8884
  authorId: skill.authorId,
8885
+ visibility,
8868
8886
  createdAt: now,
8869
8887
  updatedAt: now
8870
8888
  };
@@ -8924,6 +8942,7 @@ var MongoDBSkillsStorage = class _MongoDBSkillsStorage extends storage.SkillsSto
8924
8942
  };
8925
8943
  const metadataFields = {
8926
8944
  authorId: updates.authorId,
8945
+ visibility: updates.visibility,
8927
8946
  activeVersionId: updates.activeVersionId,
8928
8947
  status: updates.status
8929
8948
  };
@@ -8956,6 +8975,7 @@ var MongoDBSkillsStorage = class _MongoDBSkillsStorage extends storage.SkillsSto
8956
8975
  });
8957
8976
  }
8958
8977
  if (metadataFields.authorId !== void 0) updateDoc.authorId = metadataFields.authorId;
8978
+ if (metadataFields.visibility !== void 0) updateDoc.visibility = metadataFields.visibility;
8959
8979
  if (metadataFields.activeVersionId !== void 0) {
8960
8980
  updateDoc.activeVersionId = metadataFields.activeVersionId;
8961
8981
  if (metadataFields.status === void 0) {
@@ -9011,7 +9031,7 @@ var MongoDBSkillsStorage = class _MongoDBSkillsStorage extends storage.SkillsSto
9011
9031
  }
9012
9032
  async list(args) {
9013
9033
  try {
9014
- const { page = 0, perPage: perPageInput, orderBy, authorId, metadata } = args || {};
9034
+ const { page = 0, perPage: perPageInput, orderBy, authorId, visibility, metadata } = args || {};
9015
9035
  const { field, direction } = this.parseOrderBy(orderBy);
9016
9036
  if (page < 0) {
9017
9037
  throw new error.MastraError(
@@ -9031,6 +9051,9 @@ var MongoDBSkillsStorage = class _MongoDBSkillsStorage extends storage.SkillsSto
9031
9051
  if (authorId) {
9032
9052
  filter.authorId = authorId;
9033
9053
  }
9054
+ if (visibility) {
9055
+ filter.visibility = visibility;
9056
+ }
9034
9057
  if (metadata) {
9035
9058
  for (const [key, value] of Object.entries(metadata)) {
9036
9059
  filter[`metadata.${key}`] = value;
@@ -9283,6 +9306,7 @@ var MongoDBSkillsStorage = class _MongoDBSkillsStorage extends storage.SkillsSto
9283
9306
  status: rest.status,
9284
9307
  activeVersionId: rest.activeVersionId,
9285
9308
  authorId: rest.authorId,
9309
+ visibility: rest.visibility,
9286
9310
  createdAt: rest.createdAt instanceof Date ? rest.createdAt : new Date(rest.createdAt),
9287
9311
  updatedAt: rest.updatedAt instanceof Date ? rest.updatedAt : new Date(rest.updatedAt)
9288
9312
  };
@@ -9293,6 +9317,7 @@ var MongoDBSkillsStorage = class _MongoDBSkillsStorage extends storage.SkillsSto
9293
9317
  status: skill.status,
9294
9318
  activeVersionId: skill.activeVersionId,
9295
9319
  authorId: skill.authorId,
9320
+ visibility: skill.visibility,
9296
9321
  createdAt: skill.createdAt,
9297
9322
  updatedAt: skill.updatedAt
9298
9323
  };