pinia-orm-edge 1.9.0-28582911.bbf7a93 → 1.9.0-28583486.807fa36

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.
@@ -290,13 +290,20 @@ declare class Interpreter {
290
290
  private getSchema;
291
291
  }
292
292
 
293
- interface Where {
294
- field: WherePrimaryClosure | string;
295
- value: WhereSecondaryClosure | any;
293
+ interface Where<T = Model> {
294
+ field: WherePrimaryClosure<T> | NonMethodKeys<T> | string | string[];
295
+ value: WhereSecondaryClosure<T> | any;
296
296
  boolean: 'and' | 'or';
297
297
  }
298
- type WherePrimaryClosure = (model: any) => boolean;
299
- type WhereSecondaryClosure = (value: any) => boolean;
298
+ type NonMethodKeys<T> = {
299
+ [P in keyof T]: T[P] extends Function ? never : P;
300
+ }[keyof T];
301
+ type GetElementType<T extends unknown[] | unknown> = T extends (infer U)[] ? U : T;
302
+ type UltimateKeys<M> = {
303
+ [T in keyof M]: M[T] extends Model | Model[] | null ? GetElementType<NonNullable<M[T]>> : never;
304
+ };
305
+ type WherePrimaryClosure<T> = (model: T) => boolean;
306
+ type WhereSecondaryClosure<T> = (value: T) => boolean;
300
307
  interface WhereGroup {
301
308
  and?: Where[];
302
309
  or?: Where[];
@@ -312,10 +319,10 @@ type OrderBy = string | ((model: any) => any);
312
319
  type GroupBy = string;
313
320
  type GroupByFields = string[];
314
321
  type OrderDirection = 'asc' | 'desc';
315
- interface EagerLoad {
316
- [name: string]: EagerLoadConstraint;
317
- }
318
- type EagerLoadConstraint = (query: Query) => void;
322
+ type EagerLoad<M extends Model> = {
323
+ [K in keyof M]: EagerLoadConstraint<GetElementType<M[WithKeys<M>] extends Model ? M[WithKeys<M>] : never>>;
324
+ };
325
+ type EagerLoadConstraint<M extends Model> = (query: Query<M>) => void;
319
326
 
320
327
  declare class Query<M extends Model = Model> {
321
328
  /**
@@ -329,7 +336,7 @@ declare class Query<M extends Model = Model> {
329
336
  /**
330
337
  * The where constraints for the query.
331
338
  */
332
- protected wheres: Where[];
339
+ protected wheres: Where<M>[];
333
340
  /**
334
341
  * The orderings for the query.
335
342
  */
@@ -361,7 +368,7 @@ declare class Query<M extends Model = Model> {
361
368
  /**
362
369
  * The relationships that should be eager loaded.
363
370
  */
364
- protected eagerLoad: EagerLoad;
371
+ protected eagerLoad: EagerLoad<M> | {};
365
372
  /**
366
373
  * The pinia store.
367
374
  */
@@ -380,15 +387,15 @@ declare class Query<M extends Model = Model> {
380
387
  /**
381
388
  * Create a new query instance for the given model.
382
389
  */
383
- newQuery(model: string): Query;
390
+ newQuery(model: string): Query<M>;
384
391
  /**
385
392
  * Create a new query instance with constraints for the given model.
386
393
  */
387
- newQueryWithConstraints(model: string): Query;
394
+ newQueryWithConstraints(model: string): Query<M>;
388
395
  /**
389
396
  * Create a new query instance from the given relation.
390
397
  */
391
- newQueryForRelation(relation: Relation): Query;
398
+ newQueryForRelation(relation: Relation): Query<M>;
392
399
  /**
393
400
  * Create a new interpreter instance.
394
401
  */
@@ -412,11 +419,11 @@ declare class Query<M extends Model = Model> {
412
419
  /**
413
420
  * Add a basic where clause to the query.
414
421
  */
415
- where(field: WherePrimaryClosure | string, value?: WhereSecondaryClosure | any): this;
422
+ 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
423
  /**
417
424
  * Add a "where in" clause to the query.
418
425
  */
419
- whereIn(field: string, values: any[] | Set<any>): this;
426
+ whereIn<T extends NonMethodKeys<M>>(field: T | string & {}, values: any[] | Set<any>): this;
420
427
  /**
421
428
  * Add a "where not in" clause to the query.
422
429
  */
@@ -436,7 +443,7 @@ declare class Query<M extends Model = Model> {
436
443
  /**
437
444
  * Add an "or where" clause to the query.
438
445
  */
439
- orWhere(field: WherePrimaryClosure | string, value?: WhereSecondaryClosure | any): this;
446
+ 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;
440
447
  /**
441
448
  * Add a "whereNULL" clause to the query.
442
449
  */
@@ -448,11 +455,11 @@ declare class Query<M extends Model = Model> {
448
455
  /**
449
456
  * Add a "where has" clause to the query.
450
457
  */
451
- whereHas(relation: string, callback?: EagerLoadConstraint, operator?: string | number, count?: number): this;
458
+ 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;
452
459
  /**
453
460
  * Add an "or where has" clause to the query.
454
461
  */
455
- orWhereHas(relation: string, callback?: EagerLoadConstraint, operator?: string | number, count?: number): this;
462
+ 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;
456
463
  /**
457
464
  * Add a "has" clause to the query.
458
465
  */
@@ -472,11 +479,11 @@ declare class Query<M extends Model = Model> {
472
479
  /**
473
480
  * Add a "where doesn't have" clause to the query.
474
481
  */
475
- whereDoesntHave(relation: string, callback?: EagerLoadConstraint): this;
482
+ whereDoesntHave<T extends WithKeys<M>>(relation: T | string & {}, callback?: M[T] extends Model | Model[] | null ? EagerLoadConstraint<GetElementType<NonNullable<M[T]>>> : () => void): this;
476
483
  /**
477
484
  * Add an "or where doesn't have" clause to the query.
478
485
  */
479
- orWhereDoesntHave(relation: string, callback?: EagerLoadConstraint): this;
486
+ orWhereDoesntHave<T extends WithKeys<M>>(relation: T | string & {}, callback?: M[T] extends Model | Model[] | null ? EagerLoadConstraint<GetElementType<NonNullable<M[T]>>> : () => void): this;
480
487
  /**
481
488
  * Add a "group by" clause to the query.
482
489
  */
@@ -496,11 +503,11 @@ declare class Query<M extends Model = Model> {
496
503
  /**
497
504
  * Set the relationships that should be eager loaded.
498
505
  */
499
- with(name: string, callback?: EagerLoadConstraint): this;
506
+ with<T extends WithKeys<M>>(name: T | string & {}, callback?: M[T] extends Model | Model[] | null ? EagerLoadConstraint<GetElementType<NonNullable<M[T]>>> : () => void): this;
500
507
  /**
501
508
  * Set to eager load all top-level relationships. Constraint is set for all relationships.
502
509
  */
503
- withAll(callback?: EagerLoadConstraint): this;
510
+ withAll(callback?: EagerLoadConstraint<any>): this;
504
511
  /**
505
512
  * Set to eager load all relationships recursively.
506
513
  */
@@ -512,7 +519,7 @@ declare class Query<M extends Model = Model> {
512
519
  /**
513
520
  * Get where closure for relations
514
521
  */
515
- protected getFieldWhereForRelations(relation: string, callback?: EagerLoadConstraint, operator?: string | number, count?: number): WherePrimaryClosure;
522
+ 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>;
516
523
  /**
517
524
  * Get all models by id from the store. The difference with the `get` is that this
518
525
  * method will not process any query chain.
@@ -548,11 +555,11 @@ declare class Query<M extends Model = Model> {
548
555
  /**
549
556
  * Get comparator for the where clause.
550
557
  */
551
- protected getWhereComparator(): (model: any) => boolean;
558
+ protected getWhereComparator(): (model: M) => boolean;
552
559
  /**
553
560
  * The function to compare where clause to the given model.
554
561
  */
555
- protected whereComparator(model: M, where: Where): boolean;
562
+ protected whereComparator(model: M, where: Where<M>): boolean;
556
563
  /**
557
564
  * Filter the given collection by the registered order conditions.
558
565
  */
@@ -576,7 +583,7 @@ declare class Query<M extends Model = Model> {
576
583
  /**
577
584
  * Eagerly load the relationship on a set of models.
578
585
  */
579
- protected eagerLoadRelation(models: Collection<M>, name: string, constraints: EagerLoadConstraint): void;
586
+ protected eagerLoadRelation<T extends WithKeys<M>>(models: Collection<M>, name: T | string & {}, constraints: EagerLoadConstraint<M>): void;
580
587
  /**
581
588
  * Get the relation instance for the given relation name.
582
589
  */
@@ -702,15 +709,15 @@ declare abstract class Relation extends Attribute {
702
709
  /**
703
710
  * Set the constraints for an eager loading relation.
704
711
  */
705
- abstract addEagerConstraints(query: Query, models: Collection): void;
712
+ abstract addEagerConstraints(query: Query<any>, models: Collection): void;
706
713
  /**
707
714
  * Match the eagerly loaded results to their parents.
708
715
  */
709
- abstract match(relation: string, models: Collection, query: Query): void;
716
+ abstract match(relation: string, models: Collection, query: Query<any>): void;
710
717
  /**
711
718
  * Get all of the primary keys for an array of models.
712
719
  */
713
- protected getKeys(models: Collection, key: string): (string | number)[];
720
+ protected getKeys<M extends Model = Model>(models: Collection<any>, key: string): (string | number)[];
714
721
  /**
715
722
  * Specify how this model should behave on delete
716
723
  */
@@ -718,7 +725,7 @@ declare abstract class Relation extends Attribute {
718
725
  /**
719
726
  * Run a dictionary map over the items.
720
727
  */
721
- protected mapToDictionary(models: Collection, callback: (model: Model) => [string, Model]): Dictionary;
728
+ protected mapToDictionary(models: Collection<any>, callback: (model: Model) => [string, Model]): Dictionary;
722
729
  /**
723
730
  * Call a function for a current key match
724
731
  */
@@ -761,11 +768,11 @@ declare class HasOne extends Relation {
761
768
  /**
762
769
  * Match the eagerly loaded results to their parents.
763
770
  */
764
- match(relation: string, models: Collection, query: Query): void;
771
+ match(relation: string, models: Collection<any>, query: Query<any>): void;
765
772
  /**
766
773
  * Build model dictionary keyed by the relation's foreign key.
767
774
  */
768
- protected buildDictionary(results: Collection): Dictionary;
775
+ protected buildDictionary(results: Collection<any>): Dictionary;
769
776
  /**
770
777
  * Make a related model.
771
778
  */
@@ -808,15 +815,15 @@ declare class BelongsTo extends Relation {
808
815
  /**
809
816
  * Gather the keys from a collection of related models.
810
817
  */
811
- protected getEagerModelKeys(models: Collection, foreignKey: string): (string | number)[];
818
+ protected getEagerModelKeys(models: Collection<any>, foreignKey: string): (string | number)[];
812
819
  /**
813
820
  * Match the eagerly loaded results to their respective parents.
814
821
  */
815
- match(relation: string, models: Collection, query: Query): void;
822
+ match(relation: string, models: Collection<any>, query: Query): void;
816
823
  /**
817
824
  * Build model dictionary keyed by relation's parent key.
818
825
  */
819
- protected buildDictionary(models: Collection): Record<string, Model>;
826
+ protected buildDictionary(models: Collection<any>): Record<string, Model>;
820
827
  /**
821
828
  * Make a related model.
822
829
  */
@@ -871,7 +878,7 @@ declare class BelongsToMany extends Relation {
871
878
  /**
872
879
  * Match the eagerly loaded results to their parents.
873
880
  */
874
- match(relation: string, models: Collection, query: Query): void;
881
+ match(relation: string, models: Collection<any>, query: Query<any>): void;
875
882
  /**
876
883
  * Set the constraints for the related relation.
877
884
  */
@@ -910,11 +917,11 @@ declare class HasMany extends Relation {
910
917
  /**
911
918
  * Match the eagerly loaded results to their parents.
912
919
  */
913
- match(relation: string, models: Collection, query: Query): void;
920
+ match(relation: string, models: Collection<any>, query: Query<any>): void;
914
921
  /**
915
922
  * Build model dictionary keyed by the relation's foreign key.
916
923
  */
917
- protected buildDictionary(results: Collection): Dictionary;
924
+ protected buildDictionary(results: Collection<any>): Dictionary;
918
925
  /**
919
926
  * Make related models.
920
927
  */
@@ -962,15 +969,15 @@ declare class HasManyBy extends Relation {
962
969
  /**
963
970
  * Gather the keys from a collection of related models.
964
971
  */
965
- protected getEagerModelKeys(models: Collection): (string | number)[];
972
+ protected getEagerModelKeys(models: Collection<any>): (string | number)[];
966
973
  /**
967
974
  * Match the eagerly loaded results to their parents.
968
975
  */
969
- match(relation: string, models: Collection, query: Query): void;
976
+ match(relation: string, models: Collection<any>, query: Query<any>): void;
970
977
  /**
971
978
  * Build model dictionary keyed by the relation's foreign key.
972
979
  */
973
- protected buildDictionary(models: Collection): Record<string, Model>;
980
+ protected buildDictionary(models: Collection<any>): Record<string, Model>;
974
981
  /**
975
982
  * Get all related models from the given dictionary.
976
983
  */
@@ -1013,15 +1020,15 @@ declare class MorphOne extends Relation {
1013
1020
  /**
1014
1021
  * Set the constraints for an eager load of the relation.
1015
1022
  */
1016
- addEagerConstraints(query: Query, models: Collection): void;
1023
+ addEagerConstraints(query: Query<any>, models: Collection<any>): void;
1017
1024
  /**
1018
1025
  * Match the eagerly loaded results to their parents.
1019
1026
  */
1020
- match(relation: string, models: Collection, query: Query): void;
1027
+ match(relation: string, models: Collection<any>, query: Query<any>): void;
1021
1028
  /**
1022
1029
  * Build model dictionary keyed by the relation's foreign key.
1023
1030
  */
1024
- protected buildDictionary(models: Collection): Record<string, Model>;
1031
+ protected buildDictionary(models: Collection<any>): Record<string, Model>;
1025
1032
  /**
1026
1033
  * Make a related model.
1027
1034
  */
@@ -1095,11 +1102,11 @@ declare class MorphTo extends Relation {
1095
1102
  /**
1096
1103
  * Build model dictionary keyed by the owner key for each entity.
1097
1104
  */
1098
- protected buildDictionary(query: Query, models: Collection): DictionaryByEntities;
1105
+ protected buildDictionary(query: Query<any>, models: Collection<any>): DictionaryByEntities;
1099
1106
  /**
1100
1107
  * Get the relation's primary keys grouped by its entity.
1101
1108
  */
1102
- protected getKeysByEntity(models: Collection): Record<string, (string | number)[]>;
1109
+ protected getKeysByEntity(models: Collection<any>): Record<string, (string | number)[]>;
1103
1110
  }
1104
1111
 
1105
1112
  declare class MorphMany extends Relation {
@@ -1134,15 +1141,15 @@ declare class MorphMany extends Relation {
1134
1141
  /**
1135
1142
  * Set the constraints for an eager load of the relation.
1136
1143
  */
1137
- addEagerConstraints(query: Query, models: Collection): void;
1144
+ addEagerConstraints(query: Query<any>, models: Collection<any>): void;
1138
1145
  /**
1139
1146
  * Match the eagerly loaded results to their parents.
1140
1147
  */
1141
- match(relation: string, models: Collection, query: Query): void;
1148
+ match(relation: string, models: Collection<any>, query: Query<any>): void;
1142
1149
  /**
1143
1150
  * Build model dictionary keyed by the relation's foreign key.
1144
1151
  */
1145
- protected buildDictionary(results: Collection): Dictionary;
1152
+ protected buildDictionary(results: Collection<any>): Dictionary;
1146
1153
  /**
1147
1154
  * Make related models.
1148
1155
  */
@@ -1237,11 +1244,11 @@ declare class HasManyThrough extends Relation {
1237
1244
  /**
1238
1245
  * Match the eagerly loaded results to their parents.
1239
1246
  */
1240
- match(relation: string, models: Collection, query: Query): void;
1247
+ match(relation: string, models: Collection<any>, query: Query<any>): void;
1241
1248
  /**
1242
1249
  * Build model dictionary keyed by the relation's foreign key.
1243
1250
  */
1244
- protected buildDictionary(throughResults: Collection, results: Collection): Dictionary;
1251
+ protected buildDictionary(throughResults: Collection<any>, results: Collection<any>): Dictionary;
1245
1252
  /**
1246
1253
  * Make related models.
1247
1254
  */
@@ -1300,7 +1307,7 @@ declare class MorphToMany extends Relation {
1300
1307
  /**
1301
1308
  * Match the eagerly loaded results to their parents.
1302
1309
  */
1303
- match(relation: string, models: Collection, query: Query): void;
1310
+ match(relation: string, models: Collection<any>, query: Query<any>): void;
1304
1311
  /**
1305
1312
  * Set the constraints for the related relation.
1306
1313
  */
@@ -1334,8 +1341,11 @@ interface AfterHook {
1334
1341
  interface InheritanceTypes {
1335
1342
  [key: string]: typeof Model;
1336
1343
  }
1344
+ type WithKeys<T> = {
1345
+ [P in keyof T]: T[P] extends (Model | null) | Model[] ? P & string : never;
1346
+ }[keyof T];
1337
1347
  declare class Model {
1338
- [s: keyof ModelFields]: any;
1348
+ pivot?: any;
1339
1349
  _meta: undefined | MetaValues;
1340
1350
  /**
1341
1351
  * The name of the model.
@@ -1345,6 +1355,10 @@ declare class Model {
1345
1355
  * The reference to the base entity name if the class extends a base entity.
1346
1356
  */
1347
1357
  static baseEntity: string;
1358
+ /**
1359
+ * The reference to the base namespace if the class extends a base with a different namespace.
1360
+ */
1361
+ static baseNamespace: string;
1348
1362
  /**
1349
1363
  * Define a namespace if you have multiple equal entity names.
1350
1364
  * Resulting in "{namespace}/{entity}"
@@ -1420,6 +1434,8 @@ declare class Model {
1420
1434
  * Create a new model fields definition.
1421
1435
  */
1422
1436
  static fields(): ModelFields;
1437
+ static usedNamespace(): string;
1438
+ static modelEntity(): string;
1423
1439
  /**
1424
1440
  * Build the schema by evaluating fields and registry.
1425
1441
  */
@@ -1598,6 +1614,14 @@ declare class Model {
1598
1614
  * Get the base entity for this model.
1599
1615
  */
1600
1616
  $baseEntity(): string;
1617
+ /**
1618
+ * Get the base namespace for this model.
1619
+ */
1620
+ $baseNamespace(): string;
1621
+ /**
1622
+ * Get the model entity for this model.
1623
+ */
1624
+ $modelEntity(): string;
1601
1625
  /**
1602
1626
  * Get the type key for this model.
1603
1627
  */
@@ -1753,7 +1777,7 @@ interface ModelConstructor<M extends Model> extends Constructor<M> {
1753
1777
  newRawInstance(): M;
1754
1778
  }
1755
1779
 
1756
- declare function useDataStore<S extends DataStoreState, T extends DataStore = DataStore>(id: string, options: DefineStoreOptionsBase<S, T>, query?: Query): pinia.StoreDefinition<string, S, {}, {
1780
+ declare function useDataStore<S extends DataStoreState, T extends DataStore = DataStore>(id: string, options: DefineStoreOptionsBase<S, T>, query?: Query<any>): pinia.StoreDefinition<string, S, {}, {
1757
1781
  save(this: any, records: Elements, triggerQueryAction?: boolean): void;
1758
1782
  insert(this: any, records: Elements, triggerQueryAction?: boolean): void;
1759
1783
  update(this: any, records: Elements, triggerQueryAction?: boolean): void;
@@ -1803,7 +1827,7 @@ declare class Repository<M extends Model = Model> {
1803
1827
  /**
1804
1828
  * The model object to be used for the custom repository.
1805
1829
  */
1806
- static useModel?: Model;
1830
+ static useModel?: typeof Model;
1807
1831
  /**
1808
1832
  * Global config
1809
1833
  */
@@ -1817,7 +1841,7 @@ declare class Repository<M extends Model = Model> {
1817
1841
  /**
1818
1842
  * Set the model
1819
1843
  */
1820
- static setModel(model: Model): typeof Repository;
1844
+ static setModel(model: typeof Model): typeof Repository;
1821
1845
  /**
1822
1846
  * Set the global config
1823
1847
  */
@@ -1864,19 +1888,19 @@ declare class Repository<M extends Model = Model> {
1864
1888
  /**
1865
1889
  * Add a basic where clause to the query.
1866
1890
  */
1867
- where(field: WherePrimaryClosure | string, value?: WhereSecondaryClosure | any): Query<M>;
1891
+ 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>;
1868
1892
  /**
1869
1893
  * Add an "or where" clause to the query.
1870
1894
  */
1871
- orWhere(field: WherePrimaryClosure | string, value?: WhereSecondaryClosure | any): Query<M>;
1895
+ 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>;
1872
1896
  /**
1873
1897
  * Add a "where has" clause to the query.
1874
1898
  */
1875
- whereHas(relation: string, callback?: EagerLoadConstraint, operator?: string | number, count?: number): Query<M>;
1899
+ 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>;
1876
1900
  /**
1877
1901
  * Add an "or where has" clause to the query.
1878
1902
  */
1879
- orWhereHas(relation: string, callback?: EagerLoadConstraint, operator?: string | number, count?: number): Query<M>;
1903
+ 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>;
1880
1904
  /**
1881
1905
  * Add a "has" clause to the query.
1882
1906
  */
@@ -1896,11 +1920,11 @@ declare class Repository<M extends Model = Model> {
1896
1920
  /**
1897
1921
  * Add a "where doesn't have" clause to the query.
1898
1922
  */
1899
- whereDoesntHave(relation: string, callback?: EagerLoadConstraint): Query<M>;
1923
+ whereDoesntHave<T extends WithKeys<M>>(relation: T | string & {}, callback?: M[T] extends Model | Model[] | null ? EagerLoadConstraint<GetElementType<NonNullable<M[T]>>> : () => void): Query<M>;
1900
1924
  /**
1901
1925
  * Add an "or where doesn't have" clause to the query.
1902
1926
  */
1903
- orWhereDoesntHave(relation: string, callback?: EagerLoadConstraint): Query<M>;
1927
+ orWhereDoesntHave<T extends WithKeys<M>>(relation: T | string & {}, callback?: M[T] extends Model | Model[] | null ? EagerLoadConstraint<GetElementType<NonNullable<M[T]>>> : () => void): Query<M>;
1904
1928
  /**
1905
1929
  * Make meta field visible
1906
1930
  */
@@ -1932,11 +1956,11 @@ declare class Repository<M extends Model = Model> {
1932
1956
  /**
1933
1957
  * Set the relationships that should be eager loaded.
1934
1958
  */
1935
- with(name: string, callback?: EagerLoadConstraint): Query<M>;
1959
+ with<T extends WithKeys<M>>(name: string & {} | T, callback?: M[T] extends Model | Model[] | null ? EagerLoadConstraint<GetElementType<NonNullable<M[T]>>> : never): Query<M>;
1936
1960
  /**
1937
1961
  * Set to eager load all top-level relationships. Constraint is set for all relationships.
1938
1962
  */
1939
- withAll(callback?: EagerLoadConstraint): Query<M>;
1963
+ withAll(callback?: EagerLoadConstraint<M>): Query<M>;
1940
1964
  /**
1941
1965
  * Set to eager load all top-level relationships. Constraint is set for all relationships.
1942
1966
  */
@@ -1989,4 +2013,4 @@ declare class Repository<M extends Model = Model> {
1989
2013
  flush(): M[];
1990
2014
  }
1991
2015
 
1992
- 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 };
2016
+ 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 };