@mastra/cloudflare 1.0.0-beta.11 → 1.0.0-beta.12
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/index.cjs +27 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +27 -17
- 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 +4 -4
package/dist/index.js
CHANGED
|
@@ -614,21 +614,23 @@ var MemoryStorageCloudflare = class extends MemoryStorage {
|
|
|
614
614
|
return null;
|
|
615
615
|
}
|
|
616
616
|
}
|
|
617
|
-
async
|
|
617
|
+
async listThreads(args) {
|
|
618
|
+
const { page = 0, perPage: perPageInput, orderBy, filter } = args;
|
|
619
|
+
try {
|
|
620
|
+
this.validatePaginationInput(page, perPageInput ?? 100);
|
|
621
|
+
} catch (error) {
|
|
622
|
+
throw new MastraError(
|
|
623
|
+
{
|
|
624
|
+
id: createStorageErrorId("CLOUDFLARE", "LIST_THREADS", "INVALID_PAGE"),
|
|
625
|
+
domain: ErrorDomain.STORAGE,
|
|
626
|
+
category: ErrorCategory.USER,
|
|
627
|
+
details: { page, ...perPageInput !== void 0 && { perPage: perPageInput } }
|
|
628
|
+
},
|
|
629
|
+
error instanceof Error ? error : new Error("Invalid pagination parameters")
|
|
630
|
+
);
|
|
631
|
+
}
|
|
632
|
+
const perPage = normalizePerPage(perPageInput, 100);
|
|
618
633
|
try {
|
|
619
|
-
const { resourceId, page = 0, perPage: perPageInput, orderBy } = args;
|
|
620
|
-
const perPage = normalizePerPage(perPageInput, 100);
|
|
621
|
-
if (page < 0) {
|
|
622
|
-
throw new MastraError(
|
|
623
|
-
{
|
|
624
|
-
id: createStorageErrorId("CLOUDFLARE", "LIST_THREADS_BY_RESOURCE_ID", "INVALID_PAGE"),
|
|
625
|
-
domain: ErrorDomain.STORAGE,
|
|
626
|
-
category: ErrorCategory.USER,
|
|
627
|
-
details: { page }
|
|
628
|
-
},
|
|
629
|
-
new Error("page must be >= 0")
|
|
630
|
-
);
|
|
631
|
-
}
|
|
632
634
|
const { offset, perPage: perPageForResponse } = calculatePagination(page, perPageInput, perPage);
|
|
633
635
|
const { field, direction } = this.parseOrderBy(orderBy);
|
|
634
636
|
const prefix = this.#db.namespacePrefix ? `${this.#db.namespacePrefix}:` : "";
|
|
@@ -637,7 +639,15 @@ var MemoryStorageCloudflare = class extends MemoryStorage {
|
|
|
637
639
|
for (const { name: key } of keyObjs) {
|
|
638
640
|
const data = await this.#db.getKV(TABLE_THREADS, key);
|
|
639
641
|
if (!data) continue;
|
|
640
|
-
if (data.resourceId !== resourceId)
|
|
642
|
+
if (filter?.resourceId && data.resourceId !== filter.resourceId) {
|
|
643
|
+
continue;
|
|
644
|
+
}
|
|
645
|
+
if (filter?.metadata && Object.keys(filter.metadata).length > 0) {
|
|
646
|
+
const metadata = this.ensureMetadata(data.metadata);
|
|
647
|
+
if (!metadata) continue;
|
|
648
|
+
const matches = Object.entries(filter.metadata).every(([key2, value]) => metadata[key2] === value);
|
|
649
|
+
if (!matches) continue;
|
|
650
|
+
}
|
|
641
651
|
threads.push(data);
|
|
642
652
|
}
|
|
643
653
|
threads.sort((a, b) => {
|
|
@@ -657,10 +667,10 @@ var MemoryStorageCloudflare = class extends MemoryStorage {
|
|
|
657
667
|
} catch (error) {
|
|
658
668
|
throw new MastraError(
|
|
659
669
|
{
|
|
660
|
-
id: createStorageErrorId("CLOUDFLARE", "
|
|
670
|
+
id: createStorageErrorId("CLOUDFLARE", "LIST_THREADS", "FAILED"),
|
|
661
671
|
domain: ErrorDomain.STORAGE,
|
|
662
672
|
category: ErrorCategory.THIRD_PARTY,
|
|
663
|
-
text: "Failed to
|
|
673
|
+
text: "Failed to list threads with filters"
|
|
664
674
|
},
|
|
665
675
|
error
|
|
666
676
|
);
|