typeorm-extensions 2.2.0-rc.1 → 2.2.0-rc.11

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 (115) hide show
  1. package/README.md +70 -39
  2. package/dist/decorators/calculated-column.decorator.d.ts +7 -3
  3. package/dist/decorators/calculated-column.decorator.js +35 -6
  4. package/dist/decorators/generated-column.decorator.d.ts +17 -0
  5. package/dist/decorators/generated-column.decorator.js +15 -0
  6. package/dist/decorators/index.d.ts +1 -0
  7. package/dist/decorators/index.js +1 -0
  8. package/dist/extensions/calculated-column.extension.d.ts +3 -3
  9. package/dist/extensions/calculated-column.extension.js +3 -16
  10. package/dist/extensions/cursor-pagination.extension.d.ts +15 -2
  11. package/dist/extensions/cursor-pagination.extension.js +90 -13
  12. package/dist/extensions/get-many-with-totals.extension.js +12 -31
  13. package/dist/extensions/join-lateral.extension.js +4 -6
  14. package/dist/extensions/order.extension.d.ts +2 -2
  15. package/dist/extensions/pagination.extension.d.ts +7 -1
  16. package/dist/extensions/pagination.extension.js +5 -12
  17. package/dist/extensions/period-filter.extension.d.ts +4 -0
  18. package/dist/extensions/period-filter.extension.js +1 -9
  19. package/dist/extensions/typed/index.d.ts +2 -0
  20. package/dist/extensions/typed/index.js +2 -0
  21. package/dist/extensions/typed/typed-calculated/typed-calculated-column.extension.d.ts +19 -0
  22. package/dist/extensions/typed/typed-calculated/typed-calculated-column.extension.js +17 -0
  23. package/dist/extensions/typed/typed-distinct/typed-distinct.extension.d.ts +6 -4
  24. package/dist/extensions/typed/typed-distinct/typed-distinct.extension.js +9 -2
  25. package/dist/extensions/typed/typed-group-by/typed-group-by.extension.d.ts +8 -7
  26. package/dist/extensions/typed/typed-group-by/typed-group-by.extension.js +1 -1
  27. package/dist/extensions/typed/typed-having/typed-having.extension.d.ts +4 -4
  28. package/dist/extensions/typed/typed-having/typed-having.extension.js +1 -1
  29. package/dist/extensions/typed/typed-joins/typed-join-and-map.extension.d.ts +19 -0
  30. package/dist/extensions/typed/typed-joins/typed-join-and-map.extension.js +23 -0
  31. package/dist/extensions/typed/typed-joins/typed-joins.extension.d.ts +4 -4
  32. package/dist/extensions/typed/typed-joins/typed-joins.extension.js +11 -22
  33. package/dist/extensions/typed/typed-order-by/typed-order-by-array-position.extension.d.ts +2 -2
  34. package/dist/extensions/typed/typed-order-by/typed-order-by.extension.d.ts +4 -2
  35. package/dist/extensions/typed/typed-order-by/typed-order-by.extension.js +18 -17
  36. package/dist/extensions/typed/typed-returning/typed-returning.extension.js +1 -9
  37. package/dist/extensions/typed/typed-root.extension.d.ts +26 -4
  38. package/dist/extensions/typed/typed-select/typed-select.extension.d.ts +6 -6
  39. package/dist/extensions/typed/typed-select/typed-select.extension.js +3 -9
  40. package/dist/extensions/typed/typed-where/typed-period-filter.extension.d.ts +5 -1
  41. package/dist/extensions/typed/typed-where/typed-period-filter.extension.js +1 -9
  42. package/dist/extensions/typed/typed-where/typed-where-array.extension.d.ts +13 -9
  43. package/dist/extensions/typed/typed-where/typed-where-array.extension.js +4 -16
  44. package/dist/extensions/typed/typed-where/typed-where-ilike.extension.d.ts +10 -6
  45. package/dist/extensions/typed/typed-where/typed-where-ilike.extension.js +1 -9
  46. package/dist/extensions/typed/typed-where/typed-where-is-any.extension.d.ts +10 -6
  47. package/dist/extensions/typed/typed-where/typed-where-is-any.extension.js +3 -20
  48. package/dist/extensions/typed/typed-where/typed-where-is-distinct-from.extension.d.ts +10 -6
  49. package/dist/extensions/typed/typed-where/typed-where-is-distinct-from.extension.js +3 -20
  50. package/dist/extensions/typed/typed-where/typed-where-is-in.extension.d.ts +10 -6
  51. package/dist/extensions/typed/typed-where/typed-where-is-in.extension.js +3 -21
  52. package/dist/extensions/typed/typed-where/typed-where-json.extension.d.ts +10 -6
  53. package/dist/extensions/typed/typed-where/typed-where-json.extension.js +4 -21
  54. package/dist/extensions/typed/typed-where/typed-where-lower.extension.d.ts +10 -6
  55. package/dist/extensions/typed/typed-where/typed-where-lower.extension.js +1 -9
  56. package/dist/extensions/typed/typed-where/typed-where-similar.extension.d.ts +8 -4
  57. package/dist/extensions/typed/typed-where/typed-where-similar.extension.js +1 -8
  58. package/dist/extensions/typed/typed-where/typed-where.extension.d.ts +7 -3
  59. package/dist/extensions/typed/typed-where/typed-where.extension.js +2 -10
  60. package/dist/extensions/union.extension.js +1 -1
  61. package/dist/extensions/where-array.extension.d.ts +4 -0
  62. package/dist/extensions/where-array.extension.js +1 -9
  63. package/dist/extensions/where-exists.extension.js +4 -15
  64. package/dist/extensions/where-is-any.extension.d.ts +41 -128
  65. package/dist/extensions/where-is-any.extension.js +1 -9
  66. package/dist/extensions/where-is-distinct-from.extension.d.ts +4 -0
  67. package/dist/extensions/where-is-distinct-from.extension.js +1 -9
  68. package/dist/extensions/where-is-in.extension.d.ts +38 -116
  69. package/dist/extensions/where-is-in.extension.js +11 -27
  70. package/dist/extensions/where-json.extension.d.ts +4 -0
  71. package/dist/extensions/where-json.extension.js +1 -9
  72. package/dist/extensions/where-relation-exists.extension.d.ts +6 -6
  73. package/dist/extensions/where-relation-exists.extension.js +5 -25
  74. package/dist/helpers.d.ts +5 -0
  75. package/dist/helpers.js +12 -3
  76. package/dist/index.d.ts +1 -2
  77. package/dist/index.js +1 -4
  78. package/dist/types/extensions/cursor-pagination.types.d.ts +16 -1
  79. package/dist/types/extensions/get-many-with-totals.types.d.ts +4 -0
  80. package/dist/types/extensions/index.d.ts +1 -0
  81. package/dist/types/extensions/index.js +1 -0
  82. package/dist/types/extensions/typed-group-by.types.d.ts +2 -2
  83. package/dist/types/extensions/typed-join-and-map.types.d.ts +6 -0
  84. package/dist/types/extensions/typed-join-and-map.types.js +2 -0
  85. package/dist/types/interfaces/cursor-pagination.interface.d.ts +11 -0
  86. package/dist/types/modules/typed-root.types.d.ts +11 -9
  87. package/dist/utils/calculated-column.utils.d.ts +11 -0
  88. package/dist/utils/calculated-column.utils.js +33 -4
  89. package/dist/utils/common.utils.d.ts +2 -0
  90. package/dist/utils/common.utils.js +4 -1
  91. package/dist/utils/cursor.utils.d.ts +5 -0
  92. package/dist/utils/cursor.utils.js +18 -7
  93. package/dist/utils/json-path.utils.js +2 -2
  94. package/dist/utils/pagination.utils.d.ts +10 -0
  95. package/dist/utils/pagination.utils.js +27 -10
  96. package/dist/utils/parameter.utils.d.ts +10 -0
  97. package/dist/utils/parameter.utils.js +22 -1
  98. package/dist/utils/period.utils.js +2 -1
  99. package/dist/utils/prototype.utils.d.ts +9 -0
  100. package/dist/utils/prototype.utils.js +12 -2
  101. package/dist/utils/query-builder.utils.d.ts +43 -4
  102. package/dist/utils/query-builder.utils.js +239 -36
  103. package/dist/utils/reserved-qualifier-guard.utils.d.ts +36 -0
  104. package/dist/utils/reserved-qualifier-guard.utils.js +98 -0
  105. package/dist/utils/reserved-qualifier.utils.d.ts +33 -0
  106. package/dist/utils/reserved-qualifier.utils.js +252 -0
  107. package/dist/utils/table.utils.d.ts +27 -11
  108. package/dist/utils/table.utils.js +58 -23
  109. package/dist/utils/time-zone.utils.d.ts +8 -0
  110. package/dist/utils/time-zone.utils.js +15 -5
  111. package/dist/utils/typed-where.utils.d.ts +9 -0
  112. package/dist/utils/typed-where.utils.js +17 -0
  113. package/dist/utils/where.utils.d.ts +2 -0
  114. package/dist/utils/where.utils.js +21 -14
  115. package/package.json +2 -2
