@mastra/mongodb 0.12.3-alpha.0 → 0.12.3-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/.turbo/turbo-build.log +7 -7
- package/CHANGELOG.md +26 -0
- package/dist/_tsup-dts-rollup.d.cts +2 -0
- package/dist/_tsup-dts-rollup.d.ts +2 -0
- package/dist/index.cjs +17 -12
- package/dist/index.js +17 -12
- package/package.json +5 -5
- package/src/storage/domains/memory/index.ts +1 -1
- package/src/storage/domains/operations/index.ts +16 -13
- package/src/storage/index.ts +2 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
|
|
2
|
-
> @mastra/mongodb@0.12.3-alpha.
|
|
2
|
+
> @mastra/mongodb@0.12.3-alpha.2 build /home/runner/work/mastra/mastra/stores/mongodb
|
|
3
3
|
> tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: src/index.ts
|
|
6
6
|
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
7
7
|
[34mCLI[39m tsup v8.5.0
|
|
8
8
|
[34mTSC[39m Build start
|
|
9
|
-
[32mTSC[39m ⚡️ Build success in
|
|
9
|
+
[32mTSC[39m ⚡️ Build success in 11757ms
|
|
10
10
|
[34mDTS[39m Build start
|
|
11
11
|
[34mCLI[39m Target: es2022
|
|
12
12
|
Analysis will use the bundled TypeScript version 5.8.3
|
|
13
13
|
[36mWriting package typings: /home/runner/work/mastra/mastra/stores/mongodb/dist/_tsup-dts-rollup.d.ts[39m
|
|
14
14
|
Analysis will use the bundled TypeScript version 5.8.3
|
|
15
15
|
[36mWriting package typings: /home/runner/work/mastra/mastra/stores/mongodb/dist/_tsup-dts-rollup.d.cts[39m
|
|
16
|
-
[32mDTS[39m ⚡️ Build success in
|
|
16
|
+
[32mDTS[39m ⚡️ Build success in 13349ms
|
|
17
17
|
[34mCLI[39m Cleaning output folder
|
|
18
18
|
[34mESM[39m Build start
|
|
19
19
|
[34mCJS[39m Build start
|
|
20
|
-
[
|
|
21
|
-
[
|
|
22
|
-
[
|
|
23
|
-
[
|
|
20
|
+
[32mESM[39m [1mdist/index.js [22m[32m73.39 KB[39m
|
|
21
|
+
[32mESM[39m ⚡️ Build success in 1653ms
|
|
22
|
+
[32mCJS[39m [1mdist/index.cjs [22m[32m74.73 KB[39m
|
|
23
|
+
[32mCJS[39m ⚡️ Build success in 1644ms
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# @mastra/mongodb
|
|
2
2
|
|
|
3
|
+
## 0.12.3-alpha.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- f42c4c2: update peer deps for packages to latest core range
|
|
8
|
+
- @mastra/core@0.12.0-alpha.5
|
|
9
|
+
|
|
10
|
+
## 0.12.3-alpha.1
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- 9881232: dependencies updates:
|
|
15
|
+
- Updated dependency [`cloudflare@^4.5.0` ↗︎](https://www.npmjs.com/package/cloudflare/v/4.5.0) (from `^4.4.1`, in `dependencies`)
|
|
16
|
+
- eba48c8: Sort getThreads by updatedAt.
|
|
17
|
+
- 14456f3: fix: [MongoDB] batchInsert with process json
|
|
18
|
+
- Updated dependencies [27cc97a]
|
|
19
|
+
- Updated dependencies [41daa63]
|
|
20
|
+
- Updated dependencies [254a36b]
|
|
21
|
+
- Updated dependencies [0b89602]
|
|
22
|
+
- Updated dependencies [4d37822]
|
|
23
|
+
- Updated dependencies [ff9c125]
|
|
24
|
+
- Updated dependencies [b8efbb9]
|
|
25
|
+
- Updated dependencies [71466e7]
|
|
26
|
+
- Updated dependencies [0c99fbe]
|
|
27
|
+
- @mastra/core@0.12.0-alpha.2
|
|
28
|
+
|
|
3
29
|
## 0.12.3-alpha.0
|
|
4
30
|
|
|
5
31
|
### Patch Changes
|
|
@@ -254,6 +254,7 @@ declare class MongoDBStore extends MastraStorage {
|
|
|
254
254
|
resourceWorkingMemory: boolean;
|
|
255
255
|
hasColumn: boolean;
|
|
256
256
|
createTable: boolean;
|
|
257
|
+
deleteMessages: boolean;
|
|
257
258
|
};
|
|
258
259
|
constructor(config: MongoDBConfig);
|
|
259
260
|
createTable({ tableName, schema, }: {
|
|
@@ -543,6 +544,7 @@ export declare class StoreOperationsMongoDB extends StoreOperations {
|
|
|
543
544
|
dropTable({ tableName }: {
|
|
544
545
|
tableName: TABLE_NAMES;
|
|
545
546
|
}): Promise<void>;
|
|
547
|
+
private processJsonbFields;
|
|
546
548
|
insert({ tableName, record }: {
|
|
547
549
|
tableName: TABLE_NAMES;
|
|
548
550
|
record: Record<string, any>;
|
|
@@ -254,6 +254,7 @@ declare class MongoDBStore extends MastraStorage {
|
|
|
254
254
|
resourceWorkingMemory: boolean;
|
|
255
255
|
hasColumn: boolean;
|
|
256
256
|
createTable: boolean;
|
|
257
|
+
deleteMessages: boolean;
|
|
257
258
|
};
|
|
258
259
|
constructor(config: MongoDBConfig);
|
|
259
260
|
createTable({ tableName, schema, }: {
|
|
@@ -543,6 +544,7 @@ export declare class StoreOperationsMongoDB extends StoreOperations {
|
|
|
543
544
|
dropTable({ tableName }: {
|
|
544
545
|
tableName: TABLE_NAMES;
|
|
545
546
|
}): Promise<void>;
|
|
547
|
+
private processJsonbFields;
|
|
546
548
|
insert({ tableName, record }: {
|
|
547
549
|
tableName: TABLE_NAMES;
|
|
548
550
|
record: Record<string, any>;
|
package/dist/index.cjs
CHANGED
|
@@ -1213,7 +1213,7 @@ var MemoryStorageMongoDB = class extends storage.MemoryStorage {
|
|
|
1213
1213
|
async getThreadsByResourceId({ resourceId }) {
|
|
1214
1214
|
try {
|
|
1215
1215
|
const collection = await this.operations.getCollection(storage.TABLE_THREADS);
|
|
1216
|
-
const results = await collection.find({ resourceId }).toArray();
|
|
1216
|
+
const results = await collection.find({ resourceId }).sort({ updatedAt: -1 }).toArray();
|
|
1217
1217
|
if (!results.length) {
|
|
1218
1218
|
return [];
|
|
1219
1219
|
}
|
|
@@ -1413,18 +1413,21 @@ var StoreOperationsMongoDB = class extends storage.StoreOperations {
|
|
|
1413
1413
|
);
|
|
1414
1414
|
}
|
|
1415
1415
|
}
|
|
1416
|
+
processJsonbFields(tableName, record) {
|
|
1417
|
+
const schema = storage.TABLE_SCHEMAS[tableName];
|
|
1418
|
+
return Object.fromEntries(
|
|
1419
|
+
Object.entries(schema).map(([key, value]) => {
|
|
1420
|
+
if (value.type === "jsonb" && record[key] && typeof record[key] === "string") {
|
|
1421
|
+
return [key, storage.safelyParseJSON(record[key])];
|
|
1422
|
+
}
|
|
1423
|
+
return [key, record[key]];
|
|
1424
|
+
})
|
|
1425
|
+
);
|
|
1426
|
+
}
|
|
1416
1427
|
async insert({ tableName, record }) {
|
|
1417
1428
|
try {
|
|
1418
1429
|
const collection = await this.getCollection(tableName);
|
|
1419
|
-
const
|
|
1420
|
-
const recordToInsert = Object.fromEntries(
|
|
1421
|
-
Object.entries(schema).map(([key, value]) => {
|
|
1422
|
-
if (value.type === "jsonb" && record[key] && typeof record[key] === "string") {
|
|
1423
|
-
return [key, storage.safelyParseJSON(record[key])];
|
|
1424
|
-
}
|
|
1425
|
-
return [key, record[key]];
|
|
1426
|
-
})
|
|
1427
|
-
);
|
|
1430
|
+
const recordToInsert = this.processJsonbFields(tableName, record);
|
|
1428
1431
|
await collection.insertOne(recordToInsert);
|
|
1429
1432
|
} catch (error$1) {
|
|
1430
1433
|
if (error$1 instanceof Error) {
|
|
@@ -1448,7 +1451,8 @@ var StoreOperationsMongoDB = class extends storage.StoreOperations {
|
|
|
1448
1451
|
}
|
|
1449
1452
|
try {
|
|
1450
1453
|
const collection = await this.getCollection(tableName);
|
|
1451
|
-
|
|
1454
|
+
const processedRecords = records.map((record) => this.processJsonbFields(tableName, record));
|
|
1455
|
+
await collection.insertMany(processedRecords);
|
|
1452
1456
|
} catch (error$1) {
|
|
1453
1457
|
throw new error.MastraError(
|
|
1454
1458
|
{
|
|
@@ -2098,7 +2102,8 @@ var MongoDBStore = class extends storage.MastraStorage {
|
|
|
2098
2102
|
selectByIncludeResourceScope: true,
|
|
2099
2103
|
resourceWorkingMemory: true,
|
|
2100
2104
|
hasColumn: false,
|
|
2101
|
-
createTable: false
|
|
2105
|
+
createTable: false,
|
|
2106
|
+
deleteMessages: false
|
|
2102
2107
|
};
|
|
2103
2108
|
}
|
|
2104
2109
|
constructor(config) {
|
package/dist/index.js
CHANGED
|
@@ -1211,7 +1211,7 @@ var MemoryStorageMongoDB = class extends MemoryStorage {
|
|
|
1211
1211
|
async getThreadsByResourceId({ resourceId }) {
|
|
1212
1212
|
try {
|
|
1213
1213
|
const collection = await this.operations.getCollection(TABLE_THREADS);
|
|
1214
|
-
const results = await collection.find({ resourceId }).toArray();
|
|
1214
|
+
const results = await collection.find({ resourceId }).sort({ updatedAt: -1 }).toArray();
|
|
1215
1215
|
if (!results.length) {
|
|
1216
1216
|
return [];
|
|
1217
1217
|
}
|
|
@@ -1411,18 +1411,21 @@ var StoreOperationsMongoDB = class extends StoreOperations {
|
|
|
1411
1411
|
);
|
|
1412
1412
|
}
|
|
1413
1413
|
}
|
|
1414
|
+
processJsonbFields(tableName, record) {
|
|
1415
|
+
const schema = TABLE_SCHEMAS[tableName];
|
|
1416
|
+
return Object.fromEntries(
|
|
1417
|
+
Object.entries(schema).map(([key, value]) => {
|
|
1418
|
+
if (value.type === "jsonb" && record[key] && typeof record[key] === "string") {
|
|
1419
|
+
return [key, safelyParseJSON(record[key])];
|
|
1420
|
+
}
|
|
1421
|
+
return [key, record[key]];
|
|
1422
|
+
})
|
|
1423
|
+
);
|
|
1424
|
+
}
|
|
1414
1425
|
async insert({ tableName, record }) {
|
|
1415
1426
|
try {
|
|
1416
1427
|
const collection = await this.getCollection(tableName);
|
|
1417
|
-
const
|
|
1418
|
-
const recordToInsert = Object.fromEntries(
|
|
1419
|
-
Object.entries(schema).map(([key, value]) => {
|
|
1420
|
-
if (value.type === "jsonb" && record[key] && typeof record[key] === "string") {
|
|
1421
|
-
return [key, safelyParseJSON(record[key])];
|
|
1422
|
-
}
|
|
1423
|
-
return [key, record[key]];
|
|
1424
|
-
})
|
|
1425
|
-
);
|
|
1428
|
+
const recordToInsert = this.processJsonbFields(tableName, record);
|
|
1426
1429
|
await collection.insertOne(recordToInsert);
|
|
1427
1430
|
} catch (error) {
|
|
1428
1431
|
if (error instanceof Error) {
|
|
@@ -1446,7 +1449,8 @@ var StoreOperationsMongoDB = class extends StoreOperations {
|
|
|
1446
1449
|
}
|
|
1447
1450
|
try {
|
|
1448
1451
|
const collection = await this.getCollection(tableName);
|
|
1449
|
-
|
|
1452
|
+
const processedRecords = records.map((record) => this.processJsonbFields(tableName, record));
|
|
1453
|
+
await collection.insertMany(processedRecords);
|
|
1450
1454
|
} catch (error) {
|
|
1451
1455
|
throw new MastraError(
|
|
1452
1456
|
{
|
|
@@ -2096,7 +2100,8 @@ var MongoDBStore = class extends MastraStorage {
|
|
|
2096
2100
|
selectByIncludeResourceScope: true,
|
|
2097
2101
|
resourceWorkingMemory: true,
|
|
2098
2102
|
hasColumn: false,
|
|
2099
|
-
createTable: false
|
|
2103
|
+
createTable: false,
|
|
2104
|
+
deleteMessages: false
|
|
2100
2105
|
};
|
|
2101
2106
|
}
|
|
2102
2107
|
constructor(config) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/mongodb",
|
|
3
|
-
"version": "0.12.3-alpha.
|
|
3
|
+
"version": "0.12.3-alpha.2",
|
|
4
4
|
"description": "MongoDB provider for Mastra - includes vector store capabilities",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@types/mongodb": "^4.0.7",
|
|
23
|
-
"cloudflare": "^4.
|
|
23
|
+
"cloudflare": "^4.5.0",
|
|
24
24
|
"mongodb": "^6.17.0",
|
|
25
25
|
"uuid": "^11.1.0"
|
|
26
26
|
},
|
|
@@ -32,11 +32,11 @@
|
|
|
32
32
|
"typescript": "^5.8.3",
|
|
33
33
|
"vitest": "^3.2.4",
|
|
34
34
|
"@internal/lint": "0.0.23",
|
|
35
|
-
"@
|
|
36
|
-
"@
|
|
35
|
+
"@mastra/core": "0.12.0-alpha.5",
|
|
36
|
+
"@internal/storage-test-utils": "0.0.19"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
|
-
"@mastra/core": ">=0.10.7-0 <0.
|
|
39
|
+
"@mastra/core": ">=0.10.7-0 <0.13.0-0"
|
|
40
40
|
},
|
|
41
41
|
"scripts": {
|
|
42
42
|
"build": "tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting",
|
|
@@ -568,7 +568,7 @@ export class MemoryStorageMongoDB extends MemoryStorage {
|
|
|
568
568
|
async getThreadsByResourceId({ resourceId }: { resourceId: string }): Promise<StorageThreadType[]> {
|
|
569
569
|
try {
|
|
570
570
|
const collection = await this.operations.getCollection(TABLE_THREADS);
|
|
571
|
-
const results = await collection.find<any>({ resourceId }).toArray();
|
|
571
|
+
const results = await collection.find<any>({ resourceId }).sort({ updatedAt: -1 }).toArray();
|
|
572
572
|
if (!results.length) {
|
|
573
573
|
return [];
|
|
574
574
|
}
|
|
@@ -78,21 +78,23 @@ export class StoreOperationsMongoDB extends StoreOperations {
|
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
+
private processJsonbFields(tableName: TABLE_NAMES, record: Record<string, any>): Record<string, any> {
|
|
82
|
+
const schema = TABLE_SCHEMAS[tableName];
|
|
83
|
+
|
|
84
|
+
return Object.fromEntries(
|
|
85
|
+
Object.entries(schema).map(([key, value]) => {
|
|
86
|
+
if (value.type === 'jsonb' && record[key] && typeof record[key] === 'string') {
|
|
87
|
+
return [key, safelyParseJSON(record[key])];
|
|
88
|
+
}
|
|
89
|
+
return [key, record[key]];
|
|
90
|
+
}),
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
|
|
81
94
|
async insert({ tableName, record }: { tableName: TABLE_NAMES; record: Record<string, any> }): Promise<void> {
|
|
82
95
|
try {
|
|
83
96
|
const collection = await this.getCollection(tableName);
|
|
84
|
-
|
|
85
|
-
const schema = TABLE_SCHEMAS[tableName];
|
|
86
|
-
|
|
87
|
-
const recordToInsert = Object.fromEntries(
|
|
88
|
-
Object.entries(schema).map(([key, value]) => {
|
|
89
|
-
if (value.type === 'jsonb' && record[key] && typeof record[key] === 'string') {
|
|
90
|
-
return [key, safelyParseJSON(record[key])];
|
|
91
|
-
}
|
|
92
|
-
return [key, record[key]];
|
|
93
|
-
}),
|
|
94
|
-
);
|
|
95
|
-
|
|
97
|
+
const recordToInsert = this.processJsonbFields(tableName, record);
|
|
96
98
|
await collection.insertOne(recordToInsert);
|
|
97
99
|
} catch (error) {
|
|
98
100
|
if (error instanceof Error) {
|
|
@@ -118,7 +120,8 @@ export class StoreOperationsMongoDB extends StoreOperations {
|
|
|
118
120
|
|
|
119
121
|
try {
|
|
120
122
|
const collection = await this.getCollection(tableName);
|
|
121
|
-
|
|
123
|
+
const processedRecords = records.map(record => this.processJsonbFields(tableName, record));
|
|
124
|
+
await collection.insertMany(processedRecords);
|
|
122
125
|
} catch (error) {
|
|
123
126
|
throw new MastraError(
|
|
124
127
|
{
|
package/src/storage/index.ts
CHANGED
|
@@ -75,12 +75,14 @@ export class MongoDBStore extends MastraStorage {
|
|
|
75
75
|
resourceWorkingMemory: boolean;
|
|
76
76
|
hasColumn: boolean;
|
|
77
77
|
createTable: boolean;
|
|
78
|
+
deleteMessages: boolean;
|
|
78
79
|
} {
|
|
79
80
|
return {
|
|
80
81
|
selectByIncludeResourceScope: true,
|
|
81
82
|
resourceWorkingMemory: true,
|
|
82
83
|
hasColumn: false,
|
|
83
84
|
createTable: false,
|
|
85
|
+
deleteMessages: false,
|
|
84
86
|
};
|
|
85
87
|
}
|
|
86
88
|
|