@mastra/mssql 0.0.0-mssql-store-20250804200341 → 0.0.0-pgvector-index-fix-20250905222058
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 +267 -3
- package/dist/index.cjs +139 -36
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +139 -36
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/memory/index.d.ts +9 -1
- package/dist/storage/domains/memory/index.d.ts.map +1 -1
- package/dist/storage/domains/scores/index.d.ts +2 -2
- package/dist/storage/domains/scores/index.d.ts.map +1 -1
- package/dist/storage/domains/traces/index.d.ts +1 -1
- package/dist/storage/domains/workflows/index.d.ts +20 -2
- package/dist/storage/domains/workflows/index.d.ts.map +1 -1
- package/dist/storage/index.d.ts +27 -1
- package/dist/storage/index.d.ts.map +1 -1
- package/package.json +22 -8
- package/docker-compose.yaml +0 -14
- package/eslint.config.js +0 -6
- package/src/index.ts +0 -2
- package/src/storage/domains/legacy-evals/index.ts +0 -175
- package/src/storage/domains/memory/index.ts +0 -1024
- package/src/storage/domains/operations/index.ts +0 -401
- package/src/storage/domains/scores/index.ts +0 -289
- package/src/storage/domains/traces/index.ts +0 -212
- package/src/storage/domains/utils.ts +0 -12
- package/src/storage/domains/workflows/index.ts +0 -259
- package/src/storage/index.test.ts +0 -2228
- package/src/storage/index.ts +0 -448
- package/tsconfig.build.json +0 -9
- package/tsconfig.json +0 -5
- package/tsup.config.ts +0 -22
- package/vitest.config.ts +0 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,10 +1,223 @@
|
|
|
1
1
|
# @mastra/mssql
|
|
2
2
|
|
|
3
|
-
## 0.0.0-
|
|
3
|
+
## 0.0.0-pgvector-index-fix-20250905222058
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [0662d02]
|
|
8
|
+
- Updated dependencies [6189844]
|
|
9
|
+
- Updated dependencies [d7a8f59]
|
|
10
|
+
- Updated dependencies [4dda259]
|
|
11
|
+
- Updated dependencies [defed1c]
|
|
12
|
+
- Updated dependencies [6991ced]
|
|
13
|
+
- Updated dependencies [9cb9c42]
|
|
14
|
+
- Updated dependencies [8334859]
|
|
15
|
+
- @mastra/core@0.0.0-pgvector-index-fix-20250905222058
|
|
16
|
+
|
|
17
|
+
## 0.4.0
|
|
4
18
|
|
|
5
19
|
### Minor Changes
|
|
6
20
|
|
|
7
|
-
-
|
|
21
|
+
- 376913a: Update peerdeps of @mastra/core
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- 6f5eb7a: Throw if an empty or whitespace-only threadId is passed when getting messages
|
|
26
|
+
- Updated dependencies [8fbf79e]
|
|
27
|
+
- Updated dependencies [fd83526]
|
|
28
|
+
- Updated dependencies [d0b90ab]
|
|
29
|
+
- Updated dependencies [6f5eb7a]
|
|
30
|
+
- Updated dependencies [a01cf14]
|
|
31
|
+
- Updated dependencies [a9e50ee]
|
|
32
|
+
- Updated dependencies [5397eb4]
|
|
33
|
+
- Updated dependencies [c9f4e4a]
|
|
34
|
+
- Updated dependencies [0acbc80]
|
|
35
|
+
- @mastra/core@0.16.0
|
|
36
|
+
|
|
37
|
+
## 0.4.0-alpha.1
|
|
38
|
+
|
|
39
|
+
### Minor Changes
|
|
40
|
+
|
|
41
|
+
- 376913a: Update peerdeps of @mastra/core
|
|
42
|
+
|
|
43
|
+
### Patch Changes
|
|
44
|
+
|
|
45
|
+
- Updated dependencies [8fbf79e]
|
|
46
|
+
- @mastra/core@0.16.0-alpha.1
|
|
47
|
+
|
|
48
|
+
## 0.3.7-alpha.0
|
|
49
|
+
|
|
50
|
+
### Patch Changes
|
|
51
|
+
|
|
52
|
+
- 6f5eb7a: Throw if an empty or whitespace-only threadId is passed when getting messages
|
|
53
|
+
- Updated dependencies [fd83526]
|
|
54
|
+
- Updated dependencies [d0b90ab]
|
|
55
|
+
- Updated dependencies [6f5eb7a]
|
|
56
|
+
- Updated dependencies [a01cf14]
|
|
57
|
+
- Updated dependencies [a9e50ee]
|
|
58
|
+
- Updated dependencies [5397eb4]
|
|
59
|
+
- Updated dependencies [c9f4e4a]
|
|
60
|
+
- Updated dependencies [0acbc80]
|
|
61
|
+
- @mastra/core@0.16.0-alpha.0
|
|
62
|
+
|
|
63
|
+
## 0.3.6
|
|
64
|
+
|
|
65
|
+
### Patch Changes
|
|
66
|
+
|
|
67
|
+
- de3cbc6: Update the `package.json` file to include additional fields like `repository`, `homepage` or `files`.
|
|
68
|
+
- f0dfcac: updated core peerdep
|
|
69
|
+
- Updated dependencies [ab48c97]
|
|
70
|
+
- Updated dependencies [85ef90b]
|
|
71
|
+
- Updated dependencies [aedbbfa]
|
|
72
|
+
- Updated dependencies [ff89505]
|
|
73
|
+
- Updated dependencies [637f323]
|
|
74
|
+
- Updated dependencies [de3cbc6]
|
|
75
|
+
- Updated dependencies [c19bcf7]
|
|
76
|
+
- Updated dependencies [4474d04]
|
|
77
|
+
- Updated dependencies [183dc95]
|
|
78
|
+
- Updated dependencies [a1111e2]
|
|
79
|
+
- Updated dependencies [b42a961]
|
|
80
|
+
- Updated dependencies [61debef]
|
|
81
|
+
- Updated dependencies [9beaeff]
|
|
82
|
+
- Updated dependencies [29de0e1]
|
|
83
|
+
- Updated dependencies [f643c65]
|
|
84
|
+
- Updated dependencies [00c74e7]
|
|
85
|
+
- Updated dependencies [fef7375]
|
|
86
|
+
- Updated dependencies [e3d8fea]
|
|
87
|
+
- Updated dependencies [45e4d39]
|
|
88
|
+
- Updated dependencies [9eee594]
|
|
89
|
+
- Updated dependencies [7149d8d]
|
|
90
|
+
- Updated dependencies [822c2e8]
|
|
91
|
+
- Updated dependencies [979912c]
|
|
92
|
+
- Updated dependencies [7dcf4c0]
|
|
93
|
+
- Updated dependencies [4106a58]
|
|
94
|
+
- Updated dependencies [ad78bfc]
|
|
95
|
+
- Updated dependencies [0302f50]
|
|
96
|
+
- Updated dependencies [6ac697e]
|
|
97
|
+
- Updated dependencies [74db265]
|
|
98
|
+
- Updated dependencies [0ce418a]
|
|
99
|
+
- Updated dependencies [af90672]
|
|
100
|
+
- Updated dependencies [8387952]
|
|
101
|
+
- Updated dependencies [7f3b8da]
|
|
102
|
+
- Updated dependencies [905352b]
|
|
103
|
+
- Updated dependencies [599d04c]
|
|
104
|
+
- Updated dependencies [56041d0]
|
|
105
|
+
- Updated dependencies [3412597]
|
|
106
|
+
- Updated dependencies [5eca5d2]
|
|
107
|
+
- Updated dependencies [f2cda47]
|
|
108
|
+
- Updated dependencies [5de1555]
|
|
109
|
+
- Updated dependencies [cfd377a]
|
|
110
|
+
- Updated dependencies [1ed5a3e]
|
|
111
|
+
- @mastra/core@0.15.3
|
|
112
|
+
|
|
113
|
+
## 0.3.6-alpha.1
|
|
114
|
+
|
|
115
|
+
### Patch Changes
|
|
116
|
+
|
|
117
|
+
- [#7394](https://github.com/mastra-ai/mastra/pull/7394) [`f0dfcac`](https://github.com/mastra-ai/mastra/commit/f0dfcac4458bdf789b975e2d63e984f5d1e7c4d3) Thanks [@NikAiyer](https://github.com/NikAiyer)! - updated core peerdep
|
|
118
|
+
|
|
119
|
+
- Updated dependencies [[`7149d8d`](https://github.com/mastra-ai/mastra/commit/7149d8d4bdc1edf0008e0ca9b7925eb0b8b60dbe)]:
|
|
120
|
+
- @mastra/core@0.15.3-alpha.7
|
|
121
|
+
|
|
122
|
+
## 0.3.6-alpha.0
|
|
123
|
+
|
|
124
|
+
### Patch Changes
|
|
125
|
+
|
|
126
|
+
- [#7343](https://github.com/mastra-ai/mastra/pull/7343) [`de3cbc6`](https://github.com/mastra-ai/mastra/commit/de3cbc61079211431bd30487982ea3653517278e) Thanks [@LekoArts](https://github.com/LekoArts)! - Update the `package.json` file to include additional fields like `repository`, `homepage` or `files`.
|
|
127
|
+
|
|
128
|
+
- Updated dependencies [[`85ef90b`](https://github.com/mastra-ai/mastra/commit/85ef90bb2cd4ae4df855c7ac175f7d392c55c1bf), [`de3cbc6`](https://github.com/mastra-ai/mastra/commit/de3cbc61079211431bd30487982ea3653517278e)]:
|
|
129
|
+
- @mastra/core@0.15.3-alpha.5
|
|
130
|
+
|
|
131
|
+
## 0.3.5
|
|
132
|
+
|
|
133
|
+
### Patch Changes
|
|
134
|
+
|
|
135
|
+
- [`c6113ed`](https://github.com/mastra-ai/mastra/commit/c6113ed7f9df297e130d94436ceee310273d6430) Thanks [@wardpeet](https://github.com/wardpeet)! - Fix peerdpes for @mastra/core
|
|
136
|
+
|
|
137
|
+
- Updated dependencies []:
|
|
138
|
+
- @mastra/core@0.15.2
|
|
139
|
+
|
|
140
|
+
## 0.3.4
|
|
141
|
+
|
|
142
|
+
### Patch Changes
|
|
143
|
+
|
|
144
|
+
- [`95b2aa9`](https://github.com/mastra-ai/mastra/commit/95b2aa908230919e67efcac0d69005a2d5745298) Thanks [@wardpeet](https://github.com/wardpeet)! - Fix peerdeps @mastra/core
|
|
145
|
+
|
|
146
|
+
- Updated dependencies []:
|
|
147
|
+
- @mastra/core@0.15.1
|
|
148
|
+
|
|
149
|
+
## 0.3.3
|
|
150
|
+
|
|
151
|
+
### Patch Changes
|
|
152
|
+
|
|
153
|
+
- [#6994](https://github.com/mastra-ai/mastra/pull/6994) [`0594a70`](https://github.com/mastra-ai/mastra/commit/0594a70ac948d306c7f38765b171c9535e6c78d4) Thanks [@wardpeet](https://github.com/wardpeet)! - Improve type resolving for storage adapters
|
|
154
|
+
|
|
155
|
+
- Updated dependencies [[`0778757`](https://github.com/mastra-ai/mastra/commit/07787570e4addbd501522037bd2542c3d9e26822), [`943a7f3`](https://github.com/mastra-ai/mastra/commit/943a7f3dbc6a8ab3f9b7bc7c8a1c5b319c3d7f56), [`bf504a8`](https://github.com/mastra-ai/mastra/commit/bf504a833051f6f321d832cc7d631f3cb86d657b), [`be49354`](https://github.com/mastra-ai/mastra/commit/be493546dca540101923ec700feb31f9a13939f2), [`d591ab3`](https://github.com/mastra-ai/mastra/commit/d591ab3ecc985c1870c0db347f8d7a20f7360536), [`ba82abe`](https://github.com/mastra-ai/mastra/commit/ba82abe76e869316bb5a9c95e8ea3946f3436fae), [`727f7e5`](https://github.com/mastra-ai/mastra/commit/727f7e5086e62e0dfe3356fb6dcd8bcb420af246), [`e6f5046`](https://github.com/mastra-ai/mastra/commit/e6f50467aff317e67e8bd74c485c3fbe2a5a6db1), [`82d9f64`](https://github.com/mastra-ai/mastra/commit/82d9f647fbe4f0177320e7c05073fce88599aa95), [`2e58325`](https://github.com/mastra-ai/mastra/commit/2e58325beb170f5b92f856e27d915cd26917e5e6), [`1191ce9`](https://github.com/mastra-ai/mastra/commit/1191ce946b40ed291e7877a349f8388e3cff7e5c), [`4189486`](https://github.com/mastra-ai/mastra/commit/4189486c6718fda78347bdf4ce4d3fc33b2236e1), [`ca8ec2f`](https://github.com/mastra-ai/mastra/commit/ca8ec2f61884b9dfec5fc0d5f4f29d281ad13c01), [`9613558`](https://github.com/mastra-ai/mastra/commit/9613558e6475f4710e05d1be7553a32ee7bddc20)]:
|
|
156
|
+
- @mastra/core@0.15.0
|
|
157
|
+
|
|
158
|
+
## 0.3.3-alpha.0
|
|
159
|
+
|
|
160
|
+
### Patch Changes
|
|
161
|
+
|
|
162
|
+
- [#6994](https://github.com/mastra-ai/mastra/pull/6994) [`0594a70`](https://github.com/mastra-ai/mastra/commit/0594a70ac948d306c7f38765b171c9535e6c78d4) Thanks [@wardpeet](https://github.com/wardpeet)! - Improve type resolving for storage adapters
|
|
163
|
+
|
|
164
|
+
- Updated dependencies [[`943a7f3`](https://github.com/mastra-ai/mastra/commit/943a7f3dbc6a8ab3f9b7bc7c8a1c5b319c3d7f56), [`be49354`](https://github.com/mastra-ai/mastra/commit/be493546dca540101923ec700feb31f9a13939f2), [`d591ab3`](https://github.com/mastra-ai/mastra/commit/d591ab3ecc985c1870c0db347f8d7a20f7360536), [`ba82abe`](https://github.com/mastra-ai/mastra/commit/ba82abe76e869316bb5a9c95e8ea3946f3436fae), [`727f7e5`](https://github.com/mastra-ai/mastra/commit/727f7e5086e62e0dfe3356fb6dcd8bcb420af246), [`82d9f64`](https://github.com/mastra-ai/mastra/commit/82d9f647fbe4f0177320e7c05073fce88599aa95), [`4189486`](https://github.com/mastra-ai/mastra/commit/4189486c6718fda78347bdf4ce4d3fc33b2236e1), [`ca8ec2f`](https://github.com/mastra-ai/mastra/commit/ca8ec2f61884b9dfec5fc0d5f4f29d281ad13c01)]:
|
|
165
|
+
- @mastra/core@0.14.2-alpha.1
|
|
166
|
+
|
|
167
|
+
## 0.3.2
|
|
168
|
+
|
|
169
|
+
### Patch Changes
|
|
170
|
+
|
|
171
|
+
- [#6700](https://github.com/mastra-ai/mastra/pull/6700) [`a5a23d9`](https://github.com/mastra-ai/mastra/commit/a5a23d981920d458dc6078919992a5338931ef02) Thanks [@gpanakkal](https://github.com/gpanakkal)! - Add `getMessagesById` method to `MastraStorage` adapters
|
|
172
|
+
|
|
173
|
+
- Updated dependencies [[`6e7e120`](https://github.com/mastra-ai/mastra/commit/6e7e1207d6e8d8b838f9024f90bd10df1181ba27), [`0f00e17`](https://github.com/mastra-ai/mastra/commit/0f00e172953ccdccadb35ed3d70f5e4d89115869), [`217cd7a`](https://github.com/mastra-ai/mastra/commit/217cd7a4ce171e9a575c41bb8c83300f4db03236), [`a5a23d9`](https://github.com/mastra-ai/mastra/commit/a5a23d981920d458dc6078919992a5338931ef02)]:
|
|
174
|
+
- @mastra/core@0.14.1
|
|
175
|
+
|
|
176
|
+
## 0.3.2-alpha.0
|
|
177
|
+
|
|
178
|
+
### Patch Changes
|
|
179
|
+
|
|
180
|
+
- [#6700](https://github.com/mastra-ai/mastra/pull/6700) [`a5a23d9`](https://github.com/mastra-ai/mastra/commit/a5a23d981920d458dc6078919992a5338931ef02) Thanks [@gpanakkal](https://github.com/gpanakkal)! - Add `getMessagesById` method to `MastraStorage` adapters
|
|
181
|
+
|
|
182
|
+
- Updated dependencies [[`6e7e120`](https://github.com/mastra-ai/mastra/commit/6e7e1207d6e8d8b838f9024f90bd10df1181ba27), [`a5a23d9`](https://github.com/mastra-ai/mastra/commit/a5a23d981920d458dc6078919992a5338931ef02)]:
|
|
183
|
+
- @mastra/core@0.14.1-alpha.0
|
|
184
|
+
|
|
185
|
+
## 0.3.1
|
|
186
|
+
|
|
187
|
+
### Patch Changes
|
|
188
|
+
|
|
189
|
+
- 03997ae: Update peerdeps
|
|
190
|
+
- Updated dependencies [227c7e6]
|
|
191
|
+
- Updated dependencies [12cae67]
|
|
192
|
+
- Updated dependencies [fd3a3eb]
|
|
193
|
+
- Updated dependencies [6faaee5]
|
|
194
|
+
- Updated dependencies [4232b14]
|
|
195
|
+
- Updated dependencies [a89de7e]
|
|
196
|
+
- Updated dependencies [5a37d0c]
|
|
197
|
+
- Updated dependencies [4bde0cb]
|
|
198
|
+
- Updated dependencies [cf4f357]
|
|
199
|
+
- Updated dependencies [ad888a2]
|
|
200
|
+
- Updated dependencies [481751d]
|
|
201
|
+
- Updated dependencies [2454423]
|
|
202
|
+
- Updated dependencies [194e395]
|
|
203
|
+
- Updated dependencies [a722c0b]
|
|
204
|
+
- Updated dependencies [c30bca8]
|
|
205
|
+
- Updated dependencies [3b5fec7]
|
|
206
|
+
- Updated dependencies [a8f129d]
|
|
207
|
+
- @mastra/core@0.14.0
|
|
208
|
+
|
|
209
|
+
## 0.3.1-alpha.0
|
|
210
|
+
|
|
211
|
+
### Patch Changes
|
|
212
|
+
|
|
213
|
+
- 03997ae: Update peerdeps
|
|
214
|
+
- @mastra/core@0.14.0-alpha.7
|
|
215
|
+
|
|
216
|
+
## 0.3.0
|
|
217
|
+
|
|
218
|
+
### Minor Changes
|
|
219
|
+
|
|
220
|
+
- 8c5a2b0: feat(mssql): implement comprehensive scoring system, enhance storage operations & format storage into domains
|
|
8
221
|
- Add full CRUD operations for scoring system (getScoreById, saveScore, getScoresByScorerId, etc.)
|
|
9
222
|
- Implement message deletion functionality with thread timestamp updates
|
|
10
223
|
- Enhance thread management with sorting options and improved pagination
|
|
@@ -21,13 +234,64 @@
|
|
|
21
234
|
|
|
22
235
|
### Patch Changes
|
|
23
236
|
|
|
237
|
+
- 2871020: update safelyParseJSON to check for value of param when handling parse
|
|
238
|
+
- 4a406ec: fixes TypeScript declaration file imports to ensure proper ESM compatibility
|
|
239
|
+
- Updated dependencies [cb36de0]
|
|
240
|
+
- Updated dependencies [d0496e6]
|
|
241
|
+
- Updated dependencies [a82b851]
|
|
242
|
+
- Updated dependencies [ea0c5f2]
|
|
243
|
+
- Updated dependencies [41a0a0e]
|
|
244
|
+
- Updated dependencies [2871020]
|
|
24
245
|
- Updated dependencies [94f4812]
|
|
25
246
|
- Updated dependencies [e202b82]
|
|
26
247
|
- Updated dependencies [e00f6a0]
|
|
248
|
+
- Updated dependencies [4a406ec]
|
|
249
|
+
- Updated dependencies [b0e43c1]
|
|
250
|
+
- Updated dependencies [5d377e5]
|
|
251
|
+
- Updated dependencies [1fb812e]
|
|
252
|
+
- Updated dependencies [35c5798]
|
|
253
|
+
- @mastra/core@0.13.0
|
|
254
|
+
|
|
255
|
+
## 0.3.0-alpha.1
|
|
256
|
+
|
|
257
|
+
### Patch Changes
|
|
258
|
+
|
|
259
|
+
- 2871020: update safelyParseJSON to check for value of param when handling parse
|
|
260
|
+
- 4a406ec: fixes TypeScript declaration file imports to ensure proper ESM compatibility
|
|
261
|
+
- Updated dependencies [cb36de0]
|
|
262
|
+
- Updated dependencies [a82b851]
|
|
263
|
+
- Updated dependencies [41a0a0e]
|
|
264
|
+
- Updated dependencies [2871020]
|
|
265
|
+
- Updated dependencies [4a406ec]
|
|
266
|
+
- Updated dependencies [5d377e5]
|
|
267
|
+
- @mastra/core@0.13.0-alpha.2
|
|
268
|
+
|
|
269
|
+
## 0.3.0-alpha.0
|
|
270
|
+
|
|
271
|
+
### Minor Changes
|
|
272
|
+
|
|
273
|
+
- 8c5a2b0: feat(mssql): implement comprehensive scoring system, enhance storage operations & format storage into domains
|
|
274
|
+
- Add full CRUD operations for scoring system (getScoreById, saveScore, getScoresByScorerId, etc.)
|
|
275
|
+
- Implement message deletion functionality with thread timestamp updates
|
|
276
|
+
- Enhance thread management with sorting options and improved pagination
|
|
277
|
+
- Add batch trace insertion for improved performance
|
|
278
|
+
- Implement proper storage domain initialization with all operation bindings
|
|
279
|
+
- Enhance message parsing and formatting with better v1/v2 support
|
|
280
|
+
- Improve table operations with better foreign key handling
|
|
281
|
+
- Add float data type support in schema creation
|
|
282
|
+
- Enhance timestamp handling with proper SQL DateTime2 usage
|
|
283
|
+
- Update core dependency to latest version
|
|
284
|
+
- Format storage into domains and separate these into different files
|
|
285
|
+
|
|
286
|
+
BREAKING CHANGE: deleteMessages support is now enabled (was previously false)
|
|
287
|
+
|
|
288
|
+
### Patch Changes
|
|
289
|
+
|
|
290
|
+
- Updated dependencies [ea0c5f2]
|
|
27
291
|
- Updated dependencies [b0e43c1]
|
|
28
292
|
- Updated dependencies [1fb812e]
|
|
29
293
|
- Updated dependencies [35c5798]
|
|
30
|
-
- @mastra/core@0.
|
|
294
|
+
- @mastra/core@0.13.0-alpha.1
|
|
31
295
|
|
|
32
296
|
## 0.2.3
|
|
33
297
|
|
package/dist/index.cjs
CHANGED
|
@@ -467,6 +467,7 @@ var MemoryMSSQL = class extends storage.MemoryStorage {
|
|
|
467
467
|
selectBy,
|
|
468
468
|
orderByStatement
|
|
469
469
|
}) {
|
|
470
|
+
if (!threadId.trim()) throw new Error("threadId must be a non-empty string");
|
|
470
471
|
const include = selectBy?.include;
|
|
471
472
|
if (!include) return null;
|
|
472
473
|
const unionQueries = [];
|
|
@@ -538,11 +539,12 @@ var MemoryMSSQL = class extends storage.MemoryStorage {
|
|
|
538
539
|
return dedupedRows;
|
|
539
540
|
}
|
|
540
541
|
async getMessages(args) {
|
|
541
|
-
const { threadId, format, selectBy } = args;
|
|
542
|
+
const { threadId, resourceId, format, selectBy } = args;
|
|
542
543
|
const selectStatement = `SELECT seq_id, id, content, role, type, [createdAt], thread_id AS threadId, resourceId`;
|
|
543
544
|
const orderByStatement = `ORDER BY [seq_id] DESC`;
|
|
544
545
|
const limit = storage.resolveMessageLimit({ last: selectBy?.last, defaultLimit: 40 });
|
|
545
546
|
try {
|
|
547
|
+
if (!threadId.trim()) throw new Error("threadId must be a non-empty string");
|
|
546
548
|
let rows = [];
|
|
547
549
|
const include = selectBy?.include || [];
|
|
548
550
|
if (include?.length) {
|
|
@@ -580,7 +582,8 @@ var MemoryMSSQL = class extends storage.MemoryStorage {
|
|
|
580
582
|
domain: error.ErrorDomain.STORAGE,
|
|
581
583
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
582
584
|
details: {
|
|
583
|
-
threadId
|
|
585
|
+
threadId,
|
|
586
|
+
resourceId: resourceId ?? ""
|
|
584
587
|
}
|
|
585
588
|
},
|
|
586
589
|
error$1
|
|
@@ -590,30 +593,65 @@ var MemoryMSSQL = class extends storage.MemoryStorage {
|
|
|
590
593
|
return [];
|
|
591
594
|
}
|
|
592
595
|
}
|
|
593
|
-
async
|
|
594
|
-
|
|
595
|
-
|
|
596
|
+
async getMessagesById({
|
|
597
|
+
messageIds,
|
|
598
|
+
format
|
|
599
|
+
}) {
|
|
600
|
+
if (messageIds.length === 0) return [];
|
|
601
|
+
const selectStatement = `SELECT seq_id, id, content, role, type, [createdAt], thread_id AS threadId, resourceId`;
|
|
596
602
|
const orderByStatement = `ORDER BY [seq_id] DESC`;
|
|
597
|
-
|
|
598
|
-
|
|
603
|
+
try {
|
|
604
|
+
let rows = [];
|
|
605
|
+
let query = `${selectStatement} FROM ${getTableName({ indexName: storage.TABLE_MESSAGES, schemaName: getSchemaName(this.schema) })} WHERE [id] IN (${messageIds.map((_, i) => `@id${i}`).join(", ")})`;
|
|
606
|
+
const request = this.pool.request();
|
|
607
|
+
messageIds.forEach((id, i) => request.input(`id${i}`, id));
|
|
608
|
+
query += ` ${orderByStatement}`;
|
|
609
|
+
const result = await request.query(query);
|
|
610
|
+
const remainingRows = result.recordset || [];
|
|
611
|
+
rows.push(...remainingRows);
|
|
612
|
+
rows.sort((a, b) => {
|
|
613
|
+
const timeDiff = a.seq_id - b.seq_id;
|
|
614
|
+
return timeDiff;
|
|
615
|
+
});
|
|
616
|
+
rows = rows.map(({ seq_id, ...rest }) => rest);
|
|
617
|
+
if (format === `v1`) return this._parseAndFormatMessages(rows, format);
|
|
618
|
+
return this._parseAndFormatMessages(rows, `v2`);
|
|
619
|
+
} catch (error$1) {
|
|
620
|
+
const mastraError = new error.MastraError(
|
|
621
|
+
{
|
|
622
|
+
id: "MASTRA_STORAGE_MSSQL_STORE_GET_MESSAGES_BY_ID_FAILED",
|
|
623
|
+
domain: error.ErrorDomain.STORAGE,
|
|
624
|
+
category: error.ErrorCategory.THIRD_PARTY,
|
|
625
|
+
details: {
|
|
626
|
+
messageIds: JSON.stringify(messageIds)
|
|
627
|
+
}
|
|
628
|
+
},
|
|
629
|
+
error$1
|
|
630
|
+
);
|
|
631
|
+
this.logger?.error?.(mastraError.toString());
|
|
632
|
+
this.logger?.trackException(mastraError);
|
|
633
|
+
return [];
|
|
599
634
|
}
|
|
635
|
+
}
|
|
636
|
+
async getMessagesPaginated(args) {
|
|
637
|
+
const { threadId, resourceId, format, selectBy } = args;
|
|
638
|
+
const { page = 0, perPage: perPageInput, dateRange } = selectBy?.pagination || {};
|
|
600
639
|
try {
|
|
601
|
-
|
|
602
|
-
const { page: page2 = 0, perPage: perPageInput2, dateRange } = selectBy2?.pagination || {};
|
|
640
|
+
if (!threadId.trim()) throw new Error("threadId must be a non-empty string");
|
|
603
641
|
const fromDate = dateRange?.start;
|
|
604
642
|
const toDate = dateRange?.end;
|
|
605
643
|
const selectStatement = `SELECT seq_id, id, content, role, type, [createdAt], thread_id AS threadId, resourceId`;
|
|
606
|
-
const
|
|
607
|
-
let
|
|
608
|
-
if (
|
|
609
|
-
const includeMessages = await this._getIncludedMessages({ threadId
|
|
610
|
-
if (includeMessages)
|
|
644
|
+
const orderByStatement = `ORDER BY [seq_id] DESC`;
|
|
645
|
+
let messages = [];
|
|
646
|
+
if (selectBy?.include?.length) {
|
|
647
|
+
const includeMessages = await this._getIncludedMessages({ threadId, selectBy, orderByStatement });
|
|
648
|
+
if (includeMessages) messages.push(...includeMessages);
|
|
611
649
|
}
|
|
612
|
-
const perPage =
|
|
613
|
-
const currentOffset =
|
|
650
|
+
const perPage = perPageInput !== void 0 ? perPageInput : storage.resolveMessageLimit({ last: selectBy?.last, defaultLimit: 40 });
|
|
651
|
+
const currentOffset = page * perPage;
|
|
614
652
|
const conditions = ["[thread_id] = @threadId"];
|
|
615
653
|
const request = this.pool.request();
|
|
616
|
-
request.input("threadId",
|
|
654
|
+
request.input("threadId", threadId);
|
|
617
655
|
if (fromDate instanceof Date && !isNaN(fromDate.getTime())) {
|
|
618
656
|
conditions.push("[createdAt] >= @fromDate");
|
|
619
657
|
request.input("fromDate", fromDate.toISOString());
|
|
@@ -626,35 +664,35 @@ var MemoryMSSQL = class extends storage.MemoryStorage {
|
|
|
626
664
|
const countQuery = `SELECT COUNT(*) as total FROM ${getTableName({ indexName: storage.TABLE_MESSAGES, schemaName: getSchemaName(this.schema) })} ${whereClause}`;
|
|
627
665
|
const countResult = await request.query(countQuery);
|
|
628
666
|
const total = parseInt(countResult.recordset[0]?.total, 10) || 0;
|
|
629
|
-
if (total === 0 &&
|
|
630
|
-
const parsedIncluded = this._parseAndFormatMessages(
|
|
667
|
+
if (total === 0 && messages.length > 0) {
|
|
668
|
+
const parsedIncluded = this._parseAndFormatMessages(messages, format);
|
|
631
669
|
return {
|
|
632
670
|
messages: parsedIncluded,
|
|
633
671
|
total: parsedIncluded.length,
|
|
634
|
-
page
|
|
672
|
+
page,
|
|
635
673
|
perPage,
|
|
636
674
|
hasMore: false
|
|
637
675
|
};
|
|
638
676
|
}
|
|
639
|
-
const excludeIds =
|
|
677
|
+
const excludeIds = messages.map((m) => m.id);
|
|
640
678
|
if (excludeIds.length > 0) {
|
|
641
679
|
const excludeParams = excludeIds.map((_, idx) => `@id${idx}`);
|
|
642
680
|
conditions.push(`id NOT IN (${excludeParams.join(", ")})`);
|
|
643
681
|
excludeIds.forEach((id, idx) => request.input(`id${idx}`, id));
|
|
644
682
|
}
|
|
645
683
|
const finalWhereClause = `WHERE ${conditions.join(" AND ")}`;
|
|
646
|
-
const dataQuery = `${selectStatement} FROM ${getTableName({ indexName: storage.TABLE_MESSAGES, schemaName: getSchemaName(this.schema) })} ${finalWhereClause} ${
|
|
684
|
+
const dataQuery = `${selectStatement} FROM ${getTableName({ indexName: storage.TABLE_MESSAGES, schemaName: getSchemaName(this.schema) })} ${finalWhereClause} ${orderByStatement} OFFSET @offset ROWS FETCH NEXT @limit ROWS ONLY`;
|
|
647
685
|
request.input("offset", currentOffset);
|
|
648
686
|
request.input("limit", perPage);
|
|
649
687
|
const rowsResult = await request.query(dataQuery);
|
|
650
688
|
const rows = rowsResult.recordset || [];
|
|
651
689
|
rows.sort((a, b) => a.seq_id - b.seq_id);
|
|
652
|
-
|
|
653
|
-
const parsed = this._parseAndFormatMessages(
|
|
690
|
+
messages.push(...rows);
|
|
691
|
+
const parsed = this._parseAndFormatMessages(messages, format);
|
|
654
692
|
return {
|
|
655
693
|
messages: parsed,
|
|
656
694
|
total: total + excludeIds.length,
|
|
657
|
-
page
|
|
695
|
+
page,
|
|
658
696
|
perPage,
|
|
659
697
|
hasMore: currentOffset + rows.length < total
|
|
660
698
|
};
|
|
@@ -666,6 +704,7 @@ var MemoryMSSQL = class extends storage.MemoryStorage {
|
|
|
666
704
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
667
705
|
details: {
|
|
668
706
|
threadId,
|
|
707
|
+
resourceId: resourceId ?? "",
|
|
669
708
|
page
|
|
670
709
|
}
|
|
671
710
|
},
|
|
@@ -1379,18 +1418,25 @@ ${columns}
|
|
|
1379
1418
|
}
|
|
1380
1419
|
}
|
|
1381
1420
|
};
|
|
1382
|
-
function
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
} catch {
|
|
1388
|
-
input = row.input;
|
|
1389
|
-
}
|
|
1421
|
+
function parseJSON(jsonString) {
|
|
1422
|
+
try {
|
|
1423
|
+
return JSON.parse(jsonString);
|
|
1424
|
+
} catch {
|
|
1425
|
+
return jsonString;
|
|
1390
1426
|
}
|
|
1427
|
+
}
|
|
1428
|
+
function transformScoreRow(row) {
|
|
1391
1429
|
return {
|
|
1392
1430
|
...row,
|
|
1393
|
-
input,
|
|
1431
|
+
input: parseJSON(row.input),
|
|
1432
|
+
scorer: parseJSON(row.scorer),
|
|
1433
|
+
preprocessStepResult: parseJSON(row.preprocessStepResult),
|
|
1434
|
+
analyzeStepResult: parseJSON(row.analyzeStepResult),
|
|
1435
|
+
metadata: parseJSON(row.metadata),
|
|
1436
|
+
output: parseJSON(row.output),
|
|
1437
|
+
additionalContext: parseJSON(row.additionalContext),
|
|
1438
|
+
runtimeContext: parseJSON(row.runtimeContext),
|
|
1439
|
+
entity: parseJSON(row.entity),
|
|
1394
1440
|
createdAt: row.createdAt,
|
|
1395
1441
|
updatedAt: row.updatedAt
|
|
1396
1442
|
};
|
|
@@ -1435,13 +1481,32 @@ var ScoresMSSQL = class extends storage.ScoresStorage {
|
|
|
1435
1481
|
async saveScore(score) {
|
|
1436
1482
|
try {
|
|
1437
1483
|
const scoreId = crypto.randomUUID();
|
|
1438
|
-
const {
|
|
1484
|
+
const {
|
|
1485
|
+
scorer,
|
|
1486
|
+
preprocessStepResult,
|
|
1487
|
+
analyzeStepResult,
|
|
1488
|
+
metadata,
|
|
1489
|
+
input,
|
|
1490
|
+
output,
|
|
1491
|
+
additionalContext,
|
|
1492
|
+
runtimeContext,
|
|
1493
|
+
entity,
|
|
1494
|
+
...rest
|
|
1495
|
+
} = score;
|
|
1439
1496
|
await this.operations.insert({
|
|
1440
1497
|
tableName: storage.TABLE_SCORERS,
|
|
1441
1498
|
record: {
|
|
1442
1499
|
id: scoreId,
|
|
1443
1500
|
...rest,
|
|
1444
|
-
input: JSON.stringify(input),
|
|
1501
|
+
input: JSON.stringify(input) || "",
|
|
1502
|
+
output: JSON.stringify(output) || "",
|
|
1503
|
+
preprocessStepResult: preprocessStepResult ? JSON.stringify(preprocessStepResult) : null,
|
|
1504
|
+
analyzeStepResult: analyzeStepResult ? JSON.stringify(analyzeStepResult) : null,
|
|
1505
|
+
metadata: metadata ? JSON.stringify(metadata) : null,
|
|
1506
|
+
additionalContext: additionalContext ? JSON.stringify(additionalContext) : null,
|
|
1507
|
+
runtimeContext: runtimeContext ? JSON.stringify(runtimeContext) : null,
|
|
1508
|
+
entity: entity ? JSON.stringify(entity) : null,
|
|
1509
|
+
scorer: scorer ? JSON.stringify(scorer) : null,
|
|
1445
1510
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1446
1511
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
1447
1512
|
}
|
|
@@ -1812,6 +1877,22 @@ var WorkflowsMSSQL = class extends storage.WorkflowsStorage {
|
|
|
1812
1877
|
this.operations = operations;
|
|
1813
1878
|
this.schema = schema;
|
|
1814
1879
|
}
|
|
1880
|
+
updateWorkflowResults({
|
|
1881
|
+
// workflowName,
|
|
1882
|
+
// runId,
|
|
1883
|
+
// stepId,
|
|
1884
|
+
// result,
|
|
1885
|
+
// runtimeContext,
|
|
1886
|
+
}) {
|
|
1887
|
+
throw new Error("Method not implemented.");
|
|
1888
|
+
}
|
|
1889
|
+
updateWorkflowState({
|
|
1890
|
+
// workflowName,
|
|
1891
|
+
// runId,
|
|
1892
|
+
// opts,
|
|
1893
|
+
}) {
|
|
1894
|
+
throw new Error("Method not implemented.");
|
|
1895
|
+
}
|
|
1815
1896
|
async persistWorkflowSnapshot({
|
|
1816
1897
|
workflowName,
|
|
1817
1898
|
runId,
|
|
@@ -2163,6 +2244,12 @@ var MSSQLStore = class extends storage.MastraStorage {
|
|
|
2163
2244
|
async getMessages(args) {
|
|
2164
2245
|
return this.stores.memory.getMessages(args);
|
|
2165
2246
|
}
|
|
2247
|
+
async getMessagesById({
|
|
2248
|
+
messageIds,
|
|
2249
|
+
format
|
|
2250
|
+
}) {
|
|
2251
|
+
return this.stores.memory.getMessagesById({ messageIds, format });
|
|
2252
|
+
}
|
|
2166
2253
|
async getMessagesPaginated(args) {
|
|
2167
2254
|
return this.stores.memory.getMessagesPaginated(args);
|
|
2168
2255
|
}
|
|
@@ -2193,6 +2280,22 @@ var MSSQLStore = class extends storage.MastraStorage {
|
|
|
2193
2280
|
/**
|
|
2194
2281
|
* Workflows
|
|
2195
2282
|
*/
|
|
2283
|
+
async updateWorkflowResults({
|
|
2284
|
+
workflowName,
|
|
2285
|
+
runId,
|
|
2286
|
+
stepId,
|
|
2287
|
+
result,
|
|
2288
|
+
runtimeContext
|
|
2289
|
+
}) {
|
|
2290
|
+
return this.stores.workflows.updateWorkflowResults({ workflowName, runId, stepId, result, runtimeContext });
|
|
2291
|
+
}
|
|
2292
|
+
async updateWorkflowState({
|
|
2293
|
+
workflowName,
|
|
2294
|
+
runId,
|
|
2295
|
+
opts
|
|
2296
|
+
}) {
|
|
2297
|
+
return this.stores.workflows.updateWorkflowState({ workflowName, runId, opts });
|
|
2298
|
+
}
|
|
2196
2299
|
async persistWorkflowSnapshot({
|
|
2197
2300
|
workflowName,
|
|
2198
2301
|
runId,
|