@@ -12,7 +12,7 @@ export interface TypedPeriodFilterMethods<Entity extends ObjectLiteral> {
12
12
  * Both ends are inclusive unless `options.includeFrom` / `options.includeTo` is `false`.
13
13
  * A date-only string (`'2024-01-31'`) stands for the whole day: `periodTo: '2024-01-31'` → `column < '2024-02-01'`.
14
14
  */
15
- applyPeriodFilterTyped<Type extends ObjectLiteral = TypedRoot<Entity>>(selection: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, periodFilter: PeriodFilter | null | undefined, options?: ApplyPeriodOptions): this;
15
+ applyPeriodFilterTyped<Type extends ObjectLiteral = TypedRoot<Entity, this>>(selection: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, periodFilter: PeriodFilter | null | undefined, options?: ApplyPeriodOptions): this;
16
16
  }
17
17
  declare module 'typeorm/query-builder/WhereExpressionBuilder' {
18
18
  interface WhereExpressionBuilder extends TypedPeriodFilterMethods<ObjectLiteral> {
@@ -30,3 +30,7 @@ declare module 'typeorm/query-builder/DeleteQueryBuilder' {
30
30
  interface DeleteQueryBuilder<Entity extends ObjectLiteral> extends TypedPeriodFilterMethods<Entity> {
31
31
  }
32
32
  }
33
+ declare module 'typeorm/query-builder/SoftDeleteQueryBuilder' {
34
+ interface SoftDeleteQueryBuilder<Entity extends ObjectLiteral> extends TypedPeriodFilterMethods<Entity> {
35
+ }
36
+ }
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  require("../../period-filter.extension");
4
- const typeorm_1 = require("typeorm");
5
4
  const query_builder_utils_1 = require("../../../utils/query-builder.utils");
6
5
  const prototype_utils_1 = require("../../../utils/prototype.utils");
7
6
  const period_utils_1 = require("../../../utils/period.utils");
@@ -15,11 +14,4 @@ const extension = {
15
14
  },
16
15
  },
17
16
  };
18
- const queryBuilders = [
19
- typeorm_1.SelectQueryBuilder,
20
- typeorm_1.UpdateQueryBuilder,
21
- typeorm_1.DeleteQueryBuilder,
22
- ];
23
- queryBuilders.forEach((builder) => {
24
- (0, prototype_utils_1.patchPrototype)(builder, extension);
25
- });
17
+ (0, prototype_utils_1.patchPrototypes)(prototype_utils_1.WHERE_QUERY_BUILDERS, extension);
@@ -13,43 +13,43 @@ export interface TypedWhereArrayMethods<Entity extends ObjectLiteral> {
13
13
  * If you had previously WHERE expression defined,
14
14
  * calling this function will override previously set WHERE conditions.
15
15
  */
16
- whereArrayContainsTyped<Type extends ObjectLiteral = TypedRoot<Entity>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, values: ArgsType, arrayType?: string): this;
16
+ whereArrayContainsTyped<Type extends ObjectLiteral = TypedRoot<Entity, this>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, values: ArgsType, arrayType?: string): this;
17
17
  /**
18
18
  * Adds new AND WHERE `column @> :values` condition (PostgreSQL): the array column contains every value.
19
19
  */
20
- andWhereArrayContainsTyped<Type extends ObjectLiteral = TypedRoot<Entity>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, values: ArgsType, arrayType?: string): this;
20
+ andWhereArrayContainsTyped<Type extends ObjectLiteral = TypedRoot<Entity, this>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, values: ArgsType, arrayType?: string): this;
21
21
  /**
22
22
  * Adds new OR WHERE `column @> :values` condition (PostgreSQL): the array column contains every value.
23
23
  */
24
- orWhereArrayContainsTyped<Type extends ObjectLiteral = TypedRoot<Entity>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, values: ArgsType, arrayType?: string): this;
24
+ orWhereArrayContainsTyped<Type extends ObjectLiteral = TypedRoot<Entity, this>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, values: ArgsType, arrayType?: string): this;
25
25
  /**
26
26
  * Sets WHERE `column <@ :values` condition (PostgreSQL): every element of the array column is one of the values.
27
27
  * If you had previously WHERE expression defined,
28
28
  * calling this function will override previously set WHERE conditions.
29
29
  */
30
- whereArrayContainedByTyped<Type extends ObjectLiteral = TypedRoot<Entity>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, values: ArgsType, arrayType?: string): this;
30
+ whereArrayContainedByTyped<Type extends ObjectLiteral = TypedRoot<Entity, this>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, values: ArgsType, arrayType?: string): this;
31
31
  /**
32
32
  * Adds new AND WHERE `column <@ :values` condition (PostgreSQL): every element of the array column is one of the values.
33
33
  */
34
- andWhereArrayContainedByTyped<Type extends ObjectLiteral = TypedRoot<Entity>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, values: ArgsType, arrayType?: string): this;
34
+ andWhereArrayContainedByTyped<Type extends ObjectLiteral = TypedRoot<Entity, this>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, values: ArgsType, arrayType?: string): this;
35
35
  /**
36
36
  * Adds new OR WHERE `column <@ :values` condition (PostgreSQL): every element of the array column is one of the values.
37
37
  */
