@orieljs/database 0.1.0-alpha.4 → 0.1.0-alpha.6

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/NOTICE CHANGED
@@ -7,3 +7,6 @@ This product includes software developed by the Oriel project
7
7
  Oriel is licensed under the Apache License, Version 2.0 (see LICENSE).
8
8
  The Oriel name and logo are not covered by that license; see TRADEMARKS.md
9
9
  (https://github.com/orieljs/framework/blob/main/TRADEMARKS.md).
10
+
11
+ @orieljs/support (and @orieljs/framework, which bundles it) includes transliteration data from
12
+ voku/portable-ascii (https://github.com/voku/portable-ascii), Copyright (C) 2019 Lars Moelleken, MIT License.
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { OrielError, ModelNotFoundError as ModelNotFoundError$1, DriverName, DatabaseConnection, Row, QueryBuilder, Operator, DatabaseManager, Token, ModelInstance, Application, ConsoleKernel, RouteModelResolver, Class } from '@orieljs/contracts';
1
+ import { OrielError, ModelNotFoundError as ModelNotFoundError$1, DriverName, DatabaseConnection, Row, QueryBuilder, Operator, DatabaseManager, Token, ModelInstance, DatabaseNotification as DatabaseNotification$1, Application, ConsoleKernel, RouteModelResolver, Class } from '@orieljs/contracts';
2
2
  import { SqliteDatabase, SqliteStatement, Dialect, RawBuilder, Kysely, CompiledQuery, QueryResult } from 'kysely';
3
3
  import { Collection, LazyCollection } from '@orieljs/collections';
4
4
  import * as _orieljs_support from '@orieljs/support';
@@ -595,8 +595,11 @@ declare abstract class AbstractPaginator<T> implements Iterable<T> {
595
595
  items(): T[];
596
596
  getCollection(): Collection<T>;
597
597
  setCollection(items: Collection<T>): this;
598
- /** Transforms each item in place, typically for serialization: paginator.through(post => ({ id: post.id })). */
599
- through(callback: (item: T, index: number) => unknown): this;
598
+ /**
599
+ * Transforms each item in place, typically for serialization, and returns this paginator typed with the new items:
600
+ * `posts.through((post) => ({ id: post.id }))`. Each paginator narrows the return type to its own class.
601
+ */
602
+ through<U>(callback: (item: T, index: number) => U): AbstractPaginator<U>;
600
603
  perPage(): number;
601
604
  count(): number;
602
605
  isEmpty(): boolean;
@@ -642,6 +645,7 @@ declare class CursorPaginator<T> extends AbstractPaginator<T> {
642
645
  static resolveCurrentCursor(cursorName?: string): Cursor | undefined;
643
646
  cursor(): Cursor | undefined;
644
647
  getCursorName(): string;
648
+ through<U>(callback: (item: T, index: number) => U): CursorPaginator<U>;
645
649
  hasMorePages(): boolean;
646
650
  onFirstPage(): boolean;
647
651
  nextCursor(): Cursor | undefined;
@@ -671,12 +675,16 @@ declare class LengthAwarePaginator<T> extends AbstractPaginator<T> {
671
675
  protected readonly lastPageValue: number;
672
676
  constructor(items: Iterable<T>, totalValue: number, perPage: number, currentPage?: number, options?: PaginatorOptions);
673
677
  total(): number;
678
+ through<U>(callback: (item: T, index: number) => U): LengthAwarePaginator<U>;
674
679
  lastPage(): number;
675
680
  hasPages(): boolean;
676
681
  hasMorePages(): boolean;
677
682
  onLastPage(): boolean;
678
683
  nextPageUrl(): string | null;
679
- /** The page links Laravel renders: previous, the page window with '...' gaps, next. */
684
+ /**
685
+ * The page links Laravel renders: previous, the page window with '...' gaps, next. The labels are plain text
686
+ * ("« Previous", "Next »"), not Laravel's `&laquo;` entities, so a page can print them as text.
687
+ */
680
688
  linkCollection(): PaginationLink[];
681
689
  /** Laravel's UrlWindow: the first pages, the slider around the current page and the last pages, with '...' between. */
682
690
  protected elements(): Array<UrlRange | '...'>;
@@ -693,6 +701,7 @@ declare class Paginator<T> extends AbstractPaginator<T> {
693
701
  protected readonly hasMore: boolean;
694
702
  constructor(items: Iterable<T>, perPage: number, currentPage?: number, options?: PaginatorOptions);
695
703
  hasMorePages(): boolean;
704
+ through<U>(callback: (item: T, index: number) => U): Paginator<U>;
696
705
  hasPages(): boolean;
697
706
  onLastPage(): boolean;
698
707
  nextPageUrl(): string | null;
@@ -723,6 +732,13 @@ declare class Grammar {
723
732
  compileOrders(query: Builder$1<unknown>): Sql | undefined;
724
733
  compileWheres(wheres: readonly Where[], keyword?: 'where' | 'on'): Sql | undefined;
725
734
  compileWhere(where: Where): Sql;
735
+ /**
736
+ * whereLike() per driver, as Laravel 12's grammars: Postgres compares the column as text with ilike (like when
737
+ * case-sensitive); MySQL uses like (like binary); SQLite uses like, or glob with the pattern translated.
738
+ */
739
+ compileWhereLike(where: Extract<Where, {
740
+ type: 'like';
741
+ }>): Sql;
726
742
  compileJoin(joinClause: JoinClause): Sql;
727
743
  compileHavings(havings: readonly Having[]): Sql | undefined;
728
744
  compileLimitOffset(limit: number | undefined, offset: number | undefined): Sql | undefined;
@@ -770,6 +786,13 @@ type Where = {
770
786
  values: readonly [unknown, unknown];
771
787
  not: boolean;
772
788
  boolean: WhereBoolean;
789
+ } | {
790
+ type: 'like';
791
+ column: ColumnRef;
792
+ value: string;
793
+ caseSensitive: boolean;
794
+ not: boolean;
795
+ boolean: WhereBoolean;
773
796
  } | {
774
797
  type: 'column';
775
798
  first: ColumnRef;
@@ -812,6 +835,8 @@ type SelectColumn = ColumnRef | {
812
835
  as: string;
813
836
  };
814
837
  type NestedCallback<Q> = (query: Q) => unknown;
838
+ /** The value when()'s callback receives: the condition's type without its falsy members. */
839
+ type Truthy<V> = Exclude<V, false | 0 | 0n | '' | null | undefined>;
815
840
  /** The key a selected column comes back under: 'users.name' → 'name', 'name as n' → 'n'. */
816
841
  declare function columnKey(column: string): string;
817
842
  /**
@@ -862,6 +887,16 @@ declare class Builder$1<T = Row> implements QueryBuilder<T> {
862
887
  whereBetween(column: ColumnRef, values: readonly [unknown, unknown]): this;
863
888
  orWhereBetween(column: ColumnRef, values: readonly [unknown, unknown]): this;
864
889
  whereNotBetween(column: ColumnRef, values: readonly [unknown, unknown]): this;
890
+ /**
891
+ * Laravel's whereLike(): the value is the pattern, `%` and `_` included (`whereLike('title', `%${term}%`)`).
892
+ * Case-insensitive unless caseSensitive: ilike on Postgres, like on MySQL and SQLite (their like already ignores
893
+ * case: MySQL through the column's collation, SQLite for ASCII letters). Case-sensitive is like on Postgres,
894
+ * like binary on MySQL and glob on SQLite.
895
+ */
896
+ whereLike(column: ColumnRef, value: string, caseSensitive?: boolean, boolean?: WhereBoolean, not?: boolean): this;
897
+ orWhereLike(column: ColumnRef, value: string, caseSensitive?: boolean): this;
898
+ whereNotLike(column: ColumnRef, value: string, caseSensitive?: boolean, boolean?: WhereBoolean): this;
899
+ orWhereNotLike(column: ColumnRef, value: string, caseSensitive?: boolean): this;
865
900
  /** Compares two columns: whereColumn('updated_at', '>', 'created_at'). */
866
901
  whereColumn(first: ColumnRef, operatorOrSecond: string, second?: ColumnRef, boolean?: WhereBoolean): this;
867
902
  orWhereColumn(first: ColumnRef, operatorOrSecond: string, second?: ColumnRef): this;
@@ -896,8 +931,20 @@ declare class Builder$1<T = Row> implements QueryBuilder<T> {
896
931
  forPage(page: number, perPage?: number): this;
897
932
  lockForUpdate(): this;
898
933
  sharedLock(): this;
899
- /** Calls callback(this, value) when value is truthy (or the default callback otherwise). */
900
- when<V>(value: V, callback: (query: this, value: V) => unknown, otherwise?: (query: this, value: V) => unknown): this;
934
+ /**
935
+ * Laravel's when(): callback(query, value) runs when the value is truthy, otherwise(query, value) when it is falsy.
936
+ * A function value is called with the query first and its result is the value. Truthiness is JavaScript's, so `'0'`
937
+ * and `[]` are truthy: a `?active=0` filter applies, where Laravel would skip it. Returns the query; what the
938
+ * callbacks return is ignored.
939
+ *
940
+ * @example
941
+ * Post.query().when(request.query('q'), (query, q) => query.whereLike('title', `%${q}%`))
942
+ */
943
+ when<V>(value: (query: this) => V, callback: (query: this, value: Truthy<V>) => unknown, otherwise?: (query: this, value: V) => unknown): this;
944
+ when<V>(value: V, callback: (query: this, value: Truthy<V>) => unknown, otherwise?: (query: this, value: V) => unknown): this;
945
+ /** Laravel's unless(): when() with the condition reversed. callback(query, value) runs when the value is falsy. */
946
+ unless<V>(value: (query: this) => V, callback: (query: this, value: V) => unknown, otherwise?: (query: this, value: Truthy<V>) => unknown): this;
947
+ unless<V>(value: V, callback: (query: this, value: V) => unknown, otherwise?: (query: this, value: Truthy<V>) => unknown): this;
901
948
  tap(callback: (query: this) => unknown): this;
902
949
  get(): Promise<Collection<T>>;
903
950
  /** The raw rows, without a Collection around them. */
@@ -1218,6 +1265,10 @@ declare class Builder<M extends Model = Model> extends Builder$1<M> {
1218
1265
  whereNull(columns: Column<M> | Expression | Array<Column<M> | Expression>): this;
1219
1266
  whereNotNull(columns: Column<M> | Expression | Array<Column<M> | Expression>): this;
1220
1267
  whereBetween(column: Column<M> | Expression, values: readonly [unknown, unknown]): this;
1268
+ whereLike(column: Column<M> | Expression, value: string, caseSensitive?: boolean, boolean?: WhereBoolean, not?: boolean): this;
1269
+ orWhereLike(column: Column<M> | Expression, value: string, caseSensitive?: boolean): this;
1270
+ whereNotLike(column: Column<M> | Expression, value: string, caseSensitive?: boolean, boolean?: WhereBoolean): this;
1271
+ orWhereNotLike(column: Column<M> | Expression, value: string, caseSensitive?: boolean): this;
1221
1272
  orderBy(column: Column<M> | Expression, direction?: Direction | Uppercase<Direction>): this;
1222
1273
  /** Newest first by the model's created_at column (or the given one). */
1223
1274
  latest(column?: Column<M> | Expression): this;
@@ -1270,6 +1321,9 @@ declare class Builder<M extends Model = Model> extends Builder$1<M> {
1270
1321
  exists(): Promise<boolean>;
1271
1322
  /** The column's values, through the model's casts and accessors. */
1272
1323
  pluck<V = unknown>(column: Column<M>): Promise<Collection<V>>;
1324
+ /** Whether `id` can't be one of the model's unique ids (not a UUID for HasUuids): it matches no row. */
1325
+ protected isMalformedKey(id: unknown): boolean;
1326
+ /** A malformed unique id (HasUuids, HasUlids) finds nothing without a query, as route model binding does. */
1273
1327
  find(id: unknown): Promise<M | undefined>;
1274
1328
  findMany(ids: readonly unknown[]): Promise<Collection<M>>;
1275
1329
  /** find(), or ModelNotFoundError (a 404). With an array, every id must exist. */
@@ -1569,6 +1623,8 @@ declare abstract class HasOneOrMany<R extends Model, P extends Model, Result> ex
1569
1623
  readonly foreignKey: string;
1570
1624
  readonly localKey: string;
1571
1625
  readonly morph?: MorphConstraint | undefined;
1626
+ /** The relation on each related model that chaperone() points back at the parent. */
1627
+ protected inverseRelationship: string | undefined;
1572
1628
  /**
1573
1629
  * @param foreignKey the qualified foreign key on the related table ('comments.post_id')
1574
1630
  * @param localKey the key on the parent it points at ('id')
@@ -1584,6 +1640,26 @@ declare abstract class HasOneOrMany<R extends Model, P extends Model, Result> ex
1584
1640
  getMorphType(): string | undefined;
1585
1641
  /** The parent's value in the type column, for a morph relation. */
1586
1642
  getMorphClass(): string | undefined;
1643
+ /**
1644
+ * Laravel's chaperone(): every related model this relation loads, eagerly or lazily, or makes, gets the parent as
1645
+ * its `relation` (guessed when not given: post_id → post, the parent's class, owner), so reading it needs no query:
1646
+ * `comments() { return this.hasMany(Comment).chaperone() }`.
1647
+ */
1648
+ chaperone(relation?: string): this;
1649
+ /** Laravel's inverse(): chaperone() under its other name. */
1650
+ inverse(relation?: string): this;
1651
+ withoutChaperone(): this;
1652
+ withoutInverse(): this;
1653
+ getInverseRelationship(): string | undefined;
1654
+ /** The first of the possible names that is a relation of the related model. */
1655
+ protected guessInverseRelation(): string | undefined;
1656
+ /** Laravel's candidates: the morph name, the foreign key without the parent's key, the parent's class, owner, parent. */
1657
+ protected getPossibleInverseRelations(): string[];
1658
+ /** Sets the parent on a related model, when chaperone() named the relation. */
1659
+ protected applyInverseRelationToModel<M extends R | null | undefined>(model: M, parent?: P): M;
1660
+ protected applyInverseRelationToMany(models: R[], parent?: P): R[];
1661
+ /** The relation query's rows (get(), first(), paginate(), …), pointing back at the parent with chaperone(). */
1662
+ runSelect(): Promise<R[]>;
1587
1663
  addConstraints(): void;
1588
1664
  addEagerConstraints(models: P[]): void;
1589
1665
  /** Related models grouped by their foreign key, as strings: bigint and integer keys compare equal. */
@@ -1803,12 +1879,21 @@ declare class Model implements ModelInstance {
1803
1879
  /** A new query of this model, with its global scopes. */
1804
1880
  static query<C extends typeof Model>(this: C): ModelBuilder<C>;
1805
1881
  static where<C extends typeof Model>(this: C, ...args: WhereArgs<Instance<C>, ModelBuilder<C>>): ModelBuilder<C>;
1882
+ /** Post.when(request.query('q'), (query, q) => query.whereLike('title', `%${q}%`)): a new query, then when(). */
1883
+ static when<C extends typeof Model, V>(this: C, value: (query: ModelBuilder<C>) => V, callback: (query: ModelBuilder<C>, value: Truthy<V>) => unknown, otherwise?: (query: ModelBuilder<C>, value: V) => unknown): ModelBuilder<C>;
1884
+ static when<C extends typeof Model, V>(this: C, value: V, callback: (query: ModelBuilder<C>, value: Truthy<V>) => unknown, otherwise?: (query: ModelBuilder<C>, value: V) => unknown): ModelBuilder<C>;
1885
+ /** A new query, then unless(): the callback runs when the value is falsy. */
1886
+ static unless<C extends typeof Model, V>(this: C, value: (query: ModelBuilder<C>) => V, callback: (query: ModelBuilder<C>, value: V) => unknown, otherwise?: (query: ModelBuilder<C>, value: Truthy<V>) => unknown): ModelBuilder<C>;
1887
+ static unless<C extends typeof Model, V>(this: C, value: V, callback: (query: ModelBuilder<C>, value: V) => unknown, otherwise?: (query: ModelBuilder<C>, value: Truthy<V>) => unknown): ModelBuilder<C>;
1806
1888
  static whereKey<C extends typeof Model>(this: C, id: unknown): ModelBuilder<C>;
1807
1889
  static whereIn<C extends typeof Model>(this: C, column: Column<Instance<C>> | Expression, values: readonly unknown[]): ModelBuilder<C>;
1808
1890
  static whereNotIn<C extends typeof Model>(this: C, column: Column<Instance<C>> | Expression, values: readonly unknown[]): ModelBuilder<C>;
1809
1891
  static whereNull<C extends typeof Model>(this: C, column: Column<Instance<C>> | Expression): ModelBuilder<C>;
1810
1892
  static whereNotNull<C extends typeof Model>(this: C, column: Column<Instance<C>> | Expression): ModelBuilder<C>;
1811
1893
  static whereBetween<C extends typeof Model>(this: C, column: Column<Instance<C>> | Expression, values: readonly [unknown, unknown]): ModelBuilder<C>;
1894
+ /** Post.whereLike('title', `%${term}%`): case-insensitive unless caseSensitive (see the query builder's whereLike()). */
1895
+ static whereLike<C extends typeof Model>(this: C, column: Column<Instance<C>> | Expression, value: string, caseSensitive?: boolean): ModelBuilder<C>;
1896
+ static whereNotLike<C extends typeof Model>(this: C, column: Column<Instance<C>> | Expression, value: string, caseSensitive?: boolean): ModelBuilder<C>;
1812
1897
  static whereColumn<C extends typeof Model>(this: C, first: Column<Instance<C>>, operatorOrSecond: string, second?: Column<Instance<C>>): ModelBuilder<C>;
1813
1898
  static whereRaw<C extends typeof Model>(this: C, sql: string, bindings?: readonly unknown[]): ModelBuilder<C>;
1814
1899
  static select<C extends typeof Model>(this: C, ...columns: Array<Column<Instance<C>> | Expression>): ModelBuilder<C>;
@@ -1925,6 +2010,16 @@ declare class Model implements ModelInstance {
1925
2010
  getKeyName(): string;
1926
2011
  getKeyType(): 'int' | 'string';
1927
2012
  getIncrementing(): boolean;
2013
+ /** Whether new rows get unique string ids before `creating` (HasUuids, HasUlids). */
2014
+ usesUniqueIds(): boolean;
2015
+ /** The columns that get a unique id (HasUuids and HasUlids: the primary key). */
2016
+ uniqueIds(): string[];
2017
+ /** A new unique id (HasUuids: a version 7 UUID; HasUlids: a lower-case ULID). */
2018
+ newUniqueId(): string | undefined;
2019
+ /** Whether a value has the shape of this model's unique ids (HasUuids: a UUID). Any value passes by default. */
2020
+ isValidUniqueId(_value: unknown): boolean;
2021
+ /** Fills each empty unique id column with newUniqueId() (Laravel's setUniqueIds()). */
2022
+ setUniqueIds(): void;
1928
2023
  getKey(): unknown;
1929
2024
  getTable(): string;
1930
2025
  getConnectionName(): string | undefined;
@@ -1938,7 +2033,8 @@ declare class Model implements ModelInstance {
1938
2033
  getRouteKey(): unknown;
1939
2034
  /**
1940
2035
  * The model a route parameter value points at: where <field or route key> = value (global scopes apply, so a
1941
- * soft-deleted row isn't found). A non-numeric value for an integer primary key finds nothing without a query.
2036
+ * soft-deleted row isn't found). A non-numeric value for an integer primary key, or a value that isn't a UUID
2037
+ * (ULID) for a unique id column, finds nothing without a query.
1942
2038
  */
1943
2039
  resolveRouteBinding(value: string, field?: string): Promise<this | undefined>;
1944
2040
  /** Override to customize the binding query (Laravel's resolveRouteBindingQuery()). */
@@ -2071,6 +2167,8 @@ declare class Model implements ModelInstance {
2071
2167
  get pivot(): Model | undefined;
2072
2168
  /** A related model instance on this model's connection when it has none of its own. */
2073
2169
  protected newRelatedInstance<C extends typeof Model>(related: C): InstanceType<C>;
2170
+ /** Whether the model has a relation method called `name` (Laravel's isRelation()). */
2171
+ isRelation(name: string): boolean;
2074
2172
  /** Calls the relation method `name` (post.comments()) and checks that it returns a relation. */
2075
2173
  getRelationInstance(name: string): Relation;
2076
2174
  /**
@@ -2102,7 +2200,10 @@ declare class Model implements ModelInstance {
2102
2200
  setAppends(appends: string[]): this;
2103
2201
  /** Adds accessor-only attributes to the serialized form of this instance. */
2104
2202
  append(...attributes: Array<string | string[]>): this;
2105
- /** Attributes (through accessors and casts, dates as ISO strings), appends and loaded relations, minus hidden ones. */
2203
+ /**
2204
+ * Attributes (through accessors and casts, dates as ISO strings), appends and loaded relations, minus hidden ones.
2205
+ * A model met again while its own toArray() runs (a child chaperone() pointed back at it) gives its attributes only.
2206
+ */
2106
2207
  toArray(): Row;
2107
2208
  toJSON(): Row;
2108
2209
  attributesToArray(): Row;
@@ -2121,6 +2222,89 @@ declare class Pivot extends Model {
2121
2222
  timestamps: boolean;
2122
2223
  }
2123
2224
 
2225
+ declare const DatabaseNotification_base: typeof Model;
2226
+ /**
2227
+ * Laravel's DatabaseNotification: one row of the `notifications` table, which the database channel writes. A UUID
2228
+ * string key (HasUuids: a malformed id finds nothing without a query, so it is a 404), `data` as an array cast and
2229
+ * `read_at` as a datetime. `user.notifications()` returns these, newest first.
2230
+ */
2231
+ declare class DatabaseNotification extends DatabaseNotification_base implements DatabaseNotification$1 {
2232
+ protected table: string | undefined;
2233
+ protected keyType: 'int' | 'string';
2234
+ incrementing: boolean;
2235
+ protected guarded: string[];
2236
+ protected casts: Readonly<Record<string, CastDefinition>>;
2237
+ $attributes?: {
2238
+ id: string;
2239
+ type: string;
2240
+ notifiable_type: string;
2241
+ notifiable_id: number | string;
2242
+ data: Record<string, unknown>;
2243
+ read_at: Date | null;
2244
+ created_at: Date | null;
2245
+ updated_at: Date | null;
2246
+ };
2247
+ readonly id: string;
2248
+ readonly type: string;
2249
+ readonly notifiable_type: string;
2250
+ readonly notifiable_id: number | string;
2251
+ readonly data: Record<string, unknown>;
2252
+ read_at: Date | null;
2253
+ readonly created_at: Date | null;
2254
+ readonly updated_at: Date | null;
2255
+ /** The model the notification was sent to. */
2256
+ notifiable<R extends Model = Model>(): MorphTo<R, this>;
2257
+ /** Sets read_at to now and saves, unless it is already read. */
2258
+ markAsRead(): Promise<void>;
2259
+ /** Clears read_at and saves, unless it is already unread. */
2260
+ markAsUnread(): Promise<void>;
2261
+ read(): boolean;
2262
+ unread(): boolean;
2263
+ /** `query.read()`: only read notifications. */
2264
+ static scopeRead(query: Builder<DatabaseNotification>): Builder<DatabaseNotification>;
2265
+ /** `query.unread()`: only unread notifications. */
2266
+ static scopeUnread(query: Builder<DatabaseNotification>): Builder<DatabaseNotification>;
2267
+ }
2268
+ /** Laravel's DatabaseNotificationCollection: what `await user.notifications().get()` returns. */
2269
+ declare class DatabaseNotificationCollection extends Collection<DatabaseNotification> {
2270
+ /** Marks every notification as read (one save each, as in Laravel). */
2271
+ markAsRead(): Promise<void>;
2272
+ /** Marks every notification as unread. */
2273
+ markAsUnread(): Promise<void>;
2274
+ }
2275
+ /**
2276
+ * The relation `notifications()`, `readNotifications()` and `unreadNotifications()` return: a morphMany over
2277
+ * DatabaseNotification whose results (get(), the loaded relation, eager loads) are DatabaseNotificationCollections.
2278
+ * Every builder method works on it: paginate(), count(), update({ read_at }), where(), …
2279
+ */
2280
+ declare class DatabaseNotificationsRelation<P extends Model = Model> extends MorphMany<DatabaseNotification, P> {
2281
+ get(): Promise<DatabaseNotificationCollection>;
2282
+ getResults(): Promise<DatabaseNotificationCollection>;
2283
+ initRelation(models: P[], relation: string): P[];
2284
+ match(models: P[], results: DatabaseNotification[], relation: string): P[];
2285
+ }
2286
+
2287
+ type ModelConstructor = new (...args: any[]) => Model;
2288
+ /** What HasDatabaseNotifications adds to a model. */
2289
+ interface HasDatabaseNotificationsModel extends Model {
2290
+ /** The model's notifications, newest first: morphMany(DatabaseNotification, 'notifiable').latest(). */
2291
+ notifications(): DatabaseNotificationsRelation<this>;
2292
+ /** The read ones (read_at set). */
2293
+ readNotifications(): DatabaseNotificationsRelation<this>;
2294
+ /** The unread ones (read_at null). */
2295
+ unreadNotifications(): DatabaseNotificationsRelation<this>;
2296
+ }
2297
+ /**
2298
+ * Laravel's HasDatabaseNotifications: the notifications the database channel stored for this model, as queries.
2299
+ * `class User extends HasDatabaseNotifications(Model) {}`; apps get it through `Notifiable`.
2300
+ */
2301
+ declare function HasDatabaseNotifications<TBase extends ModelConstructor>(Base: TBase): TBase & (new (...args: any[]) => HasDatabaseNotificationsModel);
2302
+
2303
+ /** Laravel's HasUuids: `class Post extends HasUuids(Model) {}` keys new rows with a version 7 UUID. */
2304
+ declare function HasUuids<TBase extends ModelConstructor>(Base: TBase): TBase;
2305
+ /** Laravel's HasUlids: `class Post extends HasUlids(Model) {}` keys new rows with a lower-case ULID. */
2306
+ declare function HasUlids<TBase extends ModelConstructor>(Base: TBase): TBase;
2307
+
2124
2308
  /**
2125
2309
  * The morph map: the value stored in `*_type` columns for each model class (Laravel's Relation::morphMap()).
2126
2310
  * Without an entry the class name is stored ('Post'). Returns the current map.
@@ -2438,7 +2622,11 @@ declare class RouteModelResolverImpl implements RouteModelResolver {
2438
2622
 
2439
2623
  /** Laravel 11's config/database.php defaults (the app's config/database.ts wins, key by key). */
2440
2624
  declare function databaseConfigDefaults(app: Pick<Application, 'databasePath'>): DatabaseConfig & Record<string, unknown>;
2441
- /** Points the paginators at the current request: ?page=, ?cursor=, the URL and the query string (Laravel's resolvers). */
2625
+ /**
2626
+ * Points the paginators at the current request: ?page=, ?cursor=, the URL and the query string (Laravel's resolvers).
2627
+ * A bound PaginationState is asked first for the page and the path (Livewire's WithPagination replaces Laravel's
2628
+ * resolvers the same way); what it leaves undefined comes from the request.
2629
+ */
2442
2630
  declare function usePaginationResolvers(): void;
2443
2631
  /**
2444
2632
  * Binds the database layer: the DatabaseManager (a root singleton owning the pools) behind the DB facade, the
@@ -2453,4 +2641,4 @@ declare class DatabaseServiceProvider extends ServiceProvider {
2453
2641
  private manager;
2454
2642
  }
2455
2643
 
2456
- export { AbstractPaginator, type Attributes, BelongsTo, BelongsToMany, Blueprint, type BlueprintCommand, Builder, type BuiltInCast, type BunDatabase, BunSqliteDatabase, type BunStatement, type CastDefinition, type CastsAttributes, type Column, type ColumnAttributes, ColumnDefinition, type ColumnInfo, type ColumnRef, type ColumnType, Connection, type ConnectionConfig, type CreateMigrationOptions, Cursor, CursorPaginator, type CursorPaginatorOptions, DB, type DatabaseCommandContext, type DatabaseConfig, DatabaseConfigError, DatabaseError, DatabaseManagerImpl, DatabaseServiceProvider, type Direction, type EagerLoadSpec, type EnumLike, Expression, Factory, type FactoryResult, Faker, FakerOverflowError, ForeignIdColumnDefinition, ForeignKeyDefinition, type GlobalScope, Grammar, type HasFactory, HasMany, HasManyThrough, HasOne, HasOneOrMany, type Having, type IndexType, InvalidCastError, JoinClause, type JoinType, LengthAwarePaginator, type LoggedQuery, LogicError, MIGRATION_CREATE_STUB, MIGRATION_STUB, MIGRATION_UPDATE_STUB, MODEL_EVENTS, type Many, MassAssignmentError, Migration, MigrationCreator, type MigrationRecord, MigrationRepository, type MigrationStatus, Migrator, type MigratorOptions, Model, type ModelBuilder, type ModelClass, type ModelEvent, type ModelListener, ModelNotFoundError, ModelRegistry, type MorphConstraint, MorphMany, MorphOne, MorphTo, MySqlSchemaGrammar, OPERATORS, type Order, type PaginationLink, Paginator, type PaginatorOptions, Pivot, type PivotIds, PostgresSchemaGrammar, Builder$1 as QueryBuilder, QueryError, type RawResult, type ReferentialAction, type RegisteredModel, Relation, type RelationConstraint, type RelationNames, RelationNotFoundError, RelationNotLoadedError, type RelationValue, type RollbackOptions, RouteModelResolverImpl, Schema, SchemaBuilder, SchemaBuilderToken, SchemaGrammar, type Scope, type ScopeCallback, type ScopeStatic, type Scopes, Seeder, type SeederClass, type SelectColumn, SoftDeletingScope, SqliteSchemaGrammar, type State, type StateContext, type SyncChanges, TypeGenerator, type TypeGeneratorOptions, type Where, type WhereArgs, type WhereBoolean, buildQuery, castGet, castSet, columnKey, createDialect, databaseConfigDefaults, discoverFactories, enumValues, fake, formatDate, formatDateTime, generateModelTypes, getMorphAlias, getMorphedModel, guessTable, isBun, isDateCast, isEquivalent, isJsonCast, loadRelations, migrationDatePrefix, modelEventName, morphMap, mysqlPoolOptions, openSqlite, parseDateTime, prepareValue, raw, rawWithBindings, registerMigrationCommands, registerModelTypesCommand, resolveMorphClass, runSeeder, serializeDate, usePaginationResolvers };
2644
+ export { AbstractPaginator, type Attributes, BelongsTo, BelongsToMany, Blueprint, type BlueprintCommand, Builder, type BuiltInCast, type BunDatabase, BunSqliteDatabase, type BunStatement, type CastDefinition, type CastsAttributes, type Column, type ColumnAttributes, ColumnDefinition, type ColumnInfo, type ColumnRef, type ColumnType, Connection, type ConnectionConfig, type CreateMigrationOptions, Cursor, CursorPaginator, type CursorPaginatorOptions, DB, type DatabaseCommandContext, type DatabaseConfig, DatabaseConfigError, DatabaseError, DatabaseManagerImpl, DatabaseNotification, DatabaseNotificationCollection, DatabaseNotificationsRelation, DatabaseServiceProvider, type Direction, type EagerLoadSpec, type EnumLike, Expression, Factory, type FactoryResult, Faker, FakerOverflowError, ForeignIdColumnDefinition, ForeignKeyDefinition, type GlobalScope, Grammar, HasDatabaseNotifications, type HasDatabaseNotificationsModel, type HasFactory, HasMany, HasManyThrough, HasOne, HasOneOrMany, HasUlids, HasUuids, type Having, type IndexType, InvalidCastError, JoinClause, type JoinType, LengthAwarePaginator, type LoggedQuery, LogicError, MIGRATION_CREATE_STUB, MIGRATION_STUB, MIGRATION_UPDATE_STUB, MODEL_EVENTS, type Many, MassAssignmentError, Migration, MigrationCreator, type MigrationRecord, MigrationRepository, type MigrationStatus, Migrator, type MigratorOptions, Model, type ModelBuilder, type ModelClass, type ModelConstructor, type ModelEvent, type ModelListener, ModelNotFoundError, ModelRegistry, type MorphConstraint, MorphMany, MorphOne, MorphTo, MySqlSchemaGrammar, OPERATORS, type Order, type PaginationLink, Paginator, type PaginatorOptions, Pivot, type PivotIds, PostgresSchemaGrammar, Builder$1 as QueryBuilder, QueryError, type RawResult, type ReferentialAction, type RegisteredModel, Relation, type RelationConstraint, type RelationNames, RelationNotFoundError, RelationNotLoadedError, type RelationValue, type RollbackOptions, RouteModelResolverImpl, Schema, SchemaBuilder, SchemaBuilderToken, SchemaGrammar, type Scope, type ScopeCallback, type ScopeStatic, type Scopes, Seeder, type SeederClass, type SelectColumn, SoftDeletingScope, SqliteSchemaGrammar, type State, type StateContext, type SyncChanges, TypeGenerator, type TypeGeneratorOptions, type Where, type WhereArgs, type WhereBoolean, buildQuery, castGet, castSet, columnKey, createDialect, databaseConfigDefaults, discoverFactories, enumValues, fake, formatDate, formatDateTime, generateModelTypes, getMorphAlias, getMorphedModel, guessTable, isBun, isDateCast, isEquivalent, isJsonCast, loadRelations, migrationDatePrefix, modelEventName, morphMap, mysqlPoolOptions, openSqlite, parseDateTime, prepareValue, raw, rawWithBindings, registerMigrationCommands, registerModelTypesCommand, resolveMorphClass, runSeeder, serializeDate, usePaginationResolvers };