@mastra/mysql 0.0.0-deploy-alex-2-20260602122535

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.
Files changed (54) hide show
  1. package/CHANGELOG.md +47 -0
  2. package/LICENSE.md +30 -0
  3. package/README.md +152 -0
  4. package/dist/index.cjs +10838 -0
  5. package/dist/index.cjs.map +1 -0
  6. package/dist/index.d.ts +4 -0
  7. package/dist/index.d.ts.map +1 -0
  8. package/dist/index.js +10821 -0
  9. package/dist/index.js.map +1 -0
  10. package/dist/storage/domains/agents/index.d.ts +62 -0
  11. package/dist/storage/domains/agents/index.d.ts.map +1 -0
  12. package/dist/storage/domains/background-tasks/index.d.ts +33 -0
  13. package/dist/storage/domains/background-tasks/index.d.ts.map +1 -0
  14. package/dist/storage/domains/blobs/index.d.ts +22 -0
  15. package/dist/storage/domains/blobs/index.d.ts.map +1 -0
  16. package/dist/storage/domains/channels/index.d.ts +34 -0
  17. package/dist/storage/domains/channels/index.d.ts.map +1 -0
  18. package/dist/storage/domains/datasets/index.d.ts +75 -0
  19. package/dist/storage/domains/datasets/index.d.ts.map +1 -0
  20. package/dist/storage/domains/experiments/index.d.ts +63 -0
  21. package/dist/storage/domains/experiments/index.d.ts.map +1 -0
  22. package/dist/storage/domains/favorites/index.d.ts +49 -0
  23. package/dist/storage/domains/favorites/index.d.ts.map +1 -0
  24. package/dist/storage/domains/mcp-clients/index.d.ts +61 -0
  25. package/dist/storage/domains/mcp-clients/index.d.ts.map +1 -0
  26. package/dist/storage/domains/mcp-servers/index.d.ts +61 -0
  27. package/dist/storage/domains/mcp-servers/index.d.ts.map +1 -0
  28. package/dist/storage/domains/memory/index.d.ts +110 -0
  29. package/dist/storage/domains/memory/index.d.ts.map +1 -0
  30. package/dist/storage/domains/observability/index.d.ts +35 -0
  31. package/dist/storage/domains/observability/index.d.ts.map +1 -0
  32. package/dist/storage/domains/operations/index.d.ts +106 -0
  33. package/dist/storage/domains/operations/index.d.ts.map +1 -0
  34. package/dist/storage/domains/prompt-blocks/index.d.ts +42 -0
  35. package/dist/storage/domains/prompt-blocks/index.d.ts.map +1 -0
  36. package/dist/storage/domains/schedules/index.d.ts +33 -0
  37. package/dist/storage/domains/schedules/index.d.ts.map +1 -0
  38. package/dist/storage/domains/scorer-definitions/index.d.ts +43 -0
  39. package/dist/storage/domains/scorer-definitions/index.d.ts.map +1 -0
  40. package/dist/storage/domains/scores/index.d.ts +87 -0
  41. package/dist/storage/domains/scores/index.d.ts.map +1 -0
  42. package/dist/storage/domains/skills/index.d.ts +61 -0
  43. package/dist/storage/domains/skills/index.d.ts.map +1 -0
  44. package/dist/storage/domains/tool-provider-connections/index.d.ts +46 -0
  45. package/dist/storage/domains/tool-provider-connections/index.d.ts.map +1 -0
  46. package/dist/storage/domains/utils.d.ts +40 -0
  47. package/dist/storage/domains/utils.d.ts.map +1 -0
  48. package/dist/storage/domains/workflows/index.d.ts +78 -0
  49. package/dist/storage/domains/workflows/index.d.ts.map +1 -0
  50. package/dist/storage/domains/workspaces/index.d.ts +61 -0
  51. package/dist/storage/domains/workspaces/index.d.ts.map +1 -0
  52. package/dist/storage/index.d.ts +58 -0
  53. package/dist/storage/index.d.ts.map +1 -0
  54. package/package.json +67 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,47 @@