38
- orWhereArrayContainedByTyped<Type extends ObjectLiteral = TypedRoot<Entity>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, values: ArgsType, arrayType?: string): this;
38
+ orWhereArrayContainedByTyped<Type extends ObjectLiteral = TypedRoot<Entity, this>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, values: ArgsType, arrayType?: string): this;
39
39
  /**
40
40
  * Sets WHERE `column && :values` condition (PostgreSQL): the array column has at least one of the values.
41
41
  * If you had previously WHERE expression defined,
42
42
  * calling this function will override previously set WHERE conditions.
43
43
  */
44
- whereArrayOverlapsTyped<Type extends ObjectLiteral = TypedRoot<Entity>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, values: ArgsType, arrayType?: string): this;
44
+ whereArrayOverlapsTyped<Type extends ObjectLiteral = TypedRoot<Entity, this>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, values: ArgsType, arrayType?: string): this;
45
45
  /**
46
46
  * Adds new AND WHERE `column && :values` condition (PostgreSQL): the array column has at least one of the values.
47
47
  */
48
- andWhereArrayOverlapsTyped<Type extends ObjectLiteral = TypedRoot<Entity>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, values: ArgsType, arrayType?: string): this;
48
+ andWhereArrayOverlapsTyped<Type extends ObjectLiteral = TypedRoot<Entity, this>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, values: ArgsType, arrayType?: string): this;
49
49
  /**
50
50
  * Adds new OR WHERE `column && :values` condition (PostgreSQL): the array column has at least one of the values.
51
51
  */
52
- orWhereArrayOverlapsTyped<Type extends ObjectLiteral = TypedRoot<Entity>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, values: ArgsType, arrayType?: string): this;
52
+ orWhereArrayOverlapsTyped<Type extends ObjectLiteral = TypedRoot<Entity, this>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, values: ArgsType, arrayType?: string): this;
53
53
  }
54
54
  declare module 'typeorm/query-builder/WhereExpressionBuilder' {
55
55
  interface WhereExpressionBuilder extends TypedWhereArrayMethods<ObjectLiteral> {
@@ -67,3 +67,7 @@ declare module 'typeorm/query-builder/DeleteQueryBuilder' {
67
67
  interface DeleteQueryBuilder<Entity extends ObjectLiteral> extends TypedWhereArrayMethods<Entity> {
68
68
  }
69
69
  }
70
+ declare module 'typeorm/query-builder/SoftDeleteQueryBuilder' {
71
+ interface SoftDeleteQueryBuilder<Entity extends ObjectLiteral> extends TypedWhereArrayMethods<Entity> {
72
+ }
73
+ }
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  require("../../where-array.extension");
4
- const typeorm_1 = require("typeorm");
5
4
  const query_builder_utils_1 = require("../../../utils/query-builder.utils");
6
5
  const sql_utils_1 = require("../../../utils/sql.utils");
7
6
  const prototype_utils_1 = require("../../../utils/prototype.utils");
7
+ const typed_where_utils_1 = require("../../../utils/typed-where.utils");
8
8
  /* eslint-enable @typescript-eslint/no-empty-interface */
9
9
  // patching
10
10
  const createWhereArrayTypedMethod = (method) => function (where, values, arrayType) {
@@ -23,25 +23,13 @@ const extension = {
23
23
  orWhereArrayOverlapsTyped: createWhereArrayTypedMethod('orWhereArrayOverlaps'),
24
24
  },
25
25
  };
26
- const queryBuilders = [
27
- typeorm_1.SelectQueryBuilder,
28
- typeorm_1.UpdateQueryBuilder,
29
- typeorm_1.DeleteQueryBuilder,
30
- ];
31
- queryBuilders.forEach((builder) => {
32
- (0, prototype_utils_1.patchPrototype)(builder, extension);
33
- });
26
+ (0, prototype_utils_1.patchPrototypes)(prototype_utils_1.WHERE_QUERY_BUILDERS, extension);
34
27
  // implementation
35
28
  function attachWhereArrayTyped(builder, method, where, values, arrayType) {
36
- if (typeof where !== 'function') {
37
- return builder;
38
- }
39
- const key = (0, query_builder_utils_1.getTypedSingleColumnKey)(builder, where, `${method}Typed`);
40
- if ((0, query_builder_utils_1.isTypedJsonPath)(builder, where)) {
29
+ if (typeof where === 'function' && (0, query_builder_utils_1.isTypedJsonPath)(builder, where)) {
41
30
  return attachWhereJsonArray(builder, method, where, values, arrayType);
42
31
  }
43
- // .andWhereArrayContains(`"table"."column"`, ['value'])
44
- return builder[method](key, values, arrayType);
32
+ return (0, typed_where_utils_1.attachTypedColumnWhere)(builder, method, where, undefined, values, arrayType);
45
33
  }
46
34
  const JSON_ARRAY_METHOD = /^(where|andWhere|orWhere)Array(Contains|ContainedBy|Overlaps)$/;
47
35
  const JSON_ARRAY_OPERATORS = { Contains: '@>', ContainedBy: '<@', Overlaps: '?|' };
@@ -14,17 +14,17 @@ export interface TypedWhereILikeMethods<Entity extends ObjectLiteral> {
14
14
  * If you had previously WHERE expression defined,
15
15
  * calling this function will override previously set WHERE conditions.
16
16
  */
17
- whereILikeTyped<Type extends ObjectLiteral = TypedRoot<Entity>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, value: string | null | undefined, options?: TypedILikeOptions): this;
17
+ whereILikeTyped<Type extends ObjectLiteral = TypedRoot<Entity, this>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, value: string | null | undefined, options?: TypedILikeOptions): this;
18
18
  /**
19
19
  * Adds new AND WHERE `column ILIKE :pattern` condition in the query builder.
20
20
  * `null`, `undefined` or a blank value adds no condition.
21
21
  */
22
- andWhereILikeTyped<Type extends ObjectLiteral = TypedRoot<Entity>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, value: string | null | undefined, options?: TypedILikeOptions): this;
22
+ andWhereILikeTyped<Type extends ObjectLiteral = TypedRoot<Entity, this>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, value: string | null | undefined, options?: TypedILikeOptions): this;
23
23
  /**
24
24
  * Adds new OR WHERE `column ILIKE :pattern` condition in the query builder.
25
25
  * `null`, `undefined` or a blank value adds no condition.
26
26
  */
27
- orWhereILikeTyped<Type extends ObjectLiteral = TypedRoot<Entity>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, value: string | null | undefined, options?: TypedILikeOptions): this;
27
+ orWhereILikeTyped<Type extends ObjectLiteral = TypedRoot<Entity, this>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, value: string | null | undefined, options?: TypedILikeOptions): this;
28
28
  /**
29
29
  * Sets WHERE `(col1 ILIKE :pattern OR col2 ILIKE :pattern …)` condition in the query builder:
30
30
  * one group, one parameter for every column. A selector is a typed callback (it may select
@@ -33,17 +33,17 @@ export interface TypedWhereILikeMethods<Entity extends ObjectLiteral> {
33
33
  * If you had previously WHERE expression defined,
34
34
  * calling this function will override previously set WHERE conditions.
35
35
  */
