@gravito/ripple 3.0.1 → 4.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.
Files changed (168) hide show
  1. package/README.md +432 -18
  2. package/README.zh-TW.md +104 -2
  3. package/dist/atlas/src/DB.d.ts +301 -0
  4. package/dist/atlas/src/OrbitAtlas.d.ts +9 -0
  5. package/dist/atlas/src/config/defineConfig.d.ts +14 -0
  6. package/dist/atlas/src/config/index.d.ts +7 -0
  7. package/dist/atlas/src/config/loadConfig.d.ts +48 -0
  8. package/dist/atlas/src/connection/Connection.d.ts +108 -0
  9. package/dist/atlas/src/connection/ConnectionManager.d.ts +111 -0
  10. package/dist/atlas/src/drivers/BunSQLDriver.d.ts +32 -0
  11. package/dist/atlas/src/drivers/BunSQLPreparedStatement.d.ts +118 -0
  12. package/dist/atlas/src/drivers/MongoDBDriver.d.ts +36 -0
  13. package/dist/atlas/src/drivers/MySQLDriver.d.ts +66 -0
  14. package/dist/atlas/src/drivers/PostgresDriver.d.ts +83 -0
  15. package/dist/atlas/src/drivers/RedisDriver.d.ts +43 -0
  16. package/dist/atlas/src/drivers/SQLiteDriver.d.ts +45 -0
  17. package/dist/atlas/src/drivers/types.d.ts +260 -0
  18. package/dist/atlas/src/errors/index.d.ts +45 -0
  19. package/dist/atlas/src/grammar/Grammar.d.ts +342 -0
  20. package/dist/atlas/src/grammar/MongoGrammar.d.ts +47 -0
  21. package/dist/atlas/src/grammar/MySQLGrammar.d.ts +54 -0
  22. package/dist/atlas/src/grammar/NullGrammar.d.ts +35 -0
  23. package/dist/atlas/src/grammar/PostgresGrammar.d.ts +62 -0
  24. package/dist/atlas/src/grammar/SQLiteGrammar.d.ts +32 -0
  25. package/dist/atlas/src/index.d.ts +67 -0
  26. package/dist/atlas/src/migration/Migration.d.ts +64 -0
  27. package/dist/atlas/src/migration/MigrationRepository.d.ts +65 -0
  28. package/dist/atlas/src/migration/Migrator.d.ts +110 -0
  29. package/dist/atlas/src/migration/index.d.ts +6 -0
  30. package/dist/atlas/src/observability/AtlasMetrics.d.ts +11 -0
  31. package/dist/atlas/src/observability/AtlasObservability.d.ts +15 -0
  32. package/dist/atlas/src/observability/AtlasTracer.d.ts +12 -0
  33. package/dist/atlas/src/observability/index.d.ts +9 -0
  34. package/dist/atlas/src/orm/index.d.ts +5 -0
  35. package/dist/atlas/src/orm/model/DirtyTracker.d.ts +121 -0
  36. package/dist/atlas/src/orm/model/Model.d.ts +449 -0
  37. package/dist/atlas/src/orm/model/ModelRegistry.d.ts +20 -0
  38. package/dist/atlas/src/orm/model/concerns/HasAttributes.d.ts +136 -0
  39. package/dist/atlas/src/orm/model/concerns/HasEvents.d.ts +36 -0
  40. package/dist/atlas/src/orm/model/concerns/HasPersistence.d.ts +87 -0
  41. package/dist/atlas/src/orm/model/concerns/HasRelationships.d.ts +117 -0
  42. package/dist/atlas/src/orm/model/concerns/HasSerialization.d.ts +64 -0
  43. package/dist/atlas/src/orm/model/concerns/applyMixins.d.ts +15 -0
  44. package/dist/atlas/src/orm/model/concerns/index.d.ts +12 -0
  45. package/dist/atlas/src/orm/model/decorators.d.ts +109 -0
  46. package/dist/atlas/src/orm/model/errors.d.ts +52 -0
  47. package/dist/atlas/src/orm/model/index.d.ts +10 -0
  48. package/dist/atlas/src/orm/model/relationships.d.ts +207 -0
  49. package/dist/atlas/src/orm/model/types.d.ts +12 -0
  50. package/dist/atlas/src/orm/schema/SchemaRegistry.d.ts +123 -0
  51. package/dist/atlas/src/orm/schema/SchemaSniffer.d.ts +54 -0
  52. package/dist/atlas/src/orm/schema/index.d.ts +6 -0
  53. package/dist/atlas/src/orm/schema/types.d.ts +85 -0
  54. package/dist/atlas/src/query/Expression.d.ts +60 -0
  55. package/dist/atlas/src/query/NPlusOneDetector.d.ts +10 -0
  56. package/dist/atlas/src/query/QueryBuilder.d.ts +573 -0
  57. package/dist/atlas/src/query/clauses/GroupByClause.d.ts +51 -0
  58. package/dist/atlas/src/query/clauses/HavingClause.d.ts +70 -0
  59. package/dist/atlas/src/query/clauses/JoinClause.d.ts +87 -0
  60. package/dist/atlas/src/query/clauses/LimitClause.d.ts +82 -0
  61. package/dist/atlas/src/query/clauses/OrderByClause.d.ts +69 -0
  62. package/dist/atlas/src/query/clauses/SelectClause.d.ts +71 -0
  63. package/dist/atlas/src/query/clauses/WhereClause.d.ts +167 -0
  64. package/dist/atlas/src/query/clauses/index.d.ts +11 -0
  65. package/dist/atlas/src/schema/Blueprint.d.ts +276 -0
  66. package/dist/atlas/src/schema/ColumnDefinition.d.ts +154 -0
  67. package/dist/atlas/src/schema/ForeignKeyDefinition.d.ts +37 -0
  68. package/dist/atlas/src/schema/Schema.d.ts +131 -0
  69. package/dist/atlas/src/schema/grammars/MySQLSchemaGrammar.d.ts +23 -0
  70. package/dist/atlas/src/schema/grammars/PostgresSchemaGrammar.d.ts +26 -0
  71. package/dist/atlas/src/schema/grammars/SQLiteSchemaGrammar.d.ts +28 -0
  72. package/dist/atlas/src/schema/grammars/SchemaGrammar.d.ts +97 -0
  73. package/dist/atlas/src/schema/grammars/index.d.ts +7 -0
  74. package/dist/atlas/src/schema/index.d.ts +8 -0
  75. package/dist/atlas/src/seed/Factory.d.ts +90 -0
  76. package/dist/atlas/src/seed/Seeder.d.ts +28 -0
  77. package/dist/atlas/src/seed/SeederRunner.d.ts +74 -0
  78. package/dist/atlas/src/seed/index.d.ts +6 -0
  79. package/dist/atlas/src/types/index.d.ts +1100 -0
  80. package/dist/atlas/src/utils/levenshtein.d.ts +9 -0
  81. package/dist/core/src/Application.d.ts +43 -17
  82. package/dist/core/src/CommandKernel.d.ts +33 -0
  83. package/dist/core/src/Container.d.ts +78 -14
  84. package/dist/core/src/HookManager.d.ts +422 -8
  85. package/dist/core/src/PlanetCore.d.ts +52 -7
  86. package/dist/core/src/Router.d.ts +41 -7
  87. package/dist/core/src/ServiceProvider.d.ts +14 -8
  88. package/dist/core/src/adapters/GravitoEngineAdapter.d.ts +1 -0
  89. package/dist/core/src/adapters/PhotonAdapter.d.ts +1 -0
  90. package/dist/core/src/adapters/bun/BunNativeAdapter.d.ts +1 -0
  91. package/dist/core/src/adapters/types.d.ts +39 -0
  92. package/dist/core/src/engine/AOTRouter.d.ts +1 -11
  93. package/dist/core/src/engine/FastContext.d.ts +4 -2
  94. package/dist/core/src/engine/Gravito.d.ts +1 -1
  95. package/dist/core/src/engine/MinimalContext.d.ts +4 -2
  96. package/dist/core/src/engine/types.d.ts +6 -1
  97. package/dist/core/src/events/CircuitBreaker.d.ts +229 -0
  98. package/dist/core/src/events/DeadLetterQueue.d.ts +145 -0
  99. package/dist/core/src/events/EventBackend.d.ts +11 -0
  100. package/dist/core/src/events/EventOptions.d.ts +109 -0
  101. package/dist/core/src/events/EventPriorityQueue.d.ts +202 -0
  102. package/dist/core/src/events/IdempotencyCache.d.ts +60 -0
  103. package/dist/core/src/events/index.d.ts +14 -0
  104. package/dist/core/src/events/observability/EventMetrics.d.ts +132 -0
  105. package/dist/core/src/events/observability/EventTracer.d.ts +68 -0
  106. package/dist/core/src/events/observability/EventTracing.d.ts +161 -0
  107. package/dist/core/src/events/observability/OTelEventMetrics.d.ts +240 -0
  108. package/dist/core/src/events/observability/ObservableHookManager.d.ts +108 -0
  109. package/dist/core/src/events/observability/index.d.ts +20 -0
  110. package/dist/core/src/events/observability/metrics-types.d.ts +16 -0
  111. package/dist/core/src/events/types.d.ts +75 -0
  112. package/dist/core/src/exceptions/CircularDependencyException.d.ts +9 -0
  113. package/dist/core/src/exceptions/index.d.ts +1 -0
  114. package/dist/core/src/http/cookie.d.ts +29 -0
  115. package/dist/core/src/http/types.d.ts +21 -0
  116. package/dist/core/src/index.d.ts +13 -3
  117. package/dist/core/src/instrumentation/index.d.ts +35 -0
  118. package/dist/core/src/instrumentation/opentelemetry.d.ts +178 -0
  119. package/dist/core/src/instrumentation/types.d.ts +182 -0
  120. package/dist/core/src/reliability/DeadLetterQueueManager.d.ts +316 -0
  121. package/dist/core/src/reliability/RetryPolicy.d.ts +217 -0
  122. package/dist/core/src/reliability/index.d.ts +6 -0
  123. package/dist/core/src/router/ControllerDispatcher.d.ts +12 -0
  124. package/dist/core/src/router/RequestValidator.d.ts +20 -0
  125. package/dist/index.js +6487 -9562
  126. package/dist/index.js.map +68 -62
  127. package/dist/photon/src/index.d.ts +69 -5
  128. package/dist/photon/src/middleware/binary.d.ts +12 -15
  129. package/dist/photon/src/middleware/htmx.d.ts +39 -0
  130. package/dist/photon/src/middleware/ratelimit.d.ts +157 -0
  131. package/dist/photon/src/openapi.d.ts +19 -0
  132. package/dist/proto/ripple.proto +120 -0
  133. package/dist/ripple/src/OrbitRipple.d.ts +34 -12
  134. package/dist/ripple/src/RippleServer.d.ts +76 -63
  135. package/dist/ripple/src/channels/ChannelManager.d.ts +132 -22
  136. package/dist/ripple/src/drivers/LocalDriver.d.ts +43 -11
  137. package/dist/ripple/src/drivers/NATSDriver.d.ts +87 -0
  138. package/dist/ripple/src/drivers/RedisDriver.d.ts +135 -28
  139. package/dist/ripple/src/drivers/index.d.ts +1 -0
  140. package/dist/ripple/src/engines/BunEngine.d.ts +98 -0
  141. package/dist/ripple/src/engines/IRippleEngine.d.ts +205 -0
  142. package/dist/ripple/src/engines/index.d.ts +11 -0
  143. package/dist/ripple/src/errors/RippleError.d.ts +48 -0
  144. package/dist/ripple/src/errors/index.d.ts +1 -0
  145. package/dist/ripple/src/events/BroadcastEvent.d.ts +78 -6
  146. package/dist/ripple/src/events/BroadcastManager.d.ts +100 -0
  147. package/dist/ripple/src/events/Broadcaster.d.ts +211 -14
  148. package/dist/ripple/src/events/index.d.ts +1 -0
  149. package/dist/ripple/src/health/HealthChecker.d.ts +93 -0
  150. package/dist/ripple/src/health/index.d.ts +1 -0
  151. package/dist/ripple/src/index.d.ts +42 -17
  152. package/dist/ripple/src/logging/Logger.d.ts +99 -0
  153. package/dist/ripple/src/logging/index.d.ts +1 -0
  154. package/dist/ripple/src/middleware/InterceptorManager.d.ts +21 -0
  155. package/dist/ripple/src/observability/RippleMetrics.d.ts +24 -0
  156. package/dist/ripple/src/reliability/AckManager.d.ts +48 -0
  157. package/dist/ripple/src/serializers/ISerializer.d.ts +39 -0
  158. package/dist/ripple/src/serializers/JsonSerializer.d.ts +19 -0
  159. package/dist/ripple/src/serializers/ProtobufSerializer.d.ts +38 -0
  160. package/dist/ripple/src/serializers/index.d.ts +3 -0
  161. package/dist/ripple/src/tracking/ConnectionTracker.d.ts +116 -0
  162. package/dist/ripple/src/tracking/SessionManager.d.ts +104 -0
  163. package/dist/ripple/src/tracking/index.d.ts +2 -0
  164. package/dist/ripple/src/types.d.ts +766 -28
  165. package/dist/ripple/src/utils/MessageSerializer.d.ts +54 -0
  166. package/dist/ripple/src/utils/TokenBucket.d.ts +25 -0
  167. package/dist/ripple/src/utils/index.d.ts +1 -0
  168. package/package.json +25 -7
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Migration Interface
3
+ * @description Contract for database migration classes
4
+ */
5
+ /**
6
+ * Migration Interface
7
+ *
8
+ * All database migration classes must implement this interface.
9
+ * The `up` method is used to apply changes (e.g., create tables),
10
+ * while the `down` method is used to reverse those changes.
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * import { Migration, Schema } from '@gravito/atlas'
15
+ *
16
+ * export default class CreateUsersTable implements Migration {
17
+ * async up(): Promise<void> {
18
+ * await Schema.create('users', (table) => {
19
+ * table.id()
20
+ * table.string('email').unique()
21
+ * table.timestamps()
22
+ * })
23
+ * }
24
+ *
25
+ * async down(): Promise<void> {
26
+ * await Schema.dropIfExists('users')
27
+ * }
28
+ * }
29
+ * ```
30
+ */
31
+ export interface Migration {
32
+ /**
33
+ * Run the migration (create tables, add columns, etc.)
34
+ */
35
+ up(): Promise<void>;
36
+ /**
37
+ * Reverse the migration (drop tables, remove columns, etc.)
38
+ */
39
+ down(): Promise<void>;
40
+ }
41
+ /**
42
+ * Migration constructor type
43
+ */
44
+ export type MigrationConstructor = new () => Migration;
45
+ /**
46
+ * Migration record stored in the database
47
+ */
48
+ export interface MigrationRecord {
49
+ /** Migration ID */
50
+ id: number;
51
+ /** Migration file name (without path) */
52
+ migration: string;
53
+ /** Batch number when the migration was run */
54
+ batch: number;
55
+ }
56
+ /**
57
+ * Migration file info
58
+ */
59
+ export interface MigrationFile {
60
+ /** Migration file name (without path) */
61
+ name: string;
62
+ /** Full file path */
63
+ path: string;
64
+ }
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Migration Repository
3
+ * @description Tracks migration execution state in the database
4
+ */
5
+ import type { MigrationRecord } from './Migration';
6
+ /**
7
+ * Migration Repository
8
+ *
9
+ * The MigrationRepository class manages the database table that tracks
10
+ * which migrations have been executed. It provides methods for logging
11
+ * migrations, retrieving the list of ran migrations, and managing batches.
12
+ */
13
+ export declare class MigrationRepository {
14
+ private tableName;
15
+ private connectionName;
16
+ constructor(connectionName?: string);
17
+ /**
18
+ * Set the table name for migrations
19
+ */
20
+ setTable(table: string): this;
21
+ /**
22
+ * Create the migration repository table if it doesn't exist
23
+ */
24
+ createRepository(): Promise<void>;
25
+ /**
26
+ * Check if the migration repository exists
27
+ */
28
+ repositoryExists(): Promise<boolean>;
29
+ /**
30
+ * Delete the migration repository table
31
+ */
32
+ deleteRepository(): Promise<void>;
33
+ /**
34
+ * Get all ran migrations
35
+ */
36
+ getRan(): Promise<string[]>;
37
+ /**
38
+ * Get migrations for a specific batch
39
+ */
40
+ getMigrations(batch: number): Promise<MigrationRecord[]>;
41
+ /**
42
+ * Get the last batch number
43
+ */
44
+ getLastBatchNumber(): Promise<number>;
45
+ /**
46
+ * Get the next batch number
47
+ */
48
+ getNextBatchNumber(): Promise<number>;
49
+ /**
50
+ * Log that a migration was run
51
+ */
52
+ log(migration: string, batch: number): Promise<void>;
53
+ /**
54
+ * Remove a migration from the log
55
+ */
56
+ delete(migration: string): Promise<void>;
57
+ /**
58
+ * Get the last migrations (for rollback)
59
+ */
60
+ getLast(): Promise<MigrationRecord[]>;
61
+ /**
62
+ * Get the database connection
63
+ */
64
+ private getConnection;
65
+ }
@@ -0,0 +1,110 @@
1
+ /**
2
+ * Migrator
3
+ * @description Migration runner with support for running and rolling back migrations
4
+ */
5
+ /**
6
+ * Migrator Options
7
+ */
8
+ export interface MigratorOptions {
9
+ /** Path to migrations directory */
10
+ path?: string;
11
+ /** Database connection name */
12
+ connection?: string;
13
+ /** Migration table name */
14
+ table?: string;
15
+ }
16
+ /**
17
+ * Migration Result
18
+ */
19
+ export interface MigrationResult {
20
+ /** Migrations that were run */
21
+ migrations: string[];
22
+ /** Batch number */
23
+ batch?: number;
24
+ }
25
+ /**
26
+ * Migrator
27
+ *
28
+ * The Migrator class is responsible for managing the database migration lifecycle.
29
+ * It handles discovering migration files, tracking which migrations have been run
30
+ * in the database, and executing the `up` or `down` methods of migration classes.
31
+ *
32
+ * @example
33
+ * ```typescript
34
+ * const migrator = new Migrator({ path: './migrations' })
35
+ *
36
+ * // Run all pending migrations
37
+ * await migrator.run()
38
+ *
39
+ * // Rollback the last batch of migrations
40
+ * await migrator.rollback()
41
+ * ```
42
+ */
43
+ export declare class Migrator {
44
+ private repository;
45
+ private migrationsPath;
46
+ private resolvedMigrations;
47
+ constructor(options?: MigratorOptions);
48
+ /**
49
+ * Set migrations path
50
+ */
51
+ setPath(path: string): this;
52
+ /**
53
+ * Set database connection
54
+ */
55
+ connection(name: string): this;
56
+ /**
57
+ * Run all pending migrations.
58
+ *
59
+ * This method will identify all migration files that have not yet been
60
+ * recorded in the migrations table and execute their `up` method.
61
+ *
62
+ * @returns A promise that resolves to the migration result.
63
+ */
64
+ run(): Promise<MigrationResult>;
65
+ /**
66
+ * Run a specific migration up
67
+ */
68
+ runUp(migrationName: string): Promise<void>;
69
+ /**
70
+ * Rollback the last batch of migrations.
71
+ *
72
+ * This method will identify the migrations that were part of the last
73
+ * execution batch and execute their `down` method.
74
+ *
75
+ * @param steps The number of batches to rollback (defaults to 1).
76
+ * @returns A promise that resolves to the migration result.
77
+ */
78
+ rollback(steps?: number): Promise<MigrationResult>;
79
+ /**
80
+ * Rollback all migrations
81
+ */
82
+ reset(): Promise<MigrationResult>;
83
+ /**
84
+ * Reset and re-run all migrations
85
+ */
86
+ fresh(): Promise<MigrationResult>;
87
+ /**
88
+ * Rollback and re-run the last batch
89
+ */
90
+ refresh(steps?: number): Promise<MigrationResult>;
91
+ /**
92
+ * Get migration status
93
+ */
94
+ status(): Promise<{
95
+ ran: string[];
96
+ pending: string[];
97
+ }>;
98
+ /**
99
+ * Get all migration files from the migrations directory
100
+ */
101
+ private getMigrationFiles;
102
+ /**
103
+ * Run a single migration
104
+ */
105
+ private runMigration;
106
+ /**
107
+ * Resolve migration class from file
108
+ */
109
+ private resolveMigration;
110
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Migration Module Index
3
+ */
4
+ export type { Migration, MigrationConstructor, MigrationFile, MigrationRecord } from './Migration';
5
+ export { MigrationRepository } from './MigrationRepository';
6
+ export { type MigrationResult, Migrator, type MigratorOptions } from './Migrator';
@@ -0,0 +1,11 @@
1
+ import { type Counter, type Histogram } from '@opentelemetry/api';
2
+ export interface AtlasMetricsConfig {
3
+ enabled: boolean;
4
+ }
5
+ export declare class AtlasMetrics {
6
+ private meter;
7
+ private config;
8
+ readonly operationDuration?: Histogram;
9
+ readonly operationErrors?: Counter;
10
+ constructor(config: AtlasMetricsConfig);
11
+ }
@@ -0,0 +1,15 @@
1
+ import { AtlasMetrics, type AtlasMetricsConfig } from './AtlasMetrics';
2
+ import { AtlasTracer, type AtlasTracingConfig } from './AtlasTracer';
3
+ export declare class AtlasObservability {
4
+ private static instance;
5
+ tracer?: AtlasTracer;
6
+ metrics?: AtlasMetrics;
7
+ private constructor();
8
+ static getInstance(): AtlasObservability;
9
+ initialize(config: {
10
+ tracing?: AtlasTracingConfig;
11
+ metrics?: AtlasMetricsConfig;
12
+ }): void;
13
+ static getTracer(): AtlasTracer | undefined;
14
+ static getMetrics(): AtlasMetrics | undefined;
15
+ }
@@ -0,0 +1,12 @@
1
+ import { type Context, type Span } from '@opentelemetry/api';
2
+ export interface AtlasTracingConfig {
3
+ enabled: boolean;
4
+ serviceName?: string;
5
+ }
6
+ export declare class AtlasTracer {
7
+ private tracer;
8
+ private config;
9
+ constructor(config: AtlasTracingConfig);
10
+ startSpan(name: string, attributes?: Record<string, any>): Span | undefined;
11
+ getActiveContext(): Context;
12
+ }
@@ -0,0 +1,9 @@
1
+ export * from './AtlasMetrics';
2
+ export * from './AtlasObservability';
3
+ export * from './AtlasTracer';
4
+ export interface AtlasObservabilityConfig {
5
+ enabled: boolean;
6
+ tracing?: boolean;
7
+ metrics?: boolean;
8
+ serviceName?: string;
9
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * ORM Module Index
3
+ */
4
+ export * from './model';
5
+ export * from './schema';
@@ -0,0 +1,121 @@
1
+ /**
2
+ * Dirty Tracker for monitoring attribute modifications on model instances.
3
+ *
4
+ * Maintains a snapshot of original values and tracks which keys have been
5
+ * changed. Supports optimized structural comparison and deep change detection
6
+ * for complex objects.
7
+ *
8
+ * @template T - The shape of the model attributes.
9
+ */
10
+ export declare class DirtyTracker<T extends Record<string, unknown>> {
11
+ /**
12
+ * Stores the initial values as retrieved from the database.
13
+ */
14
+ private original;
15
+ /**
16
+ * Tracks keys that differ from their original state.
17
+ */
18
+ private dirty;
19
+ /**
20
+ * When enabled, nested objects are compared recursively.
21
+ */
22
+ private useDeepComparison;
23
+ /**
24
+ * Configures the comparison strategy for nested structures.
25
+ *
26
+ * @param enabled - True to enable recursive comparison.
27
+ */
28
+ setDeepComparison(enabled: boolean): void;
29
+ /**
30
+ * Records initial state and clears the dirty set.
31
+ *
32
+ * Called typically during hydration or after a successful save.
33
+ *
34
+ * @param data - The baseline values.
35
+ */
36
+ setOriginal(data: Partial<T>): void;
37
+ /**
38
+ * Checks for changes and updates the dirty set accordingly.
39
+ *
40
+ * Compares the new value against the original. If they match, the key
41
+ * is removed from the dirty set (reversion).
42
+ *
43
+ * @param key - The attribute name.
44
+ * @param newValue - The proposed new value.
45
+ */
46
+ mark(key: keyof T, newValue: unknown): void;
47
+ /**
48
+ * Indicates if any attributes or a specific attribute has been modified.
49
+ *
50
+ * @param key - Optional specific attribute to check.
51
+ * @returns True if changes are detected.
52
+ */
53
+ isDirty(key?: keyof T): boolean;
54
+ /**
55
+ * Returns a list of all modified attribute names.
56
+ */
57
+ getDirty(): Array<keyof T>;
58
+ /**
59
+ * Extracts current values for all dirty attributes.
60
+ *
61
+ * @param current - The source object containing all current values.
62
+ * @returns An object with only the modified entries.
63
+ */
64
+ getDirtyValues(current: Partial<T>): Partial<T>;
65
+ /**
66
+ * Retrieves the original value of an attribute from the snapshot.
67
+ */
68
+ getOriginal(key: keyof T): unknown;
69
+ /**
70
+ * Retrieves the complete original snapshot.
71
+ */
72
+ getOriginals(): Partial<T>;
73
+ /**
74
+ * Synchronizes the snapshot with the current state.
75
+ *
76
+ * @param data - The new baseline data.
77
+ */
78
+ sync(data: Partial<T>): void;
79
+ /**
80
+ * Reverts the dirty flag for a specific attribute.
81
+ */
82
+ reset(key: keyof T): void;
83
+ /**
84
+ * Clears all tracking information.
85
+ */
86
+ resetAll(): void;
87
+ /**
88
+ * Compares two values for equality using optimized structural comparison.
89
+ *
90
+ * Performs shallow comparison by default. Avoids JSON.stringify overhead
91
+ * by using recursive structural comparison for arrays, maps, and sets.
92
+ *
93
+ * @param a - First value.
94
+ * @param b - Second value.
95
+ * @returns True if equal.
96
+ * @internal
97
+ */
98
+ private isEqual;
99
+ /**
100
+ * Performs deep equality comparison with cycle detection.
101
+ *
102
+ * @param a - First value.
103
+ * @param b - Second value.
104
+ * @param visited - Set tracking visited objects.
105
+ * @returns True if deeply equal.
106
+ * @internal
107
+ */
108
+ private deepEqual;
109
+ /**
110
+ * Clones a value to ensure the original snapshot remains immutable.
111
+ *
112
+ * @param value - Value to clone.
113
+ * @internal
114
+ */
115
+ private cloneValue;
116
+ /**
117
+ * Performs recursive deep cloning.
118
+ * @internal
119
+ */
120
+ private deepClone;
121
+ }