@farukada/aws-langgraph-dynamodb-ts 0.0.2
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/LICENSE +21 -0
- package/README.md +960 -0
- package/dist/checkpointer/actions/delete-thread.d.ts +9 -0
- package/dist/checkpointer/actions/delete-thread.d.ts.map +1 -0
- package/dist/checkpointer/actions/delete-thread.js +109 -0
- package/dist/checkpointer/actions/delete-thread.js.map +1 -0
- package/dist/checkpointer/actions/get-tuple.d.ts +11 -0
- package/dist/checkpointer/actions/get-tuple.d.ts.map +1 -0
- package/dist/checkpointer/actions/get-tuple.js +96 -0
- package/dist/checkpointer/actions/get-tuple.js.map +1 -0
- package/dist/checkpointer/actions/index.d.ts +5 -0
- package/dist/checkpointer/actions/index.d.ts.map +1 -0
- package/dist/checkpointer/actions/index.js +21 -0
- package/dist/checkpointer/actions/index.js.map +1 -0
- package/dist/checkpointer/actions/put-writes.d.ts +9 -0
- package/dist/checkpointer/actions/put-writes.d.ts.map +1 -0
- package/dist/checkpointer/actions/put-writes.js +63 -0
- package/dist/checkpointer/actions/put-writes.js.map +1 -0
- package/dist/checkpointer/actions/put.d.ts +11 -0
- package/dist/checkpointer/actions/put.d.ts.map +1 -0
- package/dist/checkpointer/actions/put.js +55 -0
- package/dist/checkpointer/actions/put.js.map +1 -0
- package/dist/checkpointer/actions/validate-configurable.d.ts +10 -0
- package/dist/checkpointer/actions/validate-configurable.d.ts.map +1 -0
- package/dist/checkpointer/actions/validate-configurable.js +39 -0
- package/dist/checkpointer/actions/validate-configurable.js.map +1 -0
- package/dist/checkpointer/actions/writer.d.ts +50 -0
- package/dist/checkpointer/actions/writer.d.ts.map +1 -0
- package/dist/checkpointer/actions/writer.js +109 -0
- package/dist/checkpointer/actions/writer.js.map +1 -0
- package/dist/checkpointer/index.d.ts +70 -0
- package/dist/checkpointer/index.d.ts.map +1 -0
- package/dist/checkpointer/index.js +172 -0
- package/dist/checkpointer/index.js.map +1 -0
- package/dist/checkpointer/types/index.d.ts +162 -0
- package/dist/checkpointer/types/index.d.ts.map +1 -0
- package/dist/checkpointer/types/index.js +3 -0
- package/dist/checkpointer/types/index.js.map +1 -0
- package/dist/checkpointer/utils/index.d.ts +6 -0
- package/dist/checkpointer/utils/index.d.ts.map +1 -0
- package/dist/checkpointer/utils/index.js +26 -0
- package/dist/checkpointer/utils/index.js.map +1 -0
- package/dist/checkpointer/utils/validation.d.ts +48 -0
- package/dist/checkpointer/utils/validation.d.ts.map +1 -0
- package/dist/checkpointer/utils/validation.js +190 -0
- package/dist/checkpointer/utils/validation.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/shared/index.d.ts +5 -0
- package/dist/shared/index.d.ts.map +1 -0
- package/dist/shared/index.js +21 -0
- package/dist/shared/index.js.map +1 -0
- package/dist/shared/utils/constants.d.ts +11 -0
- package/dist/shared/utils/constants.d.ts.map +1 -0
- package/dist/shared/utils/constants.js +35 -0
- package/dist/shared/utils/constants.js.map +1 -0
- package/dist/shared/utils/index.d.ts +6 -0
- package/dist/shared/utils/index.d.ts.map +1 -0
- package/dist/shared/utils/index.js +22 -0
- package/dist/shared/utils/index.js.map +1 -0
- package/dist/shared/utils/retry.d.ts +19 -0
- package/dist/shared/utils/retry.d.ts.map +1 -0
- package/dist/shared/utils/retry.js +102 -0
- package/dist/shared/utils/retry.js.map +1 -0
- package/dist/store/actions/get-operation.d.ts +11 -0
- package/dist/store/actions/get-operation.d.ts.map +1 -0
- package/dist/store/actions/get-operation.js +42 -0
- package/dist/store/actions/get-operation.js.map +1 -0
- package/dist/store/actions/index.d.ts +5 -0
- package/dist/store/actions/index.d.ts.map +1 -0
- package/dist/store/actions/index.js +21 -0
- package/dist/store/actions/index.js.map +1 -0
- package/dist/store/actions/list-namespaces-operation.d.ts +10 -0
- package/dist/store/actions/list-namespaces-operation.d.ts.map +1 -0
- package/dist/store/actions/list-namespaces-operation.js +212 -0
- package/dist/store/actions/list-namespaces-operation.js.map +1 -0
- package/dist/store/actions/put-operation.d.ts +9 -0
- package/dist/store/actions/put-operation.d.ts.map +1 -0
- package/dist/store/actions/put-operation.js +94 -0
- package/dist/store/actions/put-operation.js.map +1 -0
- package/dist/store/actions/search-operation.d.ts +11 -0
- package/dist/store/actions/search-operation.d.ts.map +1 -0
- package/dist/store/actions/search-operation.js +150 -0
- package/dist/store/actions/search-operation.js.map +1 -0
- package/dist/store/index.d.ts +73 -0
- package/dist/store/index.d.ts.map +1 -0
- package/dist/store/index.js +145 -0
- package/dist/store/index.js.map +1 -0
- package/dist/store/types/index.d.ts +97 -0
- package/dist/store/types/index.d.ts.map +1 -0
- package/dist/store/types/index.js +3 -0
- package/dist/store/types/index.js.map +1 -0
- package/dist/store/utils/filter.d.ts +16 -0
- package/dist/store/utils/filter.d.ts.map +1 -0
- package/dist/store/utils/filter.js +71 -0
- package/dist/store/utils/filter.js.map +1 -0
- package/dist/store/utils/index.d.ts +8 -0
- package/dist/store/utils/index.d.ts.map +1 -0
- package/dist/store/utils/index.js +28 -0
- package/dist/store/utils/index.js.map +1 -0
- package/dist/store/utils/result.d.ts +42 -0
- package/dist/store/utils/result.d.ts.map +1 -0
- package/dist/store/utils/result.js +51 -0
- package/dist/store/utils/result.js.map +1 -0
- package/dist/store/utils/validation.d.ts +57 -0
- package/dist/store/utils/validation.d.ts.map +1 -0
- package/dist/store/utils/validation.js +243 -0
- package/dist/store/utils/validation.js.map +1 -0
- package/package.json +85 -0
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DynamoDBStore = void 0;
|
|
4
|
+
const langgraph_1 = require("@langchain/langgraph");
|
|
5
|
+
const client_dynamodb_1 = require("@aws-sdk/client-dynamodb");
|
|
6
|
+
const lib_dynamodb_1 = require("@aws-sdk/lib-dynamodb");
|
|
7
|
+
const actions_1 = require("./actions");
|
|
8
|
+
const utils_1 = require("./utils");
|
|
9
|
+
/**
|
|
10
|
+
* DynamoDB-based store implementation for LangGraph
|
|
11
|
+
* Provides persistent storage for memory items with optional semantic search via embeddings
|
|
12
|
+
*/
|
|
13
|
+
class DynamoDBStore extends langgraph_1.BaseStore {
|
|
14
|
+
ddbClient;
|
|
15
|
+
client;
|
|
16
|
+
memoryTableName;
|
|
17
|
+
embedding;
|
|
18
|
+
ttlDays;
|
|
19
|
+
/**
|
|
20
|
+
* Create a new DynamoDB store instance
|
|
21
|
+
*
|
|
22
|
+
* @param options - Configuration options for the store
|
|
23
|
+
* @param options.memoryTableName - Name of the DynamoDB table to use
|
|
24
|
+
* @param options.embedding - Optional Bedrock embeddings for semantic search
|
|
25
|
+
* @param options.clientConfig - Optional DynamoDB client configuration
|
|
26
|
+
* @param options.ttlDays - Optional TTL in days for stored items
|
|
27
|
+
*/
|
|
28
|
+
constructor(options) {
|
|
29
|
+
super();
|
|
30
|
+
this.memoryTableName = options.memoryTableName;
|
|
31
|
+
this.ddbClient = new client_dynamodb_1.DynamoDBClient(options.clientConfig || {});
|
|
32
|
+
this.client = lib_dynamodb_1.DynamoDBDocument.from(this.ddbClient);
|
|
33
|
+
this.embedding = options.embedding;
|
|
34
|
+
this.ttlDays = options.ttlDays;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Extract and validate user ID from config
|
|
38
|
+
*
|
|
39
|
+
* @param config - Runnable configuration
|
|
40
|
+
* @returns User ID string
|
|
41
|
+
* @throws Error if user_id is not provided or invalid
|
|
42
|
+
*/
|
|
43
|
+
getUserId(config) {
|
|
44
|
+
const userId = config?.configurable?.user_id;
|
|
45
|
+
if (!userId || typeof userId !== 'string') {
|
|
46
|
+
throw new Error('Field user_id is required in the RunnableConfig for DynamoDBStore.');
|
|
47
|
+
}
|
|
48
|
+
return userId;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Execute a batch of operations in parallel
|
|
52
|
+
*
|
|
53
|
+
* @param operations - Array of operations to execute
|
|
54
|
+
* @param config - Runnable configuration containing user_id
|
|
55
|
+
* @returns Array of results corresponding to each operation
|
|
56
|
+
* @throws Error if user_id is not provided in config or if any operation fails
|
|
57
|
+
*/
|
|
58
|
+
async batch(operations, config) {
|
|
59
|
+
const userId = this.getUserId(config);
|
|
60
|
+
// Validate batch size to prevent resource exhaustion
|
|
61
|
+
(0, utils_1.validateBatchSize)(operations.length);
|
|
62
|
+
// Execute all operations in parallel for better performance
|
|
63
|
+
const promises = operations.map(async (op, index) => {
|
|
64
|
+
if ('key' in op && !('value' in op)) {
|
|
65
|
+
return await this.getOperation(userId, op);
|
|
66
|
+
}
|
|
67
|
+
if ('key' in op && 'value' in op) {
|
|
68
|
+
return await this.putOperation(userId, op);
|
|
69
|
+
}
|
|
70
|
+
if ('namespacePrefix' in op) {
|
|
71
|
+
return await this.searchOperation(userId, op);
|
|
72
|
+
}
|
|
73
|
+
if (!('namespacePrefix' in op) && 'limit' in op && 'offset' in op) {
|
|
74
|
+
return await this.listNamespacesOperation(userId, op);
|
|
75
|
+
}
|
|
76
|
+
// Unrecognized operation - sanitized error message to prevent information disclosure
|
|
77
|
+
throw new Error(`Unrecognized operation type at index ${index}`);
|
|
78
|
+
});
|
|
79
|
+
return (await Promise.all(promises));
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Get a single item from the store
|
|
83
|
+
*
|
|
84
|
+
* @param userId - User ID for the item
|
|
85
|
+
* @param op - Get operation parameters
|
|
86
|
+
* @returns The item if found, null otherwise
|
|
87
|
+
*/
|
|
88
|
+
async getOperation(userId, op) {
|
|
89
|
+
return await (0, actions_1.getOperationAction)({
|
|
90
|
+
client: this.client,
|
|
91
|
+
memoryTableName: this.memoryTableName,
|
|
92
|
+
userId,
|
|
93
|
+
op,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Put an item into the store
|
|
98
|
+
*
|
|
99
|
+
* @param userId - User ID for the item
|
|
100
|
+
* @param op - Put operation parameters
|
|
101
|
+
*/
|
|
102
|
+
async putOperation(userId, op) {
|
|
103
|
+
await (0, actions_1.putOperationAction)({
|
|
104
|
+
client: this.client,
|
|
105
|
+
memoryTableName: this.memoryTableName,
|
|
106
|
+
userId,
|
|
107
|
+
op,
|
|
108
|
+
embedding: this.embedding,
|
|
109
|
+
ttlDays: this.ttlDays,
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Search for items in the store with optional semantic search
|
|
114
|
+
*
|
|
115
|
+
* @param userId - User ID for filtering items
|
|
116
|
+
* @param op - Search operation parameters
|
|
117
|
+
* @returns Array of matching items with optional similarity scores
|
|
118
|
+
*/
|
|
119
|
+
async searchOperation(userId, op) {
|
|
120
|
+
return await (0, actions_1.searchOperationAction)({
|
|
121
|
+
client: this.client,
|
|
122
|
+
memoryTableName: this.memoryTableName,
|
|
123
|
+
userId,
|
|
124
|
+
op,
|
|
125
|
+
embedding: this.embedding,
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* List unique namespaces in the store
|
|
130
|
+
*
|
|
131
|
+
* @param userId - User ID for filtering namespaces
|
|
132
|
+
* @param op - List namespaces operation parameters
|
|
133
|
+
* @returns Array of namespace paths
|
|
134
|
+
*/
|
|
135
|
+
async listNamespacesOperation(userId, op) {
|
|
136
|
+
return await (0, actions_1.listNamespacesOperationAction)({
|
|
137
|
+
client: this.client,
|
|
138
|
+
memoryTableName: this.memoryTableName,
|
|
139
|
+
userId,
|
|
140
|
+
op,
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
exports.DynamoDBStore = DynamoDBStore;
|
|
145
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/store/index.ts"],"names":[],"mappings":";;;AAAA,oDAS8B;AAK9B,8DAA0D;AA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CAAC,SAAS;YACzB,OAAO,EAAE,IAAI,CAAC,OAAO;SACtB,CAAC,CAAC;IACL,CAAC;IAED;;;;;;OAMG;IACK,KAAK,CAAC,eAAe,CAAC,MAAc,EAAE,EAAmB;QAC/D,OAAO,MAAM,IAAA,+BAAqB,EAAC;YACjC,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,eAAe,EAAE,IAAI,CAAC,eAAe;YACrC,MAAM;YACN,EAAE;YACF,SAAS,EAAE,IAAI,CAAC,SAAS;SAC1B,CAAC,CAAC;IACL,CAAC;IAED;;;;;;OAMG;IACK,KAAK,CAAC,uBAAuB,CACnC,MAAc,EACd,EAA2B;QAE3B,OAAO,MAAM,IAAA,uCAA6B,EAAC;YACzC,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,eAAe,EAAE,IAAI,CAAC,eAAe;YACrC,MAAM;YACN,EAAE;SACH,CAAC,CAAC;IACL,CAAC;CACF;AAnJD,sCAmJC"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { BedrockEmbeddings } from '@langchain/aws';
|
|
2
|
+
import { DynamoDBClientConfig } from '@aws-sdk/client-dynamodb';
|
|
3
|
+
import { DynamoDBDocument } from '@aws-sdk/lib-dynamodb';
|
|
4
|
+
import { GetOperation, type ListNamespacesOperation, type PutOperation, type SearchOperation } from '@langchain/langgraph';
|
|
5
|
+
/**
|
|
6
|
+
* Namespace path - array of strings with optional wildcards
|
|
7
|
+
*/
|
|
8
|
+
export type NamespacePath = (string | '*')[];
|
|
9
|
+
/**
|
|
10
|
+
* Configuration options for DynamoDBStore
|
|
11
|
+
*/
|
|
12
|
+
export interface DynamoDBStoreOptions {
|
|
13
|
+
/** Name of the DynamoDB table to use for storage */
|
|
14
|
+
memoryTableName: string;
|
|
15
|
+
/** Optional Bedrock embeddings for semantic search */
|
|
16
|
+
embedding?: BedrockEmbeddings;
|
|
17
|
+
/** Optional DynamoDB client configuration */
|
|
18
|
+
clientConfig?: DynamoDBClientConfig;
|
|
19
|
+
/** Optional TTL in days for stored items (1-1825 days) */
|
|
20
|
+
ttlDays?: number;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Parameters for put operation action
|
|
24
|
+
*/
|
|
25
|
+
export interface PutOperationActionParams {
|
|
26
|
+
/** DynamoDB document client */
|
|
27
|
+
client: DynamoDBDocument;
|
|
28
|
+
/** Name of the memory table */
|
|
29
|
+
memoryTableName: string;
|
|
30
|
+
/** User ID for the operation */
|
|
31
|
+
userId: string;
|
|
32
|
+
/** Put operation parameters */
|
|
33
|
+
op: PutOperation;
|
|
34
|
+
/** Optional embeddings for semantic search */
|
|
35
|
+
embedding?: BedrockEmbeddings;
|
|
36
|
+
/** Optional TTL in days */
|
|
37
|
+
ttlDays?: number;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Parameters for get operation action
|
|
41
|
+
*/
|
|
42
|
+
export interface GetOperationActionParams {
|
|
43
|
+
/** DynamoDB document client */
|
|
44
|
+
client: DynamoDBDocument;
|
|
45
|
+
/** Name of the memory table */
|
|
46
|
+
memoryTableName: string;
|
|
47
|
+
/** User ID for the operation */
|
|
48
|
+
userId: string;
|
|
49
|
+
/** Get operation parameters */
|
|
50
|
+
op: GetOperation;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Parameters for search operation action
|
|
54
|
+
*/
|
|
55
|
+
export interface SearchOperationActionParams {
|
|
56
|
+
/** DynamoDB document client */
|
|
57
|
+
client: DynamoDBDocument;
|
|
58
|
+
/** Name of the memory table */
|
|
59
|
+
memoryTableName: string;
|
|
60
|
+
/** User ID for the operation */
|
|
61
|
+
userId: string;
|
|
62
|
+
/** Search operation parameters */
|
|
63
|
+
op: SearchOperation;
|
|
64
|
+
/** Optional embeddings for semantic search */
|
|
65
|
+
embedding?: BedrockEmbeddings;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Parameters for list namespaces operation action
|
|
69
|
+
*/
|
|
70
|
+
export interface ListNamespacesOperationActionParams {
|
|
71
|
+
/** DynamoDB document client */
|
|
72
|
+
client: DynamoDBDocument;
|
|
73
|
+
/** Name of the memory table */
|
|
74
|
+
memoryTableName: string;
|
|
75
|
+
/** User ID for the operation */
|
|
76
|
+
userId: string;
|
|
77
|
+
/** List namespaces operation parameters */
|
|
78
|
+
op: ListNamespacesOperation;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Filter value with comparison operators
|
|
82
|
+
*/
|
|
83
|
+
export type FilterValue = {
|
|
84
|
+
/** Equal to */
|
|
85
|
+
$eq?: any;
|
|
86
|
+
/** Not equal to */
|
|
87
|
+
$ne?: any;
|
|
88
|
+
/** Greater than */
|
|
89
|
+
$gt?: number;
|
|
90
|
+
/** Greater than or equal to */
|
|
91
|
+
$gte?: number;
|
|
92
|
+
/** Less than */
|
|
93
|
+
$lt?: number;
|
|
94
|
+
/** Less than or equal to */
|
|
95
|
+
$lte?: number;
|
|
96
|
+
};
|
|
97
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/store/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EACL,YAAY,EACZ,KAAK,uBAAuB,EAC5B,KAAK,YAAY,EACjB,KAAK,eAAe,EACrB,MAAM,sBAAsB,CAAC;AAE9B;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,MAAM,GAAG,GAAG,CAAC,EAAE,CAAC;AAE7C;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,oDAAoD;IACpD,eAAe,EAAE,MAAM,CAAC;IACxB,sDAAsD;IACtD,SAAS,CAAC,EAAE,iBAAiB,CAAC;IAC9B,6CAA6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G,CAAC,EAAE,GAAG,CAAC;IACV,mBAAmB;IACnB,GAAG,CAAC,EAAE,GAAG,CAAC;IACV,mBAAmB;IACnB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,+BAA+B;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,gBAAgB;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,4BAA4B;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/store/types/index.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DynamoDB filter expression builder utilities
|
|
3
|
+
*/
|
|
4
|
+
import { FilterValue } from '../types';
|
|
5
|
+
/**
|
|
6
|
+
* Build DynamoDB filter expression from a filter object
|
|
7
|
+
*
|
|
8
|
+
* @param filter - Filter criteria object with field names and values
|
|
9
|
+
* @param expressionAttributeNames - Object to populate with attribute name mappings
|
|
10
|
+
* @param expressionAttributeValues - Object to populate with attribute value mappings
|
|
11
|
+
* @returns Object containing the constructed filter expression
|
|
12
|
+
*/
|
|
13
|
+
export declare function buildFilterExpression(filter: Record<string, FilterValue | any>, expressionAttributeNames: Record<string, string>, expressionAttributeValues: Record<string, any>): {
|
|
14
|
+
filterExpression: string;
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=filter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filter.d.ts","sourceRoot":"","sources":["../../../src/store/utils/filter.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,GAAG,GAAG,CAAC,EACzC,wBAAwB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAChD,yBAAyB,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAC7C;IACD,gBAAgB,EAAE,MAAM,CAAC;CAC1B,CA+DA"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* DynamoDB filter expression builder utilities
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.buildFilterExpression = buildFilterExpression;
|
|
7
|
+
/**
|
|
8
|
+
* Build DynamoDB filter expression from a filter object
|
|
9
|
+
*
|
|
10
|
+
* @param filter - Filter criteria object with field names and values
|
|
11
|
+
* @param expressionAttributeNames - Object to populate with attribute name mappings
|
|
12
|
+
* @param expressionAttributeValues - Object to populate with attribute value mappings
|
|
13
|
+
* @returns Object containing the constructed filter expression
|
|
14
|
+
*/
|
|
15
|
+
function buildFilterExpression(filter, expressionAttributeNames, expressionAttributeValues) {
|
|
16
|
+
const filterExpressions = [];
|
|
17
|
+
let nameCounter = Object.keys(expressionAttributeNames).length;
|
|
18
|
+
let valueCounter = Object.keys(expressionAttributeValues).length;
|
|
19
|
+
// Add #value for nested access if not present
|
|
20
|
+
if (!expressionAttributeNames['#value']) {
|
|
21
|
+
expressionAttributeNames['#value'] = 'value';
|
|
22
|
+
}
|
|
23
|
+
for (const [fieldKey, fieldValue] of Object.entries(filter)) {
|
|
24
|
+
const attrName = `#attr${nameCounter++}`;
|
|
25
|
+
const valuePath = `#value.${attrName}`;
|
|
26
|
+
expressionAttributeNames[attrName] = fieldKey;
|
|
27
|
+
// Handle operator-based filtering
|
|
28
|
+
if (typeof fieldValue === 'object' && fieldValue !== null && !Array.isArray(fieldValue)) {
|
|
29
|
+
if (fieldValue.$eq !== undefined) {
|
|
30
|
+
const valueKey = `:val${valueCounter++}`;
|
|
31
|
+
expressionAttributeValues[valueKey] = fieldValue.$eq;
|
|
32
|
+
filterExpressions.push(`${valuePath} = ${valueKey}`);
|
|
33
|
+
}
|
|
34
|
+
if (fieldValue.$ne !== undefined) {
|
|
35
|
+
const valueKey = `:val${valueCounter++}`;
|
|
36
|
+
expressionAttributeValues[valueKey] = fieldValue.$ne;
|
|
37
|
+
filterExpressions.push(`${valuePath} <> ${valueKey}`);
|
|
38
|
+
}
|
|
39
|
+
if (fieldValue.$gt !== undefined) {
|
|
40
|
+
const valueKey = `:val${valueCounter++}`;
|
|
41
|
+
expressionAttributeValues[valueKey] = fieldValue.$gt;
|
|
42
|
+
filterExpressions.push(`${valuePath} > ${valueKey}`);
|
|
43
|
+
}
|
|
44
|
+
if (fieldValue.$gte !== undefined) {
|
|
45
|
+
const valueKey = `:val${valueCounter++}`;
|
|
46
|
+
expressionAttributeValues[valueKey] = fieldValue.$gte;
|
|
47
|
+
filterExpressions.push(`${valuePath} >= ${valueKey}`);
|
|
48
|
+
}
|
|
49
|
+
if (fieldValue.$lt !== undefined) {
|
|
50
|
+
const valueKey = `:val${valueCounter++}`;
|
|
51
|
+
expressionAttributeValues[valueKey] = fieldValue.$lt;
|
|
52
|
+
filterExpressions.push(`${valuePath} < ${valueKey}`);
|
|
53
|
+
}
|
|
54
|
+
if (fieldValue.$lte !== undefined) {
|
|
55
|
+
const valueKey = `:val${valueCounter++}`;
|
|
56
|
+
expressionAttributeValues[valueKey] = fieldValue.$lte;
|
|
57
|
+
filterExpressions.push(`${valuePath} <= ${valueKey}`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
// Direct equality comparison
|
|
62
|
+
const valueKey = `:val${valueCounter++}`;
|
|
63
|
+
expressionAttributeValues[valueKey] = fieldValue;
|
|
64
|
+
filterExpressions.push(`${valuePath} = ${valueKey}`);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return {
|
|
68
|
+
filterExpression: filterExpressions.length > 0 ? filterExpressions.join(' AND ') : '',
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=filter.js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AiB,CAAC,IAAI,CAAC,GAAG,SAAS,OAAO,QAAQ,EAAE,CAAC,CAAC;YACxD,CAAC;QACH,CAAC;aAAM,CAAC;YACN,6BAA6B;YAC7B,MAAM,QAAQ,GAAG,OAAO,YAAY,EAAE,EAAE,CAAC;YACzC,yBAAyB,CAAC,QAAQ,CAAC,GAAG,UAAU,CAAC;YACjD,iBAAiB,CAAC,IAAI,CAAC,GAAG,SAAS,MAAM,QAAQ,EAAE,CAAC,CAAC;QACvD,CAAC;IACH,CAAC;IAED,OAAO;QACL,gBAAgB,EAAE,iBAAiB,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE;KACtF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/store/utils/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AAEzB,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Store utilities
|
|
4
|
+
*/
|
|
5
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
+
}
|
|
11
|
+
Object.defineProperty(o, k2, desc);
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
17
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.withRetry = exports.withDynamoDBRetry = void 0;
|
|
21
|
+
__exportStar(require("./result"), exports);
|
|
22
|
+
__exportStar(require("./validation"), exports);
|
|
23
|
+
__exportStar(require("./filter"), exports);
|
|
24
|
+
// Retry utilities re-exported from shared
|
|
25
|
+
var utils_1 = require("../../shared/utils");
|
|
26
|
+
Object.defineProperty(exports, "withDynamoDBRetry", { enumerable: true, get: function () { return utils_1.withDynamoDBRetry; } });
|
|
27
|
+
Object.defineProperty(exports, "withRetry", { enumerable: true, get: function () { return utils_1.withRetry; } });
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/store/utils/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;;AAEH,2CAAyB;AACzB,+CAA6B;AAC7B,2CAAyB;AACzB,0CAA0C;AAC1C,4CAAqF;AAA5E,0GAAA,iBAAiB,OAAA;AAAE,kGAAA,SAAS,OAAA"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Result type for better error handling
|
|
3
|
+
* Allows functions to return either a success value or an error
|
|
4
|
+
*/
|
|
5
|
+
export type Result<T, E = Error> = {
|
|
6
|
+
success: true;
|
|
7
|
+
data: T;
|
|
8
|
+
} | {
|
|
9
|
+
success: false;
|
|
10
|
+
error: E;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Create a successful result
|
|
14
|
+
*/
|
|
15
|
+
export declare function Ok<T>(data: T): Result<T, never>;
|
|
16
|
+
/**
|
|
17
|
+
* Create an error result
|
|
18
|
+
*/
|
|
19
|
+
export declare function Err<E = Error>(error: E): Result<never, E>;
|
|
20
|
+
/**
|
|
21
|
+
* Check if a result is successful
|
|
22
|
+
*/
|
|
23
|
+
export declare function isOk<T, E>(result: Result<T, E>): result is {
|
|
24
|
+
success: true;
|
|
25
|
+
data: T;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Check if a result is an error
|
|
29
|
+
*/
|
|
30
|
+
export declare function isErr<T, E>(result: Result<T, E>): result is {
|
|
31
|
+
success: false;
|
|
32
|
+
error: E;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Unwrap a result or throw if it's an error
|
|
36
|
+
*/
|
|
37
|
+
export declare function unwrap<T, E>(result: Result<T, E>): T;
|
|
38
|
+
/**
|
|
39
|
+
* Unwrap a result or return a default value if it's an error
|
|
40
|
+
*/
|
|
41
|
+
export declare function unwrapOr<T, E>(result: Result<T, E>, defaultValue: T): T;
|
|
42
|
+
//# sourceMappingURL=result.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"result.d.ts","sourceRoot":"","sources":["../../../src/store/utils/result.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,MAAM,MAAM,CAAC,CAAC,EAAE,CAAC,GAAG,KAAK,IAAI;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,CAAC,CAAA;CAAE,GAAG;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,CAAC,CAAA;CAAE,CAAC;AAE7F;;GAEG;AACH,wBAAgB,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,GAAG,MAAM,CAAC,CAAC,EAAE,KAAK,CAAC,CAE/C;AAED;;GAEG;AACH,wBAAgB,GAAG,CAAC,CAAC,GAAG,KAAK,EAAE,KAAK,EAAE,CAAC,GAAG,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAEzD;AAED;;GAEG;AACH,wBAAgB,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,MAAM,IAAI;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,CAAC,CAAA;CAAE,CAErF;AAED;;GAEG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,MAAM,IAAI;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,CAAC,CAAA;CAAE,CAExF;AAED;;GAEG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAKpD;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,GAAG,CAAC,CAKvE"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Ok = Ok;
|
|
4
|
+
exports.Err = Err;
|
|
5
|
+
exports.isOk = isOk;
|
|
6
|
+
exports.isErr = isErr;
|
|
7
|
+
exports.unwrap = unwrap;
|
|
8
|
+
exports.unwrapOr = unwrapOr;
|
|
9
|
+
/**
|
|
10
|
+
* Create a successful result
|
|
11
|
+
*/
|
|
12
|
+
function Ok(data) {
|
|
13
|
+
return { success: true, data };
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Create an error result
|
|
17
|
+
*/
|
|
18
|
+
function Err(error) {
|
|
19
|
+
return { success: false, error };
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Check if a result is successful
|
|
23
|
+
*/
|
|
24
|
+
function isOk(result) {
|
|
25
|
+
return result.success === true;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Check if a result is an error
|
|
29
|
+
*/
|
|
30
|
+
function isErr(result) {
|
|
31
|
+
return result.success === false;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Unwrap a result or throw if it's an error
|
|
35
|
+
*/
|
|
36
|
+
function unwrap(result) {
|
|
37
|
+
if (isOk(result)) {
|
|
38
|
+
return result.data;
|
|
39
|
+
}
|
|
40
|
+
throw result.error;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Unwrap a result or return a default value if it's an error
|
|
44
|
+
*/
|
|
45
|
+
function unwrapOr(result, defaultValue) {
|
|
46
|
+
if (isOk(result)) {
|
|
47
|
+
return result.data;
|
|
48
|
+
}
|
|
49
|
+
return defaultValue;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=result.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"result.js","sourceRoot":"","sources":["../../../src/store/utils/result.ts"],"names":[],"mappings":";;AASA,gBAEC;AAKD,kBAEC;AAKD,oBAEC;AAKD,sBAEC;AAKD,wBAKC;AAKD,4BAKC;AA9CD;;GAEG;AACH,SAAgB,EAAE,CAAI,IAAO;IAC3B,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;AACjC,CAAC;AAED;;GAEG;AACH,SAAgB,GAAG,CAAY,KAAQ;IACrC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;AACnC,CAAC;AAED;;GAEG;AACH,SAAgB,IAAI,CAAO,MAAoB;IAC7C,OAAO,MAAM,CAAC,OAAO,KAAK,IAAI,CAAC;AACjC,CAAC;AAED;;GAEG;AACH,SAAgB,KAAK,CAAO,MAAoB;IAC9C,OAAO,MAAM,CAAC,OAAO,KAAK,KAAK,CAAC;AAClC,CAAC;AAED;;GAEG;AACH,SAAgB,MAAM,CAAO,MAAoB;IAC/C,IAAI,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QACjB,OAAO,MAAM,CAAC,IAAI,CAAC;IACrB,CAAC;IACD,MAAM,MAAM,CAAC,KAAK,CAAC;AACrB,CAAC;AAED;;GAEG;AACH,SAAgB,QAAQ,CAAO,MAAoB,EAAE,YAAe;IAClE,IAAI,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QACjB,OAAO,MAAM,CAAC,IAAI,CAAC;IACrB,CAAC;IACD,OAAO,YAAY,CAAC;AACtB,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validation utilities for store operations
|
|
3
|
+
*/
|
|
4
|
+
export declare class ValidationError extends Error {
|
|
5
|
+
constructor(message: string);
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Validate namespace array
|
|
9
|
+
*/
|
|
10
|
+
export declare function validateNamespace(namespace: string[]): void;
|
|
11
|
+
/**
|
|
12
|
+
* Validate key string
|
|
13
|
+
*/
|
|
14
|
+
export declare function validateKey(key: string): void;
|
|
15
|
+
/**
|
|
16
|
+
* Validate value size
|
|
17
|
+
*/
|
|
18
|
+
export declare function validateValue(value: any): void;
|
|
19
|
+
/**
|
|
20
|
+
* Validate pagination parameters
|
|
21
|
+
*/
|
|
22
|
+
export declare function validatePagination(limit?: number, offset?: number): void;
|
|
23
|
+
/**
|
|
24
|
+
* Validate TTL days (wraps shared validation with store-specific error type)
|
|
25
|
+
*/
|
|
26
|
+
export declare function validateTTL(ttlDays?: number): void;
|
|
27
|
+
/**
|
|
28
|
+
* Validate embeddings
|
|
29
|
+
*/
|
|
30
|
+
export declare function validateEmbeddings(embeddings?: number[][]): void;
|
|
31
|
+
/**
|
|
32
|
+
* Validate user ID
|
|
33
|
+
*/
|
|
34
|
+
export declare function validateUserId(userId: string): void;
|
|
35
|
+
/**
|
|
36
|
+
* Validate JSONPath expressions to prevent injection attacks
|
|
37
|
+
*/
|
|
38
|
+
export declare function validateJSONPath(paths: string[]): void;
|
|
39
|
+
/**
|
|
40
|
+
* Validate maxDepth parameter
|
|
41
|
+
*/
|
|
42
|
+
export declare function validateMaxDepth(maxDepth?: number): void;
|
|
43
|
+
/**
|
|
44
|
+
* Validate batch operations count
|
|
45
|
+
*/
|
|
46
|
+
export declare function validateBatchSize(operationsCount: number): void;
|
|
47
|
+
/**
|
|
48
|
+
* Export constants for use in other modules
|
|
49
|
+
*/
|
|
50
|
+
export declare const ValidationConstants: {
|
|
51
|
+
readonly MAX_LOOP_ITERATIONS: 100;
|
|
52
|
+
readonly MAX_TOTAL_ITEMS_IN_MEMORY: 10000;
|
|
53
|
+
readonly MAX_OFFSET: 10000;
|
|
54
|
+
readonly MAX_DEPTH: 100;
|
|
55
|
+
readonly MAX_BATCH_SIZE: 100;
|
|
56
|
+
};
|
|
57
|
+
//# sourceMappingURL=validation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../../src/store/utils/validation.ts"],"names":[],"mappings":"AAAA;;GAEG;AAkBH,qBAAa,eAAgB,SAAQ,KAAK;gBAC5B,OAAO,EAAE,MAAM;CAI5B;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,IAAI,CA8B3D;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAgB7C;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,GAAG,GAAG,IAAI,CAW9C;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CA4BxE;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAMlD;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,CAAC,EAAE,MAAM,EAAE,EAAE,GAAG,IAAI,CAoChE;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAYnD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,CAiCtD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAgBxD;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,eAAe,EAAE,MAAM,GAAG,IAAI,CAc/D;AAED;;GAEG;AACH,eAAO,MAAM,mBAAmB;;;;;;CAMtB,CAAC"}
|