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
@@ -1,39 +1,23 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const typeorm_1 = require("typeorm");
4
3
  const prototype_utils_1 = require("../utils/prototype.utils");
5
4
  const where_utils_1 = require("../utils/where.utils");
5
+ /* eslint-enable @typescript-eslint/no-empty-interface, @typescript-eslint/no-unused-vars */
6
6
  // patching
7
+ const createWhereIsInMethod = (method, operator) => function (field, array) {
8
+ return attachWhereIsIn(this, method, field, operator, array);
9
+ };
7
10
  const extension = {
8
11
  prototype: {
9
- whereIsIn: function (field, array) {
10
- return attachWhereIsIn(this, 'where', field, 'IN', array);
11
- },
12
- andWhereIsIn: function (field, array) {
13
- return attachWhereIsIn(this, 'andWhere', field, 'IN', array);
14
- },
15
- orWhereIsIn: function (field, array) {
16
- return attachWhereIsIn(this, 'orWhere', field, 'IN', array);
17
- },
18
- whereIsNotIn: function (field, array) {
19
- return attachWhereIsIn(this, 'where', field, 'NOT IN', array);
20
- },
21
- andWhereIsNotIn: function (field, array) {
22
- return attachWhereIsIn(this, 'andWhere', field, 'NOT IN', array);
23
- },
24
- orWhereIsNotIn: function (field, array) {
25
- return attachWhereIsIn(this, 'orWhere', field, 'NOT IN', array);
26
- },
12
+ whereIsIn: createWhereIsInMethod('where', 'IN'),
13
+ andWhereIsIn: createWhereIsInMethod('andWhere', 'IN'),
14
+ orWhereIsIn: createWhereIsInMethod('orWhere', 'IN'),
15
+ whereIsNotIn: createWhereIsInMethod('where', 'NOT IN'),
16
+ andWhereIsNotIn: createWhereIsInMethod('andWhere', 'NOT IN'),
17
+ orWhereIsNotIn: createWhereIsInMethod('orWhere', 'NOT IN'),
27
18
  },
28
19
  };
29
- const queryBuilders = [
30
- typeorm_1.SelectQueryBuilder,
31
- typeorm_1.UpdateQueryBuilder,
32
- typeorm_1.DeleteQueryBuilder,
33
- ];
34
- queryBuilders.forEach((builder) => {
35
- (0, prototype_utils_1.patchPrototype)(builder, extension);
36
- });
20
+ (0, prototype_utils_1.patchPrototypes)(prototype_utils_1.WHERE_QUERY_BUILDERS, extension);
37
21
  // implementation