36
- whereSearchTyped<Type extends ObjectLiteral = TypedRoot<Entity>>(selectors: ReadonlyArray<SearchSelector<Type>>, value: string | null | undefined, options?: TypedSearchOptions): this;
36
+ whereSearchTyped<Type extends ObjectLiteral = TypedRoot<Entity, this>>(selectors: ReadonlyArray<SearchSelector<Type>>, value: string | null | undefined, options?: TypedSearchOptions): this;
37
37
  /**
38
38
  * Adds new AND WHERE `(col1 ILIKE :pattern OR col2 ILIKE :pattern …)` condition in the query builder.
39
39
  * A value shorter than `options.minLength` (default 1, after trimming) adds no condition.
40
40
  */
41
- andWhereSearchTyped<Type extends ObjectLiteral = TypedRoot<Entity>>(selectors: ReadonlyArray<SearchSelector<Type>>, value: string | null | undefined, options?: TypedSearchOptions): this;
41
+ andWhereSearchTyped<Type extends ObjectLiteral = TypedRoot<Entity, this>>(selectors: ReadonlyArray<SearchSelector<Type>>, value: string | null | undefined, options?: TypedSearchOptions): this;
42
42
  /**
43
43
  * Adds new OR WHERE `(col1 ILIKE :pattern OR col2 ILIKE :pattern …)` condition in the query builder.
44
44
  * A value shorter than `options.minLength` (default 1, after trimming) adds no condition.
45
45
  */
46
- orWhereSearchTyped<Type extends ObjectLiteral = TypedRoot<Entity>>(selectors: ReadonlyArray<SearchSelector<Type>>, value: string | null | undefined, options?: TypedSearchOptions): this;
46
+ orWhereSearchTyped<Type extends ObjectLiteral = TypedRoot<Entity, this>>(selectors: ReadonlyArray<SearchSelector<Type>>, value: string | null | undefined, options?: TypedSearchOptions): this;
47
47
  }
