@onivoro/server-typeorm-mysql 24.17.0 → 24.19.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.
Files changed (61) hide show
  1. package/package.json +2 -2
  2. package/src/index.d.ts +20 -0
  3. package/src/index.js +23 -0
  4. package/src/index.js.map +1 -0
  5. package/src/lib/classes/type-orm-paging-repository.class.d.ts +15 -0
  6. package/src/lib/classes/type-orm-paging-repository.class.js +17 -0
  7. package/src/lib/classes/type-orm-paging-repository.class.js.map +1 -0
  8. package/src/lib/classes/type-orm-repository.class.d.ts +44 -0
  9. package/src/lib/classes/type-orm-repository.class.js +104 -0
  10. package/src/lib/classes/type-orm-repository.class.js.map +1 -0
  11. package/src/lib/constants/many-to-one-relation-options.constant.d.ts +3 -0
  12. package/src/lib/constants/many-to-one-relation-options.constant.js +5 -0
  13. package/src/lib/constants/many-to-one-relation-options.constant.js.map +1 -0
  14. package/src/lib/decorators/nullable-table-column.decorator.d.ts +3 -0
  15. package/src/lib/decorators/nullable-table-column.decorator.js +13 -0
  16. package/src/lib/decorators/nullable-table-column.decorator.js.map +1 -0
  17. package/src/lib/decorators/primary-table-column.decorator.d.ts +3 -0
  18. package/src/lib/decorators/primary-table-column.decorator.js +13 -0
  19. package/src/lib/decorators/primary-table-column.decorator.js.map +1 -0
  20. package/src/lib/decorators/table-column.decorator.d.ts +3 -0
  21. package/src/lib/decorators/table-column.decorator.js +13 -0
  22. package/src/lib/decorators/table-column.decorator.js.map +1 -0
  23. package/src/lib/decorators/table.decorator.d.ts +4 -0
  24. package/src/lib/decorators/table.decorator.js +12 -0
  25. package/src/lib/decorators/table.decorator.js.map +1 -0
  26. package/src/lib/functions/data-source-config-factory.function.d.ts +4 -0
  27. package/src/lib/functions/data-source-config-factory.function.js +25 -0
  28. package/src/lib/functions/data-source-config-factory.function.js.map +1 -0
  29. package/src/lib/functions/data-source-factory.function.d.ts +4 -0
  30. package/src/lib/functions/data-source-factory.function.js +8 -0
  31. package/src/lib/functions/data-source-factory.function.js.map +1 -0
  32. package/src/lib/functions/generate-date-query.function.d.ts +3 -0
  33. package/src/lib/functions/generate-date-query.function.js +17 -0
  34. package/src/lib/functions/generate-date-query.function.js.map +1 -0
  35. package/src/lib/functions/get-api-type-from-column.function.d.ts +3 -0
  36. package/src/lib/functions/get-api-type-from-column.function.js +15 -0
  37. package/src/lib/functions/get-api-type-from-column.function.js.map +1 -0
  38. package/src/lib/functions/get-paging-key.function.d.ts +2 -0
  39. package/src/lib/functions/get-paging-key.function.js +7 -0
  40. package/src/lib/functions/get-paging-key.function.js.map +1 -0
  41. package/src/lib/functions/get-skip.function.d.ts +2 -0
  42. package/src/lib/functions/get-skip.function.js +7 -0
  43. package/src/lib/functions/get-skip.function.js.map +1 -0
  44. package/src/lib/functions/remove-falsey-keys.function.d.ts +2 -0
  45. package/src/lib/functions/remove-falsey-keys.function.js +12 -0
  46. package/src/lib/functions/remove-falsey-keys.function.js.map +1 -0
  47. package/src/lib/server-typeorm-mysql.module.d.ts +7 -0
  48. package/src/lib/server-typeorm-mysql.module.js +59 -0
  49. package/src/lib/server-typeorm-mysql.module.js.map +1 -0
  50. package/src/lib/types/data-source-options.interface.d.ts +11 -0
  51. package/src/lib/types/data-source-options.interface.js +3 -0
  52. package/src/lib/types/data-source-options.interface.js.map +1 -0
  53. package/src/lib/types/entity-provider.interface.d.ts +10 -0
  54. package/src/lib/types/entity-provider.interface.js +3 -0
  55. package/src/lib/types/entity-provider.interface.js.map +1 -0
  56. package/src/lib/types/page-params.interface.d.ts +7 -0
  57. package/src/lib/types/page-params.interface.js +3 -0
  58. package/src/lib/types/page-params.interface.js.map +1 -0
  59. package/src/lib/types/paged-data.interface.d.ts +7 -0
  60. package/src/lib/types/paged-data.interface.js +3 -0
  61. package/src/lib/types/paged-data.interface.js.map +1 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onivoro/server-typeorm-mysql",
3
- "version": "24.17.0",
3
+ "version": "24.19.0",
4
4
  "type": "commonjs",
5
5
  "main": "./src/index.js",
6
6
  "types": "./src/index.d.ts",
@@ -25,4 +25,4 @@
25
25
  "**/*.js.map",
26
26
  "README.md"
27
27
  ]
