@depup/typeorm-extension 3.9.0-depup.0
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/LICENSE +21 -0
- package/README.MD +674 -0
- package/README.md +34 -0
- package/bin/cli.cjs +275 -0
- package/bin/cli.mjs +273 -0
- package/changes.json +22 -0
- package/dist/cli/commands/database/create.d.ts +27 -0
- package/dist/cli/commands/database/drop.d.ts +23 -0
- package/dist/cli/commands/database/index.d.ts +2 -0
- package/dist/cli/commands/index.d.ts +2 -0
- package/dist/cli/commands/seed/create.d.ts +21 -0
- package/dist/cli/commands/seed/index.d.ts +2 -0
- package/dist/cli/commands/seed/run.d.ts +24 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/data-source/find/index.d.ts +2 -0
- package/dist/data-source/find/module.d.ts +3 -0
- package/dist/data-source/find/type.d.ts +22 -0
- package/dist/data-source/index.d.ts +4 -0
- package/dist/data-source/options/index.d.ts +4 -0
- package/dist/data-source/options/module.d.ts +8 -0
- package/dist/data-source/options/singleton.d.ts +4 -0
- package/dist/data-source/options/type.d.ts +26 -0
- package/dist/data-source/options/utils/env.d.ts +4 -0
- package/dist/data-source/options/utils/index.d.ts +2 -0
- package/dist/data-source/options/utils/merge.d.ts +2 -0
- package/dist/data-source/singleton.d.ts +5 -0
- package/dist/data-source/type.d.ts +2 -0
- package/dist/database/driver/cockroachdb.d.ts +4 -0
- package/dist/database/driver/index.d.ts +9 -0
- package/dist/database/driver/mongodb.d.ts +6 -0
- package/dist/database/driver/mssql.d.ts +6 -0
- package/dist/database/driver/mysql.d.ts +7 -0
- package/dist/database/driver/oracle.d.ts +6 -0
- package/dist/database/driver/postgres.d.ts +8 -0
- package/dist/database/driver/sqlite.d.ts +3 -0
- package/dist/database/driver/types.d.ts +20 -0
- package/dist/database/driver/utils/build.d.ts +3 -0
- package/dist/database/driver/utils/character-set.d.ts +2 -0
- package/dist/database/driver/utils/charset.d.ts +2 -0
- package/dist/database/driver/utils/create.d.ts +2 -0
- package/dist/database/driver/utils/index.d.ts +4 -0
- package/dist/database/index.d.ts +3 -0
- package/dist/database/methods/check/index.d.ts +2 -0
- package/dist/database/methods/check/module.d.ts +7 -0
- package/dist/database/methods/check/types.d.ts +51 -0
- package/dist/database/methods/create/index.d.ts +1 -0
- package/dist/database/methods/create/module.d.ts +10 -0
- package/dist/database/methods/drop/index.d.ts +1 -0
- package/dist/database/methods/drop/module.d.ts +10 -0
- package/dist/database/methods/index.d.ts +4 -0
- package/dist/database/methods/type.d.ts +43 -0
- package/dist/database/utils/context.d.ts +3 -0
- package/dist/database/utils/index.d.ts +5 -0
- package/dist/database/utils/migration.d.ts +2 -0
- package/dist/database/utils/query.d.ts +3 -0
- package/dist/database/utils/schema.d.ts +3 -0
- package/dist/database/utils/type.d.ts +32 -0
- package/dist/env/constants.d.ts +68 -0
- package/dist/env/index.d.ts +3 -0
- package/dist/env/module.d.ts +4 -0
- package/dist/env/type.d.ts +36 -0
- package/dist/env/utils.d.ts +3 -0
- package/dist/errors/base.d.ts +2 -0
- package/dist/errors/driver.d.ts +6 -0
- package/dist/errors/index.d.ts +3 -0
- package/dist/errors/options.d.ts +7 -0
- package/dist/helpers/entity/error.d.ts +20 -0
- package/dist/helpers/entity/index.d.ts +5 -0
- package/dist/helpers/entity/join-columns.d.ts +16 -0
- package/dist/helpers/entity/metadata.d.ts +10 -0
- package/dist/helpers/entity/property-names.d.ts +11 -0
- package/dist/helpers/entity/uniqueness.d.ts +28 -0
- package/dist/helpers/index.d.ts +1 -0
- package/dist/index.cjs +3258 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.mjs +3136 -0
- package/dist/index.mjs.map +1 -0
- package/dist/query/index.d.ts +4 -0
- package/dist/query/module.d.ts +5 -0
- package/dist/query/parameter/fields/index.d.ts +2 -0
- package/dist/query/parameter/fields/module.d.ts +25 -0
- package/dist/query/parameter/fields/type.d.ts +6 -0
- package/dist/query/parameter/filters/index.d.ts +2 -0
- package/dist/query/parameter/filters/module.d.ts +35 -0
- package/dist/query/parameter/filters/type.d.ts +12 -0
- package/dist/query/parameter/index.d.ts +5 -0
- package/dist/query/parameter/pagination/index.d.ts +2 -0
- package/dist/query/parameter/pagination/module.d.ts +26 -0
- package/dist/query/parameter/pagination/type.d.ts +3 -0
- package/dist/query/parameter/relations/index.d.ts +2 -0
- package/dist/query/parameter/relations/module.d.ts +27 -0
- package/dist/query/parameter/relations/type.d.ts +8 -0
- package/dist/query/parameter/sort/index.d.ts +2 -0
- package/dist/query/parameter/sort/module.d.ts +26 -0
- package/dist/query/parameter/sort/type.d.ts +6 -0
- package/dist/query/type.d.ts +16 -0
- package/dist/query/utils/alias.d.ts +2 -0
- package/dist/query/utils/index.d.ts +3 -0
- package/dist/query/utils/key.d.ts +1 -0
- package/dist/query/utils/option.d.ts +1 -0
- package/dist/seeder/entity.d.ts +42 -0
- package/dist/seeder/executor.d.ts +24 -0
- package/dist/seeder/factory/index.d.ts +4 -0
- package/dist/seeder/factory/manager.d.ts +8 -0
- package/dist/seeder/factory/module.d.ts +17 -0
- package/dist/seeder/factory/type.d.ts +12 -0
- package/dist/seeder/factory/utils.d.ts +7 -0
- package/dist/seeder/index.d.ts +6 -0
- package/dist/seeder/module.d.ts +5 -0
- package/dist/seeder/type.d.ts +44 -0
- package/dist/seeder/utils/file-path.d.ts +7 -0
- package/dist/seeder/utils/index.d.ts +3 -0
- package/dist/seeder/utils/prepare.d.ts +2 -0
- package/dist/seeder/utils/template.d.ts +1 -0
- package/dist/utils/code-transformation/constants.d.ts +4 -0
- package/dist/utils/code-transformation/index.d.ts +2 -0
- package/dist/utils/code-transformation/module.d.ts +3 -0
- package/dist/utils/entity.d.ts +2 -0
- package/dist/utils/file-path.d.ts +9 -0
- package/dist/utils/file-system.d.ts +1 -0
- package/dist/utils/has-property.d.ts +2 -0
- package/dist/utils/index.d.ts +10 -0
- package/dist/utils/object.d.ts +2 -0
- package/dist/utils/promise.d.ts +1 -0
- package/dist/utils/separator.d.ts +3 -0
- package/dist/utils/slash.d.ts +2 -0
- package/dist/utils/tsconfig/index.d.ts +2 -0
- package/dist/utils/tsconfig/module.d.ts +2 -0
- package/dist/utils/tsconfig/type.d.ts +13 -0
- package/package.json +134 -0
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ParseInput, ParseOutput } from 'rapiq';
|
|
2
|
+
import type { ObjectLiteral, SelectQueryBuilder } from 'typeorm';
|
|
3
|
+
import type { QueryApplyOptions, QueryApplyOutput } from './type';
|
|
4
|
+
export declare function applyQueryParseOutput<T extends ObjectLiteral = ObjectLiteral>(query: SelectQueryBuilder<T>, context: ParseOutput, options?: QueryApplyOptions<T>): ParseOutput;
|
|
5
|
+
export declare function applyQuery<T extends ObjectLiteral = ObjectLiteral>(query: SelectQueryBuilder<T>, input: ParseInput, options?: QueryApplyOptions<T>): QueryApplyOutput;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ObjectLiteral, SelectQueryBuilder } from 'typeorm';
|
|
2
|
+
import type { QueryFieldsApplyOptions, QueryFieldsApplyOutput } from './type';
|
|
3
|
+
/**
|
|
4
|
+
* Apply parsed fields parameter data on the db query.
|
|
5
|
+
*
|
|
6
|
+
* @param query
|
|
7
|
+
* @param data
|
|
8
|
+
*/
|
|
9
|
+
export declare function applyQueryFieldsParseOutput<T extends ObjectLiteral = ObjectLiteral>(query: SelectQueryBuilder<T>, data: QueryFieldsApplyOutput, options?: QueryFieldsApplyOptions<T>): import("rapiq").FieldsParseOutput;
|
|
10
|
+
/**
|
|
11
|
+
* Apply raw fields parameter data on the db query.
|
|
12
|
+
*
|
|
13
|
+
* @param query
|
|
14
|
+
* @param data
|
|
15
|
+
* @param options
|
|
16
|
+
*/
|
|
17
|
+
export declare function applyQueryFields<T extends ObjectLiteral = ObjectLiteral>(query: SelectQueryBuilder<T>, data: unknown, options?: QueryFieldsApplyOptions<T>): QueryFieldsApplyOutput;
|
|
18
|
+
/**
|
|
19
|
+
* Apply raw fields parameter data on the db query.
|
|
20
|
+
*
|
|
21
|
+
* @param query
|
|
22
|
+
* @param data
|
|
23
|
+
* @param options
|
|
24
|
+
*/
|
|
25
|
+
export declare function applyFields<T extends ObjectLiteral = ObjectLiteral>(query: SelectQueryBuilder<T>, data: unknown, options?: QueryFieldsApplyOptions<T>): QueryFieldsApplyOutput;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { FieldsParseOptions, FieldsParseOutput } from 'rapiq';
|
|
2
|
+
import type { ObjectLiteral } from 'typeorm';
|
|
3
|
+
export type QueryFieldsApplyOptions<T extends ObjectLiteral = ObjectLiteral> = FieldsParseOptions<T> & {
|
|
4
|
+
defaultAlias?: string;
|
|
5
|
+
};
|
|
6
|
+
export type QueryFieldsApplyOutput = FieldsParseOutput;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { FiltersParseOutput } from 'rapiq';
|
|
2
|
+
import type { ObjectLiteral, SelectQueryBuilder, WhereExpressionBuilder } from 'typeorm';
|
|
3
|
+
import type { QueryFiltersApplyOptions, QueryFiltersApplyOutput, QueryFiltersOutput } from './type';
|
|
4
|
+
export declare function transformParsedFilters<T extends ObjectLiteral = ObjectLiteral>(data: FiltersParseOutput, options?: QueryFiltersApplyOptions<T>): QueryFiltersOutput;
|
|
5
|
+
/**
|
|
6
|
+
* Apply transformed filter[s] parameter data on the db query.
|
|
7
|
+
*
|
|
8
|
+
* @param query
|
|
9
|
+
* @param data
|
|
10
|
+
*/
|
|
11
|
+
export declare function applyFiltersTransformed<T extends ObjectLiteral = ObjectLiteral>(query: SelectQueryBuilder<T> | WhereExpressionBuilder, data: QueryFiltersOutput): QueryFiltersOutput;
|
|
12
|
+
/**
|
|
13
|
+
* Apply parsed filter[s] parameter data on the db query.
|
|
14
|
+
*
|
|
15
|
+
* @param query
|
|
16
|
+
* @param data
|
|
17
|
+
* @param options
|
|
18
|
+
*/
|
|
19
|
+
export declare function applyQueryFiltersParseOutput<T extends ObjectLiteral = ObjectLiteral>(query: SelectQueryBuilder<T> | WhereExpressionBuilder, data: FiltersParseOutput, options?: QueryFiltersApplyOptions<T>): QueryFiltersApplyOutput;
|
|
20
|
+
/**
|
|
21
|
+
* Apply raw filter[s] parameter data on the db query.
|
|
22
|
+
*
|
|
23
|
+
* @param query
|
|
24
|
+
* @param data
|
|
25
|
+
* @param options
|
|
26
|
+
*/
|
|
27
|
+
export declare function applyQueryFilters<T extends ObjectLiteral = ObjectLiteral>(query: SelectQueryBuilder<T>, data: unknown, options?: QueryFiltersApplyOptions<T>): QueryFiltersApplyOutput;
|
|
28
|
+
/**
|
|
29
|
+
* Apply raw filter[s] parameter data on the db query.
|
|
30
|
+
*
|
|
31
|
+
* @param query
|
|
32
|
+
* @param data
|
|
33
|
+
* @param options
|
|
34
|
+
*/
|
|
35
|
+
export declare function applyFilters<T extends ObjectLiteral = ObjectLiteral>(query: SelectQueryBuilder<T>, data: unknown, options?: QueryFiltersApplyOptions<T>): QueryFiltersApplyOutput;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { FiltersParseOptions, FiltersParseOutput } from 'rapiq';
|
|
2
|
+
import type { ObjectLiteral } from 'typeorm';
|
|
3
|
+
export type QueryFiltersApplyOptions<T extends ObjectLiteral = ObjectLiteral> = FiltersParseOptions<T> & {
|
|
4
|
+
bindingKey?: (key: string) => string;
|
|
5
|
+
defaultAlias?: string;
|
|
6
|
+
};
|
|
7
|
+
export type QueryFiltersApplyOutput = FiltersParseOutput;
|
|
8
|
+
export type QueryFiltersOutputElement = {
|
|
9
|
+
statement: string;
|
|
10
|
+
binding: Record<string, any>;
|
|
11
|
+
};
|
|
12
|
+
export type QueryFiltersOutput = QueryFiltersOutputElement[];
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ObjectLiteral } from 'rapiq';
|
|
2
|
+
import type { SelectQueryBuilder } from 'typeorm';
|
|
3
|
+
import type { QueryPaginationApplyOptions, QueryPaginationApplyOutput } from './type';
|
|
4
|
+
/**
|
|
5
|
+
* Apply parsed page/pagination parameter data on the db query.
|
|
6
|
+
*
|
|
7
|
+
* @param query
|
|
8
|
+
* @param data
|
|
9
|
+
*/
|
|
10
|
+
export declare function applyQueryPaginationParseOutput<T extends ObjectLiteral = ObjectLiteral>(query: SelectQueryBuilder<T>, data: QueryPaginationApplyOutput): import("rapiq").PaginationParseOutput;
|
|
11
|
+
/**
|
|
12
|
+
* Apply raw page/pagination parameter data on the db query.
|
|
13
|
+
*
|
|
14
|
+
* @param query
|
|
15
|
+
* @param data
|
|
16
|
+
* @param options
|
|
17
|
+
*/
|
|
18
|
+
export declare function applyQueryPagination<T extends ObjectLiteral = ObjectLiteral>(query: SelectQueryBuilder<T>, data: unknown, options?: QueryPaginationApplyOptions): QueryPaginationApplyOutput;
|
|
19
|
+
/**
|
|
20
|
+
* Apply raw page/pagination parameter data on the db query.
|
|
21
|
+
*
|
|
22
|
+
* @param query
|
|
23
|
+
* @param data
|
|
24
|
+
* @param options
|
|
25
|
+
*/
|
|
26
|
+
export declare function applyPagination<T extends ObjectLiteral = ObjectLiteral>(query: SelectQueryBuilder<T>, data: unknown, options?: QueryPaginationApplyOptions): QueryPaginationApplyOutput;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { RelationsParseOutput } from 'rapiq';
|
|
2
|
+
import type { ObjectLiteral, SelectQueryBuilder } from 'typeorm';
|
|
3
|
+
import type { QueryRelationsApplyOptions, QueryRelationsApplyOutput } from './type';
|
|
4
|
+
/**
|
|
5
|
+
* Apply parsed include/relation parameter data on the db query.
|
|
6
|
+
*
|
|
7
|
+
* @param query
|
|
8
|
+
* @param data
|
|
9
|
+
* @param options
|
|
10
|
+
*/
|
|
11
|
+
export declare function applyQueryRelationsParseOutput<T extends ObjectLiteral = ObjectLiteral>(query: SelectQueryBuilder<T>, data: RelationsParseOutput, options?: QueryRelationsApplyOptions<T>): QueryRelationsApplyOutput;
|
|
12
|
+
/**
|
|
13
|
+
* Apply raw include/relations parameter data on the db query.
|
|
14
|
+
*
|
|
15
|
+
* @param query
|
|
16
|
+
* @param data
|
|
17
|
+
* @param options
|
|
18
|
+
*/
|
|
19
|
+
export declare function applyQueryRelations<T extends ObjectLiteral = ObjectLiteral>(query: SelectQueryBuilder<T>, data: unknown, options?: QueryRelationsApplyOptions<T>): QueryRelationsApplyOutput;
|
|
20
|
+
/**
|
|
21
|
+
* Apply raw include/relations parameter data on the db query.
|
|
22
|
+
*
|
|
23
|
+
* @param query
|
|
24
|
+
* @param data
|
|
25
|
+
* @param options
|
|
26
|
+
*/
|
|
27
|
+
export declare function applyRelations<T extends ObjectLiteral = ObjectLiteral>(query: SelectQueryBuilder<T>, data: unknown, options?: QueryRelationsApplyOptions<T>): QueryRelationsApplyOutput;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { RelationsParseOptions, RelationsParseOutput } from 'rapiq';
|
|
2
|
+
import type { ObjectLiteral, SelectQueryBuilder } from 'typeorm';
|
|
3
|
+
export type QueryRelationsOnJoinFn<T extends ObjectLiteral = ObjectLiteral> = (property: string, alias: string, query: SelectQueryBuilder<T>) => void;
|
|
4
|
+
export type QueryRelationsApplyOptions<T extends ObjectLiteral = ObjectLiteral> = RelationsParseOptions<T> & {
|
|
5
|
+
defaultAlias?: string;
|
|
6
|
+
onJoin?: QueryRelationsOnJoinFn<T>;
|
|
7
|
+
};
|
|
8
|
+
export type QueryRelationsApplyOutput = RelationsParseOutput;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { SortParseOutput } from 'rapiq';
|
|
2
|
+
import type { ObjectLiteral, SelectQueryBuilder } from 'typeorm';
|
|
3
|
+
import type { QuerySortApplyOptions, QuerySortApplyOutput } from './type';
|
|
4
|
+
/**
|
|
5
|
+
* Apply parsed sort parameter data on the db query.
|
|
6
|
+
*
|
|
7
|
+
* @param query
|
|
8
|
+
* @param data
|
|
9
|
+
*/
|
|
10
|
+
export declare function applyQuerySortParseOutput<T extends ObjectLiteral = ObjectLiteral>(query: SelectQueryBuilder<T>, data: SortParseOutput): QuerySortApplyOutput;
|
|
11
|
+
/**
|
|
12
|
+
* Apply raw sort parameter data on the db query.
|
|
13
|
+
*
|
|
14
|
+
* @param query
|
|
15
|
+
* @param data
|
|
16
|
+
* @param options
|
|
17
|
+
*/
|
|
18
|
+
export declare function applyQuerySort<T extends ObjectLiteral = ObjectLiteral>(query: SelectQueryBuilder<T>, data: unknown, options?: QuerySortApplyOptions<T>): SortParseOutput;
|
|
19
|
+
/**
|
|
20
|
+
* Apply raw sort parameter data on the db query.
|
|
21
|
+
*
|
|
22
|
+
* @param query
|
|
23
|
+
* @param data
|
|
24
|
+
* @param options
|
|
25
|
+
*/
|
|
26
|
+
export declare function applySort<T extends ObjectLiteral = ObjectLiteral>(query: SelectQueryBuilder<T>, data: unknown, options?: QuerySortApplyOptions<T>): SortParseOutput;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { SortParseOptions, SortParseOutput } from 'rapiq';
|
|
2
|
+
import type { ObjectLiteral } from 'typeorm';
|
|
3
|
+
export type QuerySortApplyOptions<T extends ObjectLiteral = ObjectLiteral> = SortParseOptions<T> & {
|
|
4
|
+
defaultAlias?: string;
|
|
5
|
+
};
|
|
6
|
+
export type QuerySortApplyOutput = SortParseOutput;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ParseOutput } from 'rapiq';
|
|
2
|
+
import type { ObjectLiteral } from 'typeorm';
|
|
3
|
+
import type { QueryFieldsApplyOptions, QueryFiltersApplyOptions, QueryPaginationApplyOptions, QueryRelationsApplyOptions, QuerySortApplyOptions } from './parameter';
|
|
4
|
+
export type QueryApplyOptions<T extends ObjectLiteral = ObjectLiteral> = {
|
|
5
|
+
defaultPath?: string;
|
|
6
|
+
throwOnFailure?: boolean;
|
|
7
|
+
defaultAlias?: string;
|
|
8
|
+
fields?: boolean | QueryFieldsApplyOptions<T>;
|
|
9
|
+
filters?: boolean | QueryFiltersApplyOptions<T>;
|
|
10
|
+
pagination?: boolean | QueryPaginationApplyOptions;
|
|
11
|
+
relations?: boolean | QueryRelationsApplyOptions<T>;
|
|
12
|
+
sort?: boolean | QuerySortApplyOptions<T>;
|
|
13
|
+
};
|
|
14
|
+
export type QueryApplyOutput = ParseOutput & {
|
|
15
|
+
defaultAlias?: string;
|
|
16
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function buildKeyWithPrefix(name: string, prefix?: string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isQueryOptionDefined(input: Record<string, any> | boolean, option: string | string[]): boolean;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { Seeder, SeederConstructor } from './type';
|
|
2
|
+
export declare class SeederEntity {
|
|
3
|
+
/**
|
|
4
|
+
* ID of the seeder.
|
|
5
|
+
*
|
|
6
|
+
* Indicates order of the executed seeders.
|
|
7
|
+
*/
|
|
8
|
+
id?: number;
|
|
9
|
+
/**
|
|
10
|
+
* Timestamp of the seeder.
|
|
11
|
+
*/
|
|
12
|
+
timestamp: number;
|
|
13
|
+
/**
|
|
14
|
+
* Name of the seeder (class name).
|
|
15
|
+
*/
|
|
16
|
+
name: string;
|
|
17
|
+
/**
|
|
18
|
+
* Instance of seeder constructor.
|
|
19
|
+
*/
|
|
20
|
+
instance?: Seeder;
|
|
21
|
+
/**
|
|
22
|
+
* File name of the seeder.
|
|
23
|
+
*/
|
|
24
|
+
fileName?: string;
|
|
25
|
+
/**
|
|
26
|
+
* File path of the seeder.
|
|
27
|
+
*/
|
|
28
|
+
filePath?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Result of the executed seeder.
|
|
31
|
+
*/
|
|
32
|
+
result?: unknown;
|
|
33
|
+
constructor(ctx: {
|
|
34
|
+
id?: number;
|
|
35
|
+
timestamp: number;
|
|
36
|
+
name: string;
|
|
37
|
+
constructor?: SeederConstructor;
|
|
38
|
+
fileName?: string;
|
|
39
|
+
filePath?: string;
|
|
40
|
+
});
|
|
41
|
+
get trackExecution(): boolean | undefined;
|
|
42
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { DataSource, DataSourceOptions, QueryRunner } from 'typeorm';
|
|
2
|
+
import { SeederEntity } from './entity';
|
|
3
|
+
import type { SeederExecutorOptions, SeederOptions, SeederPrepareElement } from './type';
|
|
4
|
+
export declare class SeederExecutor {
|
|
5
|
+
protected dataSource: DataSource;
|
|
6
|
+
protected options: SeederExecutorOptions;
|
|
7
|
+
private readonly tableName;
|
|
8
|
+
constructor(dataSource: DataSource, options?: SeederExecutorOptions);
|
|
9
|
+
execute(input?: SeederOptions): Promise<SeederEntity[]>;
|
|
10
|
+
protected loadExisting(queryRunner: QueryRunner): Promise<SeederEntity[]>;
|
|
11
|
+
/**
|
|
12
|
+
* Gets all migrations that setup for this connection.
|
|
13
|
+
*/
|
|
14
|
+
protected buildEntities(seeds?: SeederPrepareElement[]): Promise<SeederEntity[]>;
|
|
15
|
+
protected checkForDuplicates(entities: SeederEntity[]): void;
|
|
16
|
+
protected createTableIfNotExist(queryRunner: QueryRunner): Promise<void>;
|
|
17
|
+
protected track(queryRunner: QueryRunner, seederEntity: SeederEntity): Promise<void>;
|
|
18
|
+
protected get dataSourceOptions(): DataSourceOptions & SeederOptions;
|
|
19
|
+
protected get database(): string | undefined;
|
|
20
|
+
protected get schema(): string | undefined;
|
|
21
|
+
protected get table(): string;
|
|
22
|
+
protected buildOptions(input?: SeederOptions): Promise<SeederOptions>;
|
|
23
|
+
protected classNameToTimestamp(className: string): number | undefined;
|
|
24
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { EntitySchema, ObjectType } from 'typeorm';
|
|
2
|
+
import type { FactoryCallback, SeederFactoryItem } from './type';
|
|
3
|
+
import { SeederFactory } from './module';
|
|
4
|
+
export declare class SeederFactoryManager {
|
|
5
|
+
readonly items: Record<string, SeederFactoryItem>;
|
|
6
|
+
set<O extends Record<string, any>, Meta = unknown>(entity: ObjectType<O> | EntitySchema<O>, factoryFn: FactoryCallback<O, Meta>): SeederFactoryItem;
|
|
7
|
+
get<O extends Record<string, any>, Meta = unknown>(entity: ObjectType<O> | EntitySchema<O>): SeederFactory<O, Meta>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Faker } from '@faker-js/faker';
|
|
2
|
+
import type { SaveOptions } from 'typeorm';
|
|
3
|
+
import type { SeederFactoryContext } from './type';
|
|
4
|
+
export declare class SeederFactory<O extends Record<string, any>, Meta = unknown> {
|
|
5
|
+
readonly context: SeederFactoryContext<O, Meta>;
|
|
6
|
+
meta: Meta | undefined;
|
|
7
|
+
protected faker: Faker | undefined;
|
|
8
|
+
protected locale: string[] | undefined;
|
|
9
|
+
constructor(context: SeederFactoryContext<O, Meta>);
|
|
10
|
+
setMeta(value: Meta): this;
|
|
11
|
+
setLocale(value: string | string[]): void;
|
|
12
|
+
make(params?: Partial<O>, save?: boolean): Promise<O>;
|
|
13
|
+
save(params?: Partial<O>, options?: SaveOptions): Promise<O>;
|
|
14
|
+
saveMany(amount: number, params?: Partial<O>, options?: SaveOptions): Promise<O[]>;
|
|
15
|
+
private resolve;
|
|
16
|
+
protected useFaker(): Promise<Faker>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Faker } from '@faker-js/faker';
|
|
2
|
+
import type { EntitySchema, ObjectType } from 'typeorm';
|
|
3
|
+
export type FactoryCallback<O, Meta = unknown> = (faker: Faker, meta: Meta) => O | Promise<O>;
|
|
4
|
+
export type SeederFactoryItem = {
|
|
5
|
+
factoryFn: FactoryCallback<any, any>;
|
|
6
|
+
entity: ObjectType<any> | EntitySchema<any>;
|
|
7
|
+
};
|
|
8
|
+
export type SeederFactoryContext<O, Meta = unknown> = {
|
|
9
|
+
name: string;
|
|
10
|
+
entity: ObjectType<O> | EntitySchema<O>;
|
|
11
|
+
factoryFn: FactoryCallback<O, Meta | undefined>;
|
|
12
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { EntitySchema, ObjectType } from 'typeorm';
|
|
2
|
+
import { SeederFactoryManager } from './manager';
|
|
3
|
+
import type { FactoryCallback, SeederFactoryItem } from './type';
|
|
4
|
+
export declare function useSeederFactoryManager(): SeederFactoryManager;
|
|
5
|
+
export declare function setSeederFactory<O extends Record<string, any>, Meta = unknown>(entity: ObjectType<O> | EntitySchema<O>, factoryFn: FactoryCallback<O, Meta>): SeederFactoryItem;
|
|
6
|
+
export declare function useSeederFactory<O extends Record<string, any>>(entity: ObjectType<O> | EntitySchema<O>): import("./module").SeederFactory<O, unknown>;
|
|
7
|
+
export declare function prepareSeederFactories(items: SeederFactoryItem[] | string[], root?: string): Promise<void>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { DataSource } from 'typeorm';
|
|
2
|
+
import type { SeederEntity } from './entity';
|
|
3
|
+
import type { SeederConstructor, SeederOptions } from './type';
|
|
4
|
+
export declare function runSeeder(dataSource: DataSource, seeder: SeederConstructor | string, options?: SeederOptions): Promise<SeederEntity | undefined>;
|
|
5
|
+
export declare function runSeeders(dataSource: DataSource, options?: SeederOptions): Promise<SeederEntity[]>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { DataSource } from 'typeorm';
|
|
2
|
+
import type { TSConfig } from '../utils/tsconfig';
|
|
3
|
+
import type { SeederFactoryItem, SeederFactoryManager } from './factory';
|
|
4
|
+
export interface Seeder {
|
|
5
|
+
/**
|
|
6
|
+
* Track seeder execution.
|
|
7
|
+
*
|
|
8
|
+
* Default: false
|
|
9
|
+
*/
|
|
10
|
+
track?: boolean;
|
|
11
|
+
run(dataSource: DataSource, factoryManager: SeederFactoryManager): Promise<any>;
|
|
12
|
+
}
|
|
13
|
+
export type SeederConstructor = new () => Seeder;
|
|
14
|
+
export type SeederOptions = {
|
|
15
|
+
seeds?: SeederConstructor[] | string[];
|
|
16
|
+
seedName?: string;
|
|
17
|
+
seedTableName?: string;
|
|
18
|
+
seedTracking?: boolean;
|
|
19
|
+
factories?: SeederFactoryItem[] | string[];
|
|
20
|
+
factoriesLoad?: boolean;
|
|
21
|
+
};
|
|
22
|
+
export type SeederExecutorOptions = {
|
|
23
|
+
/**
|
|
24
|
+
* Root directory of the project.
|
|
25
|
+
*/
|
|
26
|
+
root?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Directory path to the tsconfig.json file
|
|
29
|
+
*
|
|
30
|
+
* Default: process.cwd() + path.sep + tsconfig.json
|
|
31
|
+
*/
|
|
32
|
+
tsconfig?: string | TSConfig;
|
|
33
|
+
/**
|
|
34
|
+
* This option indicates if file paths should be preserved,
|
|
35
|
+
* and treated as if the just-in-time compilation environment is detected.
|
|
36
|
+
*/
|
|
37
|
+
preserveFilePaths?: boolean;
|
|
38
|
+
};
|
|
39
|
+
export type SeederPrepareElement = {
|
|
40
|
+
constructor: SeederConstructor;
|
|
41
|
+
timestamp?: number;
|
|
42
|
+
fileName?: string;
|
|
43
|
+
filePath?: string;
|
|
44
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { LocatorInfo } from 'locter';
|
|
2
|
+
export declare function resolveFilePatterns(filesPattern: string[], root?: string): Promise<string[]>;
|
|
3
|
+
export declare function resolveFilePaths(filePaths: string[], root?: string): string[];
|
|
4
|
+
/**
|
|
5
|
+
* Exported only for testing purposes
|
|
6
|
+
*/
|
|
7
|
+
export declare function buildFilePathname(files: LocatorInfo[]): string[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function buildSeederFileTemplate(name: string, timestamp: number): string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { TSConfig } from './tsconfig';
|
|
2
|
+
export declare function transformFilePath(input: string, dist?: string, src?: string): string;
|
|
3
|
+
export declare function adjustFilePath<T extends unknown | unknown[]>(input: T, tsconfig?: string | TSConfig): Promise<T>;
|
|
4
|
+
export declare function adjustFilePaths<T extends Record<string, any>>(input: T, keys?: (keyof T)[], tsconfig?: string | TSConfig): Promise<T>;
|
|
5
|
+
export declare function resolveFilePath(filePath: string, root?: string): string;
|
|
6
|
+
export declare function parseFilePath(filePath: string, root?: string): {
|
|
7
|
+
directory: string;
|
|
8
|
+
name: string;
|
|
9
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isDirectory(input: string): Promise<boolean>;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare function hasOwnProperty<X extends Record<string, any>, Y extends PropertyKey>(obj: X, prop: Y): obj is X & Record<Y, unknown>;
|
|
2
|
+
export declare function hasStringProperty<X extends Record<string, any>, Y extends PropertyKey>(obj: X, prop: Y): obj is X & Record<Y, string>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './code-transformation';
|
|
2
|
+
export * from './entity';
|
|
3
|
+
export * from './file-path';
|
|
4
|
+
export * from './file-system';
|
|
5
|
+
export * from './has-property';
|
|
6
|
+
export * from './object';
|
|
7
|
+
export * from './promise';
|
|
8
|
+
export * from './separator';
|
|
9
|
+
export * from './slash';
|
|
10
|
+
export * from './tsconfig';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isPromise(p: unknown): p is Promise<unknown>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { CompilerOptions, TypeAcquisition } from 'typescript';
|
|
2
|
+
export type StripEnums<T extends Record<string, any>> = {
|
|
3
|
+
[K in keyof T]: T[K] extends boolean ? T[K] : T[K] extends string ? T[K] : T[K] extends object ? T[K] : T[K] extends Array<any> ? T[K] : T[K] extends undefined ? undefined : any;
|
|
4
|
+
};
|
|
5
|
+
export interface TSConfig {
|
|
6
|
+
compilerOptions?: StripEnums<CompilerOptions>;
|
|
7
|
+
exclude?: string[];
|
|
8
|
+
compileOnSave?: boolean;
|
|
9
|
+
extends?: string;
|
|
10
|
+
files?: string[];
|
|
11
|
+
include?: string[];
|
|
12
|
+
typeAcquisition?: TypeAcquisition;
|
|
13
|
+
}
|