taon-typeorm 19.0.5 → 19.0.7

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 (42) hide show
  1. package/browser/fesm2022/taon-typeorm.mjs +4 -0
  2. package/browser/fesm2022/taon-typeorm.mjs.map +1 -1
  3. package/browser/lib/typeorm/find-options/FindOneOptions.d.ts +2 -1
  4. package/browser/lib/typeorm/index.d.ts +3 -0
  5. package/browser/lib/typeorm/query-builder/QueryBuilder.d.ts +2 -0
  6. package/browser/lib/typeorm/query-builder/SelectQueryBuilder.d.ts +3 -0
  7. package/browser/lib/typeorm/relation-path.d.ts +7 -0
  8. package/browser/package.json +1 -1
  9. package/client/fesm2022/taon-typeorm.mjs +4 -0
  10. package/client/fesm2022/taon-typeorm.mjs.map +1 -1
  11. package/client/lib/typeorm/find-options/FindOneOptions.d.ts +2 -1
  12. package/client/lib/typeorm/index.d.ts +3 -0
  13. package/client/lib/typeorm/query-builder/QueryBuilder.d.ts +2 -0
  14. package/client/lib/typeorm/query-builder/SelectQueryBuilder.d.ts +3 -0
  15. package/client/lib/typeorm/relation-path.d.ts +7 -0
  16. package/client/package.json +1 -1
  17. package/lib/build-info._auto-generated_.d.ts +1 -1
  18. package/lib/build-info._auto-generated_.js +1 -1
  19. package/lib/typeorm/find-options/FindOneOptions.d.ts +2 -1
  20. package/lib/typeorm/index.d.ts +3 -0
  21. package/lib/typeorm/index.js +3 -0
  22. package/lib/typeorm/index.js.map +1 -1
  23. package/lib/typeorm/query-builder/QueryBuilder.d.ts +2 -0
  24. package/lib/typeorm/query-builder/QueryBuilder.js.map +1 -1
  25. package/lib/typeorm/query-builder/RelationQueryBuilder.js +3 -0
  26. package/lib/typeorm/query-builder/RelationQueryBuilder.js.map +1 -1
  27. package/lib/typeorm/query-builder/SelectQueryBuilder.d.ts +3 -0
  28. package/lib/typeorm/query-builder/SelectQueryBuilder.js +1 -0
  29. package/lib/typeorm/query-builder/SelectQueryBuilder.js.map +1 -1
  30. package/lib/typeorm/relation-path.d.ts +6 -0
  31. package/lib/typeorm/relation-path.js +3 -0
  32. package/lib/typeorm/relation-path.js.map +1 -0
  33. package/package.json +1 -1
  34. package/tmp-environment.json +3 -3
  35. package/websql/fesm2022/taon-typeorm.mjs +4 -0
  36. package/websql/fesm2022/taon-typeorm.mjs.map +1 -1
  37. package/websql/lib/typeorm/find-options/FindOneOptions.d.ts +2 -1
  38. package/websql/lib/typeorm/index.d.ts +3 -0
  39. package/websql/lib/typeorm/query-builder/QueryBuilder.d.ts +2 -0
  40. package/websql/lib/typeorm/query-builder/SelectQueryBuilder.d.ts +3 -0
  41. package/websql/lib/typeorm/relation-path.d.ts +7 -0
  42. package/websql/package.json +1 -1
@@ -4,6 +4,7 @@ import { FindOptionsWhere } from "./FindOptionsWhere";
4
4
  import { FindOptionsSelect, FindOptionsSelectByString } from "./FindOptionsSelect";
5
5
  import { FindOptionsRelationByString, FindOptionsRelations } from "./FindOptionsRelations";
6
6
  import { FindOptionsOrder } from "./FindOptionsOrder";
7
+ import { RelationPath } from "../relation-path";
7
8
  /**
8
9
  * Defines a special criteria to find specific entity.
9
10
  */