48
48
  declare module 'typeorm/query-builder/WhereExpressionBuilder' {
49
49
  interface WhereExpressionBuilder extends TypedWhereILikeMethods<ObjectLiteral> {
@@ -61,3 +61,7 @@ declare module 'typeorm/query-builder/DeleteQueryBuilder' {
61
61
  interface DeleteQueryBuilder<Entity extends ObjectLiteral> extends TypedWhereILikeMethods<Entity> {
62
62
  }
63
63
  }
64
+ declare module 'typeorm/query-builder/SoftDeleteQueryBuilder' {
65
+ interface SoftDeleteQueryBuilder<Entity extends ObjectLiteral> extends TypedWhereILikeMethods<Entity> {
66
+ }
67
+ }
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const typeorm_1 = require("typeorm");
4
3
  const query_builder_utils_1 = require("../../../utils/query-builder.utils");
5
4
  const prototype_utils_1 = require("../../../utils/prototype.utils");
6
5
  const sql_utils_1 = require("../../../utils/sql.utils");
@@ -42,14 +41,7 @@ const extension = {
42
41
  orWhereSearchTyped: createWhereSearchTypedMethod('orWhere'),
43
42
  },
44
43
  };
45
- const queryBuilders = [
46
- typeorm_1.SelectQueryBuilder,
47
- typeorm_1.UpdateQueryBuilder,
48
- typeorm_1.DeleteQueryBuilder,
49
- ];
50
- queryBuilders.forEach((builder) => {
51
- (0, prototype_utils_1.patchPrototype)(builder, extension);
52
- });
44
+ (0, prototype_utils_1.patchPrototypes)(prototype_utils_1.WHERE_QUERY_BUILDERS, extension);
53
45
  // implementation
54
46
  /** Quoted columns and raw expressions of the search selectors, in order. */
55
47
  function getSearchColumns(builder, selectors, methodName) {
@@ -11,30 +11,30 @@ export interface TypedWhereIsAnyMethods<Entity extends ObjectLiteral> {
11
11
  * If you had previously WHERE expression defined,
12
12
  * calling this function will override previously set WHERE conditions.
13
13
  */
14
- whereIsAnyTyped<Type extends ObjectLiteral = UnsetType, Value extends ProxyColumnValueType = ProxyColumnValueType>(where: (proxy: DeepUnwrapArray<TypeOrDefault<Type, TypedRoot<Entity>>>) => Value, array?: TypedArrayArg<Type, Value>, arrayType?: string): this;
14
+ whereIsAnyTyped<Type extends ObjectLiteral = UnsetType, Value extends ProxyColumnValueType = ProxyColumnValueType>(where: (proxy: DeepUnwrapArray<TypeOrDefault<Type, TypedRoot<Entity, this>>>) => Value, array?: TypedArrayArg<Type, Value>, arrayType?: string): this;
15
15
  /**
16
16
  * Adds new AND WHERE `column = ANY(:array)` condition in the query builder (PostgreSQL).
17
17
  */
18
- andWhereIsAnyTyped<Type extends ObjectLiteral = UnsetType, Value extends ProxyColumnValueType = ProxyColumnValueType>(where: (proxy: DeepUnwrapArray<TypeOrDefault<Type, TypedRoot<Entity>>>) => Value, array?: TypedArrayArg<Type, Value>, arrayType?: string): this;
18
+ andWhereIsAnyTyped<Type extends ObjectLiteral = UnsetType, Value extends ProxyColumnValueType = ProxyColumnValueType>(where: (proxy: DeepUnwrapArray<TypeOrDefault<Type, TypedRoot<Entity, this>>>) => Value, array?: TypedArrayArg<Type, Value>, arrayType?: string): this;
19
19
  /**
20
20
  * Adds new OR WHERE `column = ANY(:array)` condition in the query builder (PostgreSQL).
21
21
  */
22
- orWhereIsAnyTyped<Type extends ObjectLiteral = UnsetType, Value extends ProxyColumnValueType = ProxyColumnValueType>(where: (proxy: DeepUnwrapArray<TypeOrDefault<Type, TypedRoot<Entity>>>) => Value, array?: TypedArrayArg<Type, Value>, arrayType?: string): this;
22
+ orWhereIsAnyTyped<Type extends ObjectLiteral = UnsetType, Value extends ProxyColumnValueType = ProxyColumnValueType>(where: (proxy: DeepUnwrapArray<TypeOrDefault<Type, TypedRoot<Entity, this>>>) => Value, array?: TypedArrayArg<Type, Value>, arrayType?: string): this;
23
23
  /**
24
24
  * Sets WHERE `column <> ALL(:array)` condition in the query builder (PostgreSQL):
25
25
  * the column differs from every value of the array.
26
26
  * If you had previously WHERE expression defined,
27
27
  * calling this function will override previously set WHERE conditions.
28
28
  */
29
- whereIsNotAnyTyped<Type extends ObjectLiteral = UnsetType, Value extends ProxyColumnValueType = ProxyColumnValueType>(where: (proxy: DeepUnwrapArray<TypeOrDefault<Type, TypedRoot<Entity>>>) => Value, array?: TypedArrayArg<Type, Value>, arrayType?: string): this;
29
+ whereIsNotAnyTyped<Type extends ObjectLiteral = UnsetType, Value extends ProxyColumnValueType = ProxyColumnValueType>(where: (proxy: DeepUnwrapArray<TypeOrDefault<Type, TypedRoot<Entity, this>>>) => Value, array?: TypedArrayArg<Type, Value>, arrayType?: string): this;
30
30
  /**
31
31
  * Adds new AND WHERE `column <> ALL(:array)` condition in the query builder (PostgreSQL).
32
32
  */
33
- andWhereIsNotAnyTyped<Type extends ObjectLiteral = UnsetType, Value extends ProxyColumnValueType = ProxyColumnValueType>(where: (proxy: DeepUnwrapArray<TypeOrDefault<Type, TypedRoot<Entity>>>) => Value, array?: TypedArrayArg<Type, Value>, arrayType?: string): this;
33
+ andWhereIsNotAnyTyped<Type extends ObjectLiteral = UnsetType, Value extends ProxyColumnValueType = ProxyColumnValueType>(where: (proxy: DeepUnwrapArray<TypeOrDefault<Type, TypedRoot<Entity, this>>>) => Value, array?: TypedArrayArg<Type, Value>, arrayType?: string): this;
34
34
  /**
35
35
  * Adds new OR WHERE `column <> ALL(:array)` condition in the query builder (PostgreSQL).
36
36
  */
37
- orWhereIsNotAnyTyped<Type extends ObjectLiteral = UnsetType, Value extends ProxyColumnValueType = ProxyColumnValueType>(where: (proxy: DeepUnwrapArray<TypeOrDefault<Type, TypedRoot<Entity>>>) => Value, array?: TypedArrayArg<Type, Value>, arrayType?: string): this;
37
+ orWhereIsNotAnyTyped<Type extends ObjectLiteral = UnsetType, Value extends ProxyColumnValueType = ProxyColumnValueType>(where: (proxy: DeepUnwrapArray<TypeOrDefault<Type, TypedRoot<Entity, this>>>) => Value, array?: TypedArrayArg<Type, Value>, arrayType?: string): this;
38
38
  }
39
39
  declare module 'typeorm/query-builder/WhereExpressionBuilder' {
40
40
  interface WhereExpressionBuilder extends TypedWhereIsAnyMethods<ObjectLiteral> {
@@ -52,3 +52,7 @@ declare module 'typeorm/query-builder/DeleteQueryBuilder' {
52
52
  interface DeleteQueryBuilder<Entity extends ObjectLiteral> extends TypedWhereIsAnyMethods<Entity> {
53
53
  }
54
54
  }
55
+ declare module 'typeorm/query-builder/SoftDeleteQueryBuilder' {
56
+ interface SoftDeleteQueryBuilder<Entity extends ObjectLiteral> extends TypedWhereIsAnyMethods<Entity> {
57
+ }
58
+ }
@@ -1,13 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  require("../../where-is-any.extension");
4
- const typeorm_1 = require("typeorm");
5
- const query_builder_utils_1 = require("../../../utils/query-builder.utils");
6
4
  const prototype_utils_1 = require("../../../utils/prototype.utils");
5
+ const typed_where_utils_1 = require("../../../utils/typed-where.utils");
7
6
  /* eslint-enable @typescript-eslint/no-empty-interface */
8
7
  // patching
9
8
  const createWhereIsAnyTypedMethod = (method) => function (where, array, arrayType) {
10
- return attachWhereIsAnyTyped(this, method, where, array, arrayType);
9
+ return (0, typed_where_utils_1.attachTypedColumnWhere)(this, method, where, { value: array }, array, arrayType);
11
10
  };
12
11
  const extension = {
13
12
  prototype: {
@@ -19,20 +18,4 @@ const extension = {
19
18
  orWhereIsNotAnyTyped: createWhereIsAnyTypedMethod('orWhereIsNotAny'),
20
19
  },
21
20
  };
22
- const queryBuilders = [
23
- typeorm_1.SelectQueryBuilder,
24
- typeorm_1.UpdateQueryBuilder,
25
- typeorm_1.DeleteQueryBuilder,
26
- ];
27
- queryBuilders.forEach((builder) => {
28
- (0, prototype_utils_1.patchPrototype)(builder, extension);
29
- });
30
- // implementation
31
- function attachWhereIsAnyTyped(builder, method, where, array, arrayType) {
32
- if (typeof where !== 'function') {
33
- return builder;
34
- }
35
- const key = (0, query_builder_utils_1.getTypedSingleColumnKey)(builder, where, `${method}Typed`, { value: array });
36
- // .andWhere(`"table"."column" = ANY(:param)`, { param: ['value'] })
37
- return builder[method](key, array, arrayType);
38
- }
21
+ (0, prototype_utils_1.patchPrototypes)(prototype_utils_1.WHERE_QUERY_BUILDERS, extension);
@@ -12,29 +12,29 @@ export interface TypedWhereDistinctMethods<Entity extends ObjectLiteral> {
12
12
  * If you had previously WHERE expression defined,
13
13
  * calling this function will override previously set WHERE conditions.
14
14
  */
15
- whereIsDistinctFromTyped<Type extends ObjectLiteral = TypedRoot<Entity>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, value: unknown): this;
15
+ whereIsDistinctFromTyped<Type extends ObjectLiteral = TypedRoot<Entity, this>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, value: unknown): this;
16
16
  /**
17
17
  * Adds new AND WHERE `column IS DISTINCT FROM :value` condition: the column differs from the value, `NULL` included.
18
18
  */
19
- andWhereIsDistinctFromTyped<Type extends ObjectLiteral = TypedRoot<Entity>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, value: unknown): this;
19
+ andWhereIsDistinctFromTyped<Type extends ObjectLiteral = TypedRoot<Entity, this>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, value: unknown): this;
20
20
  /**
21
21
  * Adds new OR WHERE `column IS DISTINCT FROM :value` condition: the column differs from the value, `NULL` included.
22
22
  */
23
- orWhereIsDistinctFromTyped<Type extends ObjectLiteral = TypedRoot<Entity>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, value: unknown): this;
23
+ orWhereIsDistinctFromTyped<Type extends ObjectLiteral = TypedRoot<Entity, this>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, value: unknown): this;
24
24
  /**
25
25
  * Sets WHERE `column IS NOT DISTINCT FROM :value` condition: the column equals the value, `NULL` included.
26
26
  * If you had previously WHERE expression defined,
27
27
  * calling this function will override previously set WHERE conditions.
28
28
  */
29
- whereIsNotDistinctFromTyped<Type extends ObjectLiteral = TypedRoot<Entity>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, value: unknown): this;
29
+ whereIsNotDistinctFromTyped<Type extends ObjectLiteral = TypedRoot<Entity, this>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, value: unknown): this;
30
30
  /**
31
31
  * Adds new AND WHERE `column IS NOT DISTINCT FROM :value` condition: the column equals the value, `NULL` included.
32
32
  */
