@mastra/dynamodb 1.0.0-beta.8 → 1.0.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/CHANGELOG.md +812 -0
- package/README.md +1 -2
- package/dist/docs/README.md +31 -0
- package/dist/docs/SKILL.md +32 -0
- package/dist/docs/SOURCE_MAP.json +6 -0
- package/dist/docs/storage/01-reference.md +253 -0
- package/dist/entities/eval.d.ts +8 -0
- package/dist/entities/eval.d.ts.map +1 -1
- package/dist/entities/index.d.ts +61 -4
- 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 +13 -4
- 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 +154 -45
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +152 -47
- package/dist/index.js.map +1 -1
- package/dist/storage/db/index.d.ts +18 -2
- package/dist/storage/db/index.d.ts.map +1 -1
- package/dist/storage/domains/memory/index.d.ts +3 -2
- package/dist/storage/domains/memory/index.d.ts.map +1 -1
- package/dist/storage/domains/scores/index.d.ts +1 -0
- package/dist/storage/domains/scores/index.d.ts.map +1 -1
- package/dist/storage/domains/workflows/index.d.ts +1 -0
- package/dist/storage/domains/workflows/index.d.ts.map +1 -1
- package/dist/storage/index.d.ts +90 -2
- 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 +9 -9
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Service } from 'electrodb';
|
|
2
|
+
import type { DynamoDBTtlConfig } from '../index.js';
|
|
2
3
|
/**
|
|
3
4
|
* Configuration for standalone domain usage.
|
|
4
5
|
* Accepts either:
|
|
@@ -11,6 +12,10 @@ export type DynamoDBDomainConfig = DynamoDBDomainServiceConfig | DynamoDBDomainR
|
|
|
11
12
|
*/
|
|
12
13
|
export interface DynamoDBDomainServiceConfig {
|
|
13
14
|
service: Service<Record<string, any>>;
|
|
15
|
+
/**
|
|
16
|
+
* TTL configuration for automatic data expiration.
|
|
17
|
+
*/
|
|
18
|
+
ttl?: DynamoDBTtlConfig;
|
|
14
19
|
}
|
|
15
20
|
/**
|
|
16
21
|
* Pass config to create a new ElectroDB service internally
|
|
@@ -23,10 +28,21 @@ export interface DynamoDBDomainRestConfig {
|
|
|
23
28
|
accessKeyId: string;
|
|
24
29
|
secretAccessKey: string;
|
|
25
30
|
};
|
|
31
|
+
/**
|
|
32
|
+
* TTL configuration for automatic data expiration.
|
|
33
|
+
*/
|
|
34
|
+
ttl?: DynamoDBTtlConfig;
|
|
26
35
|
}
|
|
27
36
|
/**
|
|
28
|
-
*
|
|
37
|
+
* Resolved DynamoDB config with service and TTL settings.
|
|
38
|
+
*/
|
|
39
|
+
export interface ResolvedDynamoDBConfig {
|
|
40
|
+
service: Service<Record<string, any>>;
|
|
41
|
+
ttl?: DynamoDBTtlConfig;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Resolves DynamoDBDomainConfig to an ElectroDB service and TTL config.
|
|
29
45
|
* Handles creating a new service if config is provided.
|
|
30
46
|
*/
|
|
31
|
-
export declare function resolveDynamoDBConfig(config: DynamoDBDomainConfig):
|
|
47
|
+
export declare function resolveDynamoDBConfig(config: DynamoDBDomainConfig): ResolvedDynamoDBConfig;
|
|
32
48
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/storage/db/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/storage/db/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAElD;;;;;GAKG;AACH,MAAM,MAAM,oBAAoB,GAAG,2BAA2B,GAAG,wBAAwB,CAAC;AAE1F;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC1C,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC;IACtC;;OAEG;IACH,GAAG,CAAC,EAAE,iBAAiB,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE;QACZ,WAAW,EAAE,MAAM,CAAC;QACpB,eAAe,EAAE,MAAM,CAAC;KACzB,CAAC;IACF;;OAEG;IACH,GAAG,CAAC,EAAE,iBAAiB,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC;IACtC,GAAG,CAAC,EAAE,iBAAiB,CAAC;CACzB;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,oBAAoB,GAAG,sBAAsB,CAkB1F"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { MastraMessageContentV2 } from '@mastra/core/agent';
|
|
2
2
|
import type { StorageThreadType, MastraDBMessage } from '@mastra/core/memory';
|
|
3
3
|
import { MemoryStorage } from '@mastra/core/storage';
|
|
4
|
-
import type { StorageResourceType, StorageListMessagesInput, StorageListMessagesOutput,
|
|
4
|
+
import type { StorageResourceType, StorageListMessagesInput, StorageListMessagesOutput, StorageListThreadsInput, StorageListThreadsOutput } from '@mastra/core/storage';
|
|
5
5
|
import type { DynamoDBDomainConfig } from '../../db/index.js';
|
|
6
6
|
export declare class MemoryStorageDynamoDB extends MemoryStorage {
|
|
7
7
|
private service;
|
|
8
|
+
private ttlConfig?;
|
|
8
9
|
constructor(config: DynamoDBDomainConfig);
|
|
9
10
|
dangerouslyClearAll(): Promise<void>;
|
|
10
11
|
deleteMessages(messageIds: string[]): Promise<void>;
|
|
@@ -35,7 +36,7 @@ export declare class MemoryStorageDynamoDB extends MemoryStorage {
|
|
|
35
36
|
}): Promise<{
|
|
36
37
|
messages: MastraDBMessage[];
|
|
37
38
|
}>;
|
|
38
|
-
|
|
39
|
+
listThreads(args: StorageListThreadsInput): Promise<StorageListThreadsOutput>;
|
|
39
40
|
private _getIncludedMessages;
|
|
40
41
|
updateMessages(args: {
|
|
41
42
|
messages: Partial<Omit<MastraDBMessage, 'createdAt'>> & {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/memory/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAEjE,OAAO,KAAK,EAAE,iBAAiB,EAAmB,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC/F,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/memory/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAEjE,OAAO,KAAK,EAAE,iBAAiB,EAAmB,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC/F,OAAO,EAGL,aAAa,EAMd,MAAM,sBAA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} from '../../db/index.js';
|
|
5
5
|
export declare class ScoresStorageDynamoDB extends ScoresStorage {
|
|
6
6
|
private service;
|
|
7
|
+
private ttlConfig?;
|
|
7
8
|
constructor(config: DynamoDBDomainConfig);
|
|
8
9
|
dangerouslyClearAll(): Promise<void>;
|
|
9
10
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/scores/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAE5G,OAAO,EAGL,aAAa,EAId,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAG9D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/scores/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAE5G,OAAO,EAGL,aAAa,EAId,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAG9D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAKrD,qBAAa,qBAAsB,SAAQ,aAAa;IACtD,OAAO,CAAC,OAAO,CAA+B;IAC9C,OAAO,CAAC,SAAS,CAAC,CAAoB;gBAE1B,MAAM,EAAE,oBAAoB;IAOlC,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC;IAI1C;;;;;;;OAOG;IACH,OAAO,CAAC,cAAc;IAsBhB,YAAY,CAAC,EAAE,EAAE,EAAE,EAAE;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;IAuBlE,SAAS,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,YAAY,CAAA;KAAE,CAAC;IA0GpE,oBAAoB,CAAC,EACzB,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,UAAU,EACV,MAAM,GACP,EAAE;QACD,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,iBAAiB,CAAC;QAC9B,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,MAAM,CAAC,EAAE,aAAa,CAAC;KACxB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IA6DzB,iBAAiB,CAAC,EACtB,KAAK,EACL,UAAU,GACX,EAAE;QACD,KAAK,EAAE,MAAM,CAAC;QACd,UAAU,EAAE,iBAAiB,CAAC;KAC/B,GAAG,OAAO,CAAC,kBAAkB,CAAC;IA6CzB,oBAAoB,CAAC,EACzB,QAAQ,EACR,UAAU,EACV,UAAU,GACX,EAAE;QACD,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,MAAM,CAAC;QACnB,UAAU,EAAE,iBAAiB,CAAC;KAC/B,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAgDzB,gBAAgB,CAAC,EACrB,OAAO,EACP,MAAM,EACN,UAAU,GACX,EAAE;QACD,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,MAAM,CAAC;QACf,UAAU,EAAE,iBAAiB,CAAC;KAC/B,GAAG,OAAO,CAAC,kBAAkB,CAAC;CA4ChC"}
|
|
@@ -4,6 +4,7 @@ import type { StepResult, WorkflowRunState } from '@mastra/core/workflows';
|
|
|
4
4
|
import type { DynamoDBDomainConfig } from '../../db/index.js';
|
|
5
5
|
export declare class WorkflowStorageDynamoDB extends WorkflowsStorage {
|
|
6
6
|
private service;
|
|
7
|
+
private ttlConfig?;
|
|
7
8
|
constructor(config: DynamoDBDomainConfig);
|
|
8
9
|
dangerouslyClearAll(): Promise<void>;
|
|
9
10
|
updateWorkflowResults({ workflowName, runId, stepId, result, requestContext, }: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/workflows/index.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,gBAAgB,EACjB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EACV,WAAW,EACX,YAAY,EACZ,4BAA4B,EAC5B,0BAA0B,EAC3B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/workflows/index.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,gBAAgB,EACjB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EACV,WAAW,EACX,YAAY,EACZ,4BAA4B,EAC5B,0BAA0B,EAC3B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAI3E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AA2BrD,qBAAa,uBAAwB,SAAQ,gBAAgB;IAC3D,OAAO,CAAC,OAAO,CAA+B;IAC9C,OAAO,CAAC,SAAS,CAAC,CAAoB;gBAE1B,MAAM,EAAE,oBAAoB;IAOlC,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC;IAIpC,qBAAqB,CAAC,EAC1B,YAAY,EACZ,KAAK,EACL,MAAM,EACN,MAAM,EACN,cAAc,GACf,EAAE;QACD,YAAY,EAAE,MAAM,CAAC;QACrB,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,UAAU,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,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AAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAuB7G"}
|
package/dist/storage/index.d.ts
CHANGED
|
@@ -1,11 +1,66 @@
|
|
|
1
1
|
import { DynamoDBDocumentClient } from '@aws-sdk/lib-dynamodb';
|
|
2
2
|
import type { StorageDomains } from '@mastra/core/storage';
|
|
3
|
-
import {
|
|
3
|
+
import { MastraCompositeStore } from '@mastra/core/storage';
|
|
4
4
|
import { MemoryStorageDynamoDB } from './domains/memory/index.js';
|
|
5
5
|
import { ScoresStorageDynamoDB } from './domains/scores/index.js';
|
|
6
6
|
import { WorkflowStorageDynamoDB } from './domains/workflows/index.js';
|
|
7
7
|
export { MemoryStorageDynamoDB, ScoresStorageDynamoDB, WorkflowStorageDynamoDB };
|
|
8
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
|
+
};
|
|
9
64
|
/**
|
|
10
65
|
* DynamoDB configuration type.
|
|
11
66
|
*
|
|
@@ -36,6 +91,38 @@ export type DynamoDBStoreConfig = {
|
|
|
36
91
|
* // No auto-init, tables must already exist
|
|
37
92
|
*/
|
|
38
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;
|
|
39
126
|
} & ({
|
|
40
127
|
/**
|
|
41
128
|
* Pre-configured DynamoDB Document client.
|
|
@@ -90,10 +177,11 @@ export type DynamoDBStoreConfig = {
|
|
|
90
177
|
* await workflows?.persistWorkflowSnapshot({ workflowName, runId, snapshot });
|
|
91
178
|
* ```
|
|
92
179
|
*/
|
|
93
|
-
export declare class DynamoDBStore extends
|
|
180
|
+
export declare class DynamoDBStore extends MastraCompositeStore {
|
|
94
181
|
private tableName;
|
|
95
182
|
private client;
|
|
96
183
|
private service;
|
|
184
|
+
private ttlConfig?;
|
|
97
185
|
protected hasInitialized: Promise<boolean> | null;
|
|
98
186
|
stores: StorageDomains;
|
|
99
187
|
constructor({ name, config }: {
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
1
|
+
{"version":3,"file":"index.d.ts","s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;;;;;;;;;;;;;;;;;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": "1.0.0
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "DynamoDB storage adapter for Mastra",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -34,15 +34,14 @@
|
|
|
34
34
|
"@types/node": "22.13.17",
|
|
35
35
|
"@vitest/coverage-v8": "4.0.12",
|
|
36
36
|
"@vitest/ui": "4.0.12",
|
|
37
|
-
"axios": "^1.12.2",
|
|
38
37
|
"eslint": "^9.37.0",
|
|
39
38
|
"tsup": "^8.5.0",
|
|
40
|
-
"typescript": "^5.
|
|
41
|
-
"vitest": "4.0.
|
|
42
|
-
"@internal/lint": "0.0.
|
|
43
|
-
"@internal/
|
|
44
|
-
"@mastra/core": "1.0.0
|
|
45
|
-
"@internal/
|
|
39
|
+
"typescript": "^5.9.3",
|
|
40
|
+
"vitest": "4.0.16",
|
|
41
|
+
"@internal/lint": "0.0.54",
|
|
42
|
+
"@internal/types-builder": "0.0.29",
|
|
43
|
+
"@mastra/core": "1.0.0",
|
|
44
|
+
"@internal/storage-test-utils": "0.0.50"
|
|
46
45
|
},
|
|
47
46
|
"homepage": "https://mastra.ai",
|
|
48
47
|
"repository": {
|
|
@@ -57,7 +56,8 @@
|
|
|
57
56
|
"node": ">=22.13.0"
|
|
58
57
|
},
|
|
59
58
|
"scripts": {
|
|
60
|
-
"build": "tsup --silent --config tsup.config.ts",
|
|
59
|
+
"build:lib": "tsup --silent --config tsup.config.ts",
|
|
60
|
+
"build:docs": "pnpx tsx ../../scripts/generate-package-docs.ts stores/dynamodb",
|
|
61
61
|
"dev": "tsup --watch && tsc -p tsconfig.build.json",
|
|
62
62
|
"clean": "rm -rf dist",
|
|
63
63
|
"lint": "eslint .",
|