@mastra/cloudflare 1.0.0-beta.11 → 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 +79 -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/index.cjs +28 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +29 -19
- 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/dist/storage/index.d.ts +2 -2
- package/dist/storage/index.d.ts.map +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,84 @@
|
|
|
1
1
|
# @mastra/cloudflare
|
|
2
2
|
|
|
3
|
+
## 1.0.0-beta.13
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Renamed MastraStorage to MastraCompositeStore for better clarity. The old MastraStorage name remains available as a deprecated alias for backward compatibility, but will be removed in a future version. ([#12093](https://github.com/mastra-ai/mastra/pull/12093))
|
|
8
|
+
|
|
9
|
+
**Migration:**
|
|
10
|
+
|
|
11
|
+
Update your imports and usage:
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
// Before
|
|
15
|
+
import { MastraStorage } from '@mastra/core/storage';
|
|
16
|
+
|
|
17
|
+
const storage = new MastraStorage({
|
|
18
|
+
id: 'composite',
|
|
19
|
+
domains: { ... }
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
// After
|
|
23
|
+
import { MastraCompositeStore } from '@mastra/core/storage';
|
|
24
|
+
|
|
25
|
+
const storage = new MastraCompositeStore({
|
|
26
|
+
id: 'composite',
|
|
27
|
+
domains: { ... }
|
|
28
|
+
});
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
The new name better reflects that this is a composite storage implementation that routes different domains (workflows, traces, messages) to different underlying stores, avoiding confusion with the general "Mastra Storage" concept.
|
|
32
|
+
|
|
33
|
+
- Updated dependencies [[`026b848`](https://github.com/mastra-ai/mastra/commit/026b8483fbf5b6d977be8f7e6aac8d15c75558ac), [`ffa553a`](https://github.com/mastra-ai/mastra/commit/ffa553a3edc1bd17d73669fba66d6b6f4ac10897)]:
|
|
34
|
+
- @mastra/core@1.0.0-beta.26
|
|
35
|
+
|
|
36
|
+
## 1.0.0-beta.12
|
|
37
|
+
|
|
38
|
+
### Patch Changes
|
|
39
|
+
|
|
40
|
+
- Added new `listThreads` method for flexible thread filtering across all storage adapters. ([#11832](https://github.com/mastra-ai/mastra/pull/11832))
|
|
41
|
+
|
|
42
|
+
**New Features**
|
|
43
|
+
- Filter threads by `resourceId`, `metadata`, or both (with AND logic for metadata key-value pairs)
|
|
44
|
+
- All filter parameters are optional, allowing you to list all threads or filter as needed
|
|
45
|
+
- Full pagination and sorting support
|
|
46
|
+
|
|
47
|
+
**Example Usage**
|
|
48
|
+
|
|
49
|
+
```typescript
|
|
50
|
+
// List all threads
|
|
51
|
+
const allThreads = await memory.listThreads({});
|
|
52
|
+
|
|
53
|
+
// Filter by resourceId only
|
|
54
|
+
const userThreads = await memory.listThreads({
|
|
55
|
+
filter: { resourceId: 'user-123' },
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
// Filter by metadata only
|
|
59
|
+
const supportThreads = await memory.listThreads({
|
|
60
|
+
filter: { metadata: { category: 'support' } },
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
// Filter by both with pagination
|
|
64
|
+
const filteredThreads = await memory.listThreads({
|
|
65
|
+
filter: {
|
|
66
|
+
resourceId: 'user-123',
|
|
67
|
+
metadata: { priority: 'high', status: 'open' },
|
|
68
|
+
},
|
|
69
|
+
orderBy: { field: 'updatedAt', direction: 'DESC' },
|
|
70
|
+
page: 0,
|
|
71
|
+
perPage: 20,
|
|
72
|
+
});
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
**Security Improvements**
|
|
76
|
+
- Added validation to prevent SQL injection via malicious metadata keys
|
|
77
|
+
- Added pagination parameter validation to prevent integer overflow attacks
|
|
78
|
+
|
|
79
|
+
- 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)]:
|
|
80
|
+
- @mastra/core@1.0.0-beta.25
|
|
81
|
+
|
|
3
82
|
## 1.0.0-beta.11
|
|
4
83
|
|
|
5
84
|
### Patch Changes
|
package/dist/docs/README.md
CHANGED
package/dist/docs/SKILL.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -620,21 +620,23 @@ var MemoryStorageCloudflare = class extends storage.MemoryStorage {
|
|
|
620
620
|
return null;
|
|
621
621
|
}
|
|
622
622
|
}
|
|
623
|
-
async
|
|
623
|
+
async listThreads(args) {
|
|
624
|
+
const { page = 0, perPage: perPageInput, orderBy, filter } = args;
|
|
625
|
+
try {
|
|
626
|
+
this.validatePaginationInput(page, perPageInput ?? 100);
|
|
627
|
+
} catch (error$1) {
|
|
628
|
+
throw new error.MastraError(
|
|
629
|
+
{
|
|
630
|
+
id: storage.createStorageErrorId("CLOUDFLARE", "LIST_THREADS", "INVALID_PAGE"),
|
|
631
|
+
domain: error.ErrorDomain.STORAGE,
|
|
632
|
+
category: error.ErrorCategory.USER,
|
|
633
|
+
details: { page, ...perPageInput !== void 0 && { perPage: perPageInput } }
|
|
634
|
+
},
|
|
635
|
+
error$1 instanceof Error ? error$1 : new Error("Invalid pagination parameters")
|
|
636
|
+
);
|
|
637
|
+
}
|
|
638
|
+
const perPage = storage.normalizePerPage(perPageInput, 100);
|
|
624
639
|
try {
|
|
625
|
-
const { resourceId, page = 0, perPage: perPageInput, orderBy } = args;
|
|
626
|
-
const perPage = storage.normalizePerPage(perPageInput, 100);
|
|
627
|
-
if (page < 0) {
|
|
628
|
-
throw new error.MastraError(
|
|
629
|
-
{
|
|
630
|
-
id: storage.createStorageErrorId("CLOUDFLARE", "LIST_THREADS_BY_RESOURCE_ID", "INVALID_PAGE"),
|
|
631
|
-
domain: error.ErrorDomain.STORAGE,
|
|
632
|
-
category: error.ErrorCategory.USER,
|
|
633
|
-
details: { page }
|
|
634
|
-
},
|
|
635
|
-
new Error("page must be >= 0")
|
|
636
|
-
);
|
|
637
|
-
}
|
|
638
640
|
const { offset, perPage: perPageForResponse } = storage.calculatePagination(page, perPageInput, perPage);
|
|
639
641
|
const { field, direction } = this.parseOrderBy(orderBy);
|
|
640
642
|
const prefix = this.#db.namespacePrefix ? `${this.#db.namespacePrefix}:` : "";
|
|
@@ -643,7 +645,15 @@ var MemoryStorageCloudflare = class extends storage.MemoryStorage {
|
|
|
643
645
|
for (const { name: key } of keyObjs) {
|
|
644
646
|
const data = await this.#db.getKV(storage.TABLE_THREADS, key);
|
|
645
647
|
if (!data) continue;
|
|
646
|
-
if (data.resourceId !== resourceId)
|
|
648
|
+
if (filter?.resourceId && data.resourceId !== filter.resourceId) {
|
|
649
|
+
continue;
|
|
650
|
+
}
|
|
651
|
+
if (filter?.metadata && Object.keys(filter.metadata).length > 0) {
|
|
652
|
+
const metadata = this.ensureMetadata(data.metadata);
|
|
653
|
+
if (!metadata) continue;
|
|
654
|
+
const matches = Object.entries(filter.metadata).every(([key2, value]) => metadata[key2] === value);
|
|
655
|
+
if (!matches) continue;
|
|
656
|
+
}
|
|
647
657
|
threads.push(data);
|
|
648
658
|
}
|
|
649
659
|
threads.sort((a, b) => {
|
|
@@ -663,10 +673,10 @@ var MemoryStorageCloudflare = class extends storage.MemoryStorage {
|
|
|
663
673
|
} catch (error$1) {
|
|
664
674
|
throw new error.MastraError(
|
|
665
675
|
{
|
|
666
|
-
id: storage.createStorageErrorId("CLOUDFLARE", "
|
|
676
|
+
id: storage.createStorageErrorId("CLOUDFLARE", "LIST_THREADS", "FAILED"),
|
|
667
677
|
domain: error.ErrorDomain.STORAGE,
|
|
668
678
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
669
|
-
text: "Failed to
|
|
679
|
+
text: "Failed to list threads with filters"
|
|
670
680
|
},
|
|
671
681
|
error$1
|
|
672
682
|
);
|
|
@@ -2159,7 +2169,7 @@ function isWorkersConfig(config) {
|
|
|
2159
2169
|
}
|
|
2160
2170
|
|
|
2161
2171
|
// src/storage/index.ts
|
|
2162
|
-
var CloudflareStore = class extends storage.
|
|
2172
|
+
var CloudflareStore = class extends storage.MastraCompositeStore {
|
|
2163
2173
|
stores;
|
|
2164
2174
|
client;
|
|
2165
2175
|
accountId;
|