@danielsimonjr/memory-mcp 0.48.0 → 9.8.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/LICENSE +22 -0
- package/README.md +2000 -194
- package/dist/__tests__/file-path.test.js +7 -11
- package/dist/__tests__/knowledge-graph.test.js +3 -8
- package/dist/core/EntityManager.d.ts +266 -0
- package/dist/core/EntityManager.d.ts.map +1 -0
- package/dist/core/EntityManager.js +85 -133
- package/dist/core/GraphEventEmitter.d.ts +202 -0
- package/dist/core/GraphEventEmitter.d.ts.map +1 -0
- package/dist/core/GraphEventEmitter.js +346 -0
- package/dist/core/GraphStorage.d.ts +395 -0
- package/dist/core/GraphStorage.d.ts.map +1 -0
- package/dist/core/GraphStorage.js +643 -31
- package/dist/core/GraphTraversal.d.ts +141 -0
- package/dist/core/GraphTraversal.d.ts.map +1 -0
- package/dist/core/GraphTraversal.js +573 -0
- package/dist/core/HierarchyManager.d.ts +111 -0
- package/dist/core/HierarchyManager.d.ts.map +1 -0
- package/dist/{features → core}/HierarchyManager.js +14 -9
- package/dist/core/ManagerContext.d.ts +72 -0
- package/dist/core/ManagerContext.d.ts.map +1 -0
- package/dist/core/ManagerContext.js +118 -0
- package/dist/core/ObservationManager.d.ts +85 -0
- package/dist/core/ObservationManager.d.ts.map +1 -0
- package/dist/core/ObservationManager.js +51 -57
- package/dist/core/RelationManager.d.ts +131 -0
- package/dist/core/RelationManager.d.ts.map +1 -0
- package/dist/core/RelationManager.js +31 -7
- package/dist/core/SQLiteStorage.d.ts +354 -0
- package/dist/core/SQLiteStorage.d.ts.map +1 -0
- package/dist/core/SQLiteStorage.js +917 -0
- package/dist/core/StorageFactory.d.ts +45 -0
- package/dist/core/StorageFactory.d.ts.map +1 -0
- package/dist/core/StorageFactory.js +64 -0
- package/dist/core/TransactionManager.d.ts +464 -0
- package/dist/core/TransactionManager.d.ts.map +1 -0
- package/dist/core/TransactionManager.js +490 -13
- package/dist/core/index.d.ts +17 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +12 -2
- package/dist/features/AnalyticsManager.d.ts +44 -0
- package/dist/features/AnalyticsManager.d.ts.map +1 -0
- package/dist/features/AnalyticsManager.js +3 -2
- package/dist/features/ArchiveManager.d.ts +133 -0
- package/dist/features/ArchiveManager.d.ts.map +1 -0
- package/dist/features/ArchiveManager.js +221 -14
- package/dist/features/CompressionManager.d.ts +117 -0
- package/dist/features/CompressionManager.d.ts.map +1 -0
- package/dist/features/CompressionManager.js +189 -20
- package/dist/features/IOManager.d.ts +225 -0
- package/dist/features/IOManager.d.ts.map +1 -0
- package/dist/features/IOManager.js +1041 -0
- package/dist/features/StreamingExporter.d.ts +123 -0
- package/dist/features/StreamingExporter.d.ts.map +1 -0
- package/dist/features/StreamingExporter.js +203 -0
- package/dist/features/TagManager.d.ts +147 -0
- package/dist/features/TagManager.d.ts.map +1 -0
- package/dist/features/index.d.ts +12 -0
- package/dist/features/index.d.ts.map +1 -0
- package/dist/features/index.js +5 -6
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -10
- package/dist/memory.jsonl +1 -26
- package/dist/search/BasicSearch.d.ts +51 -0
- package/dist/search/BasicSearch.d.ts.map +1 -0
- package/dist/search/BasicSearch.js +9 -3
- package/dist/search/BooleanSearch.d.ts +98 -0
- package/dist/search/BooleanSearch.d.ts.map +1 -0
- package/dist/search/BooleanSearch.js +156 -9
- package/dist/search/EmbeddingService.d.ts +178 -0
- package/dist/search/EmbeddingService.d.ts.map +1 -0
- package/dist/search/EmbeddingService.js +358 -0
- package/dist/search/FuzzySearch.d.ts +118 -0
- package/dist/search/FuzzySearch.d.ts.map +1 -0
- package/dist/search/FuzzySearch.js +241 -25
- package/dist/search/QueryCostEstimator.d.ts +111 -0
- package/dist/search/QueryCostEstimator.d.ts.map +1 -0
- package/dist/search/QueryCostEstimator.js +355 -0
- package/dist/search/RankedSearch.d.ts +71 -0
- package/dist/search/RankedSearch.d.ts.map +1 -0
- package/dist/search/RankedSearch.js +54 -6
- package/dist/search/SavedSearchManager.d.ts +79 -0
- package/dist/search/SavedSearchManager.d.ts.map +1 -0
- package/dist/search/SearchFilterChain.d.ts +120 -0
- package/dist/search/SearchFilterChain.d.ts.map +1 -0
- package/dist/search/SearchFilterChain.js +2 -4
- package/dist/search/SearchManager.d.ts +326 -0
- package/dist/search/SearchManager.d.ts.map +1 -0
- package/dist/search/SearchManager.js +148 -0
- package/dist/search/SearchSuggestions.d.ts +27 -0
- package/dist/search/SearchSuggestions.d.ts.map +1 -0
- package/dist/search/SearchSuggestions.js +1 -1
- package/dist/search/SemanticSearch.d.ts +149 -0
- package/dist/search/SemanticSearch.d.ts.map +1 -0
- package/dist/search/SemanticSearch.js +323 -0
- package/dist/search/TFIDFEventSync.d.ts +85 -0
- package/dist/search/TFIDFEventSync.d.ts.map +1 -0
- package/dist/search/TFIDFEventSync.js +133 -0
- package/dist/search/TFIDFIndexManager.d.ts +151 -0
- package/dist/search/TFIDFIndexManager.d.ts.map +1 -0
- package/dist/search/TFIDFIndexManager.js +232 -17
- package/dist/search/VectorStore.d.ts +235 -0
- package/dist/search/VectorStore.d.ts.map +1 -0
- package/dist/search/VectorStore.js +311 -0
- package/dist/search/index.d.ts +21 -0
- package/dist/search/index.d.ts.map +1 -0
- package/dist/search/index.js +12 -0
- package/dist/server/MCPServer.d.ts +21 -0
- package/dist/server/MCPServer.d.ts.map +1 -0
- package/dist/server/MCPServer.js +4 -4
- package/dist/server/responseCompressor.d.ts +94 -0
- package/dist/server/responseCompressor.d.ts.map +1 -0
- package/dist/server/responseCompressor.js +127 -0
- package/dist/server/toolDefinitions.d.ts +27 -0
- package/dist/server/toolDefinitions.d.ts.map +1 -0
- package/dist/server/toolDefinitions.js +188 -17
- package/dist/server/toolHandlers.d.ts +41 -0
- package/dist/server/toolHandlers.d.ts.map +1 -0
- package/dist/server/toolHandlers.js +467 -75
- package/dist/types/index.d.ts +13 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +1 -1
- package/dist/types/types.d.ts +1654 -0
- package/dist/types/types.d.ts.map +1 -0
- package/dist/types/types.js +9 -0
- package/dist/utils/compressedCache.d.ts +192 -0
- package/dist/utils/compressedCache.d.ts.map +1 -0
- package/dist/utils/compressedCache.js +309 -0
- package/dist/utils/compressionUtil.d.ts +214 -0
- package/dist/utils/compressionUtil.d.ts.map +1 -0
- package/dist/utils/compressionUtil.js +247 -0
- package/dist/utils/constants.d.ts +245 -0
- package/dist/utils/constants.d.ts.map +1 -0
- package/dist/utils/constants.js +124 -0
- package/dist/utils/entityUtils.d.ts +321 -0
- package/dist/utils/entityUtils.d.ts.map +1 -0
- package/dist/utils/entityUtils.js +434 -4
- package/dist/utils/errors.d.ts +95 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +24 -0
- package/dist/utils/formatters.d.ts +145 -0
- package/dist/utils/formatters.d.ts.map +1 -0
- package/dist/utils/{paginationUtils.js → formatters.js} +54 -3
- package/dist/utils/index.d.ts +23 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +69 -31
- package/dist/utils/indexes.d.ts +270 -0
- package/dist/utils/indexes.d.ts.map +1 -0
- package/dist/utils/indexes.js +526 -0
- package/dist/utils/logger.d.ts +24 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/operationUtils.d.ts +124 -0
- package/dist/utils/operationUtils.d.ts.map +1 -0
- package/dist/utils/operationUtils.js +175 -0
- package/dist/utils/parallelUtils.d.ts +72 -0
- package/dist/utils/parallelUtils.d.ts.map +1 -0
- package/dist/utils/parallelUtils.js +169 -0
- package/dist/utils/schemas.d.ts +374 -0
- package/dist/utils/schemas.d.ts.map +1 -0
- package/dist/utils/schemas.js +302 -2
- package/dist/utils/searchAlgorithms.d.ts +99 -0
- package/dist/utils/searchAlgorithms.d.ts.map +1 -0
- package/dist/utils/searchAlgorithms.js +167 -0
- package/dist/utils/searchCache.d.ts +108 -0
- package/dist/utils/searchCache.d.ts.map +1 -0
- package/dist/utils/taskScheduler.d.ts +290 -0
- package/dist/utils/taskScheduler.d.ts.map +1 -0
- package/dist/utils/taskScheduler.js +466 -0
- package/dist/workers/index.d.ts +12 -0
- package/dist/workers/index.d.ts.map +1 -0
- package/dist/workers/index.js +9 -0
- package/dist/workers/levenshteinWorker.d.ts +60 -0
- package/dist/workers/levenshteinWorker.d.ts.map +1 -0
- package/dist/workers/levenshteinWorker.js +98 -0
- package/package.json +17 -4
- package/dist/__tests__/edge-cases/edge-cases.test.js +0 -406
- package/dist/__tests__/integration/workflows.test.js +0 -449
- package/dist/__tests__/performance/benchmarks.test.js +0 -413
- package/dist/__tests__/unit/core/EntityManager.test.js +0 -334
- package/dist/__tests__/unit/core/GraphStorage.test.js +0 -205
- package/dist/__tests__/unit/core/RelationManager.test.js +0 -274
- package/dist/__tests__/unit/features/CompressionManager.test.js +0 -350
- package/dist/__tests__/unit/search/BasicSearch.test.js +0 -311
- package/dist/__tests__/unit/search/BooleanSearch.test.js +0 -432
- package/dist/__tests__/unit/search/FuzzySearch.test.js +0 -448
- package/dist/__tests__/unit/search/RankedSearch.test.js +0 -379
- package/dist/__tests__/unit/utils/levenshtein.test.js +0 -77
- package/dist/core/KnowledgeGraphManager.js +0 -423
- package/dist/features/BackupManager.js +0 -311
- package/dist/features/ExportManager.js +0 -305
- package/dist/features/ImportExportManager.js +0 -50
- package/dist/features/ImportManager.js +0 -328
- package/dist/memory-saved-searches.jsonl +0 -0
- package/dist/memory-tag-aliases.jsonl +0 -0
- package/dist/types/analytics.types.js +0 -6
- package/dist/types/entity.types.js +0 -7
- package/dist/types/import-export.types.js +0 -7
- package/dist/types/search.types.js +0 -7
- package/dist/types/tag.types.js +0 -6
- package/dist/utils/dateUtils.js +0 -89
- package/dist/utils/filterUtils.js +0 -155
- package/dist/utils/levenshtein.js +0 -62
- package/dist/utils/pathUtils.js +0 -115
- package/dist/utils/responseFormatter.js +0 -55
- package/dist/utils/tagUtils.js +0 -107
- package/dist/utils/tfidf.js +0 -90
- package/dist/utils/validationHelper.js +0 -99
- package/dist/utils/validationUtils.js +0 -109
|
@@ -0,0 +1,374 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validation Schemas and Helpers
|
|
3
|
+
*
|
|
4
|
+
* Consolidated module for Zod schemas and validation utilities.
|
|
5
|
+
* Provides runtime type safety and data validation.
|
|
6
|
+
*
|
|
7
|
+
* @module utils/schemas
|
|
8
|
+
*/
|
|
9
|
+
import { z, type ZodSchema, type ZodError } from 'zod';
|
|
10
|
+
/**
|
|
11
|
+
* Complete Entity schema with all fields.
|
|
12
|
+
* Used for validating full entity objects including timestamps.
|
|
13
|
+
*/
|
|
14
|
+
export declare const EntitySchema: z.ZodObject<{
|
|
15
|
+
name: z.ZodString;
|
|
16
|
+
entityType: z.ZodString;
|
|
17
|
+
observations: z.ZodArray<z.ZodString>;
|
|
18
|
+
createdAt: z.ZodOptional<z.ZodString>;
|
|
19
|
+
lastModified: z.ZodOptional<z.ZodString>;
|
|
20
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
21
|
+
importance: z.ZodOptional<z.ZodNumber>;
|
|
22
|
+
parentId: z.ZodOptional<z.ZodString>;
|
|
23
|
+
}, z.core.$strict>;
|
|
24
|
+
/**
|
|
25
|
+
* Entity creation input schema.
|
|
26
|
+
* Used for validating user input when creating new entities.
|
|
27
|
+
* Timestamps are optional and will be auto-generated if not provided.
|
|
28
|
+
*/
|
|
29
|
+
export declare const CreateEntitySchema: z.ZodObject<{
|
|
30
|
+
name: z.ZodString;
|
|
31
|
+
entityType: z.ZodString;
|
|
32
|
+
observations: z.ZodArray<z.ZodString>;
|
|
33
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
34
|
+
importance: z.ZodOptional<z.ZodNumber>;
|
|
35
|
+
parentId: z.ZodOptional<z.ZodString>;
|
|
36
|
+
createdAt: z.ZodOptional<z.ZodString>;
|
|
37
|
+
lastModified: z.ZodOptional<z.ZodString>;
|
|
38
|
+
}, z.core.$strip>;
|
|
39
|
+
/**
|
|
40
|
+
* Entity update input schema.
|
|
41
|
+
* All fields are optional for partial updates.
|
|
42
|
+
* Name cannot be updated (it's the unique identifier).
|
|
43
|
+
*/
|
|
44
|
+
export declare const UpdateEntitySchema: z.ZodObject<{
|
|
45
|
+
entityType: z.ZodOptional<z.ZodString>;
|
|
46
|
+
observations: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
47
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
48
|
+
importance: z.ZodOptional<z.ZodNumber>;
|
|
49
|
+
parentId: z.ZodOptional<z.ZodString>;
|
|
50
|
+
}, z.core.$strip>;
|
|
51
|
+
/**
|
|
52
|
+
* Complete Relation schema with all fields.
|
|
53
|
+
* Used for validating full relation objects including timestamps.
|
|
54
|
+
*/
|
|
55
|
+
export declare const RelationSchema: z.ZodObject<{
|
|
56
|
+
from: z.ZodString;
|
|
57
|
+
to: z.ZodString;
|
|
58
|
+
relationType: z.ZodString;
|
|
59
|
+
createdAt: z.ZodOptional<z.ZodString>;
|
|
60
|
+
lastModified: z.ZodOptional<z.ZodString>;
|
|
61
|
+
}, z.core.$strict>;
|
|
62
|
+
/**
|
|
63
|
+
* Relation creation input schema.
|
|
64
|
+
* Used for validating user input when creating new relations.
|
|
65
|
+
* Timestamps are optional and will be auto-generated if not provided.
|
|
66
|
+
*/
|
|
67
|
+
export declare const CreateRelationSchema: z.ZodObject<{
|
|
68
|
+
from: z.ZodString;
|
|
69
|
+
to: z.ZodString;
|
|
70
|
+
relationType: z.ZodString;
|
|
71
|
+
createdAt: z.ZodOptional<z.ZodString>;
|
|
72
|
+
lastModified: z.ZodOptional<z.ZodString>;
|
|
73
|
+
}, z.core.$strip>;
|
|
74
|
+
/**
|
|
75
|
+
* Search query validation.
|
|
76
|
+
* Validates text search queries with reasonable length constraints.
|
|
77
|
+
*/
|
|
78
|
+
export declare const SearchQuerySchema: z.ZodString;
|
|
79
|
+
/**
|
|
80
|
+
* Date range validation for search filters.
|
|
81
|
+
*/
|
|
82
|
+
export declare const DateRangeSchema: z.ZodObject<{
|
|
83
|
+
start: z.ZodString;
|
|
84
|
+
end: z.ZodString;
|
|
85
|
+
}, z.core.$strip>;
|
|
86
|
+
/**
|
|
87
|
+
* Tag alias validation for TagManager.
|
|
88
|
+
*/
|
|
89
|
+
export declare const TagAliasSchema: z.ZodObject<{
|
|
90
|
+
canonical: z.ZodString;
|
|
91
|
+
aliases: z.ZodArray<z.ZodString>;
|
|
92
|
+
}, z.core.$strip>;
|
|
93
|
+
/**
|
|
94
|
+
* Export format validation.
|
|
95
|
+
*/
|
|
96
|
+
export declare const ExportFormatSchema: z.ZodEnum<{
|
|
97
|
+
json: "json";
|
|
98
|
+
graphml: "graphml";
|
|
99
|
+
csv: "csv";
|
|
100
|
+
}>;
|
|
101
|
+
/**
|
|
102
|
+
* Batch entity creation validation.
|
|
103
|
+
* Validates array of entities with maximum constraints.
|
|
104
|
+
* Empty arrays are allowed (no-op).
|
|
105
|
+
*/
|
|
106
|
+
export declare const BatchCreateEntitiesSchema: z.ZodArray<z.ZodObject<{
|
|
107
|
+
name: z.ZodString;
|
|
108
|
+
entityType: z.ZodString;
|
|
109
|
+
observations: z.ZodArray<z.ZodString>;
|
|
110
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
111
|
+
importance: z.ZodOptional<z.ZodNumber>;
|
|
112
|
+
parentId: z.ZodOptional<z.ZodString>;
|
|
113
|
+
createdAt: z.ZodOptional<z.ZodString>;
|
|
114
|
+
lastModified: z.ZodOptional<z.ZodString>;
|
|
115
|
+
}, z.core.$strip>>;
|
|
116
|
+
/**
|
|
117
|
+
* Batch relation creation validation.
|
|
118
|
+
* Validates array of relations with maximum constraints.
|
|
119
|
+
* Empty arrays are allowed (no-op).
|
|
120
|
+
*/
|
|
121
|
+
export declare const BatchCreateRelationsSchema: z.ZodArray<z.ZodObject<{
|
|
122
|
+
from: z.ZodString;
|
|
123
|
+
to: z.ZodString;
|
|
124
|
+
relationType: z.ZodString;
|
|
125
|
+
createdAt: z.ZodOptional<z.ZodString>;
|
|
126
|
+
lastModified: z.ZodOptional<z.ZodString>;
|
|
127
|
+
}, z.core.$strip>>;
|
|
128
|
+
/**
|
|
129
|
+
* Entity name array validation for batch deletion.
|
|
130
|
+
*/
|
|
131
|
+
export declare const EntityNamesSchema: z.ZodArray<z.ZodString>;
|
|
132
|
+
/**
|
|
133
|
+
* Relation array validation for batch deletion.
|
|
134
|
+
*/
|
|
135
|
+
export declare const DeleteRelationsSchema: z.ZodArray<z.ZodObject<{
|
|
136
|
+
from: z.ZodString;
|
|
137
|
+
to: z.ZodString;
|
|
138
|
+
relationType: z.ZodString;
|
|
139
|
+
createdAt: z.ZodOptional<z.ZodString>;
|
|
140
|
+
lastModified: z.ZodOptional<z.ZodString>;
|
|
141
|
+
}, z.core.$strip>>;
|
|
142
|
+
/**
|
|
143
|
+
* Single observation input for add operations.
|
|
144
|
+
* Empty contents array is allowed (no-op).
|
|
145
|
+
*/
|
|
146
|
+
export declare const AddObservationInputSchema: z.ZodObject<{
|
|
147
|
+
entityName: z.ZodString;
|
|
148
|
+
contents: z.ZodArray<z.ZodString>;
|
|
149
|
+
}, z.core.$strip>;
|
|
150
|
+
/**
|
|
151
|
+
* Batch observation addition validation.
|
|
152
|
+
* Empty array is allowed (no-op).
|
|
153
|
+
*/
|
|
154
|
+
export declare const AddObservationsInputSchema: z.ZodArray<z.ZodObject<{
|
|
155
|
+
entityName: z.ZodString;
|
|
156
|
+
contents: z.ZodArray<z.ZodString>;
|
|
157
|
+
}, z.core.$strip>>;
|
|
158
|
+
/**
|
|
159
|
+
* Single observation deletion input.
|
|
160
|
+
* Empty observations array is allowed (no-op).
|
|
161
|
+
* Non-existent entities are silently skipped by the manager.
|
|
162
|
+
*/
|
|
163
|
+
export declare const DeleteObservationInputSchema: z.ZodObject<{
|
|
164
|
+
entityName: z.ZodString;
|
|
165
|
+
observations: z.ZodArray<z.ZodString>;
|
|
166
|
+
}, z.core.$strip>;
|
|
167
|
+
/**
|
|
168
|
+
* Batch observation deletion validation.
|
|
169
|
+
* Empty array is allowed (no-op).
|
|
170
|
+
*/
|
|
171
|
+
export declare const DeleteObservationsInputSchema: z.ZodArray<z.ZodObject<{
|
|
172
|
+
entityName: z.ZodString;
|
|
173
|
+
observations: z.ZodArray<z.ZodString>;
|
|
174
|
+
}, z.core.$strip>>;
|
|
175
|
+
/**
|
|
176
|
+
* Archive criteria validation.
|
|
177
|
+
* All fields are optional - the manager handles the case when no criteria provided.
|
|
178
|
+
*/
|
|
179
|
+
export declare const ArchiveCriteriaSchema: z.ZodObject<{
|
|
180
|
+
olderThan: z.ZodOptional<z.ZodString>;
|
|
181
|
+
importanceLessThan: z.ZodOptional<z.ZodNumber>;
|
|
182
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
183
|
+
}, z.core.$strip>;
|
|
184
|
+
/**
|
|
185
|
+
* Saved search creation input validation.
|
|
186
|
+
*/
|
|
187
|
+
export declare const SavedSearchInputSchema: z.ZodObject<{
|
|
188
|
+
name: z.ZodString;
|
|
189
|
+
description: z.ZodOptional<z.ZodString>;
|
|
190
|
+
query: z.ZodString;
|
|
191
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
192
|
+
minImportance: z.ZodOptional<z.ZodNumber>;
|
|
193
|
+
maxImportance: z.ZodOptional<z.ZodNumber>;
|
|
194
|
+
entityType: z.ZodOptional<z.ZodString>;
|
|
195
|
+
}, z.core.$strip>;
|
|
196
|
+
/**
|
|
197
|
+
* Saved search update validation.
|
|
198
|
+
* All fields are optional for partial updates.
|
|
199
|
+
*/
|
|
200
|
+
export declare const SavedSearchUpdateSchema: z.ZodObject<{
|
|
201
|
+
description: z.ZodOptional<z.ZodString>;
|
|
202
|
+
query: z.ZodOptional<z.ZodString>;
|
|
203
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
204
|
+
minImportance: z.ZodOptional<z.ZodNumber>;
|
|
205
|
+
maxImportance: z.ZodOptional<z.ZodNumber>;
|
|
206
|
+
entityType: z.ZodOptional<z.ZodString>;
|
|
207
|
+
}, z.core.$strip>;
|
|
208
|
+
/**
|
|
209
|
+
* Import format validation.
|
|
210
|
+
*/
|
|
211
|
+
export declare const ImportFormatSchema: z.ZodEnum<{
|
|
212
|
+
json: "json";
|
|
213
|
+
graphml: "graphml";
|
|
214
|
+
csv: "csv";
|
|
215
|
+
}>;
|
|
216
|
+
/**
|
|
217
|
+
* Export format validation (includes all output formats).
|
|
218
|
+
*/
|
|
219
|
+
export declare const ExtendedExportFormatSchema: z.ZodEnum<{
|
|
220
|
+
json: "json";
|
|
221
|
+
graphml: "graphml";
|
|
222
|
+
csv: "csv";
|
|
223
|
+
gexf: "gexf";
|
|
224
|
+
dot: "dot";
|
|
225
|
+
markdown: "markdown";
|
|
226
|
+
mermaid: "mermaid";
|
|
227
|
+
}>;
|
|
228
|
+
/**
|
|
229
|
+
* Merge strategy validation for imports.
|
|
230
|
+
*/
|
|
231
|
+
export declare const MergeStrategySchema: z.ZodEnum<{
|
|
232
|
+
replace: "replace";
|
|
233
|
+
skip: "skip";
|
|
234
|
+
merge: "merge";
|
|
235
|
+
fail: "fail";
|
|
236
|
+
}>;
|
|
237
|
+
/**
|
|
238
|
+
* Export filter validation.
|
|
239
|
+
*/
|
|
240
|
+
export declare const ExportFilterSchema: z.ZodObject<{
|
|
241
|
+
startDate: z.ZodOptional<z.ZodString>;
|
|
242
|
+
endDate: z.ZodOptional<z.ZodString>;
|
|
243
|
+
entityType: z.ZodOptional<z.ZodString>;
|
|
244
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
245
|
+
}, z.core.$strip>;
|
|
246
|
+
/**
|
|
247
|
+
* Tags array validation (optional, for search filters).
|
|
248
|
+
*/
|
|
249
|
+
export declare const OptionalTagsSchema: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
250
|
+
/**
|
|
251
|
+
* Optional entity names array validation.
|
|
252
|
+
*/
|
|
253
|
+
export declare const OptionalEntityNamesSchema: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
254
|
+
export type EntityInput = z.infer<typeof EntitySchema>;
|
|
255
|
+
export type CreateEntityInput = z.infer<typeof CreateEntitySchema>;
|
|
256
|
+
export type UpdateEntityInput = z.infer<typeof UpdateEntitySchema>;
|
|
257
|
+
export type RelationInput = z.infer<typeof RelationSchema>;
|
|
258
|
+
export type CreateRelationInput = z.infer<typeof CreateRelationSchema>;
|
|
259
|
+
export type SearchQuery = z.infer<typeof SearchQuerySchema>;
|
|
260
|
+
export type DateRange = z.infer<typeof DateRangeSchema>;
|
|
261
|
+
export type TagAlias = z.infer<typeof TagAliasSchema>;
|
|
262
|
+
export type ExportFormat = z.infer<typeof ExportFormatSchema>;
|
|
263
|
+
export type AddObservationInput = z.infer<typeof AddObservationInputSchema>;
|
|
264
|
+
export type DeleteObservationInput = z.infer<typeof DeleteObservationInputSchema>;
|
|
265
|
+
export type ArchiveCriteriaInput = z.infer<typeof ArchiveCriteriaSchema>;
|
|
266
|
+
export type SavedSearchInput = z.infer<typeof SavedSearchInputSchema>;
|
|
267
|
+
export type SavedSearchUpdateInput = z.infer<typeof SavedSearchUpdateSchema>;
|
|
268
|
+
export type ImportFormat = z.infer<typeof ImportFormatSchema>;
|
|
269
|
+
export type ExtendedExportFormat = z.infer<typeof ExtendedExportFormatSchema>;
|
|
270
|
+
export type MergeStrategy = z.infer<typeof MergeStrategySchema>;
|
|
271
|
+
export type ExportFilterInput = z.infer<typeof ExportFilterSchema>;
|
|
272
|
+
/**
|
|
273
|
+
* Validation result with status and error messages.
|
|
274
|
+
*/
|
|
275
|
+
export interface ValidationResult {
|
|
276
|
+
valid: boolean;
|
|
277
|
+
errors: string[];
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Formats Zod errors into human-readable strings.
|
|
281
|
+
*
|
|
282
|
+
* @param error - Zod error object
|
|
283
|
+
* @returns Array of formatted error messages
|
|
284
|
+
*/
|
|
285
|
+
export declare function formatZodErrors(error: ZodError): string[];
|
|
286
|
+
/**
|
|
287
|
+
* Validates data against a Zod schema and returns the typed result.
|
|
288
|
+
* Throws ValidationError with formatted error messages on failure.
|
|
289
|
+
*
|
|
290
|
+
* @param data - The data to validate
|
|
291
|
+
* @param schema - The Zod schema to validate against
|
|
292
|
+
* @param errorMessage - Custom error message prefix (default: 'Validation failed')
|
|
293
|
+
* @returns The validated and typed data
|
|
294
|
+
* @throws ValidationError if validation fails
|
|
295
|
+
*
|
|
296
|
+
* @example
|
|
297
|
+
* ```typescript
|
|
298
|
+
* const entities = validateWithSchema(
|
|
299
|
+
* input,
|
|
300
|
+
* BatchCreateEntitiesSchema,
|
|
301
|
+
* 'Invalid entity data'
|
|
302
|
+
* );
|
|
303
|
+
* ```
|
|
304
|
+
*/
|
|
305
|
+
export declare function validateWithSchema<T>(data: unknown, schema: ZodSchema<T>, errorMessage?: string): T;
|
|
306
|
+
/**
|
|
307
|
+
* Validates data and returns a result object instead of throwing.
|
|
308
|
+
* Useful when you want to handle validation errors gracefully.
|
|
309
|
+
*
|
|
310
|
+
* @param data - The data to validate
|
|
311
|
+
* @param schema - The Zod schema to validate against
|
|
312
|
+
* @returns Result object with success status and either data or errors
|
|
313
|
+
*
|
|
314
|
+
* @example
|
|
315
|
+
* ```typescript
|
|
316
|
+
* const result = validateSafe(input, EntitySchema);
|
|
317
|
+
* if (result.success) {
|
|
318
|
+
* console.log(result.data);
|
|
319
|
+
* } else {
|
|
320
|
+
* console.error(result.errors);
|
|
321
|
+
* }
|
|
322
|
+
* ```
|
|
323
|
+
*/
|
|
324
|
+
export declare function validateSafe<T>(data: unknown, schema: ZodSchema<T>): {
|
|
325
|
+
success: true;
|
|
326
|
+
data: T;
|
|
327
|
+
} | {
|
|
328
|
+
success: false;
|
|
329
|
+
errors: string[];
|
|
330
|
+
};
|
|
331
|
+
/**
|
|
332
|
+
* Validates an array of items against a schema.
|
|
333
|
+
* Returns detailed information about which items failed validation.
|
|
334
|
+
*
|
|
335
|
+
* @param items - Array of items to validate
|
|
336
|
+
* @param schema - Zod schema for individual items
|
|
337
|
+
* @param errorMessage - Custom error message prefix
|
|
338
|
+
* @returns Array of validated items
|
|
339
|
+
* @throws ValidationError if any item fails validation
|
|
340
|
+
*/
|
|
341
|
+
export declare function validateArrayWithSchema<T>(items: unknown[], schema: ZodSchema<T>, errorMessage?: string): T[];
|
|
342
|
+
/**
|
|
343
|
+
* Validate an entity object.
|
|
344
|
+
*
|
|
345
|
+
* Checks required fields and data types.
|
|
346
|
+
*
|
|
347
|
+
* @param entity - Entity to validate (unknown type for runtime validation)
|
|
348
|
+
* @returns Validation result
|
|
349
|
+
*/
|
|
350
|
+
export declare function validateEntity(entity: unknown): ValidationResult;
|
|
351
|
+
/**
|
|
352
|
+
* Validate a relation object.
|
|
353
|
+
*
|
|
354
|
+
* Checks required fields and data types.
|
|
355
|
+
*
|
|
356
|
+
* @param relation - Relation to validate (unknown type for runtime validation)
|
|
357
|
+
* @returns Validation result
|
|
358
|
+
*/
|
|
359
|
+
export declare function validateRelation(relation: unknown): ValidationResult;
|
|
360
|
+
/**
|
|
361
|
+
* Validate importance level (must be 0-10).
|
|
362
|
+
*
|
|
363
|
+
* @param importance - Importance value to validate
|
|
364
|
+
* @returns True if valid
|
|
365
|
+
*/
|
|
366
|
+
export declare function validateImportance(importance: number): boolean;
|
|
367
|
+
/**
|
|
368
|
+
* Validate an array of tags.
|
|
369
|
+
*
|
|
370
|
+
* @param tags - Tags array to validate (unknown type for runtime validation)
|
|
371
|
+
* @returns Validation result
|
|
372
|
+
*/
|
|
373
|
+
export declare function validateTags(tags: unknown): ValidationResult;
|
|
374
|
+
//# sourceMappingURL=schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../src/utils/schemas.ts"],"names":[],"mapp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