@gravito/echo 3.0.0 → 3.1.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/README.md +211 -0
- package/dist/atlas/src/DB.d.ts +301 -0
- package/dist/atlas/src/OrbitAtlas.d.ts +9 -0
- package/dist/atlas/src/config/defineConfig.d.ts +14 -0
- package/dist/atlas/src/config/index.d.ts +7 -0
- package/dist/atlas/src/config/loadConfig.d.ts +48 -0
- package/dist/atlas/src/connection/Connection.d.ts +108 -0
- package/dist/atlas/src/connection/ConnectionManager.d.ts +111 -0
- package/dist/atlas/src/drivers/BunSQLDriver.d.ts +32 -0
- package/dist/atlas/src/drivers/BunSQLPreparedStatement.d.ts +118 -0
- package/dist/atlas/src/drivers/MongoDBDriver.d.ts +36 -0
- package/dist/atlas/src/drivers/MySQLDriver.d.ts +66 -0
- package/dist/atlas/src/drivers/PostgresDriver.d.ts +83 -0
- package/dist/atlas/src/drivers/RedisDriver.d.ts +43 -0
- package/dist/atlas/src/drivers/SQLiteDriver.d.ts +45 -0
- package/dist/atlas/src/drivers/types.d.ts +260 -0
- package/dist/atlas/src/errors/index.d.ts +45 -0
- package/dist/atlas/src/grammar/Grammar.d.ts +342 -0
- package/dist/atlas/src/grammar/MongoGrammar.d.ts +47 -0
- package/dist/atlas/src/grammar/MySQLGrammar.d.ts +54 -0
- package/dist/atlas/src/grammar/NullGrammar.d.ts +35 -0
- package/dist/atlas/src/grammar/PostgresGrammar.d.ts +62 -0
- package/dist/atlas/src/grammar/SQLiteGrammar.d.ts +32 -0
- package/dist/atlas/src/index.d.ts +67 -0
- package/dist/atlas/src/migration/Migration.d.ts +64 -0
- package/dist/atlas/src/migration/MigrationRepository.d.ts +65 -0
- package/dist/atlas/src/migration/Migrator.d.ts +110 -0
- package/dist/atlas/src/migration/index.d.ts +6 -0
- package/dist/atlas/src/observability/AtlasMetrics.d.ts +11 -0
- package/dist/atlas/src/observability/AtlasObservability.d.ts +15 -0
- package/dist/atlas/src/observability/AtlasTracer.d.ts +12 -0
- package/dist/atlas/src/observability/index.d.ts +9 -0
- package/dist/atlas/src/orm/index.d.ts +5 -0
- package/dist/atlas/src/orm/model/DirtyTracker.d.ts +121 -0
- package/dist/atlas/src/orm/model/Model.d.ts +449 -0
- package/dist/atlas/src/orm/model/ModelRegistry.d.ts +20 -0
- package/dist/atlas/src/orm/model/concerns/HasAttributes.d.ts +136 -0
- package/dist/atlas/src/orm/model/concerns/HasEvents.d.ts +36 -0
- package/dist/atlas/src/orm/model/concerns/HasPersistence.d.ts +87 -0
- package/dist/atlas/src/orm/model/concerns/HasRelationships.d.ts +117 -0
- package/dist/atlas/src/orm/model/concerns/HasSerialization.d.ts +64 -0
- package/dist/atlas/src/orm/model/concerns/applyMixins.d.ts +15 -0
- package/dist/atlas/src/orm/model/concerns/index.d.ts +12 -0
- package/dist/atlas/src/orm/model/decorators.d.ts +109 -0
- package/dist/atlas/src/orm/model/errors.d.ts +52 -0
- package/dist/atlas/src/orm/model/index.d.ts +10 -0
- package/dist/atlas/src/orm/model/relationships.d.ts +207 -0
- package/dist/atlas/src/orm/model/types.d.ts +12 -0
- package/dist/atlas/src/orm/schema/SchemaRegistry.d.ts +123 -0
- package/dist/atlas/src/orm/schema/SchemaSniffer.d.ts +54 -0
- package/dist/atlas/src/orm/schema/index.d.ts +6 -0
- package/dist/atlas/src/orm/schema/types.d.ts +85 -0
- package/dist/atlas/src/query/Expression.d.ts +60 -0
- package/dist/atlas/src/query/NPlusOneDetector.d.ts +10 -0
- package/dist/atlas/src/query/QueryBuilder.d.ts +573 -0
- package/dist/atlas/src/query/clauses/GroupByClause.d.ts +51 -0
- package/dist/atlas/src/query/clauses/HavingClause.d.ts +70 -0
- package/dist/atlas/src/query/clauses/JoinClause.d.ts +87 -0
- package/dist/atlas/src/query/clauses/LimitClause.d.ts +82 -0
- package/dist/atlas/src/query/clauses/OrderByClause.d.ts +69 -0
- package/dist/atlas/src/query/clauses/SelectClause.d.ts +71 -0
- package/dist/atlas/src/query/clauses/WhereClause.d.ts +167 -0
- package/dist/atlas/src/query/clauses/index.d.ts +11 -0
- package/dist/atlas/src/schema/Blueprint.d.ts +276 -0
- package/dist/atlas/src/schema/ColumnDefinition.d.ts +154 -0
- package/dist/atlas/src/schema/ForeignKeyDefinition.d.ts +37 -0
- package/dist/atlas/src/schema/Schema.d.ts +131 -0
- package/dist/atlas/src/schema/grammars/MySQLSchemaGrammar.d.ts +23 -0
- package/dist/atlas/src/schema/grammars/PostgresSchemaGrammar.d.ts +26 -0
- package/dist/atlas/src/schema/grammars/SQLiteSchemaGrammar.d.ts +28 -0
- package/dist/atlas/src/schema/grammars/SchemaGrammar.d.ts +97 -0
- package/dist/atlas/src/schema/grammars/index.d.ts +7 -0
- package/dist/atlas/src/schema/index.d.ts +8 -0
- package/dist/atlas/src/seed/Factory.d.ts +90 -0
- package/dist/atlas/src/seed/Seeder.d.ts +28 -0
- package/dist/atlas/src/seed/SeederRunner.d.ts +74 -0
- package/dist/atlas/src/seed/index.d.ts +6 -0
- package/dist/atlas/src/types/index.d.ts +1100 -0
- package/dist/atlas/src/utils/levenshtein.d.ts +9 -0
- package/dist/core/src/Application.d.ts +215 -0
- package/dist/core/src/CommandKernel.d.ts +33 -0
- package/dist/core/src/ConfigManager.d.ts +26 -0
- package/dist/core/src/Container.d.ts +108 -0
- package/dist/core/src/ErrorHandler.d.ts +63 -0
- package/dist/core/src/Event.d.ts +5 -0
- package/dist/core/src/EventManager.d.ts +123 -0
- package/dist/core/src/GlobalErrorHandlers.d.ts +47 -0
- package/dist/core/src/GravitoServer.d.ts +28 -0
- package/dist/core/src/HookManager.d.ts +496 -0
- package/dist/core/src/Listener.d.ts +4 -0
- package/dist/core/src/Logger.d.ts +20 -0
- package/dist/core/src/PlanetCore.d.ts +289 -0
- package/dist/core/src/Route.d.ts +36 -0
- package/dist/core/src/Router.d.ts +284 -0
- package/dist/core/src/ServiceProvider.d.ts +156 -0
- package/dist/core/src/adapters/GravitoEngineAdapter.d.ts +27 -0
- package/dist/core/src/adapters/PhotonAdapter.d.ts +171 -0
- package/dist/core/src/adapters/bun/BunContext.d.ts +45 -0
- package/dist/core/src/adapters/bun/BunNativeAdapter.d.ts +31 -0
- package/dist/core/src/adapters/bun/BunRequest.d.ts +31 -0
- package/dist/core/src/adapters/bun/RadixNode.d.ts +19 -0
- package/dist/core/src/adapters/bun/RadixRouter.d.ts +31 -0
- package/dist/core/src/adapters/bun/types.d.ts +20 -0
- package/dist/core/src/adapters/photon-types.d.ts +73 -0
- package/dist/core/src/adapters/types.d.ts +235 -0
- package/dist/core/src/engine/AOTRouter.d.ts +124 -0
- package/dist/core/src/engine/FastContext.d.ts +100 -0
- package/dist/core/src/engine/Gravito.d.ts +137 -0
- package/dist/core/src/engine/MinimalContext.d.ts +79 -0
- package/dist/core/src/engine/analyzer.d.ts +27 -0
- package/dist/core/src/engine/constants.d.ts +23 -0
- package/dist/core/src/engine/index.d.ts +26 -0
- package/dist/core/src/engine/path.d.ts +26 -0
- package/dist/core/src/engine/pool.d.ts +83 -0
- package/dist/core/src/engine/types.d.ts +143 -0
- package/dist/core/src/events/CircuitBreaker.d.ts +229 -0
- package/dist/core/src/events/DeadLetterQueue.d.ts +145 -0
- package/dist/core/src/events/EventBackend.d.ts +11 -0
- package/dist/core/src/events/EventOptions.d.ts +109 -0
- package/dist/core/src/events/EventPriorityQueue.d.ts +202 -0
- package/dist/core/src/events/IdempotencyCache.d.ts +60 -0
- package/dist/core/src/events/index.d.ts +14 -0
- package/dist/core/src/events/observability/EventMetrics.d.ts +132 -0
- package/dist/core/src/events/observability/EventTracer.d.ts +68 -0
- package/dist/core/src/events/observability/EventTracing.d.ts +161 -0
- package/dist/core/src/events/observability/OTelEventMetrics.d.ts +240 -0
- package/dist/core/src/events/observability/ObservableHookManager.d.ts +108 -0
- package/dist/core/src/events/observability/index.d.ts +20 -0
- package/dist/core/src/events/observability/metrics-types.d.ts +16 -0
- package/dist/core/src/events/types.d.ts +75 -0
- package/dist/core/src/exceptions/AuthenticationException.d.ts +8 -0
- package/dist/core/src/exceptions/AuthorizationException.d.ts +8 -0
- package/dist/core/src/exceptions/CircularDependencyException.d.ts +9 -0
- package/dist/core/src/exceptions/GravitoException.d.ts +23 -0
- package/dist/core/src/exceptions/HttpException.d.ts +9 -0
- package/dist/core/src/exceptions/ModelNotFoundException.d.ts +10 -0
- package/dist/core/src/exceptions/ValidationException.d.ts +22 -0
- package/dist/core/src/exceptions/index.d.ts +7 -0
- package/dist/core/src/helpers/Arr.d.ts +19 -0
- package/dist/core/src/helpers/Str.d.ts +23 -0
- package/dist/core/src/helpers/data.d.ts +25 -0
- package/dist/core/src/helpers/errors.d.ts +34 -0
- package/dist/core/src/helpers/response.d.ts +41 -0
- package/dist/core/src/helpers.d.ts +338 -0
- package/dist/core/src/http/CookieJar.d.ts +51 -0
- package/dist/core/src/http/cookie.d.ts +29 -0
- package/dist/core/src/http/middleware/BodySizeLimit.d.ts +16 -0
- package/dist/core/src/http/middleware/Cors.d.ts +24 -0
- package/dist/core/src/http/middleware/Csrf.d.ts +23 -0
- package/dist/core/src/http/middleware/HeaderTokenGate.d.ts +28 -0
- package/dist/core/src/http/middleware/SecurityHeaders.d.ts +29 -0
- package/dist/core/src/http/middleware/ThrottleRequests.d.ts +18 -0
- package/dist/core/src/http/types.d.ts +355 -0
- package/dist/core/src/index.d.ts +76 -0
- package/dist/core/src/instrumentation/index.d.ts +35 -0
- package/dist/core/src/instrumentation/opentelemetry.d.ts +178 -0
- package/dist/core/src/instrumentation/types.d.ts +182 -0
- package/dist/core/src/reliability/DeadLetterQueueManager.d.ts +316 -0
- package/dist/core/src/reliability/RetryPolicy.d.ts +217 -0
- package/dist/core/src/reliability/index.d.ts +6 -0
- package/dist/core/src/router/ControllerDispatcher.d.ts +12 -0
- package/dist/core/src/router/RequestValidator.d.ts +20 -0
- package/dist/core/src/runtime.d.ts +119 -0
- package/dist/core/src/security/Encrypter.d.ts +33 -0
- package/dist/core/src/security/Hasher.d.ts +29 -0
- package/dist/core/src/testing/HttpTester.d.ts +39 -0
- package/dist/core/src/testing/TestResponse.d.ts +78 -0
- package/dist/core/src/testing/index.d.ts +2 -0
- package/dist/core/src/types/events.d.ts +94 -0
- package/dist/echo/src/OrbitEcho.d.ts +115 -0
- package/dist/echo/src/dlq/DeadLetterQueue.d.ts +94 -0
- package/dist/echo/src/dlq/MemoryDeadLetterQueue.d.ts +36 -0
- package/dist/echo/src/dlq/index.d.ts +2 -0
- package/dist/echo/src/index.d.ts +64 -0
- package/dist/echo/src/middleware/RequestBufferMiddleware.d.ts +62 -0
- package/dist/echo/src/middleware/index.d.ts +8 -0
- package/dist/echo/src/observability/index.d.ts +3 -0
- package/dist/echo/src/observability/logging/ConsoleEchoLogger.d.ts +37 -0
- package/dist/echo/src/observability/logging/EchoLogger.d.ts +38 -0
- package/dist/echo/src/observability/logging/index.d.ts +2 -0
- package/dist/echo/src/observability/metrics/MetricsProvider.d.ts +69 -0
- package/dist/echo/src/observability/metrics/NoopMetricsProvider.d.ts +17 -0
- package/dist/echo/src/observability/metrics/PrometheusMetricsProvider.d.ts +39 -0
- package/dist/echo/src/observability/metrics/index.d.ts +3 -0
- package/dist/echo/src/observability/tracing/NoopTracer.d.ts +33 -0
- package/dist/echo/src/observability/tracing/Tracer.d.ts +75 -0
- package/dist/echo/src/observability/tracing/index.d.ts +2 -0
- package/dist/echo/src/providers/GenericProvider.d.ts +53 -0
- package/dist/echo/src/providers/GitHubProvider.d.ts +35 -0
- package/dist/echo/src/providers/LinearProvider.d.ts +27 -0
- package/dist/echo/src/providers/PaddleProvider.d.ts +31 -0
- package/dist/echo/src/providers/ShopifyProvider.d.ts +27 -0
- package/dist/echo/src/providers/SlackProvider.d.ts +27 -0
- package/dist/echo/src/providers/StripeProvider.d.ts +38 -0
- package/dist/echo/src/providers/TwilioProvider.d.ts +31 -0
- package/dist/echo/src/providers/base/BaseProvider.d.ts +87 -0
- package/dist/echo/src/providers/base/HeaderUtils.d.ts +34 -0
- package/dist/echo/src/providers/index.d.ts +14 -0
- package/dist/echo/src/receive/SignatureValidator.d.ts +67 -0
- package/dist/echo/src/receive/WebhookReceiver.d.ts +185 -0
- package/dist/echo/src/receive/index.d.ts +2 -0
- package/dist/echo/src/replay/WebhookReplayService.d.ts +35 -0
- package/dist/echo/src/replay/index.d.ts +1 -0
- package/dist/echo/src/resilience/CircuitBreaker.d.ts +117 -0
- package/dist/echo/src/resilience/index.d.ts +10 -0
- package/dist/echo/src/rotation/KeyRotationManager.d.ts +127 -0
- package/dist/echo/src/rotation/index.d.ts +10 -0
- package/dist/echo/src/send/WebhookDispatcher.d.ts +198 -0
- package/dist/echo/src/send/index.d.ts +1 -0
- package/dist/echo/src/storage/MemoryWebhookStore.d.ts +14 -0
- package/dist/echo/src/storage/WebhookStore.d.ts +236 -0
- package/dist/echo/src/storage/index.d.ts +2 -0
- package/dist/echo/src/types.d.ts +756 -0
- package/dist/index.js +1332 -190
- package/dist/index.js.map +28 -10
- package/dist/photon/src/index.d.ts +84 -0
- package/dist/photon/src/middleware/binary.d.ts +31 -0
- package/dist/photon/src/middleware/htmx.d.ts +39 -0
- package/dist/photon/src/middleware/ratelimit.d.ts +157 -0
- package/dist/photon/src/openapi.d.ts +19 -0
- package/package.json +7 -5
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MySQL Grammar
|
|
3
|
+
* @description SQL grammar implementation for MySQL/MariaDB
|
|
4
|
+
*/
|
|
5
|
+
import type { CompiledQuery } from '../types';
|
|
6
|
+
import { Grammar } from './Grammar';
|
|
7
|
+
/**
|
|
8
|
+
* MySQL Grammar
|
|
9
|
+
* Implements MySQL/MariaDB-specific SQL syntax
|
|
10
|
+
*/
|
|
11
|
+
export declare class MySQLGrammar extends Grammar {
|
|
12
|
+
/**
|
|
13
|
+
* MySQL uses backticks for identifiers
|
|
14
|
+
*/
|
|
15
|
+
protected wrapChar: string;
|
|
16
|
+
/**
|
|
17
|
+
* Get placeholder for MySQL (?)
|
|
18
|
+
*/
|
|
19
|
+
getPlaceholder(_index: number): string;
|
|
20
|
+
/**
|
|
21
|
+
* Compile INSERT and return ID using LAST_INSERT_ID()
|
|
22
|
+
*/
|
|
23
|
+
compileInsertGetId(query: CompiledQuery, values: Record<string, unknown>, _primaryKey: string): string;
|
|
24
|
+
/**
|
|
25
|
+
* Compile TRUNCATE for MySQL
|
|
26
|
+
*/
|
|
27
|
+
compileTruncate(query: CompiledQuery): string;
|
|
28
|
+
/**
|
|
29
|
+
* MySQL-specific: Compile UPSERT using ON DUPLICATE KEY UPDATE
|
|
30
|
+
*/
|
|
31
|
+
compileUpsert(query: CompiledQuery, values: Record<string, unknown>[], _uniqueBy: string[], update: string[]): string;
|
|
32
|
+
/**
|
|
33
|
+
* MySQL-specific: Compile locking clause
|
|
34
|
+
*/
|
|
35
|
+
compileLock(mode: 'update' | 'share'): string;
|
|
36
|
+
/**
|
|
37
|
+
* Override offset placeholders - MySQL uses ? for all
|
|
38
|
+
*/
|
|
39
|
+
protected offsetPlaceholders(sql: string, _offset: number): string;
|
|
40
|
+
/**
|
|
41
|
+
* Compile EXISTS with MySQL syntax
|
|
42
|
+
*/
|
|
43
|
+
compileExists(query: CompiledQuery): string;
|
|
44
|
+
/**
|
|
45
|
+
* Override aggregate to use backticks
|
|
46
|
+
*/
|
|
47
|
+
compileAggregate(query: CompiledQuery, aggregate: {
|
|
48
|
+
function: string;
|
|
49
|
+
column: string;
|
|
50
|
+
}): string;
|
|
51
|
+
compileJsonPath(column: string, _value: unknown): string;
|
|
52
|
+
compileJsonContains(column: string, _value: unknown): string;
|
|
53
|
+
compileUpdateJson(query: CompiledQuery, column: string, _value: unknown): string;
|
|
54
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Null Grammar
|
|
3
|
+
* @description A fallback grammar for non-SQL drivers
|
|
4
|
+
*/
|
|
5
|
+
import type { CompiledQuery, GrammarContract } from '../types';
|
|
6
|
+
/**
|
|
7
|
+
* Null Grammar
|
|
8
|
+
* Used for MongoDB, Redis, etc. where SQL compilation is not needed.
|
|
9
|
+
*/
|
|
10
|
+
export declare class NullGrammar implements GrammarContract {
|
|
11
|
+
compileSelect(_query: CompiledQuery): string;
|
|
12
|
+
compileInsert(_query: CompiledQuery, _values: Record<string, unknown>[]): string;
|
|
13
|
+
compileInsertGetId(_query: CompiledQuery, _values: Record<string, unknown>, _primaryKey: string): string;
|
|
14
|
+
compileUpdate(_query: CompiledQuery, _values: Record<string, unknown>): string;
|
|
15
|
+
compileDelete(_query: CompiledQuery): string;
|
|
16
|
+
compileTruncate(_query: CompiledQuery): string;
|
|
17
|
+
compileAggregate(_query: CompiledQuery, _aggregate: {
|
|
18
|
+
function: string;
|
|
19
|
+
column: string;
|
|
20
|
+
}): string;
|
|
21
|
+
compileExists(_query: CompiledQuery): string;
|
|
22
|
+
getPlaceholder(_index: number): string;
|
|
23
|
+
wrapColumn(column: string): string;
|
|
24
|
+
wrapTable(table: string): string;
|
|
25
|
+
quoteValue(value: unknown): string;
|
|
26
|
+
compileLateralEagerLoad(_table: string, _foreignKey: string, _parentKeys: unknown[], _query: CompiledQuery): {
|
|
27
|
+
sql: string;
|
|
28
|
+
bindings: unknown[];
|
|
29
|
+
};
|
|
30
|
+
getStructuralKey(_query: CompiledQuery): string;
|
|
31
|
+
compileJsonPath(column: string, _value: unknown): string;
|
|
32
|
+
compileJsonContains(column: string, _value: unknown): string;
|
|
33
|
+
compileUpdateJson(_query: CompiledQuery, column: string, _value: unknown): string;
|
|
34
|
+
compileUpsert(_query: CompiledQuery, _values: Record<string, unknown>[], _uniqueBy: string[], _update: string[]): string;
|
|
35
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PostgreSQL Grammar
|
|
3
|
+
* @description SQL grammar implementation for PostgreSQL
|
|
4
|
+
*/
|
|
5
|
+
import type { CompiledQuery } from '../types';
|
|
6
|
+
import { Grammar } from './Grammar';
|
|
7
|
+
/**
|
|
8
|
+
* PostgreSQL Grammar
|
|
9
|
+
* Implements PostgreSQL-specific SQL syntax
|
|
10
|
+
*/
|
|
11
|
+
export declare class PostgresGrammar extends Grammar {
|
|
12
|
+
/**
|
|
13
|
+
* PostgreSQL uses double quotes for identifiers
|
|
14
|
+
*/
|
|
15
|
+
protected wrapChar: string;
|
|
16
|
+
/**
|
|
17
|
+
* Get placeholder for PostgreSQL ($1, $2, $3...)
|
|
18
|
+
*/
|
|
19
|
+
getPlaceholder(index: number): string;
|
|
20
|
+
/**
|
|
21
|
+
* Compile INSERT and return ID using RETURNING clause
|
|
22
|
+
*/
|
|
23
|
+
compileInsertGetId(query: CompiledQuery, values: Record<string, unknown>, primaryKey: string): string;
|
|
24
|
+
/**
|
|
25
|
+
* Compile INSERT with RETURNING clause for PostgreSQL
|
|
26
|
+
*/
|
|
27
|
+
compileInsert(query: CompiledQuery, values: Record<string, unknown>[]): string;
|
|
28
|
+
/**
|
|
29
|
+
* Compile UPDATE with RETURNING clause for PostgreSQL
|
|
30
|
+
*/
|
|
31
|
+
compileUpdate(query: CompiledQuery, values: Record<string, unknown>): string;
|
|
32
|
+
/**
|
|
33
|
+
* Compile TRUNCATE with CASCADE option for PostgreSQL
|
|
34
|
+
*/
|
|
35
|
+
compileTruncate(query: CompiledQuery): string;
|
|
36
|
+
/**
|
|
37
|
+
* PostgreSQL-specific: Compile UPSERT using ON CONFLICT
|
|
38
|
+
*/
|
|
39
|
+
compileUpsert(query: CompiledQuery, values: Record<string, unknown>[], uniqueBy: string[], update: string[]): string;
|
|
40
|
+
/**
|
|
41
|
+
* PostgreSQL-specific: Compile locking clause
|
|
42
|
+
*/
|
|
43
|
+
compileLock(mode: 'update' | 'share'): string;
|
|
44
|
+
/**
|
|
45
|
+
* Override offset placeholders for PostgreSQL
|
|
46
|
+
*/
|
|
47
|
+
protected offsetPlaceholders(sql: string, offset: number): string;
|
|
48
|
+
/**
|
|
49
|
+
* Compile a lateral eager load query for PostgreSQL
|
|
50
|
+
*/
|
|
51
|
+
compileLateralEagerLoad(_table: string, foreignKey: string, parentKeys: unknown[], query: CompiledQuery): {
|
|
52
|
+
sql: string;
|
|
53
|
+
bindings: unknown[];
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Guess the PostgreSQL type for an array of values
|
|
57
|
+
*/
|
|
58
|
+
protected guessType(values: unknown[]): string;
|
|
59
|
+
compileJsonPath(column: string, path: string[]): string;
|
|
60
|
+
compileJsonContains(column: string, _value: unknown): string;
|
|
61
|
+
compileUpdateJson(query: CompiledQuery, column: string, _value: unknown): string;
|
|
62
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SQLite Grammar
|
|
3
|
+
* @description SQL grammar implementation for SQLite
|
|
4
|
+
*/
|
|
5
|
+
import type { CompiledQuery } from '../types';
|
|
6
|
+
import { Grammar } from './Grammar';
|
|
7
|
+
/**
|
|
8
|
+
* SQLite Grammar
|
|
9
|
+
* Implements SQLite-specific SQL syntax
|
|
10
|
+
*/
|
|
11
|
+
export declare class SQLiteGrammar extends Grammar {
|
|
12
|
+
/**
|
|
13
|
+
* SQLite uses double quotes for identifiers
|
|
14
|
+
*/
|
|
15
|
+
protected wrapChar: string;
|
|
16
|
+
/**
|
|
17
|
+
* Get placeholder for SQLite (?)
|
|
18
|
+
*/
|
|
19
|
+
getPlaceholder(_index: number): string;
|
|
20
|
+
/**
|
|
21
|
+
* Compile INSERT statement with RETURNING *
|
|
22
|
+
*/
|
|
23
|
+
compileInsert(query: CompiledQuery, values: Record<string, unknown>[]): string;
|
|
24
|
+
compileInsertGetId(query: CompiledQuery, values: Record<string, unknown>, primaryKey: string): string;
|
|
25
|
+
/**
|
|
26
|
+
* Compile TRUNCATE statement
|
|
27
|
+
* SQLite doesn't have TRUNCATE, use DELETE FROM
|
|
28
|
+
*/
|
|
29
|
+
compileTruncate(query: CompiledQuery): string;
|
|
30
|
+
compileJsonPath(column: string, _value: unknown): string;
|
|
31
|
+
compileJsonContains(_column: string, _value: unknown): string;
|
|
32
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @gravito/atlas
|
|
3
|
+
* @description The Standard Database Orbit - Custom Query Builder & ORM for Gravito
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```typescript
|
|
7
|
+
* import { DB } from '@gravito/atlas'
|
|
8
|
+
*
|
|
9
|
+
* // Configure
|
|
10
|
+
* DB.addConnection('default', {
|
|
11
|
+
* driver: 'postgres',
|
|
12
|
+
* host: 'localhost',
|
|
13
|
+
* port: 5432,
|
|
14
|
+
* database: 'myapp',
|
|
15
|
+
* username: 'postgres',
|
|
16
|
+
* password: 'secret'
|
|
17
|
+
* })
|
|
18
|
+
*
|
|
19
|
+
* // Query
|
|
20
|
+
* const users = await DB.table('users')
|
|
21
|
+
* .where('status', 'active')
|
|
22
|
+
* .orderBy('created_at', 'desc')
|
|
23
|
+
* .limit(10)
|
|
24
|
+
* .get()
|
|
25
|
+
*
|
|
26
|
+
* // Insert
|
|
27
|
+
* const newUser = await DB.table('users').insert({
|
|
28
|
+
* name: 'John Doe',
|
|
29
|
+
* email: 'john@example.com'
|
|
30
|
+
* })
|
|
31
|
+
*
|
|
32
|
+
* // Update
|
|
33
|
+
* await DB.table('users')
|
|
34
|
+
* .where('id', 1)
|
|
35
|
+
* .update({ name: 'Jane Doe' })
|
|
36
|
+
*
|
|
37
|
+
* // Transaction
|
|
38
|
+
* await DB.transaction(async (db) => {
|
|
39
|
+
* await db.table('accounts').where('id', 1).decrement('balance', 100)
|
|
40
|
+
* await db.table('accounts').where('id', 2).increment('balance', 100)
|
|
41
|
+
* })
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export type { AtlasConfig } from './config';
|
|
45
|
+
export { autoConfigure, defineConfig, fromEnv, loadConfig, loadConfigFile } from './config';
|
|
46
|
+
export { Connection } from './connection/Connection';
|
|
47
|
+
export { ConnectionManager } from './connection/ConnectionManager';
|
|
48
|
+
export { DB } from './DB';
|
|
49
|
+
export { BunSQLDriver } from './drivers/BunSQLDriver';
|
|
50
|
+
export { PostgresDriver } from './drivers/PostgresDriver';
|
|
51
|
+
export { SQLiteDriver } from './drivers/SQLiteDriver';
|
|
52
|
+
export { ConnectionError, ConstraintViolationError, DatabaseError, ForeignKeyConstraintError, NotNullConstraintError, TableNotFoundError, UniqueConstraintError, } from './errors';
|
|
53
|
+
export { Grammar } from './grammar/Grammar';
|
|
54
|
+
export { PostgresGrammar } from './grammar/PostgresGrammar';
|
|
55
|
+
export type { Migration, MigrationFile, MigrationRecord, MigrationResult, MigratorOptions, } from './migration';
|
|
56
|
+
export { MigrationRepository, Migrator } from './migration';
|
|
57
|
+
export { OrbitAtlas } from './OrbitAtlas';
|
|
58
|
+
export type { ColumnSchema as OrmColumnSchema, ModelAttributes, ModelConstructor, ModelStatic, RelationshipMeta, RelationType, SchemaLock, SchemaMode, SchemaRegistryOptions, TableSchema, } from './orm';
|
|
59
|
+
export { BelongsTo, BelongsToMany, ColumnNotFoundError, column, DirtyTracker, eagerLoad, eagerLoadMany, getRelationships, HasMany, HasOne, Model, ModelNotFoundError, ModelRegistry, MorphMany, MorphOne, MorphTo, NullableConstraintError, SchemaRegistry, SchemaSniffer, SoftDeletes, TypeMismatchError, version, } from './orm';
|
|
60
|
+
export { Expression, raw } from './query/Expression';
|
|
61
|
+
export { QueryBuilder, QueryBuilderError, RecordNotFoundError } from './query/QueryBuilder';
|
|
62
|
+
export type { ColumnType, ForeignKeyAction, ForeignKeyDefinition, IndexDefinition } from './schema';
|
|
63
|
+
export { Blueprint, ColumnDefinition, Schema } from './schema';
|
|
64
|
+
export { MySQLSchemaGrammar, PostgresSchemaGrammar, SchemaGrammar, SQLiteSchemaGrammar, } from './schema/grammars';
|
|
65
|
+
export type { FactoryDefinition, Seeder, SeederFile, SeederRunnerOptions } from './seed';
|
|
66
|
+
export { Factory, factory, SeederRunner } from './seed';
|
|
67
|
+
export type { BooleanOperator, CompiledQuery, ConnectionConfig, ConnectionContract, DriverContract, DriverType, ExecuteResult, FieldInfo, GrammarContract, HavingClause, JoinClause, JoinType, MySQLConfig, Operator, OrderClause, OrderDirection, PaginateResult, PoolConfig, PostgresConfig, QueryBuilderContract, QueryResult, SQLiteConfig, SSLConfig, WhereClause, } from './types';
|
|
@@ -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,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
|
+
}
|