@mastra/dynamodb 0.0.0-error-handler-fix-20251020202607 → 0.0.0-execa-dynamic-import-20260304221256
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 +1442 -3
- package/LICENSE.md +15 -0
- package/README.md +1 -2
- package/dist/docs/SKILL.md +22 -0
- package/dist/docs/assets/SOURCE_MAP.json +6 -0
- package/dist/docs/references/reference-storage-dynamodb.md +282 -0
- package/dist/entities/eval.d.ts +8 -0
- package/dist/entities/eval.d.ts.map +1 -1
- package/dist/entities/index.d.ts +66 -5
- package/dist/entities/index.d.ts.map +1 -1
- package/dist/entities/message.d.ts +8 -0
- package/dist/entities/message.d.ts.map +1 -1
- package/dist/entities/resource.d.ts +8 -0
- package/dist/entities/resource.d.ts.map +1 -1
- package/dist/entities/score.d.ts +18 -5
- package/dist/entities/score.d.ts.map +1 -1
- package/dist/entities/thread.d.ts +8 -0
- package/dist/entities/thread.d.ts.map +1 -1
- package/dist/entities/trace.d.ts +8 -0
- package/dist/entities/trace.d.ts.map +1 -1
- package/dist/entities/utils.d.ts +90 -0
- package/dist/entities/utils.d.ts.map +1 -1
- package/dist/entities/workflow-snapshot.d.ts +8 -0
- package/dist/entities/workflow-snapshot.d.ts.map +1 -1
- package/dist/index.cjs +786 -1269
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +780 -1270
- package/dist/index.js.map +1 -1
- package/dist/storage/db/index.d.ts +48 -0
- package/dist/storage/db/index.d.ts.map +1 -0
- package/dist/storage/domains/memory/index.d.ts +18 -45
- package/dist/storage/domains/memory/index.d.ts.map +1 -1
- package/dist/storage/domains/scores/index.d.ts +47 -0
- package/dist/storage/domains/scores/index.d.ts.map +1 -0
- package/dist/storage/domains/utils.d.ts +7 -0
- package/dist/storage/domains/utils.d.ts.map +1 -0
- package/dist/storage/domains/workflows/index.d.ts +26 -24
- package/dist/storage/domains/workflows/index.d.ts.map +1 -1
- package/dist/storage/index.d.ts +177 -221
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/storage/ttl.d.ts +52 -0
- package/dist/storage/ttl.d.ts.map +1 -0
- package/package.json +17 -16
- package/dist/storage/domains/legacy-evals/index.d.ts +0 -19
- package/dist/storage/domains/legacy-evals/index.d.ts.map +0 -1
- package/dist/storage/domains/operations/index.d.ts +0 -69
- package/dist/storage/domains/operations/index.d.ts.map +0 -1
- package/dist/storage/domains/score/index.d.ts +0 -51
- package/dist/storage/domains/score/index.d.ts.map +0 -1
- package/dist/storage/domains/traces/index.d.ts +0 -28
- package/dist/storage/domains/traces/index.d.ts.map +0 -1
package/dist/storage/index.d.ts
CHANGED
|
@@ -1,37 +1,193 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
export
|
|
9
|
-
|
|
1
|
+
import { DynamoDBDocumentClient } from '@aws-sdk/lib-dynamodb';
|
|
2
|
+
import type { StorageDomains } from '@mastra/core/storage';
|
|
3
|
+
import { MastraCompositeStore } from '@mastra/core/storage';
|
|
4
|
+
import { MemoryStorageDynamoDB } from './domains/memory/index.js';
|
|
5
|
+
import { ScoresStorageDynamoDB } from './domains/scores/index.js';
|
|
6
|
+
import { WorkflowStorageDynamoDB } from './domains/workflows/index.js';
|
|
7
|
+
export { MemoryStorageDynamoDB, ScoresStorageDynamoDB, WorkflowStorageDynamoDB };
|
|
8
|
+
export type { DynamoDBDomainConfig } from './db/index.js';
|
|
9
|
+
export { calculateTtl, getTtlAttributeName, isTtlEnabled, getTtlProps } from './ttl.js';
|
|
10
|
+
/**
|
|
11
|
+
* Entity names that support TTL configuration.
|
|
12
|
+
*/
|
|
13
|
+
export type DynamoDBTtlEntityName = 'thread' | 'message' | 'trace' | 'eval' | 'workflow_snapshot' | 'resource' | 'score';
|
|
14
|
+
/**
|
|
15
|
+
* TTL configuration for a single entity type.
|
|
16
|
+
*/
|
|
17
|
+
export interface DynamoDBEntityTtlConfig {
|
|
18
|
+
/**
|
|
19
|
+
* Whether TTL is enabled for this entity type.
|
|
20
|
+
*/
|
|
21
|
+
enabled: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* The DynamoDB attribute name to use for TTL.
|
|
24
|
+
* Must match the TTL attribute configured on your DynamoDB table.
|
|
25
|
+
* @default 'ttl'
|
|
26
|
+
*/
|
|
27
|
+
attributeName?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Default TTL in seconds from item creation/update time.
|
|
30
|
+
* Items will be automatically deleted by DynamoDB after this duration.
|
|
31
|
+
* @example 30 * 24 * 60 * 60 // 30 days
|
|
32
|
+
*/
|
|
33
|
+
defaultTtlSeconds?: number;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* TTL configuration for DynamoDB store.
|
|
37
|
+
* Configure TTL per entity type for automatic data expiration.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```typescript
|
|
41
|
+
* const store = new DynamoDBStore({
|
|
42
|
+
* name: 'my-store',
|
|
43
|
+
* config: {
|
|
44
|
+
* id: 'my-id',
|
|
45
|
+
* tableName: 'my-table',
|
|
46
|
+
* ttl: {
|
|
47
|
+
* message: {
|
|
48
|
+
* enabled: true,
|
|
49
|
+
* defaultTtlSeconds: 30 * 24 * 60 * 60, // 30 days
|
|
50
|
+
* },
|
|
51
|
+
* trace: {
|
|
52
|
+
* enabled: true,
|
|
53
|
+
* attributeName: 'expiresAt',
|
|
54
|
+
* defaultTtlSeconds: 7 * 24 * 60 * 60, // 7 days
|
|
55
|
+
* },
|
|
56
|
+
* },
|
|
57
|
+
* },
|
|
58
|
+
* });
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
export type DynamoDBTtlConfig = {
|
|
62
|
+
[EntityKey in DynamoDBTtlEntityName]?: DynamoDBEntityTtlConfig;
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* DynamoDB configuration type.
|
|
66
|
+
*
|
|
67
|
+
* Accepts either:
|
|
68
|
+
* - A pre-configured DynamoDB client: `{ id, client, tableName }`
|
|
69
|
+
* - AWS config: `{ id, tableName, region?, endpoint?, credentials? }`
|
|
70
|
+
*/
|
|
71
|
+
export type DynamoDBStoreConfig = {
|
|
72
|
+
id: string;
|
|
10
73
|
tableName: string;
|
|
74
|
+
/**
|
|
75
|
+
* When true, automatic initialization (table creation/migrations) is disabled.
|
|
76
|
+
* This is useful for CI/CD pipelines where you want to:
|
|
77
|
+
* 1. Run migrations explicitly during deployment (not at runtime)
|
|
78
|
+
* 2. Use different credentials for schema changes vs runtime operations
|
|
79
|
+
*
|
|
80
|
+
* When disableInit is true:
|
|
81
|
+
* - The storage will not automatically create/alter tables on first use
|
|
82
|
+
* - You must call `storage.init()` explicitly in your CI/CD scripts
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* // In CI/CD script:
|
|
86
|
+
* const storage = new DynamoDBStore({ name: 'my-store', config: { ...config, disableInit: false } });
|
|
87
|
+
* await storage.init(); // Explicitly run migrations
|
|
88
|
+
*
|
|
89
|
+
* // In runtime application:
|
|
90
|
+
* const storage = new DynamoDBStore({ name: 'my-store', config: { ...config, disableInit: true } });
|
|
91
|
+
* // No auto-init, tables must already exist
|
|
92
|
+
*/
|
|
93
|
+
disableInit?: boolean;
|
|
94
|
+
/**
|
|
95
|
+
* TTL (Time To Live) configuration for automatic data expiration.
|
|
96
|
+
*
|
|
97
|
+
* Configure TTL per entity type to automatically delete items after a specified duration.
|
|
98
|
+
* DynamoDB TTL is a background process that deletes items within 48 hours after expiration.
|
|
99
|
+
*
|
|
100
|
+
* **Important**: TTL must also be enabled on your DynamoDB table via AWS Console or CLI,
|
|
101
|
+
* specifying the attribute name (default: 'ttl'). The table-level TTL attribute name
|
|
102
|
+
* must match the `attributeName` in your configuration.
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* ```typescript
|
|
106
|
+
* const store = new DynamoDBStore({
|
|
107
|
+
* name: 'my-store',
|
|
108
|
+
* config: {
|
|
109
|
+
* id: 'my-id',
|
|
110
|
+
* tableName: 'my-table',
|
|
111
|
+
* ttl: {
|
|
112
|
+
* message: {
|
|
113
|
+
* enabled: true,
|
|
114
|
+
* defaultTtlSeconds: 30 * 24 * 60 * 60, // 30 days
|
|
115
|
+
* },
|
|
116
|
+
* trace: {
|
|
117
|
+
* enabled: true,
|
|
118
|
+
* defaultTtlSeconds: 7 * 24 * 60 * 60, // 7 days
|
|
119
|
+
* },
|
|
120
|
+
* },
|
|
121
|
+
* },
|
|
122
|
+
* });
|
|
123
|
+
* ```
|
|
124
|
+
*/
|
|
125
|
+
ttl?: DynamoDBTtlConfig;
|
|
126
|
+
} & ({
|
|
127
|
+
/**
|
|
128
|
+
* Pre-configured DynamoDB Document client.
|
|
129
|
+
* Use this when you need to configure the client before initialization,
|
|
130
|
+
* e.g., to set custom middleware or retry strategies.
|
|
131
|
+
*
|
|
132
|
+
* @example
|
|
133
|
+
* ```typescript
|
|
134
|
+
* import { DynamoDBClient } from '@aws-sdk/client-dynamodb';
|
|
135
|
+
* import { DynamoDBDocumentClient } from '@aws-sdk/lib-dynamodb';
|
|
136
|
+
*
|
|
137
|
+
* const dynamoClient = new DynamoDBClient({
|
|
138
|
+
* region: 'us-east-1',
|
|
139
|
+
* // Custom settings
|
|
140
|
+
* maxAttempts: 5,
|
|
141
|
+
* });
|
|
142
|
+
*
|
|
143
|
+
* const client = DynamoDBDocumentClient.from(dynamoClient, {
|
|
144
|
+
* marshallOptions: { removeUndefinedValues: true },
|
|
145
|
+
* });
|
|
146
|
+
*
|
|
147
|
+
* const store = new DynamoDBStore({
|
|
148
|
+
* name: 'my-store',
|
|
149
|
+
* config: { id: 'my-id', client, tableName: 'my-table' }
|
|
150
|
+
* });
|
|
151
|
+
* ```
|
|
152
|
+
*/
|
|
153
|
+
client: DynamoDBDocumentClient;
|
|
154
|
+
} | {
|
|
155
|
+
region?: string;
|
|
11
156
|
endpoint?: string;
|
|
12
157
|
credentials?: {
|
|
13
158
|
accessKeyId: string;
|
|
14
159
|
secretAccessKey: string;
|
|
15
160
|
};
|
|
16
|
-
}
|
|
17
|
-
|
|
161
|
+
});
|
|
162
|
+
/**
|
|
163
|
+
* DynamoDB storage adapter for Mastra.
|
|
164
|
+
*
|
|
165
|
+
* Access domain-specific storage via `getStore()`:
|
|
166
|
+
*
|
|
167
|
+
* @example
|
|
168
|
+
* ```typescript
|
|
169
|
+
* const storage = new DynamoDBStore({ name: 'my-store', config: { id: 'my-id', tableName: 'my-table' } });
|
|
170
|
+
*
|
|
171
|
+
* // Access memory domain
|
|
172
|
+
* const memory = await storage.getStore('memory');
|
|
173
|
+
* await memory?.saveThread({ thread });
|
|
174
|
+
*
|
|
175
|
+
* // Access workflows domain
|
|
176
|
+
* const workflows = await storage.getStore('workflows');
|
|
177
|
+
* await workflows?.persistWorkflowSnapshot({ workflowName, runId, snapshot });
|
|
178
|
+
* ```
|
|
179
|
+
*/
|
|
180
|
+
export declare class DynamoDBStore extends MastraCompositeStore {
|
|
18
181
|
private tableName;
|
|
19
182
|
private client;
|
|
20
183
|
private service;
|
|
184
|
+
private ttlConfig?;
|
|
21
185
|
protected hasInitialized: Promise<boolean> | null;
|
|
22
186
|
stores: StorageDomains;
|
|
23
187
|
constructor({ name, config }: {
|
|
24
188
|
name: string;
|
|
25
189
|
config: DynamoDBStoreConfig;
|
|
26
190
|
});
|
|
27
|
-
get supports(): {
|
|
28
|
-
selectByIncludeResourceScope: boolean;
|
|
29
|
-
resourceWorkingMemory: boolean;
|
|
30
|
-
hasColumn: boolean;
|
|
31
|
-
createTable: boolean;
|
|
32
|
-
deleteMessages: boolean;
|
|
33
|
-
getScoresBySpan: boolean;
|
|
34
|
-
};
|
|
35
191
|
/**
|
|
36
192
|
* Validates that the required DynamoDB table exists and is accessible.
|
|
37
193
|
* This does not check the table structure - it assumes the table
|
|
@@ -49,211 +205,11 @@ export declare class DynamoDBStore extends MastraStorage {
|
|
|
49
205
|
* Handles resetting the stored promise on failure to allow retries.
|
|
50
206
|
*/
|
|
51
207
|
private _performInitializationAndStore;
|
|
52
|
-
createTable({ tableName, schema }: {
|
|
53
|
-
tableName: TABLE_NAMES;
|
|
54
|
-
schema: Record<string, any>;
|
|
55
|
-
}): Promise<void>;
|
|
56
|
-
alterTable(_args: {
|
|
57
|
-
tableName: TABLE_NAMES;
|
|
58
|
-
schema: Record<string, StorageColumn>;
|
|
59
|
-
ifNotExists: string[];
|
|
60
|
-
}): Promise<void>;
|
|
61
|
-
clearTable({ tableName }: {
|
|
62
|
-
tableName: TABLE_NAMES;
|
|
63
|
-
}): Promise<void>;
|
|
64
|
-
dropTable({ tableName }: {
|
|
65
|
-
tableName: TABLE_NAMES;
|
|
66
|
-
}): Promise<void>;
|
|
67
|
-
insert({ tableName, record }: {
|
|
68
|
-
tableName: TABLE_NAMES;
|
|
69
|
-
record: Record<string, any>;
|
|
70
|
-
}): Promise<void>;
|
|
71
|
-
batchInsert({ tableName, records }: {
|
|
72
|
-
tableName: TABLE_NAMES;
|
|
73
|
-
records: Record<string, any>[];
|
|
74
|
-
}): Promise<void>;
|
|
75
|
-
load<R>({ tableName, keys }: {
|
|
76
|
-
tableName: TABLE_NAMES;
|
|
77
|
-
keys: Record<string, string>;
|
|
78
|
-
}): Promise<R | null>;
|
|
79
|
-
getThreadById({ threadId }: {
|
|
80
|
-
threadId: string;
|
|
81
|
-
}): Promise<StorageThreadType | null>;
|
|
82
|
-
getThreadsByResourceId(args: {
|
|
83
|
-
resourceId: string;
|
|
84
|
-
} & ThreadSortOptions): Promise<StorageThreadType[]>;
|
|
85
|
-
saveThread({ thread }: {
|
|
86
|
-
thread: StorageThreadType;
|
|
87
|
-
}): Promise<StorageThreadType>;
|
|
88
|
-
updateThread({ id, title, metadata, }: {
|
|
89
|
-
id: string;
|
|
90
|
-
title: string;
|
|
91
|
-
metadata: Record<string, unknown>;
|
|
92
|
-
}): Promise<StorageThreadType>;
|
|
93
|
-
deleteThread({ threadId }: {
|
|
94
|
-
threadId: string;
|
|
95
|
-
}): Promise<void>;
|
|
96
|
-
getMessages(args: StorageGetMessagesArg & {
|
|
97
|
-
format?: 'v1';
|
|
98
|
-
}): Promise<MastraMessageV1[]>;
|
|
99
|
-
getMessages(args: StorageGetMessagesArg & {
|
|
100
|
-
format: 'v2';
|
|
101
|
-
}): Promise<MastraMessageV2[]>;
|
|
102
|
-
getMessagesById({ messageIds, format }: {
|
|
103
|
-
messageIds: string[];
|
|
104
|
-
format: 'v1';
|
|
105
|
-
}): Promise<MastraMessageV1[]>;
|
|
106
|
-
getMessagesById({ messageIds, format }: {
|
|
107
|
-
messageIds: string[];
|
|
108
|
-
format?: 'v2';
|
|
109
|
-
}): Promise<MastraMessageV2[]>;
|
|
110
|
-
saveMessages(args: {
|
|
111
|
-
messages: MastraMessageV1[];
|
|
112
|
-
format?: undefined | 'v1';
|
|
113
|
-
}): Promise<MastraMessageV1[]>;
|
|
114
|
-
saveMessages(args: {
|
|
115
|
-
messages: MastraMessageV2[];
|
|
116
|
-
format: 'v2';
|
|
117
|
-
}): Promise<MastraMessageV2[]>;
|
|
118
|
-
getThreadsByResourceIdPaginated(args: {
|
|
119
|
-
resourceId: string;
|
|
120
|
-
page: number;
|
|
121
|
-
perPage: number;
|
|
122
|
-
} & ThreadSortOptions): Promise<PaginationInfo & {
|
|
123
|
-
threads: StorageThreadType[];
|
|
124
|
-
}>;
|
|
125
|
-
getMessagesPaginated(args: StorageGetMessagesArg & {
|
|
126
|
-
format?: 'v1' | 'v2';
|
|
127
|
-
}): Promise<PaginationInfo & {
|
|
128
|
-
messages: MastraMessageV1[] | MastraMessageV2[];
|
|
129
|
-
}>;
|
|
130
|
-
updateMessages(_args: {
|
|
131
|
-
messages: Partial<Omit<MastraMessageV2, 'createdAt'>> & {
|
|
132
|
-
id: string;
|
|
133
|
-
content?: {
|
|
134
|
-
metadata?: MastraMessageContentV2['metadata'];
|
|
135
|
-
content?: MastraMessageContentV2['content'];
|
|
136
|
-
};
|
|
137
|
-
}[];
|
|
138
|
-
}): Promise<MastraMessageV2[]>;
|
|
139
|
-
getTraces(args: {
|
|
140
|
-
name?: string;
|
|
141
|
-
scope?: string;
|
|
142
|
-
page: number;
|
|
143
|
-
perPage: number;
|
|
144
|
-
attributes?: Record<string, string>;
|
|
145
|
-
filters?: Record<string, any>;
|
|
146
|
-
}): Promise<any[]>;
|
|
147
|
-
batchTraceInsert({ records }: {
|
|
148
|
-
records: Record<string, any>[];
|
|
149
|
-
}): Promise<void>;
|
|
150
|
-
getTracesPaginated(_args: StorageGetTracesArg): Promise<PaginationInfo & {
|
|
151
|
-
traces: Trace[];
|
|
152
|
-
}>;
|
|
153
|
-
updateWorkflowResults({ workflowName, runId, stepId, result, runtimeContext, }: {
|
|
154
|
-
workflowName: string;
|
|
155
|
-
runId: string;
|
|
156
|
-
stepId: string;
|
|
157
|
-
result: StepResult<any, any, any, any>;
|
|
158
|
-
runtimeContext: Record<string, any>;
|
|
159
|
-
}): Promise<Record<string, StepResult<any, any, any, any>>>;
|
|
160
|
-
updateWorkflowState({ workflowName, runId, opts, }: {
|
|
161
|
-
workflowName: string;
|
|
162
|
-
runId: string;
|
|
163
|
-
opts: {
|
|
164
|
-
status: string;
|
|
165
|
-
result?: StepResult<any, any, any, any>;
|
|
166
|
-
error?: string;
|
|
167
|
-
suspendedPaths?: Record<string, number[]>;
|
|
168
|
-
waitingPaths?: Record<string, number[]>;
|
|
169
|
-
};
|
|
170
|
-
}): Promise<WorkflowRunState | undefined>;
|
|
171
|
-
persistWorkflowSnapshot({ workflowName, runId, resourceId, snapshot, }: {
|
|
172
|
-
workflowName: string;
|
|
173
|
-
runId: string;
|
|
174
|
-
resourceId?: string;
|
|
175
|
-
snapshot: WorkflowRunState;
|
|
176
|
-
}): Promise<void>;
|
|
177
|
-
loadWorkflowSnapshot({ workflowName, runId, }: {
|
|
178
|
-
workflowName: string;
|
|
179
|
-
runId: string;
|
|
180
|
-
}): Promise<WorkflowRunState | null>;
|
|
181
|
-
getWorkflowRuns(args?: {
|
|
182
|
-
workflowName?: string;
|
|
183
|
-
fromDate?: Date;
|
|
184
|
-
toDate?: Date;
|
|
185
|
-
limit?: number;
|
|
186
|
-
offset?: number;
|
|
187
|
-
resourceId?: string;
|
|
188
|
-
}): Promise<WorkflowRuns>;
|
|
189
|
-
getWorkflowRunById(args: {
|
|
190
|
-
runId: string;
|
|
191
|
-
workflowName?: string;
|
|
192
|
-
}): Promise<WorkflowRun | null>;
|
|
193
|
-
getResourceById({ resourceId }: {
|
|
194
|
-
resourceId: string;
|
|
195
|
-
}): Promise<StorageResourceType | null>;
|
|
196
|
-
saveResource({ resource }: {
|
|
197
|
-
resource: StorageResourceType;
|
|
198
|
-
}): Promise<StorageResourceType>;
|
|
199
|
-
updateResource({ resourceId, workingMemory, metadata, }: {
|
|
200
|
-
resourceId: string;
|
|
201
|
-
workingMemory?: string;
|
|
202
|
-
metadata?: Record<string, any>;
|
|
203
|
-
}): Promise<StorageResourceType>;
|
|
204
|
-
getEvalsByAgentName(agentName: string, type?: 'test' | 'live'): Promise<EvalRow[]>;
|
|
205
|
-
getEvals(options: {
|
|
206
|
-
agentName?: string;
|
|
207
|
-
type?: 'test' | 'live';
|
|
208
|
-
} & PaginationArgs): Promise<PaginationInfo & {
|
|
209
|
-
evals: EvalRow[];
|
|
210
|
-
}>;
|
|
211
208
|
/**
|
|
212
209
|
* Closes the DynamoDB client connection and cleans up resources.
|
|
213
|
-
*
|
|
210
|
+
*
|
|
211
|
+
* This will close the DynamoDB client, including pre-configured clients.
|
|
214
212
|
*/
|
|
215
213
|
close(): Promise<void>;
|
|
216
|
-
/**
|
|
217
|
-
* SCORERS - Not implemented
|
|
218
|
-
*/
|
|
219
|
-
getScoreById({ id: _id }: {
|
|
220
|
-
id: string;
|
|
221
|
-
}): Promise<ScoreRowData | null>;
|
|
222
|
-
saveScore(_score: ScoreRowData): Promise<{
|
|
223
|
-
score: ScoreRowData;
|
|
224
|
-
}>;
|
|
225
|
-
getScoresByRunId({ runId: _runId, pagination: _pagination, }: {
|
|
226
|
-
runId: string;
|
|
227
|
-
pagination: StoragePagination;
|
|
228
|
-
}): Promise<{
|
|
229
|
-
pagination: PaginationInfo;
|
|
230
|
-
scores: ScoreRowData[];
|
|
231
|
-
}>;
|
|
232
|
-
getScoresByEntityId({ entityId: _entityId, entityType: _entityType, pagination: _pagination, }: {
|
|
233
|
-
pagination: StoragePagination;
|
|
234
|
-
entityId: string;
|
|
235
|
-
entityType: string;
|
|
236
|
-
}): Promise<{
|
|
237
|
-
pagination: PaginationInfo;
|
|
238
|
-
scores: ScoreRowData[];
|
|
239
|
-
}>;
|
|
240
|
-
getScoresByScorerId({ scorerId, source, entityId, entityType, pagination, }: {
|
|
241
|
-
scorerId: string;
|
|
242
|
-
entityId?: string;
|
|
243
|
-
entityType?: string;
|
|
244
|
-
source?: ScoringSource;
|
|
245
|
-
pagination: StoragePagination;
|
|
246
|
-
}): Promise<{
|
|
247
|
-
pagination: PaginationInfo;
|
|
248
|
-
scores: ScoreRowData[];
|
|
249
|
-
}>;
|
|
250
|
-
getScoresBySpan({ traceId, spanId, pagination, }: {
|
|
251
|
-
traceId: string;
|
|
252
|
-
spanId: string;
|
|
253
|
-
pagination: StoragePagination;
|
|
254
|
-
}): Promise<{
|
|
255
|
-
pagination: PaginationInfo;
|
|
256
|
-
scores: ScoreRowData[];
|
|
257
|
-
}>;
|
|
258
214
|
}
|
|
259
215
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/storage/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/storage/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAE/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAwB,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAIlF,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAG9D,OAAO,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,CAAC;AACjF,YAAY,EAAE,oBAAoB,EAAE,MAAM,MAAM,CAAC;AAGjD,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAErF;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAC7B,QAAQ,GACR,SAAS,GACT,OAAO,GACP,MAAM,GACN,mBAAmB,GACnB,UAAU,GACV,OAAO,CAAC;AAEZ;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;IACjB;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,MAAM,iBAAiB,GAAG;KAC7B,SAAS,IAAI,qBAAqB,CAAC,CAAC,EAAE,uBAAuB;CAC/D,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB;;;;;;;;;;;;;;;;;;OAkBG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;IACH,GAAG,CAAC,EAAE,iBAAiB,CAAC;CACzB,GAAG,CACA;IACE;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,MAAM,EAAE,sBAAsB,CAAC;CAChC,GACD;IACE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE;QACZ,WAAW,EAAE,MAAM,CAAC;QACpB,eAAe,EAAE,MAAM,CAAC;KACzB,CAAC;CACH,CACJ,CAAC;AAgBF;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,aAAc,SAAQ,oBAAoB;IACrD,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,MAAM,CAAyB;IACvC,OAAO,CAAC,OAAO,CAAgB;IAC/B,OAAO,CAAC,SAAS,CAAC,CAAoB;IACtC,SAAS,CAAC,cAAc,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,IAAI,CAAQ;IACzD,MAAM,EAAE,cAAc,CAAC;gBAEX,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,mBAAmB,CAAA;KAAE;IA2D3E;;;;OAIG;YACW,mBAAmB;IA6BjC;;;;OAIG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IA8B3B;;;OAGG;IACH,OAAO,CAAC,8BAA8B;IAmBtC;;;;OAIG;IACU,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAgBpC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { DynamoDBTtlConfig, DynamoDBTtlEntityName, DynamoDBEntityTtlConfig } from './index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Calculate TTL value for a given entity type.
|
|
4
|
+
*
|
|
5
|
+
* DynamoDB TTL is a Unix timestamp (seconds since epoch) that indicates when an item
|
|
6
|
+
* should be automatically deleted. AWS processes TTL deletions typically within 48 hours
|
|
7
|
+
* after the item expires.
|
|
8
|
+
*
|
|
9
|
+
* @param entityName - The entity type (e.g., 'thread', 'message')
|
|
10
|
+
* @param ttlConfig - The TTL configuration for all entities
|
|
11
|
+
* @param customTtlSeconds - Optional override for the TTL duration
|
|
12
|
+
* @returns The TTL Unix timestamp, or undefined if TTL is not enabled
|
|
13
|
+
*/
|
|
14
|
+
export declare function calculateTtl(entityName: DynamoDBTtlEntityName, ttlConfig?: DynamoDBTtlConfig, customTtlSeconds?: number): number | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* Get the TTL attribute name for a given entity type.
|
|
17
|
+
*
|
|
18
|
+
* @param entityName - The entity type (e.g., 'thread', 'message')
|
|
19
|
+
* @param ttlConfig - The TTL configuration for all entities
|
|
20
|
+
* @returns The attribute name to use for TTL (default: 'ttl')
|
|
21
|
+
*/
|
|
22
|
+
export declare function getTtlAttributeName(entityName: DynamoDBTtlEntityName, ttlConfig?: DynamoDBTtlConfig): string;
|
|
23
|
+
/**
|
|
24
|
+
* Get the TTL configuration for a specific entity type.
|
|
25
|
+
*
|
|
26
|
+
* @param entityName - The entity type (e.g., 'thread', 'message')
|
|
27
|
+
* @param ttlConfig - The TTL configuration for all entities
|
|
28
|
+
* @returns The entity TTL config, or undefined if not configured
|
|
29
|
+
*/
|
|
30
|
+
export declare function getEntityTtlConfig(entityName: DynamoDBTtlEntityName, ttlConfig?: DynamoDBTtlConfig): DynamoDBEntityTtlConfig | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* Check if TTL is enabled for a given entity type.
|
|
33
|
+
*
|
|
34
|
+
* @param entityName - The entity type (e.g., 'thread', 'message')
|
|
35
|
+
* @param ttlConfig - The TTL configuration for all entities
|
|
36
|
+
* @returns true if TTL is enabled for this entity
|
|
37
|
+
*/
|
|
38
|
+
export declare function isTtlEnabled(entityName: DynamoDBTtlEntityName, ttlConfig?: DynamoDBTtlConfig): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Get TTL properties to spread into a record.
|
|
41
|
+
* Returns an empty object if TTL is not enabled, otherwise returns { [attributeName]: ttlValue }.
|
|
42
|
+
*
|
|
43
|
+
* @param entityName - The entity type (e.g., 'thread', 'message')
|
|
44
|
+
* @param ttlConfig - The TTL configuration for all entities
|
|
45
|
+
* @param customTtlSeconds - Optional override for the TTL duration
|
|
46
|
+
* @returns Object with TTL attribute to spread, or empty object
|
|
47
|
+
*/
|
|
48
|
+
export declare function getTtlProps(entityName: DynamoDBTtlEntityName, ttlConfig?: DynamoDBTtlConfig, customTtlSeconds?: number): {
|
|
49
|
+
ttl?: number;
|
|
50
|
+
expiresAt?: number;
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=ttl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ttl.d.ts","sourceRoot":"","sources":["../../src/storage/ttl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAEjG;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,CAC1B,UAAU,EAAE,qBAAqB,EACjC,SAAS,CAAC,EAAE,iBAAiB,EAC7B,gBAAgB,CAAC,EAAE,MAAM,GACxB,MAAM,GAAG,SAAS,CAmBpB;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,qBAAqB,EAAE,SAAS,CAAC,EAAE,iBAAiB,GAAG,MAAM,CAG5G;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,UAAU,EAAE,qBAAqB,EACjC,SAAS,CAAC,EAAE,iBAAiB,GAC5B,uBAAuB,GAAG,SAAS,CAErC;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,UAAU,EAAE,qBAAqB,EAAE,SAAS,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAEtG;AAED;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CACzB,UAAU,EAAE,qBAAqB,EACjC,SAAS,CAAC,EAAE,iBAAiB,EAC7B,gBAAgB,CAAC,EAAE,MAAM,GACxB;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,CAKtC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/dynamodb",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-execa-dynamic-import-20260304221256",
|
|
4
4
|
"description": "DynamoDB storage adapter for Mastra",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -25,25 +25,23 @@
|
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@aws-sdk/client-dynamodb": "^3.902.0",
|
|
27
27
|
"@aws-sdk/lib-dynamodb": "^3.902.0",
|
|
28
|
-
"electrodb": "^3.
|
|
28
|
+
"electrodb": "^3.5.3"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
|
-
"@mastra/core": "0.0.0-
|
|
31
|
+
"@mastra/core": "0.0.0-execa-dynamic-import-20260304221256"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@
|
|
35
|
-
"@
|
|
36
|
-
"@vitest/
|
|
37
|
-
"@vitest/ui": "3.2.3",
|
|
38
|
-
"axios": "^1.12.2",
|
|
34
|
+
"@types/node": "22.19.7",
|
|
35
|
+
"@vitest/coverage-v8": "4.0.18",
|
|
36
|
+
"@vitest/ui": "4.0.18",
|
|
39
37
|
"eslint": "^9.37.0",
|
|
40
|
-
"tsup": "^8.5.
|
|
41
|
-
"typescript": "^5.
|
|
42
|
-
"vitest": "
|
|
43
|
-
"@internal/lint": "0.0.0-
|
|
44
|
-
"@internal/storage-test-utils": "0.0.
|
|
45
|
-
"@
|
|
46
|
-
"@
|
|
38
|
+
"tsup": "^8.5.1",
|
|
39
|
+
"typescript": "^5.9.3",
|
|
40
|
+
"vitest": "4.0.18",
|
|
41
|
+
"@internal/lint": "0.0.0-execa-dynamic-import-20260304221256",
|
|
42
|
+
"@internal/storage-test-utils": "0.0.61",
|
|
43
|
+
"@internal/types-builder": "0.0.0-execa-dynamic-import-20260304221256",
|
|
44
|
+
"@mastra/core": "0.0.0-execa-dynamic-import-20260304221256"
|
|
47
45
|
},
|
|
48
46
|
"homepage": "https://mastra.ai",
|
|
49
47
|
"repository": {
|
|
@@ -54,8 +52,11 @@
|
|
|
54
52
|
"bugs": {
|
|
55
53
|
"url": "https://github.com/mastra-ai/mastra/issues"
|
|
56
54
|
},
|
|
55
|
+
"engines": {
|
|
56
|
+
"node": ">=22.13.0"
|
|
57
|
+
},
|
|
57
58
|
"scripts": {
|
|
58
|
-
"build": "tsup --silent --config tsup.config.ts",
|
|
59
|
+
"build:lib": "tsup --silent --config tsup.config.ts",
|
|
59
60
|
"dev": "tsup --watch && tsc -p tsconfig.build.json",
|
|
60
61
|
"clean": "rm -rf dist",
|
|
61
62
|
"lint": "eslint .",
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { EvalRow, PaginationArgs, PaginationInfo } from '@mastra/core/storage';
|
|
2
|
-
import { LegacyEvalsStorage } from '@mastra/core/storage';
|
|
3
|
-
import type { Service } from 'electrodb';
|
|
4
|
-
export declare class LegacyEvalsDynamoDB extends LegacyEvalsStorage {
|
|
5
|
-
service: Service<Record<string, any>>;
|
|
6
|
-
tableName: string;
|
|
7
|
-
constructor({ service, tableName }: {
|
|
8
|
-
service: Service<Record<string, any>>;
|
|
9
|
-
tableName: string;
|
|
10
|
-
});
|
|
11
|
-
getEvalsByAgentName(agentName: string, type?: 'test' | 'live'): Promise<EvalRow[]>;
|
|
12
|
-
getEvals(options?: {
|
|
13
|
-
agentName?: string;
|
|
14
|
-
type?: 'test' | 'live';
|
|
15
|
-
} & PaginationArgs): Promise<PaginationInfo & {
|
|
16
|
-
evals: EvalRow[];
|
|
17
|
-
}>;
|
|
18
|
-
}
|
|
19
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/legacy-evals/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACpF,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,qBAAa,mBAAoB,SAAQ,kBAAkB;IACzD,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC;IACtC,SAAS,EAAE,MAAM,CAAC;gBAEN,EAAE,OAAO,EAAE,SAAS,EAAE,EAAE;QAAE,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE;IAO1F,mBAAmB,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAqFlF,QAAQ,CACZ,OAAO,GAAE;QACP,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;KACxB,GAAG,cAAmB,GACtB,OAAO,CAAC,cAAc,GAAG;QAAE,KAAK,EAAE,OAAO,EAAE,CAAA;KAAE,CAAC;CAwIlD"}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import type { DynamoDBDocumentClient } from '@aws-sdk/lib-dynamodb';
|
|
2
|
-
import { StoreOperations } from '@mastra/core/storage';
|
|
3
|
-
import type { StorageColumn, TABLE_NAMES } from '@mastra/core/storage';
|
|
4
|
-
import type { Service } from 'electrodb';
|
|
5
|
-
export declare class StoreOperationsDynamoDB extends StoreOperations {
|
|
6
|
-
client: DynamoDBDocumentClient;
|
|
7
|
-
tableName: string;
|
|
8
|
-
service: Service<Record<string, any>>;
|
|
9
|
-
constructor({ service, tableName, client, }: {
|
|
10
|
-
service: Service<Record<string, any>>;
|
|
11
|
-
tableName: string;
|
|
12
|
-
client: DynamoDBDocumentClient;
|
|
13
|
-
});
|
|
14
|
-
hasColumn(): Promise<boolean>;
|
|
15
|
-
dropTable(): Promise<void>;
|
|
16
|
-
private getEntityNameForTable;
|
|
17
|
-
/**
|
|
18
|
-
* Pre-processes a record to ensure Date objects are converted to ISO strings
|
|
19
|
-
* This is necessary because ElectroDB validation happens before setters are applied
|
|
20
|
-
*/
|
|
21
|
-
private preprocessRecord;
|
|
22
|
-
/**
|
|
23
|
-
* Validates that the required DynamoDB table exists and is accessible.
|
|
24
|
-
* This does not check the table structure - it assumes the table
|
|
25
|
-
* was created with the correct structure via CDK/CloudFormation.
|
|
26
|
-
*/
|
|
27
|
-
private validateTableExists;
|
|
28
|
-
/**
|
|
29
|
-
* This method is modified for DynamoDB with ElectroDB single-table design.
|
|
30
|
-
* It assumes the table is created and managed externally via CDK/CloudFormation.
|
|
31
|
-
*
|
|
32
|
-
* This implementation only validates that the required table exists and is accessible.
|
|
33
|
-
* No table creation is attempted - we simply check if we can access the table.
|
|
34
|
-
*/
|
|
35
|
-
createTable({ tableName }: {
|
|
36
|
-
tableName: TABLE_NAMES;
|
|
37
|
-
schema: Record<string, any>;
|
|
38
|
-
}): Promise<void>;
|
|
39
|
-
insert({ tableName, record }: {
|
|
40
|
-
tableName: TABLE_NAMES;
|
|
41
|
-
record: Record<string, any>;
|
|
42
|
-
}): Promise<void>;
|
|
43
|
-
alterTable(_args: {
|
|
44
|
-
tableName: TABLE_NAMES;
|
|
45
|
-
schema: Record<string, StorageColumn>;
|
|
46
|
-
ifNotExists: string[];
|
|
47
|
-
}): Promise<void>;
|
|
48
|
-
/**
|
|
49
|
-
* Clear all items from a logical "table" (entity type)
|
|
50
|
-
*/
|
|
51
|
-
clearTable({ tableName }: {
|
|
52
|
-
tableName: TABLE_NAMES;
|
|
53
|
-
}): Promise<void>;
|
|
54
|
-
/**
|
|
55
|
-
* Insert multiple records as a batch
|
|
56
|
-
*/
|
|
57
|
-
batchInsert({ tableName, records }: {
|
|
58
|
-
tableName: TABLE_NAMES;
|
|
59
|
-
records: Record<string, any>[];
|
|
60
|
-
}): Promise<void>;
|
|
61
|
-
/**
|
|
62
|
-
* Load a record by its keys
|
|
63
|
-
*/
|
|
64
|
-
load<R>({ tableName, keys }: {
|
|
65
|
-
tableName: TABLE_NAMES;
|
|
66
|
-
keys: Record<string, string>;
|
|
67
|
-
}): Promise<R | null>;
|
|
68
|
-
}
|
|
69
|
-
//# sourceMappingURL=index.d.ts.map
|