@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,449 @@
|
|
|
1
|
+
import { Factory } from '../../seed/Factory';
|
|
2
|
+
import type { Operator, QueryBuilderContract } from '../../types';
|
|
3
|
+
import type { TableSchema } from '../schema/types';
|
|
4
|
+
import { HasEvents, HasPersistence, HasRelationships, HasSerialization } from './concerns';
|
|
5
|
+
import { DirtyTracker } from './DirtyTracker';
|
|
6
|
+
/**
|
|
7
|
+
* Model attributes type
|
|
8
|
+
*/
|
|
9
|
+
export type ModelAttributes = Record<string, unknown>;
|
|
10
|
+
/**
|
|
11
|
+
* Model constructor type
|
|
12
|
+
*/
|
|
13
|
+
export type ModelConstructor<T extends Model> = new () => T;
|
|
14
|
+
/**
|
|
15
|
+
* Model static interface
|
|
16
|
+
*/
|
|
17
|
+
export interface ModelStatic<T extends Model> {
|
|
18
|
+
new (): T;
|
|
19
|
+
table: string;
|
|
20
|
+
tableName?: string;
|
|
21
|
+
primaryKey: string;
|
|
22
|
+
connection?: string;
|
|
23
|
+
name: string;
|
|
24
|
+
getTable(): string;
|
|
25
|
+
find(key: unknown): Promise<T | null>;
|
|
26
|
+
findOrFail(key: unknown): Promise<T>;
|
|
27
|
+
all(): Promise<T[]>;
|
|
28
|
+
create(attributes?: Partial<ModelAttributes>): Promise<T>;
|
|
29
|
+
query(): QueryBuilderContract<T>;
|
|
30
|
+
where(column: string | Record<string, unknown>, operatorOrValue?: Operator | unknown, value?: unknown): QueryBuilderContract<T>;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Base Model Class providing Active Record implementation.
|
|
34
|
+
*
|
|
35
|
+
* Uses a Proxy-based Smart Guard to intercept property access, enabling
|
|
36
|
+
* dynamic attributes, accessors, mutators, and relationship lazy loading.
|
|
37
|
+
* Provides a fluent interface for database persistence and querying.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```typescript
|
|
41
|
+
* class User extends Model {
|
|
42
|
+
* static table = 'users'
|
|
43
|
+
*
|
|
44
|
+
* declare id: number
|
|
45
|
+
* declare name: string
|
|
46
|
+
* }
|
|
47
|
+
*
|
|
48
|
+
* // Persistence
|
|
49
|
+
* const user = new User()
|
|
50
|
+
* user.name = 'Carl'
|
|
51
|
+
* await user.save()
|
|
52
|
+
*
|
|
53
|
+
* // Retrieval
|
|
54
|
+
* const found = await User.find(1)
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export interface Model extends HasPersistence, HasEvents, HasRelationships, HasSerialization {
|
|
58
|
+
}
|
|
59
|
+
export declare abstract class Model {
|
|
60
|
+
/**
|
|
61
|
+
* Database table name associated with the model.
|
|
62
|
+
*/
|
|
63
|
+
static table: string;
|
|
64
|
+
static tableName: string;
|
|
65
|
+
/**
|
|
66
|
+
* Name of the primary key column.
|
|
67
|
+
*/
|
|
68
|
+
static primaryKey: string;
|
|
69
|
+
/**
|
|
70
|
+
* Attributes that should be hidden from serialization.
|
|
71
|
+
*/
|
|
72
|
+
static hidden: string[];
|
|
73
|
+
/**
|
|
74
|
+
* Attributes that should be visible in serialization, overriding hidden.
|
|
75
|
+
*/
|
|
76
|
+
static visible: string[];
|
|
77
|
+
/**
|
|
78
|
+
* Custom accessors to append to serialized output.
|
|
79
|
+
*/
|
|
80
|
+
static appends: string[];
|
|
81
|
+
/**
|
|
82
|
+
* Observer classes to monitor model lifecycle events.
|
|
83
|
+
*/
|
|
84
|
+
static observers: unknown[];
|
|
85
|
+
/**
|
|
86
|
+
* Controls automatic timestamp management.
|
|
87
|
+
* - `true`: Manages both created_at and updated_at.
|
|
88
|
+
* - `false`: Disables timestamp management.
|
|
89
|
+
* - `'created_only'`: Manages created_at but ignores updated_at.
|
|
90
|
+
*/
|
|
91
|
+
static timestamps: boolean | 'created_only';
|
|
92
|
+
static createdAtColumn: string;
|
|
93
|
+
static updatedAtColumn: string;
|
|
94
|
+
/**
|
|
95
|
+
* Attribute type casting definitions.
|
|
96
|
+
*/
|
|
97
|
+
static casts: Record<string, string>;
|
|
98
|
+
/**
|
|
99
|
+
* Database connection name to use for this model.
|
|
100
|
+
*/
|
|
101
|
+
static connection?: string;
|
|
102
|
+
/**
|
|
103
|
+
* When enabled, throws an error if an attribute is set that does not exist in schema.
|
|
104
|
+
*/
|
|
105
|
+
static strictMode: boolean;
|
|
106
|
+
/**
|
|
107
|
+
* Caches property descriptors to avoid expensive prototype chain traversals.
|
|
108
|
+
* Uses WeakMap to prevent memory leaks by keying off the prototype object.
|
|
109
|
+
*/
|
|
110
|
+
private static _descriptorCache;
|
|
111
|
+
/**
|
|
112
|
+
* Caches property name transformations to StudlyCase.
|
|
113
|
+
* Prevents repeated regex execution for accessor/mutator lookups.
|
|
114
|
+
*/
|
|
115
|
+
private static _studlyCache;
|
|
116
|
+
/**
|
|
117
|
+
* Internal storage for model attribute values.
|
|
118
|
+
*/
|
|
119
|
+
protected _attributes: ModelAttributes;
|
|
120
|
+
/**
|
|
121
|
+
* Tracks modified attributes for efficient delta updates.
|
|
122
|
+
*/
|
|
123
|
+
protected _dirtyTracker: DirtyTracker<ModelAttributes>;
|
|
124
|
+
/**
|
|
125
|
+
* Cached table schema metadata.
|
|
126
|
+
*/
|
|
127
|
+
private _schema?;
|
|
128
|
+
private _schemaPromise?;
|
|
129
|
+
constructor();
|
|
130
|
+
/**
|
|
131
|
+
* Converts a property name to StudlyCase format with caching.
|
|
132
|
+
*
|
|
133
|
+
* Used primarily for resolving accessor/mutator methods (e.g., "first_name" -> "FirstName").
|
|
134
|
+
* Performance-critical as it's called on every property access through the Proxy.
|
|
135
|
+
*
|
|
136
|
+
* @param prop - The property name to transform.
|
|
137
|
+
* @returns The transformed name in StudlyCase.
|
|
138
|
+
* @internal
|
|
139
|
+
*/
|
|
140
|
+
private static _toStudlyCase;
|
|
141
|
+
/**
|
|
142
|
+
* Properties that should bypass the descriptor cache.
|
|
143
|
+
* Necessary for methods frequently mocked in tests (like spyOn).
|
|
144
|
+
*/
|
|
145
|
+
private static _descriptorCacheSkip;
|
|
146
|
+
/**
|
|
147
|
+
* Retrieves a property descriptor from the prototype chain with caching.
|
|
148
|
+
*
|
|
149
|
+
* Optimizes the Proxy 'get' trap by reducing prototype lookups for methods
|
|
150
|
+
* and computed properties.
|
|
151
|
+
*
|
|
152
|
+
* @param proto - The prototype object to search.
|
|
153
|
+
* @param prop - The property name or symbol.
|
|
154
|
+
* @returns The descriptor if found, otherwise undefined.
|
|
155
|
+
* @internal
|
|
156
|
+
*/
|
|
157
|
+
private static _getDescriptorFromPrototype;
|
|
158
|
+
/**
|
|
159
|
+
* Creates a new model instance without persisting it.
|
|
160
|
+
*
|
|
161
|
+
* Wraps the instance in a Proxy to enable dynamic attribute handling.
|
|
162
|
+
*
|
|
163
|
+
* @param attributes - Initial data for the model.
|
|
164
|
+
* @returns A proxied model instance.
|
|
165
|
+
*
|
|
166
|
+
* @example
|
|
167
|
+
* ```typescript
|
|
168
|
+
* const user = User.make({ name: 'Carl' });
|
|
169
|
+
* ```
|
|
170
|
+
*/
|
|
171
|
+
static make<T extends Model>(this: ModelConstructor<T>, attributes?: Partial<ModelAttributes>): T;
|
|
172
|
+
/**
|
|
173
|
+
* Creates and immediately persists a new model instance.
|
|
174
|
+
*
|
|
175
|
+
* @param attributes - Data for the new record.
|
|
176
|
+
* @returns The saved model instance.
|
|
177
|
+
* @throws {DatabaseError} If persistence fails.
|
|
178
|
+
*
|
|
179
|
+
* @example
|
|
180
|
+
* ```typescript
|
|
181
|
+
* const user = await User.create({ name: 'Carl' });
|
|
182
|
+
* ```
|
|
183
|
+
*/
|
|
184
|
+
static create<T extends Model>(this: ModelConstructor<T>, attributes?: Partial<ModelAttributes>): Promise<T>;
|
|
185
|
+
/**
|
|
186
|
+
* Initializes a model instance from existing database data.
|
|
187
|
+
*
|
|
188
|
+
* Marks the model as existing and synchronizes the dirty tracker.
|
|
189
|
+
* Triggers the 'retrieved' event.
|
|
190
|
+
*
|
|
191
|
+
* @param row - Raw data retrieved from the database.
|
|
192
|
+
* @returns A proxied model instance ready for updates.
|
|
193
|
+
*
|
|
194
|
+
* @example
|
|
195
|
+
* ```typescript
|
|
196
|
+
* const user = User.hydrate(dbRow);
|
|
197
|
+
* ```
|
|
198
|
+
*/
|
|
199
|
+
static hydrate<T extends Model>(this: ModelConstructor<T>, row: ModelAttributes): T;
|
|
200
|
+
/**
|
|
201
|
+
* Configures the Proxy wrapper for the model instance.
|
|
202
|
+
*
|
|
203
|
+
* Implements the Smart Guard pattern to route property access to attributes,
|
|
204
|
+
* relations, methods, or accessors based on priority.
|
|
205
|
+
*
|
|
206
|
+
* @param attributes - Initial attribute values.
|
|
207
|
+
* @param exists - Whether the model exists in the database.
|
|
208
|
+
* @returns The proxied instance.
|
|
209
|
+
* @internal
|
|
210
|
+
*/
|
|
211
|
+
protected _createProxy<T extends Model>(this: T, attributes: Partial<ModelAttributes>, exists: boolean): T;
|
|
212
|
+
/**
|
|
213
|
+
* Sets an attribute value and marks it as dirty.
|
|
214
|
+
*
|
|
215
|
+
* Applies type casting automatically if defined in the model.
|
|
216
|
+
*
|
|
217
|
+
* @param key - The attribute name.
|
|
218
|
+
* @param value - The value to set.
|
|
219
|
+
* @internal
|
|
220
|
+
*/
|
|
221
|
+
protected _setAttribute(key: string, value: unknown): void;
|
|
222
|
+
/**
|
|
223
|
+
* Validates an attribute against the database schema.
|
|
224
|
+
*
|
|
225
|
+
* Performs nullability checks and type matching.
|
|
226
|
+
*
|
|
227
|
+
* @param key - The column name.
|
|
228
|
+
* @param value - The value to validate.
|
|
229
|
+
* @throws {ColumnNotFoundError} If the column does not exist in strict mode.
|
|
230
|
+
* @throws {NullableConstraintError} If a non-nullable column is set to null.
|
|
231
|
+
* @throws {TypeMismatchError} If the value type does not match schema requirements.
|
|
232
|
+
* @internal
|
|
233
|
+
*/
|
|
234
|
+
protected _validateAttribute(key: string, value: unknown): Promise<void>;
|
|
235
|
+
/**
|
|
236
|
+
* Determines the logical JavaScript type of a value.
|
|
237
|
+
*
|
|
238
|
+
* Distinguishes between null, array, date, and basic types.
|
|
239
|
+
*
|
|
240
|
+
* @param value - The value to inspect.
|
|
241
|
+
* @returns A string representing the type.
|
|
242
|
+
*/
|
|
243
|
+
private _getJSType;
|
|
244
|
+
/**
|
|
245
|
+
* Casts a raw value to the specified model type.
|
|
246
|
+
*
|
|
247
|
+
* @param _key - The attribute key (reserved for future use).
|
|
248
|
+
* @param value - The raw value.
|
|
249
|
+
* @param type - The target type identifier.
|
|
250
|
+
* @returns The casted value.
|
|
251
|
+
*/
|
|
252
|
+
private _castAttribute;
|
|
253
|
+
/**
|
|
254
|
+
* Maps database column types to valid JavaScript types.
|
|
255
|
+
*
|
|
256
|
+
* @param columnType - The database-level type.
|
|
257
|
+
* @returns An array of acceptable JavaScript types.
|
|
258
|
+
*/
|
|
259
|
+
private _getExpectedJSTypes;
|
|
260
|
+
/**
|
|
261
|
+
* Resolves the primary table name for the model.
|
|
262
|
+
*
|
|
263
|
+
* @returns The table name string.
|
|
264
|
+
* @throws {Error} If no table is defined on the class.
|
|
265
|
+
*/
|
|
266
|
+
static getTable(): string;
|
|
267
|
+
/**
|
|
268
|
+
* Fetches the table schema from the registry.
|
|
269
|
+
*
|
|
270
|
+
* Includes protection against race conditions for concurrent schema lookups.
|
|
271
|
+
*
|
|
272
|
+
* @returns The table schema metadata.
|
|
273
|
+
* @internal
|
|
274
|
+
*/
|
|
275
|
+
protected _getSchema(): Promise<TableSchema>;
|
|
276
|
+
/**
|
|
277
|
+
* Indicates if any model attributes have changed since the last sync.
|
|
278
|
+
*/
|
|
279
|
+
get isDirty(): boolean;
|
|
280
|
+
/**
|
|
281
|
+
* Retrieves a record of attributes that have been modified.
|
|
282
|
+
*
|
|
283
|
+
* @returns An object containing only modified keys and their current values.
|
|
284
|
+
*/
|
|
285
|
+
getDirty(): Partial<ModelAttributes>;
|
|
286
|
+
/**
|
|
287
|
+
* Retrieves the original values of the model attributes.
|
|
288
|
+
*
|
|
289
|
+
* @returns The attributes as they were when last synchronized with the database.
|
|
290
|
+
*/
|
|
291
|
+
getOriginal(): Partial<ModelAttributes>;
|
|
292
|
+
/**
|
|
293
|
+
* Retrieves the value of the primary key for this instance.
|
|
294
|
+
*
|
|
295
|
+
* @returns The primary key value.
|
|
296
|
+
*/
|
|
297
|
+
getKey(): unknown;
|
|
298
|
+
/**
|
|
299
|
+
* Executes a query to find the first matching record.
|
|
300
|
+
*
|
|
301
|
+
* @returns The first model instance found, or null.
|
|
302
|
+
*
|
|
303
|
+
* @example
|
|
304
|
+
* ```typescript
|
|
305
|
+
* const user = await User.where('active', true).first();
|
|
306
|
+
* ```
|
|
307
|
+
*/
|
|
308
|
+
static first<T extends Model>(this: ModelConstructor<T> & typeof Model): Promise<T | null>;
|
|
309
|
+
/**
|
|
310
|
+
* Finds a record by its primary key.
|
|
311
|
+
*
|
|
312
|
+
* @param key - The primary key value.
|
|
313
|
+
* @returns The matching model instance, or null.
|
|
314
|
+
*
|
|
315
|
+
* @example
|
|
316
|
+
* ```typescript
|
|
317
|
+
* const user = await User.find(1);
|
|
318
|
+
* ```
|
|
319
|
+
*/
|
|
320
|
+
static find<T extends Model>(this: ModelConstructor<T> & typeof Model, key: unknown): Promise<T | null>;
|
|
321
|
+
/**
|
|
322
|
+
* Finds a record by its primary key or throws an error if not found.
|
|
323
|
+
*
|
|
324
|
+
* @param key - The primary key value.
|
|
325
|
+
* @returns The matching model instance.
|
|
326
|
+
* @throws {ModelNotFoundError} If no record matches the key.
|
|
327
|
+
*
|
|
328
|
+
* @example
|
|
329
|
+
* ```typescript
|
|
330
|
+
* const user = await User.findOrFail(1);
|
|
331
|
+
* ```
|
|
332
|
+
*/
|
|
333
|
+
static findOrFail<T extends Model>(this: ModelConstructor<T> & typeof Model, key: unknown): Promise<T>;
|
|
334
|
+
/**
|
|
335
|
+
* Retrieves all records for the model.
|
|
336
|
+
*
|
|
337
|
+
* Includes an automatic safety limit of 1000 records.
|
|
338
|
+
* Use `cursor()` or `lazyAll()` for larger datasets.
|
|
339
|
+
*
|
|
340
|
+
* @returns An array of model instances.
|
|
341
|
+
*/
|
|
342
|
+
static all<T extends Model>(this: ModelConstructor<T> & typeof Model): Promise<T[]>;
|
|
343
|
+
/**
|
|
344
|
+
* Alias for {@link create}.
|
|
345
|
+
*/
|
|
346
|
+
static createAndSave<T extends Model>(this: ModelConstructor<T> & typeof Model, attributes: Partial<ModelAttributes>): Promise<T>;
|
|
347
|
+
/**
|
|
348
|
+
* Iterates through all records using memory-efficient lazy hydration.
|
|
349
|
+
*
|
|
350
|
+
* Returns an async generator that yields chunks of raw data.
|
|
351
|
+
* Models are only instantiated when explicitly needed.
|
|
352
|
+
*
|
|
353
|
+
* @param chunkSize - Number of records to fetch per iteration.
|
|
354
|
+
* @yields Chunks of raw attribute objects.
|
|
355
|
+
*
|
|
356
|
+
* @example
|
|
357
|
+
* ```typescript
|
|
358
|
+
* for await (const chunk of User.lazyAll(500)) {
|
|
359
|
+
* // process chunk
|
|
360
|
+
* }
|
|
361
|
+
* ```
|
|
362
|
+
*/
|
|
363
|
+
static lazyAll<T extends Model>(this: ModelConstructor<T> & typeof Model, chunkSize?: number): AsyncGenerator<ModelAttributes[], void, unknown>;
|
|
364
|
+
/**
|
|
365
|
+
* Iterates through records using a cursor-based approach.
|
|
366
|
+
*
|
|
367
|
+
* Yields chunks of hydrated model instances. Memory-safe for large tables.
|
|
368
|
+
*
|
|
369
|
+
* @param chunkSize - Number of models per chunk.
|
|
370
|
+
* @yields Chunks of model instances.
|
|
371
|
+
*/
|
|
372
|
+
static cursor<T extends Model>(this: ModelConstructor<T> & typeof Model, chunkSize?: number): AsyncGenerator<T[], void, unknown>;
|
|
373
|
+
/**
|
|
374
|
+
* Initializes a fluent query builder for the model.
|
|
375
|
+
*
|
|
376
|
+
* Automatically handles model hydration, soft delete filtering, and scope application.
|
|
377
|
+
*
|
|
378
|
+
* @returns A proxied query builder instance.
|
|
379
|
+
*
|
|
380
|
+
* @example
|
|
381
|
+
* ```typescript
|
|
382
|
+
* const users = await User.query().where('active', true).get();
|
|
383
|
+
* ```
|
|
384
|
+
*/
|
|
385
|
+
static query<T extends Model>(this: ModelConstructor<T> & typeof Model): QueryBuilderContract<T>;
|
|
386
|
+
/**
|
|
387
|
+
* Starts a query with a standard WHERE clause.
|
|
388
|
+
*
|
|
389
|
+
* @param column - Column name or an object of key-value pairs.
|
|
390
|
+
* @param operatorOrValue - Comparison operator or the value.
|
|
391
|
+
* @param value - Comparison value (if operator is specified).
|
|
392
|
+
* @returns The query builder.
|
|
393
|
+
*/
|
|
394
|
+
static where<T extends Model>(this: ModelConstructor<T> & typeof Model, column: string | Record<string, unknown>, operatorOrValue?: Operator | unknown, value?: unknown): QueryBuilderContract<T>;
|
|
395
|
+
/**
|
|
396
|
+
* Starts a query with a WHERE IN clause.
|
|
397
|
+
*/
|
|
398
|
+
static whereIn<T extends Model>(this: ModelConstructor<T> & typeof Model, column: string, values: unknown[]): QueryBuilderContract<T>;
|
|
399
|
+
/**
|
|
400
|
+
* Starts a query with a WHERE NULL clause.
|
|
401
|
+
*/
|
|
402
|
+
static whereNull<T extends Model>(this: ModelConstructor<T> & typeof Model, column: string): QueryBuilderContract<T>;
|
|
403
|
+
/**
|
|
404
|
+
* Starts a query with a WHERE NOT NULL clause.
|
|
405
|
+
*/
|
|
406
|
+
static whereNotNull<T extends Model>(this: ModelConstructor<T> & typeof Model, column: string): QueryBuilderContract<T>;
|
|
407
|
+
/**
|
|
408
|
+
* Configures query results ordering.
|
|
409
|
+
*/
|
|
410
|
+
static orderBy<T extends Model>(this: ModelConstructor<T> & typeof Model, column: string, direction?: 'asc' | 'desc'): QueryBuilderContract<T>;
|
|
411
|
+
/**
|
|
412
|
+
* Sets a limit on the number of returned records.
|
|
413
|
+
*/
|
|
414
|
+
static limit<T extends Model>(this: ModelConstructor<T> & typeof Model, value: number): QueryBuilderContract<T>;
|
|
415
|
+
/**
|
|
416
|
+
* Sets the number of records to skip.
|
|
417
|
+
*/
|
|
418
|
+
static offset<T extends Model>(this: ModelConstructor<T> & typeof Model, value: number): QueryBuilderContract<T>;
|
|
419
|
+
/**
|
|
420
|
+
* Specifies the columns to retrieve.
|
|
421
|
+
*/
|
|
422
|
+
static select<T extends Model>(this: ModelConstructor<T> & typeof Model, ...columns: string[]): QueryBuilderContract<T>;
|
|
423
|
+
/**
|
|
424
|
+
* Configures eager loading for relationships.
|
|
425
|
+
*
|
|
426
|
+
* @param relation - The name of the relation or an array/object of relations.
|
|
427
|
+
*/
|
|
428
|
+
static with<T extends Model>(this: ModelConstructor<T> & typeof Model, relation: string | string[] | Record<string, (query: QueryBuilderContract<any>) => void>): QueryBuilderContract<T>;
|
|
429
|
+
/**
|
|
430
|
+
* Orders results by the creation timestamp in descending order.
|
|
431
|
+
*/
|
|
432
|
+
static latest<T extends Model>(this: ModelConstructor<T> & typeof Model, column?: string): QueryBuilderContract<T>;
|
|
433
|
+
/**
|
|
434
|
+
* Orders results by the creation timestamp in ascending order.
|
|
435
|
+
*/
|
|
436
|
+
static oldest<T extends Model>(this: ModelConstructor<T> & typeof Model, column?: string): QueryBuilderContract<T>;
|
|
437
|
+
/**
|
|
438
|
+
* Initializes a factory instance for model seeding and testing.
|
|
439
|
+
*/
|
|
440
|
+
static factory<T extends Model>(this: ModelConstructor<T> & typeof Model, count?: number): Factory<any>;
|
|
441
|
+
/**
|
|
442
|
+
* Counts the number of records matching the current state.
|
|
443
|
+
*/
|
|
444
|
+
static count(this: ModelConstructor<Model> & typeof Model): Promise<number>;
|
|
445
|
+
/**
|
|
446
|
+
* Checks if any records exist matching the current state.
|
|
447
|
+
*/
|
|
448
|
+
static exists(this: ModelConstructor<Model> & typeof Model): Promise<boolean>;
|
|
449
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Model } from './Model';
|
|
2
|
+
/**
|
|
3
|
+
* Model Registry for Polymorphic Relations
|
|
4
|
+
* Maps string type names (e.g., 'Post') to Model classes
|
|
5
|
+
*/
|
|
6
|
+
export declare class ModelRegistry {
|
|
7
|
+
private static models;
|
|
8
|
+
/**
|
|
9
|
+
* Register a model class
|
|
10
|
+
*/
|
|
11
|
+
static register(model: typeof Model): void;
|
|
12
|
+
/**
|
|
13
|
+
* Get a model class by name
|
|
14
|
+
*/
|
|
15
|
+
static get(name: string): typeof Model | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Clear all registered models
|
|
18
|
+
*/
|
|
19
|
+
static clear(): void;
|
|
20
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import type { ColumnType, TableSchema } from '../../schema/types';
|
|
2
|
+
import { DirtyTracker } from '../DirtyTracker';
|
|
3
|
+
export type ModelAttributes = Record<string, unknown>;
|
|
4
|
+
/**
|
|
5
|
+
* HasAttributes Concern
|
|
6
|
+
* @description Provides attribute management functionality including getting/setting, casting, and dirty tracking.
|
|
7
|
+
*/
|
|
8
|
+
export declare class HasAttributes {
|
|
9
|
+
/**
|
|
10
|
+
* Model attributes storage
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
protected _attributes: ModelAttributes;
|
|
14
|
+
/**
|
|
15
|
+
* Dirty tracker instance
|
|
16
|
+
* @internal
|
|
17
|
+
*/
|
|
18
|
+
protected _dirtyTracker: DirtyTracker<ModelAttributes>;
|
|
19
|
+
/**
|
|
20
|
+
* Cached table schema
|
|
21
|
+
* @internal
|
|
22
|
+
*/
|
|
23
|
+
protected _schema?: TableSchema;
|
|
24
|
+
constructor();
|
|
25
|
+
/**
|
|
26
|
+
* Get an attribute value from the model.
|
|
27
|
+
*
|
|
28
|
+
* @param key - The attribute name to retrieve
|
|
29
|
+
* @returns The raw attribute value
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```typescript
|
|
33
|
+
* const name = user.getAttribute('name')
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
getAttribute(key: string): unknown;
|
|
37
|
+
/**
|
|
38
|
+
* Set an attribute value on the model with automatic casting.
|
|
39
|
+
*
|
|
40
|
+
* @param key - The attribute name to set
|
|
41
|
+
* @param value - The value to assign
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```typescript
|
|
45
|
+
* user.setAttribute('email', 'carl@example.com')
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
setAttribute(key: string, value: unknown): void;
|
|
49
|
+
/**
|
|
50
|
+
* Fill the model with an object of attributes.
|
|
51
|
+
*
|
|
52
|
+
* @param attributes - Key-value pairs of attributes to set
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```typescript
|
|
56
|
+
* user.fill({ name: 'Carl', email: 'carl@example.com' })
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
fill(attributes: Partial<ModelAttributes>): void;
|
|
60
|
+
/**
|
|
61
|
+
* Get all attributes currently set on the model.
|
|
62
|
+
*
|
|
63
|
+
* @returns A shallow copy of the model's attributes
|
|
64
|
+
*/
|
|
65
|
+
getAttributes(): Partial<ModelAttributes>;
|
|
66
|
+
/**
|
|
67
|
+
* Get only the attributes that have been modified since the last sync.
|
|
68
|
+
*
|
|
69
|
+
* @returns An object containing only modified attributes and their current values
|
|
70
|
+
*/
|
|
71
|
+
getDirtyAttributes(): Partial<ModelAttributes>;
|
|
72
|
+
/**
|
|
73
|
+
* Get the original value of an attribute before it was modified.
|
|
74
|
+
*
|
|
75
|
+
* @param key - The attribute name
|
|
76
|
+
* @returns The original value from the last sync
|
|
77
|
+
*/
|
|
78
|
+
getOriginal(key: string): unknown;
|
|
79
|
+
/**
|
|
80
|
+
* Check if an attribute (or the entire model) has been modified.
|
|
81
|
+
*
|
|
82
|
+
* @param key - Optional attribute name to check specifically
|
|
83
|
+
* @returns True if the attribute or model is dirty
|
|
84
|
+
*/
|
|
85
|
+
isDirty(key?: string): boolean;
|
|
86
|
+
/**
|
|
87
|
+
* Check if the model has no modified attributes.
|
|
88
|
+
*
|
|
89
|
+
* @returns True if the model is clean
|
|
90
|
+
*/
|
|
91
|
+
isClean(): boolean;
|
|
92
|
+
/**
|
|
93
|
+
* Determine the JavaScript type of a given value.
|
|
94
|
+
*
|
|
95
|
+
* @param value - The value to inspect
|
|
96
|
+
* @returns A string representing the JS type (e.g., 'null', 'array', 'date', 'string')
|
|
97
|
+
* @internal
|
|
98
|
+
*/
|
|
99
|
+
protected _getJSType(value: unknown): string;
|
|
100
|
+
/**
|
|
101
|
+
* Cast an attribute value to a specific type.
|
|
102
|
+
*
|
|
103
|
+
* @param _key - The attribute name (reserved for future use)
|
|
104
|
+
* @param value - The value to cast
|
|
105
|
+
* @param type - The target type (e.g., 'integer', 'boolean', 'json', 'date')
|
|
106
|
+
* @returns The casted value
|
|
107
|
+
* @internal
|
|
108
|
+
*/
|
|
109
|
+
protected _castAttribute(_key: string, value: unknown, type: string): unknown;
|
|
110
|
+
/**
|
|
111
|
+
* Get the expected JavaScript types for a given database column type.
|
|
112
|
+
*
|
|
113
|
+
* @param columnType - The database column type
|
|
114
|
+
* @returns An array of valid JavaScript type strings
|
|
115
|
+
* @internal
|
|
116
|
+
*/
|
|
117
|
+
protected _getExpectedJSTypes(columnType: ColumnType): string[];
|
|
118
|
+
/**
|
|
119
|
+
* Retrieve the table schema for the model.
|
|
120
|
+
*
|
|
121
|
+
* @returns A promise that resolves to the table schema
|
|
122
|
+
* @internal
|
|
123
|
+
*/
|
|
124
|
+
protected _getSchema(): Promise<TableSchema>;
|
|
125
|
+
/**
|
|
126
|
+
* Validate an attribute value against the table schema.
|
|
127
|
+
*
|
|
128
|
+
* @param key - The attribute name to validate
|
|
129
|
+
* @param value - The value to check
|
|
130
|
+
* @throws {ColumnNotFoundError} If the column does not exist in strict mode
|
|
131
|
+
* @throws {NullableConstraintError} If a non-nullable column is set to null
|
|
132
|
+
* @throws {TypeMismatchError} If the value type does not match the column type
|
|
133
|
+
* @internal
|
|
134
|
+
*/
|
|
135
|
+
protected _validateAttribute(key: string, value: unknown): Promise<void>;
|
|
136
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { Model } from '../Model';
|
|
2
|
+
import type { ModelObserver } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* HasEvents Concern
|
|
5
|
+
* @description Provides event system functionality including model lifecycle events and observer registration.
|
|
6
|
+
*/
|
|
7
|
+
export declare class HasEvents {
|
|
8
|
+
/**
|
|
9
|
+
* Register a model observer to listen for lifecycle events.
|
|
10
|
+
*
|
|
11
|
+
* @template T - The model type
|
|
12
|
+
* @param observer - An object containing lifecycle event handlers
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* User.observe({
|
|
17
|
+
* creating: (user) => { user.api_token = Str.random() }
|
|
18
|
+
* })
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
static observe<T extends Model>(observer: Partial<ModelObserver<T>>): void;
|
|
22
|
+
/**
|
|
23
|
+
* Fire a static event that doesn't require a model instance.
|
|
24
|
+
*
|
|
25
|
+
* @param event - The name of the event to fire
|
|
26
|
+
* @internal
|
|
27
|
+
*/
|
|
28
|
+
static fire(event: string): Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* Emit a lifecycle event to instance hooks and registered observers.
|
|
31
|
+
*
|
|
32
|
+
* @param event - The event name
|
|
33
|
+
* @internal
|
|
34
|
+
*/
|
|
35
|
+
protected emit(event: string): Promise<void>;
|
|
36
|
+
}
|