@mastra/mssql 0.2.1-alpha.0
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/.turbo/turbo-build.log +23 -0
- package/CHANGELOG.md +15 -0
- package/LICENSE.md +15 -0
- package/README.md +96 -0
- package/dist/_tsup-dts-rollup.d.cts +213 -0
- package/dist/_tsup-dts-rollup.d.ts +213 -0
- package/dist/index.cjs +1752 -0
- package/dist/index.d.cts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +1746 -0
- package/docker-compose.yaml +14 -0
- package/eslint.config.js +6 -0
- package/package.json +50 -0
- package/src/index.ts +2 -0
- package/src/storage/index.test.ts +2239 -0
- package/src/storage/index.ts +2044 -0
- package/tsconfig.json +5 -0
- package/vitest.config.ts +12 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
|
|
2
|
+
> @mastra/mssql@0.2.1-alpha.0 build /home/runner/work/mastra/mastra/stores/mssql
|
|
3
|
+
> tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting
|
|
4
|
+
|
|
5
|
+
[34mCLI[39m Building entry: src/index.ts
|
|
6
|
+
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
7
|
+
[34mCLI[39m tsup v8.5.0
|
|
8
|
+
[34mTSC[39m Build start
|
|
9
|
+
[32mTSC[39m ⚡️ Build success in 10417ms
|
|
10
|
+
[34mDTS[39m Build start
|
|
11
|
+
[34mCLI[39m Target: es2022
|
|
12
|
+
Analysis will use the bundled TypeScript version 5.8.3
|
|
13
|
+
[36mWriting package typings: /home/runner/work/mastra/mastra/stores/mssql/dist/_tsup-dts-rollup.d.ts[39m
|
|
14
|
+
Analysis will use the bundled TypeScript version 5.8.3
|
|
15
|
+
[36mWriting package typings: /home/runner/work/mastra/mastra/stores/mssql/dist/_tsup-dts-rollup.d.cts[39m
|
|
16
|
+
[32mDTS[39m ⚡️ Build success in 12492ms
|
|
17
|
+
[34mCLI[39m Cleaning output folder
|
|
18
|
+
[34mESM[39m Build start
|
|
19
|
+
[34mCJS[39m Build start
|
|
20
|
+
[32mESM[39m [1mdist/index.js [22m[32m61.79 KB[39m
|
|
21
|
+
[32mESM[39m ⚡️ Build success in 1450ms
|
|
22
|
+
[32mCJS[39m [1mdist/index.cjs [22m[32m62.90 KB[39m
|
|
23
|
+
[32mCJS[39m ⚡️ Build success in 1973ms
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Changelog for mastra-mssql
|
|
2
|
+
|
|
3
|
+
## 0.2.1-alpha.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 03745fa: mssql provider
|
|
8
|
+
- Updated dependencies [7827943]
|
|
9
|
+
- Updated dependencies [bf1e7e7]
|
|
10
|
+
- Updated dependencies [cbddd18]
|
|
11
|
+
- @mastra/core@0.11.0-alpha.0
|
|
12
|
+
|
|
13
|
+
## 0.1.0
|
|
14
|
+
|
|
15
|
+
- Initial implementation
|
package/LICENSE.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Apache License 2.0
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Kepler Software, Inc.
|
|
4
|
+
|
|
5
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
you may not use this file except in compliance with the License.
|
|
7
|
+
You may obtain a copy of the License at
|
|
8
|
+
|
|
9
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
|
|
11
|
+
Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
See the License for the specific language governing permissions and
|
|
15
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# @mastra/mssql
|
|
2
|
+
|
|
3
|
+
Microsoft SQL Server implementation for Mastra, providing general storage capabilities with connection pooling and transaction support.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @mastra/mssql
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Prerequisites
|
|
12
|
+
|
|
13
|
+
- Microsoft SQL Server 2016 or higher
|
|
14
|
+
- User with privileges to create tables and schemas (if needed)
|
|
15
|
+
|
|
16
|
+
## Usage
|
|
17
|
+
|
|
18
|
+
### Storage
|
|
19
|
+
|
|
20
|
+
```typescript
|
|
21
|
+
import { MSSQLStore } from '@mastra/mssql';
|
|
22
|
+
|
|
23
|
+
const store = new MSSQLStore({
|
|
24
|
+
server: 'localhost',
|
|
25
|
+
port: 1433,
|
|
26
|
+
database: 'mastra',
|
|
27
|
+
user: 'sa',
|
|
28
|
+
password: 'yourStrong(!)Password',
|
|
29
|
+
// options: { encrypt: true, trustServerCertificate: true }, // Optional
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
// Create a thread
|
|
33
|
+
await store.saveThread({
|
|
34
|
+
id: 'thread-123',
|
|
35
|
+
resourceId: 'resource-456',
|
|
36
|
+
title: 'My Thread',
|
|
37
|
+
metadata: { key: 'value' },
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
// Add messages to thread
|
|
41
|
+
await store.saveMessages([
|
|
42
|
+
{
|
|
43
|
+
id: 'msg-789',
|
|
44
|
+
threadId: 'thread-123',
|
|
45
|
+
role: 'user',
|
|
46
|
+
type: 'text',
|
|
47
|
+
content: [{ type: 'text', text: 'Hello' }],
|
|
48
|
+
resourceId: 'resource-456',
|
|
49
|
+
createdAt: new Date(),
|
|
50
|
+
},
|
|
51
|
+
]);
|
|
52
|
+
|
|
53
|
+
// Query threads and messages
|
|
54
|
+
const savedThread = await store.getThreadById({ threadId: 'thread-123' });
|
|
55
|
+
const messages = await store.getMessages({ threadId: 'thread-123' });
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Configuration
|
|
59
|
+
|
|
60
|
+
The MSSQL store can be initialized with either:
|
|
61
|
+
|
|
62
|
+
- `connectionString`: Microsoft SQL Server connection string
|
|
63
|
+
- Configuration object with server, port, database, user, and password
|
|
64
|
+
|
|
65
|
+
Connection pool settings are managed by the [mssql](https://www.npmjs.com/package/mssql) package.
|
|
66
|
+
|
|
67
|
+
## Features
|
|
68
|
+
|
|
69
|
+
- Thread and message storage with JSON support
|
|
70
|
+
- Atomic transactions for data consistency
|
|
71
|
+
- Efficient batch operations
|
|
72
|
+
- Rich metadata support
|
|
73
|
+
- Timestamp tracking
|
|
74
|
+
- Cascading deletes (emulated)
|
|
75
|
+
|
|
76
|
+
## Storage Methods
|
|
77
|
+
|
|
78
|
+
- `saveThread({ thread })`: Create or update a thread
|
|
79
|
+
- `getThreadById({ threadId })`: Get a thread by ID
|
|
80
|
+
- `deleteThread({ threadId })`: Delete a thread and its messages
|
|
81
|
+
- `saveMessages({ messages })`: Save multiple messages in a transaction
|
|
82
|
+
- `getMessages({ threadId })`: Get all messages for a thread
|
|
83
|
+
- `updateMessages({ messages })`: Update messages by ID
|
|
84
|
+
- `getThreadsByResourceIdPaginated({ resourceId, page, perPage })`: Paginated thread listing
|
|
85
|
+
- `getMessagesPaginated({ threadId, selectBy })`: Paginated message listing
|
|
86
|
+
- `clearTable({ tableName })`: Remove all rows from a table (with cascade)
|
|
87
|
+
- `createTable({ tableName, schema })`: Create a table if it does not exist
|
|
88
|
+
- `alterTable({ tableName, schema, ifNotExists })`: Add columns if they do not exist
|
|
89
|
+
- `saveResource({ resource })`: Save a resource
|
|
90
|
+
- `getResourceById({ resourceId })`: Get a resource by ID
|
|
91
|
+
- `updateResource({ resourceId, ... })`: Update a resource
|
|
92
|
+
|
|
93
|
+
## Related Links
|
|
94
|
+
|
|
95
|
+
- [Microsoft SQL Server Documentation](https://docs.microsoft.com/en-us/sql/sql-server/)
|
|
96
|
+
- [node-mssql Documentation](https://www.npmjs.com/package/mssql)
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import type { EvalRow } from '@mastra/core/storage';
|
|
2
|
+
import type { MastraMessageContentV2 } from '@mastra/core/agent';
|
|
3
|
+
import type { MastraMessageV1 } from '@mastra/core/memory';
|
|
4
|
+
import type { MastraMessageV2 } from '@mastra/core/agent';
|
|
5
|
+
import { MastraStorage } from '@mastra/core/storage';
|
|
6
|
+
import type { PaginationArgs } from '@mastra/core/storage';
|
|
7
|
+
import type { PaginationInfo } from '@mastra/core/storage';
|
|
8
|
+
import sql from 'mssql';
|
|
9
|
+
import type { StorageColumn } from '@mastra/core/storage';
|
|
10
|
+
import type { StorageGetMessagesArg } from '@mastra/core/storage';
|
|
11
|
+
import type { StorageResourceType } from '@mastra/core/storage';
|
|
12
|
+
import type { StorageThreadType } from '@mastra/core/memory';
|
|
13
|
+
import type { TABLE_NAMES } from '@mastra/core/storage';
|
|
14
|
+
import type { WorkflowRun } from '@mastra/core/storage';
|
|
15
|
+
import type { WorkflowRuns } from '@mastra/core/storage';
|
|
16
|
+
import type { WorkflowRunState } from '@mastra/core/workflows';
|
|
17
|
+
|
|
18
|
+
declare type MastraMessageV2WithTypedContent = Omit<MastraMessageV2, 'content'> & {
|
|
19
|
+
content: MastraMessageContentV2;
|
|
20
|
+
};
|
|
21
|
+
export { MastraMessageV2WithTypedContent }
|
|
22
|
+
export { MastraMessageV2WithTypedContent as MastraMessageV2WithTypedContent_alias_1 }
|
|
23
|
+
|
|
24
|
+
declare type MSSQLConfig = MSSQLConfigType;
|
|
25
|
+
export { MSSQLConfig }
|
|
26
|
+
export { MSSQLConfig as MSSQLConfig_alias_1 }
|
|
27
|
+
|
|
28
|
+
declare type MSSQLConfigType = {
|
|
29
|
+
schemaName?: string;
|
|
30
|
+
} & ({
|
|
31
|
+
server: string;
|
|
32
|
+
port: number;
|
|
33
|
+
database: string;
|
|
34
|
+
user: string;
|
|
35
|
+
password: string;
|
|
36
|
+
options?: sql.IOptions;
|
|
37
|
+
} | {
|
|
38
|
+
connectionString: string;
|
|
39
|
+
});
|
|
40
|
+
export { MSSQLConfigType }
|
|
41
|
+
export { MSSQLConfigType as MSSQLConfigType_alias_1 }
|
|
42
|
+
|
|
43
|
+
declare class MSSQLStore extends MastraStorage {
|
|
44
|
+
pool: sql.ConnectionPool;
|
|
45
|
+
private schema?;
|
|
46
|
+
private setupSchemaPromise;
|
|
47
|
+
private schemaSetupComplete;
|
|
48
|
+
private isConnected;
|
|
49
|
+
constructor(config: MSSQLConfigType);
|
|
50
|
+
init(): Promise<void>;
|
|
51
|
+
private _performInitializationAndStore;
|
|
52
|
+
get supports(): {
|
|
53
|
+
selectByIncludeResourceScope: boolean;
|
|
54
|
+
resourceWorkingMemory: boolean;
|
|
55
|
+
};
|
|
56
|
+
private getTableName;
|
|
57
|
+
private getSchemaName;
|
|
58
|
+
private transformEvalRow;
|
|
59
|
+
/** @deprecated use getEvals instead */
|
|
60
|
+
getEvalsByAgentName(agentName: string, type?: 'test' | 'live'): Promise<EvalRow[]>;
|
|
61
|
+
batchInsert({ tableName, records }: {
|
|
62
|
+
tableName: TABLE_NAMES;
|
|
63
|
+
records: Record<string, any>[];
|
|
64
|
+
}): Promise<void>;
|
|
65
|
+
/** @deprecated use getTracesPaginated instead*/
|
|
66
|
+
getTraces(args: {
|
|
67
|
+
name?: string;
|
|
68
|
+
scope?: string;
|
|
69
|
+
attributes?: Record<string, string>;
|
|
70
|
+
filters?: Record<string, any>;
|
|
71
|
+
page: number;
|
|
72
|
+
perPage?: number;
|
|
73
|
+
fromDate?: Date;
|
|
74
|
+
toDate?: Date;
|
|
75
|
+
}): Promise<any[]>;
|
|
76
|
+
getTracesPaginated(args: {
|
|
77
|
+
name?: string;
|
|
78
|
+
scope?: string;
|
|
79
|
+
attributes?: Record<string, string>;
|
|
80
|
+
filters?: Record<string, any>;
|
|
81
|
+
} & PaginationArgs): Promise<PaginationInfo & {
|
|
82
|
+
traces: any[];
|
|
83
|
+
}>;
|
|
84
|
+
private setupSchema;
|
|
85
|
+
protected getSqlType(type: StorageColumn['type'], isPrimaryKey?: boolean): string;
|
|
86
|
+
createTable({ tableName, schema, }: {
|
|
87
|
+
tableName: TABLE_NAMES;
|
|
88
|
+
schema: Record<string, StorageColumn>;
|
|
89
|
+
}): Promise<void>;
|
|
90
|
+
protected getDefaultValue(type: StorageColumn['type']): string;
|
|
91
|
+
alterTable({ tableName, schema, ifNotExists, }: {
|
|
92
|
+
tableName: TABLE_NAMES;
|
|
93
|
+
schema: Record<string, StorageColumn>;
|
|
94
|
+
ifNotExists: string[];
|
|
95
|
+
}): Promise<void>;
|
|
96
|
+
clearTable({ tableName }: {
|
|
97
|
+
tableName: TABLE_NAMES;
|
|
98
|
+
}): Promise<void>;
|
|
99
|
+
insert({ tableName, record }: {
|
|
100
|
+
tableName: TABLE_NAMES;
|
|
101
|
+
record: Record<string, any>;
|
|
102
|
+
}): Promise<void>;
|
|
103
|
+
load<R>({ tableName, keys }: {
|
|
104
|
+
tableName: TABLE_NAMES;
|
|
105
|
+
keys: Record<string, string>;
|
|
106
|
+
}): Promise<R | null>;
|
|
107
|
+
getThreadById({ threadId }: {
|
|
108
|
+
threadId: string;
|
|
109
|
+
}): Promise<StorageThreadType | null>;
|
|
110
|
+
getThreadsByResourceIdPaginated(args: {
|
|
111
|
+
resourceId: string;
|
|
112
|
+
} & PaginationArgs): Promise<PaginationInfo & {
|
|
113
|
+
threads: StorageThreadType[];
|
|
114
|
+
}>;
|
|
115
|
+
saveThread({ thread }: {
|
|
116
|
+
thread: StorageThreadType;
|
|
117
|
+
}): Promise<StorageThreadType>;
|
|
118
|
+
/**
|
|
119
|
+
* @deprecated use getThreadsByResourceIdPaginated instead
|
|
120
|
+
*/
|
|
121
|
+
getThreadsByResourceId(args: {
|
|
122
|
+
resourceId: string;
|
|
123
|
+
}): Promise<StorageThreadType[]>;
|
|
124
|
+
/**
|
|
125
|
+
* Updates a thread's title and metadata, merging with existing metadata. Returns the updated thread.
|
|
126
|
+
*/
|
|
127
|
+
updateThread({ id, title, metadata, }: {
|
|
128
|
+
id: string;
|
|
129
|
+
title: string;
|
|
130
|
+
metadata: Record<string, unknown>;
|
|
131
|
+
}): Promise<StorageThreadType>;
|
|
132
|
+
deleteThread({ threadId }: {
|
|
133
|
+
threadId: string;
|
|
134
|
+
}): Promise<void>;
|
|
135
|
+
private _getIncludedMessages;
|
|
136
|
+
/**
|
|
137
|
+
* @deprecated use getMessagesPaginated instead
|
|
138
|
+
*/
|
|
139
|
+
getMessages(args: StorageGetMessagesArg & {
|
|
140
|
+
format?: 'v1';
|
|
141
|
+
}): Promise<MastraMessageV1[]>;
|
|
142
|
+
getMessages(args: StorageGetMessagesArg & {
|
|
143
|
+
format: 'v2';
|
|
144
|
+
}): Promise<MastraMessageV2[]>;
|
|
145
|
+
getMessagesPaginated(args: StorageGetMessagesArg & {
|
|
146
|
+
format?: 'v1' | 'v2';
|
|
147
|
+
}): Promise<PaginationInfo & {
|
|
148
|
+
messages: MastraMessageV1[] | MastraMessageV2[];
|
|
149
|
+
}>;
|
|
150
|
+
private _parseAndFormatMessages;
|
|
151
|
+
saveMessages(args: {
|
|
152
|
+
messages: MastraMessageV1[];
|
|
153
|
+
format?: undefined | 'v1';
|
|
154
|
+
}): Promise<MastraMessageV1[]>;
|
|
155
|
+
saveMessages(args: {
|
|
156
|
+
messages: MastraMessageV2[];
|
|
157
|
+
format: 'v2';
|
|
158
|
+
}): Promise<MastraMessageV2[]>;
|
|
159
|
+
persistWorkflowSnapshot({ workflowName, runId, snapshot, }: {
|
|
160
|
+
workflowName: string;
|
|
161
|
+
runId: string;
|
|
162
|
+
snapshot: WorkflowRunState;
|
|
163
|
+
}): Promise<void>;
|
|
164
|
+
loadWorkflowSnapshot({ workflowName, runId, }: {
|
|
165
|
+
workflowName: string;
|
|
166
|
+
runId: string;
|
|
167
|
+
}): Promise<WorkflowRunState | null>;
|
|
168
|
+
private hasColumn;
|
|
169
|
+
private parseWorkflowRun;
|
|
170
|
+
getWorkflowRuns({ workflowName, fromDate, toDate, limit, offset, resourceId, }?: {
|
|
171
|
+
workflowName?: string;
|
|
172
|
+
fromDate?: Date;
|
|
173
|
+
toDate?: Date;
|
|
174
|
+
limit?: number;
|
|
175
|
+
offset?: number;
|
|
176
|
+
resourceId?: string;
|
|
177
|
+
}): Promise<WorkflowRuns>;
|
|
178
|
+
getWorkflowRunById({ runId, workflowName, }: {
|
|
179
|
+
runId: string;
|
|
180
|
+
workflowName?: string;
|
|
181
|
+
}): Promise<WorkflowRun | null>;
|
|
182
|
+
updateMessages({ messages, }: {
|
|
183
|
+
messages: (Partial<Omit<MastraMessageV2, 'createdAt'>> & {
|
|
184
|
+
id: string;
|
|
185
|
+
content?: {
|
|
186
|
+
metadata?: MastraMessageContentV2['metadata'];
|
|
187
|
+
content?: MastraMessageContentV2['content'];
|
|
188
|
+
};
|
|
189
|
+
})[];
|
|
190
|
+
}): Promise<MastraMessageV2[]>;
|
|
191
|
+
close(): Promise<void>;
|
|
192
|
+
getEvals(options?: {
|
|
193
|
+
agentName?: string;
|
|
194
|
+
type?: 'test' | 'live';
|
|
195
|
+
} & PaginationArgs): Promise<PaginationInfo & {
|
|
196
|
+
evals: EvalRow[];
|
|
197
|
+
}>;
|
|
198
|
+
saveResource({ resource }: {
|
|
199
|
+
resource: StorageResourceType;
|
|
200
|
+
}): Promise<StorageResourceType>;
|
|
201
|
+
updateResource({ resourceId, workingMemory, metadata, }: {
|
|
202
|
+
resourceId: string;
|
|
203
|
+
workingMemory?: string;
|
|
204
|
+
metadata?: Record<string, unknown>;
|
|
205
|
+
}): Promise<StorageResourceType>;
|
|
206
|
+
getResourceById({ resourceId }: {
|
|
207
|
+
resourceId: string;
|
|
208
|
+
}): Promise<StorageResourceType | null>;
|
|
209
|
+
}
|
|
210
|
+
export { MSSQLStore }
|
|
211
|
+
export { MSSQLStore as MSSQLStore_alias_1 }
|
|
212
|
+
|
|
213
|
+
export { }
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import type { EvalRow } from '@mastra/core/storage';
|
|
2
|
+
import type { MastraMessageContentV2 } from '@mastra/core/agent';
|
|
3
|
+
import type { MastraMessageV1 } from '@mastra/core/memory';
|
|
4
|
+
import type { MastraMessageV2 } from '@mastra/core/agent';
|
|
5
|
+
import { MastraStorage } from '@mastra/core/storage';
|
|
6
|
+
import type { PaginationArgs } from '@mastra/core/storage';
|
|
7
|
+
import type { PaginationInfo } from '@mastra/core/storage';
|
|
8
|
+
import sql from 'mssql';
|
|
9
|
+
import type { StorageColumn } from '@mastra/core/storage';
|
|
10
|
+
import type { StorageGetMessagesArg } from '@mastra/core/storage';
|
|
11
|
+
import type { StorageResourceType } from '@mastra/core/storage';
|
|
12
|
+
import type { StorageThreadType } from '@mastra/core/memory';
|
|
13
|
+
import type { TABLE_NAMES } from '@mastra/core/storage';
|
|
14
|
+
import type { WorkflowRun } from '@mastra/core/storage';
|
|
15
|
+
import type { WorkflowRuns } from '@mastra/core/storage';
|
|
16
|
+
import type { WorkflowRunState } from '@mastra/core/workflows';
|
|
17
|
+
|
|
18
|
+
declare type MastraMessageV2WithTypedContent = Omit<MastraMessageV2, 'content'> & {
|
|
19
|
+
content: MastraMessageContentV2;
|
|
20
|
+
};
|
|
21
|
+
export { MastraMessageV2WithTypedContent }
|
|
22
|
+
export { MastraMessageV2WithTypedContent as MastraMessageV2WithTypedContent_alias_1 }
|
|
23
|
+
|
|
24
|
+
declare type MSSQLConfig = MSSQLConfigType;
|
|
25
|
+
export { MSSQLConfig }
|
|
26
|
+
export { MSSQLConfig as MSSQLConfig_alias_1 }
|
|
27
|
+
|
|
28
|
+
declare type MSSQLConfigType = {
|
|
29
|
+
schemaName?: string;
|
|
30
|
+
} & ({
|
|
31
|
+
server: string;
|
|
32
|
+
port: number;
|
|
33
|
+
database: string;
|
|
34
|
+
user: string;
|
|
35
|
+
password: string;
|
|
36
|
+
options?: sql.IOptions;
|
|
37
|
+
} | {
|
|
38
|
+
connectionString: string;
|
|
39
|
+
});
|
|
40
|
+
export { MSSQLConfigType }
|
|
41
|
+
export { MSSQLConfigType as MSSQLConfigType_alias_1 }
|
|
42
|
+
|
|
43
|
+
declare class MSSQLStore extends MastraStorage {
|
|
44
|
+
pool: sql.ConnectionPool;
|
|
45
|
+
private schema?;
|
|
46
|
+
private setupSchemaPromise;
|
|
47
|
+
private schemaSetupComplete;
|
|
48
|
+
private isConnected;
|
|
49
|
+
constructor(config: MSSQLConfigType);
|
|
50
|
+
init(): Promise<void>;
|
|
51
|
+
private _performInitializationAndStore;
|
|
52
|
+
get supports(): {
|
|
53
|
+
selectByIncludeResourceScope: boolean;
|
|
54
|
+
resourceWorkingMemory: boolean;
|
|
55
|
+
};
|
|
56
|
+
private getTableName;
|
|
57
|
+
private getSchemaName;
|
|
58
|
+
private transformEvalRow;
|
|
59
|
+
/** @deprecated use getEvals instead */
|
|
60
|
+
getEvalsByAgentName(agentName: string, type?: 'test' | 'live'): Promise<EvalRow[]>;
|
|
61
|
+
batchInsert({ tableName, records }: {
|
|
62
|
+
tableName: TABLE_NAMES;
|
|
63
|
+
records: Record<string, any>[];
|
|
64
|
+
}): Promise<void>;
|
|
65
|
+
/** @deprecated use getTracesPaginated instead*/
|
|
66
|
+
getTraces(args: {
|
|
67
|
+
name?: string;
|
|
68
|
+
scope?: string;
|
|
69
|
+
attributes?: Record<string, string>;
|
|
70
|
+
filters?: Record<string, any>;
|
|
71
|
+
page: number;
|
|
72
|
+
perPage?: number;
|
|
73
|
+
fromDate?: Date;
|
|
74
|
+
toDate?: Date;
|
|
75
|
+
}): Promise<any[]>;
|
|
76
|
+
getTracesPaginated(args: {
|
|
77
|
+
name?: string;
|
|
78
|
+
scope?: string;
|
|
79
|
+
attributes?: Record<string, string>;
|
|
80
|
+
filters?: Record<string, any>;
|
|
81
|
+
} & PaginationArgs): Promise<PaginationInfo & {
|
|
82
|
+
traces: any[];
|
|
83
|
+
}>;
|
|
84
|
+
private setupSchema;
|
|
85
|
+
protected getSqlType(type: StorageColumn['type'], isPrimaryKey?: boolean): string;
|
|
86
|
+
createTable({ tableName, schema, }: {
|
|
87
|
+
tableName: TABLE_NAMES;
|
|
88
|
+
schema: Record<string, StorageColumn>;
|
|
89
|
+
}): Promise<void>;
|
|
90
|
+
protected getDefaultValue(type: StorageColumn['type']): string;
|
|
91
|
+
alterTable({ tableName, schema, ifNotExists, }: {
|
|
92
|
+
tableName: TABLE_NAMES;
|
|
93
|
+
schema: Record<string, StorageColumn>;
|
|
94
|
+
ifNotExists: string[];
|
|
95
|
+
}): Promise<void>;
|
|
96
|
+
clearTable({ tableName }: {
|
|
97
|
+
tableName: TABLE_NAMES;
|
|
98
|
+
}): Promise<void>;
|
|
99
|
+
insert({ tableName, record }: {
|
|
100
|
+
tableName: TABLE_NAMES;
|
|
101
|
+
record: Record<string, any>;
|
|
102
|
+
}): Promise<void>;
|
|
103
|
+
load<R>({ tableName, keys }: {
|
|
104
|
+
tableName: TABLE_NAMES;
|
|
105
|
+
keys: Record<string, string>;
|
|
106
|
+
}): Promise<R | null>;
|
|
107
|
+
getThreadById({ threadId }: {
|
|
108
|
+
threadId: string;
|
|
109
|
+
}): Promise<StorageThreadType | null>;
|
|
110
|
+
getThreadsByResourceIdPaginated(args: {
|
|
111
|
+
resourceId: string;
|
|
112
|
+
} & PaginationArgs): Promise<PaginationInfo & {
|
|
113
|
+
threads: StorageThreadType[];
|
|
114
|
+
}>;
|
|
115
|
+
saveThread({ thread }: {
|
|
116
|
+
thread: StorageThreadType;
|
|
117
|
+
}): Promise<StorageThreadType>;
|
|
118
|
+
/**
|
|
119
|
+
* @deprecated use getThreadsByResourceIdPaginated instead
|
|
120
|
+
*/
|
|
121
|
+
getThreadsByResourceId(args: {
|
|
122
|
+
resourceId: string;
|
|
123
|
+
}): Promise<StorageThreadType[]>;
|
|
124
|
+
/**
|
|
125
|
+
* Updates a thread's title and metadata, merging with existing metadata. Returns the updated thread.
|
|
126
|
+
*/
|
|
127
|
+
updateThread({ id, title, metadata, }: {
|
|
128
|
+
id: string;
|
|
129
|
+
title: string;
|
|
130
|
+
metadata: Record<string, unknown>;
|
|
131
|
+
}): Promise<StorageThreadType>;
|
|
132
|
+
deleteThread({ threadId }: {
|
|
133
|
+
threadId: string;
|
|
134
|
+
}): Promise<void>;
|
|
135
|
+
private _getIncludedMessages;
|
|
136
|
+
/**
|
|
137
|
+
* @deprecated use getMessagesPaginated instead
|
|
138
|
+
*/
|
|
139
|
+
getMessages(args: StorageGetMessagesArg & {
|
|
140
|
+
format?: 'v1';
|
|
141
|
+
}): Promise<MastraMessageV1[]>;
|
|
142
|
+
getMessages(args: StorageGetMessagesArg & {
|
|
143
|
+
format: 'v2';
|
|
144
|
+
}): Promise<MastraMessageV2[]>;
|
|
145
|
+
getMessagesPaginated(args: StorageGetMessagesArg & {
|
|
146
|
+
format?: 'v1' | 'v2';
|
|
147
|
+
}): Promise<PaginationInfo & {
|
|
148
|
+
messages: MastraMessageV1[] | MastraMessageV2[];
|
|
149
|
+
}>;
|
|
150
|
+
private _parseAndFormatMessages;
|
|
151
|
+
saveMessages(args: {
|
|
152
|
+
messages: MastraMessageV1[];
|
|
153
|
+
format?: undefined | 'v1';
|
|
154
|
+
}): Promise<MastraMessageV1[]>;
|
|
155
|
+
saveMessages(args: {
|
|
156
|
+
messages: MastraMessageV2[];
|
|
157
|
+
format: 'v2';
|
|
158
|
+
}): Promise<MastraMessageV2[]>;
|
|
159
|
+
persistWorkflowSnapshot({ workflowName, runId, snapshot, }: {
|
|
160
|
+
workflowName: string;
|
|
161
|
+
runId: string;
|
|
162
|
+
snapshot: WorkflowRunState;
|
|
163
|
+
}): Promise<void>;
|
|
164
|
+
loadWorkflowSnapshot({ workflowName, runId, }: {
|
|
165
|
+
workflowName: string;
|
|
166
|
+
runId: string;
|
|
167
|
+
}): Promise<WorkflowRunState | null>;
|
|
168
|
+
private hasColumn;
|
|
169
|
+
private parseWorkflowRun;
|
|
170
|
+
getWorkflowRuns({ workflowName, fromDate, toDate, limit, offset, resourceId, }?: {
|
|
171
|
+
workflowName?: string;
|
|
172
|
+
fromDate?: Date;
|
|
173
|
+
toDate?: Date;
|
|
174
|
+
limit?: number;
|
|
175
|
+
offset?: number;
|
|
176
|
+
resourceId?: string;
|
|
177
|
+
}): Promise<WorkflowRuns>;
|
|
178
|
+
getWorkflowRunById({ runId, workflowName, }: {
|
|
179
|
+
runId: string;
|
|
180
|
+
workflowName?: string;
|
|
181
|
+
}): Promise<WorkflowRun | null>;
|
|
182
|
+
updateMessages({ messages, }: {
|
|
183
|
+
messages: (Partial<Omit<MastraMessageV2, 'createdAt'>> & {
|
|
184
|
+
id: string;
|
|
185
|
+
content?: {
|
|
186
|
+
metadata?: MastraMessageContentV2['metadata'];
|
|
187
|
+
content?: MastraMessageContentV2['content'];
|
|
188
|
+
};
|
|
189
|
+
})[];
|
|
190
|
+
}): Promise<MastraMessageV2[]>;
|
|
191
|
+
close(): Promise<void>;
|
|
192
|
+
getEvals(options?: {
|
|
193
|
+
agentName?: string;
|
|
194
|
+
type?: 'test' | 'live';
|
|
195
|
+
} & PaginationArgs): Promise<PaginationInfo & {
|
|
196
|
+
evals: EvalRow[];
|
|
197
|
+
}>;
|
|
198
|
+
saveResource({ resource }: {
|
|
199
|
+
resource: StorageResourceType;
|
|
200
|
+
}): Promise<StorageResourceType>;
|
|
201
|
+
updateResource({ resourceId, workingMemory, metadata, }: {
|
|
202
|
+
resourceId: string;
|
|
203
|
+
workingMemory?: string;
|
|
204
|
+
metadata?: Record<string, unknown>;
|
|
205
|
+
}): Promise<StorageResourceType>;
|
|
206
|
+
getResourceById({ resourceId }: {
|
|
207
|
+
resourceId: string;
|
|
208
|
+
}): Promise<StorageResourceType | null>;
|
|
209
|
+
}
|
|
210
|
+
export { MSSQLStore }
|
|
211
|
+
export { MSSQLStore as MSSQLStore_alias_1 }
|
|
212
|
+
|
|
213
|
+
export { }
|