pinia-orm-edge 1.9.0-28582105.fda0f99 → 1.9.0-28583149.676ad48

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.
@@ -1,6 +1,7 @@
1
1
  import * as pinia from 'pinia';
2
2
  import { PiniaPlugin, Pinia, DefineStoreOptionsBase } from 'pinia';
3
3
  import { schema, Schema as Schema$1 } from '@pinia-orm/normalizr';
4
+ import { Model as Model$1, WithKeys as WithKeys$1 } from '@/model/Model';
4
5
  import * as __composables from '@/composables';
5
6
 
6
7
  interface Constructor<T> {
@@ -290,13 +291,20 @@ declare class Interpreter {
290
291
  private getSchema;
291
292
  }
292
293
 
293
- interface Where {
294
- field: WherePrimaryClosure | string;
295
- value: WhereSecondaryClosure | any;
294
+ interface Where<T = Model$1> {
295
+ field: WherePrimaryClosure<T> | NonMethodKeys<T> | string | string[];
296
+ value: WhereSecondaryClosure<T> | any;
296
297
  boolean: 'and' | 'or';
297
298
  }
298
- type WherePrimaryClosure = (model: any) => boolean;
299
- type WhereSecondaryClosure = (value: any) => boolean;
299
+ type NonMethodKeys<T> = {
300
+ [P in keyof T]: T[P] extends Function ? never : P;
301
+ }[keyof T];
302
+ type GetElementType<T extends unknown[] | unknown> = T extends (infer U)[] ? U : T;
303
+ type UltimateKeys<M> = {
304
+ [T in keyof M]: M[T] extends Model$1 | Model$1[] | null ? GetElementType<NonNullable<M[T]>> : never;
305
+ };
306
+ type WherePrimaryClosure<T> = (model: T) => boolean;
307
+ type WhereSecondaryClosure<T> = (value: T) => boolean;
300
308
  interface WhereGroup {
301
309
  and?: Where[];
302
310
  or?: Where[];
@@ -312,10 +320,10 @@ type OrderBy = string | ((model: any) => any);
312
320
  type GroupBy = string;
313
321
  type GroupByFields = string[];
314
322
  type OrderDirection = 'asc' | 'desc';
315
- interface EagerLoad {
316
- [name: string]: EagerLoadConstraint;
317
- }
318
- type EagerLoadConstraint = (query: Query) => void;
323
+ type EagerLoad<M extends Model$1> = {
324
+ [K in keyof M]: EagerLoadConstraint<GetElementType<M[WithKeys$1<M>] extends Model$1 ? M[WithKeys$1<M>] : never>>;
325
+ };
326
+ type EagerLoadConstraint<M extends Model$1> = (query: Query<M>) => void;
319
327
 
320
328
  declare class Query<M extends Model = Model> {
321
329
  /**
@@ -329,7 +337,7 @@ declare class Query<M extends Model = Model> {
329
337
  /**
330
338
  * The where constraints for the query.
331
339
  */
332
- protected wheres: Where[];
340
+ protected wheres: Where<M>[];
333
341
  /**
334
342
  * The orderings for the query.
335
343
  */
@@ -361,7 +369,7 @@ declare class Query<M extends Model = Model> {
361
369
  /**
362
370
  * The relationships that should be eager loaded.
363
371
  */
364
- protected eagerLoad: EagerLoad;
372
+ protected eagerLoad: EagerLoad<M> | {};
365
373
  /**
366
374
  * The pinia store.
367
375
  */
@@ -380,15 +388,15 @@ declare class Query<M extends Model = Model> {
380
388
  /**
381
389
  * Create a new query instance for the given model.
382
390
  */
383
- newQuery(model: string): Query;
391
+ newQuery(model: string): Query<M>;
384
392
  /**
385
393
  * Create a new query instance with constraints for the given model.
386
394
  */
387
- newQueryWithConstraints(model: string): Query;
395
+ newQueryWithConstraints(model: string): Query<M>;
388
396
  /**
389
397
  * Create a new query instance from the given relation.
390
398
  */
391
- newQueryForRelation(relation: Relation): Query;
399
+ newQueryForRelation(relation: Relation): Query<M>;
392
400
  /**
393
401
  * Create a new interpreter instance.
394
402
  */
@@ -412,11 +420,23 @@ declare class Query<M extends Model = Model> {
412
420
  /**
413
421
  * Add a basic where clause to the query.
414
422
  */
415
- where(field: WherePrimaryClosure | string, value?: WhereSecondaryClosure | any): this;
423
+ where<T extends WherePrimaryClosure<M> | NonMethodKeys<M> | string[] | (string & {})>(field: T, value?: T extends string[] ? string | number | (string | number)[] : WhereSecondaryClosure<M[T extends keyof M ? T : never]> | M[T extends keyof M ? T : never] | null): this;
416
424
  /**
417
425
  * Add a "where in" clause to the query.
418
426
  */
419
- whereIn(field: string, values: any[] | Set<any>): this;
427
+ whereIn<T extends NonMethodKeys<M>>(field: T | string & {}, values: any[] | Set<any>): this;
428
+ /**
429
+ * Add a "where not in" clause to the query.
430
+ */
431
+ whereNotIn(field: string, values: any[] | Set<any>): this;
432
+ /**
433
+ * Add a "where not in" clause to the query.
434
+ */
435
+ orWhereIn(field: string, values: any[] | Set<any>): this;
436
+ /**
437
+ * Add a "where not in" clause to the query.
438
+ */
439
+ orWhereNotIn(field: string, values: any[] | Set<any>): this;
420
440
  /**
421
441
  * Add a where clause on the primary key to the query.
422
442
  */
@@ -424,15 +444,23 @@ declare class Query<M extends Model = Model> {
424
444
  /**
425
445
  * Add an "or where" clause to the query.
426
446
  */
427
- orWhere(field: WherePrimaryClosure | string, value?: WhereSecondaryClosure | any): this;
447
+ orWhere<T extends WherePrimaryClosure<M> | NonMethodKeys<M> | string & {}>(field: T, value?: WhereSecondaryClosure<M[T extends keyof M ? T : never]> | M[T extends keyof M ? T : never]): this;
448
+ /**
449
+ * Add a "whereNULL" clause to the query.
450
+ */
451
+ whereNull(field: string): this;
452
+ /**
453
+ * Add a "whereNotNULL" clause to the query.
454
+ */
455
+ whereNotNull(field: string): this;
428
456
  /**
429
457
  * Add a "where has" clause to the query.
430
458
  */
431
- whereHas(relation: string, callback?: EagerLoadConstraint, operator?: string | number, count?: number): this;
459
+ whereHas<T extends WithKeys<M>>(relation: T | string & {}, callback?: M[T] extends Model | Model[] | null ? EagerLoadConstraint<GetElementType<NonNullable<M[T]>>> : () => void, operator?: string | number, count?: number): this;
432
460
  /**
433
461
  * Add an "or where has" clause to the query.
434
462
  */
435
- orWhereHas(relation: string, callback?: EagerLoadConstraint, operator?: string | number, count?: number): this;
463
+ orWhereHas<T extends WithKeys<M>>(relation: T | string & {}, callback?: M[T] extends Model | Model[] | null ? EagerLoadConstraint<GetElementType<NonNullable<M[T]>>> : () => void, operator?: string | number, count?: number): this;
436
464
  /**
437
465
  * Add a "has" clause to the query.
438
466
  */
@@ -452,11 +480,11 @@ declare class Query<M extends Model = Model> {
452
480
  /**
453
481
  * Add a "where doesn't have" clause to the query.
454
482
  */
455
- whereDoesntHave(relation: string, callback?: EagerLoadConstraint): this;
483
+ whereDoesntHave<T extends WithKeys<M>>(relation: T | string & {}, callback?: M[T] extends Model | Model[] | null ? EagerLoadConstraint<GetElementType<NonNullable<M[T]>>> : () => void): this;
456
484
  /**
457
485
  * Add an "or where doesn't have" clause to the query.
458
486
  */
459
- orWhereDoesntHave(relation: string, callback?: EagerLoadConstraint): this;
487
+ orWhereDoesntHave<T extends WithKeys<M>>(relation: T | string & {}, callback?: M[T] extends Model | Model[] | null ? EagerLoadConstraint<GetElementType<NonNullable<M[T]>>> : () => void): this;
460
488
  /**
461
489
  * Add a "group by" clause to the query.
462
490
  */
@@ -476,11 +504,11 @@ declare class Query<M extends Model = Model> {
476
504
  /**
477
505
  * Set the relationships that should be eager loaded.
478
506
  */
479
- with(name: string, callback?: EagerLoadConstraint): this;
507
+ with<T extends WithKeys<M>>(name: T | string & {}, callback?: M[T] extends Model | Model[] | null ? EagerLoadConstraint<GetElementType<NonNullable<M[T]>>> : () => void): this;
480
508
  /**
481
509
  * Set to eager load all top-level relationships. Constraint is set for all relationships.
482
510
  */
483
- withAll(callback?: EagerLoadConstraint): this;
511
+ withAll(callback?: EagerLoadConstraint<any>): this;
484
512
  /**
485
513
  * Set to eager load all relationships recursively.
486
514
  */
@@ -492,7 +520,7 @@ declare class Query<M extends Model = Model> {
492
520
  /**
493
521
  * Get where closure for relations
494
522
  */
495
- protected getFieldWhereForRelations(relation: string, callback?: EagerLoadConstraint, operator?: string | number, count?: number): WherePrimaryClosure;
523
+ protected getFieldWhereForRelations<T extends WithKeys<M>>(relation: T | (string & {}), callback?: M[T] extends Model | Model[] | null ? EagerLoadConstraint<GetElementType<NonNullable<M[T]>>> : () => void, operator?: string | number, count?: number): WherePrimaryClosure<M>;
496
524
  /**
497
525
  * Get all models by id from the store. The difference with the `get` is that this
498
526
  * method will not process any query chain.
@@ -528,11 +556,11 @@ declare class Query<M extends Model = Model> {
528
556
  /**
529
557
  * Get comparator for the where clause.
530
558
  */
531
- protected getWhereComparator(): (model: any) => boolean;
559
+ protected getWhereComparator(): (model: M) => boolean;
532
560
  /**
533
561
  * The function to compare where clause to the given model.
534
562
  */
535
- protected whereComparator(model: M, where: Where): boolean;
563
+ protected whereComparator(model: M, where: Where<M>): boolean;
536
564
  /**
537
565
  * Filter the given collection by the registered order conditions.
538
566
  */
@@ -556,7 +584,7 @@ declare class Query<M extends Model = Model> {
556
584
  /**
557
585
  * Eagerly load the relationship on a set of models.
558
586
  */
559
- protected eagerLoadRelation(models: Collection<M>, name: string, constraints: EagerLoadConstraint): void;
587
+ protected eagerLoadRelation<T extends WithKeys<M>>(models: Collection<M>, name: T | string & {}, constraints: EagerLoadConstraint<M>): void;
560
588
  /**
561
589
  * Get the relation instance for the given relation name.
562
590
  */
@@ -682,15 +710,15 @@ declare abstract class Relation extends Attribute {
682
710
  /**
683
711
  * Set the constraints for an eager loading relation.
684
712
  */
685
- abstract addEagerConstraints(query: Query, models: Collection): void;
713
+ abstract addEagerConstraints(query: Query<any>, models: Collection): void;
686
714
  /**
687
715
  * Match the eagerly loaded results to their parents.
688
716
  */
689
- abstract match(relation: string, models: Collection, query: Query): void;
717
+ abstract match(relation: string, models: Collection, query: Query<any>): void;
690
718
  /**
691
719
  * Get all of the primary keys for an array of models.
692
720
  */
693
- protected getKeys(models: Collection, key: string): (string | number)[];
721
+ protected getKeys<M extends Model = Model>(models: Collection<any>, key: string): (string | number)[];
694
722
  /**
695
723
  * Specify how this model should behave on delete
696
724
  */
@@ -698,7 +726,7 @@ declare abstract class Relation extends Attribute {
698
726
  /**
699
727
  * Run a dictionary map over the items.
700
728
  */
701
- protected mapToDictionary(models: Collection, callback: (model: Model) => [string, Model]): Dictionary;
729
+ protected mapToDictionary(models: Collection<any>, callback: (model: Model) => [string, Model]): Dictionary;
702
730
  /**
703
731
  * Call a function for a current key match
704
732
  */
@@ -741,11 +769,11 @@ declare class HasOne extends Relation {
741
769
  /**
742
770
  * Match the eagerly loaded results to their parents.
743
771
  */
744
- match(relation: string, models: Collection, query: Query): void;
772
+ match(relation: string, models: Collection<any>, query: Query<any>): void;
745
773
  /**
746
774
  * Build model dictionary keyed by the relation's foreign key.
747
775
  */
748
- protected buildDictionary(results: Collection): Dictionary;
776
+ protected buildDictionary(results: Collection<any>): Dictionary;
749
777
  /**
750
778
  * Make a related model.
751
779
  */
@@ -788,15 +816,15 @@ declare class BelongsTo extends Relation {
788
816
  /**
789
817
  * Gather the keys from a collection of related models.
790
818
  */
791
- protected getEagerModelKeys(models: Collection, foreignKey: string): (string | number)[];
819
+ protected getEagerModelKeys(models: Collection<any>, foreignKey: string): (string | number)[];
792
820
  /**
793
821
  * Match the eagerly loaded results to their respective parents.
794
822
  */
795
- match(relation: string, models: Collection, query: Query): void;
823
+ match(relation: string, models: Collection<any>, query: Query): void;
796
824
  /**
797
825
  * Build model dictionary keyed by relation's parent key.
798
826
  */
799
- protected buildDictionary(models: Collection): Record<string, Model>;
827
+ protected buildDictionary(models: Collection<any>): Record<string, Model>;
800
828
  /**
801
829
  * Make a related model.
802
830
  */
@@ -851,7 +879,7 @@ declare class BelongsToMany extends Relation {
851
879
  /**
852
880
  * Match the eagerly loaded results to their parents.
853
881
  */
854
- match(relation: string, models: Collection, query: Query): void;
882
+ match(relation: string, models: Collection<any>, query: Query<any>): void;
855
883
  /**
856
884
  * Set the constraints for the related relation.
857
885
  */
@@ -890,11 +918,11 @@ declare class HasMany extends Relation {
890
918
  /**
891
919
  * Match the eagerly loaded results to their parents.
892
920
  */
893
- match(relation: string, models: Collection, query: Query): void;
921
+ match(relation: string, models: Collection<any>, query: Query<any>): void;
894
922
  /**
895
923
  * Build model dictionary keyed by the relation's foreign key.
896
924
  */
897
- protected buildDictionary(results: Collection): Dictionary;
925
+ protected buildDictionary(results: Collection<any>): Dictionary;
898
926
  /**
899
927
  * Make related models.
900
928
  */
@@ -942,15 +970,15 @@ declare class HasManyBy extends Relation {
942
970
  /**
943
971
  * Gather the keys from a collection of related models.
944
972
  */
945
- protected getEagerModelKeys(models: Collection): (string | number)[];
973
+ protected getEagerModelKeys(models: Collection<any>): (string | number)[];
946
974
  /**
947
975
  * Match the eagerly loaded results to their parents.
948
976
  */
949
- match(relation: string, models: Collection, query: Query): void;
977
+ match(relation: string, models: Collection<any>, query: Query<any>): void;
950
978
  /**
951
979
  * Build model dictionary keyed by the relation's foreign key.
952
980
  */
953
- protected buildDictionary(models: Collection): Record<string, Model>;
981
+ protected buildDictionary(models: Collection<any>): Record<string, Model>;
954
982
  /**
955
983
  * Get all related models from the given dictionary.
956
984
  */
@@ -993,15 +1021,15 @@ declare class MorphOne extends Relation {
993
1021
  /**
994
1022
  * Set the constraints for an eager load of the relation.
995
1023
  */
996
- addEagerConstraints(query: Query, models: Collection): void;
1024
+ addEagerConstraints(query: Query<any>, models: Collection<any>): void;
997
1025
  /**
998
1026
  * Match the eagerly loaded results to their parents.
999
1027
  */
1000
- match(relation: string, models: Collection, query: Query): void;
1028
+ match(relation: string, models: Collection<any>, query: Query<any>): void;
1001
1029
  /**
1002
1030
  * Build model dictionary keyed by the relation's foreign key.
1003
1031
  */
1004
- protected buildDictionary(models: Collection): Record<string, Model>;
1032
+ protected buildDictionary(models: Collection<any>): Record<string, Model>;
1005
1033
  /**
1006
1034
  * Make a related model.
1007
1035
  */
@@ -1075,11 +1103,11 @@ declare class MorphTo extends Relation {
1075
1103
  /**
1076
1104
  * Build model dictionary keyed by the owner key for each entity.
1077
1105
  */
1078
- protected buildDictionary(query: Query, models: Collection): DictionaryByEntities;
1106
+ protected buildDictionary(query: Query<any>, models: Collection<any>): DictionaryByEntities;
1079
1107
  /**
1080
1108
  * Get the relation's primary keys grouped by its entity.
1081
1109
  */
1082
- protected getKeysByEntity(models: Collection): Record<string, (string | number)[]>;
1110
+ protected getKeysByEntity(models: Collection<any>): Record<string, (string | number)[]>;
1083
1111
  }
1084
1112
 
1085
1113
  declare class MorphMany extends Relation {
@@ -1114,15 +1142,15 @@ declare class MorphMany extends Relation {
1114
1142
  /**
1115
1143
  * Set the constraints for an eager load of the relation.
1116
1144
  */
1117
- addEagerConstraints(query: Query, models: Collection): void;
1145
+ addEagerConstraints(query: Query<any>, models: Collection<any>): void;
1118
1146
  /**
1119
1147
  * Match the eagerly loaded results to their parents.
1120
1148
  */
1121
- match(relation: string, models: Collection, query: Query): void;
1149
+ match(relation: string, models: Collection<any>, query: Query<any>): void;
1122
1150
  /**
1123
1151
  * Build model dictionary keyed by the relation's foreign key.
1124
1152
  */
1125
- protected buildDictionary(results: Collection): Dictionary;
1153
+ protected buildDictionary(results: Collection<any>): Dictionary;
1126
1154
  /**
1127
1155
  * Make related models.
1128
1156
  */
@@ -1217,11 +1245,11 @@ declare class HasManyThrough extends Relation {
1217
1245
  /**
1218
1246
  * Match the eagerly loaded results to their parents.
1219
1247
  */
1220
- match(relation: string, models: Collection, query: Query): void;
1248
+ match(relation: string, models: Collection<any>, query: Query<any>): void;
1221
1249
  /**
1222
1250
  * Build model dictionary keyed by the relation's foreign key.
1223
1251
  */
1224
- protected buildDictionary(throughResults: Collection, results: Collection): Dictionary;
1252
+ protected buildDictionary(throughResults: Collection<any>, results: Collection<any>): Dictionary;
1225
1253
  /**
1226
1254
  * Make related models.
1227
1255
  */
@@ -1280,7 +1308,7 @@ declare class MorphToMany extends Relation {
1280
1308
  /**
1281
1309
  * Match the eagerly loaded results to their parents.
1282
1310
  */
1283
- match(relation: string, models: Collection, query: Query): void;
1311
+ match(relation: string, models: Collection<any>, query: Query<any>): void;
1284
1312
  /**
1285
1313
  * Set the constraints for the related relation.
1286
1314
  */
@@ -1314,8 +1342,11 @@ interface AfterHook {
1314
1342
  interface InheritanceTypes {
1315
1343
  [key: string]: typeof Model;
1316
1344
  }
1345
+ type WithKeys<T> = {
1346
+ [P in keyof T]: T[P] extends (Model | null) | Model[] ? P & string : never;
1347
+ }[keyof T];
1317
1348
  declare class Model {
1318
- [s: keyof ModelFields]: any;
1349
+ pivot?: any;
1319
1350
  _meta: undefined | MetaValues;
1320
1351
  /**
1321
1352
  * The name of the model.
@@ -1733,7 +1764,7 @@ interface ModelConstructor<M extends Model> extends Constructor<M> {
1733
1764
  newRawInstance(): M;
1734
1765
  }
1735
1766
 
1736
- declare function useDataStore<S extends DataStoreState, T extends DataStore = DataStore>(id: string, options: DefineStoreOptionsBase<S, T>, query?: Query): pinia.StoreDefinition<string, S, {}, {
1767
+ declare function useDataStore<S extends DataStoreState, T extends DataStore = DataStore>(id: string, options: DefineStoreOptionsBase<S, T>, query?: Query<any>): pinia.StoreDefinition<string, S, {}, {
1737
1768
  save(this: any, records: Elements, triggerQueryAction?: boolean): void;
1738
1769
  insert(this: any, records: Elements, triggerQueryAction?: boolean): void;
1739
1770
  update(this: any, records: Elements, triggerQueryAction?: boolean): void;
@@ -1783,7 +1814,7 @@ declare class Repository<M extends Model = Model> {
1783
1814
  /**
1784
1815
  * The model object to be used for the custom repository.
1785
1816
  */
1786
- static useModel?: Model;
1817
+ static useModel?: typeof Model;
1787
1818
  /**
1788
1819
  * Global config
1789
1820
  */
@@ -1797,7 +1828,7 @@ declare class Repository<M extends Model = Model> {
1797
1828
  /**
1798
1829
  * Set the model
1799
1830
  */
1800
- static setModel(model: Model): typeof Repository;
1831
+ static setModel(model: typeof Model): typeof Repository;
1801
1832
  /**
1802
1833
  * Set the global config
1803
1834
  */
@@ -1844,19 +1875,19 @@ declare class Repository<M extends Model = Model> {
1844
1875
  /**
1845
1876
  * Add a basic where clause to the query.
1846
1877
  */
1847
- where(field: WherePrimaryClosure | string, value?: WhereSecondaryClosure | any): Query<M>;
1878
+ where<T extends WherePrimaryClosure<M> | NonMethodKeys<M> | string & {}>(field: T, value?: T extends string[] ? string | number | (string | number)[] : WhereSecondaryClosure<M[T extends keyof M ? T : never]> | M[T extends keyof M ? T : never]): Query<M>;
1848
1879
  /**
1849
1880
  * Add an "or where" clause to the query.
1850
1881
  */
1851
- orWhere(field: WherePrimaryClosure | string, value?: WhereSecondaryClosure | any): Query<M>;
1882
+ orWhere<T extends WherePrimaryClosure<M> | NonMethodKeys<M> | string & {}>(field: T, value?: WhereSecondaryClosure<M[T extends keyof M ? T : never]> | M[T extends keyof M ? T : never]): Query<M>;
1852
1883
  /**
1853
1884
  * Add a "where has" clause to the query.
1854
1885
  */
1855
- whereHas(relation: string, callback?: EagerLoadConstraint, operator?: string | number, count?: number): Query<M>;
1886
+ whereHas<T extends WithKeys<M>>(relation: T | string & {}, callback?: M[T] extends Model | Model[] | null ? EagerLoadConstraint<GetElementType<NonNullable<M[T]>>> : () => void, operator?: string | number, count?: number): Query<M>;
1856
1887
  /**
1857
1888
  * Add an "or where has" clause to the query.
1858
1889
  */
1859
- orWhereHas(relation: string, callback?: EagerLoadConstraint, operator?: string | number, count?: number): Query<M>;
1890
+ orWhereHas<T extends WithKeys<M>>(relation: T | string & {}, callback?: M[T] extends Model | Model[] | null ? EagerLoadConstraint<GetElementType<NonNullable<M[T]>>> : () => void, operator?: string | number, count?: number): Query<M>;
1860
1891
  /**
1861
1892
  * Add a "has" clause to the query.
1862
1893
  */
@@ -1876,11 +1907,11 @@ declare class Repository<M extends Model = Model> {
1876
1907
  /**
1877
1908
  * Add a "where doesn't have" clause to the query.
1878
1909
  */
1879
- whereDoesntHave(relation: string, callback?: EagerLoadConstraint): Query<M>;
1910
+ whereDoesntHave<T extends WithKeys<M>>(relation: T | string & {}, callback?: M[T] extends Model | Model[] | null ? EagerLoadConstraint<GetElementType<NonNullable<M[T]>>> : () => void): Query<M>;
1880
1911
  /**
1881
1912
  * Add an "or where doesn't have" clause to the query.
1882
1913
  */
1883
- orWhereDoesntHave(relation: string, callback?: EagerLoadConstraint): Query<M>;
1914
+ orWhereDoesntHave<T extends WithKeys<M>>(relation: T | string & {}, callback?: M[T] extends Model | Model[] | null ? EagerLoadConstraint<GetElementType<NonNullable<M[T]>>> : () => void): Query<M>;
1884
1915
  /**
1885
1916
  * Make meta field visible
1886
1917
  */
@@ -1912,11 +1943,11 @@ declare class Repository<M extends Model = Model> {
1912
1943
  /**
1913
1944
  * Set the relationships that should be eager loaded.
1914
1945
  */
1915
- with(name: string, callback?: EagerLoadConstraint): Query<M>;
1946
+ with<T extends WithKeys<M>>(name: string & {} | T, callback?: M[T] extends Model | Model[] | null ? EagerLoadConstraint<GetElementType<NonNullable<M[T]>>> : never): Query<M>;
1916
1947
  /**
1917
1948
  * Set to eager load all top-level relationships. Constraint is set for all relationships.
1918
1949
  */
1919
- withAll(callback?: EagerLoadConstraint): Query<M>;
1950
+ withAll(callback?: EagerLoadConstraint<M>): Query<M>;
1920
1951
  /**
1921
1952
  * Set to eager load all top-level relationships. Constraint is set for all relationships.
1922
1953
  */
@@ -1929,11 +1960,6 @@ declare class Repository<M extends Model = Model> {
1929
1960
  * Get all models from the store.
1930
1961
  */
1931
1962
  all(): Collection<M>;
1932
- /**
1933
- * Find the model with the given id.
1934
- */
1935
- find(id: string | number): Item<M>;
1936
- find(ids: (string | number)[]): Collection<M>;
1937
1963
  /**
1938
1964
  * Retrieves the models from the store by following the given
1939
1965
  * normalized schema.
@@ -1974,4 +2000,4 @@ declare class Repository<M extends Model = Model> {
1974
2000
  flush(): M[];
1975
2001
  }
1976
2002
 
1977
- export { CastAttribute as $, type AfterHook as A, type BeforeHook as B, type Constructor as C, type DataStore as D, type Elements as E, type FilledInstallOptions as F, type GroupedCollection as G, Relation as H, type Item as I, BelongsTo as J, BelongsToMany as K, HasMany as L, Model as M, type NormalizedData as N, HasOne as O, type PiniaOrmPluginContext as P, Query as Q, Repository as R, type Schemas as S, HasManyBy as T, HasManyThrough as U, MorphMany as V, WeakCache as W, MorphTo as X, MorphToMany as Y, MorphOne as Z, type Casts as _, type Element as a, type TypeDefault as a0, Type as a1, Interpreter as a2, type Where as a3, type WherePrimaryClosure as a4, type WhereSecondaryClosure as a5, type WhereGroup as a6, type Order as a7, type Group as a8, type OrderBy as a9, type GroupBy as aa, type GroupByFields as ab, type OrderDirection as ac, type EagerLoad as ad, type EagerLoadConstraint as ae, type PropertyDecorator as af, type TypeOptions as ag, type UidOptions as ah, type Mutator as ai, type NanoidOptions as aj, type Collection as b, type DataStoreState as c, type PiniaOrmPlugin as d, definePiniaOrmPlugin as e, type ModelConfigOptions as f, type CacheConfigOptions as g, type InstallOptions as h, type CreatePiniaOrm as i, createORM as j, Database as k, Schema as l, type ModelFields as m, type ModelSchemas as n, type ModelRegistries as o, plugins as p, type ModelRegistry as q, registerPlugins as r, type PrimaryKey as s, type ModelOptions as t, useDataStore as u, type MetaValues as v, type InheritanceTypes as w, Attribute as x, type Dictionary as y, type deleteModes as z };
2003
+ export { type Casts as $, type AfterHook as A, type BeforeHook as B, type Constructor as C, type DataStore as D, type Elements as E, type FilledInstallOptions as F, type GroupedCollection as G, type deleteModes as H, type Item as I, Relation as J, BelongsTo as K, BelongsToMany as L, Model as M, type NormalizedData as N, HasMany as O, type PiniaOrmPluginContext as P, Query as Q, Repository as R, type Schemas as S, HasOne as T, HasManyBy as U, HasManyThrough as V, WeakCache as W, MorphMany as X, MorphTo as Y, MorphToMany as Z, MorphOne as _, type Element as a, CastAttribute as a0, type TypeDefault as a1, Type as a2, Interpreter as a3, type Where as a4, type NonMethodKeys as a5, type GetElementType as a6, type UltimateKeys as a7, type WherePrimaryClosure as a8, type WhereSecondaryClosure as a9, type WhereGroup as aa, type Order as ab, type Group as ac, type OrderBy as ad, type GroupBy as ae, type GroupByFields as af, type OrderDirection as ag, type EagerLoad as ah, type EagerLoadConstraint as ai, type Mutator as aj, type MutatorFunctions as ak, type Mutators as al, type CacheConfig as am, type PropertyDecorator as an, type TypeOptions as ao, type UidOptions as ap, type NanoidOptions as aq, type Collection as b, type DataStoreState as c, type PiniaOrmPlugin as d, definePiniaOrmPlugin as e, type ModelConfigOptions as f, type CacheConfigOptions as g, type InstallOptions as h, type CreatePiniaOrm as i, createORM as j, Database as k, Schema as l, type ModelFields as m, type ModelSchemas as n, type ModelRegistries as o, plugins as p, type ModelRegistry as q, registerPlugins as r, type PrimaryKey as s, type ModelOptions as t, useDataStore as u, type MetaValues as v, type InheritanceTypes as w, type WithKeys as x, Attribute as y, type Dictionary as z };