objection 3.2.0 → 3.3.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.
Files changed (52) hide show
  1. package/README.md +13 -13
  2. package/lib/model/AjvValidator.js +133 -3
  3. package/lib/queryBuilder/QueryBuilder.js +186 -5
  4. package/lib/queryBuilder/QueryBuilderOperationSupport.js +5 -0
  5. package/lib/queryBuilder/ReferenceBuilder.js +5 -3
  6. package/lib/queryBuilder/RelationExpression.js +13 -1
  7. package/lib/queryBuilder/StaticHookArguments.js +12 -1
  8. package/lib/queryBuilder/graph/GraphUpsert.js +22 -0
  9. package/lib/queryBuilder/graph/insert/DeferredRelationGraphInsertAction.js +57 -0
  10. package/lib/queryBuilder/graph/insert/GraphInsert.js +107 -8
  11. package/lib/queryBuilder/graph/insert/GraphInsertAction.js +8 -1
  12. package/lib/queryBuilder/join/JoinResultParser.js +22 -0
  13. package/lib/queryBuilder/join/RelationJoiner.js +71 -22
  14. package/lib/queryBuilder/operations/InsertAndFetchOperation.js +7 -1
  15. package/lib/queryBuilder/operations/InsertGraphOperation.js +2 -2
  16. package/lib/queryBuilder/operations/InsertOperation.js +121 -12
  17. package/lib/queryBuilder/operations/QueryBuilderOperation.js +4 -0
  18. package/lib/queryBuilder/operations/ReturningOperation.js +28 -3
  19. package/lib/queryBuilder/operations/UpdateOperation.js +3 -2
  20. package/lib/queryBuilder/operations/UpsertGraphOperation.js +5 -0
  21. package/lib/queryBuilder/operations/WhereGroupOperation.js +41 -0
  22. package/lib/queryBuilder/operations/eager/EagerOperation.js +4 -0
  23. package/lib/queryBuilder/operations/eager/JoinEagerOperation.js +2 -6
  24. package/lib/queryBuilder/operations/eager/WhereInEagerOperation.js +10 -33
  25. package/lib/queryBuilder/operations/jsonApi/WhereJsonHasPostgresOperation.js +3 -3
  26. package/lib/queryBuilder/operations/jsonApi/WhereJsonNotObjectPostgresOperation.js +1 -1
  27. package/lib/queryBuilder/operations/jsonApi/postgresJsonApi.js +41 -34
  28. package/lib/queryBuilder/operations/select/Selection.js +95 -4
  29. package/lib/queryBuilder/operations/whereInComposite/WhereInCompositeMsSqlOperation.js +6 -0
  30. package/lib/queryBuilder/operations/whereInComposite/WhereInCompositeOperation.js +5 -1
  31. package/lib/queryBuilder/operations/whereInComposite/WhereInCompositeSqliteOperation.js +9 -0
  32. package/lib/queryBuilder/parsers/jsonFieldExpressionParser.js +81 -43
  33. package/lib/queryBuilder/parsers/jsonFieldExpressionParser.pegjs +5 -4
  34. package/lib/queryBuilder/whereGroups.js +125 -0
  35. package/lib/relations/Relation.js +5 -2
  36. package/lib/relations/hasMany/HasManyRelateOperation.js +5 -2
  37. package/lib/relations/hasMany/HasManyUnrelateOperation.js +5 -2
  38. package/lib/relations/manyToMany/ManyToManyModifyMixin.js +26 -3
  39. package/lib/relations/manyToMany/ManyToManyMySqlModifyMixin.js +66 -0
  40. package/lib/relations/manyToMany/ManyToManyPostgresModifyMixin.js +27 -0
  41. package/lib/relations/manyToMany/ManyToManyRelation.js +70 -48
  42. package/lib/relations/manyToMany/unrelate/ManyToManyUnrelateMySqlOperation.js +16 -0
  43. package/lib/relations/manyToMany/unrelate/ManyToManyUnrelateOperationBase.js +5 -1
  44. package/lib/relations/manyToMany/unrelate/ManyToManyUnrelatePostgresOperation.js +16 -0
  45. package/lib/relations/manyToMany/update/ManyToManyUpdateMySqlOperation.js +12 -0
  46. package/lib/relations/manyToMany/update/ManyToManyUpdateOperationBase.js +8 -2
  47. package/lib/relations/manyToMany/update/ManyToManyUpdatePostgresOperation.js +12 -0
  48. package/lib/utils/deprecate.js +6 -0
  49. package/lib/utils/identifierMapping.js +15 -1
  50. package/lib/utils/parseFieldExpression.js +28 -0
  51. package/package.json +10 -6
  52. package/typings/objection/index.d.ts +280 -28
