@sylphx/flow 1.8.0 → 1.8.1
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 +52 -0
- package/assets/output-styles/silent.md +141 -8
- package/assets/rules/core.md +19 -2
- package/package.json +2 -12
- package/src/commands/flow/execute.ts +470 -0
- package/src/commands/flow/index.ts +11 -0
- package/src/commands/flow/prompt.ts +35 -0
- package/src/commands/flow/setup.ts +312 -0
- package/src/commands/flow/targets.ts +18 -0
- package/src/commands/flow/types.ts +47 -0
- package/src/commands/flow-command.ts +18 -967
- package/src/commands/flow-orchestrator.ts +14 -5
- package/src/commands/hook-command.ts +1 -1
- package/src/commands/init-core.ts +12 -3
- package/src/commands/run-command.ts +1 -1
- package/src/config/rules.ts +1 -1
- package/src/core/error-handling.ts +1 -1
- package/src/core/loop-controller.ts +1 -1
- package/src/core/state-detector.ts +1 -1
- package/src/core/target-manager.ts +1 -1
- package/src/index.ts +1 -1
- package/src/shared/files/index.ts +1 -1
- package/src/shared/processing/index.ts +1 -1
- package/src/targets/claude-code.ts +3 -3
- package/src/targets/opencode.ts +3 -3
- package/src/utils/agent-enhancer.ts +2 -2
- package/src/utils/{mcp-config.ts → config/mcp-config.ts} +4 -4
- package/src/utils/{paths.ts → config/paths.ts} +1 -1
- package/src/utils/{settings.ts → config/settings.ts} +1 -1
- package/src/utils/{target-config.ts → config/target-config.ts} +5 -5
- package/src/utils/{target-utils.ts → config/target-utils.ts} +3 -3
- package/src/utils/display/banner.ts +25 -0
- package/src/utils/display/status.ts +55 -0
- package/src/utils/{file-operations.ts → files/file-operations.ts} +2 -2
- package/src/utils/files/jsonc.ts +36 -0
- package/src/utils/{sync-utils.ts → files/sync-utils.ts} +3 -3
- package/src/utils/index.ts +42 -61
- package/src/utils/version.ts +47 -0
- package/src/components/benchmark-monitor.tsx +0 -331
- package/src/components/reindex-progress.tsx +0 -261
- package/src/composables/functional/index.ts +0 -14
- package/src/composables/functional/useEnvironment.ts +0 -171
- package/src/composables/functional/useFileSystem.ts +0 -139
- package/src/composables/index.ts +0 -4
- package/src/composables/useEnv.ts +0 -13
- package/src/composables/useRuntimeConfig.ts +0 -27
- package/src/core/ai-sdk.ts +0 -603
- package/src/core/app-factory.ts +0 -381
- package/src/core/builtin-agents.ts +0 -9
- package/src/core/command-system.ts +0 -550
- package/src/core/config-system.ts +0 -550
- package/src/core/connection-pool.ts +0 -390
- package/src/core/di-container.ts +0 -155
- package/src/core/headless-display.ts +0 -96
- package/src/core/interfaces/index.ts +0 -22
- package/src/core/interfaces/repository.interface.ts +0 -91
- package/src/core/interfaces/service.interface.ts +0 -133
- package/src/core/interfaces.ts +0 -96
- package/src/core/result.ts +0 -351
- package/src/core/service-config.ts +0 -252
- package/src/core/session-service.ts +0 -121
- package/src/core/storage-factory.ts +0 -115
- package/src/core/stream-handler.ts +0 -288
- package/src/core/type-utils.ts +0 -427
- package/src/core/unified-storage.ts +0 -456
- package/src/core/validation/limit.ts +0 -46
- package/src/core/validation/query.ts +0 -20
- package/src/db/auto-migrate.ts +0 -322
- package/src/db/base-database-client.ts +0 -144
- package/src/db/cache-db.ts +0 -218
- package/src/db/cache-schema.ts +0 -75
- package/src/db/database.ts +0 -70
- package/src/db/index.ts +0 -252
- package/src/db/memory-db.ts +0 -153
- package/src/db/memory-schema.ts +0 -29
- package/src/db/schema.ts +0 -289
- package/src/db/session-repository.ts +0 -733
- package/src/domains/index.ts +0 -6
- package/src/domains/utilities/index.ts +0 -6
- package/src/domains/utilities/time/index.ts +0 -5
- package/src/domains/utilities/time/tools.ts +0 -291
- package/src/services/agent-service.ts +0 -273
- package/src/services/evaluation-service.ts +0 -271
- package/src/services/functional/evaluation-logic.ts +0 -296
- package/src/services/functional/file-processor.ts +0 -273
- package/src/services/functional/index.ts +0 -12
- package/src/services/memory.service.ts +0 -476
- package/src/types/api/batch.ts +0 -108
- package/src/types/api/errors.ts +0 -118
- package/src/types/api/index.ts +0 -55
- package/src/types/api/requests.ts +0 -76
- package/src/types/api/responses.ts +0 -180
- package/src/types/api/websockets.ts +0 -85
- package/src/types/benchmark.ts +0 -49
- package/src/types/database.types.ts +0 -510
- package/src/types/memory-types.ts +0 -63
- package/src/utils/advanced-tokenizer.ts +0 -191
- package/src/utils/ai-model-fetcher.ts +0 -19
- package/src/utils/async-file-operations.ts +0 -516
- package/src/utils/audio-player.ts +0 -345
- package/src/utils/codebase-helpers.ts +0 -211
- package/src/utils/console-ui.ts +0 -79
- package/src/utils/database-errors.ts +0 -140
- package/src/utils/debug-logger.ts +0 -49
- package/src/utils/file-scanner.ts +0 -259
- package/src/utils/help.ts +0 -20
- package/src/utils/immutable-cache.ts +0 -106
- package/src/utils/jsonc.ts +0 -158
- package/src/utils/memory-tui.ts +0 -414
- package/src/utils/models-dev.ts +0 -91
- package/src/utils/parallel-operations.ts +0 -487
- package/src/utils/process-manager.ts +0 -155
- package/src/utils/prompts.ts +0 -120
- package/src/utils/search-tool-builder.ts +0 -214
- package/src/utils/session-manager.ts +0 -168
- package/src/utils/session-title.ts +0 -87
- package/src/utils/simplified-errors.ts +0 -410
- package/src/utils/template-engine.ts +0 -94
- package/src/utils/test-audio.ts +0 -71
- package/src/utils/todo-context.ts +0 -46
- package/src/utils/token-counter.ts +0 -288
- /package/src/utils/{cli-output.ts → display/cli-output.ts} +0 -0
- /package/src/utils/{logger.ts → display/logger.ts} +0 -0
- /package/src/utils/{notifications.ts → display/notifications.ts} +0 -0
- /package/src/utils/{secret-utils.ts → security/secret-utils.ts} +0 -0
- /package/src/utils/{security.ts → security/security.ts} +0 -0
|
@@ -1,510 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
|
|
3
|
-
// ============================================================================
|
|
4
|
-
// DATABASE ENTITIES AND OPERATIONS
|
|
5
|
-
// ============================================================================
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Base database entity interface
|
|
9
|
-
*/
|
|
10
|
-
export interface BaseEntity {
|
|
11
|
-
/** Unique identifier */
|
|
12
|
-
id: string;
|
|
13
|
-
/** Creation timestamp */
|
|
14
|
-
createdAt: string;
|
|
15
|
-
/** Last updated timestamp */
|
|
16
|
-
updatedAt: string;
|
|
17
|
-
/** Entity version for optimistic locking */
|
|
18
|
-
version?: number;
|
|
19
|
-
/** Soft delete flag */
|
|
20
|
-
deletedAt?: string;
|
|
21
|
-
/** Entity metadata */
|
|
22
|
-
metadata?: Record<string, unknown>;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Memory storage entry
|
|
27
|
-
*/
|
|
28
|
-
export interface MemoryStorageEntry extends BaseEntity {
|
|
29
|
-
/** Storage namespace */
|
|
30
|
-
namespace: string;
|
|
31
|
-
/** Entry key */
|
|
32
|
-
key: string;
|
|
33
|
-
/** Entry value */
|
|
34
|
-
value: unknown;
|
|
35
|
-
/** Value type for serialization */
|
|
36
|
-
valueType: 'string' | 'number' | 'boolean' | 'object' | 'array' | 'null';
|
|
37
|
-
/** Entry size in bytes */
|
|
38
|
-
size?: number;
|
|
39
|
-
/** Expiration timestamp */
|
|
40
|
-
expiresAt?: string;
|
|
41
|
-
/** Access count */
|
|
42
|
-
accessCount?: number;
|
|
43
|
-
/** Last accessed timestamp */
|
|
44
|
-
lastAccessedAt?: string;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Vector database entry
|
|
49
|
-
*/
|
|
50
|
-
export interface VectorStorageEntry extends BaseEntity {
|
|
51
|
-
/** Entry content/text */
|
|
52
|
-
content: string;
|
|
53
|
-
/** Vector embedding */
|
|
54
|
-
embedding: number[];
|
|
55
|
-
/** Vector dimensions */
|
|
56
|
-
dimensions: number;
|
|
57
|
-
/** Source file path */
|
|
58
|
-
sourcePath?: string;
|
|
59
|
-
/** Content hash for deduplication */
|
|
60
|
-
contentHash?: string;
|
|
61
|
-
/** Entry type */
|
|
62
|
-
type: 'document' | 'code' | 'markdown' | 'text';
|
|
63
|
-
/** Language or format */
|
|
64
|
-
language?: string;
|
|
65
|
-
/** Token count */
|
|
66
|
-
tokenCount?: number;
|
|
67
|
-
/** Additional metadata */
|
|
68
|
-
metadata?: {
|
|
69
|
-
title?: string;
|
|
70
|
-
description?: string;
|
|
71
|
-
tags?: string[];
|
|
72
|
-
author?: string;
|
|
73
|
-
project?: string;
|
|
74
|
-
[key: string]: unknown;
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Search index entry
|
|
80
|
-
*/
|
|
81
|
-
export interface SearchIndexEntry extends BaseEntity {
|
|
82
|
-
/** Document ID */
|
|
83
|
-
documentId: string;
|
|
84
|
-
/** Term or token */
|
|
85
|
-
term: string;
|
|
86
|
-
/** Term frequency in document */
|
|
87
|
-
frequency: number;
|
|
88
|
-
/** Term position(s) in document */
|
|
89
|
-
positions?: number[];
|
|
90
|
-
/** Document field where term appears */
|
|
91
|
-
field?: 'title' | 'content' | 'metadata' | 'all';
|
|
92
|
-
/** TF-IDF score */
|
|
93
|
-
tfidfScore?: number;
|
|
94
|
-
/** Additional indexing metadata */
|
|
95
|
-
indexMetadata?: Record<string, unknown>;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Database health check result
|
|
100
|
-
*/
|
|
101
|
-
export interface DatabaseHealthCheckResult {
|
|
102
|
-
/** Overall health status */
|
|
103
|
-
healthy: boolean;
|
|
104
|
-
/** Health check timestamp */
|
|
105
|
-
timestamp: string;
|
|
106
|
-
/** Error message if unhealthy */
|
|
107
|
-
error?: string;
|
|
108
|
-
/** Detailed health information */
|
|
109
|
-
details?: {
|
|
110
|
-
/** Connection status */
|
|
111
|
-
connection?: 'connected' | 'disconnected' | 'error';
|
|
112
|
-
/** Response time in milliseconds */
|
|
113
|
-
responseTime?: number;
|
|
114
|
-
/** Database size information */
|
|
115
|
-
size?: {
|
|
116
|
-
totalRecords: number;
|
|
117
|
-
totalSize: number;
|
|
118
|
-
indexes: number;
|
|
119
|
-
};
|
|
120
|
-
/** Memory usage */
|
|
121
|
-
memory?: {
|
|
122
|
-
used: number;
|
|
123
|
-
available: number;
|
|
124
|
-
percentage: number;
|
|
125
|
-
};
|
|
126
|
-
/** Additional metrics */
|
|
127
|
-
metrics?: Record<string, number | string>;
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* Database query options
|
|
133
|
-
*/
|
|
134
|
-
export interface DatabaseQueryOptions {
|
|
135
|
-
/** Limit number of results */
|
|
136
|
-
limit?: number;
|
|
137
|
-
/** Offset for pagination */
|
|
138
|
-
offset?: number;
|
|
139
|
-
/** Sort order */
|
|
140
|
-
orderBy?: {
|
|
141
|
-
field: string;
|
|
142
|
-
direction: 'asc' | 'desc';
|
|
143
|
-
};
|
|
144
|
-
/** Filter conditions */
|
|
145
|
-
where?: Record<string, unknown>;
|
|
146
|
-
/** Fields to include/exclude */
|
|
147
|
-
select?: string[];
|
|
148
|
-
/** Include soft-deleted records */
|
|
149
|
-
includeDeleted?: boolean;
|
|
150
|
-
/** Query timeout in milliseconds */
|
|
151
|
-
timeout?: number;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
/**
|
|
155
|
-
* Database transaction options
|
|
156
|
-
*/
|
|
157
|
-
export interface DatabaseTransactionOptions {
|
|
158
|
-
/** Transaction isolation level */
|
|
159
|
-
isolation?: 'read-uncommitted' | 'read-committed' | 'repeatable-read' | 'serializable';
|
|
160
|
-
/** Transaction timeout in milliseconds */
|
|
161
|
-
timeout?: number;
|
|
162
|
-
/** Whether transaction is read-only */
|
|
163
|
-
readOnly?: boolean;
|
|
164
|
-
/** Transaction metadata */
|
|
165
|
-
metadata?: Record<string, unknown>;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
/**
|
|
169
|
-
* Batch operation result
|
|
170
|
-
*/
|
|
171
|
-
export interface BatchOperationResult<T = unknown> {
|
|
172
|
-
/** Number of successful operations */
|
|
173
|
-
successCount: number;
|
|
174
|
-
/** Number of failed operations */
|
|
175
|
-
failureCount: number;
|
|
176
|
-
/** Total operations attempted */
|
|
177
|
-
total: number;
|
|
178
|
-
/** Successful results */
|
|
179
|
-
successes: Array<{
|
|
180
|
-
index: number;
|
|
181
|
-
data?: T;
|
|
182
|
-
id?: string;
|
|
183
|
-
}>;
|
|
184
|
-
/** Failed operations */
|
|
185
|
-
failures: Array<{
|
|
186
|
-
index: number;
|
|
187
|
-
error: string;
|
|
188
|
-
data?: unknown;
|
|
189
|
-
}>;
|
|
190
|
-
/** Operation duration in milliseconds */
|
|
191
|
-
duration: number;
|
|
192
|
-
/** Operation timestamp */
|
|
193
|
-
timestamp: string;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
/**
|
|
197
|
-
* Database migration entry
|
|
198
|
-
*/
|
|
199
|
-
export interface DatabaseMigration extends BaseEntity {
|
|
200
|
-
/** Migration version */
|
|
201
|
-
version: string;
|
|
202
|
-
/** Migration name */
|
|
203
|
-
name: string;
|
|
204
|
-
/** Migration description */
|
|
205
|
-
description?: string;
|
|
206
|
-
/** Migration type */
|
|
207
|
-
type: 'schema' | 'data' | 'index' | 'config';
|
|
208
|
-
/** Migration status */
|
|
209
|
-
status: 'pending' | 'running' | 'completed' | 'failed' | 'rolled-back';
|
|
210
|
-
/** Migration script content */
|
|
211
|
-
script?: string;
|
|
212
|
-
/** Checksum for integrity verification */
|
|
213
|
-
checksum?: string;
|
|
214
|
-
/** Execution duration in milliseconds */
|
|
215
|
-
duration?: number;
|
|
216
|
-
/** Error message if failed */
|
|
217
|
-
error?: string;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
// ============================================================================
|
|
221
|
-
// ZOD SCHEMAS FOR RUNTIME VALIDATION
|
|
222
|
-
// ============================================================================
|
|
223
|
-
|
|
224
|
-
/**
|
|
225
|
-
* Zod schema for BaseEntity
|
|
226
|
-
*/
|
|
227
|
-
export const BaseEntitySchema = z.object({
|
|
228
|
-
id: z.string(),
|
|
229
|
-
createdAt: z.string(),
|
|
230
|
-
updatedAt: z.string(),
|
|
231
|
-
version: z.number().optional(),
|
|
232
|
-
deletedAt: z.string().optional(),
|
|
233
|
-
metadata: z.record(z.unknown()).optional(),
|
|
234
|
-
});
|
|
235
|
-
|
|
236
|
-
/**
|
|
237
|
-
* Zod schema for MemoryStorageEntry
|
|
238
|
-
*/
|
|
239
|
-
export const MemoryStorageEntrySchema = BaseEntitySchema.extend({
|
|
240
|
-
namespace: z.string(),
|
|
241
|
-
key: z.string(),
|
|
242
|
-
value: z.unknown(),
|
|
243
|
-
valueType: z.enum(['string', 'number', 'boolean', 'object', 'array', 'null']),
|
|
244
|
-
size: z.number().optional(),
|
|
245
|
-
expiresAt: z.string().optional(),
|
|
246
|
-
accessCount: z.number().optional(),
|
|
247
|
-
lastAccessedAt: z.string().optional(),
|
|
248
|
-
});
|
|
249
|
-
|
|
250
|
-
/**
|
|
251
|
-
* Zod schema for VectorStorageEntry
|
|
252
|
-
*/
|
|
253
|
-
export const VectorStorageEntrySchema = BaseEntitySchema.extend({
|
|
254
|
-
content: z.string(),
|
|
255
|
-
embedding: z.array(z.number()),
|
|
256
|
-
dimensions: z.number(),
|
|
257
|
-
sourcePath: z.string().optional(),
|
|
258
|
-
contentHash: z.string().optional(),
|
|
259
|
-
type: z.enum(['document', 'code', 'markdown', 'text']),
|
|
260
|
-
language: z.string().optional(),
|
|
261
|
-
tokenCount: z.number().optional(),
|
|
262
|
-
metadata: z
|
|
263
|
-
.object({
|
|
264
|
-
title: z.string().optional(),
|
|
265
|
-
description: z.string().optional(),
|
|
266
|
-
tags: z.array(z.string()).optional(),
|
|
267
|
-
author: z.string().optional(),
|
|
268
|
-
project: z.string().optional(),
|
|
269
|
-
})
|
|
270
|
-
.catchall(z.unknown())
|
|
271
|
-
.optional(),
|
|
272
|
-
});
|
|
273
|
-
|
|
274
|
-
/**
|
|
275
|
-
* Zod schema for SearchIndexEntry
|
|
276
|
-
*/
|
|
277
|
-
export const SearchIndexEntrySchema = BaseEntitySchema.extend({
|
|
278
|
-
documentId: z.string(),
|
|
279
|
-
term: z.string(),
|
|
280
|
-
frequency: z.number(),
|
|
281
|
-
positions: z.array(z.number()).optional(),
|
|
282
|
-
field: z.enum(['title', 'content', 'metadata', 'all']).optional(),
|
|
283
|
-
tfidfScore: z.number().optional(),
|
|
284
|
-
indexMetadata: z.record(z.unknown()).optional(),
|
|
285
|
-
});
|
|
286
|
-
|
|
287
|
-
/**
|
|
288
|
-
* Zod schema for DatabaseHealthCheckResult
|
|
289
|
-
*/
|
|
290
|
-
export const DatabaseHealthCheckResultSchema = z.object({
|
|
291
|
-
healthy: z.boolean(),
|
|
292
|
-
timestamp: z.string(),
|
|
293
|
-
error: z.string().optional(),
|
|
294
|
-
details: z
|
|
295
|
-
.object({
|
|
296
|
-
connection: z.enum(['connected', 'disconnected', 'error']).optional(),
|
|
297
|
-
responseTime: z.number().optional(),
|
|
298
|
-
size: z
|
|
299
|
-
.object({
|
|
300
|
-
totalRecords: z.number(),
|
|
301
|
-
totalSize: z.number(),
|
|
302
|
-
indexes: z.number(),
|
|
303
|
-
})
|
|
304
|
-
.optional(),
|
|
305
|
-
memory: z
|
|
306
|
-
.object({
|
|
307
|
-
used: z.number(),
|
|
308
|
-
available: z.number(),
|
|
309
|
-
percentage: z.number(),
|
|
310
|
-
})
|
|
311
|
-
.optional(),
|
|
312
|
-
metrics: z.record(z.union([z.number(), z.string()])).optional(),
|
|
313
|
-
})
|
|
314
|
-
.optional(),
|
|
315
|
-
});
|
|
316
|
-
|
|
317
|
-
/**
|
|
318
|
-
* Zod schema for DatabaseQueryOptions
|
|
319
|
-
*/
|
|
320
|
-
export const DatabaseQueryOptionsSchema = z.object({
|
|
321
|
-
limit: z.number().optional(),
|
|
322
|
-
offset: z.number().optional(),
|
|
323
|
-
orderBy: z
|
|
324
|
-
.object({
|
|
325
|
-
field: z.string(),
|
|
326
|
-
direction: z.enum(['asc', 'desc']),
|
|
327
|
-
})
|
|
328
|
-
.optional(),
|
|
329
|
-
where: z.record(z.unknown()).optional(),
|
|
330
|
-
select: z.array(z.string()).optional(),
|
|
331
|
-
includeDeleted: z.boolean().optional(),
|
|
332
|
-
timeout: z.number().optional(),
|
|
333
|
-
});
|
|
334
|
-
|
|
335
|
-
/**
|
|
336
|
-
* Zod schema for DatabaseTransactionOptions
|
|
337
|
-
*/
|
|
338
|
-
export const DatabaseTransactionOptionsSchema = z.object({
|
|
339
|
-
isolation: z
|
|
340
|
-
.enum(['read-uncommitted', 'read-committed', 'repeatable-read', 'serializable'])
|
|
341
|
-
.optional(),
|
|
342
|
-
timeout: z.number().optional(),
|
|
343
|
-
readOnly: z.boolean().optional(),
|
|
344
|
-
metadata: z.record(z.unknown()).optional(),
|
|
345
|
-
});
|
|
346
|
-
|
|
347
|
-
/**
|
|
348
|
-
* Zod schema for BatchOperationResult
|
|
349
|
-
*/
|
|
350
|
-
export const BatchOperationResultSchema = z.object({
|
|
351
|
-
successCount: z.number(),
|
|
352
|
-
failureCount: z.number(),
|
|
353
|
-
total: z.number(),
|
|
354
|
-
successes: z.array(
|
|
355
|
-
z.object({
|
|
356
|
-
index: z.number(),
|
|
357
|
-
data: z.unknown().optional(),
|
|
358
|
-
id: z.string().optional(),
|
|
359
|
-
})
|
|
360
|
-
),
|
|
361
|
-
failures: z.array(
|
|
362
|
-
z.object({
|
|
363
|
-
index: z.number(),
|
|
364
|
-
error: z.string(),
|
|
365
|
-
data: z.unknown().optional(),
|
|
366
|
-
})
|
|
367
|
-
),
|
|
368
|
-
duration: z.number(),
|
|
369
|
-
timestamp: z.string(),
|
|
370
|
-
});
|
|
371
|
-
|
|
372
|
-
/**
|
|
373
|
-
* Zod schema for DatabaseMigration
|
|
374
|
-
*/
|
|
375
|
-
export const DatabaseMigrationSchema = BaseEntitySchema.extend({
|
|
376
|
-
version: z.string(),
|
|
377
|
-
name: z.string(),
|
|
378
|
-
description: z.string().optional(),
|
|
379
|
-
type: z.enum(['schema', 'data', 'index', 'config']),
|
|
380
|
-
status: z.enum(['pending', 'running', 'completed', 'failed', 'rolled-back']),
|
|
381
|
-
script: z.string().optional(),
|
|
382
|
-
checksum: z.string().optional(),
|
|
383
|
-
duration: z.number().optional(),
|
|
384
|
-
error: z.string().optional(),
|
|
385
|
-
});
|
|
386
|
-
|
|
387
|
-
// ============================================================================
|
|
388
|
-
// TYPE GUARDS FOR RUNTIME TYPE CHECKING
|
|
389
|
-
// ============================================================================
|
|
390
|
-
|
|
391
|
-
/**
|
|
392
|
-
* Type guard to check if value is BaseEntity
|
|
393
|
-
*/
|
|
394
|
-
export function isBaseEntity(value: unknown): value is BaseEntity {
|
|
395
|
-
return BaseEntitySchema.safeParse(value).success;
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
/**
|
|
399
|
-
* Type guard to check if value is MemoryStorageEntry
|
|
400
|
-
*/
|
|
401
|
-
export function isMemoryStorageEntry(value: unknown): value is MemoryStorageEntry {
|
|
402
|
-
return MemoryStorageEntrySchema.safeParse(value).success;
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
/**
|
|
406
|
-
* Type guard to check if value is VectorStorageEntry
|
|
407
|
-
*/
|
|
408
|
-
export function isVectorStorageEntry(value: unknown): value is VectorStorageEntry {
|
|
409
|
-
return VectorStorageEntrySchema.safeParse(value).success;
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
/**
|
|
413
|
-
* Type guard to check if value is SearchIndexEntry
|
|
414
|
-
*/
|
|
415
|
-
export function isSearchIndexEntry(value: unknown): value is SearchIndexEntry {
|
|
416
|
-
return SearchIndexEntrySchema.safeParse(value).success;
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
/**
|
|
420
|
-
* Type guard to check if value is DatabaseHealthCheckResult
|
|
421
|
-
*/
|
|
422
|
-
export function isDatabaseHealthCheckResult(value: unknown): value is DatabaseHealthCheckResult {
|
|
423
|
-
return DatabaseHealthCheckResultSchema.safeParse(value).success;
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
/**
|
|
427
|
-
* Type guard to check if value is DatabaseQueryOptions
|
|
428
|
-
*/
|
|
429
|
-
export function isDatabaseQueryOptions(value: unknown): value is DatabaseQueryOptions {
|
|
430
|
-
return DatabaseQueryOptionsSchema.safeParse(value).success;
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
/**
|
|
434
|
-
* Type guard to check if value is BatchOperationResult
|
|
435
|
-
*/
|
|
436
|
-
export function isBatchOperationResult(value: unknown): value is BatchOperationResult {
|
|
437
|
-
return BatchOperationResultSchema.safeParse(value).success;
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
/**
|
|
441
|
-
* Type guard to check if value is DatabaseMigration
|
|
442
|
-
*/
|
|
443
|
-
export function isDatabaseMigration(value: unknown): value is DatabaseMigration {
|
|
444
|
-
return DatabaseMigrationSchema.safeParse(value).success;
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
// ============================================================================
|
|
448
|
-
// UTILITY TYPES AND FUNCTIONS
|
|
449
|
-
// ============================================================================
|
|
450
|
-
|
|
451
|
-
/**
|
|
452
|
-
* Generic database result wrapper
|
|
453
|
-
*/
|
|
454
|
-
export interface DatabaseResult<T = unknown> {
|
|
455
|
-
/** Success status */
|
|
456
|
-
success: boolean;
|
|
457
|
-
/** Result data */
|
|
458
|
-
data?: T;
|
|
459
|
-
/** Error information */
|
|
460
|
-
error?: {
|
|
461
|
-
code: string;
|
|
462
|
-
message: string;
|
|
463
|
-
details?: Record<string, unknown>;
|
|
464
|
-
};
|
|
465
|
-
/** Result metadata */
|
|
466
|
-
metadata?: {
|
|
467
|
-
executionTime: number;
|
|
468
|
-
timestamp: string;
|
|
469
|
-
affectedRows?: number;
|
|
470
|
-
};
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
/**
|
|
474
|
-
* Type for database event listeners
|
|
475
|
-
*/
|
|
476
|
-
export type DatabaseEventListener<T = unknown> = (event: DatabaseEvent<T>) => void;
|
|
477
|
-
|
|
478
|
-
/**
|
|
479
|
-
* Database event interface
|
|
480
|
-
*/
|
|
481
|
-
export interface DatabaseEvent<T = unknown> {
|
|
482
|
-
/** Event type */
|
|
483
|
-
type: 'insert' | 'update' | 'delete' | 'query' | 'transaction' | 'error';
|
|
484
|
-
/** Event timestamp */
|
|
485
|
-
timestamp: string;
|
|
486
|
-
/** Event data */
|
|
487
|
-
data?: T;
|
|
488
|
-
/** Event metadata */
|
|
489
|
-
metadata?: Record<string, unknown>;
|
|
490
|
-
}
|
|
491
|
-
|
|
492
|
-
/**
|
|
493
|
-
* Create a safe database result
|
|
494
|
-
*/
|
|
495
|
-
export function createDatabaseResult<T>(
|
|
496
|
-
success: boolean,
|
|
497
|
-
data?: T,
|
|
498
|
-
error?: { code: string; message: string; details?: Record<string, unknown> },
|
|
499
|
-
metadata?: { executionTime: number; timestamp: string; affectedRows?: number }
|
|
500
|
-
): DatabaseResult<T> {
|
|
501
|
-
return {
|
|
502
|
-
success,
|
|
503
|
-
data,
|
|
504
|
-
error,
|
|
505
|
-
metadata: metadata || {
|
|
506
|
-
executionTime: 0,
|
|
507
|
-
timestamp: new Date().toISOString(),
|
|
508
|
-
},
|
|
509
|
-
};
|
|
510
|
-
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Memory Service Types
|
|
3
|
-
* Value types for functional memory operations
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Metadata for memory entries
|
|
8
|
-
*/
|
|
9
|
-
export interface MemoryMetadata {
|
|
10
|
-
readonly namespace: string;
|
|
11
|
-
readonly timestamp: number;
|
|
12
|
-
readonly size: number;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Memory value with metadata
|
|
17
|
-
* Used as success value in Result<MemoryValue, E>
|
|
18
|
-
*/
|
|
19
|
-
export interface MemoryValue {
|
|
20
|
-
readonly value: string;
|
|
21
|
-
readonly metadata: MemoryMetadata;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Result of listing memory entries
|
|
26
|
-
*/
|
|
27
|
-
export interface MemoryListResult {
|
|
28
|
-
readonly entries: ReadonlyArray<{
|
|
29
|
-
readonly key: string;
|
|
30
|
-
readonly value: string;
|
|
31
|
-
readonly namespace: string;
|
|
32
|
-
readonly timestamp: number;
|
|
33
|
-
}>;
|
|
34
|
-
readonly metadata: {
|
|
35
|
-
readonly namespace: string;
|
|
36
|
-
readonly count: number;
|
|
37
|
-
readonly totalSize: number;
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Result of memory statistics
|
|
43
|
-
*/
|
|
44
|
-
export interface MemoryStatsResult {
|
|
45
|
-
readonly totalEntries: number;
|
|
46
|
-
readonly totalSize: number;
|
|
47
|
-
readonly namespaces: ReadonlyArray<{
|
|
48
|
-
readonly name: string;
|
|
49
|
-
readonly count: number;
|
|
50
|
-
readonly oldestTimestamp?: number;
|
|
51
|
-
readonly newestTimestamp?: number;
|
|
52
|
-
}>;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Memory entry for cache storage
|
|
57
|
-
*/
|
|
58
|
-
export interface CachedMemoryEntry {
|
|
59
|
-
readonly key: string;
|
|
60
|
-
readonly value: string;
|
|
61
|
-
readonly namespace: string;
|
|
62
|
-
readonly timestamp: number;
|
|
63
|
-
}
|