@mastra/mongodb 1.0.0-beta.12 → 1.0.0-beta.13
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 +46 -0
- package/dist/docs/README.md +1 -1
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/SOURCE_MAP.json +1 -1
- package/dist/docs/rag/01-vector-databases.md +3 -3
- package/dist/index.cjs +44 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +44 -18
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/memory/index.d.ts +2 -2
- package/dist/storage/domains/memory/index.d.ts.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,51 @@
|
|
|
1
1
|
# @mastra/mongodb
|
|
2
2
|
|
|
3
|
+
## 1.0.0-beta.13
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Added new `listThreads` method for flexible thread filtering across all storage adapters. ([#11832](https://github.com/mastra-ai/mastra/pull/11832))
|
|
8
|
+
|
|
9
|
+
**New Features**
|
|
10
|
+
- Filter threads by `resourceId`, `metadata`, or both (with AND logic for metadata key-value pairs)
|
|
11
|
+
- All filter parameters are optional, allowing you to list all threads or filter as needed
|
|
12
|
+
- Full pagination and sorting support
|
|
13
|
+
|
|
14
|
+
**Example Usage**
|
|
15
|
+
|
|
16
|
+
```typescript
|
|
17
|
+
// List all threads
|
|
18
|
+
const allThreads = await memory.listThreads({});
|
|
19
|
+
|
|
20
|
+
// Filter by resourceId only
|
|
21
|
+
const userThreads = await memory.listThreads({
|
|
22
|
+
filter: { resourceId: 'user-123' },
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
// Filter by metadata only
|
|
26
|
+
const supportThreads = await memory.listThreads({
|
|
27
|
+
filter: { metadata: { category: 'support' } },
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
// Filter by both with pagination
|
|
31
|
+
const filteredThreads = await memory.listThreads({
|
|
32
|
+
filter: {
|
|
33
|
+
resourceId: 'user-123',
|
|
34
|
+
metadata: { priority: 'high', status: 'open' },
|
|
35
|
+
},
|
|
36
|
+
orderBy: { field: 'updatedAt', direction: 'DESC' },
|
|
37
|
+
page: 0,
|
|
38
|
+
perPage: 20,
|
|
39
|
+
});
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
**Security Improvements**
|
|
43
|
+
- Added validation to prevent SQL injection via malicious metadata keys
|
|
44
|
+
- Added pagination parameter validation to prevent integer overflow attacks
|
|
45
|
+
|
|
46
|
+
- Updated dependencies [[`ed3e3dd`](https://github.com/mastra-ai/mastra/commit/ed3e3ddec69d564fe2b125e083437f76331f1283), [`6833c69`](https://github.com/mastra-ai/mastra/commit/6833c69607418d257750bbcdd84638993d343539), [`47b1c16`](https://github.com/mastra-ai/mastra/commit/47b1c16a01c7ffb6765fe1e499b49092f8b7eba3), [`3a76a80`](https://github.com/mastra-ai/mastra/commit/3a76a80284cb71a0faa975abb3d4b2a9631e60cd), [`8538a0d`](https://github.com/mastra-ai/mastra/commit/8538a0d232619bf55dad7ddc2a8b0ca77c679a87), [`9312dcd`](https://github.com/mastra-ai/mastra/commit/9312dcd1c6f5b321929e7d382e763d95fdc030f5)]:
|
|
47
|
+
- @mastra/core@1.0.0-beta.25
|
|
48
|
+
|
|
3
49
|
## 1.0.0-beta.12
|
|
4
50
|
|
|
5
51
|
### Minor Changes
|
package/dist/docs/README.md
CHANGED
package/dist/docs/SKILL.md
CHANGED
|
@@ -27,7 +27,7 @@ await store.upsert({
|
|
|
27
27
|
});
|
|
28
28
|
```
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
<h3>Using MongoDB Atlas Vector search</h3>
|
|
31
31
|
|
|
32
32
|
For detailed setup instructions and best practices, see the [official MongoDB Atlas Vector Search documentation](https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-overview/?utm_campaign=devrel&utm_source=third-party-content&utm_medium=cta&utm_content=mastra-docs).
|
|
33
33
|
|
|
@@ -55,7 +55,7 @@ await store.upsert({
|
|
|
55
55
|
});
|
|
56
56
|
```
|
|
57
57
|
|
|
58
|
-
|
|
58
|
+
<h3>Using PostgreSQL with pgvector</h3>
|
|
59
59
|
|
|
60
60
|
PostgreSQL with the pgvector extension is a good solution for teams already using PostgreSQL who want to minimize infrastructure complexity.
|
|
61
61
|
For detailed setup instructions and best practices, see the [official pgvector repository](https://github.com/pgvector/pgvector).
|
|
@@ -323,7 +323,7 @@ await store.upsert({
|
|
|
323
323
|
});
|
|
324
324
|
```
|
|
325
325
|
|
|
326
|
-
|
|
326
|
+
<h3>Using LanceDB</h3>
|
|
327
327
|
|
|
328
328
|
LanceDB is an embedded vector database built on the Lance columnar format, suitable for local development or cloud deployment.
|
|
329
329
|
For detailed setup instructions and best practices, see the [official LanceDB documentation](https://lancedb.github.io/lancedb/).
|
package/dist/index.cjs
CHANGED
|
@@ -13,7 +13,7 @@ var evals = require('@mastra/core/evals');
|
|
|
13
13
|
|
|
14
14
|
// package.json
|
|
15
15
|
var package_default = {
|
|
16
|
-
version: "1.0.0-beta.
|
|
16
|
+
version: "1.0.0-beta.13"};
|
|
17
17
|
var MongoDBFilterTranslator = class extends filter.BaseFilterTranslator {
|
|
18
18
|
getSupportedOperators() {
|
|
19
19
|
return {
|
|
@@ -1687,25 +1687,48 @@ var MemoryStorageMongoDB = class _MemoryStorageMongoDB extends storage.MemorySto
|
|
|
1687
1687
|
);
|
|
1688
1688
|
}
|
|
1689
1689
|
}
|
|
1690
|
-
async
|
|
1690
|
+
async listThreads(args) {
|
|
1691
|
+
const { page = 0, perPage: perPageInput, orderBy, filter } = args;
|
|
1692
|
+
try {
|
|
1693
|
+
this.validatePaginationInput(page, perPageInput ?? 100);
|
|
1694
|
+
} catch (error$1) {
|
|
1695
|
+
throw new error.MastraError(
|
|
1696
|
+
{
|
|
1697
|
+
id: storage.createStorageErrorId("MONGODB", "LIST_THREADS", "INVALID_PAGE"),
|
|
1698
|
+
domain: error.ErrorDomain.STORAGE,
|
|
1699
|
+
category: error.ErrorCategory.USER,
|
|
1700
|
+
details: { page, ...perPageInput !== void 0 && { perPage: perPageInput } }
|
|
1701
|
+
},
|
|
1702
|
+
error$1 instanceof Error ? error$1 : new Error("Invalid pagination parameters")
|
|
1703
|
+
);
|
|
1704
|
+
}
|
|
1705
|
+
const perPage = storage.normalizePerPage(perPageInput, 100);
|
|
1706
|
+
try {
|
|
1707
|
+
this.validateMetadataKeys(filter?.metadata);
|
|
1708
|
+
} catch (error$1) {
|
|
1709
|
+
throw new error.MastraError(
|
|
1710
|
+
{
|
|
1711
|
+
id: storage.createStorageErrorId("MONGODB", "LIST_THREADS", "INVALID_METADATA_KEY"),
|
|
1712
|
+
domain: error.ErrorDomain.STORAGE,
|
|
1713
|
+
category: error.ErrorCategory.USER,
|
|
1714
|
+
details: { metadataKeys: filter?.metadata ? Object.keys(filter.metadata).join(", ") : "" }
|
|
1715
|
+
},
|
|
1716
|
+
error$1 instanceof Error ? error$1 : new Error("Invalid metadata key")
|
|
1717
|
+
);
|
|
1718
|
+
}
|
|
1691
1719
|
try {
|
|
1692
|
-
const { resourceId, page = 0, perPage: perPageInput, orderBy } = args;
|
|
1693
|
-
if (page < 0) {
|
|
1694
|
-
throw new error.MastraError(
|
|
1695
|
-
{
|
|
1696
|
-
id: storage.createStorageErrorId("MONGODB", "LIST_THREADS_BY_RESOURCE_ID", "INVALID_PAGE"),
|
|
1697
|
-
domain: error.ErrorDomain.STORAGE,
|
|
1698
|
-
category: error.ErrorCategory.USER,
|
|
1699
|
-
details: { page }
|
|
1700
|
-
},
|
|
1701
|
-
new Error("page must be >= 0")
|
|
1702
|
-
);
|
|
1703
|
-
}
|
|
1704
|
-
const perPage = storage.normalizePerPage(perPageInput, 100);
|
|
1705
1720
|
const { offset, perPage: perPageForResponse } = storage.calculatePagination(page, perPageInput, perPage);
|
|
1706
1721
|
const { field, direction } = this.parseOrderBy(orderBy);
|
|
1707
1722
|
const collection = await this.getCollection(storage.TABLE_THREADS);
|
|
1708
|
-
const query = {
|
|
1723
|
+
const query = {};
|
|
1724
|
+
if (filter?.resourceId) {
|
|
1725
|
+
query.resourceId = filter.resourceId;
|
|
1726
|
+
}
|
|
1727
|
+
if (filter?.metadata && Object.keys(filter.metadata).length > 0) {
|
|
1728
|
+
for (const [key, value] of Object.entries(filter.metadata)) {
|
|
1729
|
+
query[`metadata.${key}`] = value;
|
|
1730
|
+
}
|
|
1731
|
+
}
|
|
1709
1732
|
const total = await collection.countDocuments(query);
|
|
1710
1733
|
if (perPage === 0) {
|
|
1711
1734
|
return {
|
|
@@ -1739,10 +1762,13 @@ var MemoryStorageMongoDB = class _MemoryStorageMongoDB extends storage.MemorySto
|
|
|
1739
1762
|
} catch (error$1) {
|
|
1740
1763
|
throw new error.MastraError(
|
|
1741
1764
|
{
|
|
1742
|
-
id: storage.createStorageErrorId("MONGODB", "
|
|
1765
|
+
id: storage.createStorageErrorId("MONGODB", "LIST_THREADS", "FAILED"),
|
|
1743
1766
|
domain: error.ErrorDomain.STORAGE,
|
|
1744
1767
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
1745
|
-
details: {
|
|
1768
|
+
details: {
|
|
1769
|
+
...filter?.resourceId && { resourceId: filter.resourceId },
|
|
1770
|
+
hasMetadataFilter: !!filter?.metadata
|
|
1771
|
+
}
|
|
1746
1772
|
},
|
|
1747
1773
|
error$1
|
|
1748
1774
|
);
|