33
- andWhereIsNotDistinctFromTyped<Type extends ObjectLiteral = TypedRoot<Entity>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, value: unknown): this;
33
+ andWhereIsNotDistinctFromTyped<Type extends ObjectLiteral = TypedRoot<Entity, this>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, value: unknown): this;
34
34
  /**
35
35
  * Adds new OR WHERE `column IS NOT DISTINCT FROM :value` condition: the column equals the value, `NULL` included.
36
36
  */
37
- orWhereIsNotDistinctFromTyped<Type extends ObjectLiteral = TypedRoot<Entity>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, value: unknown): this;
37
+ orWhereIsNotDistinctFromTyped<Type extends ObjectLiteral = TypedRoot<Entity, this>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, value: unknown): this;
38
38
  }
39
39
  declare module 'typeorm/query-builder/WhereExpressionBuilder' {
40
40
  interface WhereExpressionBuilder extends TypedWhereDistinctMethods<ObjectLiteral> {
@@ -52,3 +52,7 @@ declare module 'typeorm/query-builder/DeleteQueryBuilder' {
52
52
  interface DeleteQueryBuilder<Entity extends ObjectLiteral> extends TypedWhereDistinctMethods<Entity> {
53
53
  }
54
54
  }
55
+ declare module 'typeorm/query-builder/SoftDeleteQueryBuilder' {
56
+ interface SoftDeleteQueryBuilder<Entity extends ObjectLiteral> extends TypedWhereDistinctMethods<Entity> {
57
+ }
58
+ }
@@ -1,13 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  require("../../where-is-distinct-from.extension");
4
- const typeorm_1 = require("typeorm");
5
- const query_builder_utils_1 = require("../../../utils/query-builder.utils");
6
4
  const prototype_utils_1 = require("../../../utils/prototype.utils");
5
+ const typed_where_utils_1 = require("../../../utils/typed-where.utils");
7
6
  /* eslint-enable @typescript-eslint/no-empty-interface */
8
7
  // patching
9
8
  const createWhereDistinctTypedMethod = (method) => function (where, value) {
10
- return attachWhereDistinctTyped(this, method, where, value);
9
+ return (0, typed_where_utils_1.attachTypedColumnWhere)(this, method, where, { value }, value);
11
10
  };
12
11
  const extension = {
13
12
  prototype: {
@@ -19,20 +18,4 @@ const extension = {
19
18
  orWhereIsNotDistinctFromTyped: createWhereDistinctTypedMethod('orWhereIsNotDistinctFrom'),
20
19
  },
21
20
  };
22
- const queryBuilders = [
23
- typeorm_1.SelectQueryBuilder,
24
- typeorm_1.UpdateQueryBuilder,
25
- typeorm_1.DeleteQueryBuilder,
26
- ];
27
- queryBuilders.forEach((builder) => {
28
- (0, prototype_utils_1.patchPrototype)(builder, extension);
29
- });
30
- // implementation
31
- function attachWhereDistinctTyped(builder, method, where, value) {
32
- if (typeof where !== 'function') {
33
- return builder;
34
- }
35
- const key = (0, query_builder_utils_1.getTypedSingleColumnKey)(builder, where, `${method}Typed`, { value });
36
- // .andWhereIsDistinctFrom(`"table"."column"`, value)
37
- return builder[method](key, value);
38
- }
21
+ (0, prototype_utils_1.patchPrototypes)(prototype_utils_1.WHERE_QUERY_BUILDERS, extension);
@@ -9,29 +9,29 @@ export interface TypedWhereIsInMethods<Entity extends ObjectLiteral> {
9
9
  * If you had previously WHERE expression defined,
10
10
  * calling this function will override previously set WHERE conditions.
11
11
  */
12
- whereIsInTyped<Type extends ObjectLiteral = UnsetType, Value extends ProxyColumnValueType = ProxyColumnValueType>(where: (proxy: DeepUnwrapArray<TypeOrDefault<Type, TypedRoot<Entity>>>) => Value, array?: TypedArrayArg<Type, Value>): this;
12
+ whereIsInTyped<Type extends ObjectLiteral = UnsetType, Value extends ProxyColumnValueType = ProxyColumnValueType>(where: (proxy: DeepUnwrapArray<TypeOrDefault<Type, TypedRoot<Entity, this>>>) => Value, array?: TypedArrayArg<Type, Value>): this;
13
13
  /**
14
14
  * Adds new AND WHERE IN condition in the query builder.
15
15
  */
16
- andWhereIsInTyped<Type extends ObjectLiteral = UnsetType, Value extends ProxyColumnValueType = ProxyColumnValueType>(where: (proxy: DeepUnwrapArray<TypeOrDefault<Type, TypedRoot<Entity>>>) => Value, array?: TypedArrayArg<Type, Value>): this;
16
+ andWhereIsInTyped<Type extends ObjectLiteral = UnsetType, Value extends ProxyColumnValueType = ProxyColumnValueType>(where: (proxy: DeepUnwrapArray<TypeOrDefault<Type, TypedRoot<Entity, this>>>) => Value, array?: TypedArrayArg<Type, Value>): this;
17
17
  /**
18
18
  * Adds new OR WHERE IN condition in the query builder.
19
19
  */
20
- orWhereIsInTyped<Type extends ObjectLiteral = UnsetType, Value extends ProxyColumnValueType = ProxyColumnValueType>(where: (proxy: DeepUnwrapArray<TypeOrDefault<Type, TypedRoot<Entity>>>) => Value, array?: TypedArrayArg<Type, Value>): this;
20
+ orWhereIsInTyped<Type extends ObjectLiteral = UnsetType, Value extends ProxyColumnValueType = ProxyColumnValueType>(where: (proxy: DeepUnwrapArray<TypeOrDefault<Type, TypedRoot<Entity, this>>>) => Value, array?: TypedArrayArg<Type, Value>): this;
21
21
  /**
22
22
  * Sets WHERE NOT IN condition in the query builder.
23
23
  * If you had previously WHERE expression defined,
24
24
  * calling this function will override previously set WHERE conditions.
25
25
  */
26
- whereIsNotInTyped<Type extends ObjectLiteral = UnsetType, Value extends ProxyColumnValueType = ProxyColumnValueType>(where: (proxy: DeepUnwrapArray<TypeOrDefault<Type, TypedRoot<Entity>>>) => Value, array?: TypedArrayArg<Type, Value>): this;
26
+ whereIsNotInTyped<Type extends ObjectLiteral = UnsetType, Value extends ProxyColumnValueType = ProxyColumnValueType>(where: (proxy: DeepUnwrapArray<TypeOrDefault<Type, TypedRoot<Entity, this>>>) => Value, array?: TypedArrayArg<Type, Value>): this;
27
27
  /**
28
28
  * Adds new AND WHERE NOT IN condition in the query builder.
29
29
  */
30
- andWhereIsNotInTyped<Type extends ObjectLiteral = UnsetType, Value extends ProxyColumnValueType = ProxyColumnValueType>(where: (proxy: DeepUnwrapArray<TypeOrDefault<Type, TypedRoot<Entity>>>) => Value, array?: TypedArrayArg<Type, Value>): this;
30
+ andWhereIsNotInTyped<Type extends ObjectLiteral = UnsetType, Value extends ProxyColumnValueType = ProxyColumnValueType>(where: (proxy: DeepUnwrapArray<TypeOrDefault<Type, TypedRoot<Entity, this>>>) => Value, array?: TypedArrayArg<Type, Value>): this;
31
31
  /**
32
32
  * Adds new OR WHERE NOT IN condition in the query builder.
33
33
  */
34
- orWhereIsNotInTyped<Type extends ObjectLiteral = UnsetType, Value extends ProxyColumnValueType = ProxyColumnValueType>(where: (proxy: DeepUnwrapArray<TypeOrDefault<Type, TypedRoot<Entity>>>) => Value, array?: TypedArrayArg<Type, Value>): this;
34
+ orWhereIsNotInTyped<Type extends ObjectLiteral = UnsetType, Value extends ProxyColumnValueType = ProxyColumnValueType>(where: (proxy: DeepUnwrapArray<TypeOrDefault<Type, TypedRoot<Entity, this>>>) => Value, array?: TypedArrayArg<Type, Value>): this;
35
35
  }
36
36
  declare module 'typeorm/query-builder/WhereExpressionBuilder' {
37
37
  interface WhereExpressionBuilder extends TypedWhereIsInMethods<ObjectLiteral> {
@@ -49,3 +49,7 @@ declare module 'typeorm/query-builder/DeleteQueryBuilder' {
49
49
  interface DeleteQueryBuilder<Entity extends ObjectLiteral> extends TypedWhereIsInMethods<Entity> {
50
50
  }
51
51
  }
52
+ declare module 'typeorm/query-builder/SoftDeleteQueryBuilder' {
53
+ interface SoftDeleteQueryBuilder<Entity extends ObjectLiteral> extends TypedWhereIsInMethods<Entity> {
54
+ }
55
+ }
@@ -1,13 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  require("../../where-is-in.extension");
4
- const typeorm_1 = require("typeorm");
5
- const query_builder_utils_1 = require("../../../utils/query-builder.utils");
6
4
  const prototype_utils_1 = require("../../../utils/prototype.utils");
5
+ const typed_where_utils_1 = require("../../../utils/typed-where.utils");
7
6
  /* eslint-enable @typescript-eslint/no-empty-interface */
8
7
  // patching
9
8
  const createWhereIsInTypedMethod = (method) => function (where, array) {
10
- return attachWhereIsIn(this, method, where, array);
9
+ return (0, typed_where_utils_1.attachTypedColumnWhere)(this, method, where, { value: array }, array);
11
10
  };
12
11
  const extension = {
13
12
  prototype: {
@@ -19,21 +18,4 @@ const extension = {
19
18
  orWhereIsNotInTyped: createWhereIsInTypedMethod('orWhereIsNotIn'),
20
19
  },
21
20
  };
22
- const queryBuilders = [
23
- typeorm_1.SelectQueryBuilder,
24
- typeorm_1.UpdateQueryBuilder,
25
- typeorm_1.DeleteQueryBuilder,
26
- ];
27
- queryBuilders.forEach((builder) => {
28
- (0, prototype_utils_1.patchPrototype)(builder, extension);
29
- });
30
- // implementation
31
- function attachWhereIsIn(builder, method, where, array) {
32
- if (typeof where === 'function') {
33
- // several columns have no single meaning (AND? OR?), and `where…` kept only the last one
34
- const key = (0, query_builder_utils_1.getTypedSingleColumnKey)(builder, where, `${method}Typed`, { value: array });
35
- // .andWhere(`"table"."column" IN (:...values)`, { values: ['value'] })
36
- return builder[method](key, array);
37
- }
38
- return builder;
39
- }
21
+ (0, prototype_utils_1.patchPrototypes)(prototype_utils_1.WHERE_QUERY_BUILDERS, extension);
@@ -12,29 +12,29 @@ export interface TypedWhereJsonMethods<Entity extends ObjectLiteral> {
12
12
  * If you had previously WHERE expression defined,
13
13
  * calling this function will override previously set WHERE conditions.
14
14
  */
15
- whereJsonContainsTyped<Type extends ObjectLiteral = TypedRoot<Entity>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, value: unknown): this;
15
+ whereJsonContainsTyped<Type extends ObjectLiteral = TypedRoot<Entity, this>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, value: unknown): this;
16
16
  /**
17
17
  * Adds new AND WHERE `column @> :value` condition (PostgreSQL): the JSON document contains `value`.
18
18
  */
19
- andWhereJsonContainsTyped<Type extends ObjectLiteral = TypedRoot<Entity>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, value: unknown): this;
19
+ andWhereJsonContainsTyped<Type extends ObjectLiteral = TypedRoot<Entity, this>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, value: unknown): this;
20
20
  /**
21
21
  * Adds new OR WHERE `column @> :value` condition (PostgreSQL): the JSON document contains `value`.
22
22
  */
23
- orWhereJsonContainsTyped<Type extends ObjectLiteral = TypedRoot<Entity>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, value: unknown): this;
23
+ orWhereJsonContainsTyped<Type extends ObjectLiteral = TypedRoot<Entity, this>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, value: unknown): this;
24
24
  /**
25
25
  * Sets WHERE `column ? :key` condition (PostgreSQL): the JSON object has the top-level key.
26
26
  * If you had previously WHERE expression defined,
27
27
  * calling this function will override previously set WHERE conditions.
28
28
  */
29
- whereJsonHasKeyTyped<Type extends ObjectLiteral = TypedRoot<Entity>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, key: string): this;
29
+ whereJsonHasKeyTyped<Type extends ObjectLiteral = TypedRoot<Entity, this>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, key: string): this;
30
30
  /**
31
31
  * Adds new AND WHERE `column ? :key` condition (PostgreSQL): the JSON object has the top-level key.
32
32
  */
