typeorm-extensions 1.2.3 → 1.2.4

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 (84) hide show
  1. package/dist/constants/index.d.ts +5 -0
  2. package/dist/constants/index.js +8 -0
  3. package/dist/extensions/get-many-with-totals.extension.d.ts +16 -0
  4. package/dist/extensions/get-many-with-totals.extension.js +30 -0
  5. package/dist/extensions/index.js +20 -0
  6. package/dist/extensions/order.extension.d.ts +15 -0
  7. package/dist/extensions/order.extension.js +48 -0
  8. package/dist/extensions/ordering.extension.js +48 -0
  9. package/dist/extensions/pagination.extension.d.ts +10 -0
  10. package/dist/extensions/pagination.extension.js +13 -0
  11. package/{src/extensions/typed/index.ts → dist/extensions/typed/index.d.ts} +0 -5
  12. package/dist/extensions/typed/index.js +27 -0
  13. package/dist/extensions/typed/typed-distinct/typed-distinct.extension.d.ts +14 -0
  14. package/dist/extensions/typed/typed-distinct/typed-distinct.extension.js +11 -0
  15. package/dist/extensions/typed/typed-joins/typed-joins.extension.d.ts +10 -0
  16. package/dist/extensions/typed/typed-joins/typed-joins.extension.js +32 -0
  17. package/dist/extensions/typed/typed-order-by/typed-order-by.extension.d.ts +17 -0
  18. package/dist/extensions/typed/typed-order-by/typed-order-by.extension.js +25 -0
  19. package/dist/extensions/typed/typed-select/typed-select.extension.d.ts +33 -0
  20. package/dist/extensions/typed/typed-select/typed-select.extension.js +31 -0
  21. package/dist/extensions/typed/typed-where/typed-where.extension.d.ts +89 -0
  22. package/dist/extensions/typed/typed-where/typed-where.extension.js +33 -0
  23. package/dist/extensions/typed/typeorm-querybuilder.types.d.ts +22 -0
  24. package/dist/extensions/typed/typeorm-querybuilder.types.js +56 -0
  25. package/{src/extensions/typed/typeorm.types.ts → dist/extensions/typed/typeorm.types.d.ts} +7 -20
  26. package/dist/extensions/typed/typeorm.types.js +2 -0
  27. package/{src/index.ts → dist/index.d.ts} +0 -1
  28. package/dist/index.js +18 -0
  29. package/dist/types/interfaces/index.js +18 -0
  30. package/{src/types/interfaces/ordering.interface.ts → dist/types/interfaces/ordering.interface.d.ts} +7 -12
  31. package/dist/types/interfaces/ordering.interface.js +2 -0
  32. package/dist/types/interfaces/pagination.interface.d.ts +6 -0
  33. package/dist/types/interfaces/pagination.interface.js +2 -0
  34. package/{src/types/modules/column.types.ts → dist/types/modules/column.types.d.ts} +1 -3
  35. package/dist/types/modules/column.types.js +2 -0
  36. package/{src/types/modules/proxy-types/proxy-callback.types.ts → dist/types/modules/proxy-types/proxy-callback.types.d.ts} +2 -7
  37. package/dist/types/modules/proxy-types/proxy-callback.types.js +2 -0
  38. package/dist/types/modules/relations.types.d.ts +16 -0
  39. package/dist/types/modules/relations.types.js +2 -0
  40. package/dist/types/util-types/index.d.ts +7 -0
  41. package/dist/types/util-types/index.js +2 -0
  42. package/dist/utils/common.utils.d.ts +1 -0
  43. package/dist/utils/common.utils.js +5 -0
  44. package/dist/utils/identifier.utils.d.ts +15 -0
  45. package/dist/utils/identifier.utils.js +45 -0
  46. package/dist/utils/pagination.utils.d.ts +5 -0
  47. package/dist/utils/pagination.utils.js +16 -0
  48. package/dist/utils/proxy-key.utils.d.ts +22 -0
  49. package/dist/utils/proxy-key.utils.js +100 -0
  50. package/dist/utils/sql.utils.d.ts +5 -0
  51. package/dist/utils/sql.utils.js +18 -0
  52. package/dist/utils/string.utils.js +11 -0
  53. package/package.json +4 -1
  54. package/.eslintignore +0 -2
  55. package/.eslintrc +0 -12
  56. package/docs/api_reference/index.html +0 -21
  57. package/docs/api_reference/order/applyOrderFilter.html +0 -77
  58. package/docs/api_reference/order/index.html +0 -36
  59. package/docs/api_reference/pagination/applyPaginationFilter.html +0 -78
  60. package/docs/api_reference/pagination/index.html +0 -35
  61. package/docs/api_reference/typed/index.html +0 -37
  62. package/docs/examples/index.html +0 -21
  63. package/docs/index.html +0 -78
  64. package/src/constants/index.ts +0 -9
  65. package/src/extensions/get-many-with-totals.extension.ts +0 -62
  66. package/src/extensions/order.extension.ts +0 -123
  67. package/src/extensions/pagination.extension.ts +0 -35
  68. package/src/extensions/typed/typed-distinct/typed-distinct.extension.ts +0 -38
  69. package/src/extensions/typed/typed-joins/typed-joins.extension.ts +0 -141
  70. package/src/extensions/typed/typed-order-by/typed-order-by.extension.ts +0 -73
  71. package/src/extensions/typed/typed-select/typed-select.extension.ts +0 -124
  72. package/src/extensions/typed/typed-where/typed-where.extension.ts +0 -268
  73. package/src/extensions/typed/typeorm-querybuilder.types.ts +0 -75
  74. package/src/types/interfaces/pagination.interface.ts +0 -8
  75. package/src/types/modules/relations.types.ts +0 -34
  76. package/src/types/util-types/index.ts +0 -8
  77. package/src/utils/common.utils.ts +0 -2
  78. package/src/utils/identifier.utils.ts +0 -60
  79. package/src/utils/pagination.utils.ts +0 -17
  80. package/src/utils/proxy-key.utils.ts +0 -133
  81. package/src/utils/sql.utils.ts +0 -24
  82. package/tsconfig.json +0 -109
  83. /package/{src/extensions/index.ts → dist/extensions/index.d.ts} +0 -0
  84. /package/{src/types/interfaces/index.ts → dist/types/interfaces/index.d.ts} +0 -0
