@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/dist/index.js CHANGED
@@ -12,7 +12,7 @@ import { saveScorePayloadSchema } from '@mastra/core/evals';
12
12
 
13
13
  // package.json
14
14
  var package_default = {
15
- version: "1.8.1"};
15
+ version: "1.9.0-alpha.0"};
16
16
  var MongoDBFilterTranslator = class extends BaseFilterTranslator {
17
17
  getSupportedOperators() {
18
18
  return {
@@ -920,7 +920,8 @@ var SNAPSHOT_FIELDS = [
920
920
  "requestContextSchema",
921
921
  "workspace",
922
922
  "skills",
923
- "skillsFormat"
923
+ "skillsFormat",
924
+ "browser"
924
925
  ];
925
926
  var MongoDBAgentsStorage = class _MongoDBAgentsStorage extends AgentsStorage {
926
927
  #connector;
@@ -1063,17 +1064,20 @@ var MongoDBAgentsStorage = class _MongoDBAgentsStorage extends AgentsStorage {
1063
1064
  });
1064
1065
  }
1065
1066
  const now = /* @__PURE__ */ new Date();
1067
+ const visibility = agent.visibility ?? (agent.authorId ? "private" : void 0);
1066
1068
  const newAgent = {
1067
1069
  id: agent.id,
1068
1070
  status: "draft",
1069
1071
  activeVersionId: void 0,
1070
1072
  authorId: agent.authorId,
1073
+ visibility,
1071
1074
  metadata: agent.metadata,
1075
+ favoriteCount: 0,
1072
1076
  createdAt: now,
1073
1077
  updatedAt: now
1074
1078
  };
1075
1079
  await collection.insertOne(this.serializeAgent(newAgent));
1076
- const { id: _id, authorId: _authorId, metadata: _metadata, ...snapshotConfig } = agent;
1080
+ const { id: _id, authorId: _authorId, visibility: _visibility, metadata: _metadata, ...snapshotConfig } = agent;
1077
1081
  const versionId = randomUUID();
1078
1082
  await this.createVersion({
1079
1083
  id: versionId,
@@ -1119,6 +1123,7 @@ var MongoDBAgentsStorage = class _MongoDBAgentsStorage extends AgentsStorage {
1119
1123
  const metadataFields = {
1120
1124
  authorId: updates.authorId,
1121
1125
  activeVersionId: updates.activeVersionId,
1126
+ visibility: updates.visibility,
1122
1127
  metadata: updates.metadata,
1123
1128
  status: updates.status
1124
1129
  };
@@ -1126,6 +1131,9 @@ var MongoDBAgentsStorage = class _MongoDBAgentsStorage extends AgentsStorage {
1126
1131
  if (metadataFields.activeVersionId !== void 0) {
1127
1132
  updateDoc.activeVersionId = metadataFields.activeVersionId;
1128
1133
  }
1134
+ if (metadataFields.visibility !== void 0) {
1135
+ updateDoc.visibility = metadataFields.visibility;
1136
+ }
1129
1137
  if (metadataFields.status !== void 0) {
1130
1138
  updateDoc.status = metadataFields.status;
1131
1139
  }
@@ -1179,7 +1187,7 @@ var MongoDBAgentsStorage = class _MongoDBAgentsStorage extends AgentsStorage {
1179
1187
  }
1180
1188
  async list(args) {
1181
1189
  try {
1182
- const { page = 0, perPage: perPageInput, orderBy, authorId, metadata, status } = args || {};
1190
+ const { page = 0, perPage: perPageInput, orderBy, authorId, visibility, metadata, status } = args || {};
1183
1191
  const { field, direction } = this.parseOrderBy(orderBy);
1184
1192
  if (page < 0) {
1185
1193
  throw new MastraError(
@@ -1202,6 +1210,9 @@ var MongoDBAgentsStorage = class _MongoDBAgentsStorage extends AgentsStorage {
1202
1210
  if (authorId) {
1203
1211
  filter.authorId = authorId;
1204
1212
  }
1213
+ if (visibility) {
1214
+ filter.visibility = visibility;
1215
+ }
1205
1216
  if (metadata) {
1206
1217
  for (const [key, value] of Object.entries(metadata)) {
1207
1218
  filter[`metadata.${key}`] = value;
@@ -1256,7 +1267,9 @@ var MongoDBAgentsStorage = class _MongoDBAgentsStorage extends AgentsStorage {
1256
1267
  status: rest.status,
1257
1268
  activeVersionId: rest.activeVersionId,
1258
1269
  authorId: rest.authorId,
1270
+ visibility: rest.visibility ?? void 0,
1259
1271
  metadata: rest.metadata,
1272
+ favoriteCount: rest.favoriteCount === null || rest.favoriteCount === void 0 ? 0 : Number(rest.favoriteCount),
1260
1273
  createdAt: rest.createdAt instanceof Date ? rest.createdAt : new Date(rest.createdAt),
1261
1274
  updatedAt: rest.updatedAt instanceof Date ? rest.updatedAt : new Date(rest.updatedAt)
1262
1275
  };
@@ -1271,7 +1284,9 @@ var MongoDBAgentsStorage = class _MongoDBAgentsStorage extends AgentsStorage {
1271
1284
  status: agent.status,
1272
1285
  activeVersionId: agent.activeVersionId,
1273
1286
  authorId: agent.authorId,
1287
+ visibility: agent.visibility,
1274
1288
  metadata: agent.metadata,
1289
+ favoriteCount: agent.favoriteCount,
1275
1290
  createdAt: agent.createdAt,
1276
1291
  updatedAt: agent.updatedAt
1277
1292
  };
@@ -8749,6 +8764,7 @@ var SNAPSHOT_FIELDS6 = [
8749
8764
  "references",
8750
8765
  "scripts",
8751
8766
  "assets",
8767
+ "files",
8752
8768
  "metadata",
8753
8769
  "tree"
8754
8770
  ];
@@ -8858,11 +8874,13 @@ var MongoDBSkillsStorage = class _MongoDBSkillsStorage extends SkillsStorage {
8858
8874
  });
8859
8875
  }
8860
8876
  const now = /* @__PURE__ */ new Date();
8877
+ const visibility = skill.visibility ?? (skill.authorId ? "private" : void 0);
8861
8878
  const newSkill = {
8862
8879
  id,
8863
8880
  status: "draft",
8864
8881
  activeVersionId: void 0,
8865
8882
  authorId: skill.authorId,
8883
+ visibility,
8866
8884
  createdAt: now,
8867
8885
  updatedAt: now
8868
8886
  };
@@ -8922,6 +8940,7 @@ var MongoDBSkillsStorage = class _MongoDBSkillsStorage extends SkillsStorage {
8922
8940
  };
8923
8941
  const metadataFields = {
8924
8942
  authorId: updates.authorId,
8943
+ visibility: updates.visibility,
8925
8944
  activeVersionId: updates.activeVersionId,
8926
8945
  status: updates.status
8927
8946
  };
@@ -8954,6 +8973,7 @@ var MongoDBSkillsStorage = class _MongoDBSkillsStorage extends SkillsStorage {
8954
8973
  });
8955
8974
  }
8956
8975
  if (metadataFields.authorId !== void 0) updateDoc.authorId = metadataFields.authorId;
8976
+ if (metadataFields.visibility !== void 0) updateDoc.visibility = metadataFields.visibility;
8957
8977
  if (metadataFields.activeVersionId !== void 0) {
8958
8978
  updateDoc.activeVersionId = metadataFields.activeVersionId;
8959
8979
  if (metadataFields.status === void 0) {
@@ -9009,7 +9029,7 @@ var MongoDBSkillsStorage = class _MongoDBSkillsStorage extends SkillsStorage {
9009
9029
  }
9010
9030
  async list(args) {
9011
9031
  try {
9012
- const { page = 0, perPage: perPageInput, orderBy, authorId, metadata } = args || {};
9032
+ const { page = 0, perPage: perPageInput, orderBy, authorId, visibility, metadata } = args || {};
9013
9033
  const { field, direction } = this.parseOrderBy(orderBy);
9014
9034
  if (page < 0) {
9015
9035
  throw new MastraError(
@@ -9029,6 +9049,9 @@ var MongoDBSkillsStorage = class _MongoDBSkillsStorage extends SkillsStorage {
9029
9049
  if (authorId) {
9030
9050
  filter.authorId = authorId;
9031
9051
  }
9052
+ if (visibility) {
9053
+ filter.visibility = visibility;
9054
+ }
9032
9055
  if (metadata) {
9033
9056
  for (const [key, value] of Object.entries(metadata)) {
9034
9057
  filter[`metadata.${key}`] = value;
@@ -9281,6 +9304,7 @@ var MongoDBSkillsStorage = class _MongoDBSkillsStorage extends SkillsStorage {
9281
9304
  status: rest.status,
9282
9305
  activeVersionId: rest.activeVersionId,
9283
9306
  authorId: rest.authorId,
9307
+ visibility: rest.visibility,
9284
9308
  createdAt: rest.createdAt instanceof Date ? rest.createdAt : new Date(rest.createdAt),
9285
9309
  updatedAt: rest.updatedAt instanceof Date ? rest.updatedAt : new Date(rest.updatedAt)
9286
9310
  };
@@ -9291,6 +9315,7 @@ var MongoDBSkillsStorage = class _MongoDBSkillsStorage extends SkillsStorage {
9291
9315
  status: skill.status,
9292
9316
  activeVersionId: skill.activeVersionId,
9293
9317
  authorId: skill.authorId,
9318
+ visibility: skill.visibility,
9294
9319
  createdAt: skill.createdAt,
9295
9320
  updatedAt: skill.updatedAt
9296
9321
  };