@gravito/ripple 3.1.0 → 4.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (190) hide show
  1. package/README.md +260 -19
  2. package/dist/atlas/src/DB.d.ts +348 -0
  3. package/dist/atlas/src/OrbitAtlas.d.ts +9 -0
  4. package/dist/atlas/src/config/defineConfig.d.ts +14 -0
  5. package/dist/atlas/src/config/index.d.ts +7 -0
  6. package/dist/atlas/src/config/loadConfig.d.ts +41 -0
  7. package/dist/atlas/src/connection/Connection.d.ts +112 -0
  8. package/dist/atlas/src/connection/ConnectionManager.d.ts +180 -0
  9. package/dist/atlas/src/connection/ReplicaConnectionPool.d.ts +54 -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 +79 -0
  14. package/dist/atlas/src/drivers/PostgresDriver.d.ts +96 -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 +79 -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 +33 -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/Repository.d.ts +247 -0
  35. package/dist/atlas/src/orm/index.d.ts +6 -0
  36. package/dist/atlas/src/orm/model/DirtyTracker.d.ts +121 -0
  37. package/dist/atlas/src/orm/model/Model.d.ts +458 -0
  38. package/dist/atlas/src/orm/model/ModelRegistry.d.ts +20 -0
  39. package/dist/atlas/src/orm/model/concerns/HasAttributes.d.ts +150 -0
  40. package/dist/atlas/src/orm/model/concerns/HasEvents.d.ts +36 -0
  41. package/dist/atlas/src/orm/model/concerns/HasPersistence.d.ts +92 -0
  42. package/dist/atlas/src/orm/model/concerns/HasRelationships.d.ts +117 -0
  43. package/dist/atlas/src/orm/model/concerns/HasSerialization.d.ts +64 -0
  44. package/dist/atlas/src/orm/model/concerns/applyMixins.d.ts +15 -0
  45. package/dist/atlas/src/orm/model/concerns/index.d.ts +12 -0
  46. package/dist/atlas/src/orm/model/decorators.d.ts +138 -0
  47. package/dist/atlas/src/orm/model/errors.d.ts +52 -0
  48. package/dist/atlas/src/orm/model/index.d.ts +10 -0
  49. package/dist/atlas/src/orm/model/relationships.d.ts +207 -0
  50. package/dist/atlas/src/orm/model/types.d.ts +12 -0
  51. package/dist/atlas/src/orm/schema/SchemaRegistry.d.ts +124 -0
  52. package/dist/atlas/src/orm/schema/SchemaSniffer.d.ts +54 -0
  53. package/dist/atlas/src/orm/schema/index.d.ts +6 -0
  54. package/dist/atlas/src/orm/schema/types.d.ts +85 -0
  55. package/dist/atlas/src/pool/AdaptivePoolManager.d.ts +98 -0
  56. package/dist/atlas/src/pool/PoolHealthChecker.d.ts +91 -0
  57. package/dist/atlas/src/pool/PoolStrategy.d.ts +129 -0
  58. package/dist/atlas/src/pool/PoolWarmer.d.ts +92 -0
  59. package/dist/atlas/src/query/Expression.d.ts +60 -0
  60. package/dist/atlas/src/query/NPlusOneDetector.d.ts +10 -0
  61. package/dist/atlas/src/query/QueryBuilder.d.ts +643 -0
  62. package/dist/atlas/src/query/RelationshipResolver.d.ts +23 -0
  63. package/dist/atlas/src/query/clauses/GroupByClause.d.ts +51 -0
  64. package/dist/atlas/src/query/clauses/HavingClause.d.ts +70 -0
  65. package/dist/atlas/src/query/clauses/JoinClause.d.ts +87 -0
  66. package/dist/atlas/src/query/clauses/LimitClause.d.ts +82 -0
  67. package/dist/atlas/src/query/clauses/OrderByClause.d.ts +69 -0
  68. package/dist/atlas/src/query/clauses/SelectClause.d.ts +71 -0
  69. package/dist/atlas/src/query/clauses/WhereClause.d.ts +167 -0
  70. package/dist/atlas/src/query/clauses/index.d.ts +11 -0
  71. package/dist/atlas/src/schema/Blueprint.d.ts +276 -0
  72. package/dist/atlas/src/schema/ColumnDefinition.d.ts +154 -0
  73. package/dist/atlas/src/schema/ForeignKeyDefinition.d.ts +37 -0
  74. package/dist/atlas/src/schema/MigrationGenerator.d.ts +45 -0
  75. package/dist/atlas/src/schema/Schema.d.ts +131 -0
  76. package/dist/atlas/src/schema/SchemaDiff.d.ts +73 -0
  77. package/dist/atlas/src/schema/TypeGenerator.d.ts +57 -0
  78. package/dist/atlas/src/schema/TypeWriter.d.ts +42 -0
  79. package/dist/atlas/src/schema/grammars/MySQLSchemaGrammar.d.ts +23 -0
  80. package/dist/atlas/src/schema/grammars/PostgresSchemaGrammar.d.ts +26 -0
  81. package/dist/atlas/src/schema/grammars/SQLiteSchemaGrammar.d.ts +28 -0
  82. package/dist/atlas/src/schema/grammars/SchemaGrammar.d.ts +97 -0
  83. package/dist/atlas/src/schema/grammars/index.d.ts +7 -0
  84. package/dist/atlas/src/schema/index.d.ts +8 -0
  85. package/dist/atlas/src/seed/Factory.d.ts +90 -0
  86. package/dist/atlas/src/seed/Seeder.d.ts +28 -0
  87. package/dist/atlas/src/seed/SeederRunner.d.ts +74 -0
  88. package/dist/atlas/src/seed/index.d.ts +6 -0
  89. package/dist/atlas/src/sharding/ShardingManager.d.ts +59 -0
  90. package/dist/atlas/src/types/index.d.ts +1182 -0
  91. package/dist/atlas/src/utils/CursorEncoding.d.ts +63 -0
  92. package/dist/atlas/src/utils/levenshtein.d.ts +9 -0
  93. package/dist/core/src/CommandKernel.d.ts +33 -0
  94. package/dist/core/src/ConfigManager.d.ts +39 -0
  95. package/dist/core/src/Container/RequestScopeManager.d.ts +62 -0
  96. package/dist/core/src/Container/RequestScopeMetrics.d.ts +144 -0
  97. package/dist/core/src/Container.d.ts +86 -11
  98. package/dist/core/src/ErrorHandler.d.ts +3 -0
  99. package/dist/core/src/HookManager.d.ts +511 -4
  100. package/dist/core/src/PlanetCore.d.ts +89 -0
  101. package/dist/core/src/RequestContext.d.ts +97 -0
  102. package/dist/core/src/Router.d.ts +1 -5
  103. package/dist/core/src/ServiceProvider.d.ts +22 -0
  104. package/dist/core/src/adapters/GravitoEngineAdapter.d.ts +1 -0
  105. package/dist/core/src/adapters/PhotonAdapter.d.ts +5 -0
  106. package/dist/core/src/adapters/bun/BunContext.d.ts +4 -0
  107. package/dist/core/src/adapters/bun/BunNativeAdapter.d.ts +1 -0
  108. package/dist/core/src/adapters/types.d.ts +27 -0
  109. package/dist/core/src/cli/queue-commands.d.ts +6 -0
  110. package/dist/core/src/engine/AOTRouter.d.ts +7 -12
  111. package/dist/core/src/engine/FastContext.d.ts +27 -2
  112. package/dist/core/src/engine/Gravito.d.ts +0 -1
  113. package/dist/core/src/engine/MinimalContext.d.ts +25 -2
  114. package/dist/core/src/engine/types.d.ts +9 -1
  115. package/dist/core/src/error-handling/RequestScopeErrorContext.d.ts +126 -0
  116. package/dist/core/src/events/BackpressureManager.d.ts +215 -0
  117. package/dist/core/src/events/CircuitBreaker.d.ts +229 -0
  118. package/dist/core/src/events/DeadLetterQueue.d.ts +219 -0
  119. package/dist/core/src/events/EventBackend.d.ts +12 -0
  120. package/dist/core/src/events/EventOptions.d.ts +204 -0
  121. package/dist/core/src/events/EventPriorityQueue.d.ts +301 -0
  122. package/dist/core/src/events/FlowControlStrategy.d.ts +109 -0
  123. package/dist/core/src/events/IdempotencyCache.d.ts +60 -0
  124. package/dist/core/src/events/MessageQueueBridge.d.ts +184 -0
  125. package/dist/core/src/events/PriorityEscalationManager.d.ts +82 -0
  126. package/dist/core/src/events/RetryScheduler.d.ts +104 -0
  127. package/dist/core/src/events/WorkerPool.d.ts +98 -0
  128. package/dist/core/src/events/WorkerPoolConfig.d.ts +153 -0
  129. package/dist/core/src/events/WorkerPoolMetrics.d.ts +65 -0
  130. package/dist/core/src/events/aggregation/AggregationWindow.d.ts +77 -0
  131. package/dist/core/src/events/aggregation/DeduplicationManager.d.ts +135 -0
  132. package/dist/core/src/events/aggregation/EventAggregationManager.d.ts +108 -0
  133. package/dist/core/src/events/aggregation/EventBatcher.d.ts +99 -0
  134. package/dist/core/src/events/aggregation/types.d.ts +117 -0
  135. package/dist/core/src/events/index.d.ts +25 -0
  136. package/dist/core/src/events/observability/EventMetrics.d.ts +132 -0
  137. package/dist/core/src/events/observability/EventTracer.d.ts +68 -0
  138. package/dist/core/src/events/observability/EventTracing.d.ts +161 -0
  139. package/dist/core/src/events/observability/OTelEventMetrics.d.ts +332 -0
  140. package/dist/core/src/events/observability/ObservableHookManager.d.ts +108 -0
  141. package/dist/core/src/events/observability/StreamWorkerMetrics.d.ts +76 -0
  142. package/dist/core/src/events/observability/index.d.ts +24 -0
  143. package/dist/core/src/events/observability/metrics-types.d.ts +16 -0
  144. package/dist/core/src/events/types.d.ts +134 -0
  145. package/dist/core/src/exceptions/CircularDependencyException.d.ts +9 -0
  146. package/dist/core/src/exceptions/index.d.ts +1 -0
  147. package/dist/core/src/health/HealthProvider.d.ts +67 -0
  148. package/dist/core/src/http/types.d.ts +40 -0
  149. package/dist/core/src/index.d.ts +25 -4
  150. package/dist/core/src/instrumentation/index.d.ts +35 -0
  151. package/dist/core/src/instrumentation/opentelemetry.d.ts +178 -0
  152. package/dist/core/src/instrumentation/types.d.ts +182 -0
  153. package/dist/core/src/observability/Metrics.d.ts +244 -0
  154. package/dist/core/src/observability/QueueDashboard.d.ts +136 -0
  155. package/dist/core/src/reliability/DeadLetterQueueManager.d.ts +350 -0
  156. package/dist/core/src/reliability/RetryPolicy.d.ts +217 -0
  157. package/dist/core/src/reliability/index.d.ts +6 -0
  158. package/dist/core/src/router/ControllerDispatcher.d.ts +12 -0
  159. package/dist/core/src/router/RequestValidator.d.ts +20 -0
  160. package/dist/index.js +6709 -9888
  161. package/dist/index.js.map +64 -62
  162. package/dist/photon/src/index.d.ts +19 -0
  163. package/dist/photon/src/middleware/ratelimit-redis.d.ts +50 -0
  164. package/dist/photon/src/middleware/ratelimit.d.ts +161 -0
  165. package/dist/photon/src/openapi.d.ts +19 -0
  166. package/dist/proto/ripple.proto +120 -0
  167. package/dist/ripple/src/RippleServer.d.ts +64 -445
  168. package/dist/ripple/src/channels/ChannelManager.d.ts +25 -10
  169. package/dist/ripple/src/drivers/NATSDriver.d.ts +87 -0
  170. package/dist/ripple/src/drivers/RedisDriver.d.ts +30 -1
  171. package/dist/ripple/src/drivers/index.d.ts +1 -0
  172. package/dist/ripple/src/engines/BunEngine.d.ts +98 -0
  173. package/dist/ripple/src/engines/IRippleEngine.d.ts +205 -0
  174. package/dist/ripple/src/engines/UWebSocketsEngine.d.ts +97 -0
  175. package/dist/ripple/src/engines/WsEngine.d.ts +69 -0
  176. package/dist/ripple/src/engines/index.d.ts +15 -0
  177. package/dist/ripple/src/index.d.ts +2 -0
  178. package/dist/ripple/src/middleware/InterceptorManager.d.ts +21 -0
  179. package/dist/ripple/src/observability/RippleMetrics.d.ts +24 -0
  180. package/dist/ripple/src/reliability/AckManager.d.ts +48 -0
  181. package/dist/ripple/src/serializers/ISerializer.d.ts +39 -0
  182. package/dist/ripple/src/serializers/JsonSerializer.d.ts +19 -0
  183. package/dist/ripple/src/serializers/ProtobufSerializer.d.ts +41 -0
  184. package/dist/ripple/src/serializers/index.d.ts +3 -0
  185. package/dist/ripple/src/tracking/SessionManager.d.ts +104 -0
  186. package/dist/ripple/src/tracking/index.d.ts +1 -0
  187. package/dist/ripple/src/types.d.ts +188 -12
  188. package/dist/ripple/src/utils/MessageSerializer.d.ts +33 -23
  189. package/dist/ripple/src/utils/TokenBucket.d.ts +25 -0
  190. package/package.json +25 -8
@@ -0,0 +1,92 @@
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
+ }
@@ -0,0 +1,117 @@
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
+ }
@@ -0,0 +1,64 @@
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
+ }
@@ -0,0 +1,15 @@
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];
@@ -0,0 +1,12 @@
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';
@@ -0,0 +1,138 @@
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;
@@ -0,0 +1,52 @@
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
+ }
@@ -0,0 +1,10 @@
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';