@punks/backend-entity-manager 0.0.96 → 0.0.98
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.
- package/dist/cjs/index.js +109 -10
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/__test__/entity/foo.d.ts +1 -1
- package/dist/cjs/types/__test__/providers/typeorm/converter/foo.d.ts +9 -0
- package/dist/cjs/types/__test__/providers/typeorm/entity/foo.d.ts +1 -83
- package/dist/cjs/types/__test__/providers/typeorm/init/foo.d.ts +6 -0
- package/dist/cjs/types/__test__/providers/typeorm/manager/foo.d.ts +4 -0
- package/dist/cjs/types/__test__/providers/typeorm/models/foo.d.ts +56 -0
- package/dist/cjs/types/__test__/providers/typeorm/queries/foo.d.ts +12 -0
- package/dist/cjs/types/__test__/providers/typeorm/repository/foo.d.ts +6 -0
- package/dist/cjs/types/__test__/providers/typeorm/serializer/foo.d.ts +6 -0
- package/dist/cjs/types/integrations/repository/typeorm/clause.d.ts +32 -0
- package/dist/cjs/types/integrations/repository/typeorm/facets.d.ts +7 -0
- package/dist/cjs/types/integrations/repository/typeorm/queryBuilder.d.ts +6 -1
- package/dist/cjs/types/integrations/repository/typeorm/queryClauseBuilder.d.ts +8 -0
- package/dist/cjs/types/integrations/repository/typeorm/repository.d.ts +1 -0
- package/dist/cjs/types/platforms/nest/__test__/server/entities/appCompanies/appCompany.query.d.ts +1 -1
- package/dist/cjs/types/platforms/nest/__test__/server/entities/appDivisions/appDivision.query.d.ts +1 -1
- package/dist/cjs/types/platforms/nest/__test__/server/entities/appOrganizations/appOrganization.query.d.ts +1 -1
- package/dist/cjs/types/platforms/nest/__test__/server/entities/appRoles/appRole.query.d.ts +1 -1
- package/dist/cjs/types/platforms/nest/__test__/server/entities/appTenants/appTenant.query.d.ts +1 -1
- package/dist/cjs/types/platforms/nest/__test__/server/entities/appUserGroupMembers/appUserGroupMember.query.d.ts +1 -1
- package/dist/cjs/types/platforms/nest/__test__/server/entities/appUserGroups/appUserGroup.query.d.ts +1 -1
- package/dist/cjs/types/platforms/nest/__test__/server/entities/appUserProfiles/appUserProfile.query.d.ts +1 -1
- package/dist/cjs/types/platforms/nest/__test__/server/entities/appUserRoles/appUserRole.query.d.ts +1 -1
- package/dist/cjs/types/platforms/nest/__test__/server/entities/appUsers/appUser.query.d.ts +1 -1
- package/dist/cjs/types/platforms/nest/__test__/server/entities/foos/foo.models.d.ts +2 -0
- package/dist/cjs/types/platforms/nest/__test__/server/entities/foos/foo.query.d.ts +1 -1
- package/dist/esm/index.js +110 -11
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/__test__/entity/foo.d.ts +1 -1
- package/dist/esm/types/__test__/providers/typeorm/converter/foo.d.ts +9 -0
- package/dist/esm/types/__test__/providers/typeorm/entity/foo.d.ts +1 -83
- package/dist/esm/types/__test__/providers/typeorm/init/foo.d.ts +6 -0
- package/dist/esm/types/__test__/providers/typeorm/manager/foo.d.ts +4 -0
- package/dist/esm/types/__test__/providers/typeorm/models/foo.d.ts +56 -0
- package/dist/esm/types/__test__/providers/typeorm/queries/foo.d.ts +12 -0
- package/dist/esm/types/__test__/providers/typeorm/repository/foo.d.ts +6 -0
- package/dist/esm/types/__test__/providers/typeorm/serializer/foo.d.ts +6 -0
- package/dist/esm/types/integrations/repository/typeorm/clause.d.ts +32 -0
- package/dist/esm/types/integrations/repository/typeorm/facets.d.ts +7 -0
- package/dist/esm/types/integrations/repository/typeorm/queryBuilder.d.ts +6 -1
- package/dist/esm/types/integrations/repository/typeorm/queryClauseBuilder.d.ts +8 -0
- package/dist/esm/types/integrations/repository/typeorm/repository.d.ts +1 -0
- package/dist/esm/types/platforms/nest/__test__/server/entities/appCompanies/appCompany.query.d.ts +1 -1
- package/dist/esm/types/platforms/nest/__test__/server/entities/appDivisions/appDivision.query.d.ts +1 -1
- package/dist/esm/types/platforms/nest/__test__/server/entities/appOrganizations/appOrganization.query.d.ts +1 -1
- package/dist/esm/types/platforms/nest/__test__/server/entities/appRoles/appRole.query.d.ts +1 -1
- package/dist/esm/types/platforms/nest/__test__/server/entities/appTenants/appTenant.query.d.ts +1 -1
- package/dist/esm/types/platforms/nest/__test__/server/entities/appUserGroupMembers/appUserGroupMember.query.d.ts +1 -1
- package/dist/esm/types/platforms/nest/__test__/server/entities/appUserGroups/appUserGroup.query.d.ts +1 -1
- package/dist/esm/types/platforms/nest/__test__/server/entities/appUserProfiles/appUserProfile.query.d.ts +1 -1
- package/dist/esm/types/platforms/nest/__test__/server/entities/appUserRoles/appUserRole.query.d.ts +1 -1
- package/dist/esm/types/platforms/nest/__test__/server/entities/appUsers/appUser.query.d.ts +1 -1
- package/dist/esm/types/platforms/nest/__test__/server/entities/foos/foo.models.d.ts +2 -0
- package/dist/esm/types/platforms/nest/__test__/server/entities/foos/foo.query.d.ts +1 -1
- package/dist/index.d.ts +50 -2
- package/package.json +1 -1
|
@@ -6,9 +6,9 @@ import { IEntitiesSearchResults } from "../../models";
|
|
|
6
6
|
import { EntityServiceLocator } from "../../providers/services";
|
|
7
7
|
import { InMemoryRepository } from "../../testing/mocks/repository";
|
|
8
8
|
import { EntitySerializerSheetDefinition, IAuthenticationContext, IEntityManager } from "../../abstractions";
|
|
9
|
-
import { FooDeleteParameters } from "../providers/typeorm/entity/foo";
|
|
10
9
|
import { IEntitiesDeleteResult } from "../../abstractions/repository";
|
|
11
10
|
import { EntitySerializer } from "../../base";
|
|
11
|
+
import { FooDeleteParameters } from "../providers/typeorm/models/foo";
|
|
12
12
|
export interface FooEntity {
|
|
13
13
|
id: string;
|
|
14
14
|
name: string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { IEntityConverter } from "../../../../abstractions";
|
|
2
|
+
import { FooEntity } from "../entity/foo";
|
|
3
|
+
import { FooCreateInput, FooDto, FooListItemDto, FooUpdateInput } from "../models/foo";
|
|
4
|
+
export declare class FooConverter implements IEntityConverter<FooEntity, FooDto, FooListItemDto, FooCreateInput, FooUpdateInput> {
|
|
5
|
+
toListItemDto(entity: FooEntity): FooListItemDto;
|
|
6
|
+
toEntityDto(entity: FooEntity): FooDto;
|
|
7
|
+
createDtoToEntity(input: FooCreateInput): Partial<FooEntity>;
|
|
8
|
+
updateDtoToEntity(input: FooUpdateInput): Partial<FooEntity>;
|
|
9
|
+
}
|
|
@@ -1,89 +1,7 @@
|
|
|
1
|
-
import { DataSource, Repository, FindOptionsWhere } from "typeorm";
|
|
2
|
-
import { EntitySerializerSheetDefinition, IAuthenticationContext, IEntityConverter, IEntityManager, IEntityManagerServiceRoot, IEntitySearchParameters, ISearchSorting, ISearchSortingField, SortDirection } from "../../../../abstractions";
|
|
3
|
-
import { TypeOrmRepository } from "../../../../integrations/repository/typeorm";
|
|
4
|
-
import { EntityServiceLocator } from "../../../../providers/services";
|
|
5
|
-
import { TypeOrmQueryBuilder } from "../../../../integrations/repository/typeorm";
|
|
6
|
-
import { IEntitiesDeleteParameters } from "../../../../abstractions/commands";
|
|
7
|
-
import { EntitySerializer } from "../../../../base";
|
|
8
1
|
export declare class FooEntity {
|
|
9
2
|
id: string;
|
|
10
3
|
name: string;
|
|
11
4
|
age: number;
|
|
5
|
+
enabled: boolean;
|
|
12
6
|
updatedOn: Date;
|
|
13
7
|
}
|
|
14
|
-
export type FooEntityManager = IEntityManager<FooEntity, string, Partial<FooEntity>, Partial<FooEntity>, FooDeleteParameters, FooSearchParameters, FooSorting, FooCursor, FooFacets>;
|
|
15
|
-
export declare class FooTypeOrmRepo extends TypeOrmRepository<FooEntity, string> {
|
|
16
|
-
constructor(repository: Repository<FooEntity>);
|
|
17
|
-
}
|
|
18
|
-
export interface FooSearchFilters {
|
|
19
|
-
minAge?: number;
|
|
20
|
-
maxAge?: number;
|
|
21
|
-
}
|
|
22
|
-
export declare enum FooSorting {
|
|
23
|
-
Name = "Name",
|
|
24
|
-
Age = "Age"
|
|
25
|
-
}
|
|
26
|
-
export type FooCursor = number;
|
|
27
|
-
export interface FooSearchParameters extends IEntitySearchParameters<FooSorting, FooCursor> {
|
|
28
|
-
filters?: FooSearchFilters;
|
|
29
|
-
}
|
|
30
|
-
export interface FooSearchSortingField extends ISearchSortingField<FooSorting> {
|
|
31
|
-
field: FooSorting;
|
|
32
|
-
direction: SortDirection;
|
|
33
|
-
}
|
|
34
|
-
export interface FooQuerySorting extends ISearchSorting<FooSorting> {
|
|
35
|
-
fields: FooSearchSortingField[];
|
|
36
|
-
}
|
|
37
|
-
export interface FooDeleteParameters extends IEntitiesDeleteParameters<FooSorting> {
|
|
38
|
-
filters?: FooSearchFilters;
|
|
39
|
-
sorting?: FooQuerySorting;
|
|
40
|
-
}
|
|
41
|
-
export interface FooFacets {
|
|
42
|
-
}
|
|
43
|
-
export declare class FooQueryBuilder extends TypeOrmQueryBuilder<FooEntity, FooSearchParameters, FooSorting, FooFacets, unknown> {
|
|
44
|
-
constructor(services: EntityServiceLocator<FooEntity, string>);
|
|
45
|
-
protected buildContextFilter(context?: IAuthenticationContext<unknown> | undefined): FindOptionsWhere<FooEntity> | FindOptionsWhere<FooEntity>[];
|
|
46
|
-
protected buildWhereClause(request: FooSearchParameters): FindOptionsWhere<FooEntity> | FindOptionsWhere<FooEntity>[];
|
|
47
|
-
private buildAgeWhereClause;
|
|
48
|
-
protected calculateFacets(request: FooSearchParameters): Promise<FooFacets | undefined>;
|
|
49
|
-
}
|
|
50
|
-
export interface FooDto {
|
|
51
|
-
id: string;
|
|
52
|
-
profile: {
|
|
53
|
-
name: string;
|
|
54
|
-
age: number;
|
|
55
|
-
};
|
|
56
|
-
updatedOn: Date;
|
|
57
|
-
}
|
|
58
|
-
export interface FooListItemDto {
|
|
59
|
-
id: string;
|
|
60
|
-
profile: {
|
|
61
|
-
name: string;
|
|
62
|
-
age: number;
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
export interface FooCreateInput {
|
|
66
|
-
profile: {
|
|
67
|
-
name: string;
|
|
68
|
-
age: number;
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
export interface FooUpdateInput {
|
|
72
|
-
id: string;
|
|
73
|
-
profile: {
|
|
74
|
-
name: string;
|
|
75
|
-
age: number;
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
export declare class FooConverter implements IEntityConverter<FooEntity, FooDto, FooListItemDto, FooCreateInput, FooUpdateInput> {
|
|
79
|
-
toListItemDto(entity: FooEntity): FooListItemDto;
|
|
80
|
-
toEntityDto(entity: FooEntity): FooDto;
|
|
81
|
-
createDtoToEntity(input: FooCreateInput): Partial<FooEntity>;
|
|
82
|
-
updateDtoToEntity(input: FooUpdateInput): Partial<FooEntity>;
|
|
83
|
-
}
|
|
84
|
-
export declare class FooSerializer extends EntitySerializer<FooEntity, string> {
|
|
85
|
-
protected getDefinition(): EntitySerializerSheetDefinition<FooEntity>;
|
|
86
|
-
}
|
|
87
|
-
export declare const registerFooTypeOrmEntity: (container: IEntityManagerServiceRoot, dataSource: DataSource, options?: {
|
|
88
|
-
useConverter?: boolean;
|
|
89
|
-
}) => import("../../../../abstractions").IEntityManagerServiceCollection<FooEntity, string>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { DataSource } from "typeorm";
|
|
2
|
+
import { IEntityManagerServiceRoot } from "../../../../abstractions";
|
|
3
|
+
import { FooEntity } from "../entity/foo";
|
|
4
|
+
export declare const registerFooTypeOrmEntity: (container: IEntityManagerServiceRoot, dataSource: DataSource, options?: {
|
|
5
|
+
useConverter?: boolean;
|
|
6
|
+
}) => import("../../../../abstractions").IEntityManagerServiceCollection<FooEntity, string>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { IEntityManager } from "../../../../abstractions/manager";
|
|
2
|
+
import { FooEntity } from "../entity/foo";
|
|
3
|
+
import { FooCursor, FooDeleteParameters, FooFacets, FooSearchParameters, FooSorting } from "../models/foo";
|
|
4
|
+
export type FooEntityManager = IEntityManager<FooEntity, string, Partial<FooEntity>, Partial<FooEntity>, FooDeleteParameters, FooSearchParameters, FooSorting, FooCursor, FooFacets>;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { IEntitiesDeleteParameters, IEntitySearchParameters, ISearchSorting, ISearchSortingField, SortDirection } from "../../../../abstractions";
|
|
2
|
+
import { BooleanFilter, NumericFilter, StringFilter } from "../../../../integrations/repository/typeorm/clause";
|
|
3
|
+
export interface FooSearchFilters {
|
|
4
|
+
age?: NumericFilter;
|
|
5
|
+
name?: StringFilter;
|
|
6
|
+
enabled?: BooleanFilter;
|
|
7
|
+
}
|
|
8
|
+
export declare enum FooSorting {
|
|
9
|
+
Name = "Name",
|
|
10
|
+
Age = "Age"
|
|
11
|
+
}
|
|
12
|
+
export type FooCursor = number;
|
|
13
|
+
export interface FooSearchParameters extends IEntitySearchParameters<FooSorting, FooCursor> {
|
|
14
|
+
filters?: FooSearchFilters;
|
|
15
|
+
}
|
|
16
|
+
export interface FooSearchSortingField extends ISearchSortingField<FooSorting> {
|
|
17
|
+
field: FooSorting;
|
|
18
|
+
direction: SortDirection;
|
|
19
|
+
}
|
|
20
|
+
export interface FooQuerySorting extends ISearchSorting<FooSorting> {
|
|
21
|
+
fields: FooSearchSortingField[];
|
|
22
|
+
}
|
|
23
|
+
export interface FooDeleteParameters extends IEntitiesDeleteParameters<FooSorting> {
|
|
24
|
+
filters?: FooSearchFilters;
|
|
25
|
+
sorting?: FooQuerySorting;
|
|
26
|
+
}
|
|
27
|
+
export interface FooFacets {
|
|
28
|
+
}
|
|
29
|
+
export interface FooDto {
|
|
30
|
+
id: string;
|
|
31
|
+
profile: {
|
|
32
|
+
name: string;
|
|
33
|
+
age: number;
|
|
34
|
+
};
|
|
35
|
+
updatedOn: Date;
|
|
36
|
+
}
|
|
37
|
+
export interface FooListItemDto {
|
|
38
|
+
id: string;
|
|
39
|
+
profile: {
|
|
40
|
+
name: string;
|
|
41
|
+
age: number;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
export interface FooCreateInput {
|
|
45
|
+
profile: {
|
|
46
|
+
name: string;
|
|
47
|
+
age: number;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
export interface FooUpdateInput {
|
|
51
|
+
id: string;
|
|
52
|
+
profile: {
|
|
53
|
+
name: string;
|
|
54
|
+
age: number;
|
|
55
|
+
};
|
|
56
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { FindOptionsWhere } from "typeorm";
|
|
2
|
+
import { IAuthenticationContext } from "../../../../abstractions";
|
|
3
|
+
import { TypeOrmQueryBuilder } from "../../../../integrations";
|
|
4
|
+
import { EntityServiceLocator } from "../../../../providers/services";
|
|
5
|
+
import { FooEntity } from "../entity/foo";
|
|
6
|
+
import { FooFacets, FooSearchParameters, FooSorting } from "../models/foo";
|
|
7
|
+
export declare class FooQueryBuilder extends TypeOrmQueryBuilder<FooEntity, FooSearchParameters, FooSorting, FooFacets, unknown> {
|
|
8
|
+
constructor(services: EntityServiceLocator<FooEntity, string>);
|
|
9
|
+
protected buildContextFilter(context?: IAuthenticationContext<unknown> | undefined): FindOptionsWhere<FooEntity> | FindOptionsWhere<FooEntity>[];
|
|
10
|
+
protected buildWhereClause(request: FooSearchParameters): FindOptionsWhere<FooEntity> | FindOptionsWhere<FooEntity>[];
|
|
11
|
+
protected calculateFacets(request: FooSearchParameters): Promise<FooFacets>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Repository } from "typeorm";
|
|
2
|
+
import { TypeOrmRepository } from "../../../../integrations";
|
|
3
|
+
import { FooEntity } from "../entity/foo";
|
|
4
|
+
export declare class FooTypeOrmRepo extends TypeOrmRepository<FooEntity, string> {
|
|
5
|
+
constructor(repository: Repository<FooEntity>);
|
|
6
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { EntitySerializerSheetDefinition } from "../../../../abstractions";
|
|
2
|
+
import { EntitySerializer } from "../../../../base";
|
|
3
|
+
import { FooEntity } from "../entity/foo";
|
|
4
|
+
export declare class FooSerializer extends EntitySerializer<FooEntity, string> {
|
|
5
|
+
protected getDefinition(): EntitySerializerSheetDefinition<FooEntity>;
|
|
6
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export type NumericFilter = {
|
|
2
|
+
in?: number[];
|
|
3
|
+
eq?: number;
|
|
4
|
+
gt?: number;
|
|
5
|
+
gte?: number;
|
|
6
|
+
lt?: number;
|
|
7
|
+
lte?: number;
|
|
8
|
+
};
|
|
9
|
+
export type StringFilter = {
|
|
10
|
+
gt?: string;
|
|
11
|
+
gte?: string;
|
|
12
|
+
lt?: string;
|
|
13
|
+
lte?: string;
|
|
14
|
+
in?: string[];
|
|
15
|
+
eq?: string;
|
|
16
|
+
like?: string;
|
|
17
|
+
ne?: string;
|
|
18
|
+
notIn?: string[];
|
|
19
|
+
notLike?: string;
|
|
20
|
+
};
|
|
21
|
+
export type BooleanFilter = {
|
|
22
|
+
eq?: boolean;
|
|
23
|
+
ne?: boolean;
|
|
24
|
+
};
|
|
25
|
+
export type DateFilter = {
|
|
26
|
+
in?: Date[];
|
|
27
|
+
eq?: Date;
|
|
28
|
+
gt?: Date;
|
|
29
|
+
gte?: Date;
|
|
30
|
+
lt?: Date;
|
|
31
|
+
lte?: Date;
|
|
32
|
+
};
|
|
@@ -5,14 +5,18 @@ import { QueryBuilderBase } from "../../../templates";
|
|
|
5
5
|
import { TypeOrmRepository } from "./repository";
|
|
6
6
|
import { EntityServiceLocator } from "../../../providers/services";
|
|
7
7
|
import { IEntitiesDeleteResult } from "../../../abstractions/repository";
|
|
8
|
+
import { QueryClauseBuilder } from "./queryClauseBuilder";
|
|
9
|
+
import { Facet } from "./facets";
|
|
8
10
|
export declare abstract class TypeOrmQueryBuilder<TEntity extends ObjectLiteral, TEntitySearchParameters extends IEntitySearchParameters<TSorting, number>, TSorting extends SortingType, TFacets extends IEntityFacets, TUserContext> extends QueryBuilderBase<TEntity, TEntitySearchParameters, TSorting, number, TFacets, TUserContext> {
|
|
9
11
|
private readonly services;
|
|
10
12
|
private repository;
|
|
13
|
+
protected clause: QueryClauseBuilder;
|
|
11
14
|
constructor(services: EntityServiceLocator<TEntity, unknown>);
|
|
12
15
|
exists(filters: NonNullable<TEntitySearchParameters["filters"]>, context?: IAuthenticationContext<TUserContext> | undefined): Promise<boolean>;
|
|
13
16
|
count(filters: NonNullable<TEntitySearchParameters["filters"]>, context?: IAuthenticationContext<TUserContext> | undefined): Promise<number>;
|
|
14
17
|
delete(filters: NonNullable<TEntitySearchParameters["filters"]>, context?: IAuthenticationContext<TUserContext> | undefined): Promise<IEntitiesDeleteResult>;
|
|
15
18
|
search(request: TEntitySearchParameters, context?: IAuthenticationContext<TUserContext>): Promise<IEntitiesSearchResults<TEntitySearchParameters, TEntity, TSorting, number, TFacets>>;
|
|
19
|
+
protected getFieldFacet(): Promise<void>;
|
|
16
20
|
protected findPagedQueryResults(request: TEntitySearchParameters, context?: IAuthenticationContext<TUserContext>): Promise<TEntity[]>;
|
|
17
21
|
protected getRelationsToLoad(request: TEntitySearchParameters, context: IAuthenticationContext<TUserContext> | undefined): FindOptionsRelations<TEntity> | undefined;
|
|
18
22
|
protected buildPagingParameters(request: TEntitySearchParameters): {
|
|
@@ -22,6 +26,7 @@ export declare abstract class TypeOrmQueryBuilder<TEntity extends ObjectLiteral,
|
|
|
22
26
|
protected countQueryResults(request: TEntitySearchParameters, context?: IAuthenticationContext<TUserContext>): Promise<number>;
|
|
23
27
|
protected abstract buildWhereClause(request: TEntitySearchParameters): FindOptionsWhere<TEntity>[] | FindOptionsWhere<TEntity>;
|
|
24
28
|
protected abstract buildContextFilter(context?: IAuthenticationContext<TUserContext>): FindOptionsWhere<TEntity>[] | FindOptionsWhere<TEntity>;
|
|
25
|
-
protected abstract calculateFacets(request: TEntitySearchParameters, context?: IAuthenticationContext<TUserContext>): Promise<TFacets
|
|
29
|
+
protected abstract calculateFacets(request: TEntitySearchParameters, context?: IAuthenticationContext<TUserContext>): Promise<TFacets>;
|
|
30
|
+
protected calculateFacet<TField extends keyof TEntity, TValue>(field: TField, request: TEntitySearchParameters, context: IAuthenticationContext<TUserContext> | undefined): Promise<Facet<TValue>>;
|
|
26
31
|
protected getRepository(): TypeOrmRepository<TEntity, unknown>;
|
|
27
32
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { FindOperator } from "typeorm";
|
|
2
|
+
import { BooleanFilter, DateFilter, NumericFilter, StringFilter } from "./clause";
|
|
3
|
+
export declare class QueryClauseBuilder {
|
|
4
|
+
stringFilter(filter: StringFilter): FindOperator<string>;
|
|
5
|
+
numericFilter(filter: NumericFilter): FindOperator<number>;
|
|
6
|
+
dateFilter(filter: DateFilter): FindOperator<Date>;
|
|
7
|
+
boolFilter(filter: BooleanFilter): FindOperator<boolean>;
|
|
8
|
+
}
|
|
@@ -8,6 +8,7 @@ export declare class TypeOrmRepository<TEntity extends ObjectLiteral, TEntityId>
|
|
|
8
8
|
private readonly logger;
|
|
9
9
|
constructor(innerRepository: Repository<TEntity>);
|
|
10
10
|
getInnerRepository(): Repository<TEntity>;
|
|
11
|
+
distinct<TField extends keyof TEntity, TValue>(field: TField, condition: FindManyOptions<TEntity>): Promise<any[]>;
|
|
11
12
|
exists(id: TEntityId): Promise<boolean>;
|
|
12
13
|
existsBy(condition: FindOneOptions<TEntity>): Promise<boolean>;
|
|
13
14
|
get(id: TEntityId): Promise<TEntity | undefined>;
|
package/dist/cjs/types/platforms/nest/__test__/server/entities/appCompanies/appCompany.query.d.ts
CHANGED
|
@@ -7,5 +7,5 @@ export declare class AppCompanyQueryBuilder extends NestTypeOrmQueryBuilder<AppC
|
|
|
7
7
|
constructor(registry: EntityManagerRegistry);
|
|
8
8
|
protected buildContextFilter(context?: IAuthenticationContext<AppAuthContext> | undefined): FindOptionsWhere<AppCompanyEntity> | FindOptionsWhere<AppCompanyEntity>[];
|
|
9
9
|
protected buildWhereClause(request: AppCompanySearchParameters): FindOptionsWhere<AppCompanyEntity> | FindOptionsWhere<AppCompanyEntity>[];
|
|
10
|
-
protected calculateFacets(request: AppCompanySearchParameters): Promise<AppCompanyFacets
|
|
10
|
+
protected calculateFacets(request: AppCompanySearchParameters): Promise<AppCompanyFacets>;
|
|
11
11
|
}
|
package/dist/cjs/types/platforms/nest/__test__/server/entities/appDivisions/appDivision.query.d.ts
CHANGED
|
@@ -7,5 +7,5 @@ export declare class AppDivisionQueryBuilder extends NestTypeOrmQueryBuilder<App
|
|
|
7
7
|
constructor(registry: EntityManagerRegistry);
|
|
8
8
|
protected buildContextFilter(context?: IAuthenticationContext<AppAuthContext> | undefined): FindOptionsWhere<AppDivisionEntity> | FindOptionsWhere<AppDivisionEntity>[];
|
|
9
9
|
protected buildWhereClause(request: AppDivisionSearchParameters): FindOptionsWhere<AppDivisionEntity> | FindOptionsWhere<AppDivisionEntity>[];
|
|
10
|
-
protected calculateFacets(request: AppDivisionSearchParameters): Promise<AppDivisionFacets
|
|
10
|
+
protected calculateFacets(request: AppDivisionSearchParameters): Promise<AppDivisionFacets>;
|
|
11
11
|
}
|
|
@@ -7,5 +7,5 @@ export declare class AppOrganizationQueryBuilder extends NestTypeOrmQueryBuilder
|
|
|
7
7
|
constructor(registry: EntityManagerRegistry);
|
|
8
8
|
protected buildContextFilter(context?: IAuthenticationContext<AppAuthContext> | undefined): FindOptionsWhere<AppOrganizationEntity> | FindOptionsWhere<AppOrganizationEntity>[];
|
|
9
9
|
protected buildWhereClause(request: AppOrganizationSearchParameters): FindOptionsWhere<AppOrganizationEntity> | FindOptionsWhere<AppOrganizationEntity>[];
|
|
10
|
-
protected calculateFacets(request: AppOrganizationSearchParameters): Promise<AppOrganizationFacets
|
|
10
|
+
protected calculateFacets(request: AppOrganizationSearchParameters): Promise<AppOrganizationFacets>;
|
|
11
11
|
}
|
|
@@ -7,6 +7,6 @@ export declare class AppRoleQueryBuilder extends NestTypeOrmQueryBuilder<AppRole
|
|
|
7
7
|
constructor(registry: EntityManagerRegistry);
|
|
8
8
|
protected buildContextFilter(context?: IAuthenticationContext<AppAuthContext> | undefined): FindOptionsWhere<AppRoleEntity> | FindOptionsWhere<AppRoleEntity>[];
|
|
9
9
|
protected buildWhereClause(request: AppRoleSearchParameters, context?: IAuthenticationContext<AppAuthContext> | undefined): FindOptionsWhere<AppRoleEntity> | FindOptionsWhere<AppRoleEntity>[];
|
|
10
|
-
protected calculateFacets(request: AppRoleSearchParameters): Promise<AppRoleFacets
|
|
10
|
+
protected calculateFacets(request: AppRoleSearchParameters): Promise<AppRoleFacets>;
|
|
11
11
|
protected getRelationsToLoad(request: AppRoleSearchParameters, context?: IAuthenticationContext<AppAuthContext> | undefined): FindOptionsRelations<AppRoleEntity> | undefined;
|
|
12
12
|
}
|
package/dist/cjs/types/platforms/nest/__test__/server/entities/appTenants/appTenant.query.d.ts
CHANGED
|
@@ -7,5 +7,5 @@ export declare class AppTenantQueryBuilder extends NestTypeOrmQueryBuilder<AppTe
|
|
|
7
7
|
constructor(registry: EntityManagerRegistry);
|
|
8
8
|
protected buildContextFilter(context?: IAuthenticationContext<AppAuthContext> | undefined): FindOptionsWhere<AppTenantEntity> | FindOptionsWhere<AppTenantEntity>[];
|
|
9
9
|
protected buildWhereClause(request: AppTenantSearchParameters): FindOptionsWhere<AppTenantEntity> | FindOptionsWhere<AppTenantEntity>[];
|
|
10
|
-
protected calculateFacets(request: AppTenantSearchParameters): Promise<AppTenantFacets
|
|
10
|
+
protected calculateFacets(request: AppTenantSearchParameters): Promise<AppTenantFacets>;
|
|
11
11
|
}
|
|
@@ -7,5 +7,5 @@ export declare class AppUserGroupMemberQueryBuilder extends NestTypeOrmQueryBuil
|
|
|
7
7
|
constructor(registry: EntityManagerRegistry);
|
|
8
8
|
protected buildContextFilter(context?: IAuthenticationContext<AppAuthContext> | undefined): FindOptionsWhere<AppUserGroupMemberEntity> | FindOptionsWhere<AppUserGroupMemberEntity>[];
|
|
9
9
|
protected buildWhereClause(request: AppUserGroupMemberSearchParameters): FindOptionsWhere<AppUserGroupMemberEntity> | FindOptionsWhere<AppUserGroupMemberEntity>[];
|
|
10
|
-
protected calculateFacets(request: AppUserGroupMemberSearchParameters): Promise<AppUserGroupMemberFacets
|
|
10
|
+
protected calculateFacets(request: AppUserGroupMemberSearchParameters): Promise<AppUserGroupMemberFacets>;
|
|
11
11
|
}
|
package/dist/cjs/types/platforms/nest/__test__/server/entities/appUserGroups/appUserGroup.query.d.ts
CHANGED
|
@@ -7,5 +7,5 @@ export declare class AppUserGroupQueryBuilder extends NestTypeOrmQueryBuilder<Ap
|
|
|
7
7
|
constructor(registry: EntityManagerRegistry);
|
|
8
8
|
protected buildContextFilter(context?: IAuthenticationContext<AppAuthContext> | undefined): FindOptionsWhere<AppUserGroupEntity> | FindOptionsWhere<AppUserGroupEntity>[];
|
|
9
9
|
protected buildWhereClause(request: AppUserGroupSearchParameters): FindOptionsWhere<AppUserGroupEntity> | FindOptionsWhere<AppUserGroupEntity>[];
|
|
10
|
-
protected calculateFacets(request: AppUserGroupSearchParameters): Promise<AppUserGroupFacets
|
|
10
|
+
protected calculateFacets(request: AppUserGroupSearchParameters): Promise<AppUserGroupFacets>;
|
|
11
11
|
}
|
|
@@ -7,5 +7,5 @@ export declare class AppUserProfileQueryBuilder extends NestTypeOrmQueryBuilder<
|
|
|
7
7
|
constructor(registry: EntityManagerRegistry);
|
|
8
8
|
protected buildContextFilter(context?: IAuthenticationContext<AppAuthContext> | undefined): FindOptionsWhere<AppUserProfileEntity> | FindOptionsWhere<AppUserProfileEntity>[];
|
|
9
9
|
protected buildWhereClause(request: AppUserProfileSearchParameters): FindOptionsWhere<AppUserProfileEntity> | FindOptionsWhere<AppUserProfileEntity>[];
|
|
10
|
-
protected calculateFacets(request: AppUserProfileSearchParameters): Promise<AppUserProfileFacets
|
|
10
|
+
protected calculateFacets(request: AppUserProfileSearchParameters): Promise<AppUserProfileFacets>;
|
|
11
11
|
}
|
package/dist/cjs/types/platforms/nest/__test__/server/entities/appUserRoles/appUserRole.query.d.ts
CHANGED
|
@@ -7,6 +7,6 @@ export declare class AppUserRoleQueryBuilder extends NestTypeOrmQueryBuilder<App
|
|
|
7
7
|
constructor(registry: EntityManagerRegistry);
|
|
8
8
|
protected buildContextFilter(context?: IAuthenticationContext<AppAuthContext> | undefined): FindOptionsWhere<AppUserRoleEntity> | FindOptionsWhere<AppUserRoleEntity>[];
|
|
9
9
|
protected buildWhereClause(request: AppUserRoleSearchParameters): FindOptionsWhere<AppUserRoleEntity> | FindOptionsWhere<AppUserRoleEntity>[];
|
|
10
|
-
protected calculateFacets(request: AppUserRoleSearchParameters): Promise<AppUserRoleFacets
|
|
10
|
+
protected calculateFacets(request: AppUserRoleSearchParameters): Promise<AppUserRoleFacets>;
|
|
11
11
|
protected getRelationsToLoad(request: AppUserRoleSearchParameters, context: IAuthenticationContext<AppAuthContext> | undefined): FindOptionsRelations<AppUserRoleEntity> | undefined;
|
|
12
12
|
}
|
|
@@ -7,5 +7,5 @@ export declare class AppUserQueryBuilder extends NestTypeOrmQueryBuilder<AppUser
|
|
|
7
7
|
constructor(registry: EntityManagerRegistry);
|
|
8
8
|
protected buildContextFilter(context?: IAuthenticationContext<AppAuthContext> | undefined): FindOptionsWhere<AppUserEntity> | FindOptionsWhere<AppUserEntity>[];
|
|
9
9
|
protected buildWhereClause(request: AppUserSearchParameters): FindOptionsWhere<AppUserEntity> | FindOptionsWhere<AppUserEntity>[];
|
|
10
|
-
protected calculateFacets(request: AppUserSearchParameters): Promise<AppUserFacets
|
|
10
|
+
protected calculateFacets(request: AppUserSearchParameters): Promise<AppUserFacets>;
|
|
11
11
|
}
|
|
@@ -2,6 +2,7 @@ import { IEntitySearchParameters, ISearchSorting, ISearchSortingField, SortDirec
|
|
|
2
2
|
import { IEntitiesSearchResults, IEntitiesSearchResultsPaging } from "../../../../../../models";
|
|
3
3
|
import { FooEntity } from "../../database/core/entities/foo.entity";
|
|
4
4
|
import { IEntitiesDeleteParameters } from "../../../../../../abstractions/commands";
|
|
5
|
+
import { NumberFacets } from "../../../../../../integrations/repository/typeorm/facets";
|
|
5
6
|
export type FooEntityId = string;
|
|
6
7
|
export type FooCreateData = Partial<FooEntity>;
|
|
7
8
|
export type FooUpdateData = Partial<FooEntity>;
|
|
@@ -9,6 +10,7 @@ export interface FooSearchParameters extends IEntitySearchParameters<FooSorting,
|
|
|
9
10
|
filters?: FooSearchFilters;
|
|
10
11
|
}
|
|
11
12
|
export interface FooFacets {
|
|
13
|
+
age: NumberFacets;
|
|
12
14
|
}
|
|
13
15
|
export interface FooSearchFilters {
|
|
14
16
|
minAge?: number;
|
|
@@ -10,5 +10,5 @@ export declare class FooQueryBuilder extends NestTypeOrmQueryBuilder<FooEntity,
|
|
|
10
10
|
protected buildContextFilter(context?: IAuthenticationContext<AppAuthContext> | undefined): FindOptionsWhere<FooEntity> | FindOptionsWhere<FooEntity>[];
|
|
11
11
|
protected buildWhereClause(request: FooSearchParameters): FindOptionsWhere<FooEntity> | FindOptionsWhere<FooEntity>[];
|
|
12
12
|
private buildAgeWhereClause;
|
|
13
|
-
protected calculateFacets(request: FooSearchParameters, context?: IAuthenticationContext<AppAuthContext>): Promise<FooFacets
|
|
13
|
+
protected calculateFacets(request: FooSearchParameters, context?: IAuthenticationContext<AppAuthContext>): Promise<FooFacets>;
|
|
14
14
|
}
|
package/dist/esm/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import { STATIC_CONTEXT } from '@nestjs/core/injector/constants';
|
|
|
9
9
|
import { MetadataScanner } from '@nestjs/core/metadata-scanner';
|
|
10
10
|
import { JwtService, JwtModule } from '@nestjs/jwt';
|
|
11
11
|
import { EventEmitter2, EventEmitterModule } from '@nestjs/event-emitter';
|
|
12
|
-
import { In } from 'typeorm';
|
|
12
|
+
import { MoreThanOrEqual, MoreThan, LessThanOrEqual, LessThan, In, Equal, Like, Not, And } from 'typeorm';
|
|
13
13
|
import { ListObjectsCommand, PutObjectCommand, GetObjectCommand, DeleteObjectCommand, S3Client } from '@aws-sdk/client-s3';
|
|
14
14
|
import { getSignedUrl } from '@aws-sdk/s3-request-presigner';
|
|
15
15
|
import { SendEmailCommand, SESClient } from '@aws-sdk/client-ses';
|
|
@@ -21434,10 +21434,90 @@ class QueryBuilderBase {
|
|
|
21434
21434
|
}
|
|
21435
21435
|
}
|
|
21436
21436
|
|
|
21437
|
+
class QueryClauseBuilder {
|
|
21438
|
+
stringFilter(filter) {
|
|
21439
|
+
const clauses = [];
|
|
21440
|
+
if (!!filter?.gte) {
|
|
21441
|
+
clauses.push(MoreThanOrEqual(filter.gte));
|
|
21442
|
+
}
|
|
21443
|
+
if (!!filter?.gt) {
|
|
21444
|
+
clauses.push(MoreThan(filter.gt));
|
|
21445
|
+
}
|
|
21446
|
+
if (!!filter?.lte) {
|
|
21447
|
+
clauses.push(LessThanOrEqual(filter.lte));
|
|
21448
|
+
}
|
|
21449
|
+
if (!!filter?.lt) {
|
|
21450
|
+
clauses.push(LessThan(filter.lt));
|
|
21451
|
+
}
|
|
21452
|
+
if (!!filter?.in) {
|
|
21453
|
+
clauses.push(In(filter.in));
|
|
21454
|
+
}
|
|
21455
|
+
if (!!filter?.eq) {
|
|
21456
|
+
clauses.push(Equal(filter.eq));
|
|
21457
|
+
}
|
|
21458
|
+
if (!!filter?.like) {
|
|
21459
|
+
clauses.push(Like(filter.like.replaceAll("*", "%")));
|
|
21460
|
+
}
|
|
21461
|
+
if (!!filter?.ne) {
|
|
21462
|
+
clauses.push(Not(Equal(filter.ne)));
|
|
21463
|
+
}
|
|
21464
|
+
if (!!filter?.notIn) {
|
|
21465
|
+
clauses.push(Not(In(filter.notIn)));
|
|
21466
|
+
}
|
|
21467
|
+
if (!!filter?.notLike) {
|
|
21468
|
+
clauses.push(Not(Like(filter.notLike.replaceAll("*", "%"))));
|
|
21469
|
+
}
|
|
21470
|
+
return And(...clauses);
|
|
21471
|
+
}
|
|
21472
|
+
numericFilter(filter) {
|
|
21473
|
+
const clauses = [];
|
|
21474
|
+
if (!!filter?.gte) {
|
|
21475
|
+
clauses.push(MoreThanOrEqual(filter.gte));
|
|
21476
|
+
}
|
|
21477
|
+
if (!!filter?.gt) {
|
|
21478
|
+
clauses.push(MoreThan(filter.gt));
|
|
21479
|
+
}
|
|
21480
|
+
if (!!filter?.lte) {
|
|
21481
|
+
clauses.push(LessThanOrEqual(filter.lte));
|
|
21482
|
+
}
|
|
21483
|
+
if (!!filter?.lt) {
|
|
21484
|
+
clauses.push(LessThan(filter.lt));
|
|
21485
|
+
}
|
|
21486
|
+
return And(...clauses);
|
|
21487
|
+
}
|
|
21488
|
+
dateFilter(filter) {
|
|
21489
|
+
const clauses = [];
|
|
21490
|
+
if (!!filter?.gte) {
|
|
21491
|
+
clauses.push(MoreThanOrEqual(filter.gte));
|
|
21492
|
+
}
|
|
21493
|
+
if (!!filter?.gt) {
|
|
21494
|
+
clauses.push(MoreThan(filter.gt));
|
|
21495
|
+
}
|
|
21496
|
+
if (!!filter?.lte) {
|
|
21497
|
+
clauses.push(LessThanOrEqual(filter.lte));
|
|
21498
|
+
}
|
|
21499
|
+
if (!!filter?.lt) {
|
|
21500
|
+
clauses.push(LessThan(filter.lt));
|
|
21501
|
+
}
|
|
21502
|
+
return And(...clauses);
|
|
21503
|
+
}
|
|
21504
|
+
boolFilter(filter) {
|
|
21505
|
+
const clauses = [];
|
|
21506
|
+
if (!isNullOrUndefined(filter?.eq)) {
|
|
21507
|
+
clauses.push(Equal(filter.eq));
|
|
21508
|
+
}
|
|
21509
|
+
if (!isNullOrUndefined(filter?.ne)) {
|
|
21510
|
+
clauses.push(Not(Equal(filter.ne)));
|
|
21511
|
+
}
|
|
21512
|
+
return And(...clauses);
|
|
21513
|
+
}
|
|
21514
|
+
}
|
|
21515
|
+
|
|
21437
21516
|
class TypeOrmQueryBuilder extends QueryBuilderBase {
|
|
21438
21517
|
constructor(services) {
|
|
21439
21518
|
super();
|
|
21440
21519
|
this.services = services;
|
|
21520
|
+
this.clause = new QueryClauseBuilder();
|
|
21441
21521
|
}
|
|
21442
21522
|
async exists(filters, context) {
|
|
21443
21523
|
return (await this.count(filters, context)) > 0;
|
|
@@ -21461,7 +21541,9 @@ class TypeOrmQueryBuilder extends QueryBuilderBase {
|
|
|
21461
21541
|
// todo: execute inside read transaction in order to perform the three queries on the same dataset
|
|
21462
21542
|
const queryResults = await this.countQueryResults(request, context);
|
|
21463
21543
|
const results = await this.findPagedQueryResults(request, context);
|
|
21464
|
-
const facets =
|
|
21544
|
+
const facets = request.options?.includeFacets
|
|
21545
|
+
? await this.calculateFacets(request, context)
|
|
21546
|
+
: undefined;
|
|
21465
21547
|
return {
|
|
21466
21548
|
items: results,
|
|
21467
21549
|
request,
|
|
@@ -21473,6 +21555,9 @@ class TypeOrmQueryBuilder extends QueryBuilderBase {
|
|
|
21473
21555
|
facets,
|
|
21474
21556
|
};
|
|
21475
21557
|
}
|
|
21558
|
+
async getFieldFacet() {
|
|
21559
|
+
this.getRepository().find({});
|
|
21560
|
+
}
|
|
21476
21561
|
async findPagedQueryResults(request, context) {
|
|
21477
21562
|
return await this.getRepository().find({
|
|
21478
21563
|
where: {
|
|
@@ -21502,15 +21587,15 @@ class TypeOrmQueryBuilder extends QueryBuilderBase {
|
|
|
21502
21587
|
},
|
|
21503
21588
|
});
|
|
21504
21589
|
}
|
|
21505
|
-
|
|
21506
|
-
|
|
21507
|
-
|
|
21508
|
-
|
|
21509
|
-
|
|
21510
|
-
|
|
21511
|
-
|
|
21512
|
-
|
|
21513
|
-
|
|
21590
|
+
async calculateFacet(field, request, context) {
|
|
21591
|
+
const values = await this.getRepository().distinct(field, {
|
|
21592
|
+
...(context ? this.buildContextFilter(context) : {}),
|
|
21593
|
+
...this.buildWhereClause(request),
|
|
21594
|
+
});
|
|
21595
|
+
return {
|
|
21596
|
+
values,
|
|
21597
|
+
};
|
|
21598
|
+
}
|
|
21514
21599
|
getRepository() {
|
|
21515
21600
|
if (!this.repository) {
|
|
21516
21601
|
this.repository = this.services.resolveRepository();
|
|
@@ -21527,6 +21612,20 @@ class TypeOrmRepository {
|
|
|
21527
21612
|
getInnerRepository() {
|
|
21528
21613
|
return this.innerRepository;
|
|
21529
21614
|
}
|
|
21615
|
+
async distinct(field, condition) {
|
|
21616
|
+
this.logger.debug("Getting distinct values", { field });
|
|
21617
|
+
const columnName = this.innerRepository.metadata.findColumnWithPropertyName(field)?.databaseName;
|
|
21618
|
+
if (!columnName) {
|
|
21619
|
+
throw new Error(`Column '${field}' not found`);
|
|
21620
|
+
}
|
|
21621
|
+
const results = await this.innerRepository
|
|
21622
|
+
.createQueryBuilder()
|
|
21623
|
+
.select(`DISTINCT ${columnName}`)
|
|
21624
|
+
.where(condition)
|
|
21625
|
+
.orderBy(columnName)
|
|
21626
|
+
.getRawMany();
|
|
21627
|
+
return results.map((x) => x[columnName]);
|
|
21628
|
+
}
|
|
21530
21629
|
async exists(id) {
|
|
21531
21630
|
if (isNullOrUndefined(id)) {
|
|
21532
21631
|
throw new Error("Invalid 'id' parameter.");
|