@mastra/cloudflare-d1 1.0.0-beta.1 → 1.0.0-beta.3
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 +56 -0
- package/dist/index.cjs +61 -65
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +62 -66
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/memory/index.d.ts.map +1 -1
- package/dist/storage/domains/operations/index.d.ts.map +1 -1
- package/dist/storage/domains/scores/index.d.ts.map +1 -1
- package/dist/storage/domains/workflows/index.d.ts.map +1 -1
- package/dist/storage/index.d.ts +31 -14
- package/dist/storage/index.d.ts.map +1 -1
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,61 @@
|
|
|
1
1
|
# @mastra/cloudflare-d1
|
|
2
2
|
|
|
3
|
+
## 1.0.0-beta.3
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Add `disableInit` option to all storage adapters ([#10851](https://github.com/mastra-ai/mastra/pull/10851))
|
|
8
|
+
|
|
9
|
+
Adds a new `disableInit` config option to all storage providers that allows users to disable automatic table creation/migrations at runtime. This is useful for CI/CD pipelines where you want to run migrations during deployment with elevated credentials, then run the application with `disableInit: true` so it doesn't attempt schema changes at runtime.
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
// CI/CD script - run migrations
|
|
13
|
+
const storage = new PostgresStore({
|
|
14
|
+
connectionString: DATABASE_URL,
|
|
15
|
+
id: 'pg-storage',
|
|
16
|
+
});
|
|
17
|
+
await storage.init();
|
|
18
|
+
|
|
19
|
+
// Runtime - skip auto-init
|
|
20
|
+
const storage = new PostgresStore({
|
|
21
|
+
connectionString: DATABASE_URL,
|
|
22
|
+
id: 'pg-storage',
|
|
23
|
+
disableInit: true,
|
|
24
|
+
});
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Patch Changes
|
|
28
|
+
|
|
29
|
+
- Standardize error IDs across all storage and vector stores using centralized helper functions (`createStorageErrorId` and `createVectorErrorId`). This ensures consistent error ID patterns (`MASTRA_STORAGE_{STORE}_{OPERATION}_{STATUS}` and `MASTRA_VECTOR_{STORE}_{OPERATION}_{STATUS}`) across the codebase for better error tracking and debugging. ([#10913](https://github.com/mastra-ai/mastra/pull/10913))
|
|
30
|
+
|
|
31
|
+
- Updated dependencies [[`3076c67`](https://github.com/mastra-ai/mastra/commit/3076c6778b18988ae7d5c4c5c466366974b2d63f), [`85d7ee1`](https://github.com/mastra-ai/mastra/commit/85d7ee18ff4e14d625a8a30ec6656bb49804989b), [`c6c1092`](https://github.com/mastra-ai/mastra/commit/c6c1092f8fbf76109303f69e000e96fd1960c4ce), [`81dc110`](https://github.com/mastra-ai/mastra/commit/81dc11008d147cf5bdc8996ead1aa61dbdebb6fc), [`7aedb74`](https://github.com/mastra-ai/mastra/commit/7aedb74883adf66af38e270e4068fd42e7a37036), [`8f02d80`](https://github.com/mastra-ai/mastra/commit/8f02d800777397e4b45d7f1ad041988a8b0c6630), [`d7aad50`](https://github.com/mastra-ai/mastra/commit/d7aad501ce61646b76b4b511e558ac4eea9884d0), [`ce0a73a`](https://github.com/mastra-ai/mastra/commit/ce0a73abeaa75b10ca38f9e40a255a645d50ebfb), [`a02e542`](https://github.com/mastra-ai/mastra/commit/a02e542d23179bad250b044b17ff023caa61739f), [`a372c64`](https://github.com/mastra-ai/mastra/commit/a372c640ad1fd12e8f0613cebdc682fc156b4d95), [`8846867`](https://github.com/mastra-ai/mastra/commit/8846867ffa9a3746767618e314bebac08eb77d87), [`42a42cf`](https://github.com/mastra-ai/mastra/commit/42a42cf3132b9786feecbb8c13c583dce5b0e198), [`ae08bf0`](https://github.com/mastra-ai/mastra/commit/ae08bf0ebc6a4e4da992b711c4a389c32ba84cf4), [`21735a7`](https://github.com/mastra-ai/mastra/commit/21735a7ef306963554a69a89b44f06c3bcd85141), [`1d877b8`](https://github.com/mastra-ai/mastra/commit/1d877b8d7b536a251c1a7a18db7ddcf4f68d6f8b)]:
|
|
32
|
+
- @mastra/core@1.0.0-beta.7
|
|
33
|
+
|
|
34
|
+
## 1.0.0-beta.2
|
|
35
|
+
|
|
36
|
+
### Patch Changes
|
|
37
|
+
|
|
38
|
+
- feat(storage): support querying messages from multiple threads ([#10663](https://github.com/mastra-ai/mastra/pull/10663))
|
|
39
|
+
- Fixed TypeScript errors where `threadId: string | string[]` was being passed to places expecting `Scalar` type
|
|
40
|
+
- Added proper multi-thread support for `listMessages` across all adapters when `threadId` is an array
|
|
41
|
+
- Updated `_getIncludedMessages` to look up message threadId by ID (since message IDs are globally unique)
|
|
42
|
+
- **upstash**: Added `msg-idx:{messageId}` index for O(1) message lookups (backwards compatible with fallback to scan for old messages, with automatic backfill)
|
|
43
|
+
|
|
44
|
+
- fix: ensure score responses match saved payloads for Mastra Stores. ([#10557](https://github.com/mastra-ai/mastra/pull/10557))
|
|
45
|
+
|
|
46
|
+
- Unify transformScoreRow functions across storage adapters ([#10648](https://github.com/mastra-ai/mastra/pull/10648))
|
|
47
|
+
|
|
48
|
+
Added a unified `transformScoreRow` function in `@mastra/core/storage` that provides schema-driven row transformation for score data. This eliminates code duplication across 10 storage adapters while maintaining store-specific behavior through configurable options:
|
|
49
|
+
- `preferredTimestampFields`: Preferred source fields for timestamps (PostgreSQL, Cloudflare D1)
|
|
50
|
+
- `convertTimestamps`: Convert timestamp strings to Date objects (MSSQL, MongoDB, ClickHouse)
|
|
51
|
+
- `nullValuePattern`: Skip values matching pattern (ClickHouse's `'_null_'`)
|
|
52
|
+
- `fieldMappings`: Map source column names to schema fields (LibSQL's `additionalLLMContext`)
|
|
53
|
+
|
|
54
|
+
Each store adapter now uses the unified function with appropriate options, reducing ~200 lines of duplicate transformation logic while ensuring consistent behavior across all storage backends.
|
|
55
|
+
|
|
56
|
+
- Updated dependencies [[`ac0d2f4`](https://github.com/mastra-ai/mastra/commit/ac0d2f4ff8831f72c1c66c2be809706d17f65789), [`1a0d3fc`](https://github.com/mastra-ai/mastra/commit/1a0d3fc811482c9c376cdf79ee615c23bae9b2d6), [`85a628b`](https://github.com/mastra-ai/mastra/commit/85a628b1224a8f64cd82ea7f033774bf22df7a7e), [`c237233`](https://github.com/mastra-ai/mastra/commit/c23723399ccedf7f5744b3f40997b79246bfbe64), [`15f9e21`](https://github.com/mastra-ai/mastra/commit/15f9e216177201ea6e3f6d0bfb063fcc0953444f), [`ff94dea`](https://github.com/mastra-ai/mastra/commit/ff94dea935f4e34545c63bcb6c29804732698809), [`5b2ff46`](https://github.com/mastra-ai/mastra/commit/5b2ff4651df70c146523a7fca773f8eb0a2272f8), [`db41688`](https://github.com/mastra-ai/mastra/commit/db4168806d007417e2e60b4f68656dca4e5f40c9), [`5ca599d`](https://github.com/mastra-ai/mastra/commit/5ca599d0bb59a1595f19f58473fcd67cc71cef58), [`bff1145`](https://github.com/mastra-ai/mastra/commit/bff114556b3cbadad9b2768488708f8ad0e91475), [`5c8ca24`](https://github.com/mastra-ai/mastra/commit/5c8ca247094e0cc2cdbd7137822fb47241f86e77), [`e191844`](https://github.com/mastra-ai/mastra/commit/e1918444ca3f80e82feef1dad506cd4ec6e2875f), [`22553f1`](https://github.com/mastra-ai/mastra/commit/22553f11c63ee5e966a9c034a349822249584691), [`7237163`](https://github.com/mastra-ai/mastra/commit/72371635dbf96a87df4b073cc48fc655afbdce3d), [`2500740`](https://github.com/mastra-ai/mastra/commit/2500740ea23da067d6e50ec71c625ab3ce275e64), [`873ecbb`](https://github.com/mastra-ai/mastra/commit/873ecbb517586aa17d2f1e99283755b3ebb2863f), [`4f9bbe5`](https://github.com/mastra-ai/mastra/commit/4f9bbe5968f42c86f4930b8193de3c3c17e5bd36), [`02e51fe`](https://github.com/mastra-ai/mastra/commit/02e51feddb3d4155cfbcc42624fd0d0970d032c0), [`8f3fa3a`](https://github.com/mastra-ai/mastra/commit/8f3fa3a652bb77da092f913ec51ae46e3a7e27dc), [`cd29ad2`](https://github.com/mastra-ai/mastra/commit/cd29ad23a255534e8191f249593849ed29160886), [`bdf4d8c`](https://github.com/mastra-ai/mastra/commit/bdf4d8cdc656d8a2c21d81834bfa3bfa70f56c16), [`854e3da`](https://github.com/mastra-ai/mastra/commit/854e3dad5daac17a91a20986399d3a51f54bf68b), [`ce18d38`](https://github.com/mastra-ai/mastra/commit/ce18d38678c65870350d123955014a8432075fd9), [`cccf9c8`](https://github.com/mastra-ai/mastra/commit/cccf9c8b2d2dfc1a5e63919395b83d78c89682a0), [`61a5705`](https://github.com/mastra-ai/mastra/commit/61a570551278b6743e64243b3ce7d73de915ca8a), [`db70a48`](https://github.com/mastra-ai/mastra/commit/db70a48aeeeeb8e5f92007e8ede52c364ce15287), [`f0fdc14`](https://github.com/mastra-ai/mastra/commit/f0fdc14ee233d619266b3d2bbdeea7d25cfc6d13), [`db18bc9`](https://github.com/mastra-ai/mastra/commit/db18bc9c3825e2c1a0ad9a183cc9935f6691bfa1), [`9b37b56`](https://github.com/mastra-ai/mastra/commit/9b37b565e1f2a76c24f728945cc740c2b09be9da), [`41a23c3`](https://github.com/mastra-ai/mastra/commit/41a23c32f9877d71810f37e24930515df2ff7a0f), [`5d171ad`](https://github.com/mastra-ai/mastra/commit/5d171ad9ef340387276b77c2bb3e83e83332d729), [`f03ae60`](https://github.com/mastra-ai/mastra/commit/f03ae60500fe350c9d828621006cdafe1975fdd8), [`d1e74a0`](https://github.com/mastra-ai/mastra/commit/d1e74a0a293866dece31022047f5dbab65a304d0), [`39e7869`](https://github.com/mastra-ai/mastra/commit/39e7869bc7d0ee391077ce291474d8a84eedccff), [`5761926`](https://github.com/mastra-ai/mastra/commit/57619260c4a2cdd598763abbacd90de594c6bc76), [`c900fdd`](https://github.com/mastra-ai/mastra/commit/c900fdd504c41348efdffb205cfe80d48c38fa33), [`604a79f`](https://github.com/mastra-ai/mastra/commit/604a79fecf276e26a54a3fe01bb94e65315d2e0e), [`887f0b4`](https://github.com/mastra-ai/mastra/commit/887f0b4746cdbd7cb7d6b17ac9f82aeb58037ea5), [`2562143`](https://github.com/mastra-ai/mastra/commit/256214336b4faa78646c9c1776612393790d8784), [`ef11a61`](https://github.com/mastra-ai/mastra/commit/ef11a61920fa0ed08a5b7ceedd192875af119749)]:
|
|
57
|
+
- @mastra/core@1.0.0-beta.6
|
|
58
|
+
|
|
3
59
|
## 1.0.0-beta.1
|
|
4
60
|
|
|
5
61
|
### Patch Changes
|
package/dist/index.cjs
CHANGED
|
@@ -281,7 +281,7 @@ var MemoryStorageD1 = class extends storage.MemoryStorage {
|
|
|
281
281
|
} catch (error$1) {
|
|
282
282
|
const mastraError = new error.MastraError(
|
|
283
283
|
{
|
|
284
|
-
id: "
|
|
284
|
+
id: storage.createStorageErrorId("CLOUDFLARE_D1", "GET_RESOURCE_BY_ID", "FAILED"),
|
|
285
285
|
domain: error.ErrorDomain.STORAGE,
|
|
286
286
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
287
287
|
text: `Error processing resource ${resourceId}: ${error$1 instanceof Error ? error$1.message : String(error$1)}`,
|
|
@@ -320,7 +320,7 @@ var MemoryStorageD1 = class extends storage.MemoryStorage {
|
|
|
320
320
|
} catch (error$1) {
|
|
321
321
|
throw new error.MastraError(
|
|
322
322
|
{
|
|
323
|
-
id: "
|
|
323
|
+
id: storage.createStorageErrorId("CLOUDFLARE_D1", "SAVE_RESOURCE", "FAILED"),
|
|
324
324
|
domain: error.ErrorDomain.STORAGE,
|
|
325
325
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
326
326
|
text: `Failed to save resource to ${fullTableName}: ${error$1 instanceof Error ? error$1.message : String(error$1)}`,
|
|
@@ -367,7 +367,7 @@ var MemoryStorageD1 = class extends storage.MemoryStorage {
|
|
|
367
367
|
} catch (error$1) {
|
|
368
368
|
throw new error.MastraError(
|
|
369
369
|
{
|
|
370
|
-
id: "
|
|
370
|
+
id: storage.createStorageErrorId("CLOUDFLARE_D1", "UPDATE_RESOURCE", "FAILED"),
|
|
371
371
|
domain: error.ErrorDomain.STORAGE,
|
|
372
372
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
373
373
|
text: `Failed to update resource ${resourceId}: ${error$1 instanceof Error ? error$1.message : String(error$1)}`,
|
|
@@ -393,7 +393,7 @@ var MemoryStorageD1 = class extends storage.MemoryStorage {
|
|
|
393
393
|
} catch (error$1) {
|
|
394
394
|
const mastraError = new error.MastraError(
|
|
395
395
|
{
|
|
396
|
-
id: "
|
|
396
|
+
id: storage.createStorageErrorId("CLOUDFLARE_D1", "GET_THREAD_BY_ID", "FAILED"),
|
|
397
397
|
domain: error.ErrorDomain.STORAGE,
|
|
398
398
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
399
399
|
text: `Error processing thread ${threadId}: ${error$1 instanceof Error ? error$1.message : String(error$1)}`,
|
|
@@ -412,7 +412,7 @@ var MemoryStorageD1 = class extends storage.MemoryStorage {
|
|
|
412
412
|
if (page < 0) {
|
|
413
413
|
throw new error.MastraError(
|
|
414
414
|
{
|
|
415
|
-
id: "
|
|
415
|
+
id: storage.createStorageErrorId("CLOUDFLARE_D1", "LIST_THREADS_BY_RESOURCE_ID", "INVALID_PAGE"),
|
|
416
416
|
domain: error.ErrorDomain.STORAGE,
|
|
417
417
|
category: error.ErrorCategory.USER,
|
|
418
418
|
details: { page }
|
|
@@ -447,7 +447,7 @@ var MemoryStorageD1 = class extends storage.MemoryStorage {
|
|
|
447
447
|
} catch (error$1) {
|
|
448
448
|
const mastraError = new error.MastraError(
|
|
449
449
|
{
|
|
450
|
-
id: "
|
|
450
|
+
id: storage.createStorageErrorId("CLOUDFLARE_D1", "LIST_THREADS_BY_RESOURCE_ID", "FAILED"),
|
|
451
451
|
domain: error.ErrorDomain.STORAGE,
|
|
452
452
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
453
453
|
text: `Error getting threads by resourceId ${resourceId}: ${error$1 instanceof Error ? error$1.message : String(error$1)}`,
|
|
@@ -494,7 +494,7 @@ var MemoryStorageD1 = class extends storage.MemoryStorage {
|
|
|
494
494
|
} catch (error$1) {
|
|
495
495
|
throw new error.MastraError(
|
|
496
496
|
{
|
|
497
|
-
id: "
|
|
497
|
+
id: storage.createStorageErrorId("CLOUDFLARE_D1", "SAVE_THREAD", "FAILED"),
|
|
498
498
|
domain: error.ErrorDomain.STORAGE,
|
|
499
499
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
500
500
|
text: `Failed to save thread to ${fullTableName}: ${error$1 instanceof Error ? error$1.message : String(error$1)}`,
|
|
@@ -537,7 +537,7 @@ var MemoryStorageD1 = class extends storage.MemoryStorage {
|
|
|
537
537
|
} catch (error$1) {
|
|
538
538
|
throw new error.MastraError(
|
|
539
539
|
{
|
|
540
|
-
id: "
|
|
540
|
+
id: storage.createStorageErrorId("CLOUDFLARE_D1", "UPDATE_THREAD", "FAILED"),
|
|
541
541
|
domain: error.ErrorDomain.STORAGE,
|
|
542
542
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
543
543
|
text: `Failed to update thread ${id}: ${error$1 instanceof Error ? error$1.message : String(error$1)}`,
|
|
@@ -560,7 +560,7 @@ var MemoryStorageD1 = class extends storage.MemoryStorage {
|
|
|
560
560
|
} catch (error$1) {
|
|
561
561
|
throw new error.MastraError(
|
|
562
562
|
{
|
|
563
|
-
id: "
|
|
563
|
+
id: storage.createStorageErrorId("CLOUDFLARE_D1", "DELETE_THREAD", "FAILED"),
|
|
564
564
|
domain: error.ErrorDomain.STORAGE,
|
|
565
565
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
566
566
|
text: `Failed to delete thread ${threadId}: ${error$1 instanceof Error ? error$1.message : String(error$1)}`,
|
|
@@ -624,7 +624,7 @@ var MemoryStorageD1 = class extends storage.MemoryStorage {
|
|
|
624
624
|
} catch (error$1) {
|
|
625
625
|
throw new error.MastraError(
|
|
626
626
|
{
|
|
627
|
-
id: "
|
|
627
|
+
id: storage.createStorageErrorId("CLOUDFLARE_D1", "SAVE_MESSAGES", "FAILED"),
|
|
628
628
|
domain: error.ErrorDomain.STORAGE,
|
|
629
629
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
630
630
|
text: `Failed to save messages: ${error$1 instanceof Error ? error$1.message : String(error$1)}`
|
|
@@ -633,23 +633,25 @@ var MemoryStorageD1 = class extends storage.MemoryStorage {
|
|
|
633
633
|
);
|
|
634
634
|
}
|
|
635
635
|
}
|
|
636
|
-
async _getIncludedMessages(
|
|
637
|
-
if (!
|
|
638
|
-
if (!include) return null;
|
|
636
|
+
async _getIncludedMessages(include) {
|
|
637
|
+
if (!include || include.length === 0) return null;
|
|
639
638
|
const unionQueries = [];
|
|
640
639
|
const params = [];
|
|
641
640
|
let paramIdx = 1;
|
|
641
|
+
const tableName = this.operations.getTableName(storage.TABLE_MESSAGES);
|
|
642
642
|
for (const inc of include) {
|
|
643
643
|
const { id, withPreviousMessages = 0, withNextMessages = 0 } = inc;
|
|
644
|
-
const searchId = inc.threadId || threadId;
|
|
645
644
|
unionQueries.push(`
|
|
646
645
|
SELECT * FROM (
|
|
647
|
-
WITH
|
|
646
|
+
WITH target_thread AS (
|
|
647
|
+
SELECT thread_id FROM ${tableName} WHERE id = ?
|
|
648
|
+
),
|
|
649
|
+
ordered_messages AS (
|
|
648
650
|
SELECT
|
|
649
651
|
*,
|
|
650
652
|
ROW_NUMBER() OVER (ORDER BY createdAt ASC) AS row_num
|
|
651
|
-
FROM ${
|
|
652
|
-
WHERE thread_id =
|
|
653
|
+
FROM ${tableName}
|
|
654
|
+
WHERE thread_id = (SELECT thread_id FROM target_thread)
|
|
653
655
|
)
|
|
654
656
|
SELECT
|
|
655
657
|
m.id,
|
|
@@ -672,7 +674,7 @@ var MemoryStorageD1 = class extends storage.MemoryStorage {
|
|
|
672
674
|
)
|
|
673
675
|
) AS query_${paramIdx}
|
|
674
676
|
`);
|
|
675
|
-
params.push(
|
|
677
|
+
params.push(id, id, id, withNextMessages, withPreviousMessages);
|
|
676
678
|
paramIdx++;
|
|
677
679
|
}
|
|
678
680
|
const finalQuery = unionQueries.join(" UNION ALL ") + " ORDER BY createdAt ASC";
|
|
@@ -714,7 +716,7 @@ var MemoryStorageD1 = class extends storage.MemoryStorage {
|
|
|
714
716
|
} catch (error$1) {
|
|
715
717
|
const mastraError = new error.MastraError(
|
|
716
718
|
{
|
|
717
|
-
id: "
|
|
719
|
+
id: storage.createStorageErrorId("CLOUDFLARE_D1", "LIST_MESSAGES_BY_ID", "FAILED"),
|
|
718
720
|
domain: error.ErrorDomain.STORAGE,
|
|
719
721
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
720
722
|
text: `Failed to retrieve messages by ID: ${error$1 instanceof Error ? error$1.message : String(error$1)}`,
|
|
@@ -729,21 +731,22 @@ var MemoryStorageD1 = class extends storage.MemoryStorage {
|
|
|
729
731
|
}
|
|
730
732
|
async listMessages(args) {
|
|
731
733
|
const { threadId, resourceId, include, filter, perPage: perPageInput, page = 0, orderBy } = args;
|
|
732
|
-
|
|
734
|
+
const threadIds = Array.isArray(threadId) ? threadId : [threadId];
|
|
735
|
+
if (threadIds.length === 0 || threadIds.some((id) => !id.trim())) {
|
|
733
736
|
throw new error.MastraError(
|
|
734
737
|
{
|
|
735
|
-
id: "
|
|
738
|
+
id: storage.createStorageErrorId("CLOUDFLARE_D1", "LIST_MESSAGES", "INVALID_THREAD_ID"),
|
|
736
739
|
domain: error.ErrorDomain.STORAGE,
|
|
737
740
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
738
|
-
details: { threadId }
|
|
741
|
+
details: { threadId: Array.isArray(threadId) ? threadId.join(",") : threadId }
|
|
739
742
|
},
|
|
740
|
-
new Error("threadId must be a non-empty string")
|
|
743
|
+
new Error("threadId must be a non-empty string or array of non-empty strings")
|
|
741
744
|
);
|
|
742
745
|
}
|
|
743
746
|
if (page < 0) {
|
|
744
747
|
throw new error.MastraError(
|
|
745
748
|
{
|
|
746
|
-
id: "
|
|
749
|
+
id: storage.createStorageErrorId("CLOUDFLARE_D1", "LIST_MESSAGES", "INVALID_PAGE"),
|
|
747
750
|
domain: error.ErrorDomain.STORAGE,
|
|
748
751
|
category: error.ErrorCategory.USER,
|
|
749
752
|
details: { page }
|
|
@@ -822,7 +825,7 @@ var MemoryStorageD1 = class extends storage.MemoryStorage {
|
|
|
822
825
|
const messageIds = new Set(paginatedMessages.map((m) => m.id));
|
|
823
826
|
let includeMessages = [];
|
|
824
827
|
if (include && include.length > 0) {
|
|
825
|
-
const includeResult = await this._getIncludedMessages(
|
|
828
|
+
const includeResult = await this._getIncludedMessages(include);
|
|
826
829
|
if (Array.isArray(includeResult)) {
|
|
827
830
|
includeMessages = includeResult;
|
|
828
831
|
for (const includeMsg of includeMessages) {
|
|
@@ -860,12 +863,12 @@ var MemoryStorageD1 = class extends storage.MemoryStorage {
|
|
|
860
863
|
} catch (error$1) {
|
|
861
864
|
const mastraError = new error.MastraError(
|
|
862
865
|
{
|
|
863
|
-
id: "
|
|
866
|
+
id: storage.createStorageErrorId("CLOUDFLARE_D1", "LIST_MESSAGES", "FAILED"),
|
|
864
867
|
domain: error.ErrorDomain.STORAGE,
|
|
865
868
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
866
|
-
text: `Failed to list messages for thread ${threadId}: ${error$1 instanceof Error ? error$1.message : String(error$1)}`,
|
|
869
|
+
text: `Failed to list messages for thread ${Array.isArray(threadId) ? threadId.join(",") : threadId}: ${error$1 instanceof Error ? error$1.message : String(error$1)}`,
|
|
867
870
|
details: {
|
|
868
|
-
threadId,
|
|
871
|
+
threadId: Array.isArray(threadId) ? threadId.join(",") : threadId,
|
|
869
872
|
resourceId: resourceId ?? ""
|
|
870
873
|
}
|
|
871
874
|
},
|
|
@@ -973,7 +976,7 @@ var MemoryStorageD1 = class extends storage.MemoryStorage {
|
|
|
973
976
|
} catch (error$1) {
|
|
974
977
|
throw new error.MastraError(
|
|
975
978
|
{
|
|
976
|
-
id: "
|
|
979
|
+
id: storage.createStorageErrorId("CLOUDFLARE_D1", "UPDATE_MESSAGES", "FAILED"),
|
|
977
980
|
domain: error.ErrorDomain.STORAGE,
|
|
978
981
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
979
982
|
details: { count: messages.length }
|
|
@@ -1042,7 +1045,7 @@ var StoreOperationsD1 = class extends storage.StoreOperations {
|
|
|
1042
1045
|
} catch (error$1) {
|
|
1043
1046
|
throw new error.MastraError(
|
|
1044
1047
|
{
|
|
1045
|
-
id: "
|
|
1048
|
+
id: storage.createStorageErrorId("CLOUDFLARE_D1", "WORKERS_BINDING_QUERY", "FAILED"),
|
|
1046
1049
|
domain: error.ErrorDomain.STORAGE,
|
|
1047
1050
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
1048
1051
|
details: { sql }
|
|
@@ -1074,7 +1077,7 @@ var StoreOperationsD1 = class extends storage.StoreOperations {
|
|
|
1074
1077
|
} catch (error$1) {
|
|
1075
1078
|
throw new error.MastraError(
|
|
1076
1079
|
{
|
|
1077
|
-
id: "
|
|
1080
|
+
id: storage.createStorageErrorId("CLOUDFLARE_D1", "REST_QUERY", "FAILED"),
|
|
1078
1081
|
domain: error.ErrorDomain.STORAGE,
|
|
1079
1082
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
1080
1083
|
details: { sql }
|
|
@@ -1155,7 +1158,7 @@ var StoreOperationsD1 = class extends storage.StoreOperations {
|
|
|
1155
1158
|
} catch (error$1) {
|
|
1156
1159
|
throw new error.MastraError(
|
|
1157
1160
|
{
|
|
1158
|
-
id: "
|
|
1161
|
+
id: storage.createStorageErrorId("CLOUDFLARE_D1", "CREATE_TABLE", "FAILED"),
|
|
1159
1162
|
domain: error.ErrorDomain.STORAGE,
|
|
1160
1163
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
1161
1164
|
details: { tableName }
|
|
@@ -1174,7 +1177,7 @@ var StoreOperationsD1 = class extends storage.StoreOperations {
|
|
|
1174
1177
|
} catch (error$1) {
|
|
1175
1178
|
throw new error.MastraError(
|
|
1176
1179
|
{
|
|
1177
|
-
id: "
|
|
1180
|
+
id: storage.createStorageErrorId("CLOUDFLARE_D1", "CLEAR_TABLE", "FAILED"),
|
|
1178
1181
|
domain: error.ErrorDomain.STORAGE,
|
|
1179
1182
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
1180
1183
|
details: { tableName }
|
|
@@ -1192,7 +1195,7 @@ var StoreOperationsD1 = class extends storage.StoreOperations {
|
|
|
1192
1195
|
} catch (error$1) {
|
|
1193
1196
|
throw new error.MastraError(
|
|
1194
1197
|
{
|
|
1195
|
-
id: "
|
|
1198
|
+
id: storage.createStorageErrorId("CLOUDFLARE_D1", "DROP_TABLE", "FAILED"),
|
|
1196
1199
|
domain: error.ErrorDomain.STORAGE,
|
|
1197
1200
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
1198
1201
|
details: { tableName }
|
|
@@ -1218,7 +1221,7 @@ var StoreOperationsD1 = class extends storage.StoreOperations {
|
|
|
1218
1221
|
} catch (error$1) {
|
|
1219
1222
|
throw new error.MastraError(
|
|
1220
1223
|
{
|
|
1221
|
-
id: "
|
|
1224
|
+
id: storage.createStorageErrorId("CLOUDFLARE_D1", "ALTER_TABLE", "FAILED"),
|
|
1222
1225
|
domain: error.ErrorDomain.STORAGE,
|
|
1223
1226
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
1224
1227
|
details: { tableName: args.tableName }
|
|
@@ -1239,7 +1242,7 @@ var StoreOperationsD1 = class extends storage.StoreOperations {
|
|
|
1239
1242
|
} catch (error$1) {
|
|
1240
1243
|
throw new error.MastraError(
|
|
1241
1244
|
{
|
|
1242
|
-
id: "
|
|
1245
|
+
id: storage.createStorageErrorId("CLOUDFLARE_D1", "INSERT", "FAILED"),
|
|
1243
1246
|
domain: error.ErrorDomain.STORAGE,
|
|
1244
1247
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
1245
1248
|
details: { tableName }
|
|
@@ -1263,7 +1266,7 @@ var StoreOperationsD1 = class extends storage.StoreOperations {
|
|
|
1263
1266
|
} catch (error$1) {
|
|
1264
1267
|
throw new error.MastraError(
|
|
1265
1268
|
{
|
|
1266
|
-
id: "
|
|
1269
|
+
id: storage.createStorageErrorId("CLOUDFLARE_D1", "BATCH_INSERT", "FAILED"),
|
|
1267
1270
|
domain: error.ErrorDomain.STORAGE,
|
|
1268
1271
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
1269
1272
|
details: { tableName }
|
|
@@ -1300,7 +1303,7 @@ var StoreOperationsD1 = class extends storage.StoreOperations {
|
|
|
1300
1303
|
} catch (error$1) {
|
|
1301
1304
|
throw new error.MastraError(
|
|
1302
1305
|
{
|
|
1303
|
-
id: "
|
|
1306
|
+
id: storage.createStorageErrorId("CLOUDFLARE_D1", "LOAD", "FAILED"),
|
|
1304
1307
|
domain: error.ErrorDomain.STORAGE,
|
|
1305
1308
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
1306
1309
|
details: { tableName }
|
|
@@ -1358,7 +1361,7 @@ var StoreOperationsD1 = class extends storage.StoreOperations {
|
|
|
1358
1361
|
} catch (error$1) {
|
|
1359
1362
|
throw new error.MastraError(
|
|
1360
1363
|
{
|
|
1361
|
-
id: "
|
|
1364
|
+
id: storage.createStorageErrorId("CLOUDFLARE_D1", "BATCH_UPSERT", "FAILED"),
|
|
1362
1365
|
domain: error.ErrorDomain.STORAGE,
|
|
1363
1366
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
1364
1367
|
text: `Failed to batch upsert into ${tableName}: ${error$1 instanceof Error ? error$1.message : String(error$1)}`,
|
|
@@ -1370,19 +1373,12 @@ var StoreOperationsD1 = class extends storage.StoreOperations {
|
|
|
1370
1373
|
}
|
|
1371
1374
|
};
|
|
1372
1375
|
function transformScoreRow(row) {
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
deserialized.metadata = storage.safelyParseJSON(row.metadata);
|
|
1380
|
-
deserialized.additionalContext = storage.safelyParseJSON(row.additionalContext);
|
|
1381
|
-
deserialized.requestContext = storage.safelyParseJSON(row.requestContext);
|
|
1382
|
-
deserialized.entity = storage.safelyParseJSON(row.entity);
|
|
1383
|
-
deserialized.createdAt = row.createdAtZ || row.createdAt;
|
|
1384
|
-
deserialized.updatedAt = row.updatedAtZ || row.updatedAt;
|
|
1385
|
-
return deserialized;
|
|
1376
|
+
return storage.transformScoreRow(row, {
|
|
1377
|
+
preferredTimestampFields: {
|
|
1378
|
+
createdAt: "createdAtZ",
|
|
1379
|
+
updatedAt: "updatedAtZ"
|
|
1380
|
+
}
|
|
1381
|
+
});
|
|
1386
1382
|
}
|
|
1387
1383
|
var ScoresStorageD1 = class extends storage.ScoresStorage {
|
|
1388
1384
|
operations;
|
|
@@ -1403,7 +1399,7 @@ var ScoresStorageD1 = class extends storage.ScoresStorage {
|
|
|
1403
1399
|
} catch (error$1) {
|
|
1404
1400
|
throw new error.MastraError(
|
|
1405
1401
|
{
|
|
1406
|
-
id: "
|
|
1402
|
+
id: storage.createStorageErrorId("CLOUDFLARE_D1", "GET_SCORE_BY_ID", "FAILED"),
|
|
1407
1403
|
domain: error.ErrorDomain.STORAGE,
|
|
1408
1404
|
category: error.ErrorCategory.THIRD_PARTY
|
|
1409
1405
|
},
|
|
@@ -1418,7 +1414,7 @@ var ScoresStorageD1 = class extends storage.ScoresStorage {
|
|
|
1418
1414
|
} catch (error$1) {
|
|
1419
1415
|
throw new error.MastraError(
|
|
1420
1416
|
{
|
|
1421
|
-
id: "
|
|
1417
|
+
id: storage.createStorageErrorId("CLOUDFLARE_D1", "SAVE_SCORE", "VALIDATION_FAILED"),
|
|
1422
1418
|
domain: error.ErrorDomain.STORAGE,
|
|
1423
1419
|
category: error.ErrorCategory.USER,
|
|
1424
1420
|
details: { scoreId: score.id }
|
|
@@ -1454,7 +1450,7 @@ var ScoresStorageD1 = class extends storage.ScoresStorage {
|
|
|
1454
1450
|
} catch (error$1) {
|
|
1455
1451
|
throw new error.MastraError(
|
|
1456
1452
|
{
|
|
1457
|
-
id: "
|
|
1453
|
+
id: storage.createStorageErrorId("CLOUDFLARE_D1", "SAVE_SCORE", "FAILED"),
|
|
1458
1454
|
domain: error.ErrorDomain.STORAGE,
|
|
1459
1455
|
category: error.ErrorCategory.THIRD_PARTY
|
|
1460
1456
|
},
|
|
@@ -1525,7 +1521,7 @@ var ScoresStorageD1 = class extends storage.ScoresStorage {
|
|
|
1525
1521
|
} catch (error$1) {
|
|
1526
1522
|
throw new error.MastraError(
|
|
1527
1523
|
{
|
|
1528
|
-
id: "
|
|
1524
|
+
id: storage.createStorageErrorId("CLOUDFLARE_D1", "GET_SCORES_BY_SCORER_ID", "FAILED"),
|
|
1529
1525
|
domain: error.ErrorDomain.STORAGE,
|
|
1530
1526
|
category: error.ErrorCategory.THIRD_PARTY
|
|
1531
1527
|
},
|
|
@@ -1574,7 +1570,7 @@ var ScoresStorageD1 = class extends storage.ScoresStorage {
|
|
|
1574
1570
|
} catch (error$1) {
|
|
1575
1571
|
throw new error.MastraError(
|
|
1576
1572
|
{
|
|
1577
|
-
id: "
|
|
1573
|
+
id: storage.createStorageErrorId("CLOUDFLARE_D1", "GET_SCORES_BY_RUN_ID", "FAILED"),
|
|
1578
1574
|
domain: error.ErrorDomain.STORAGE,
|
|
1579
1575
|
category: error.ErrorCategory.THIRD_PARTY
|
|
1580
1576
|
},
|
|
@@ -1624,7 +1620,7 @@ var ScoresStorageD1 = class extends storage.ScoresStorage {
|
|
|
1624
1620
|
} catch (error$1) {
|
|
1625
1621
|
throw new error.MastraError(
|
|
1626
1622
|
{
|
|
1627
|
-
id: "
|
|
1623
|
+
id: storage.createStorageErrorId("CLOUDFLARE_D1", "GET_SCORES_BY_ENTITY_ID", "FAILED"),
|
|
1628
1624
|
domain: error.ErrorDomain.STORAGE,
|
|
1629
1625
|
category: error.ErrorCategory.THIRD_PARTY
|
|
1630
1626
|
},
|
|
@@ -1674,7 +1670,7 @@ var ScoresStorageD1 = class extends storage.ScoresStorage {
|
|
|
1674
1670
|
} catch (error$1) {
|
|
1675
1671
|
throw new error.MastraError(
|
|
1676
1672
|
{
|
|
1677
|
-
id: "
|
|
1673
|
+
id: storage.createStorageErrorId("CLOUDFLARE_D1", "GET_SCORES_BY_SPAN", "FAILED"),
|
|
1678
1674
|
domain: error.ErrorDomain.STORAGE,
|
|
1679
1675
|
category: error.ErrorCategory.THIRD_PARTY
|
|
1680
1676
|
},
|
|
@@ -1745,7 +1741,7 @@ var WorkflowsStorageD1 = class extends storage.WorkflowsStorage {
|
|
|
1745
1741
|
} catch (error$1) {
|
|
1746
1742
|
throw new error.MastraError(
|
|
1747
1743
|
{
|
|
1748
|
-
id: "
|
|
1744
|
+
id: storage.createStorageErrorId("CLOUDFLARE_D1", "PERSIST_WORKFLOW_SNAPSHOT", "FAILED"),
|
|
1749
1745
|
domain: error.ErrorDomain.STORAGE,
|
|
1750
1746
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
1751
1747
|
text: `Failed to persist workflow snapshot: ${error$1 instanceof Error ? error$1.message : String(error$1)}`,
|
|
@@ -1770,7 +1766,7 @@ var WorkflowsStorageD1 = class extends storage.WorkflowsStorage {
|
|
|
1770
1766
|
} catch (error$1) {
|
|
1771
1767
|
throw new error.MastraError(
|
|
1772
1768
|
{
|
|
1773
|
-
id: "
|
|
1769
|
+
id: storage.createStorageErrorId("CLOUDFLARE_D1", "LOAD_WORKFLOW_SNAPSHOT", "FAILED"),
|
|
1774
1770
|
domain: error.ErrorDomain.STORAGE,
|
|
1775
1771
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
1776
1772
|
text: `Failed to load workflow snapshot: ${error$1 instanceof Error ? error$1.message : String(error$1)}`,
|
|
@@ -1856,7 +1852,7 @@ var WorkflowsStorageD1 = class extends storage.WorkflowsStorage {
|
|
|
1856
1852
|
} catch (error$1) {
|
|
1857
1853
|
throw new error.MastraError(
|
|
1858
1854
|
{
|
|
1859
|
-
id: "
|
|
1855
|
+
id: storage.createStorageErrorId("CLOUDFLARE_D1", "LIST_WORKFLOW_RUNS", "FAILED"),
|
|
1860
1856
|
domain: error.ErrorDomain.STORAGE,
|
|
1861
1857
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
1862
1858
|
text: `Failed to retrieve workflow runs: ${error$1 instanceof Error ? error$1.message : String(error$1)}`,
|
|
@@ -1893,7 +1889,7 @@ var WorkflowsStorageD1 = class extends storage.WorkflowsStorage {
|
|
|
1893
1889
|
} catch (error$1) {
|
|
1894
1890
|
throw new error.MastraError(
|
|
1895
1891
|
{
|
|
1896
|
-
id: "
|
|
1892
|
+
id: storage.createStorageErrorId("CLOUDFLARE_D1", "GET_WORKFLOW_RUN_BY_ID", "FAILED"),
|
|
1897
1893
|
domain: error.ErrorDomain.STORAGE,
|
|
1898
1894
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
1899
1895
|
text: `Failed to retrieve workflow run by ID: ${error$1 instanceof Error ? error$1.message : String(error$1)}`,
|
|
@@ -1918,7 +1914,7 @@ var D1Store = class extends storage.MastraStorage {
|
|
|
1918
1914
|
*/
|
|
1919
1915
|
constructor(config) {
|
|
1920
1916
|
try {
|
|
1921
|
-
super({ id: config.id, name: "D1" });
|
|
1917
|
+
super({ id: config.id, name: "D1", disableInit: config.disableInit });
|
|
1922
1918
|
if (config.tablePrefix && !/^[a-zA-Z0-9_]*$/.test(config.tablePrefix)) {
|
|
1923
1919
|
throw new Error("Invalid tablePrefix: only letters, numbers, and underscores are allowed.");
|
|
1924
1920
|
}
|
|
@@ -1956,7 +1952,7 @@ var D1Store = class extends storage.MastraStorage {
|
|
|
1956
1952
|
} catch (error$1) {
|
|
1957
1953
|
throw new error.MastraError(
|
|
1958
1954
|
{
|
|
1959
|
-
id: "
|
|
1955
|
+
id: storage.createStorageErrorId("CLOUDFLARE_D1", "INITIALIZATION", "FAILED"),
|
|
1960
1956
|
domain: error.ErrorDomain.STORAGE,
|
|
1961
1957
|
category: error.ErrorCategory.SYSTEM,
|
|
1962
1958
|
text: "Error initializing D1Store"
|