38
22
  function attachWhereIsIn(builder, method, field, operator, array) {
39
23
  if (method && typeof field === 'string' && typeof operator === 'string') {
@@ -53,3 +53,7 @@ declare module 'typeorm/query-builder/DeleteQueryBuilder' {
53
53
  interface DeleteQueryBuilder<Entity extends ObjectLiteral> extends WhereJsonMethods {
54
54
  }
55
55
  }
56
+ declare module 'typeorm/query-builder/SoftDeleteQueryBuilder' {
57
+ interface SoftDeleteQueryBuilder<Entity extends ObjectLiteral> extends WhereJsonMethods {
58
+ }
59
+ }
@@ -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 prototype_utils_1 = require("../utils/prototype.utils");
5
4
  const query_builder_utils_1 = require("../utils/query-builder.utils");
6
5
  const sql_utils_1 = require("../utils/sql.utils");
@@ -22,14 +21,7 @@ const extension = {
22
21
  orWhereJsonHasKey: createWhereJsonHasKeyMethod('orWhere'),
23
22
  },
24
23
  };
25
- const queryBuilders = [
26
- typeorm_1.SelectQueryBuilder,
27
- typeorm_1.UpdateQueryBuilder,
28
- typeorm_1.DeleteQueryBuilder,
29
- ];
30
- queryBuilders.forEach((builder) => {
31
- (0, prototype_utils_1.patchPrototype)(builder, extension);
32
- });
24
+ (0, prototype_utils_1.patchPrototypes)(prototype_utils_1.WHERE_QUERY_BUILDERS, extension);
33
25
  // implementation
34
26
  /**
35
27
  * `CAST("table"."column" AS jsonb)`: makes `json` and `simple-json` (text) columns work, and is dropped by PostgreSQL
@@ -19,17 +19,17 @@ type RelatedCondition<Related extends ObjectLiteral> = (subQuery: SelectQueryBui
19
19
  */
20
20
  export interface WhereRelationExistsMethods<Entity extends ObjectLiteral> {
21
21
  /** Sets `WHERE EXISTS (…)` over the relation, replacing the WHERE conditions set before. */
22
- whereRelationExists<Related extends ObjectLiteral, Type extends ObjectLiteral = TypedRoot<Entity>>(relation: RelationSelection<Type, Related>, alias: string, where?: RelatedCondition<Related>): this;
22
+ whereRelationExists<Related extends ObjectLiteral, Type extends ObjectLiteral = TypedRoot<Entity, this>>(relation: RelationSelection<Type, Related>, alias: string, where?: RelatedCondition<Related>): this;
23
23
  /** Adds `AND EXISTS (…)` over the relation. */
24
- andWhereRelationExists<Related extends ObjectLiteral, Type extends ObjectLiteral = TypedRoot<Entity>>(relation: RelationSelection<Type, Related>, alias: string, where?: RelatedCondition<Related>): this;
24
+ andWhereRelationExists<Related extends ObjectLiteral, Type extends ObjectLiteral = TypedRoot<Entity, this>>(relation: RelationSelection<Type, Related>, alias: string, where?: RelatedCondition<Related>): this;
25
25
  /** Adds `OR EXISTS (…)` over the relation. */
26
- orWhereRelationExists<Related extends ObjectLiteral, Type extends ObjectLiteral = TypedRoot<Entity>>(relation: RelationSelection<Type, Related>, alias: string, where?: RelatedCondition<Related>): this;
26
+ orWhereRelationExists<Related extends ObjectLiteral, Type extends ObjectLiteral = TypedRoot<Entity, this>>(relation: RelationSelection<Type, Related>, alias: string, where?: RelatedCondition<Related>): this;
27
27
  /** Sets `WHERE NOT EXISTS (…)` over the relation, replacing the WHERE conditions set before. */
28
- whereRelationNotExists<Related extends ObjectLiteral, Type extends ObjectLiteral = TypedRoot<Entity>>(relation: RelationSelection<Type, Related>, alias: string, where?: RelatedCondition<Related>): this;
28
+ whereRelationNotExists<Related extends ObjectLiteral, Type extends ObjectLiteral = TypedRoot<Entity, this>>(relation: RelationSelection<Type, Related>, alias: string, where?: RelatedCondition<Related>): this;
29
29
  /** Adds `AND NOT EXISTS (…)` over the relation. */
30
- andWhereRelationNotExists<Related extends ObjectLiteral, Type extends ObjectLiteral = TypedRoot<Entity>>(relation: RelationSelection<Type, Related>, alias: string, where?: RelatedCondition<Related>): this;
30
+ andWhereRelationNotExists<Related extends ObjectLiteral, Type extends ObjectLiteral = TypedRoot<Entity, this>>(relation: RelationSelection<Type, Related>, alias: string, where?: RelatedCondition<Related>): this;
31
31
  /** Adds `OR NOT EXISTS (…)` over the relation. */
32
- orWhereRelationNotExists<Related extends ObjectLiteral, Type extends ObjectLiteral = TypedRoot<Entity>>(relation: RelationSelection<Type, Related>, alias: string, where?: RelatedCondition<Related>): this;
32
+ orWhereRelationNotExists<Related extends ObjectLiteral, Type extends ObjectLiteral = TypedRoot<Entity, this>>(relation: RelationSelection<Type, Related>, alias: string, where?: RelatedCondition<Related>): this;
33
33
  }
34
34
  declare module 'typeorm/query-builder/SelectQueryBuilder' {
35
35
  interface SelectQueryBuilder<Entity extends ObjectLiteral> extends WhereRelationExistsMethods<Entity> {
@@ -22,18 +22,12 @@ const extension = {
22
22
  // implementation
23
23
  function attachRelationExists(builder, method, negate, relationSelection, alias, where) {
24
24
  const methodName = `${method}Relation${negate ? 'Not' : ''}Exists`;
25
- const key = (0, query_builder_utils_1.getTypedSelectionKey)(builder, relationSelection);
26
- if (Array.isArray(key)) {
27
- throw new TypeError(`${methodName} expects the callback to select one relation, got ${key.length}: ${key.join(', ')}`);
28
- }
29
- const dot = key.indexOf('.');
30
- const ownerAlias = key.slice(0, dot);
31
- const propertyPath = key.slice(dot + 1);
32
- const aliases = queryAliases(builder);
25
+ const { aliasName: ownerAlias, propertyPath } = (0, query_builder_utils_1.resolveTypedProperty)(builder, relationSelection, methodName);
26
+ const aliases = (0, query_builder_utils_1.listQueryAliases)(builder);
33
27
  const owner = aliases.find((candidate) => candidate.name === ownerAlias);
34
28
  const relation = (owner === null || owner === void 0 ? void 0 : owner.hasMetadata) ? owner.metadata.findRelationWithPropertyPath(propertyPath) : undefined;
35
- if (!relation) {
36
- throw new TypeError(`${methodName}: ${key} is not a relation of an entity of the query`);
29
+ if (!owner || !relation) {
30
+ throw new TypeError(`${methodName}: ${ownerAlias}.${propertyPath} is not a relation of an entity of the query`);
37
31
  }
38
32
  // in the subquery the alias would hide the outer one the join condition refers to; SQLite matches
39
33
  // names without case, so 'USER' would hide 'user' there
@@ -45,26 +39,12 @@ function attachRelationExists(builder, method, negate, relationSelection, alias,
45
39
  .createQueryBuilder()
46
40
  .select('1')
47
41
  .from(relation.inverseEntityMetadata.target, alias);
48
- const correlation = joinCondition(relation, ownerAlias, alias, column, subQuery);
42
+ const correlation = joinCondition(relation, owner.name, alias, column, subQuery);
49
43
  where === null || where === void 0 ? void 0 : where(subQuery);
50
44
  // after the caller's conditions, so a `where` or an `orWhere` of theirs can't drop or bypass it
51
45
  (0, where_utils_1.andWhereNarrowing)(subQuery, correlation);
52
46
  return (0, where_exists_extension_1.attachExists)(builder, method, subQuery, negate);
53
47
  }
54
- /**
55
- * The aliases of the query and of the queries it is part of. Inside `Brackets` the builder has the outer
56
- * query's main alias but none of its joins: those are on its parent.
57
- */
58
- function queryAliases(builder) {
59
- const aliases = [];
60
- // parentQueryBuilder is protected in TypeORM's types
61
- let query = builder;
62
- for (; query; query = query.parentQueryBuilder) {
63
- const { aliases: own, mainAlias } = query.expressionMap;
64
- aliases.push(...own, ...(mainAlias ? [mainAlias] : []));
65
- }
66
- return aliases;
67
- }
68
48
  const equal = (left, right) => `${left} = ${right}`;
69
49
  /** The condition between the related rows (`alias`) and the outer row (`ownerAlias`); joins the junction table of a many-to-many. */
70
50
  function joinCondition(relation, ownerAlias, alias, column, subQuery) {
package/dist/helpers.d.ts CHANGED
@@ -1,2 +1,7 @@
1
1
  export * from './utils/table.utils';
2
+ export * from './decorators/generated-column.decorator';
2
3
  export { escapeLikePattern } from './utils/search.utils';
4
+ export { COCKROACHDB_RESERVED_KEY_WORDS, findBareReservedQualifiers, POSTGRES_RESERVED_KEY_WORDS, } from './utils/reserved-qualifier.utils';
5
+ export type { ReservedQualifier } from './utils/reserved-qualifier.utils';
6
+ export { disableReservedQualifierGuard, enableReservedQualifierGuard, ReservedQualifierError, } from './utils/reserved-qualifier-guard.utils';
7
+ export type { ReservedQualifierGuardOptions } from './utils/reserved-qualifier-guard.utils';
package/dist/helpers.js CHANGED
@@ -14,10 +14,19 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.escapeLikePattern = void 0;
17
+ exports.ReservedQualifierError = exports.enableReservedQualifierGuard = exports.disableReservedQualifierGuard = exports.POSTGRES_RESERVED_KEY_WORDS = exports.findBareReservedQualifiers = exports.COCKROACHDB_RESERVED_KEY_WORDS = exports.escapeLikePattern = void 0;
18
18
  // Side-effect-free entry point: `typeorm-extensions/helpers`.
19
- // Exports helpers (tableHelper, escapeLikePattern) only and patches nothing; importing the package root
20
- // (`typeorm-extensions`) installs every QueryBuilder extension.
19
+ // Exports helpers (tableHelper, escapeLikePattern, the reserved qualifier guard, @GeneratedColumn) only and patches nothing on import;
20
+ // importing the package root (`typeorm-extensions`) installs every QueryBuilder extension.
21
21
  __exportStar(require("./utils/table.utils"), exports);
22
+ __exportStar(require("./decorators/generated-column.decorator"), exports);
22
23
  var search_utils_1 = require("./utils/search.utils");
23
24
  Object.defineProperty(exports, "escapeLikePattern", { enumerable: true, get: function () { return search_utils_1.escapeLikePattern; } });
25
+ var reserved_qualifier_utils_1 = require("./utils/reserved-qualifier.utils");
26
+ Object.defineProperty(exports, "COCKROACHDB_RESERVED_KEY_WORDS", { enumerable: true, get: function () { return reserved_qualifier_utils_1.COCKROACHDB_RESERVED_KEY_WORDS; } });
27
+ Object.defineProperty(exports, "findBareReservedQualifiers", { enumerable: true, get: function () { return reserved_qualifier_utils_1.findBareReservedQualifiers; } });
28
+ Object.defineProperty(exports, "POSTGRES_RESERVED_KEY_WORDS", { enumerable: true, get: function () { return reserved_qualifier_utils_1.POSTGRES_RESERVED_KEY_WORDS; } });
29
+ var reserved_qualifier_guard_utils_1 = require("./utils/reserved-qualifier-guard.utils");
30
+ Object.defineProperty(exports, "disableReservedQualifierGuard", { enumerable: true, get: function () { return reserved_qualifier_guard_utils_1.disableReservedQualifierGuard; } });
31
+ Object.defineProperty(exports, "enableReservedQualifierGuard", { enumerable: true, get: function () { return reserved_qualifier_guard_utils_1.enableReservedQualifierGuard; } });
32
+ Object.defineProperty(exports, "ReservedQualifierError", { enumerable: true, get: function () { return reserved_qualifier_guard_utils_1.ReservedQualifierError; } });
package/dist/index.d.ts CHANGED
@@ -4,5 +4,4 @@ export * from './types/interfaces';
4
4
  export * from './types/extensions';
5
5
  export type { Json } from './types/modules/proxy-callback.types';
6
6
  export type { TypedRoot, WithTypedRoot } from './types/modules/typed-root.types';
7
- export * from './utils/table.utils';
8
- export { escapeLikePattern } from './utils/search.utils';
7
+ export * from './helpers';
package/dist/index.js CHANGED
@@ -14,11 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.escapeLikePattern = void 0;
18
17
  __exportStar(require("./extensions"), exports);
19
18
  __exportStar(require("./decorators"), exports);
20
19
  __exportStar(require("./types/interfaces"), exports);
21
20
  __exportStar(require("./types/extensions"), exports);
22
- __exportStar(require("./utils/table.utils"), exports);
23
- var search_utils_1 = require("./utils/search.utils");
24
- Object.defineProperty(exports, "escapeLikePattern", { enumerable: true, get: function () { return search_utils_1.escapeLikePattern; } });
21
+ __exportStar(require("./helpers"), exports);
@@ -1,4 +1,5 @@
1
- import type { CursorOrderParam } from '../interfaces/cursor-pagination.interface';
1
+ import type { CursorOrderParam, RawCursorOrderParam } from '../interfaces/cursor-pagination.interface';
2
+ import type { OrderType } from '../interfaces/ordering.interface';
2
3
  export type GetManyWithCursorOptions<Entity> = {
3
4
  /**
4
5
  * Columns that order the rows, e.g. `[{ field: 'createdAt', direction: 'DESC' }]`.
@@ -9,7 +10,17 @@ export type GetManyWithCursorOptions<Entity> = {
9
10
  /** Use `take` instead of `limit`, as needed for queries with joined collections. Defaults to `false`. */
10
11
  useTakeAndSkip?: boolean;
11
12
  };
13
+ export type GetRawManyWithCursorOptions = {
14
+ /**
15
+ * SQL expressions that order the rows. On a query of an entity without GROUP BY or DISTINCT the
16
+ * primary key of the main alias is appended when it isn't listed; otherwise the last key has to be
17
+ * unique per row, or rows with equal keys may be skipped or repeated between pages.
18
+ * It replaces any ORDER BY of the query.
19
+ */
20
+ orderBy: RawCursorOrderParam[];
21
+ };
12
22
  export interface ListWithCursor<Entity> {
23
+ /** The entities of the page, or with `getRawManyWithCursor` its raw rows. */
13
24
  list: Entity[];
14
25
  /** Cursor of the next page, `null` on the last page. */
15
26
  nextCursor: string | null;
@@ -18,4 +29,8 @@ export interface ListWithCursor<Entity> {
18
29
  * keyset query loads `pageSize + 1` rows, so it needs no total. Equivalent to `nextCursor !== null`.
19
30
  */
20
31
  hasMore: boolean;
32
+ /** The page size used: the `pageSize` given, rounded down, or `10` when it was missing or below 1. */
33
+ pageSize: number;
34
+ /** The ORDER BY the page was read in: the `orderBy` keys, then the primary key columns not among them. */
35
+ orderBy: OrderType[];
21
36
  }
@@ -18,6 +18,10 @@ export type GetRawManyWithTotalsOptions = Omit<GetManyWithTotalsOptions, 'useTak
18
18
  export interface ListWithTotals<Entity> {
19
19
  list: Entity[];
20
20
  total: number | null;
21
+ /** The page read, 1-based: the `page` given, or `1` when it was missing or below 1. `null` with `loadAll`. */
22
+ page: number | null;
23
+ /** The page size used: the `pageSize` given, or `10` when it was missing or below 1. `null` with `loadAll`. */
24
+ pageSize: number | null;
21
25
  limit: number | null;
22
26
  offset: number | null;
23
27
  /**
@@ -10,4 +10,5 @@ export * from './search.types';
10
10
  export * from './typed-having.types';
11
11
  export * from './union.types';
12
12
  export * from './join-lateral.types';
13
+ export * from './typed-join-and-map.types';
13
14
  export * from './query-returning.types';
@@ -26,4 +26,5 @@ __exportStar(require("./search.types"), exports);
26
26
  __exportStar(require("./typed-having.types"), exports);
27
27
  __exportStar(require("./union.types"), exports);
28
28
  __exportStar(require("./join-lateral.types"), exports);
29
+ __exportStar(require("./typed-join-and-map.types"), exports);
29
30
  __exportStar(require("./query-returning.types"), exports);
@@ -1,8 +1,8 @@
1
1
  export type TypedGroupByOptions = {
2
2
  /**
3
3
  * Group by the quoted database column (`"ticket"."ticket_status"`) instead of `ticket.status`,
4
- * which TypeORM maps to the column itself. TypeORM maps only aliases with metadata, so a subquery
5
- * in FROM needs it on PostgreSQL, where an unquoted `sub.firstName` is folded to `firstname`.
4
+ * which TypeORM maps to the column itself. Keys of an alias without metadata (a subquery in FROM)
5
+ * are quoted unless this is `false`: PostgreSQL folds an unquoted `sub.firstName` to `firstname`.
6
6
  */
7
7
  useQuotes?: boolean;
8
8
  };
@@ -0,0 +1,6 @@
1
+ import type { SelectQueryBuilder } from 'typeorm';
2
+ /**
3
+ * What a map join joins, as TypeORM's `leftJoinAndMapOne` and the others take it: an entity class or name, a
4
+ * relation (`'user.photos'`), a table name, or a factory that builds a subquery on the query builder it is given.
5
+ */
6
+ export type JoinAndMapTarget = Function | string | ((qb: SelectQueryBuilder<any>) => SelectQueryBuilder<any>);
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -14,3 +14,14 @@ export type CursorOrderParam<Entity> = {
14
14
  /** `'ASC'` by default. */
15
15
  direction?: OrderDirection;
16
16
  };
17
+ /** An SQL expression that orders the rows of `getRawManyWithCursor`. */
18
+ export type RawCursorOrderParam = {
19
+ /**
20
+ * A column (`user.createdAt`, `"user"."created_at"`) or a computed value
21
+ * (`CASE "member"."role" WHEN 'owner' THEN 0 ELSE 1 END`). It must be valid in WHERE, so not an
22
+ * aggregate, and must not be `NULL`.
23
+ */
24
+ selector: string;
25
+ /** `'ASC'` by default. */
26
+ direction?: OrderDirection;
27
+ };
@@ -1,17 +1,19 @@
1
1
  import type { ObjectLiteral } from 'typeorm';
2
- declare const typedRoot: unique symbol;
3
2
  declare class TypedRootMark<Root> {
4
- [typedRoot]?(): Root;
3
+ __typedRoot?(): Root;
5
4
  }
6
5
  /**
7
- * The entity type of a builder whose typed callbacks take another root, set with `typed<Root>()`: the entity
8
- * with an optional symbol method that only types carry. Entities loaded with it are plain entities.
6
+ * A query builder whose typed callbacks take another root, as `typed<Root>()` returns it:
7
+ * `WithTypedRoot<SelectQueryBuilder<Entity>, Root>`, the builder with an optional `__typedRoot` method that only
8
+ * types carry. A builder of a marked entity, `SelectQueryBuilder<WithTypedRoot<Entity, Root>>`, takes the root too.
9
9
  */
10
- export type WithTypedRoot<Entity, Root extends ObjectLiteral> = Entity & TypedRootMark<Root>;
10
+ export type WithTypedRoot<Marked, Root extends ObjectLiteral> = Marked & TypedRootMark<Root>;
11
+ type IsAny<T> = 0 extends 1 & T ? true : false;
12
+ type BuilderRoot<Builder> = '__typedRoot' extends keyof Builder ? Builder extends TypedRootMark<infer Root> ? Root extends ObjectLiteral ? Root : never : never : never;
13
+ type EntityRoot<Entity> = '__typedRoot' extends keyof Entity ? IsAny<Entity['__typedRoot' & keyof Entity]> extends true ? Entity : Entity extends TypedRootMark<infer Root> ? Root extends ObjectLiteral ? Root : Entity : Entity : Entity;
11
14
  /**
12
- * The root of a builder's typed callbacks: the one set with `typed<Root>()`, or else its entity. The key check
13
- * comes first: without `strictNullChecks` an entity with an index signature (`ObjectLiteral`) matches the
14
- * optional mark too, and its root would be inferred as `unknown`.
15
+ * The root of a builder's typed callbacks: the one set with `typed<Root>()` on the builder (`Builder`, which the
16
+ * typed methods pass as `this`) or on its entity, or else the entity.
15
17
  */
16
- export type TypedRoot<Entity> = typeof typedRoot extends keyof Entity ? Entity extends TypedRootMark<infer Root> ? Root extends ObjectLiteral ? Root : Entity : Entity : Entity;
18
+ export type TypedRoot<Entity, Builder = unknown> = [BuilderRoot<Builder>] extends [never] ? EntityRoot<Entity> : BuilderRoot<Builder>;
17
19
  export {};
@@ -1,10 +1,14 @@
1
1
  import { ObjectLiteral, SelectQueryBuilder } from 'typeorm';
2
+ import type { ColumnMetadata } from 'typeorm/metadata/ColumnMetadata';
3
+ /** `addSelect`'s selection: an SQL expression, or a factory that builds a subquery on the builder it is given. */
4
+ export type CalculatedSelection<SubEntity extends ObjectLiteral = ObjectLiteral> = string | ((qb: SelectQueryBuilder<ObjectLiteral>) => SelectQueryBuilder<SubEntity>);
2
5
  type ResolvedCalculatedColumn = {
3
6
  /** The key TypeORM reads the column's value from when it builds the entity. */
4
7
  key: string;
5
8
  /** `Entity.property`, for error messages. */
6
9
  label: string;
7
10
  };
11
+ export declare const isCalculated: (column: ColumnMetadata | undefined) => column is ColumnMetadata;
8
12
  /** Whether `property` of the entity of `aliasName` (the main alias by default) is a `@CalculatedColumn`. */
9
13
  export declare function isCalculatedColumn<Entity extends ObjectLiteral>(builder: SelectQueryBuilder<Entity>, property: string, aliasName?: string): boolean;
10
14
  /** The `@CalculatedColumn` `property` of the entity of `aliasName`; throws a `TypeError` for anything else. */
@@ -16,6 +20,13 @@ export declare function resolveCalculatedColumn<Entity extends ObjectLiteral>(bu
16
20
  * The alias the entity is built from can't be ordered by: PostgreSQL folds it unquoted
17
21
  * (`user_imagesCount` → `user_imagescount`), and quoted it breaks the DISTINCT query TypeORM pages
18
22
  * through with `take` / `skip` and joins, which takes only select aliases it knows unquoted.
23
+ *
24
+ * A value already selected for order keeps its alias, so ORDER BY and DISTINCT ON name the same
25
+ * column: PostgreSQL requires DISTINCT ON to match the leading ORDER BY.
19
26
  */
20
27
  export declare function selectCalculatedForOrder<Entity extends ObjectLiteral>(builder: SelectQueryBuilder<Entity>, property: string, aliasName: string | undefined, methodName: string): string;
28
+ /** Selects `selection` into the `@CalculatedColumn` `property` of the entity of `aliasName` (the main alias by default). */
29
+ export declare function addSelectCalculatedColumn<Entity extends ObjectLiteral, SubEntity extends ObjectLiteral>(builder: SelectQueryBuilder<Entity>, selection: CalculatedSelection<SubEntity>, property: string, aliasName: string | undefined, methodName: string): SelectQueryBuilder<Entity>;
30
+ /** ORDER BY the value of a `@CalculatedColumn` selected with `addSelectCalculated`, through `orderBy` or `addOrderBy`. */
31
+ export declare function orderByCalculatedColumn<Entity extends ObjectLiteral>(builder: SelectQueryBuilder<Entity>, method: 'orderBy' | 'addOrderBy', property: string, order: 'ASC' | 'DESC' | undefined, nulls: 'NULLS FIRST' | 'NULLS LAST' | undefined, aliasName: string | undefined, methodName: string): SelectQueryBuilder<Entity>;
21
32
  export {};
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.selectCalculatedForOrder = exports.resolveCalculatedColumn = exports.isCalculatedColumn = void 0;
3
+ exports.orderByCalculatedColumn = exports.addSelectCalculatedColumn = exports.selectCalculatedForOrder = exports.resolveCalculatedColumn = exports.isCalculatedColumn = exports.isCalculated = void 0;
4
4
  const DriverUtils_1 = require("typeorm/driver/DriverUtils");
5
5
  const sql_utils_1 = require("./sql.utils");
6
+ const ORDER_ALIAS_PREFIX = 'calculated';
7
+ const ORDER_ALIAS_PATTERN = new RegExp(`^${ORDER_ALIAS_PREFIX}_\\w+$`);
6
8
  function findCalculatedColumn(builder, property, aliasName) {
7
9
  const { expressionMap } = builder;
8
10
  const alias = aliasName === undefined
@@ -19,10 +21,11 @@ function findCalculatedColumn(builder, property, aliasName) {
19
21
  }
20
22
  // @CalculatedColumn: a virtual property without the query of TypeORM's @VirtualColumn
21
23
  const isCalculated = (column) => !!(column === null || column === void 0 ? void 0 : column.isVirtualProperty) && !column.query;
24
+ exports.isCalculated = isCalculated;
22
25
  /** Whether `property` of the entity of `aliasName` (the main alias by default) is a `@CalculatedColumn`. */
23
26
  function isCalculatedColumn(builder, property, aliasName) {
24
27
  var _a;
25
- return isCalculated((_a = findCalculatedColumn(builder, property, aliasName)) === null || _a === void 0 ? void 0 : _a.column);
28
+ return (0, exports.isCalculated)((_a = findCalculatedColumn(builder, property, aliasName)) === null || _a === void 0 ? void 0 : _a.column);
26
29
  }
27
30
  exports.isCalculatedColumn = isCalculatedColumn;
28
31
  /** The `@CalculatedColumn` `property` of the entity of `aliasName`; throws a `TypeError` for anything else. */
@@ -33,7 +36,7 @@ function resolveCalculatedColumn(builder, property, aliasName, methodName) {
33
36
  throw new TypeError(`${methodName}: the alias "${aliasName !== null && aliasName !== void 0 ? aliasName : (_a = builder.expressionMap.mainAlias) === null || _a === void 0 ? void 0 : _a.name}" has no entity with "${property}"`);
34
37
  }
35
38
  const label = `${found.entityName}.${property}`;
36
- if (!isCalculated(found.column)) {
39
+ if (!(0, exports.isCalculated)(found.column)) {
37
40
  throw new TypeError(`${methodName}: ${label} is not a @CalculatedColumn`);
38
41
  }
39
42
  // shortened past the driver's alias length limit, as TypeORM does it
@@ -48,6 +51,9 @@ exports.resolveCalculatedColumn = resolveCalculatedColumn;
48
51
  * The alias the entity is built from can't be ordered by: PostgreSQL folds it unquoted
49
52
  * (`user_imagesCount` → `user_imagescount`), and quoted it breaks the DISTINCT query TypeORM pages
50
53
  * through with `take` / `skip` and joins, which takes only select aliases it knows unquoted.
54
+ *
55
+ * A value already selected for order keeps its alias, so ORDER BY and DISTINCT ON name the same
56
+ * column: PostgreSQL requires DISTINCT ON to match the leading ORDER BY.
51
57
  */
52
58
  function selectCalculatedForOrder(builder, property, aliasName, methodName) {
53
59
  const { key, label } = resolveCalculatedColumn(builder, property, aliasName, methodName);
@@ -55,9 +61,32 @@ function selectCalculatedForOrder(builder, property, aliasName, methodName) {
55
61
  if (!select) {
56
62
  throw new TypeError(`${methodName}: ${label} isn't selected: select it with addSelectCalculated first`);
57
63
  }
58
- const orderAlias = (0, sql_utils_1.createUniqueParameterName)('calculated').toLowerCase();
64
+ // found by its SQL rather than kept aside, so a clone of the builder finds it too
65
+ const selectedForOrder = builder.expressionMap.selects.find((candidate) => candidate.aliasName !== undefined &&
66
+ ORDER_ALIAS_PATTERN.test(candidate.aliasName) &&
67
+ candidate.selection === select.selection);
68
+ if (selectedForOrder === null || selectedForOrder === void 0 ? void 0 : selectedForOrder.aliasName) {
69
+ return selectedForOrder.aliasName;
70
+ }
71
+ const orderAlias = (0, sql_utils_1.createUniqueParameterName)(ORDER_ALIAS_PREFIX).toLowerCase();
59
72
  // TypeORM keeps a subquery selection as its SQL, with its parameters already on the builder
60
73
  builder.addSelect(select.selection, orderAlias);
61
74
  return orderAlias;
62
75
  }
63
76
  exports.selectCalculatedForOrder = selectCalculatedForOrder;
77
+ /** Selects `selection` into the `@CalculatedColumn` `property` of the entity of `aliasName` (the main alias by default). */
78
+ function addSelectCalculatedColumn(builder, selection, property, aliasName, methodName) {
79
+ const { key } = resolveCalculatedColumn(builder, property, aliasName, methodName);
80
+ // two calls: addSelect's overloads take a string or a factory, not their union
81
+ if (typeof selection === 'function') {
82
+ return builder.addSelect(selection, key);
83
+ }
84
+ return builder.addSelect(selection, key);
85
+ }
86
+ exports.addSelectCalculatedColumn = addSelectCalculatedColumn;
87
+ /** ORDER BY the value of a `@CalculatedColumn` selected with `addSelectCalculated`, through `orderBy` or `addOrderBy`. */
88
+ function orderByCalculatedColumn(builder, method, property, order, nulls, aliasName, methodName) {
89
+ const orderAlias = selectCalculatedForOrder(builder, property, aliasName, methodName);
90
+ return builder[method](orderAlias, order, nulls);
91
+ }
92
+ exports.orderByCalculatedColumn = orderByCalculatedColumn;
@@ -1,2 +1,4 @@
1
+ /** A Date, also one from another realm (a vm context, a test runner's sandbox), where `instanceof Date` is false. */
2
+ export declare const isDate: (value: unknown) => value is Date;
1
3
  export declare const isNil: (val: unknown) => boolean;
2
4
  export declare function randomString(length?: number): string;
@@ -1,6 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.randomString = exports.isNil = void 0;
3
+ exports.randomString = exports.isNil = exports.isDate = void 0;
4
+ /** A Date, also one from another realm (a vm context, a test runner's sandbox), where `instanceof Date` is false. */
5
+ const isDate = (value) => Object.prototype.toString.call(value) === '[object Date]';
6
+ exports.isDate = isDate;
4
7
  const isNil = (val) => typeof val === 'undefined' || val === null;
5
8
  exports.isNil = isNil;
6
9
  function randomString(length = 21) {
@@ -5,6 +5,11 @@ export declare class InvalidCursorError extends TypeError {
5
5
  }
6
6
  /** A key value in a cursor: as read from the database, or a JS Date tagged as `{ $date }`. */
7
7
  export type CursorValue = string | number | boolean;
8
+ /**
9
+ * Short stable name of an SQL expression key, for the cursor to recognise its order by: a cursor
10
+ * carries no SQL. 32-bit FNV-1a; telling orders apart doesn't need more.
11
+ */
12
+ export declare function getExpressionKeyName(selector: string): string;
8
13
  /** base64url-encoded JSON of the key fields and the key values of the last row. */
9
14
  export declare function encodeCursor(fields: string[], values: unknown[]): string;
10
15
  /** Key values of a cursor made for `fields`; throws `InvalidCursorError` otherwise. */
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.buildKeysetCondition = exports.getTextCastType = exports.supportsRowValueComparison = exports.decodeCursor = exports.encodeCursor = exports.InvalidCursorError = void 0;
3
+ exports.buildKeysetCondition = exports.getTextCastType = exports.supportsRowValueComparison = exports.decodeCursor = exports.encodeCursor = exports.getExpressionKeyName = exports.InvalidCursorError = void 0;
4
4
  const sql_utils_1 = require("./sql.utils");
5
+ const common_utils_1 = require("./common.utils");
5
6
  /** A cursor that can't be decoded or doesn't belong to the query's order (e.g. tampered with). */
6
7
  class InvalidCursorError extends TypeError {
7
8
  constructor(message) {
@@ -10,9 +11,8 @@ class InvalidCursorError extends TypeError {
10
11
  }
11
12
  }
12
13
  exports.InvalidCursorError = InvalidCursorError;
13
- const isDate = (value) => Object.prototype.toString.call(value) === '[object Date]';
14
14
  const toCursorValue = (value) => {
15
- if (isDate(value)) {
15
+ if ((0, common_utils_1.isDate)(value)) {
16
16
  return { $date: value.toISOString() };
17
17
  }
18
18
  if (typeof value === 'bigint') {
@@ -34,6 +34,19 @@ const fromBase64Url = (value) => {
34
34
  const binary = atob(base64 + '='.repeat((4 - (base64.length % 4)) % 4));
35
35
  return new TextDecoder('utf-8', { fatal: true }).decode(Uint8Array.from(binary, (char) => char.charCodeAt(0)));
36
36
  };
37
+ /**
38
+ * Short stable name of an SQL expression key, for the cursor to recognise its order by: a cursor
39
+ * carries no SQL. 32-bit FNV-1a; telling orders apart doesn't need more.
40
+ */
41
+ function getExpressionKeyName(selector) {
42
+ let hash = 0x811c9dc5;
43
+ for (let i = 0; i < selector.length; i++) {
44
+ hash ^= selector.charCodeAt(i);
45
+ hash = Math.imul(hash, 0x01000193);
46
+ }
47
+ return `sql:${(hash >>> 0).toString(16).padStart(8, '0')}`;
48
+ }
49
+ exports.getExpressionKeyName = getExpressionKeyName;
37
50
  /** base64url-encoded JSON of the key fields and the key values of the last row. */
38
51
  function encodeCursor(fields, values) {
39
52
  const payload = { k: fields, v: values.map(toCursorValue) };
@@ -77,9 +90,7 @@ function decodeCursor(cursor, fields) {
77
90
  }
78
91
  exports.decodeCursor = decodeCursor;
79
92
  /** Databases that compare row values: `(a, b) < (1, 2)`. */
80
- const supportsRowValueComparison = (driver) => driver === 'postgres' ||
81
- driver === 'aurora-postgres' ||
82
- driver === 'cockroachdb' ||
93
+ const supportsRowValueComparison = (driver) => (0, sql_utils_1.isPostgresLikeDriver)(driver) ||
83
94
  (0, sql_utils_1.isMysqlLikeDriver)(driver) ||
84
95
  (0, sql_utils_1.isSqliteLikeDriver)(driver);
85
96
  exports.supportsRowValueComparison = supportsRowValueComparison;
@@ -88,7 +99,7 @@ exports.supportsRowValueComparison = supportsRowValueComparison;
88
99
  * (PostgreSQL timestamps have microseconds, a JS Date only milliseconds). `undefined` when unknown.
89
100
  */
90
101
  const getTextCastType = (driver) => {
91
- if (driver === 'postgres' || driver === 'aurora-postgres' || driver === 'cockroachdb' || (0, sql_utils_1.isSqliteLikeDriver)(driver)) {
102
+ if ((0, sql_utils_1.isPostgresLikeDriver)(driver) || (0, sql_utils_1.isSqliteLikeDriver)(driver)) {
92
103
  return 'text';
93
104
  }
94
105
  if ((0, sql_utils_1.isMysqlLikeDriver)(driver)) {
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.toJsonPathSql = exports.buildJsonPath = exports.isJsonColumn = void 0;
4
4
  const sql_utils_1 = require("./sql.utils");
5
+ const common_utils_1 = require("./common.utils");
5
6
  const JSON_COLUMN_TYPES = ['json', 'jsonb', 'simple-json'];
6
7
  const isJsonColumn = (column) => JSON_COLUMN_TYPES.includes(String(column.type));
7
8
  exports.isJsonColumn = isJsonColumn;
@@ -14,7 +15,6 @@ function buildJsonPath(fieldNames, jsonOperator) {
14
15
  .join(' ');
15
16
  }
16
17
  exports.buildJsonPath = buildJsonPath;
17
- const isDate = (value) => Object.prototype.toString.call(value) === '[object Date]';
18
18
  /**
19
19
  * PostgreSQL type to compare a `->>` value (text) with `value` as: text compares `'9' >= '10'` as true.
20
20
  * An array (IN, ANY) is typed by its first value; strings and unknown values stay text.
@@ -27,7 +27,7 @@ function getJsonTextCast(value) {
27
27
  if (typeof sample === 'boolean') {
28
28
  return 'boolean';
29
29
  }
30
- if (isDate(sample)) {
30
+ if ((0, common_utils_1.isDate)(sample)) {
31
31
  return 'timestamptz';
32
32
  }
33
33
  return undefined;
@@ -1,5 +1,15 @@
1
+ import type { ObjectLiteral, SelectQueryBuilder } from "typeorm";
2
+ import type { ApplyPaginationOptions } from "../types/extensions/pagination.types";
1
3
  import { PaginationFilter } from "../types/interfaces/pagination.interface";
4
+ /** The page size to read: a number or a numeric string of at least 1, rounded down; `defaultPageSize` otherwise. */
5
+ export declare const normalizePageSize: (pageSize: unknown) => number;
6
+ /** Limits the rows with `take`, which counts entities rather than rows when the query joins a collection, or with `limit`. */
7
+ export declare const setPageLimit: <Entity extends ObjectLiteral>(builder: SelectQueryBuilder<Entity>, limit: number, useTakeAndSkip: boolean) => SelectQueryBuilder<Entity>;
2
8
  export declare const getLimitAndOffset: ({ page, pageSize }: PaginationFilter) => {
3
9
  limit: number;
4
10
  offset: number;
11
+ page: number;
12
+ pageSize: number;
5
13
  };
14
+ /** What `applyPagination` does, for code that must not depend on what is patched under that name. */
15
+ export declare const paginateQuery: <Entity extends ObjectLiteral>(builder: SelectQueryBuilder<Entity>, paginationFilter: PaginationFilter, options?: ApplyPaginationOptions) => SelectQueryBuilder<Entity>;