28
- }
28
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1,20 @@
1
+ export * from './lib/classes/type-orm-paging-repository.class';
2
+ export * from './lib/classes/type-orm-repository.class';
3
+ export * from './lib/constants/many-to-one-relation-options.constant';
4
+ export * from './lib/decorators/nullable-table-column.decorator';
5
+ export * from './lib/decorators/primary-table-column.decorator';
6
+ export * from './lib/decorators/table-column.decorator';
7
+ export * from './lib/decorators/table.decorator';
8
+ export * from './lib/functions/data-source-config-factory.function';
9
+ export * from './lib/functions/data-source-factory.function';
10
+ export * from './lib/functions/generate-date-query.function';
11
+ export * from './lib/functions/get-api-type-from-column.function';
12
+ export * from './lib/functions/get-paging-key.function';
13
+ export * from './lib/functions/get-skip.function';
14
+ export * from './lib/functions/remove-falsey-keys.function';
15
+ export * from './lib/types/data-source-options.interface';
16
+ export * from './lib/types/entity-provider.interface';
17
+ export * from './lib/types/page-params.interface';
18
+ export * from './lib/types/paged-data.interface';
19
+ export * from './lib/server-typeorm-mysql.module';
20
+ //# sourceMappingURL=index.d.ts.map
package/src/index.js ADDED
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./lib/classes/type-orm-paging-repository.class"), exports);
5
+ tslib_1.__exportStar(require("./lib/classes/type-orm-repository.class"), exports);
6
+ tslib_1.__exportStar(require("./lib/constants/many-to-one-relation-options.constant"), exports);
7
+ tslib_1.__exportStar(require("./lib/decorators/nullable-table-column.decorator"), exports);
8
+ tslib_1.__exportStar(require("./lib/decorators/primary-table-column.decorator"), exports);
9
+ tslib_1.__exportStar(require("./lib/decorators/table-column.decorator"), exports);
10
+ tslib_1.__exportStar(require("./lib/decorators/table.decorator"), exports);
11
+ tslib_1.__exportStar(require("./lib/functions/data-source-config-factory.function"), exports);
12
+ tslib_1.__exportStar(require("./lib/functions/data-source-factory.function"), exports);
13
+ tslib_1.__exportStar(require("./lib/functions/generate-date-query.function"), exports);
14
+ tslib_1.__exportStar(require("./lib/functions/get-api-type-from-column.function"), exports);
15
+ tslib_1.__exportStar(require("./lib/functions/get-paging-key.function"), exports);
16
+ tslib_1.__exportStar(require("./lib/functions/get-skip.function"), exports);
17
+ tslib_1.__exportStar(require("./lib/functions/remove-falsey-keys.function"), exports);
18
+ tslib_1.__exportStar(require("./lib/types/data-source-options.interface"), exports);
19
+ tslib_1.__exportStar(require("./lib/types/entity-provider.interface"), exports);
20
+ tslib_1.__exportStar(require("./lib/types/page-params.interface"), exports);
21
+ tslib_1.__exportStar(require("./lib/types/paged-data.interface"), exports);
22
+ tslib_1.__exportStar(require("./lib/server-typeorm-mysql.module"), exports);
23
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../libs/server/typeorm-mysql/src/index.ts"],"names":[],"mappings":";;;AAAA,yFAA+D;AAC/D,kFAAwD;AAExD,gGAAsE;AAEtE,2FAAiE;AACjE,0FAAgE;AAChE,kFAAwD;AACxD,2EAAiD;AAEjD,8FAAoE;AACpE,uFAA6D;AAC7D,uFAA6D;AAC7D,4FAAkE;AAClE,kFAAwD;AACxD,4EAAkD;AAClD,sFAA4D;AAE5D,oFAA0D;AAC1D,gFAAsD;AACtD,4EAAkD;AAClD,2EAAiD;AAEjD,4EAAkD"}
@@ -0,0 +1,15 @@
1
+ import { EntityManager } from 'typeorm';
2
+ import { TypeOrmRepository } from './type-orm-repository.class';
3
+ import { IPagedData } from '../types/paged-data.interface';
4
+ import { getSkip } from '../functions/get-skip.function';
5
+ import { removeFalseyKeys } from '../functions/remove-falsey-keys.function';
6
+ import { getPagingKey } from '../functions/get-paging-key.function';
7
+ import { IPageParams } from '../types/page-params.interface';
8
+ export declare abstract class TypeOrmPagingRepository<TEntity, TEntityParams> extends TypeOrmRepository<TEntity> {
9
+ protected getPagingKey: typeof getPagingKey;
10
+ protected getSkip: typeof getSkip;
11
+ protected removeFalseyKeys: typeof removeFalseyKeys;
12
+ constructor(entityType: any, entityManager: EntityManager);
13
+ abstract getPage(pageParams: IPageParams, params: TEntityParams): Promise<IPagedData<TEntity>>;
14
+ }
15
+ //# sourceMappingURL=type-orm-paging-repository.class.d.ts.map
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TypeOrmPagingRepository = void 0;
4
+ const type_orm_repository_class_1 = require("./type-orm-repository.class");
5
+ const get_skip_function_1 = require("../functions/get-skip.function");
6
+ const remove_falsey_keys_function_1 = require("../functions/remove-falsey-keys.function");
7
+ const get_paging_key_function_1 = require("../functions/get-paging-key.function");
8
+ class TypeOrmPagingRepository extends type_orm_repository_class_1.TypeOrmRepository {
9
+ getPagingKey = get_paging_key_function_1.getPagingKey;
10
+ getSkip = get_skip_function_1.getSkip;
11
+ removeFalseyKeys = remove_falsey_keys_function_1.removeFalseyKeys;
12
+ constructor(entityType, entityManager) {
13
+ super(entityType, entityManager);
14
+ }
15
+ }
16
+ exports.TypeOrmPagingRepository = TypeOrmPagingRepository;
17
+ //# sourceMappingURL=type-orm-paging-repository.class.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-orm-paging-repository.class.js","sourceRoot":"","sources":["../../../../../../../libs/server/typeorm-mysql/src/lib/classes/type-orm-paging-repository.class.ts"],"names":[],"mappings":";;;AAIA,2EAAgE;AAEhE,sEAAyD;AACzD,0FAA4E;AAC5E,kFAAoE;AAGpE,MAAsB,uBAAgD,SAAQ,6CAA0B;IAC5F,YAAY,GAAG,sCAAY,CAAC;IAC5B,OAAO,GAAG,2BAAO,CAAC;IAClB,gBAAgB,GAAG,8CAAgB,CAAC;IAE9C,YAAY,UAAe,EAAE,aAA4B;QACvD,KAAK,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC;IACnC,CAAC;CAGF;AAVD,0DAUC"}
@@ -0,0 +1,44 @@
1
+ import { EntityManager, FindManyOptions, FindOneOptions, FindOptionsWhere, QueryRunner } from 'typeorm';
2
+ import { QueryDeepPartialEntity } from 'typeorm/query-builder/QueryPartialEntity';
3
+ import { IEntityProvider } from '../types/entity-provider.interface';
4
+ import { ReadStream } from 'fs';
5
+ export type TQueryStreamParams<TRecord = any> = {
6
+ query: string;
7
+ onData?: (stream: ReadStream, record: TRecord, count: number) => Promise<any | void>;
8
+ onError?: (stream: ReadStream, error: any) => Promise<any | void>;
9
+ onEnd?: (stream: ReadStream, count: number) => Promise<any | void>;
10
+ };
11
+ export declare class TypeOrmRepository<TEntity> implements IEntityProvider<TEntity, FindOneOptions<TEntity>, FindManyOptions<TEntity>, FindOptionsWhere<TEntity>, QueryDeepPartialEntity<TEntity>> {
12
+ private entityType;
13
+ entityManager: EntityManager;
14
+ constructor(entityType: any, entityManager: EntityManager);
15
+ forTransaction(entityManager: EntityManager): TypeOrmRepository<TEntity>;
16
+ getMany(options: FindManyOptions<TEntity>): Promise<TEntity[]>;
17
+ getManyAndCount(options: FindManyOptions<TEntity>): Promise<[TEntity[], number]>;
18
+ getOne(options: FindOneOptions<TEntity>): Promise<TEntity>;
19
+ postOne(body: Partial<TEntity>): Promise<TEntity>;
20
+ postMany(body: Partial<TEntity | undefined>[]): Promise<TEntity[]>;
21
+ delete(options: FindOptionsWhere<TEntity>): Promise<void>;
22
+ softDelete(options: FindOptionsWhere<TEntity>): Promise<void>;
23
+ put(options: FindOptionsWhere<TEntity>, body: QueryDeepPartialEntity<TEntity>): Promise<void>;
24
+ patch(options: FindOptionsWhere<TEntity>, body: QueryDeepPartialEntity<TEntity>): Promise<void>;
25
+ get repo(): import("typeorm").Repository<import("typeorm").ObjectLiteral>;
26
+ protected insertAndReturn(entityToInsert: TEntity): Promise<TEntity>;
27
+ protected insertAndReturnMany(entitiesToInsert: TEntity[]): Promise<TEntity[]>;
28
+ static queryStream<TRecord = any>(queryRunner: QueryRunner, _: TQueryStreamParams): Promise<{
29
+ stream: ReadStream;
30
+ error: null;
31
+ } | {
32
+ stream: null;
33
+ error: any;
34
+ }>;
35
+ queryStream<TRecord = any>(_: TQueryStreamParams): Promise<{
36
+ stream: ReadStream;
37
+ error: null;
38
+ } | {
39
+ stream: null;
40
+ error: any;
41
+ }>;
42
+ buildWhereILike(filters?: Record<string, any>): FindOptionsWhere<TEntity>;
43
+ }
44
+ //# sourceMappingURL=type-orm-repository.class.d.ts.map
@@ -0,0 +1,104 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TypeOrmRepository = void 0;
4
+ const typeorm_1 = require("typeorm");
5
+ const common_1 = require("@nestjs/common");
6
+ class TypeOrmRepository {
7
+ entityType;
8
+ entityManager;
9
+ constructor(entityType, entityManager) {
10
+ this.entityType = entityType;
11
+ this.entityManager = entityManager;
12
+ }
13
+ forTransaction(entityManager) {
14
+ return { ...this, entityManager };
15
+ }
16
+ async getMany(options) {
17
+ return await this.repo.find(options);
18
+ }
19
+ async getManyAndCount(options) {
20
+ return await this.repo.findAndCount(options);
21
+ }
22
+ async getOne(options) {
23
+ const results = await this.getMany(options);
24
+ if (results?.length > 1) {
25
+ throw new Error(`${TypeOrmRepository.prototype.getOne.name} expects only 1 result but found ${results.length} results of entity type "${this.entityType}" for criteria ${JSON.stringify(options, null, 2)}`);
26
+ }
27
+ return results[0];
28
+ }
29
+ async postOne(body) {
30
+ return await this.insertAndReturn(body);
31
+ }
32
+ async postMany(body) {
33
+ return await this.insertAndReturnMany(body);
34
+ }
35
+ async delete(options) {
36
+ return await this.repo.delete(options);
37
+ }
38
+ async softDelete(options) {
39
+ return await this.repo.softDelete(options);
40
+ }
41
+ async put(options, body) {
42
+ await this.repo.save(options, body);
43
+ }
44
+ async patch(options, body) {
45
+ await this.repo.update(options, body);
46
+ }
47
+ get repo() {
48
+ return this.entityManager.getRepository(this.entityType);
49
+ }
50
+ async insertAndReturn(entityToInsert) {
51
+ return (await this.insertAndReturnMany([entityToInsert]))[0];
52
+ }
53
+ async insertAndReturnMany(entitiesToInsert) {
54
+ const insertionResult = await this.repo
55
+ .createQueryBuilder()
56
+ .insert()
57
+ .values(entitiesToInsert)
58
+ .returning('*')
59
+ .execute();
60
+ const insertedEntity = insertionResult.generatedMaps;
61
+ return insertedEntity;
62
+ }
63
+ static async queryStream(queryRunner, _) {
64
+ if (!_.query) {
65
+ throw new common_1.BadRequestException(`StreamingQueryRunner requires one of: {query, table}`);
66
+ }
67
+ let processedCount = 0;
68
+ const query = _.query;
69
+ try {
70
+ const stream = await queryRunner.stream(query);
71
+ stream.on('data', (record) => {
72
+ _.onData?.(stream, record, processedCount++);
73
+ });
74
+ stream.on('error', (error) => {
75
+ console.error({ detail: `Error processing stream for query "${_.query}"`, error });
76
+ _.onError?.(stream, error);
77
+ });
78
+ stream.on('end', () => {
79
+ console.log({ detail: `Finished processing stream for query "${_.query}"`, processedCount });
80
+ _.onEnd?.(stream, processedCount);
81
+ });
82
+ return { stream, error: null };
83
+ }
84
+ catch (error) {
85
+ console.error({ detail: `Error processing stream for query "${_.query}"`, error });
86
+ return { stream: null, error };
87
+ }
88
+ }
89
+ async queryStream(_) {
90
+ const queryRunner = this.entityManager.connection.createQueryRunner();
91
+ return await TypeOrmRepository.queryStream(queryRunner, _);
92
+ }
93
+ buildWhereILike(filters) {
94
+ if (!filters) {
95
+ return {};
96
+ }
97
+ return Object.entries(filters || {})
98
+ .reduce((_, [column, filter]) => (filter
99
+ ? { ..._, [column]: (0, typeorm_1.ILike)(`%${filter}%`) }
100
+ : _), {});
101
+ }
102
+ }
103
+ exports.TypeOrmRepository = TypeOrmRepository;
104
+ //# sourceMappingURL=type-orm-repository.class.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-orm-repository.class.js","sourceRoot":"","sources":["../../../../../../../libs/server/typeorm-mysql/src/lib/classes/type-orm-repository.class.ts"],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,CAAC,aAAa,CAAC,UAAU,CAAC,iBAAiB,EAAE,CAAC;QACtE,OAAO,MAAM,iBAAiB,CAAC,WAAW,CAAU,WAAW,EAAE,CAAC,CAAC,CAAC;IACtE,CAAC;IAED,eAAe,CAAC,OAA6B;QAE3C,IAAG,CAAC,OAAO,EAAE,CAAC;YACZ,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,OAAO,MAAM,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC;aACjC,MAAM,CACL,CAAC,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC,CACvB,MAAM;YACJ,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,EAAE,IAAA,eAAK,EAAC,IAAI,MAAM,GAAG,CAAC,EAAE;YAC1C,CAAC,CAAC,CAAC,CACN,EACD,EAAE,CACI,CAAC;IACb,CAAC;CACF;AAlID,8CAkIC"}
@@ -0,0 +1,3 @@
1
+ import { RelationOptions } from "typeorm";
2
+ export declare const manyToOneRelationOptions: RelationOptions;
3
+ //# sourceMappingURL=many-to-one-relation-options.constant.d.ts.map
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.manyToOneRelationOptions = void 0;
4
+ exports.manyToOneRelationOptions = { cascade: true, onDelete: 'CASCADE', orphanedRowAction: 'delete', onUpdate: 'CASCADE' };
5
+ //# sourceMappingURL=many-to-one-relation-options.constant.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"many-to-one-relation-options.constant.js","sourceRoot":"","sources":["../../../../../../../libs/server/typeorm-mysql/src/lib/constants/many-to-one-relation-options.constant.ts"],"names":[],"mappings":";;;AAEa,QAAA,wBAAwB,GAAoB,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,iBAAiB,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { ColumnOptions } from "typeorm";
2
+ export declare const NullableTableColumn: (options?: Pick<ColumnOptions, "type">) => <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
3
+ //# sourceMappingURL=nullable-table-column.decorator.d.ts.map
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NullableTableColumn = void 0;
4
+ const common_1 = require("@nestjs/common");
5
+ const typeorm_1 = require("typeorm");
6
+ const swagger_1 = require("@nestjs/swagger");
7
+ const get_api_type_from_column_function_1 = require("../functions/get-api-type-from-column.function");
8
+ const NullableTableColumn = (options) => {
9
+ const apiType = (0, get_api_type_from_column_function_1.getApiTypeFromColumn)(options?.type);
10
+ return (0, common_1.applyDecorators)((0, typeorm_1.Column)({ type: options?.type, nullable: true }), (0, swagger_1.ApiPropertyOptional)({ type: apiType }));
11
+ };
12
+ exports.NullableTableColumn = NullableTableColumn;
13
+ //# sourceMappingURL=nullable-table-column.decorator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nullable-table-column.decorator.js","sourceRoot":"","sources":["../../../../../../../libs/server/typeorm-mysql/src/lib/decorators/nullable-table-column.decorator.ts"],"names":[],"mappings":";;;AAAA,2CAAiD;AACjD,qCAAgD;AAChD,6CAAsD;AACtD,sGAAsF;AAE/E,MAAM,mBAAmB,GAAG,CAAC,OAAqC,EAAE,EAAE;IACzE,MAAM,OAAO,GAAG,IAAA,wDAAoB,EAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACpD,OAAO,IAAA,wBAAe,EAAC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,EAAE,IAAA,6BAAmB,EAAC,EAAC,IAAI,EAAE,OAAO,EAAC,CAAC,CAAC,CAAC;AAClH,CAAC,CAAC;AAHW,QAAA,mBAAmB,uBAG9B"}
@@ -0,0 +1,3 @@
1
+ import { ColumnOptions } from "typeorm";
2
+ export declare const PrimaryTableColumn: (options?: Pick<ColumnOptions, "type">) => <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
3
+ //# sourceMappingURL=primary-table-column.decorator.d.ts.map
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PrimaryTableColumn = void 0;
4
+ const common_1 = require("@nestjs/common");
5
+ const typeorm_1 = require("typeorm");
6
+ const swagger_1 = require("@nestjs/swagger");
7
+ const get_api_type_from_column_function_1 = require("../functions/get-api-type-from-column.function");
8
+ const PrimaryTableColumn = (options) => {
9
+ const apiType = (0, get_api_type_from_column_function_1.getApiTypeFromColumn)(options?.type);
10
+ return (0, common_1.applyDecorators)((0, typeorm_1.Column)({ type: options?.type, nullable: false }), (0, swagger_1.ApiProperty)({ type: apiType }));
11
+ };
12
+ exports.PrimaryTableColumn = PrimaryTableColumn;
13
+ //# sourceMappingURL=primary-table-column.decorator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"primary-table-column.decorator.js","sourceRoot":"","sources":["../../../../../../../libs/server/typeorm-mysql/src/lib/decorators/primary-table-column.decorator.ts"],"names":[],"mappings":";;;AAAA,2CAAiD;AACjD,qCAAgD;AAChD,6CAA8C;AAC9C,sGAAsF;AAE/E,MAAM,kBAAkB,GAAG,CAAC,OAAqC,EAAE,EAAE;IACxE,MAAM,OAAO,GAAG,IAAA,wDAAoB,EAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACpD,OAAO,IAAA,wBAAe,EAAC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,EAAE,IAAA,qBAAW,EAAC,EAAC,IAAI,EAAE,OAAO,EAAC,CAAC,CAAC,CAAC;AAC3G,CAAC,CAAC;AAHW,QAAA,kBAAkB,sBAG7B"}
@@ -0,0 +1,3 @@
1
+ import { ColumnOptions } from "typeorm";
2
+ export declare const TableColumn: (options?: Pick<ColumnOptions, "type">) => <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
3
+ //# sourceMappingURL=table-column.decorator.d.ts.map
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TableColumn = void 0;
4
+ const common_1 = require("@nestjs/common");
5
+ const typeorm_1 = require("typeorm");
6
+ const swagger_1 = require("@nestjs/swagger");
7
+ const get_api_type_from_column_function_1 = require("../functions/get-api-type-from-column.function");
8
+ const TableColumn = (options) => {
9
+ const apiType = (0, get_api_type_from_column_function_1.getApiTypeFromColumn)(options?.type);
10
+ return (0, common_1.applyDecorators)((0, typeorm_1.Column)({ type: options?.type, nullable: false }), (0, swagger_1.ApiProperty)({ type: apiType }));
11
+ };
12
+ exports.TableColumn = TableColumn;
13
+ //# sourceMappingURL=table-column.decorator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"table-column.decorator.js","sourceRoot":"","sources":["../../../../../../../libs/server/typeorm-mysql/src/lib/decorators/table-column.decorator.ts"],"names":[],"mappings":";;;AAAA,2CAAiD;AACjD,qCAAgD;AAChD,6CAA8C;AAC9C,sGAAsF;AAE/E,MAAM,WAAW,GAAG,CAAC,OAAqC,EAAE,EAAE;IACjE,MAAM,OAAO,GAAG,IAAA,wDAAoB,EAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACpD,OAAO,IAAA,wBAAe,EAAC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,EAAE,IAAA,qBAAW,EAAC,EAAC,IAAI,EAAE,OAAO,EAAC,CAAC,CAAC,CAAC;AAC3G,CAAC,CAAC;AAHW,QAAA,WAAW,eAGtB"}
@@ -0,0 +1,4 @@
1
+ export declare const Table: (EntityClass: {
2
+ name: string;
3
+ }) => <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
4
+ //# sourceMappingURL=table.decorator.d.ts.map
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Table = void 0;
4
+ const common_1 = require("@nestjs/common");
5
+ const typeorm_1 = require("typeorm");
6
+ const isomorphic_common_1 = require("@onivoro/isomorphic-common");
7
+ const Table = (EntityClass) => {
8
+ const tableName = (0, isomorphic_common_1.snakeCase)(EntityClass.name);
9
+ return (0, common_1.applyDecorators)((0, typeorm_1.Entity)(tableName));
10
+ };
11
+ exports.Table = Table;
12
+ //# sourceMappingURL=table.decorator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"table.decorator.js","sourceRoot":"","sources":["../../../../../../../libs/server/typeorm-mysql/src/lib/decorators/table.decorator.ts"],"names":[],"mappings":";;;AAAA,2CAAiD;AACjD,qCAAiC;AACjC,kEAAuD;AAEhD,MAAM,KAAK,GAAG,CAAC,WAA6B,EAAE,EAAE;IACnD,MAAM,SAAS,GAAG,IAAA,6BAAS,EAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAC9C,OAAO,IAAA,wBAAe,EAAC,IAAA,gBAAM,EAAC,SAAS,CAAC,CAAC,CAAC;AAC9C,CAAC,CAAC;AAHW,QAAA,KAAK,SAGhB"}
@@ -0,0 +1,4 @@
1
+ import { MysqlConnectionOptions } from 'typeorm/driver/mysql/MysqlConnectionOptions';
2
+ import { IDataSourceOptions } from '../types/data-source-options.interface';
3
+ export declare function dataSourceConfigFactory(name: string, options: IDataSourceOptions, entities: any[]): MysqlConnectionOptions;
4
+ //# sourceMappingURL=data-source-config-factory.function.d.ts.map
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.dataSourceConfigFactory = dataSourceConfigFactory;
4
+ const typeorm_naming_strategies_1 = require("typeorm-naming-strategies");
5
+ function dataSourceConfigFactory(name, options, entities) {
6
+ const { ca, database, host, password, port, username, synchronize = false, logging = false } = options;
7
+ const config = {
8
+ name,
9
+ type: 'mysql',
10
+ host,
11
+ port: port,
12
+ username,
13
+ password,
14
+ ssl: ca ? { ca } : undefined,
15
+ database,
16
+ synchronize,
17
+ logging,
18
+ entities,
19
+ subscribers: [],
20
+ migrations: [],
21
+ namingStrategy: new typeorm_naming_strategies_1.SnakeNamingStrategy(),
22
+ };
23
+ return config;
24
+ }
25
+ //# sourceMappingURL=data-source-config-factory.function.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data-source-config-factory.function.js","sourceRoot":"","sources":["../../../../../../../libs/server/typeorm-mysql/src/lib/functions/data-source-config-factory.function.ts"],"names":[],"mappings":";;AAIA,0DA4BC;AAhCD,yEAAgE;AAIhE,SAAgB,uBAAuB,CACrC,IAAY,EACZ,OAA2B,EAC3B,QAAe;IAGf,MAAM,EACJ,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,GAAG,KAAK,EAAE,OAAO,GAAG,KAAK,EACnF,GAAG,OAAO,CAAC;IAEZ,MAAM,MAAM,GAA2B;QACrC,IAAI;QACJ,IAAI,EAAE,OAAO;QACb,IAAI;QACJ,IAAI,EAAE,IAAW;QACjB,QAAQ;QACR,QAAQ;QACR,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS;QAC5B,QAAQ;QACR,WAAW;QACX,OAAO;QACP,QAAQ;QACR,WAAW,EAAE,EAAE;QACf,UAAU,EAAE,EAAE;QACd,cAAc,EAAE,IAAI,+CAAmB,EAAE;KAC1C,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { DataSource } from 'typeorm';
2
+ import { IDataSourceOptions } from '../types/data-source-options.interface';
3
+ export declare const dataSourceFactory: (name: string, options: IDataSourceOptions, entities: any[]) => DataSource;
4
+ //# sourceMappingURL=data-source-factory.function.d.ts.map
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.dataSourceFactory = void 0;
4
+ const typeorm_1 = require("typeorm");
5
+ const data_source_config_factory_function_1 = require("./data-source-config-factory.function");
6
+ const dataSourceFactory = (name, options, entities) => new typeorm_1.DataSource((0, data_source_config_factory_function_1.dataSourceConfigFactory)(name, options, entities));
7
+ exports.dataSourceFactory = dataSourceFactory;
8
+ //# sourceMappingURL=data-source-factory.function.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data-source-factory.function.js","sourceRoot":"","sources":["../../../../../../../libs/server/typeorm-mysql/src/lib/functions/data-source-factory.function.ts"],"names":[],"mappings":";;;AAAA,qCAAqC;AACrC,+FAAgF;AAGzE,MAAM,iBAAiB,GAAG,CAC/B,IAAY,EACZ,OAA2B,EAC3B,QAAe,EACf,EAAE,CACF,IAAI,oBAAU,CAAC,IAAA,6DAAuB,EAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC;AALtD,QAAA,iBAAiB,qBAKqC"}
@@ -0,0 +1,3 @@
1
+ import { FindOperator } from "typeorm";
2
+ export declare function generateDateQuery(minDueDate: string, maxDueDate: string): FindOperator<Date>;
3
+ //# sourceMappingURL=generate-date-query.function.d.ts.map
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateDateQuery = generateDateQuery;
4
+ const typeorm_1 = require("typeorm");
5
+ function generateDateQuery(minDueDate, maxDueDate) {
6
+ if (minDueDate && maxDueDate) {
7
+ return (0, typeorm_1.Between)(minDueDate, maxDueDate);
8
+ }
9
+ if (maxDueDate) {
10
+ return (0, typeorm_1.LessThanOrEqual)(new Date(maxDueDate));
11
+ }
12
+ if (minDueDate) {
13
+ return (0, typeorm_1.MoreThanOrEqual)(new Date(minDueDate));
14
+ }
15
+ return undefined;
16
+ }
17
+ //# sourceMappingURL=generate-date-query.function.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate-date-query.function.js","sourceRoot":"","sources":["../../../../../../../libs/server/typeorm-mysql/src/lib/functions/generate-date-query.function.ts"],"names":[],"mappings":";;AAEA,8CAiBC;AAnBD,qCAAkF;AAElF,SAAgB,iBAAiB,CAC7B,UAAkB,EAClB,UAAkB;IAElB,IAAI,UAAU,IAAI,UAAU,EAAE,CAAC;QAC3B,OAAO,IAAA,iBAAO,EAAC,UAAiB,EAAE,UAAiB,CAAC,CAAC;IACzD,CAAC;IAED,IAAI,UAAU,EAAE,CAAC;QACb,OAAO,IAAA,yBAAe,EAAC,IAAI,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;IACjD,CAAC;IAED,IAAI,UAAU,EAAE,CAAC;QACb,OAAO,IAAA,yBAAe,EAAC,IAAI,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;IACjD,CAAC;IAED,OAAO,SAAgB,CAAC;AAC5B,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { ColumnOptions } from "typeorm";
2
+ export declare function getApiTypeFromColumn(columnType: ColumnOptions['type']): "boolean" | "string";
3
+ //# sourceMappingURL=get-api-type-from-column.function.d.ts.map
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getApiTypeFromColumn = getApiTypeFromColumn;
4
+ function getApiTypeFromColumn(columnType) {
5
+ if (!columnType) {
6
+ return 'string';
7
+ }
8
+ switch (columnType) {
9
+ case 'boolean':
10
+ return columnType;
11
+ default:
12
+ return 'string';
13
+ }
14
+ }
15
+ //# sourceMappingURL=get-api-type-from-column.function.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-api-type-from-column.function.js","sourceRoot":"","sources":["../../../../../../../libs/server/typeorm-mysql/src/lib/functions/get-api-type-from-column.function.ts"],"names":[],"mappings":";;AAEA,oDAWC;AAXD,SAAgB,oBAAoB,CAAC,UAAiC;IAClE,IAAG,CAAC,UAAU,EAAE,CAAC;QACb,OAAO,QAAQ,CAAC;IACpB,CAAC;IAED,QAAQ,UAAU,EAAE,CAAC;QACjB,KAAK,SAAS;YACV,OAAO,UAAU,CAAC;QACtB;YACI,OAAO,QAAQ,CAAC;IACxB,CAAC;AACL,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function getPagingKey(pageSize: number, skip: number, total: number): number | undefined;
2
+ //# sourceMappingURL=get-paging-key.function.d.ts.map
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getPagingKey = getPagingKey;
4
+ function getPagingKey(pageSize, skip, total) {
5
+ return pageSize * skip < total ? skip + 1 : undefined;
6
+ }
7
+ //# sourceMappingURL=get-paging-key.function.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-paging-key.function.js","sourceRoot":"","sources":["../../../../../../../libs/server/typeorm-mysql/src/lib/functions/get-paging-key.function.ts"],"names":[],"mappings":";;AAAA,oCAEC;AAFD,SAAgB,YAAY,CAAC,QAAgB,EAAE,IAAY,EAAE,KAAa;IACxE,OAAO,QAAQ,GAAG,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AACxD,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function getSkip(pagingKey: number | string, pageSize: number): number;
2
+ //# sourceMappingURL=get-skip.function.d.ts.map
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getSkip = getSkip;
4
+ function getSkip(pagingKey, pageSize) {
5
+ return pagingKey ? Number(pagingKey) * pageSize : 0;
6
+ }
7
+ //# sourceMappingURL=get-skip.function.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-skip.function.js","sourceRoot":"","sources":["../../../../../../../libs/server/typeorm-mysql/src/lib/functions/get-skip.function.ts"],"names":[],"mappings":";;AAAA,0BAEC;AAFD,SAAgB,OAAO,CAAC,SAA0B,EAAE,QAAgB;IAClE,OAAO,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;AACtD,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function removeFalseyKeys<T>(obj: T): T;
2
+ //# sourceMappingURL=remove-falsey-keys.function.d.ts.map
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.removeFalseyKeys = removeFalseyKeys;
4
+ function removeFalseyKeys(obj) {
5
+ return Object.entries(obj)
6
+ .filter(([k, v]) => typeof v !== 'undefined')
7
+ .reduce((acc, [k, v]) => {
8
+ acc[k] = v;
9
+ return acc;
10
+ }, {});
11
+ }
12
+ //# sourceMappingURL=remove-falsey-keys.function.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remove-falsey-keys.function.js","sourceRoot":"","sources":["../../../../../../../libs/server/typeorm-mysql/src/lib/functions/remove-falsey-keys.function.ts"],"names":[],"mappings":";;AAAA,4CAOC;AAPD,SAAgB,gBAAgB,CAAI,GAAM;IACxC,OAAO,MAAM,CAAC,OAAO,CAAC,GAAU,CAAC;SAC9B,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,WAAW,CAAC;SAC5C,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE;QACtB,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;QACX,OAAO,GAAG,CAAC;IACb,CAAC,EAAE,EAAS,CAAM,CAAC;AACvB,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { DynamicModule, OnApplicationShutdown } from '@nestjs/common';
2
+ import { IDataSourceOptions } from './types/data-source-options.interface';
3
+ export declare class ServerTypeormMysqlModule implements OnApplicationShutdown {
4
+ onApplicationShutdown(): Promise<void>;
5
+ static configure(injectables: any[], entities: any[], options: IDataSourceOptions, name?: string): DynamicModule;
6
+ }
7
+ //# sourceMappingURL=server-typeorm-mysql.module.d.ts.map
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ var ServerTypeormMysqlModule_1;
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.ServerTypeormMysqlModule = void 0;
5
+ const tslib_1 = require("tslib");
6
+ const common_1 = require("@nestjs/common");
7
+ const typeorm_1 = require("typeorm");
8
+ const data_source_factory_function_1 = require("./functions/data-source-factory.function");
9
+ const dataSourceMap = new Map();
10
+ let ServerTypeormMysqlModule = ServerTypeormMysqlModule_1 = class ServerTypeormMysqlModule {
11
+ async onApplicationShutdown() {
12
+ for (let dataSourceKey in dataSourceMap.keys()) {
13
+ try {
14
+ const dataSource = dataSourceMap.get(dataSourceKey);
15
+ if (dataSource && dataSource.isInitialized) {
16
+ console.log(`destroying connection ${dataSourceKey}`);
17
+ await dataSource.destroy();
18
+ }
19
+ }
20
+ catch (e) {
21
+ console.error(e?.message || e);
22
+ }
23
+ }
24
+ }
25
+ static configure(injectables, entities, options, name = 'default') {
26
+ const providers = [
27
+ {
28
+ provide: typeorm_1.DataSource,
29
+ useFactory: async () => {
30
+ const cachedDataSource = dataSourceMap.get(name);
31
+ if (!cachedDataSource) {
32
+ const dataSource = (0, data_source_factory_function_1.dataSourceFactory)(name, options, entities);
33
+ await dataSource.initialize();
34
+ dataSourceMap.set(name, dataSource);
35
+ }
36
+ return dataSourceMap.get(name);
37
+ },
38
+ },
39
+ {
40
+ provide: typeorm_1.EntityManager,
41
+ useFactory: (dataSource) => {
42
+ return dataSource?.manager;
43
+ },
44
+ inject: [typeorm_1.DataSource]
45
+ },
46
+ ...injectables,
47
+ ];
48
+ return {
49
+ module: ServerTypeormMysqlModule_1,
50
+ exports: providers,
51
+ providers,
52
+ };
53
+ }
54
+ };
55
+ exports.ServerTypeormMysqlModule = ServerTypeormMysqlModule;
56
+ exports.ServerTypeormMysqlModule = ServerTypeormMysqlModule = ServerTypeormMysqlModule_1 = tslib_1.__decorate([
57
+ (0, common_1.Module)({})
58
+ ], ServerTypeormMysqlModule);
59
+ //# sourceMappingURL=server-typeorm-mysql.module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server-typeorm-mysql.module.js","sourceRoot":"","sources":["../../../../../../libs/server/typeorm-mysql/src/lib/server-typeorm-mysql.module.ts"],"names":[],"mappings":";;;;;AAAA,2CAA8E;AAC9E,qCAAoD;AACpD,2FAA6E;AAG7E,MAAM,aAAa,GAAG,IAAI,GAAG,EAAsB,CAAC;AAG7C,IAAM,wBAAwB,gCAA9B,MAAM,wBAAwB;IAEnC,KAAK,CAAC,qBAAqB;QACzB,KAAK,IAAI,aAAa,IAAI,aAAa,CAAC,IAAI,EAAE,EAAE,CAAC;YAC/C,IAAI,CAAC;gBACH,MAAM,UAAU,GAAG,aAAa,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;gBACpD,IAAI,UAAU,IAAI,UAAU,CAAC,aAAa,EAAE,CAAC;oBAC3C,OAAO,CAAC,GAAG,CAAC,yBAAyB,aAAa,EAAE,CAAC,CAAC;oBACtD,MAAM,UAAU,CAAC,OAAO,EAAE,CAAC;gBAC7B,CAAC;YACH,CAAC;YAAC,OAAO,CAAM,EAAE,CAAC;gBAChB,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,OAAO,IAAI,CAAC,CAAC,CAAC;YACjC,CAAC;QACH,CAAC;IACH,CAAC;IAED,MAAM,CAAC,SAAS,CACd,WAAkB,EAClB,QAAe,EACf,OAA2B,EAC3B,IAAI,GAAG,SAAS;QAEhB,MAAM,SAAS,GAAG;YAChB;gBACE,OAAO,EAAE,oBAAU;gBACnB,UAAU,EAAE,KAAK,IAAI,EAAE;oBACrB,MAAM,gBAAgB,GAAG,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;oBACjD,IAAI,CAAC,gBAAgB,EAAE,CAAC;wBACtB,MAAM,UAAU,GAAe,IAAA,gDAAiB,EAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;wBAC1E,MAAM,UAAU,CAAC,UAAU,EAAE,CAAC;wBAC9B,aAAa,CAAC,GAAG,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;oBACtC,CAAC;oBACD,OAAO,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;gBACjC,CAAC;aACF;YACD;gBACE,OAAO,EAAE,uBAAa;gBACtB,UAAU,EAAE,CAAC,UAAsB,EAAE,EAAE;oBACrC,OAAO,UAAU,EAAE,OAAc,CAAC;gBACpC,CAAC;gBACD,MAAM,EAAE,CAAC,oBAAU,CAAC;aACrB;YACD,GAAG,WAAW;SACf,CAAC;QACF,OAAO;YACL,MAAM,EAAE,0BAAwB;YAChC,OAAO,EAAE,SAAS;YAClB,SAAS;SACV,CAAC;IACJ,CAAC;CACF,CAAA;AAlDY,4DAAwB;mCAAxB,wBAAwB;IADpC,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,wBAAwB,CAkDpC"}
@@ -0,0 +1,11 @@
1
+ export interface IDataSourceOptions {
2
+ database: string;
3
+ host: string;
4
+ port: string;
5
+ username: string;
6
+ password: string;
7
+ synchronize?: boolean;
8
+ logging?: boolean;
9
+ ca?: string;
10
+ }
11
+ //# sourceMappingURL=data-source-options.interface.d.ts.map
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=data-source-options.interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data-source-options.interface.js","sourceRoot":"","sources":["../../../../../../../libs/server/typeorm-mysql/src/lib/types/data-source-options.interface.ts"],"names":[],"mappings":""}
@@ -0,0 +1,10 @@
1
+ export interface IEntityProvider<TEntity, TFindOneOptions, TFindManyOptions, TFindOptionsWhere, TQueryDeepPartialEntity> {
2
+ getOne: (options: TFindOneOptions) => Promise<TEntity>;
3
+ getMany: (options: TFindManyOptions) => Promise<TEntity[]>;
4
+ postOne: (body: Partial<TEntity>) => Promise<TEntity>;
5
+ postMany: (body: Partial<TEntity[]>) => Promise<TEntity[]>;
6
+ delete: (options: TFindOptionsWhere) => Promise<void>;
7
+ put: (options: TFindOptionsWhere, body: TQueryDeepPartialEntity) => Promise<void>;
8
+ patch: (options: TFindOptionsWhere, body: TQueryDeepPartialEntity) => Promise<void>;
9
+ }
10
+ //# sourceMappingURL=entity-provider.interface.d.ts.map
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=entity-provider.interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entity-provider.interface.js","sourceRoot":"","sources":["../../../../../../../libs/server/typeorm-mysql/src/lib/types/entity-provider.interface.ts"],"names":[],"mappings":""}
@@ -0,0 +1,7 @@
1
+ export interface IPageParams {
2
+ pagingKey: number;
3
+ pageSize: number;
4
+ sortKey?: string;
5
+ sortDirection?: string;
6
+ }
7
+ //# sourceMappingURL=page-params.interface.d.ts.map
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=page-params.interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"page-params.interface.js","sourceRoot":"","sources":["../../../../../../../libs/server/typeorm-mysql/src/lib/types/page-params.interface.ts"],"names":[],"mappings":""}
@@ -0,0 +1,7 @@
1
+ export interface IPagedData<TEntity> {
2
+ data: TEntity[];
3
+ total: number;
4
+ pagingKey: number;
5
+ pageSize: number;
6
+ }
7
+ //# sourceMappingURL=paged-data.interface.d.ts.map
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=paged-data.interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paged-data.interface.js","sourceRoot":"","sources":["../../../../../../../libs/server/typeorm-mysql/src/lib/types/paged-data.interface.ts"],"names":[],"mappings":""}