@@ -1,7 +1,7 @@
1
1
  /// <reference types="node" />
2
2
 
3
3
  // Type definitions for Objection.js
4
- // Project: <http://vincit.github.io/objection.js/>
4
+ // Project: <https://ditojs.github.io/objection/>
5
5
  //
6
6
  // Contributions by:
7
7
  // * Matthew McEachen <https://github.com/mceachen>
@@ -35,13 +35,15 @@ declare namespace Objection {
35
35
  const transaction: transaction;
36
36
  const initialize: initialize;
37
37
 
38
- const DBError: typeof dbErrors.DBError;
39
- const DataError: typeof dbErrors.DataError;
40
- const CheckViolationError: typeof dbErrors.CheckViolationError;
41
- const UniqueViolationError: typeof dbErrors.UniqueViolationError;
42
- const ConstraintViolationError: typeof dbErrors.ConstraintViolationError;
43
- const ForeignKeyViolationError: typeof dbErrors.ForeignKeyViolationError;
44
- const NotNullViolationError: typeof dbErrors.NotNullViolationError;
38
+ // Import aliases re-export both the value and the type side of the classes,
39
+ // so they can be used with `instanceof` as well as in type annotations.
40
+ export import DBError = dbErrors.DBError;
41
+ export import DataError = dbErrors.DataError;
42
+ export import CheckViolationError = dbErrors.CheckViolationError;
43
+ export import UniqueViolationError = dbErrors.UniqueViolationError;
44
+ export import ConstraintViolationError = dbErrors.ConstraintViolationError;
45
+ export import ForeignKeyViolationError = dbErrors.ForeignKeyViolationError;
46
+ export import NotNullViolationError = dbErrors.NotNullViolationError;
45
47
 
46
48
  export interface RawBuilder extends Aliasable {}
47
49
 
@@ -171,6 +173,216 @@ declare namespace Objection {
171
173
 
172
174
  type RelationExpression<M extends Model> = string | object;
173
175
 
176
+ // Type-level parsing of relation expressions, used to narrow the result
177
+ // types of `withGraphFetched()`, `withGraphJoined()` and `fetchGraph()`.
178
+
179
+ /**
180
+ * Parses a relation expression, in string or object notation, into a tree
181
+ * of fetched relations: '[pets.owner, children]' and
182
+ * `{ pets: { owner: true }, children: true }` both become
183
+ * `{ pets: { owner: {} }, children: {} }`.
184
+ *
185
+ * Anything that isn't a literal expression (e.g. a `string` variable) yields
186
+ * `{}`, and so do nodes the parser doesn't understand (aliases, `*`,
187
+ * recursion with `^`), so these simply don't narrow.
188
+ */
189
+ type ParseRelationExpression<E> = string extends E
190
+ ? {}
191
+ : E extends string
192
+ ? ParseRelationString<E>
193
+ : ParseRelationObject<E>;
194
+
195
+ type Whitespace = ' ' | '\n' | '\r' | '\t';
196
+
197
+ type Trim<S extends string> = S extends `${Whitespace}${infer R}`
198
+ ? Trim<R>
199
+ : S extends `${infer L}${Whitespace}`
200
+ ? Trim<L>
201
+ : S;
202
+
203
+ /**
204
+ * Counts the occurrences of character C in S, as a tuple length.
205
+ */
206
+ type CountChar<
207
+ S extends string,
208
+ C extends string,
209
+ N extends 0[] = [],
210
+ > = S extends `${string}${C}${infer R}` ? CountChar<R, C, [...N, 0]> : N['length'];
211
+
212
+ /**
213
+ * True if S has as many opening as closing brackets and parentheses.
214
+ */
215
+ type IsBalanced<S extends string> =
216
+ CountChar<S, '['> extends CountChar<S, ']'>
217
+ ? CountChar<S, '('> extends CountChar<S, ')'>
218
+ ? true
219
+ : false
220
+ : false;
221
+
222
+ /**
223
+ * Splits a list of expressions at the commas that aren't nested inside
224
+ * brackets or parentheses: 'a, b.[c, d]' -> ['a', 'b.[c, d]'].
225
+ */
226
+ type SplitList<
227
+ S extends string,
228
+ Acc extends string = '',
229
+ Out extends string[] = [],
230
+ > = S extends `${infer Head},${infer Rest}`
231
+ ? IsBalanced<`${Acc}${Head}`> extends true
232
+ ? SplitList<Rest, '', [...Out, `${Acc}${Head}`]>
233
+ : SplitList<Rest, `${Acc}${Head},`, Out>
234
+ : [...Out, `${Acc}${S}`];
235
+
236
+ type ParseRelationList<L extends string[], Acc = {}> = L extends [
237
+ infer H extends string,
238
+ ...infer T extends string[],
239
+ ]
240
+ ? ParseRelationList<T, Acc & ParseRelationString<H>>
241
+ : Acc;
242
+
243
+ /**
244
+ * Parses '[a, b]', 'a.b' and 'a' style expressions.
245
+ */
246
+ type ParseRelationString<S extends string> =
247
+ Trim<S> extends `[${infer Inner}]`
248
+ ? ParseRelationList<SplitList<Inner>>
249
+ : Trim<S> extends `${infer Head}.${infer Rest}`
250
+ ? IsBalanced<Head> extends true
251
+ ? RelationNode<RelationName<Head>, ParseRelationString<Rest>>
252
+ : {}
253
+ : RelationNode<RelationName<S>, {}>;
254
+
255
+ /**
256
+ * Extracts the relation name from a single node, dropping modifiers:
257
+ * 'pets(selectName)' -> 'pets'. Returns never for nodes that can't be
258
+ * narrowed: aliases ('pets as p'), '*' and recursion ('^', '^2').
259
+ */
260
+ type RelationName<S extends string> =
261
+ Trim<S> extends `${infer Name}(${string})`
262
+ ? RelationName<Name>
263
+ : Trim<S> extends infer Name extends string
264
+ ? Name extends '' | '*' | `^${string}` | `${string}${Whitespace}${string}`
265
+ ? never
266
+ : string extends Name
267
+ ? never
268
+ : Name
269
+ : never;
270
+
271
+ type RelationNode<Name extends string, Children> = [Name] extends [never]
272
+ ? {}
273
+ : { [K in Name]: Children };
274
+
275
+ /**
276
+ * Parses `{ a: true, b: { c: true } }` style expressions. Keys starting with
277
+ * `$` are options, and aliased nodes (`{ p: { $relation: 'pets' } }`) are
278
+ * skipped.
279
+ */
280
+ type ParseRelationObject<E> = string extends keyof E
281
+ ? {}
282
+ : {
283
+ [
284
+ K in keyof E as K extends `$${string}`
285
+ ? never
286
+ : false extends E[K]
287
+ ? never
288
+ : E[K] extends { $relation: any }
289
+ ? never
290
+ : K
291
+ ]: E[K] extends object ? ParseRelationObject<E[K]> : {};
292
+ };
293
+
294
+ /**
295
+ * Marks the relations in tree T as fetched on model M: they become required
296
+ * and are narrowed recursively. Only `undefined` is removed: declared `null`
297
+ * is kept, as to-one relations can be null when there is no related row.
298
+ */
299
+ type WithGraph<M, T> = [keyof T] extends [never]
300
+ ? M
301
+ : WithGraphRelations<M, T, FetchedRelations<M, T>>;
302
+
303
+ type WithGraphRelations<M, T, K extends keyof M & keyof T> = [K] extends [never]
304
+ ? M
305
+ : { -readonly [P in K]-?: WithGraphProperty<Defined<M[P]>, T[P]> } & UnnarrowedMethods<M> & M;
306
+
307
+ /**
308
+ * `$query()` of the un-narrowed model M, as it doesn't fetch the relations
309
+ * that were fetched on the instance. Otherwise its polymorphic `this` would
310
+ * resolve to the narrowed model. With chained narrowing, the first `$query`
311
+ * signature of the intersection wins, which is the one of the innermost,
312
+ * un-narrowed model.
313
+ */
314
+ type UnnarrowedMethods<M> = Pick<M, Extract<'$query', keyof M>>;
315
+
316
+ /**
317
+ * The keys of tree T that are relation properties of model M.
318
+ */
319
+ type FetchedRelations<M, T> = {
320
+ [K in keyof M & keyof T]: NonNullable<M[K]> extends Model | Model[] ? K : never;
321
+ }[keyof M & keyof T];
322
+
323
+ type WithGraphProperty<P, T> = [keyof T] extends [never]
324
+ ? P
325
+ : P extends Array<infer I>
326
+ ? WithGraph<I, T>[]
327
+ : P extends Model
328
+ ? WithGraph<P, T>
329
+ : P;
330
+
331
+ /**
332
+ * The model type after fetching the relation expression E on model M.
333
+ */
334
+ type WithGraphModel<M, E> = WithGraph<M, ParseRelationExpression<E>>;
335
+
336
+ /**
337
+ * The query builder type for model M after fetching relation expression E.
338
+ * `M extends unknown` makes this distributive, so that in generic code (e.g.
339
+ * `this` in model methods), TypeScript can resolve it through the constraint
340
+ * of M.
341
+ */
342
+ type WithGraphModelQueryBuilder<M extends Model, E> = M extends unknown
343
+ ? WithGraphModel<M, E>['QueryBuilderType']
344
+ : never;
345
+
346
+ /**
347
+ * The query builder type after `withGraphFetched(E)` / `withGraphJoined(E)`
348
+ * on QB. The model type is narrowed, and the query builder for the narrowed
349
+ * model is looked up through its `QueryBuilderType`, so custom query
350
+ * builders are kept. Falls back to QB if nothing can be narrowed, or if the
351
+ * model type is `any` (`0 extends 1 & M`), e.g. for AnyQueryBuilder.
352
+ * `QB extends unknown` below serves the same purpose as in
353
+ * WithGraphModelQueryBuilder.
354
+ */
355
+ type WithGraphQueryBuilder<QB extends AnyQueryBuilder, E> = WithGraphTreeQueryBuilder<
356
+ QB,
357
+ ParseRelationExpression<E>
358
+ >;
359
+
360
+ type WithGraphTreeQueryBuilder<QB extends AnyQueryBuilder, T> = [keyof T] extends [never]
361
+ ? QB
362
+ : QB extends unknown
363
+ ? 0 extends 1 & ModelType<QB>
364
+ ? QB
365
+ : [FetchedRelations<ModelType<QB>, T>] extends [never]
366
+ ? QB
367
+ : WithResultKind<QB, WithGraph<ModelType<QB>, T>['QueryBuilderType']>
368
+ : never;
369
+
370
+ /**
371
+ * Converts the query builder NQB to the same result kind as QB:
372
+ * array, single, maybe-single or page.
373
+ */
374
+ type WithResultKind<QB extends AnyQueryBuilder, NQB extends AnyQueryBuilder> = [
375
+ ResultType<QB>,
376
+ ] extends [ModelType<QB>[]]
377
+ ? ArrayQueryBuilder<NQB>
378
+ : [ResultType<QB>] extends [ModelType<QB>]
379
+ ? SingleQueryBuilder<NQB>
380
+ : [ResultType<QB>] extends [ModelType<QB> | undefined]
381
+ ? MaybeSingleQueryBuilder<NQB>
382
+ : [ResultType<QB>] extends [Page<ModelType<QB>>]
383
+ ? PageQueryBuilder<NQB>
384
+ : QB;
385
+
174
386
  /**
175
387
  * If T is an array, returns the item type, otherwise returns T.
176
388
  */
@@ -209,6 +421,16 @@ declare namespace Objection {
209
421
  : Expression<T[K]>;
210
422
  };
211
423
 
424
+ /**
425
+ * Like PartialModelObject, but relation properties are not allowed. Unlike
426
+ * PartialModelObject, this doesn't depend on the relation types, so query
427
+ * builders for models with narrowed relations (see WithGraphModel) remain
428
+ * assignable to the query builders for the plain models.
429
+ */
430
+ type PartialModelProps<T extends Model> = {
431
+ [K in DataPropertyNames<T>]?: Defined<T[K]> extends Model | Model[] ? never : Expression<T[K]>;
432
+ };
433
+
212
434
  /**
213
435
  * Additional optional parameters that may be used in graphs.
214
436
  */
@@ -343,7 +565,7 @@ declare namespace Objection {
343
565
  }
344
566
 
345
567
  /**
346
- * https://vincit.github.io/objection.js/api/types/#type-fieldexpression
568
+ * https://ditojs.github.io/objection/api/types/#type-fieldexpression
347
569
  */
348
570
  type FieldExpression = string;
349
571
 
@@ -442,7 +664,7 @@ declare namespace Objection {
442
664
  (raw: Raw): QB;
443
665
  <QBA extends AnyQueryBuilder>(qb: QBA): QB;
444
666
 
445
- (obj: PartialModelObject<ModelType<QB>>): QB;
667
+ (obj: PartialModelProps<ModelType<QB>>): QB;
446
668
  // We must allow any keys in the object. The previous type
447
669
  // is kind of useless, but maybe one day vscode and other
448
670
  // tools can autocomplete using it.
@@ -710,10 +932,15 @@ declare namespace Objection {
710
932
  (): ModelClass<M>;
711
933
  }
712
934
 
935
+ interface ReturningOptions {
936
+ includeTriggerModifications?: boolean;
937
+ }
938
+
713
939
  interface ReturningMethod {
714
940
  <QB extends AnyQueryBuilder>(
715
941
  this: QB,
716
942
  column: string | Raw | (string | Raw)[] | readonly (string | Raw)[],
943
+ options?: ReturningOptions,
717
944
  ): QB extends NumberQueryBuilder<QB> ? ArrayQueryBuilder<QB> : QB;
718
945
  }
719
946
 
@@ -824,6 +1051,10 @@ declare namespace Objection {
824
1051
  maxBatchSize?: number;
825
1052
  }
826
1053
 
1054
+ export interface WithGraphOptions extends GraphOptions {
1055
+ algorithm?: 'fetch' | 'join';
1056
+ }
1057
+
827
1058
  interface ModifyGraphMethod<QB extends AnyQueryBuilder> {
828
1059
  <M extends Model>(
829
1060
  expr: RelationExpression<ModelType<QB>>,
@@ -1057,6 +1288,7 @@ declare namespace Objection {
1057
1288
 
1058
1289
  update(update: PartialModelObject<M>): NumberQueryBuilder<this>;
1059
1290
  update(): NumberQueryBuilder<this>;
1291
+ updateById(id: MaybeCompositeId, update: PartialModelObject<M>): NumberQueryBuilder<this>;
1060
1292
  updateAndFetch(update: PartialModelObject<M>): SingleQueryBuilder<this>;
1061
1293
  updateAndFetchById(
1062
1294
  id: MaybeCompositeId,
@@ -1065,6 +1297,7 @@ declare namespace Objection {
1065
1297
 
1066
1298
  patch(update: PartialModelObject<M>): NumberQueryBuilder<this>;
1067
1299
  patch(): NumberQueryBuilder<this>;
1300
+ patchById(id: MaybeCompositeId, update: PartialModelObject<M>): NumberQueryBuilder<this>;
1068
1301
  patchAndFetch(update: PartialModelObject<M>): SingleQueryBuilder<this>;
1069
1302
  patchAndFetchById(
1070
1303
  id: MaybeCompositeId,
@@ -1094,8 +1327,20 @@ declare namespace Objection {
1094
1327
  unrelate(): NumberQueryBuilder<this>;
1095
1328
  for(ids: ForIdValue | ForIdValue[]): this;
1096
1329
 
1097
- withGraphFetched(expr: RelationExpression<M>, options?: GraphOptions): this;
1098
- withGraphJoined(expr: RelationExpression<M>, options?: GraphOptions): this;
1330
+ // With literal relation expressions, the fetched relations become required
1331
+ // on the result type, see WithGraphQueryBuilder.
1332
+ withGraphFetched<const E extends RelationExpression<M>>(
1333
+ expr: E,
1334
+ options?: GraphOptions,
1335
+ ): WithGraphQueryBuilder<this, E>;
1336
+ withGraphJoined<const E extends RelationExpression<M>>(
1337
+ expr: E,
1338
+ options?: GraphOptions,
1339
+ ): WithGraphQueryBuilder<this, E>;
1340
+ withGraph<const E extends RelationExpression<M>>(
1341
+ expr: E,
1342
+ options?: WithGraphOptions,
1343
+ ): WithGraphQueryBuilder<this, E>;
1099
1344
 
1100
1345
  truncate(): Promise<void>;
1101
1346
  allowGraph: AllowGraphMethod<this>;
@@ -1169,6 +1414,7 @@ declare namespace Objection {
1169
1414
  isRelate: BooleanReturningMethod;
1170
1415
  isUnrelate: BooleanReturningMethod;
1171
1416
  isInternal: BooleanReturningMethod;
1417
+ isJoinChildQuery: BooleanReturningMethod;
1172
1418
  hasWheres: BooleanReturningMethod;
1173
1419
  hasSelects: BooleanReturningMethod;
1174
1420
  hasWithGraph: BooleanReturningMethod;
@@ -1346,6 +1592,12 @@ declare namespace Objection {
1346
1592
  underscoreBeforeDigits?: boolean;
1347
1593
  underscoreBetweenUppercaseLetters?: boolean;
1348
1594
  noDoubleUnderscores?: boolean;
1595
+ /**
1596
+ * Only convert the column part of field expressions like
1597
+ * `jsonColumn:someKey` and keep their JSON keys as written.
1598
+ * Only used by `snakeCaseMappers`.
1599
+ */
1600
+ preserveJsonKeys?: boolean;
1349
1601
  }
1350
1602
 
1351
1603
  export interface ColumnNameMappers {
@@ -1526,17 +1778,17 @@ declare namespace Objection {
1526
1778
  bindKnex(trxOrKnex: TransactionOrKnex): this;
1527
1779
  bindTransaction(trxOrKnex: TransactionOrKnex): this;
1528
1780
 
1529
- fetchGraph(
1781
+ fetchGraph<const E extends RelationExpression<M>>(
1530
1782
  modelOrObject: PartialModelObject<M>,
1531
- expression: RelationExpression<M>,
1783
+ expression: E,
1532
1784
  options?: FetchGraphOptions,
1533
- ): SingleQueryBuilder<QueryBuilderType<M>>;
1785
+ ): SingleQueryBuilder<WithGraphModelQueryBuilder<M, E>>;
1534
1786
 
1535
- fetchGraph(
1787
+ fetchGraph<const E extends RelationExpression<M>>(
1536
1788
  modelOrObject: PartialModelObject<M>[],
1537
- expression: RelationExpression<M>,
1789
+ expression: E,
1538
1790
  options?: FetchGraphOptions,
1539
- ): QueryBuilderType<M>;
1791
+ ): WithGraphModelQueryBuilder<M, E>;
1540
1792
 
1541
1793
  getRelations(): Relations;
1542
1794
  getRelation(name: string): Relation;
@@ -1641,19 +1893,19 @@ declare namespace Objection {
1641
1893
  static bindKnex<M>(this: M, trxOrKnex: TransactionOrKnex): M;
1642
1894
  static bindTransaction<M>(this: M, trxOrKnex: TransactionOrKnex): M;
1643
1895
 
1644
- static fetchGraph<M extends Model>(
1896
+ static fetchGraph<M extends Model, const E extends RelationExpression<M>>(
1645
1897
  this: ConstructorType<M>,
1646
1898
  modelOrObject: PartialModelObject<M>,
1647
- expression: RelationExpression<M>,
1899
+ expression: E,
1648
1900
  options?: FetchGraphOptions,
1649
- ): SingleQueryBuilder<QueryBuilderType<M>>;
1901
+ ): SingleQueryBuilder<WithGraphModelQueryBuilder<M, E>>;
1650
1902
 
1651
- static fetchGraph<M extends Model>(
1903
+ static fetchGraph<M extends Model, const E extends RelationExpression<M>>(
1652
1904
  this: ConstructorType<M>,
1653
1905
  modelOrObject: PartialModelObject<M>[],
1654
- expression: RelationExpression<M>,
1906
+ expression: E,
1655
1907
  options?: FetchGraphOptions,
1656
- ): QueryBuilderType<M>;
1908
+ ): WithGraphModelQueryBuilder<M, E>;
1657
1909
 
1658
1910
  static getRelations(): Relations;
1659
1911
  static getRelation(name: string): Relation;
@@ -1697,10 +1949,10 @@ declare namespace Objection {
1697
1949
  $id(id: any): void;
1698
1950
  $id(): any;
1699
1951
 
1700
- $fetchGraph(
1701
- expression: RelationExpression<this>,
1952
+ $fetchGraph<const E extends RelationExpression<this>>(
1953
+ expression: E,
1702
1954
  options?: FetchGraphOptions,
1703
- ): SingleQueryBuilder<QueryBuilderType<this>>;
1955
+ ): SingleQueryBuilder<WithGraphModelQueryBuilder<this, E>>;
1704
1956
 
1705
1957
  $formatDatabaseJson(json: Pojo): Pojo;
1706
1958
  $parseDatabaseJson(json: Pojo): Pojo;
@@ -1758,7 +2010,7 @@ declare namespace Objection {
1758
2010
  * - https://github.com/microsoft/TypeScript/issues/1360
1759
2011
  * - https://github.com/Microsoft/TypeScript/issues/5453
1760
2012
  *
1761
- * @tutorial https://vincit.github.io/objection.js/guide/transactions.html#creating-a-transaction
2013
+ * @tutorial https://ditojs.github.io/objection/guide/transactions.html#creating-a-transaction
1762
2014
  */
1763
2015
  export interface transaction {
1764
2016
  start(knexOrModel: Knex | AnyModelConstructor): Promise<Transaction>;