@punks/backend-entity-manager 0.0.95 → 0.0.97
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 +81 -1
- 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/queryBuilder.d.ts +2 -0
- package/dist/cjs/types/integrations/repository/typeorm/queryClauseBuilder.d.ts +8 -0
- package/dist/esm/index.js +82 -2
- 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/queryBuilder.d.ts +2 -0
- package/dist/esm/types/integrations/repository/typeorm/queryClauseBuilder.d.ts +8 -0
- package/dist/index.d.ts +42 -1
- 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 | undefined>;
|
|
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,9 +5,11 @@ 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";
|
|
8
9
|
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
10
|
private readonly services;
|
|
10
11
|
private repository;
|
|
12
|
+
protected clause: QueryClauseBuilder;
|
|
11
13
|
constructor(services: EntityServiceLocator<TEntity, unknown>);
|
|
12
14
|
exists(filters: NonNullable<TEntitySearchParameters["filters"]>, context?: IAuthenticationContext<TUserContext> | undefined): Promise<boolean>;
|
|
13
15
|
count(filters: NonNullable<TEntitySearchParameters["filters"]>, context?: IAuthenticationContext<TUserContext> | undefined): Promise<number>;
|
|
@@ -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
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ import { Reflector, ModulesContainer as ModulesContainer$1 } from '@nestjs/core'
|
|
|
13
13
|
import { JwtService } from '@nestjs/jwt';
|
|
14
14
|
import * as express from 'express';
|
|
15
15
|
import { Response, Request, NextFunction } from 'express';
|
|
16
|
-
import { ObjectLiteral, FindOneOptions, FindManyOptions, Repository, ObjectId, FindOptionsWhere, FindOptionsRelations } from 'typeorm';
|
|
16
|
+
import { ObjectLiteral, FindOneOptions, FindManyOptions, Repository, ObjectId, FindOptionsWhere, FindOperator, FindOptionsRelations } from 'typeorm';
|
|
17
17
|
import { EventEmitter2 } from '@nestjs/event-emitter';
|
|
18
18
|
import * as qs from 'qs';
|
|
19
19
|
import * as express_serve_static_core from 'express-serve-static-core';
|
|
@@ -1868,9 +1868,50 @@ declare class TypeOrmRepository<TEntity extends ObjectLiteral, TEntityId> implem
|
|
|
1868
1868
|
upsert(id: TEntityId, entity: Partial<TEntity>): Promise<TEntity>;
|
|
1869
1869
|
}
|
|
1870
1870
|
|
|
1871
|
+
type NumericFilter = {
|
|
1872
|
+
in?: number[];
|
|
1873
|
+
eq?: number;
|
|
1874
|
+
gt?: number;
|
|
1875
|
+
gte?: number;
|
|
1876
|
+
lt?: number;
|
|
1877
|
+
lte?: number;
|
|
1878
|
+
};
|
|
1879
|
+
type StringFilter = {
|
|
1880
|
+
gt?: string;
|
|
1881
|
+
gte?: string;
|
|
1882
|
+
lt?: string;
|
|
1883
|
+
lte?: string;
|
|
1884
|
+
in?: string[];
|
|
1885
|
+
eq?: string;
|
|
1886
|
+
like?: string;
|
|
1887
|
+
ne?: string;
|
|
1888
|
+
notIn?: string[];
|
|
1889
|
+
notLike?: string;
|
|
1890
|
+
};
|
|
1891
|
+
type BooleanFilter = {
|
|
1892
|
+
eq?: boolean;
|
|
1893
|
+
ne?: boolean;
|
|
1894
|
+
};
|
|
1895
|
+
type DateFilter = {
|
|
1896
|
+
in?: Date[];
|
|
1897
|
+
eq?: Date;
|
|
1898
|
+
gt?: Date;
|
|
1899
|
+
gte?: Date;
|
|
1900
|
+
lt?: Date;
|
|
1901
|
+
lte?: Date;
|
|
1902
|
+
};
|
|
1903
|
+
|
|
1904
|
+
declare class QueryClauseBuilder {
|
|
1905
|
+
stringFilter(filter: StringFilter): FindOperator<string>;
|
|
1906
|
+
numericFilter(filter: NumericFilter): FindOperator<number>;
|
|
1907
|
+
dateFilter(filter: DateFilter): FindOperator<Date>;
|
|
1908
|
+
boolFilter(filter: BooleanFilter): FindOperator<boolean>;
|
|
1909
|
+
}
|
|
1910
|
+
|
|
1871
1911
|
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> {
|
|
1872
1912
|
private readonly services;
|
|
1873
1913
|
private repository;
|
|
1914
|
+
protected clause: QueryClauseBuilder;
|
|
1874
1915
|
constructor(services: EntityServiceLocator<TEntity, unknown>);
|
|
1875
1916
|
exists(filters: NonNullable<TEntitySearchParameters["filters"]>, context?: IAuthenticationContext<TUserContext> | undefined): Promise<boolean>;
|
|
1876
1917
|
count(filters: NonNullable<TEntitySearchParameters["filters"]>, context?: IAuthenticationContext<TUserContext> | undefined): Promise<number>;
|