@mastra/mongodb 1.16.0-alpha.0 → 1.16.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.
- package/CHANGELOG.md +25 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/index.cjs +6 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/memory/index.d.ts.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -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.16.0-alpha.
|
|
12
|
+
var version = "1.16.0-alpha.1";
|
|
13
13
|
//#endregion
|
|
14
14
|
//#region src/vector/filter.ts
|
|
15
15
|
/**
|
|
@@ -5328,11 +5328,15 @@ var MemoryStorageMongoDB = class MemoryStorageMongoDB extends MemoryStorage {
|
|
|
5328
5328
|
for (const indexDef of this.getDefaultIndexDefinitions()) try {
|
|
5329
5329
|
await (await this.getCollection(indexDef.collection)).createIndex(indexDef.keys, indexDef.options);
|
|
5330
5330
|
} catch (error) {
|
|
5331
|
+
const isUniqueConflict = error?.code === 85 && indexDef.options?.unique === true;
|
|
5332
|
+
const field = Object.keys(indexDef.keys)[0] ?? "id";
|
|
5333
|
+
const indexName = Object.entries(indexDef.keys).map(([k, v]) => `${k}_${v}`).join("_");
|
|
5334
|
+
const text = isUniqueConflict ? `Index conflict on collection "${indexDef.collection}": an existing non-unique index on { ${field}: 1 } conflicts with Mastra's required unique index.\n\nTo migrate:\n 1. Check for duplicates: db.${indexDef.collection}.aggregate([{ $group: { _id: "$${field}", n: { $sum: 1 } } }, { $match: { n: { $gt: 1 } } }])\n 2. Drop the old index: db.${indexDef.collection}.dropIndex("${indexName}")\n 3. Recreate as unique: db.${indexDef.collection}.createIndex({ ${field}: 1 }, { unique: true })\n\nAlternatively, set skipDefaultIndexes: true to manage indexes yourself.` : `Failed to create default index on collection "${indexDef.collection}". Set skipDefaultIndexes to manage indexes yourself.`;
|
|
5331
5335
|
throw new MastraError({
|
|
5332
5336
|
id: createStorageErrorId("MONGODB", "CREATE_DEFAULT_INDEXES", "FAILED"),
|
|
5333
5337
|
domain: ErrorDomain.STORAGE,
|
|
5334
5338
|
category: ErrorCategory.THIRD_PARTY,
|
|
5335
|
-
text
|
|
5339
|
+
text,
|
|
5336
5340
|
details: { collection: indexDef.collection }
|
|
5337
5341
|
}, error);
|
|
5338
5342
|
}
|