@affectively/aeon 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/LICENSE +21 -0
- package/README.md +332 -0
- package/dist/core/index.cjs +4 -0
- package/dist/core/index.cjs.map +1 -0
- package/dist/core/index.d.cts +146 -0
- package/dist/core/index.d.ts +146 -0
- package/dist/core/index.js +3 -0
- package/dist/core/index.js.map +1 -0
- package/dist/distributed/index.cjs +1874 -0
- package/dist/distributed/index.cjs.map +1 -0
- package/dist/distributed/index.d.cts +2 -0
- package/dist/distributed/index.d.ts +2 -0
- package/dist/distributed/index.js +1869 -0
- package/dist/distributed/index.js.map +1 -0
- package/dist/index-C_4CMV5c.d.cts +1207 -0
- package/dist/index-C_4CMV5c.d.ts +1207 -0
- package/dist/index.cjs +4671 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +812 -0
- package/dist/index.d.ts +812 -0
- package/dist/index.js +4632 -0
- package/dist/index.js.map +1 -0
- package/dist/utils/index.cjs +64 -0
- package/dist/utils/index.cjs.map +1 -0
- package/dist/utils/index.d.cts +38 -0
- package/dist/utils/index.d.ts +38 -0
- package/dist/utils/index.js +57 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/versioning/index.cjs +871 -0
- package/dist/versioning/index.cjs.map +1 -0
- package/dist/versioning/index.d.cts +472 -0
- package/dist/versioning/index.d.ts +472 -0
- package/dist/versioning/index.js +866 -0
- package/dist/versioning/index.js.map +1 -0
- package/package.json +142 -0
|
@@ -0,0 +1,472 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Schema Version Manager
|
|
3
|
+
*
|
|
4
|
+
* Manages schema versioning across the application.
|
|
5
|
+
* Tracks version history, compatibility, and migration paths.
|
|
6
|
+
*
|
|
7
|
+
* Features:
|
|
8
|
+
* - Version tracking and comparison
|
|
9
|
+
* - Compatibility matrix management
|
|
10
|
+
* - Migration path calculation
|
|
11
|
+
* - Version validation
|
|
12
|
+
*/
|
|
13
|
+
interface SchemaVersion {
|
|
14
|
+
major: number;
|
|
15
|
+
minor: number;
|
|
16
|
+
patch: number;
|
|
17
|
+
timestamp: string;
|
|
18
|
+
description: string;
|
|
19
|
+
breaking: boolean;
|
|
20
|
+
}
|
|
21
|
+
interface VersionMetadata {
|
|
22
|
+
version: SchemaVersion;
|
|
23
|
+
previousVersion?: SchemaVersion;
|
|
24
|
+
changes: string[];
|
|
25
|
+
migrationsRequired: string[];
|
|
26
|
+
rollbackPossible: boolean;
|
|
27
|
+
}
|
|
28
|
+
interface CompatibilityRule {
|
|
29
|
+
from: string;
|
|
30
|
+
to: string;
|
|
31
|
+
compatible: boolean;
|
|
32
|
+
requiresMigration: boolean;
|
|
33
|
+
migrationSteps: number;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Schema Version Manager
|
|
37
|
+
* Tracks and manages schema versions across the application
|
|
38
|
+
*/
|
|
39
|
+
declare class SchemaVersionManager {
|
|
40
|
+
private versions;
|
|
41
|
+
private versionHistory;
|
|
42
|
+
private compatibilityMatrix;
|
|
43
|
+
private currentVersion;
|
|
44
|
+
constructor();
|
|
45
|
+
/**
|
|
46
|
+
* Initialize default versions
|
|
47
|
+
*/
|
|
48
|
+
private initializeDefaultVersions;
|
|
49
|
+
/**
|
|
50
|
+
* Register a new schema version
|
|
51
|
+
*/
|
|
52
|
+
registerVersion(version: SchemaVersion): void;
|
|
53
|
+
/**
|
|
54
|
+
* Get current version
|
|
55
|
+
*/
|
|
56
|
+
getCurrentVersion(): SchemaVersion;
|
|
57
|
+
/**
|
|
58
|
+
* Set current version
|
|
59
|
+
*/
|
|
60
|
+
setCurrentVersion(version: SchemaVersion): void;
|
|
61
|
+
/**
|
|
62
|
+
* Get version history
|
|
63
|
+
*/
|
|
64
|
+
getVersionHistory(): SchemaVersion[];
|
|
65
|
+
/**
|
|
66
|
+
* Check if version exists
|
|
67
|
+
*/
|
|
68
|
+
hasVersion(version: SchemaVersion): boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Get version by string (e.g., "1.2.3")
|
|
71
|
+
*/
|
|
72
|
+
getVersion(versionString: string): SchemaVersion | undefined;
|
|
73
|
+
/**
|
|
74
|
+
* Register compatibility rule
|
|
75
|
+
*/
|
|
76
|
+
registerCompatibility(rule: CompatibilityRule): void;
|
|
77
|
+
/**
|
|
78
|
+
* Check if migration path exists
|
|
79
|
+
*/
|
|
80
|
+
canMigrate(fromVersion: SchemaVersion | string, toVersion: SchemaVersion | string): boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Get migration path
|
|
83
|
+
*/
|
|
84
|
+
getMigrationPath(fromVersion: SchemaVersion, toVersion: SchemaVersion): SchemaVersion[];
|
|
85
|
+
/**
|
|
86
|
+
* Compare two versions
|
|
87
|
+
* Returns: -1 if v1 < v2, 0 if equal, 1 if v1 > v2
|
|
88
|
+
*/
|
|
89
|
+
compareVersions(v1: SchemaVersion | string, v2: SchemaVersion | string): number;
|
|
90
|
+
/**
|
|
91
|
+
* Parse version string to SchemaVersion
|
|
92
|
+
*/
|
|
93
|
+
parseVersion(versionString: string): SchemaVersion;
|
|
94
|
+
/**
|
|
95
|
+
* Create new version
|
|
96
|
+
*/
|
|
97
|
+
createVersion(major: number, minor: number, patch: number, description: string, breaking?: boolean): SchemaVersion;
|
|
98
|
+
/**
|
|
99
|
+
* Convert version to string
|
|
100
|
+
*/
|
|
101
|
+
versionToString(version: SchemaVersion): string;
|
|
102
|
+
/**
|
|
103
|
+
* Get version metadata
|
|
104
|
+
*/
|
|
105
|
+
getVersionMetadata(version: SchemaVersion): VersionMetadata;
|
|
106
|
+
/**
|
|
107
|
+
* Get all registered versions
|
|
108
|
+
*/
|
|
109
|
+
getAllVersions(): SchemaVersion[];
|
|
110
|
+
/**
|
|
111
|
+
* Clear all versions (for testing)
|
|
112
|
+
*/
|
|
113
|
+
clear(): void;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Migration Engine
|
|
118
|
+
*
|
|
119
|
+
* Executes schema migrations with rollback support.
|
|
120
|
+
* Manages migration execution, error handling, and state management.
|
|
121
|
+
*
|
|
122
|
+
* Features:
|
|
123
|
+
* - Migration execution and tracking
|
|
124
|
+
* - Rollback support
|
|
125
|
+
* - Error handling and recovery
|
|
126
|
+
* - Migration state management
|
|
127
|
+
*/
|
|
128
|
+
interface Migration {
|
|
129
|
+
id: string;
|
|
130
|
+
version: string;
|
|
131
|
+
name: string;
|
|
132
|
+
up: (data: unknown) => unknown;
|
|
133
|
+
down?: (data: unknown) => unknown;
|
|
134
|
+
timestamp: string;
|
|
135
|
+
description: string;
|
|
136
|
+
}
|
|
137
|
+
interface MigrationResult {
|
|
138
|
+
migrationId: string;
|
|
139
|
+
success: boolean;
|
|
140
|
+
timestamp: string;
|
|
141
|
+
duration: number;
|
|
142
|
+
itemsAffected: number;
|
|
143
|
+
errors: string[];
|
|
144
|
+
}
|
|
145
|
+
interface MigrationState {
|
|
146
|
+
currentVersion: string;
|
|
147
|
+
appliedMigrations: string[];
|
|
148
|
+
failedMigrations: string[];
|
|
149
|
+
lastMigrationTime: string;
|
|
150
|
+
totalMigrationsRun: number;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Migration Engine
|
|
154
|
+
* Executes and manages schema migrations
|
|
155
|
+
*/
|
|
156
|
+
declare class MigrationEngine {
|
|
157
|
+
private migrations;
|
|
158
|
+
private executedMigrations;
|
|
159
|
+
private state;
|
|
160
|
+
/**
|
|
161
|
+
* Register a migration
|
|
162
|
+
*/
|
|
163
|
+
registerMigration(migration: Migration): void;
|
|
164
|
+
/**
|
|
165
|
+
* Execute a migration
|
|
166
|
+
*/
|
|
167
|
+
executeMigration(migrationId: string, data: unknown): Promise<MigrationResult>;
|
|
168
|
+
/**
|
|
169
|
+
* Rollback a migration
|
|
170
|
+
*/
|
|
171
|
+
rollbackMigration(migrationId: string, data: unknown): Promise<MigrationResult>;
|
|
172
|
+
/**
|
|
173
|
+
* Get migration state
|
|
174
|
+
*/
|
|
175
|
+
getState(): MigrationState;
|
|
176
|
+
/**
|
|
177
|
+
* Get migration execution history
|
|
178
|
+
*/
|
|
179
|
+
getExecutionHistory(): MigrationResult[];
|
|
180
|
+
/**
|
|
181
|
+
* Get migration by ID
|
|
182
|
+
*/
|
|
183
|
+
getMigration(migrationId: string): Migration | undefined;
|
|
184
|
+
/**
|
|
185
|
+
* Get all registered migrations
|
|
186
|
+
*/
|
|
187
|
+
getAllMigrations(): Migration[];
|
|
188
|
+
/**
|
|
189
|
+
* Get applied migrations
|
|
190
|
+
*/
|
|
191
|
+
getAppliedMigrations(): string[];
|
|
192
|
+
/**
|
|
193
|
+
* Get failed migrations
|
|
194
|
+
*/
|
|
195
|
+
getFailedMigrations(): string[];
|
|
196
|
+
/**
|
|
197
|
+
* Get pending migrations
|
|
198
|
+
*/
|
|
199
|
+
getPendingMigrations(): Migration[];
|
|
200
|
+
/**
|
|
201
|
+
* Get migration statistics
|
|
202
|
+
*/
|
|
203
|
+
getStatistics(): {
|
|
204
|
+
totalExecuted: number;
|
|
205
|
+
successful: number;
|
|
206
|
+
failed: number;
|
|
207
|
+
successRate: number;
|
|
208
|
+
totalDurationMs: number;
|
|
209
|
+
averageDurationMs: number;
|
|
210
|
+
totalAffected: number;
|
|
211
|
+
};
|
|
212
|
+
/**
|
|
213
|
+
* Clear history (for testing)
|
|
214
|
+
*/
|
|
215
|
+
clear(): void;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Data Transformer
|
|
220
|
+
*
|
|
221
|
+
* Transforms data structures during schema migrations.
|
|
222
|
+
* Handles field transformation, type casting, and validation.
|
|
223
|
+
*
|
|
224
|
+
* Features:
|
|
225
|
+
* - Field-level transformation
|
|
226
|
+
* - Type conversion and casting
|
|
227
|
+
* - Validation during transformation
|
|
228
|
+
* - Error handling and reporting
|
|
229
|
+
* - Batch transformation support
|
|
230
|
+
*/
|
|
231
|
+
interface FieldTransformer {
|
|
232
|
+
(value: unknown): unknown;
|
|
233
|
+
}
|
|
234
|
+
interface TransformationRule {
|
|
235
|
+
field: string;
|
|
236
|
+
transformer: FieldTransformer;
|
|
237
|
+
required?: boolean;
|
|
238
|
+
defaultValue?: unknown;
|
|
239
|
+
}
|
|
240
|
+
interface TransformationResult {
|
|
241
|
+
success: boolean;
|
|
242
|
+
itemsTransformed: number;
|
|
243
|
+
itemsFailed: number;
|
|
244
|
+
errors: Array<{
|
|
245
|
+
item: unknown;
|
|
246
|
+
error: string;
|
|
247
|
+
}>;
|
|
248
|
+
warnings: string[];
|
|
249
|
+
duration: number;
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Data Transformer
|
|
253
|
+
* Transforms data structures during schema migrations
|
|
254
|
+
*/
|
|
255
|
+
declare class DataTransformer {
|
|
256
|
+
private rules;
|
|
257
|
+
private transformationHistory;
|
|
258
|
+
/**
|
|
259
|
+
* Register a transformation rule
|
|
260
|
+
*/
|
|
261
|
+
registerRule(rule: TransformationRule): void;
|
|
262
|
+
/**
|
|
263
|
+
* Transform a single field value
|
|
264
|
+
*/
|
|
265
|
+
transformField(field: string, value: unknown): unknown;
|
|
266
|
+
/**
|
|
267
|
+
* Transform a single object
|
|
268
|
+
*/
|
|
269
|
+
transformObject(data: Record<string, unknown>): Record<string, unknown>;
|
|
270
|
+
/**
|
|
271
|
+
* Transform a collection of items
|
|
272
|
+
*/
|
|
273
|
+
transformCollection(items: unknown[]): TransformationResult;
|
|
274
|
+
/**
|
|
275
|
+
* Validate transformed data
|
|
276
|
+
*/
|
|
277
|
+
validateTransformation(original: unknown[], transformed: unknown[]): {
|
|
278
|
+
valid: boolean;
|
|
279
|
+
issues: string[];
|
|
280
|
+
};
|
|
281
|
+
/**
|
|
282
|
+
* Validate a single item transformation
|
|
283
|
+
*/
|
|
284
|
+
private validateItem;
|
|
285
|
+
/**
|
|
286
|
+
* Get transformation history
|
|
287
|
+
*/
|
|
288
|
+
getTransformationHistory(): TransformationResult[];
|
|
289
|
+
/**
|
|
290
|
+
* Get transformation statistics
|
|
291
|
+
*/
|
|
292
|
+
getStatistics(): {
|
|
293
|
+
totalBatches: number;
|
|
294
|
+
totalTransformed: number;
|
|
295
|
+
totalFailed: number;
|
|
296
|
+
successRate: number;
|
|
297
|
+
totalDurationMs: number;
|
|
298
|
+
averageBatchDurationMs: number;
|
|
299
|
+
};
|
|
300
|
+
/**
|
|
301
|
+
* Get registered rules
|
|
302
|
+
*/
|
|
303
|
+
getRules(): TransformationRule[];
|
|
304
|
+
/**
|
|
305
|
+
* Get rule for field
|
|
306
|
+
*/
|
|
307
|
+
getRule(field: string): TransformationRule | undefined;
|
|
308
|
+
/**
|
|
309
|
+
* Clear all rules (for testing)
|
|
310
|
+
*/
|
|
311
|
+
clearRules(): void;
|
|
312
|
+
/**
|
|
313
|
+
* Clear history (for testing)
|
|
314
|
+
*/
|
|
315
|
+
clearHistory(): void;
|
|
316
|
+
/**
|
|
317
|
+
* Clear all state (for testing)
|
|
318
|
+
*/
|
|
319
|
+
clear(): void;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
* Migration Tracker
|
|
324
|
+
*
|
|
325
|
+
* Tracks migration history and enables rollback.
|
|
326
|
+
* Maintains detailed audit trail of all schema changes.
|
|
327
|
+
*
|
|
328
|
+
* Features:
|
|
329
|
+
* - Migration history tracking
|
|
330
|
+
* - Rollback path calculation
|
|
331
|
+
* - Data snapshots for recovery
|
|
332
|
+
* - Audit trail with timestamps
|
|
333
|
+
* - Migration dependency tracking
|
|
334
|
+
*/
|
|
335
|
+
interface MigrationRecord {
|
|
336
|
+
id: string;
|
|
337
|
+
migrationId: string;
|
|
338
|
+
timestamp: string;
|
|
339
|
+
version: string;
|
|
340
|
+
direction: 'up' | 'down';
|
|
341
|
+
status: 'pending' | 'applied' | 'failed' | 'rolled-back';
|
|
342
|
+
duration: number;
|
|
343
|
+
itemsAffected: number;
|
|
344
|
+
dataSnapshot?: {
|
|
345
|
+
beforeHash: string;
|
|
346
|
+
afterHash: string;
|
|
347
|
+
itemCount: number;
|
|
348
|
+
};
|
|
349
|
+
errorMessage?: string;
|
|
350
|
+
appliedBy: string;
|
|
351
|
+
metadata?: Record<string, unknown>;
|
|
352
|
+
}
|
|
353
|
+
interface RollbackPath {
|
|
354
|
+
path: string[];
|
|
355
|
+
canRollback: boolean;
|
|
356
|
+
affectedVersions: string[];
|
|
357
|
+
estimatedDuration: number;
|
|
358
|
+
}
|
|
359
|
+
/**
|
|
360
|
+
* Migration Tracker
|
|
361
|
+
* Tracks and manages migration history with rollback support
|
|
362
|
+
*/
|
|
363
|
+
declare class MigrationTracker {
|
|
364
|
+
private migrations;
|
|
365
|
+
private snapshots;
|
|
366
|
+
/**
|
|
367
|
+
* Track a new migration
|
|
368
|
+
*/
|
|
369
|
+
recordMigration(record: MigrationRecord): void;
|
|
370
|
+
/**
|
|
371
|
+
* Track migration with snapshot
|
|
372
|
+
*/
|
|
373
|
+
trackMigration(migrationId: string, version: string, beforeHash: string, afterHash: string, itemCount: number, duration: number, itemsAffected: number, appliedBy?: string): void;
|
|
374
|
+
/**
|
|
375
|
+
* Get all migration records
|
|
376
|
+
*/
|
|
377
|
+
getMigrations(): MigrationRecord[];
|
|
378
|
+
/**
|
|
379
|
+
* Get migrations for a specific version
|
|
380
|
+
*/
|
|
381
|
+
getMigrationsForVersion(version: string): MigrationRecord[];
|
|
382
|
+
/**
|
|
383
|
+
* Get migration by ID
|
|
384
|
+
*/
|
|
385
|
+
getMigration(id: string): MigrationRecord | undefined;
|
|
386
|
+
/**
|
|
387
|
+
* Check if can rollback
|
|
388
|
+
*/
|
|
389
|
+
canRollback(fromVersion: string, toVersion: string): boolean;
|
|
390
|
+
/**
|
|
391
|
+
* Get rollback path
|
|
392
|
+
*/
|
|
393
|
+
getRollbackPath(fromVersion: string, toVersion: string): RollbackPath;
|
|
394
|
+
/**
|
|
395
|
+
* Get applied migrations
|
|
396
|
+
*/
|
|
397
|
+
getAppliedMigrations(): MigrationRecord[];
|
|
398
|
+
/**
|
|
399
|
+
* Get failed migrations
|
|
400
|
+
*/
|
|
401
|
+
getFailedMigrations(): MigrationRecord[];
|
|
402
|
+
/**
|
|
403
|
+
* Get pending migrations
|
|
404
|
+
*/
|
|
405
|
+
getPendingMigrations(): MigrationRecord[];
|
|
406
|
+
/**
|
|
407
|
+
* Get latest migration
|
|
408
|
+
*/
|
|
409
|
+
getLatestMigration(): MigrationRecord | undefined;
|
|
410
|
+
/**
|
|
411
|
+
* Get migration timeline
|
|
412
|
+
*/
|
|
413
|
+
getTimeline(): Array<{
|
|
414
|
+
timestamp: string;
|
|
415
|
+
version: string;
|
|
416
|
+
status: string;
|
|
417
|
+
}>;
|
|
418
|
+
/**
|
|
419
|
+
* Get migration statistics
|
|
420
|
+
*/
|
|
421
|
+
getStatistics(): {
|
|
422
|
+
total: number;
|
|
423
|
+
applied: number;
|
|
424
|
+
failed: number;
|
|
425
|
+
pending: number;
|
|
426
|
+
rolledBack: number;
|
|
427
|
+
successRate: number;
|
|
428
|
+
totalDurationMs: number;
|
|
429
|
+
averageDurationMs: number;
|
|
430
|
+
totalItemsAffected: number;
|
|
431
|
+
};
|
|
432
|
+
/**
|
|
433
|
+
* Get audit trail
|
|
434
|
+
*/
|
|
435
|
+
getAuditTrail(migrationId?: string): {
|
|
436
|
+
id: string;
|
|
437
|
+
timestamp: string;
|
|
438
|
+
migrationId: string;
|
|
439
|
+
version: string;
|
|
440
|
+
status: "pending" | "failed" | "applied" | "rolled-back";
|
|
441
|
+
appliedBy: string;
|
|
442
|
+
duration: number;
|
|
443
|
+
itemsAffected: number;
|
|
444
|
+
error: string | undefined;
|
|
445
|
+
}[];
|
|
446
|
+
/**
|
|
447
|
+
* Get data snapshot for recovery
|
|
448
|
+
*/
|
|
449
|
+
getSnapshot(recordId: string): {
|
|
450
|
+
beforeHash: string;
|
|
451
|
+
afterHash: string;
|
|
452
|
+
itemCount: number;
|
|
453
|
+
} | undefined;
|
|
454
|
+
/**
|
|
455
|
+
* Update migration status
|
|
456
|
+
*/
|
|
457
|
+
updateMigrationStatus(recordId: string, status: MigrationRecord['status'], error?: string): void;
|
|
458
|
+
/**
|
|
459
|
+
* Clear history (for testing)
|
|
460
|
+
*/
|
|
461
|
+
clear(): void;
|
|
462
|
+
/**
|
|
463
|
+
* Get total migrations tracked
|
|
464
|
+
*/
|
|
465
|
+
getTotalMigrations(): number;
|
|
466
|
+
/**
|
|
467
|
+
* Find migrations by time range
|
|
468
|
+
*/
|
|
469
|
+
getMigrationsByTimeRange(startTime: string, endTime: string): MigrationRecord[];
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
export { type CompatibilityRule, DataTransformer, type FieldTransformer, type Migration, MigrationEngine, type MigrationRecord, type MigrationResult, type MigrationState, MigrationTracker, type RollbackPath, type SchemaVersion, SchemaVersionManager, type TransformationResult, type TransformationRule, type VersionMetadata };
|