1
+ # @mastra/mysql
2
+
3
+ ## 0.0.0-deploy-alex-2-20260602122535
4
+
5
+ ### Minor Changes
6
+
7
+ - Added the MySQL storage adapter for Mastra. Use it as a storage backend with the same domain coverage as the other first-party adapters (memory, threads, workflows, observability, agents, and more). ([#17446](https://github.com/mastra-ai/mastra/pull/17446))
8
+
9
+ ```ts
10
+ import { MySQLStore } from '@mastra/mysql';
11
+
12
+ const store = new MySQLStore({
13
+ connectionString: 'mysql://user:password@localhost:3306/mastra',
14
+ });
15
+ ```
16
+
17
+ This release also makes table and index setup reliable on a brand-new database:
18
+ - Fixed store initialization failing on a fresh database. Idempotency for favorites is now enforced by the table's primary key instead of a separate index that MySQL rejected, which previously aborted setup and left the connection pool unusable.
19
+ - Fixed default performance indexes silently failing to be created. Indexes on text columns now include a key-length prefix so they are created instead of skipped.
20
+
21
+ ### Patch Changes
22
+
23
+ - Updated dependencies [[`fa63872`](https://github.com/mastra-ai/mastra/commit/fa6387280954e6b667bec5714b55ba082bc627ff), [`d779de3`](https://github.com/mastra-ai/mastra/commit/d779de3cd9d2e7ed8110547190e2f15e786a0e41), [`1750c97`](https://github.com/mastra-ai/mastra/commit/1750c975d6179fbf6db2813b15229d4f8f23fc55), [`9283971`](https://github.com/mastra-ai/mastra/commit/928397157009b4aef4d5fdf3a0a273cb371beb55), [`f07b646`](https://github.com/mastra-ai/mastra/commit/f07b64604ab7d25391179790b7fd4823df9e2dff), [`d8838ae`](https://github.com/mastra-ai/mastra/commit/d8838ae80b69780361693d27098f7f6684af12fe), [`40f9297`](https://github.com/mastra-ai/mastra/commit/40f9297003b921c62373d3e8d3a4bda76c9f6de3), [`19a8658`](https://github.com/mastra-ai/mastra/commit/19a86589c788ef48bb6c1b0612cc82a201857379), [`0f0d1ba`](https://github.com/mastra-ai/mastra/commit/0f0d1ba67bfcb2204e571401662f1eceefc03357), [`a18775a`](https://github.com/mastra-ai/mastra/commit/a18775a693172546ee2378d39b67d4e32895b251), [`1baf2d1`](https://github.com/mastra-ai/mastra/commit/1baf2d152c6881338ff8f114633d5316fe13dd15), [`8c31bcd`](https://github.com/mastra-ai/mastra/commit/8c31bcdb00e597880d5939b1b7d7566fbe5dacae), [`0e32507`](https://github.com/mastra-ai/mastra/commit/0e32507962cdfa5569b7bda5bc6fb3dd34e40b03), [`95b14cd`](https://github.com/mastra-ai/mastra/commit/95b14cdd820e86d97ac05fe568424c513a252e31), [`07c3de7`](https://github.com/mastra-ai/mastra/commit/07c3de7f7bc418beccaea3b5e6b7f7cdda79d492), [`0bf2d93`](https://github.com/mastra-ai/mastra/commit/0bf2d932d20e2936f2d9abb8c0a86e24fbc97ec6), [`a659a77`](https://github.com/mastra-ai/mastra/commit/a659a779bdebe3a52a518c56d2260592d0240fe0), [`aa36be2`](https://github.com/mastra-ai/mastra/commit/aa36be23aa513b7dc53cb8ca16b7fab8f20e43ad), [`3332be9`](https://github.com/mastra-ai/mastra/commit/3332be9701ecd77aba840959d9a1d1ce7aef02d3), [`212c635`](https://github.com/mastra-ai/mastra/commit/212c635203e61d036ab41db8ff86c3893dc795b3), [`d8838ae`](https://github.com/mastra-ai/mastra/commit/d8838ae80b69780361693d27098f7f6684af12fe), [`9aa5a73`](https://github.com/mastra-ai/mastra/commit/9aa5a73e7e110f6e9365eec69364a33d5f03bb56), [`f73c789`](https://github.com/mastra-ai/mastra/commit/f73c789e8ef21561580395d2c410119cab5848c8), [`8bd16da`](https://github.com/mastra-ai/mastra/commit/8bd16da73a4cb874d739373643dbd6a6e7f88684), [`c8630f8`](https://github.com/mastra-ai/mastra/commit/c8630f80d4f40cb5d22e60ab162b618b1907167a), [`94dfef6`](https://github.com/mastra-ai/mastra/commit/94dfef6e2bf19a88467ea3940afcbce88a433f0f), [`47f71dc`](https://github.com/mastra-ai/mastra/commit/47f71dc6fbcbd12d71e21a979e676e20a02bd77d), [`50ceae2`](https://github.com/mastra-ai/mastra/commit/50ceae270878e2f8fb2b2c6c2faab09df0007c8a), [`a122f79`](https://github.com/mastra-ai/mastra/commit/a122f79427ae225ec79c7b2ed46278da48d04b17), [`8cdde58`](https://github.com/mastra-ai/mastra/commit/8cdde5875bbba6702d9df226f2b20232b8d75d6c), [`3a081c1`](https://github.com/mastra-ai/mastra/commit/3a081c1255c5ae8c99f6dad91cc612934ef6f2bd), [`49f8abc`](https://github.com/mastra-ai/mastra/commit/49f8abce8258e4f2f87bd326acfbdb641264a47c), [`847ff1e`](https://github.com/mastra-ai/mastra/commit/847ff1e0d94368d94b2e173e4e0908e115568ef3), [`259d409`](https://github.com/mastra-ai/mastra/commit/259d409a514174299dbde1ff5e1121209b3ba850), [`9e16c68`](https://github.com/mastra-ai/mastra/commit/9e16c6818b6485ccb43df28aba6f3a2219d28662), [`cefca33`](https://github.com/mastra-ai/mastra/commit/cefca33ae666e69810c935fedf95a929c173d1d7), [`d00e8c5`](https://github.com/mastra-ai/mastra/commit/d00e8c50daebe5bce5bf2f48bde39c86fc3d2fe4), [`36fa7e2`](https://github.com/mastra-ai/mastra/commit/36fa7e24d14e58a1eb46147097b32f583e5b8775), [`87e9774`](https://github.com/mastra-ai/mastra/commit/87e97741c1e493cd6d62f478eb810b49bda4d57c), [`65a72e7`](https://github.com/mastra-ai/mastra/commit/65a72e70c25eedea8ff985a6624b96be2850236b), [`fe9eacd`](https://github.com/mastra-ai/mastra/commit/fe9eacd9545a0a9d64aad31c9fa90294a425289e), [`4c02027`](https://github.com/mastra-ai/mastra/commit/4c020277235eaa6b1dc957c90ad0639eef213992), [`0f77241`](https://github.com/mastra-ai/mastra/commit/0f7724108806703799a8ba80ad0f09414afd5066), [`92ff509`](https://github.com/mastra-ai/mastra/commit/92ff5098ef8a990438ca038077021a5f7541ec1d), [`3fce5e7`](https://github.com/mastra-ai/mastra/commit/3fce5e70d011d289043e75003ef3336ed4aa43c3), [`a763592`](https://github.com/mastra-ai/mastra/commit/a763592c3db46963ef1011cfe16fe372816e775e), [`db79c86`](https://github.com/mastra-ai/mastra/commit/db79c86c60723d57e02f9636ca2611bd4515f194), [`6855012`](https://github.com/mastra-ai/mastra/commit/685501247cc4717506f3e89beed03509d63a5370), [`80c7737`](https://github.com/mastra-ai/mastra/commit/80c7737e32d7917b5f356957d67c169d01744fd3), [`7fef31c`](https://github.com/mastra-ai/mastra/commit/7fef31c0d2a6d362a43a647a8a4f6ab893758a23), [`7fef31c`](https://github.com/mastra-ai/mastra/commit/7fef31c0d2a6d362a43a647a8a4f6ab893758a23), [`3f1cf47`](https://github.com/mastra-ai/mastra/commit/3f1cf476f74c1e4cc2df908837e05853a5347e31)]:
24
+ - @mastra/core@0.0.0-deploy-alex-2-20260602122535
25
+
26
+ ## 0.1.0-alpha.0
27
+
28
+ ### Minor Changes
29
+
30
+ - Added the MySQL storage adapter for Mastra. Use it as a storage backend with the same domain coverage as the other first-party adapters (memory, threads, workflows, observability, agents, and more). ([#17446](https://github.com/mastra-ai/mastra/pull/17446))
31
+
32
+ ```ts
33
+ import { MySQLStore } from '@mastra/mysql';
34
+
35
+ const store = new MySQLStore({
36
+ connectionString: 'mysql://user:password@localhost:3306/mastra',
37
+ });
38
+ ```
39
+
40
+ This release also makes table and index setup reliable on a brand-new database:
41
+ - Fixed store initialization failing on a fresh database. Idempotency for favorites is now enforced by the table's primary key instead of a separate index that MySQL rejected, which previously aborted setup and left the connection pool unusable.
42
+ - Fixed default performance indexes silently failing to be created. Indexes on text columns now include a key-length prefix so they are created instead of skipped.
43
+
44
+ ### Patch Changes
45
+
46
+ - Updated dependencies [[`19a8658`](https://github.com/mastra-ai/mastra/commit/19a86589c788ef48bb6c1b0612cc82a201857379), [`a659a77`](https://github.com/mastra-ai/mastra/commit/a659a779bdebe3a52a518c56d2260592d0240fe0), [`3332be9`](https://github.com/mastra-ai/mastra/commit/3332be9701ecd77aba840959d9a1d1ce7aef02d3)]:
47
+ - @mastra/core@1.38.0-alpha.6
package/LICENSE.md ADDED
@@ -0,0 +1,30 @@
1
+ Portions of this software are licensed as follows:
2
+
3
+ - All content that resides under any directory named "ee/" within this
4
+ repository, including but not limited to:
5
+ - `packages/core/src/auth/ee/`
6
+ - `packages/server/src/server/auth/ee/`
7
+ is licensed under the license defined in `ee/LICENSE`.
8
+
9
+ - All third-party components incorporated into the Mastra Software are
10
+ licensed under the original license provided by the owner of the
11
+ applicable component.
12
+
13
+ - Content outside of the above-mentioned directories or restrictions is
14
+ available under the "Apache License 2.0" as defined below.
15
+
16
+ # Apache License 2.0
17
+
18
+ Copyright (c) 2025 Kepler Software, Inc.
19
+
20
+ Licensed under the Apache License, Version 2.0 (the "License");
21
+ you may not use this file except in compliance with the License.
22
+ You may obtain a copy of the License at
23
+
24
+ http://www.apache.org/licenses/LICENSE-2.0
25
+
26
+ Unless required by applicable law or agreed to in writing, software
27
+ distributed under the License is distributed on an "AS IS" BASIS,
28
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
29
+ See the License for the specific language governing permissions and
30
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,152 @@
1
+ # @mastra/mysql
2
+
3
+ MySQL storage implementation for Mastra, providing persistent storage for threads, messages, workflows, traces, and more with connection pooling and transaction support.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @mastra/mysql
9
+ ```
10
+
11
+ ## Prerequisites
12
+
13
+ - MySQL 8.0 or higher
14
+
15
+ ## Usage
16
+
17
+ ```typescript
18
+ import { MySQLStore } from '@mastra/mysql';
19
+
20
+ const store = new MySQLStore({
21
+ connectionString: 'mysql://user:password@localhost:3306/mastra',
22
+ });
23
+
24
+ // Create a thread
25
+ await store.saveThread({
26
+ thread: {
27
+ id: 'thread-123',
28
+ resourceId: 'resource-456',
29
+ title: 'My Thread',
30
+ metadata: { key: 'value' },
31
+ createdAt: new Date(),
32
+ updatedAt: new Date(),
33
+ },
34
+ });
35
+
36
+ // Add messages to thread
37
+ await store.saveMessages({
38
+ messages: [
39
+ {
40
+ id: 'msg-789',
41
+ threadId: 'thread-123',
42
+ role: 'user',
43
+ content: { content: 'Hello' },
44
+ resourceId: 'resource-456',
45
+ createdAt: new Date(),
46
+ },
47
+ ],
48
+ });
49
+
50
+ // Query threads and messages
51
+ const savedThread = await store.getThreadById({ threadId: 'thread-123' });
52
+ const messages = await store.listMessages({ threadId: 'thread-123' });
53
+ ```
54
+
55
+ ### With Mastra
56
+
57
+ ```typescript
58
+ import { Mastra } from '@mastra/core';
59
+ import { MySQLStore } from '@mastra/mysql';
60
+
61
+ export const mastra = new Mastra({
62
+ storage: new MySQLStore({
63
+ connectionString: 'mysql://user:password@localhost:3306/mastra',
64
+ }),
65
+ });
66
+ ```
67
+
68
+ ## Configuration
69
+
70
+ `MySQLStore` supports two connection methods:
71
+
72
+ **1. Connection String**
73
+
74
+ ```typescript
75
+ const store = new MySQLStore({
76
+ connectionString: 'mysql://user:password@localhost:3306/mastra',
77
+ });
78
+ ```
79
+
80
+ **2. Host/Port/Database**
81
+
82
+ ```typescript
83
+ const store = new MySQLStore({
84
+ host: 'localhost',
85
+ port: 3306,
86
+ user: 'mastra',
87
+ password: 'mastra',
88
+ database: 'mastra',
89
+ });
90
+ ```
91
+
92
+ ### Optional Configuration
93
+
94
+ - `ssl`: Enable SSL or provide custom SSL options (`true` | `false` | object)
95
+ - `max`: Maximum pool connections (default: `10`)
96
+ - `database`: Override the database name parsed from the connection string
97
+ - `waitForConnections`: Queue requests when the pool is full (default: `true`, host config only)
98
+ - `queueLimit`: Maximum queued connection requests, `0` for unlimited (default: `0`, host config only)
99
+ - `skipDefaultIndexes`: Skip creating the built-in performance indexes during setup (default: `false`)
100
+ - `indexes`: Additional custom indexes to create during setup
101
+
102
+ ## Features
103
+
104
+ - Persistent storage for threads, messages, workflows, scores, datasets, and experiments
105
+ - Full observability/tracing storage (spans and traces)
106
+ - Atomic transactions for data consistency
107
+ - Efficient batch operations
108
+ - Connection pooling via `mysql2`
109
+ - Automatic table and index setup on first use
110
+ - Rich metadata support with JSON columns
111
+ - Timestamp tracking and cascading deletes
112
+
113
+ ## Storage Methods
114
+
115
+ - `saveThread({ thread })`: Create or update a thread
116
+ - `getThreadById({ threadId })`: Get a thread by ID
117
+ - `deleteThread({ threadId })`: Delete a thread and its messages
118
+ - `saveMessages({ messages })`: Save multiple messages in a transaction
119
+ - `listMessages({ threadId, perPage?, page? })`: Get messages for a thread with pagination
120
+ - `deleteMessages(messageIds)`: Delete specific messages
121
+
122
+ ## Development
123
+
124
+ ### Environment Variables
125
+
126
+ The test suite reads the following variables to connect to MySQL, falling back to the defaults shown:
127
+
128
+ - `MYSQL_HOST` (default: `localhost`)
129
+ - `MYSQL_PORT` (default: `3306`)
130
+ - `MYSQL_USER` (default: `mastra`)
131
+ - `MYSQL_PASSWORD` (default: `mastra`)
132
+ - `MYSQL_DB` (default: `mastra`)
133
+
134
+ ### Running Tests
135
+
136
+ Unit tests run without a database:
137
+
138
+ ```bash
139
+ pnpm test src/storage/index.unit.test.ts
140
+ ```
141
+
142
+ Integration tests use Docker to start a MySQL instance, run the suite, and clean up afterward:
143
+
144
+ ```bash
145
+ # Ensure Docker is running
146
+ pnpm test
147
+ ```
148
+
149
+ ## Related Links
150
+
151
+ - [Mastra Storage Documentation](https://mastra.ai/docs)
152
+ - [MySQL Documentation](https://dev.mysql.com/doc/)