@gravito/ripple 4.0.1 → 5.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/README.md +26 -10
- package/dist/{ripple/src/OrbitRipple.d.ts → OrbitRipple.d.ts} +1 -0
- package/dist/{ripple/src/RippleServer.d.ts → RippleServer.d.ts} +32 -1
- package/dist/core/src/Application.d.ts +41 -0
- package/dist/core/src/HookManager.d.ts +33 -189
- package/dist/core/src/PlanetCore.d.ts +31 -1
- package/dist/core/src/Router.d.ts +32 -46
- package/dist/core/src/adapters/bun/BunContext.d.ts +6 -1
- package/dist/core/src/adapters/bun/BunNativeAdapter.d.ts +35 -0
- package/dist/core/src/adapters/bun/BunWebSocketHandler.d.ts +48 -0
- package/dist/core/src/adapters/bun/RadixRouter.d.ts +1 -0
- package/dist/core/src/adapters/bun/index.d.ts +7 -0
- package/dist/core/src/binary/BinaryUtils.d.ts +105 -0
- package/dist/core/src/binary/index.d.ts +5 -0
- package/dist/core/src/compat/async-local-storage.d.ts +7 -0
- package/dist/core/src/compat/crypto.d.ts +6 -0
- package/dist/core/src/engine/AOTRouter.d.ts +10 -0
- package/dist/core/src/engine/FastContext.d.ts +19 -1
- package/dist/core/src/engine/Gravito.d.ts +13 -18
- package/dist/core/src/engine/MinimalContext.d.ts +2 -0
- package/dist/core/src/engine/analyzer.d.ts +92 -6
- package/dist/core/src/engine/types.d.ts +3 -0
- package/dist/core/src/events/CircuitBreaker.d.ts +12 -0
- package/dist/core/src/events/EventPriorityQueue.d.ts +18 -256
- package/dist/core/src/events/index.d.ts +12 -11
- package/dist/core/src/events/queue-core.d.ts +77 -0
- package/dist/core/src/events/task-executor.d.ts +51 -0
- package/dist/core/src/exceptions/AuthException.d.ts +10 -0
- package/dist/core/src/exceptions/AuthenticationException.d.ts +2 -2
- package/dist/core/src/exceptions/AuthorizationException.d.ts +2 -2
- package/dist/core/src/exceptions/CacheException.d.ts +9 -0
- package/dist/core/src/exceptions/CircularDependencyException.d.ts +2 -1
- package/dist/core/src/exceptions/ConfigurationException.d.ts +9 -0
- package/dist/core/src/exceptions/DatabaseException.d.ts +9 -0
- package/dist/core/src/exceptions/DomainException.d.ts +9 -0
- package/dist/core/src/exceptions/InfrastructureException.d.ts +17 -0
- package/dist/core/src/exceptions/QueueException.d.ts +9 -0
- package/dist/core/src/exceptions/StorageException.d.ts +9 -0
- package/dist/core/src/exceptions/StreamException.d.ts +9 -0
- package/dist/core/src/exceptions/SystemException.d.ts +9 -0
- package/dist/core/src/exceptions/ValidationException.d.ts +2 -2
- package/dist/core/src/exceptions/index.d.ts +10 -0
- package/dist/core/src/ffi/NativeAccelerator.d.ts +62 -0
- package/dist/core/src/ffi/NativeHasher.d.ts +139 -0
- package/dist/core/src/ffi/cbor-fallback.d.ts +96 -0
- package/dist/core/src/ffi/hash-fallback.d.ts +33 -0
- package/dist/core/src/ffi/index.d.ts +10 -0
- package/dist/core/src/ffi/types.d.ts +135 -0
- package/dist/core/src/helpers/Str.d.ts +15 -0
- package/dist/core/src/hooks/ActionManager.d.ts +132 -0
- package/dist/core/src/hooks/AsyncDetector.d.ts +84 -0
- package/dist/core/src/hooks/FilterManager.d.ts +71 -0
- package/dist/core/src/hooks/MigrationWarner.d.ts +24 -0
- package/dist/core/src/hooks/dlq-operations.d.ts +60 -0
- package/dist/core/src/hooks/types.d.ts +107 -0
- package/dist/core/src/http/CookieJar.d.ts +2 -2
- package/dist/core/src/http/types.d.ts +24 -3
- package/dist/core/src/index.d.ts +491 -14
- package/dist/core/src/observability/contracts.d.ts +137 -0
- package/dist/core/src/reliability/DeadLetterQueueManager.d.ts +2 -3
- package/dist/core/src/runtime/adapter-bun.d.ts +12 -0
- package/dist/core/src/runtime/adapter-deno.d.ts +12 -0
- package/dist/core/src/runtime/adapter-node.d.ts +12 -0
- package/dist/core/src/runtime/adapter-unknown.d.ts +13 -0
- package/dist/core/src/runtime/archive.d.ts +17 -0
- package/dist/core/src/runtime/compression.d.ts +21 -0
- package/dist/core/src/runtime/deep-equals.d.ts +56 -0
- package/dist/core/src/runtime/detection.d.ts +22 -0
- package/dist/core/src/runtime/escape.d.ts +34 -0
- package/dist/core/src/runtime/index.d.ts +44 -0
- package/dist/core/src/runtime/markdown.d.ts +44 -0
- package/dist/core/src/runtime/types.d.ts +436 -0
- package/dist/core/src/runtime-helpers.d.ts +67 -0
- package/dist/core/src/runtime.d.ts +10 -118
- package/dist/core/src/testing/HttpTester.d.ts +1 -0
- package/dist/core/src/transpiler-utils.d.ts +170 -0
- package/dist/{ripple/src/engines → engines}/BunEngine.d.ts +11 -0
- package/dist/errors/RippleError.d.ts +66 -0
- package/dist/index.js +1 -7502
- package/dist/index.js.map +3 -71
- package/package.json +6 -2
- package/dist/atlas/src/DB.d.ts +0 -348
- package/dist/atlas/src/OrbitAtlas.d.ts +0 -9
- package/dist/atlas/src/config/defineConfig.d.ts +0 -14
- package/dist/atlas/src/config/index.d.ts +0 -7
- package/dist/atlas/src/config/loadConfig.d.ts +0 -41
- package/dist/atlas/src/connection/Connection.d.ts +0 -112
- package/dist/atlas/src/connection/ConnectionManager.d.ts +0 -180
- package/dist/atlas/src/connection/ReplicaConnectionPool.d.ts +0 -54
- package/dist/atlas/src/drivers/BunSQLDriver.d.ts +0 -32
- package/dist/atlas/src/drivers/BunSQLPreparedStatement.d.ts +0 -118
- package/dist/atlas/src/drivers/MongoDBDriver.d.ts +0 -36
- package/dist/atlas/src/drivers/MySQLDriver.d.ts +0 -79
- package/dist/atlas/src/drivers/PostgresDriver.d.ts +0 -96
- package/dist/atlas/src/drivers/RedisDriver.d.ts +0 -43
- package/dist/atlas/src/drivers/SQLiteDriver.d.ts +0 -45
- package/dist/atlas/src/drivers/types.d.ts +0 -260
- package/dist/atlas/src/errors/index.d.ts +0 -45
- package/dist/atlas/src/grammar/Grammar.d.ts +0 -342
- package/dist/atlas/src/grammar/MongoGrammar.d.ts +0 -47
- package/dist/atlas/src/grammar/MySQLGrammar.d.ts +0 -54
- package/dist/atlas/src/grammar/NullGrammar.d.ts +0 -35
- package/dist/atlas/src/grammar/PostgresGrammar.d.ts +0 -62
- package/dist/atlas/src/grammar/SQLiteGrammar.d.ts +0 -32
- package/dist/atlas/src/index.d.ts +0 -79
- package/dist/atlas/src/migration/Migration.d.ts +0 -64
- package/dist/atlas/src/migration/MigrationRepository.d.ts +0 -65
- package/dist/atlas/src/migration/Migrator.d.ts +0 -110
- package/dist/atlas/src/migration/index.d.ts +0 -6
- package/dist/atlas/src/observability/AtlasMetrics.d.ts +0 -33
- package/dist/atlas/src/observability/AtlasObservability.d.ts +0 -15
- package/dist/atlas/src/observability/AtlasTracer.d.ts +0 -12
- package/dist/atlas/src/observability/index.d.ts +0 -9
- package/dist/atlas/src/orm/Repository.d.ts +0 -247
- package/dist/atlas/src/orm/index.d.ts +0 -6
- package/dist/atlas/src/orm/model/DirtyTracker.d.ts +0 -121
- package/dist/atlas/src/orm/model/Model.d.ts +0 -458
- package/dist/atlas/src/orm/model/ModelRegistry.d.ts +0 -20
- package/dist/atlas/src/orm/model/concerns/HasAttributes.d.ts +0 -150
- package/dist/atlas/src/orm/model/concerns/HasEvents.d.ts +0 -36
- package/dist/atlas/src/orm/model/concerns/HasPersistence.d.ts +0 -92
- package/dist/atlas/src/orm/model/concerns/HasRelationships.d.ts +0 -117
- package/dist/atlas/src/orm/model/concerns/HasSerialization.d.ts +0 -64
- package/dist/atlas/src/orm/model/concerns/applyMixins.d.ts +0 -15
- package/dist/atlas/src/orm/model/concerns/index.d.ts +0 -12
- package/dist/atlas/src/orm/model/decorators.d.ts +0 -138
- package/dist/atlas/src/orm/model/errors.d.ts +0 -52
- package/dist/atlas/src/orm/model/index.d.ts +0 -10
- package/dist/atlas/src/orm/model/relationships.d.ts +0 -207
- package/dist/atlas/src/orm/model/types.d.ts +0 -12
- package/dist/atlas/src/orm/schema/SchemaRegistry.d.ts +0 -124
- package/dist/atlas/src/orm/schema/SchemaSniffer.d.ts +0 -54
- package/dist/atlas/src/orm/schema/index.d.ts +0 -6
- package/dist/atlas/src/orm/schema/types.d.ts +0 -85
- package/dist/atlas/src/pool/AdaptivePoolManager.d.ts +0 -98
- package/dist/atlas/src/pool/PoolHealthChecker.d.ts +0 -91
- package/dist/atlas/src/pool/PoolStrategy.d.ts +0 -129
- package/dist/atlas/src/pool/PoolWarmer.d.ts +0 -92
- package/dist/atlas/src/query/Expression.d.ts +0 -60
- package/dist/atlas/src/query/NPlusOneDetector.d.ts +0 -10
- package/dist/atlas/src/query/QueryBuilder.d.ts +0 -643
- package/dist/atlas/src/query/RelationshipResolver.d.ts +0 -23
- package/dist/atlas/src/query/clauses/GroupByClause.d.ts +0 -51
- package/dist/atlas/src/query/clauses/HavingClause.d.ts +0 -70
- package/dist/atlas/src/query/clauses/JoinClause.d.ts +0 -87
- package/dist/atlas/src/query/clauses/LimitClause.d.ts +0 -82
- package/dist/atlas/src/query/clauses/OrderByClause.d.ts +0 -69
- package/dist/atlas/src/query/clauses/SelectClause.d.ts +0 -71
- package/dist/atlas/src/query/clauses/WhereClause.d.ts +0 -167
- package/dist/atlas/src/query/clauses/index.d.ts +0 -11
- package/dist/atlas/src/schema/Blueprint.d.ts +0 -276
- package/dist/atlas/src/schema/ColumnDefinition.d.ts +0 -154
- package/dist/atlas/src/schema/ForeignKeyDefinition.d.ts +0 -37
- package/dist/atlas/src/schema/MigrationGenerator.d.ts +0 -45
- package/dist/atlas/src/schema/Schema.d.ts +0 -131
- package/dist/atlas/src/schema/SchemaDiff.d.ts +0 -73
- package/dist/atlas/src/schema/TypeGenerator.d.ts +0 -57
- package/dist/atlas/src/schema/TypeWriter.d.ts +0 -42
- package/dist/atlas/src/schema/grammars/MySQLSchemaGrammar.d.ts +0 -23
- package/dist/atlas/src/schema/grammars/PostgresSchemaGrammar.d.ts +0 -26
- package/dist/atlas/src/schema/grammars/SQLiteSchemaGrammar.d.ts +0 -28
- package/dist/atlas/src/schema/grammars/SchemaGrammar.d.ts +0 -97
- package/dist/atlas/src/schema/grammars/index.d.ts +0 -7
- package/dist/atlas/src/schema/index.d.ts +0 -8
- package/dist/atlas/src/seed/Factory.d.ts +0 -90
- package/dist/atlas/src/seed/Seeder.d.ts +0 -28
- package/dist/atlas/src/seed/SeederRunner.d.ts +0 -74
- package/dist/atlas/src/seed/index.d.ts +0 -6
- package/dist/atlas/src/sharding/ShardingManager.d.ts +0 -59
- package/dist/atlas/src/types/index.d.ts +0 -1182
- package/dist/atlas/src/utils/CursorEncoding.d.ts +0 -63
- package/dist/atlas/src/utils/levenshtein.d.ts +0 -9
- package/dist/core/src/adapters/PhotonAdapter.d.ts +0 -175
- package/dist/core/src/adapters/photon-types.d.ts +0 -73
- package/dist/core/src/http/middleware/BodySizeLimit.d.ts +0 -16
- package/dist/core/src/http/middleware/Cors.d.ts +0 -24
- package/dist/core/src/http/middleware/Csrf.d.ts +0 -23
- package/dist/core/src/http/middleware/HeaderTokenGate.d.ts +0 -28
- package/dist/core/src/http/middleware/SecurityHeaders.d.ts +0 -29
- package/dist/core/src/http/middleware/ThrottleRequests.d.ts +0 -18
- package/dist/core/src/instrumentation/index.d.ts +0 -35
- package/dist/core/src/instrumentation/opentelemetry.d.ts +0 -178
- package/dist/core/src/instrumentation/types.d.ts +0 -182
- package/dist/core/src/observability/Metrics.d.ts +0 -244
- package/dist/photon/src/index.d.ts +0 -89
- package/dist/photon/src/middleware/binary.d.ts +0 -31
- package/dist/photon/src/middleware/htmx.d.ts +0 -39
- package/dist/photon/src/middleware/ratelimit-redis.d.ts +0 -50
- package/dist/photon/src/middleware/ratelimit.d.ts +0 -161
- package/dist/photon/src/openapi.d.ts +0 -19
- package/dist/ripple/src/errors/RippleError.d.ts +0 -48
- /package/dist/{ripple/src/channels → channels}/Channel.d.ts +0 -0
- /package/dist/{ripple/src/channels → channels}/ChannelManager.d.ts +0 -0
- /package/dist/{ripple/src/channels → channels}/index.d.ts +0 -0
- /package/dist/{ripple/src/drivers → drivers}/LocalDriver.d.ts +0 -0
- /package/dist/{ripple/src/drivers → drivers}/NATSDriver.d.ts +0 -0
- /package/dist/{ripple/src/drivers → drivers}/RedisDriver.d.ts +0 -0
- /package/dist/{ripple/src/drivers → drivers}/index.d.ts +0 -0
- /package/dist/{ripple/src/engines → engines}/IRippleEngine.d.ts +0 -0
- /package/dist/{ripple/src/engines → engines}/UWebSocketsEngine.d.ts +0 -0
- /package/dist/{ripple/src/engines → engines}/WsEngine.d.ts +0 -0
- /package/dist/{ripple/src/engines → engines}/index.d.ts +0 -0
- /package/dist/{ripple/src/errors → errors}/index.d.ts +0 -0
- /package/dist/{ripple/src/events → events}/BroadcastEvent.d.ts +0 -0
- /package/dist/{ripple/src/events → events}/BroadcastManager.d.ts +0 -0
- /package/dist/{ripple/src/events → events}/Broadcaster.d.ts +0 -0
- /package/dist/{ripple/src/events → events}/index.d.ts +0 -0
- /package/dist/{ripple/src/health → health}/HealthChecker.d.ts +0 -0
- /package/dist/{ripple/src/health → health}/index.d.ts +0 -0
- /package/dist/{ripple/src/index.d.ts → index.d.ts} +0 -0
- /package/dist/{ripple/src/logging → logging}/Logger.d.ts +0 -0
- /package/dist/{ripple/src/logging → logging}/index.d.ts +0 -0
- /package/dist/{ripple/src/middleware → middleware}/InterceptorManager.d.ts +0 -0
- /package/dist/{ripple/src/observability → observability}/RippleMetrics.d.ts +0 -0
- /package/dist/{ripple/src/reliability → reliability}/AckManager.d.ts +0 -0
- /package/dist/{ripple/src/serializers → serializers}/ISerializer.d.ts +0 -0
- /package/dist/{ripple/src/serializers → serializers}/JsonSerializer.d.ts +0 -0
- /package/dist/{ripple/src/serializers → serializers}/ProtobufSerializer.d.ts +0 -0
- /package/dist/{ripple/src/serializers → serializers}/index.d.ts +0 -0
- /package/dist/{ripple/src/tracking → tracking}/ConnectionTracker.d.ts +0 -0
- /package/dist/{ripple/src/tracking → tracking}/SessionManager.d.ts +0 -0
- /package/dist/{ripple/src/tracking → tracking}/index.d.ts +0 -0
- /package/dist/{ripple/src/types.d.ts → types.d.ts} +0 -0
- /package/dist/{ripple/src/utils → utils}/MessageSerializer.d.ts +0 -0
- /package/dist/{ripple/src/utils → utils}/TokenBucket.d.ts +0 -0
- /package/dist/{ripple/src/utils → utils}/index.d.ts +0 -0
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* HasPersistence Concern
|
|
3
|
-
* @description Provides database persistence functionality including saving, deleting, and refreshing.
|
|
4
|
-
*/
|
|
5
|
-
export declare class HasPersistence {
|
|
6
|
-
/**
|
|
7
|
-
* Indicates if the model exists in the database.
|
|
8
|
-
* @internal
|
|
9
|
-
*/
|
|
10
|
-
protected _exists: boolean;
|
|
11
|
-
/**
|
|
12
|
-
* Check if the model instance exists in the database.
|
|
13
|
-
*
|
|
14
|
-
* @returns True if the model has been persisted
|
|
15
|
-
*/
|
|
16
|
-
get exists(): boolean;
|
|
17
|
-
/**
|
|
18
|
-
* Internal helper to retrieve the correct connection depending on sharding configuration
|
|
19
|
-
* @internal
|
|
20
|
-
*/
|
|
21
|
-
protected _getConnection(): import('../../../types').ConnectionContract;
|
|
22
|
-
/**
|
|
23
|
-
* Save the model instance to the database (insert or update).
|
|
24
|
-
*
|
|
25
|
-
* @returns A promise that resolves to the model instance
|
|
26
|
-
*
|
|
27
|
-
* @example
|
|
28
|
-
* ```typescript
|
|
29
|
-
* await user.save()
|
|
30
|
-
* ```
|
|
31
|
-
*/
|
|
32
|
-
save(): Promise<this>;
|
|
33
|
-
/**
|
|
34
|
-
* Perform an insert operation for a new model instance.
|
|
35
|
-
*
|
|
36
|
-
* @returns A promise that resolves to the model instance
|
|
37
|
-
* @internal
|
|
38
|
-
*/
|
|
39
|
-
protected _performInsert(): Promise<this>;
|
|
40
|
-
/**
|
|
41
|
-
* Perform an update operation for an existing model instance.
|
|
42
|
-
*
|
|
43
|
-
* @returns A promise that resolves to the model instance
|
|
44
|
-
* @internal
|
|
45
|
-
*/
|
|
46
|
-
protected _performUpdate(): Promise<this>;
|
|
47
|
-
/**
|
|
48
|
-
* Delete the model instance from the database.
|
|
49
|
-
* Supports soft deletes if configured on the model.
|
|
50
|
-
*
|
|
51
|
-
* @returns A promise that resolves to true if deleted successfully
|
|
52
|
-
*
|
|
53
|
-
* @example
|
|
54
|
-
* ```typescript
|
|
55
|
-
* await user.delete()
|
|
56
|
-
* ```
|
|
57
|
-
*/
|
|
58
|
-
delete(): Promise<boolean>;
|
|
59
|
-
/**
|
|
60
|
-
* Restore a soft-deleted model instance.
|
|
61
|
-
*
|
|
62
|
-
* @returns A promise that resolves to true
|
|
63
|
-
*
|
|
64
|
-
* @example
|
|
65
|
-
* ```typescript
|
|
66
|
-
* await user.restore()
|
|
67
|
-
* ```
|
|
68
|
-
*/
|
|
69
|
-
restore(): Promise<boolean>;
|
|
70
|
-
/**
|
|
71
|
-
* Force a hard delete even if soft deletes are enabled.
|
|
72
|
-
*
|
|
73
|
-
* @returns A promise that resolves to true
|
|
74
|
-
*
|
|
75
|
-
* @example
|
|
76
|
-
* ```typescript
|
|
77
|
-
* await user.forceDelete()
|
|
78
|
-
* ```
|
|
79
|
-
*/
|
|
80
|
-
forceDelete(): Promise<boolean>;
|
|
81
|
-
/**
|
|
82
|
-
* Refresh the model instance with fresh data from the database.
|
|
83
|
-
*
|
|
84
|
-
* @returns A promise that resolves to the model instance
|
|
85
|
-
*
|
|
86
|
-
* @example
|
|
87
|
-
* ```typescript
|
|
88
|
-
* await user.refresh()
|
|
89
|
-
* ```
|
|
90
|
-
*/
|
|
91
|
-
refresh(): Promise<this>;
|
|
92
|
-
}
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import type { Model, ModelConstructor } from '../Model';
|
|
2
|
-
/**
|
|
3
|
-
* HasRelationships Concern
|
|
4
|
-
* @description Provides relationship management functionality including defining and loading relationships.
|
|
5
|
-
*/
|
|
6
|
-
export declare class HasRelationships {
|
|
7
|
-
/**
|
|
8
|
-
* Define a one-to-many relationship.
|
|
9
|
-
* Returns a QueryBuilder scoped to the related records.
|
|
10
|
-
*
|
|
11
|
-
* @template R - The related model type.
|
|
12
|
-
* @param related - The related model constructor.
|
|
13
|
-
* @param foreignKey - The foreign key on the related table.
|
|
14
|
-
* @param localKey - The local key on this table.
|
|
15
|
-
* @returns A QueryBuilder for the related model.
|
|
16
|
-
* @example
|
|
17
|
-
* ```typescript
|
|
18
|
-
* const posts = await user.hasMany(Post).where('published', true).get()
|
|
19
|
-
* ```
|
|
20
|
-
*/
|
|
21
|
-
hasMany<R extends Model>(related: ModelConstructor<R> & typeof Model, foreignKey?: string, localKey?: string): any;
|
|
22
|
-
/**
|
|
23
|
-
* Define a one-to-one relationship.
|
|
24
|
-
*
|
|
25
|
-
* @template R - The related model type.
|
|
26
|
-
* @param related - The related model constructor.
|
|
27
|
-
* @param foreignKey - The foreign key on the related table.
|
|
28
|
-
* @param localKey - The local key on this table.
|
|
29
|
-
* @returns A QueryBuilder for the related model, limited to 1 result.
|
|
30
|
-
*/
|
|
31
|
-
hasOne<R extends Model>(related: ModelConstructor<R> & typeof Model, foreignKey?: string, localKey?: string): any;
|
|
32
|
-
/**
|
|
33
|
-
* Define an inverse one-to-one or one-to-many relationship.
|
|
34
|
-
*
|
|
35
|
-
* @template R - The related model type.
|
|
36
|
-
* @param related - The related model constructor.
|
|
37
|
-
* @param foreignKey - The foreign key on this table.
|
|
38
|
-
* @param ownerKey - The owner key on the related table.
|
|
39
|
-
* @returns A QueryBuilder for the related model.
|
|
40
|
-
* @example
|
|
41
|
-
* ```typescript
|
|
42
|
-
* const user = await post.belongsTo(User).first()
|
|
43
|
-
* ```
|
|
44
|
-
*/
|
|
45
|
-
belongsTo<R extends Model>(related: ModelConstructor<R> & typeof Model, foreignKey?: string, ownerKey?: string): any;
|
|
46
|
-
/**
|
|
47
|
-
* Define a many-to-many relationship through a pivot table.
|
|
48
|
-
*
|
|
49
|
-
* @template R - The related model type.
|
|
50
|
-
* @param related - The related model constructor.
|
|
51
|
-
* @param pivotTable - The name of the join table.
|
|
52
|
-
* @param foreignPivotKey - The key on the pivot table pointing to this model.
|
|
53
|
-
* @param relatedPivotKey - The key on the pivot table pointing to the related model.
|
|
54
|
-
* @param localKey - The local key on this table.
|
|
55
|
-
* @param relatedKey - The related key on the related table.
|
|
56
|
-
* @returns Promise resolving to an array of related models.
|
|
57
|
-
*/
|
|
58
|
-
belongsToMany<R extends Model>(related: ModelConstructor<R> & typeof Model, pivotTable: string, foreignPivotKey?: string, relatedPivotKey?: string, localKey?: string, relatedKey?: string): Promise<R[]>;
|
|
59
|
-
/**
|
|
60
|
-
* Stream hasMany relationship with cursor-based iteration
|
|
61
|
-
* Memory-safe for large relationship sets
|
|
62
|
-
*
|
|
63
|
-
* @example
|
|
64
|
-
* ```typescript
|
|
65
|
-
* for await (const posts of user.hasManyStream(Post, 'user_id', 100)) {
|
|
66
|
-
* for (const post of posts) {
|
|
67
|
-
* await processPost(post)
|
|
68
|
-
* }
|
|
69
|
-
* }
|
|
70
|
-
* ```
|
|
71
|
-
*/
|
|
72
|
-
hasManyStream<R extends Model>(related: ModelConstructor<R> & typeof Model, foreignKey?: string, chunkSize?: number, localKey?: string): AsyncGenerator<R[], void, unknown>;
|
|
73
|
-
/**
|
|
74
|
-
* Define a polymorphic one-to-one relationship.
|
|
75
|
-
*
|
|
76
|
-
* @template R - The related model type.
|
|
77
|
-
* @param related - The related model constructor.
|
|
78
|
-
* @param name - The polymorphic relationship name (used to derive type and id fields).
|
|
79
|
-
* @param foreignKey - Optional explicit foreign key.
|
|
80
|
-
* @param localKey - Optional explicit local key.
|
|
81
|
-
* @returns A QueryBuilder for the related model.
|
|
82
|
-
*/
|
|
83
|
-
morphOne<R extends Model>(related: ModelConstructor<R> & typeof Model, name: string, foreignKey?: string, localKey?: string): any;
|
|
84
|
-
/**
|
|
85
|
-
* Define a polymorphic one-to-many relationship.
|
|
86
|
-
*
|
|
87
|
-
* @template R - The related model type.
|
|
88
|
-
* @param related - The related model constructor.
|
|
89
|
-
* @param name - The polymorphic relationship name.
|
|
90
|
-
* @param foreignKey - Optional explicit foreign key.
|
|
91
|
-
* @param localKey - Optional explicit local key.
|
|
92
|
-
* @returns A QueryBuilder for the related model.
|
|
93
|
-
*/
|
|
94
|
-
morphMany<R extends Model>(related: ModelConstructor<R> & typeof Model, name: string, foreignKey?: string, localKey?: string): any;
|
|
95
|
-
/**
|
|
96
|
-
* Define a polymorphic inverse relationship.
|
|
97
|
-
*
|
|
98
|
-
* @template R - The related model type.
|
|
99
|
-
* @param name - The polymorphic relationship name.
|
|
100
|
-
* @param typeField - Optional explicit type field name.
|
|
101
|
-
* @param idField - Optional explicit ID field name.
|
|
102
|
-
* @returns A QueryBuilder for the resolved related model, or null if not resolvable.
|
|
103
|
-
*/
|
|
104
|
-
morphTo<R extends Model>(name: string, typeField?: string, idField?: string): any;
|
|
105
|
-
/**
|
|
106
|
-
* Lazy load relationships for the current model
|
|
107
|
-
* @example await user.load('posts')
|
|
108
|
-
*/
|
|
109
|
-
load(relation: string | string[]): Promise<this>;
|
|
110
|
-
/**
|
|
111
|
-
* Alias for load(), used for fluent eager loading on an instance.
|
|
112
|
-
*
|
|
113
|
-
* @param relation - The relationship name or an array of names
|
|
114
|
-
* @returns A promise that resolves to the model instance
|
|
115
|
-
*/
|
|
116
|
-
with(relation: string | string[]): Promise<this>;
|
|
117
|
-
}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* HasSerialization Concern
|
|
3
|
-
* @description Provides serialization functionality including converting to JSON, array/object, and handling hidden/appended attributes.
|
|
4
|
-
*/
|
|
5
|
-
export declare class HasSerialization {
|
|
6
|
-
/**
|
|
7
|
-
* Fill the model instance with an object of attributes.
|
|
8
|
-
*
|
|
9
|
-
* @param attributes - Key-value pairs of attributes to set
|
|
10
|
-
* @returns The model instance
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```typescript
|
|
14
|
-
* user.fill({ name: 'Carl', email: 'carl@example.com' })
|
|
15
|
-
* ```
|
|
16
|
-
*/
|
|
17
|
-
fill(attributes: Record<string, unknown>): this;
|
|
18
|
-
/**
|
|
19
|
-
* Convert the model instance to a JSON string.
|
|
20
|
-
*
|
|
21
|
-
* @returns A JSON string representation of the model
|
|
22
|
-
*
|
|
23
|
-
* @example
|
|
24
|
-
* ```typescript
|
|
25
|
-
* const json = user.toJSON()
|
|
26
|
-
* ```
|
|
27
|
-
*/
|
|
28
|
-
toJSON(): unknown;
|
|
29
|
-
/**
|
|
30
|
-
* Convert the model instance to a plain JavaScript object.
|
|
31
|
-
* Alias for `toJSON()`.
|
|
32
|
-
*
|
|
33
|
-
* @returns A plain object representation of the model
|
|
34
|
-
*/
|
|
35
|
-
toObject(): Record<string, unknown>;
|
|
36
|
-
/**
|
|
37
|
-
* Convert the model instance to a plain JavaScript object.
|
|
38
|
-
* Alias for `toJSON()`.
|
|
39
|
-
*
|
|
40
|
-
* @returns A plain object representation of the model
|
|
41
|
-
*/
|
|
42
|
-
toArray(): Record<string, unknown>;
|
|
43
|
-
/**
|
|
44
|
-
* Get all attributes currently set on the model.
|
|
45
|
-
*
|
|
46
|
-
* @returns An object containing all model attributes
|
|
47
|
-
* @internal
|
|
48
|
-
*/
|
|
49
|
-
getAttributes(): Record<string, unknown>;
|
|
50
|
-
/**
|
|
51
|
-
* Get a specific attribute value.
|
|
52
|
-
*
|
|
53
|
-
* @param key - The attribute name
|
|
54
|
-
* @returns The attribute value
|
|
55
|
-
* @internal
|
|
56
|
-
*/
|
|
57
|
-
getAttribute(key: string): unknown;
|
|
58
|
-
/**
|
|
59
|
-
* Get the string representation of the model.
|
|
60
|
-
*
|
|
61
|
-
* @returns A JSON string representation of the model
|
|
62
|
-
*/
|
|
63
|
-
toString(): string;
|
|
64
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Mixin utility for composing classes with multiple concerns.
|
|
3
|
-
* @description Utility function to copy properties from mixin prototypes to a base class prototype.
|
|
4
|
-
*
|
|
5
|
-
* @param base - Base class to extend
|
|
6
|
-
* @param mixins - Mixin classes to apply
|
|
7
|
-
* @returns Combined class with all mixin properties
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* ```typescript
|
|
11
|
-
* class MyModel extends Model {}
|
|
12
|
-
* applyMixins(MyModel, [HasAttributes, HasEvents])
|
|
13
|
-
* ```
|
|
14
|
-
*/
|
|
15
|
-
export declare function applyMixins<T extends new (...args: unknown[]) => unknown, U extends (new (...args: unknown[]) => unknown)[]>(base: T, mixins: U): T & U[number];
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Concerns Index
|
|
3
|
-
*
|
|
4
|
-
* Re-exports all model concerns for easier importing.
|
|
5
|
-
*/
|
|
6
|
-
export { applyMixins } from './applyMixins';
|
|
7
|
-
export type { ModelAttributes } from './HasAttributes';
|
|
8
|
-
export { HasAttributes } from './HasAttributes';
|
|
9
|
-
export { HasEvents } from './HasEvents';
|
|
10
|
-
export { HasPersistence } from './HasPersistence';
|
|
11
|
-
export { HasRelationships } from './HasRelationships';
|
|
12
|
-
export { HasSerialization } from './HasSerialization';
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Options for the SoftDeletes decorator.
|
|
3
|
-
*/
|
|
4
|
-
export interface SoftDeletesOptions {
|
|
5
|
-
/**
|
|
6
|
-
* The name of the column used to store the deletion timestamp.
|
|
7
|
-
* @default 'deleted_at'
|
|
8
|
-
*/
|
|
9
|
-
column?: string;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Meta keys for decorators
|
|
13
|
-
*/
|
|
14
|
-
/**
|
|
15
|
-
* Metadata key for Soft Deletes configuration.
|
|
16
|
-
* @internal
|
|
17
|
-
*/
|
|
18
|
-
export declare const SOFT_DELETES_KEY: unique symbol;
|
|
19
|
-
/**
|
|
20
|
-
* Metadata key for Column definitions.
|
|
21
|
-
* @internal
|
|
22
|
-
*/
|
|
23
|
-
export declare const COLUMN_KEY: unique symbol;
|
|
24
|
-
/**
|
|
25
|
-
* Metadata key for Version column.
|
|
26
|
-
* @internal
|
|
27
|
-
*/
|
|
28
|
-
export declare const VERSION_KEY: unique symbol;
|
|
29
|
-
/**
|
|
30
|
-
* Metadata key for Sharded configuration.
|
|
31
|
-
* @internal
|
|
32
|
-
*/
|
|
33
|
-
export declare const SHARDED_KEY: unique symbol;
|
|
34
|
-
/**
|
|
35
|
-
* Options for the Sharded decorator.
|
|
36
|
-
*/
|
|
37
|
-
export interface ShardedOptions {
|
|
38
|
-
/**
|
|
39
|
-
* The name of the ShardingManager to use.
|
|
40
|
-
* @default 'default'
|
|
41
|
-
*/
|
|
42
|
-
manager?: string;
|
|
43
|
-
/**
|
|
44
|
-
* The property name of the shard key (e.g. 'tenantId').
|
|
45
|
-
*/
|
|
46
|
-
key: string;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Sharded Decorator
|
|
50
|
-
*
|
|
51
|
-
* Marks a model as being horizontally sharded across multiple databases.
|
|
52
|
-
* Active Record operations will automatically route to the correct connection
|
|
53
|
-
* based on the shard key provided.
|
|
54
|
-
*
|
|
55
|
-
* @param options - Configuration for sharding containing the distribution key
|
|
56
|
-
*/
|
|
57
|
-
export declare function sharded(options: ShardedOptions): ClassDecorator;
|
|
58
|
-
/**
|
|
59
|
-
* Soft Deletes Decorator
|
|
60
|
-
*
|
|
61
|
-
* Automatically adds a global scope to filter out deleted records.
|
|
62
|
-
* When applied to a Model class, it ensures that queries only return records
|
|
63
|
-
* where the deletion column (default 'deleted_at') is null.
|
|
64
|
-
*
|
|
65
|
-
* @param options - Configuration for soft deletes
|
|
66
|
-
*
|
|
67
|
-
* @example
|
|
68
|
-
* ```typescript
|
|
69
|
-
* @SoftDeletes({ column: 'deleted_at' })
|
|
70
|
-
* class User extends Model {
|
|
71
|
-
* @column()
|
|
72
|
-
* declare deletedAt: Date | null
|
|
73
|
-
* }
|
|
74
|
-
* ```
|
|
75
|
-
*/
|
|
76
|
-
export declare function SoftDeletes(options?: SoftDeletesOptions): ClassDecorator;
|
|
77
|
-
/**
|
|
78
|
-
* Options for the Column decorator.
|
|
79
|
-
*/
|
|
80
|
-
export interface ColumnOptions {
|
|
81
|
-
/**
|
|
82
|
-
* Whether the column is a primary key.
|
|
83
|
-
* @default false
|
|
84
|
-
*/
|
|
85
|
-
isPrimary?: boolean;
|
|
86
|
-
/**
|
|
87
|
-
* Whether the column should be automatically populated with a timestamp on creation.
|
|
88
|
-
* @default false
|
|
89
|
-
*/
|
|
90
|
-
autoCreate?: boolean;
|
|
91
|
-
/**
|
|
92
|
-
* Whether the column should be automatically updated with a timestamp on every update.
|
|
93
|
-
* @default false
|
|
94
|
-
*/
|
|
95
|
-
autoUpdate?: boolean;
|
|
96
|
-
/**
|
|
97
|
-
* The name of the column in the database.
|
|
98
|
-
* If not provided, the property name will be used.
|
|
99
|
-
*/
|
|
100
|
-
name?: string;
|
|
101
|
-
/**
|
|
102
|
-
* The name to use when serializing the model to JSON.
|
|
103
|
-
* Set to null to hide the column from JSON output.
|
|
104
|
-
*/
|
|
105
|
-
serializeAs?: string | null;
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Column Decorator
|
|
109
|
-
*
|
|
110
|
-
* Marks a property as a database column. This decorator also triggers
|
|
111
|
-
* the registration of the model in the global ModelRegistry.
|
|
112
|
-
*
|
|
113
|
-
* @param options - Configuration for the column
|
|
114
|
-
*
|
|
115
|
-
* @example
|
|
116
|
-
* ```typescript
|
|
117
|
-
* class User extends Model {
|
|
118
|
-
* @column({ isPrimary: true })
|
|
119
|
-
* declare id: number
|
|
120
|
-
*
|
|
121
|
-
* @column({ name: 'email_address' })
|
|
122
|
-
* declare email: string
|
|
123
|
-
*
|
|
124
|
-
* @column.dateTime({ autoCreate: true })
|
|
125
|
-
* declare createdAt: Date
|
|
126
|
-
* }
|
|
127
|
-
* ```
|
|
128
|
-
*/
|
|
129
|
-
export declare function column(options?: ColumnOptions): PropertyDecorator;
|
|
130
|
-
/**
|
|
131
|
-
* Version Decorator for Optimistic Locking
|
|
132
|
-
*
|
|
133
|
-
* Marks a property as a version column for optimistic locking.
|
|
134
|
-
* When a model updates, it checks if the version matches the one in the database.
|
|
135
|
-
*
|
|
136
|
-
* @param options - Configuration for the column (same as @column)
|
|
137
|
-
*/
|
|
138
|
-
export declare function version(options?: ColumnOptions): PropertyDecorator;
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Model Errors
|
|
3
|
-
* @description Custom error types for ORM model operations
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Column Not Found Error
|
|
7
|
-
* Thrown when accessing/setting a column that doesn't exist in schema
|
|
8
|
-
*/
|
|
9
|
-
export declare class ColumnNotFoundError extends Error {
|
|
10
|
-
readonly table: string;
|
|
11
|
-
readonly column: string;
|
|
12
|
-
constructor(table: string, column: string, availableColumns?: string[]);
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Type Mismatch Error
|
|
16
|
-
* Thrown when setting a value with incompatible type
|
|
17
|
-
*/
|
|
18
|
-
export declare class TypeMismatchError extends Error {
|
|
19
|
-
readonly table: string;
|
|
20
|
-
readonly column: string;
|
|
21
|
-
readonly expectedType: string;
|
|
22
|
-
readonly actualType: string;
|
|
23
|
-
readonly value?: unknown | undefined;
|
|
24
|
-
constructor(table: string, column: string, expectedType: string, actualType: string, value?: unknown | undefined);
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Nullable Constraint Error
|
|
28
|
-
* Thrown when setting null on a non-nullable column
|
|
29
|
-
*/
|
|
30
|
-
export declare class NullableConstraintError extends Error {
|
|
31
|
-
readonly table: string;
|
|
32
|
-
readonly column: string;
|
|
33
|
-
constructor(table: string, column: string);
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Model Not Found Error
|
|
37
|
-
* Thrown when a model is not found in the database
|
|
38
|
-
*/
|
|
39
|
-
export declare class ModelNotFoundError extends Error {
|
|
40
|
-
readonly model: string;
|
|
41
|
-
readonly key: unknown;
|
|
42
|
-
constructor(model: string, key: unknown);
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Stale Model Error
|
|
46
|
-
* Thrown when an optimistic lock check fails (concurrent update)
|
|
47
|
-
*/
|
|
48
|
-
export declare class StaleModelError extends Error {
|
|
49
|
-
readonly model: string;
|
|
50
|
-
readonly key: unknown;
|
|
51
|
-
constructor(model: string, key: unknown);
|
|
52
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Model Module Index
|
|
3
|
-
*/
|
|
4
|
-
export { applyMixins, HasAttributes, HasEvents, HasPersistence, HasRelationships, HasSerialization, } from './concerns';
|
|
5
|
-
export { DirtyTracker } from './DirtyTracker';
|
|
6
|
-
export { column, SoftDeletes, sharded, version } from './decorators';
|
|
7
|
-
export { ColumnNotFoundError, ModelNotFoundError, NullableConstraintError, TypeMismatchError, } from './errors';
|
|
8
|
-
export { Model, type ModelAttributes, type ModelConstructor, type ModelStatic } from './Model';
|
|
9
|
-
export { ModelRegistry } from './ModelRegistry';
|
|
10
|
-
export { BelongsTo, BelongsToMany, eagerLoad, eagerLoadMany, getRelationships, HasMany, HasOne, MorphMany, MorphOne, MorphTo, type RelationshipMeta, type RelationshipOptions, type RelationType, } from './relationships';
|