33
- andWhereJsonHasKeyTyped<Type extends ObjectLiteral = TypedRoot<Entity>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, key: string): this;
33
+ andWhereJsonHasKeyTyped<Type extends ObjectLiteral = TypedRoot<Entity, this>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, key: string): this;
34
34
  /**
35
35
  * Adds new OR WHERE `column ? :key` condition (PostgreSQL): the JSON object has the top-level key.
36
36
  */
37
- orWhereJsonHasKeyTyped<Type extends ObjectLiteral = TypedRoot<Entity>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, key: string): this;
37
+ orWhereJsonHasKeyTyped<Type extends ObjectLiteral = TypedRoot<Entity, this>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, key: string): this;
38
38
  }
39
39
  declare module 'typeorm/query-builder/WhereExpressionBuilder' {
40
40
  interface WhereExpressionBuilder extends TypedWhereJsonMethods<ObjectLiteral> {
@@ -52,3 +52,7 @@ declare module 'typeorm/query-builder/DeleteQueryBuilder' {
52
52
  interface DeleteQueryBuilder<Entity extends ObjectLiteral> extends TypedWhereJsonMethods<Entity> {
53
53
  }
54
54
  }
55
+ declare module 'typeorm/query-builder/SoftDeleteQueryBuilder' {
56
+ interface SoftDeleteQueryBuilder<Entity extends ObjectLiteral> extends TypedWhereJsonMethods<Entity> {
57
+ }
58
+ }
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  require("../../where-json.extension");
4
- const typeorm_1 = require("typeorm");
5
- const query_builder_utils_1 = require("../../../utils/query-builder.utils");
6
4
  const prototype_utils_1 = require("../../../utils/prototype.utils");
5
+ const typed_where_utils_1 = require("../../../utils/typed-where.utils");
7
6
  /* eslint-enable @typescript-eslint/no-empty-interface */
8
7
  // patching
9
8
  const createWhereJsonTypedMethod = (method) => function (where, value) {
10
- return attachWhereJsonTyped(this, method, where, value);
9
+ // one signature for both: `value` is the JSON value or the key, each method checks its own
10
+ return (0, typed_where_utils_1.attachTypedColumnWhere)(this, method, where, { accessor: 'json' }, value);
11
11
  };
12
12
  const extension = {
13
13
  prototype: {
@@ -19,21 +19,4 @@ const extension = {
19
19
  orWhereJsonHasKeyTyped: createWhereJsonTypedMethod('orWhereJsonHasKey'),
20
20
  },
21
21
  };
22
- const queryBuilders = [
23
- typeorm_1.SelectQueryBuilder,
24
- typeorm_1.UpdateQueryBuilder,
25
- typeorm_1.DeleteQueryBuilder,
26
- ];
27
- queryBuilders.forEach((builder) => {
28
- (0, prototype_utils_1.patchPrototype)(builder, extension);
29
- });
30
- // implementation
31
- function attachWhereJsonTyped(builder, method, where, value) {
32
- if (typeof where !== 'function') {
33
- return builder;
34
- }
35
- const key = (0, query_builder_utils_1.getTypedSingleColumnKey)(builder, where, `${method}Typed`, { accessor: 'json' });
36
- // .andWhereJsonContains(`"table"."column"`, { role: 'admin' }) / .andWhereJsonHasKey(`"table"."column"`, 'role')
37
- // (one signature for both: `value` is the JSON value or the key, each method checks its own)
38
- return builder[method](key, value);
39
- }
22
+ (0, prototype_utils_1.patchPrototypes)(prototype_utils_1.WHERE_QUERY_BUILDERS, extension);
@@ -13,34 +13,34 @@ export interface TypedWhereLowerMethods<Entity extends ObjectLiteral> {
13
13
  * If you had previously WHERE expression defined,
14
14
  * calling this function will override previously set WHERE conditions.
15
15
  */
16
- whereLowerEqualsTyped<Type extends ObjectLiteral = TypedRoot<Entity>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, value: string | null | undefined, options?: TypedLowerOptions): this;
16
+ whereLowerEqualsTyped<Type extends ObjectLiteral = TypedRoot<Entity, this>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, value: string | null | undefined, options?: TypedLowerOptions): this;
17
17
  /**
18
18
  * Adds new AND WHERE `LOWER(column) = LOWER(:value)` condition in the query builder.
19
19
  * `null` / `undefined` matches nothing (`FALSE`).
20
20
  */
21
- andWhereLowerEqualsTyped<Type extends ObjectLiteral = TypedRoot<Entity>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, value: string | null | undefined, options?: TypedLowerOptions): this;
21
+ andWhereLowerEqualsTyped<Type extends ObjectLiteral = TypedRoot<Entity, this>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, value: string | null | undefined, options?: TypedLowerOptions): this;
22
22
  /**
23
23
  * Adds new OR WHERE `LOWER(column) = LOWER(:value)` condition in the query builder.
24
24
  * `null` / `undefined` matches nothing (`FALSE`).
25
25
  */