@@ -25,7 +26,7 @@ export interface FindOneOptions<Entity = any> {
25
26
  /**
26
27
  * Indicates what relations of entity should be loaded (simplified left join form).
27
28
  */
28
- relations?: FindOptionsRelations<Entity> | FindOptionsRelationByString;
29
+ relations?: RelationPath<Entity>[] | FindOptionsRelations<Entity> | FindOptionsRelationByString;
29
30
  /**
30
31
  * Specifies how relations must be loaded - using "joins" or separate queries.
31
32
  * If you are loading too much data with nested joins it's better to load relations
@@ -1,6 +1,9 @@
1
1
  // @ts-nocheck
2
2
  export { OrignalClassKey } from './constants';
3
3
  export * from './globals';
4
+ export * from './query-builder/QueryPartialEntity';
5
+ export * from './repository/UpsertOptions';
6
+ export * from './relation-path';
4
7
  export * from './common/EntityTarget';
5
8
  export * from './common/ObjectType';
6
9
  export * from './common/ObjectLiteral';
@@ -19,6 +19,7 @@ import { ColumnMetadata } from "../metadata/ColumnMetadata";
19
19
  import { WhereClause, WhereClauseCondition } from "./WhereClause";
20
20
  import { NotBrackets } from "./NotBrackets";
21
21
  import { ReturningType } from "../driver/Driver";
22
+ import { RelationPath } from "../relation-path";
22
23
  /**
23
24
  * Allows to build complex sql queries in a fashion way and execute those queries.
24
25
  */
@@ -105,6 +106,7 @@ export declare abstract class QueryBuilder<Entity extends ObjectLiteral> {
105
106
  * Sets entity's relation with which this query builder gonna work.
106
107
  */
107
108
  relation(propertyPath: string): RelationQueryBuilder<Entity>;
109
+ relation(propertyPath: RelationPath<Entity>): RelationQueryBuilder<Entity>;
108
110
  /**
109
111
  * Sets entity's relation with which this query builder gonna work.
110
112
  */
@@ -16,6 +16,7 @@ import { RelationMetadata } from "../metadata/RelationMetadata";
16
16
  import { FindOptionsOrder } from "../find-options/FindOptionsOrder";
17
17
  import { FindOptionsWhere } from "../find-options/FindOptionsWhere";
18
18
  import { FindOptionsRelations } from "../find-options/FindOptionsRelations";
19
+ import { RelationPath } from "../relation-path";
19
20
  /**
20
21
  * Allows to build complex sql queries in a fashion way and execute those queries.
21
22
  */
@@ -177,6 +178,7 @@ export declare class SelectQueryBuilder<Entity extends ObjectLiteral> extends Qu
177
178
  * Optionally, you can add condition and parameters used in condition.
178
179
  */
179
180
  innerJoinAndSelect(property: string, alias: string, condition?: string, parameters?: ObjectLiteral): this;
181
+ innerJoinAndSelect(property: RelationPath<Entity>, alias: string, condition?: string, parameters?: ObjectLiteral): this;
180
182
  /**
181
183
  * INNER JOINs entity and adds all selection properties to SELECT.
182
184
  * You also need to specify an alias of the joined data.
@@ -202,6 +204,7 @@ export declare class SelectQueryBuilder<Entity extends ObjectLiteral> extends Qu
202
204
  * Optionally, you can add condition and parameters used in condition.
203
205
  */
204
206
  leftJoinAndSelect(property: string, alias: string, condition?: string, parameters?: ObjectLiteral): this;
207
+ leftJoinAndSelect(property: RelationPath<Entity>, alias: string, condition?: string, parameters?: ObjectLiteral): this;
205
208
  /**
206
209
  * LEFT JOINs entity and adds all selection properties to SELECT.
207
210
  * You also need to specify an alias of the joined data.
@@ -0,0 +1,7 @@
1
+ // @ts-nocheck
2
+ type Join<K, P> = K extends string ? P extends string ? `${K}.${P}` : never : never;
3
+ export type RelationPath<T, Depth extends number = 3> = Depth extends 0 ? never : {
4
+ [K in keyof T]: T[K] extends object ? T[K] extends Array<infer U> ? K | Join<K, RelationPath<U, Prev[Depth]>> : K | Join<K, RelationPath<T[K], Prev[Depth]>> : K;
5
+ }[keyof T];
6
+ type Prev = [never, 0, 1, 2, 3, 4, 5, 6];
7
+ export {};
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "taon-typeorm/browser",
3
- "version": "19.0.5",
3
+ "version": "19.0.7",
4
4
  "module": "fesm2022/taon-typeorm.mjs",
5
5
  "typings": "index.d.ts",
6
6
  "exports": {
@@ -21756,6 +21756,7 @@ let SelectQueryBuilder = SelectQueryBuilder_1 = class SelectQueryBuilder extends
21756
21756
  subQuery() {
21757
21757
  const qb = this.createQueryBuilder();
21758
21758
  qb.expressionMap.subQuery = true;
21759
+ // @ts-ignore
21759
21760
  qb.parentQueryBuilder = this;
21760
21761
  return qb;
21761
21762
  }
@@ -26513,6 +26514,7 @@ let RelationQueryBuilder = class RelationQueryBuilder extends QueryBuilder {
26513
26514
  (!ObjectUtils.isObject(value) ||
26514
26515
  Object.keys(value).length < relation.joinColumns.length))
26515
26516
  throw new TypeORMError(`Value to be set into the relation must be a map of relation ids, for example: .set({ firstName: "...", lastName: "..." })`);
26517
+ // @ts-ignore
26516
26518
  const updater = new RelationUpdater(this, this.expressionMap);
26517
26519
  return updater.update(value);
26518
26520
  }
@@ -26540,6 +26542,7 @@ let RelationQueryBuilder = class RelationQueryBuilder extends QueryBuilder {
26540
26542
  (!ObjectUtils.isObject(value) ||
26541
26543
  Object.keys(value).length < relation.joinColumns.length))
26542
26544
  throw new TypeORMError(`Value to be set into the relation must be a map of relation ids, for example: .set({ firstName: "...", lastName: "..." })`);
26545
+ // @ts-ignore
26543
26546
  const updater = new RelationUpdater(this, this.expressionMap);
26544
26547
  return updater.update(value);
26545
26548
  }
@@ -26561,6 +26564,7 @@ let RelationQueryBuilder = class RelationQueryBuilder extends QueryBuilder {
26561
26564
  throw new TypeORMError(`Add operation is only supported for many-to-many and one-to-many relations. ` +
26562
26565
  `However given "${relation.propertyPath}" has ${relation.relationType} relation. ` +
26563
26566
  `Use .set(null) method instead.`);
26567
+ // @ts-ignore
26564
26568
  const remover = new RelationRemover(this, this.expressionMap);
26565
26569
  return remover.remove(value);
26566
26570
  }