@@ -1,36 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>Order / Api reference / typeorm-extensions</title>
7
- </head>
8
- <body>
9
- <header>
10
- <h1>Category: Order</h1>
11
- </header>
12
-
13
- <main>
14
- <section>
15
- <h2>
16
- Categories:
17
- </h2>
18
- <ul>
19
- <li><a href="../pagination">Pagination</a></li>
20
- <li><a href="../order">Order</a></li>
21
- <li><a href="../typed">Typed Extensions</a></li>
22
- </ul>
23
- </section>
24
-
25
- <section>
26
- <h2>
27
- Functions:
28
- </h2>
29
- <ul>
30
- <li><a href="applyOrderFilter.html">applyOrderFilter</a></li>
31
- <li><a href="applyOrder.html">applyOrder</a></li>
32
- </ul>
33
- </section>
34
- </main>
35
- </body>
36
- </html>
@@ -1,78 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>applyPaginationFilter / API reference / typeorm-extensions</title>
7
- </head>
8
- <body>
9
- <header>
10
- <h1>applyPaginationFilter</h1>
11
-
12
- </header>
13
-
14
- <nav>
15
- <ul>
16
- <li><a href="../pagination">Pagination</a></li>
17
- <li><a href="../order">Order</a></li>
18
- <li><a href="../typed">Typed Extensions</a></li>
19
- </ul>
20
- </nav>
21
-
22
- <main>
23
- <section>
24
- <h2>Description</h2>
25
- <p>
26
- <code>applyPaginationFilter</code> is a method that applies pagination to a query.
27
- </p>
28
- </section>
29
- <section>
30
- <h2>Signature</h2>
31
- <p>
32
- <pre><code>applyPaginationFilter(paginationFilter: PaginationFilter, paginationOptions?: ApplyPaginationOptions): void</code></pre>
33
- </p>
34
- </section>
35
- <section>
36
- <h2>Arguments</h2>
37
- <ul>
38
- <li>
39
- <h3>paginationFilter: PaginationFilter</h3>
40
- <p>The pagination options to apply to the query.</p>
41
- <p>
42
- <h4>Properties</h4>
43
- <ul>
44
- <li>
45
- <h5>page: number</h5>
46
- <p>The page number to retrieve.</p>
47
- </li>
48
- <li>
49
- <h5>pageSize: number</h5>
50
- <p>The number of items per page.</p>
51
- </li>
52
- </ul>
53
- </p>
54
- </li>
55
- <li>
56
- <h3>(optional) paginationOptions?: ApplyPaginationOptions</h3>
57
- <p>Additional options to apply to the pagination filter.</p>
58
- <p>
59
- <h4>Properties</h4>
60
- <ul>
61
- <li>
62
- <h5>useTakeAndSkip?: boolean</h5>
63
- <p>
64
- Whether to use the <code>take</code> and <code>skip</code> methods instead of <code>limit</code> and <code>offset</code> (defaults to false).
65
- </p>
66
- </li>
67
- </ul>
68
- </p>
69
- </li>
70
- </ul>
71
- </section>
72
- <section>
73
- <h2>Usage</h2>
74
- <pre><code>query.applyPaginationFilter({ page: 1, pageSize: 10 }, { useTakeAndSkip: true })</code></pre>
75
- </section>
76
- </main>
77
- </body>
78
- </html>
@@ -1,35 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>Pagination / Api reference / typeorm-extensions</title>
7
- </head>
8
- <body>
9
- <header>
10
- <h1>Category: Pagination</h1>
11
- </header>
12
-
13
- <main>
14
- <section>
15
- <h2>
16
- Categories:
17
- </h2>
18
- <ul>
19
- <li><a href="../pagination">Pagination</a></li>
20
- <li><a href="../order">Order</a></li>
21
- <li><a href="../typed">Typed Extensions</a></li>
22
- </ul>
23
- </section>
24
-
25
- <section>
26
- <h2>
27
- Functions:
28
- </h2>
29
- <ul>
30
- <li><a href="applyPaginationFilter.html">applyPaginationFilter</a></li>
31
- </ul>
32
- </section>
33
- </main>
34
- </body>
35
- </html>
@@ -1,37 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>Typed extensions / Api reference / typeorm-extensions</title>
7
- </head>
8
- <body>
9
- <header>
10
- <h1>Category: Typed Extensions</h1>
11
- </header>
12
-
13
- <main>
14
-
15
- <section>
16
- <h2>
17
- Categories:
18
- </h2>
19
- <ul>
20
- <li><a href="../pagination">Pagination</a></li>
21
- <li><a href="../order">Order</a></li>
22
- <li><a href="../typed">Typed Extensions</a></li>
23
- </ul>
24
- </section>
25
-
26
- <section>
27
- <h2>
28
- Functions:
29
- </h2>
30
- <ul>
31
- <li><a href="typed-where.html">whereTyped</a></li>
32
- <li><a href="/">...TBD...</a></li>
33
- </ul>
34
- </section>
35
- </main>
36
- </body>
37
- </html>
@@ -1,21 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>Examples / typeorm-extensions</title>
7
- </head>
8
- <body>
9
- <header>
10
- <h1>Examples</h1>
11
- </header>
12
-
13
- <nav>
14
- <ul>
15
- <li><a href="pagination">Pagination</a></li>
16
- <li><a href="order">Order</a></li>
17
- <li><a href="typed">Typed Extensions</a></li>
18
- </ul>
19
- </nav>
20
- </body>
21
- </html>
package/docs/index.html DELETED
@@ -1,78 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>typeorm-extensions</title>
5
- <link rel="stylesheet" href="styles.css" />
6
- </head>
7
- <body>
8
- <header>
9
- <h1>Documentation</h1>
10
- </header>
11
-
12
- <nav>
13
- <ul>
14
- <li><a href="#getting-started">Getting Started</a></li>
15
- <li><a href="#usage">Usage</a></li>
16
- <li><a href="api_reference">API Reference</a></li>
17
- <li><a href="examples">Examples</a></li>
18
- </ul>
19
- </nav>
20
-
21
- <main>
22
- <section id="getting-started">
23
- <h2>Getting Started</h2>
24
- <p>
25
- <h3>Installation</h3>
26
- <p>Install using npm, yarn or pnpm:</p>
27
- <pre><code>npm install typeorm-extensions</code></pre>
28
- </p>
29
- <p>
30
- <h3>Importing</h3>
31
- <h4>Import the entire library:</h4>
32
- <pre><code>import from 'typeorm-extensions';</code></pre>
33
- <h4>Import the specific extension:</h4>
34
- <pre><code>import from 'typeorm-extensions/dist/extensions/typed/typed-where/typed-where.extension';</code></pre>
35
- </p>
36
- </section>
37
-
38
- <section id="api-reference">
39
- <h2>API Reference</h2>
40
- <p>
41
- API documentation is available <a href="api_reference">here</a>
42
- </p>
43
- </section>
44
-
45
- <section id="usage">
46
- <h2>Usage</h2>
47
- <p>
48
- <h3>Pagination</h3>
49
- <pre><code>query.applyPaginationFilter({ page: 1, pageSize: 10 }, { useTakeAndSkip: true })</code></pre>
50
- </p>
51
- <p>
52
- <h3>Typed Where</h3>
53
- <pre><code>query.whereTyped(user => user.name, 'ILIKE :search', { search: value })</code></pre>
54
- </p>
55
- <p>
56
- <h3>Typed Order By</h3>
57
- <pre><code>query.orderByTyped(user => user.name, 'ASC')</code></pre>
58
- </p>
59
- <p>
60
- <h3>Typed Select</h3>
61
- <pre><code>query.selectTyped(user => user.name)</code></pre>
62
- </p>
63
- <p>
64
- <h3>Typed Join</h3>
65
- <pre><code>query.leftJoinTyped(user => user.address, 'address')</code></pre>
66
- </p>
67
- <br>
68
- <p>
69
- For other examples please visit the <a href="examples">Examples</a> page.
70
- </p>
71
- </section>
72
- </main>
73
-
74
- <footer>
75
- <p>&copy; 2024 typeorm-extensions</p>
76
- </footer>
77
- </body>
78
- </html>
@@ -1,9 +0,0 @@
1
- export const defaultPageSize = 10;
2
-
3
- export const defaultUseTakeAndSkip = false;
4
-
5
- export const defaultUseDoubleQuotes = true;
6
-
7
- export const defaultOrderDirection = 'ASC';
8
-
9
- export const defaultNullsOrder = undefined;
@@ -1,62 +0,0 @@
1
- import { SelectQueryBuilder } from 'typeorm/query-builder/SelectQueryBuilder';
2
- import { PaginationFilter } from '../types/interfaces/pagination.interface';
3
- import { getLimitAndOffset } from '../utils/pagination.utils';
4
- import { ApplyPaginationOptions } from './pagination.extension';
5
-
6
- export type GetManyWithTotalsOptions = {
7
- disableTotalsCalculation?: boolean;
8
- loadAll?: boolean;
9
- };
10
-
11
- export interface ListWithTotals<Entity> {
12
- list: Entity[];
13
- totalCount: number | null;
14
- limit: number | null;
15
- offset: number | null;
16
- }
17
-
18
- declare module 'typeorm/query-builder/SelectQueryBuilder' {
19
- interface SelectQueryBuilder<Entity> {
20
- getManyWithTotals(
21
- paginationFilter: PaginationFilter,
22
- options?: GetManyWithTotalsOptions
23
- ): Promise<ListWithTotals<Entity>>;
24
- }
25
- }
26
-
27
- SelectQueryBuilder.prototype.getManyWithTotals = async function <Entity>(
28
- paginationFilter: PaginationFilter,
29
- options?: GetManyWithTotalsOptions & ApplyPaginationOptions
30
- ): Promise<ListWithTotals<Entity>> {
31
- const { disableTotalsCalculation = false, loadAll = false } = options || {};
32
-
33
- const { limit, offset } = loadAll
34
- ? { limit: null, offset: null }
35
- : getLimitAndOffset(paginationFilter);
36
-
37
- const requests = [];
38
-
39
- if (!disableTotalsCalculation) {
40
- requests[0] = this.getCount();
41
- } else {
42
- requests[0] = Promise.resolve(null);
43
- }
44
-
45
- if (loadAll) {
46
- requests[1] = this.getMany();
47
- } else {
48
- requests[1] = this.applyPaginationFilter(paginationFilter).getMany();
49
- }
50
-
51
- const [totalCount, list] = (await Promise.all(requests)) as [
52
- number | null,
53
- Entity[]
54
- ];
55
-
56
- return {
57
- list,
58
- totalCount: totalCount,
59
- limit,
60
- offset,
61
- };
62
- };
@@ -1,123 +0,0 @@
1
- import { SelectQueryBuilder } from 'typeorm/query-builder/SelectQueryBuilder';
2
- import type {
3
- OrderParam,
4
- OrderFilter,
5
- OrderType,
6
- } from '../types/interfaces/ordering.interface';
7
- import {
8
- defaultNullsOrder,
9
- defaultOrderDirection,
10
- defaultUseDoubleQuotes,
11
- } from '../constants';
12
- import { ObjectLiteral } from 'typeorm';
13
- import { isNil } from '../utils/common.utils';
14
- import { Identifier } from '../utils/identifier.utils';
15
-
16
- const alwaysAliasWhiteList = [
17
- 'id',
18
- 'createdAt',
19
- 'created_at',
20
- 'updatedAt',
21
- 'updated_at',
22
- 'deletedAt',
23
- 'deleted_at',
24
- ];
25
-
26
- export type ApplyOrderOptions = {
27
- useDoubleQuotes?: boolean;
28
- alias?: string;
29
- alwaysAliasFields?: string[];
30
- resetPreviousOrder?: boolean;
31
- };
32
-
33
- declare module 'typeorm/query-builder/SelectQueryBuilder' {
34
- interface SelectQueryBuilder<Entity> {
35
- applyOrder<OrderEntity>(
36
- orderBy: OrderParam<OrderEntity>,
37
- options?: ApplyOrderOptions
38
- ): SelectQueryBuilder<Entity>;
39
- applyOrderFilter<OrderEntity>(
40
- orderFilter: OrderFilter<OrderEntity>,
41
- options?: ApplyOrderOptions
42
- ): SelectQueryBuilder<Entity>;
43
- }
44
- }
45
-
46
- SelectQueryBuilder.prototype.applyOrder = function <
47
- Entity extends ObjectLiteral,
48
- OrderEntity
49
- >(
50
- orderBy: OrderParam<OrderEntity>,
51
- options?: ApplyOrderOptions
52
- ): SelectQueryBuilder<Entity> {
53
- const { resetPreviousOrder = false } = options ?? {};
54
-
55
- const orderOption = getOrderOption(orderBy, this.alias, options);
56
-
57
- const query = resetPreviousOrder ? this.orderBy() : this;
58
-
59
- return query.addOrderBy(
60
- orderOption.selector,
61
- orderOption.order,
62
- orderOption.nulls
63
- );
64
- };
65
-
66
- SelectQueryBuilder.prototype.applyOrderFilter = function <
67
- Entity extends ObjectLiteral,
68
- OrderEntity
69
- >(
70
- orderFilter: OrderFilter<OrderEntity>,
71
- options?: ApplyOrderOptions
72
- ): SelectQueryBuilder<Entity> {
73
- if (!isNil(orderFilter?.orderBy)) {
74
- return orderFilter.orderBy!.reduce(
75
- (acc, order, index) =>
76
- acc.applyOrder(order, {
77
- ...options,
78
- resetPreviousOrder: index === 0 ? options?.resetPreviousOrder : false,
79
- }),
80
- this as SelectQueryBuilder<Entity>
81
- );
82
- }
83
-
84
- return this;
85
- };
86
-
87
- export const getOrderOption = <OrderEntity>(
88
- orderBy: OrderParam<OrderEntity>,
89
- defaultAlias: string,
90
- options?: ApplyOrderOptions
91
- ): OrderType => {
92
- const {
93
- useDoubleQuotes = defaultUseDoubleQuotes,
94
- alias: customAlias,
95
- alwaysAliasFields = alwaysAliasWhiteList,
96
- } = options ?? {};
97
- const {
98
- field,
99
- direction = defaultOrderDirection,
100
- nulls: nullsOrder = defaultNullsOrder,
101
- } = orderBy;
102
-
103
- const alias =
104
- customAlias ??
105
- (alwaysAliasFields.includes(field as string) ? defaultAlias : undefined);
106
-
107
- const identifier = new Identifier(field, alias, useDoubleQuotes);
108
-
109
- const selector = identifier.fieldIdentifier();
110
- const order = direction.toUpperCase() as 'ASC' | 'DESC';
111
-
112
- const nulls = nullsOrder
113
- ? (`NULLS ${nullsOrder.toUpperCase()}` as 'NULLS LAST' | 'NULLS FIRST')
114
- : undefined;
115
-
116
- return {
117
- selector,
118
- order,
119
- nulls,
120
- };
121
- };
122
-
123
- export {};
@@ -1,35 +0,0 @@
1
- import { SelectQueryBuilder } from 'typeorm/query-builder/SelectQueryBuilder';
2
- import type { PaginationFilter } from '../types/interfaces/pagination.interface';
3
- import { defaultUseTakeAndSkip } from '../constants';
4
- import { getLimitAndOffset } from '../utils/pagination.utils';
5
- import { ObjectLiteral } from 'typeorm';
6
-
7
- export type ApplyPaginationOptions = {
8
- useTakeAndSkip?: boolean;
9
- };
10
-
11
- declare module 'typeorm/query-builder/SelectQueryBuilder' {
12
- interface SelectQueryBuilder<Entity> {
13
- applyPaginationFilter(
14
- paginationFilter: PaginationFilter,
15
- options?: ApplyPaginationOptions
16
- ): SelectQueryBuilder<Entity>;
17
- }
18
- }
19
-
20
- SelectQueryBuilder.prototype.applyPaginationFilter = function <Entity extends ObjectLiteral>(
21
- paginationFilter: PaginationFilter,
22
- options?: ApplyPaginationOptions
23
- ): SelectQueryBuilder<Entity> {
24
- const { useTakeAndSkip = defaultUseTakeAndSkip } = options || {};
25
-
26
- const { limit, offset } = getLimitAndOffset(paginationFilter);
27
-
28
- if (useTakeAndSkip) {
29
- return this.take(limit).skip(offset);
30
- }
31
-
32
- return this.limit(limit).offset(offset);
33
- };
34
-
35
- export {};
@@ -1,38 +0,0 @@
1
- import { ObjectLiteral, SelectQueryBuilder } from 'typeorm';
2
- import { ColumnValueType } from '../typeorm.types';
3
- import { getSqlKey } from '../../../utils/proxy-key.utils';
4
-
5
- declare module 'typeorm/query-builder/SelectQueryBuilder' {
6
- interface SelectQueryBuilder<Entity> {
7
- /**
8
- * Sets the distinct on clause for Postgres.
9
- */
10
- distinctOnTyped<Type extends ObjectLiteral = Entity>(
11
- this: SelectQueryBuilder<Entity>,
12
- ...distinctOn: Array<(proxy: Type) => ColumnValueType>
13
- ): SelectQueryBuilder<Entity>;
14
- /**
15
- * Sets the distinct on clause for Postgres.
16
- */
17
- distinctOnTyped<Type extends ObjectLiteral = Entity>(
18
- this: SelectQueryBuilder<Entity>,
19
- distinctOn: (proxy: Type) => Array<ColumnValueType>
20
- ): SelectQueryBuilder<Entity>;
21
- }
22
- }
23
-
24
- SelectQueryBuilder.prototype.distinctOnTyped = function <
25
- Entity extends ObjectLiteral,
26
- Type extends ObjectLiteral = Entity
27
- >(
28
- this: SelectQueryBuilder<Entity>,
29
- ...distinctOn: Array<(proxy: Type) => ColumnValueType | Array<ColumnValueType>>
30
- ): SelectQueryBuilder<Entity> {
31
- if (Array.isArray(distinctOn) && distinctOn.length) {
32
- const keys = distinctOn.map((callback) => getSqlKey<Type>(callback, this.alias)).flat(3);
33
-
34
- return this.distinctOn(keys as string[]);
35
- }
36
-
37
- return this;
38
- };