26
- orWhereLowerEqualsTyped<Type extends ObjectLiteral = TypedRoot<Entity>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, value: string | null | undefined, options?: TypedLowerOptions): this;
26
+ orWhereLowerEqualsTyped<Type extends ObjectLiteral = TypedRoot<Entity, this>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, value: string | null | undefined, options?: TypedLowerOptions): this;
27
27
  /**
28
28
  * Sets WHERE `LOWER(column) IN (LOWER(:v1), LOWER(:v2), …)` condition in the query builder.
29
29
  * An empty or missing array matches nothing (`FALSE`), like `whereIsIn`.
30
30
  * If you had previously WHERE expression defined,
31
31
  * calling this function will override previously set WHERE conditions.
32
32
  */
33
- whereIsInLowerTyped<Type extends ObjectLiteral = TypedRoot<Entity>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, values: ReadonlyArray<string> | null | undefined, options?: TypedLowerOptions): this;
33
+ whereIsInLowerTyped<Type extends ObjectLiteral = TypedRoot<Entity, this>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, values: ReadonlyArray<string> | null | undefined, options?: TypedLowerOptions): this;
34
34
  /**
35
35
  * Adds new AND WHERE `LOWER(column) IN (LOWER(:v1), LOWER(:v2), …)` condition in the query builder.
36
36
  * An empty or missing array matches nothing (`FALSE`).
37
37
  */
38
- andWhereIsInLowerTyped<Type extends ObjectLiteral = TypedRoot<Entity>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, values: ReadonlyArray<string> | null | undefined, options?: TypedLowerOptions): this;
38
+ andWhereIsInLowerTyped<Type extends ObjectLiteral = TypedRoot<Entity, this>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, values: ReadonlyArray<string> | null | undefined, options?: TypedLowerOptions): this;
39
39
  /**
40
40
  * Adds new OR WHERE `LOWER(column) IN (LOWER(:v1), LOWER(:v2), …)` condition in the query builder.
41
41
  * An empty or missing array matches nothing (`FALSE`).
42
42
  */
43
- orWhereIsInLowerTyped<Type extends ObjectLiteral = TypedRoot<Entity>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, values: ReadonlyArray<string> | null | undefined, options?: TypedLowerOptions): this;
43
+ orWhereIsInLowerTyped<Type extends ObjectLiteral = TypedRoot<Entity, this>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, values: ReadonlyArray<string> | null | undefined, options?: TypedLowerOptions): this;
44
44
  }
45
45
  declare module 'typeorm/query-builder/WhereExpressionBuilder' {
46
46
  interface WhereExpressionBuilder extends TypedWhereLowerMethods<ObjectLiteral> {
@@ -58,3 +58,7 @@ declare module 'typeorm/query-builder/DeleteQueryBuilder' {
58
58
  interface DeleteQueryBuilder<Entity extends ObjectLiteral> extends TypedWhereLowerMethods<Entity> {
59
59
  }
60
60
  }
61
+ declare module 'typeorm/query-builder/SoftDeleteQueryBuilder' {
62
+ interface SoftDeleteQueryBuilder<Entity extends ObjectLiteral> extends TypedWhereLowerMethods<Entity> {
63
+ }
64
+ }