@nathapp/nestjs-data 2.1.5 → 3.0.1

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 (81) hide show
  1. package/.turbo/turbo-build.log +4 -0
  2. package/CHANGELOG.md +11 -0
  3. package/dist/constant/index.d.ts +1 -0
  4. package/dist/constant/index.js +18 -0
  5. package/dist/constant/index.js.map +1 -0
  6. package/dist/constant/tokens.d.ts +1 -0
  7. package/dist/constant/tokens.js +5 -0
  8. package/dist/constant/tokens.js.map +1 -0
  9. package/dist/index.d.ts +2 -6
  10. package/dist/index.js +2 -6
  11. package/dist/index.js.map +1 -1
  12. package/dist/interface/index.d.ts +1 -0
  13. package/dist/interface/index.js +18 -0
  14. package/dist/interface/index.js.map +1 -0
  15. package/dist/interface/transaction-manager.interface.d.ts +5 -0
  16. package/dist/interface/transaction-manager.interface.js +3 -0
  17. package/dist/interface/transaction-manager.interface.js.map +1 -0
  18. package/lib/constant/index.ts +1 -0
  19. package/lib/constant/tokens.ts +1 -0
  20. package/lib/index.ts +2 -0
  21. package/lib/interface/index.ts +1 -0
  22. package/lib/interface/transaction-manager.interface.ts +40 -0
  23. package/package.json +6 -23
  24. package/test/jest-test.json +24 -0
  25. package/test/tokens.spec.ts +11 -0
  26. package/tsconfig.json +9 -0
  27. package/LICENSE +0 -21
  28. package/README.md +0 -4
  29. package/dist/decorator/date-column.decorator.d.ts +0 -7
  30. package/dist/decorator/date-column.decorator.js +0 -51
  31. package/dist/decorator/date-column.decorator.js.map +0 -1
  32. package/dist/decorator/index.d.ts +0 -4
  33. package/dist/decorator/index.js +0 -15
  34. package/dist/decorator/index.js.map +0 -1
  35. package/dist/decorator/readonly-column.decorator.d.ts +0 -1
  36. package/dist/decorator/readonly-column.decorator.js +0 -14
  37. package/dist/decorator/readonly-column.decorator.js.map +0 -1
  38. package/dist/decorator/typeorm-ex.decorator.d.ts +0 -2
  39. package/dist/decorator/typeorm-ex.decorator.js +0 -10
  40. package/dist/decorator/typeorm-ex.decorator.js.map +0 -1
  41. package/dist/entities/base-entity.d.ts +0 -3
  42. package/dist/entities/base-entity.js +0 -8
  43. package/dist/entities/base-entity.js.map +0 -1
  44. package/dist/entities/index.d.ts +0 -2
  45. package/dist/entities/index.js +0 -6
  46. package/dist/entities/index.js.map +0 -1
  47. package/dist/pagination/index.d.ts +0 -2
  48. package/dist/pagination/index.js +0 -9
  49. package/dist/pagination/index.js.map +0 -1
  50. package/dist/pagination/page.d.ts +0 -35
  51. package/dist/pagination/page.js +0 -123
  52. package/dist/pagination/page.js.map +0 -1
  53. package/dist/repository/base.repository.d.ts +0 -18
  54. package/dist/repository/base.repository.js +0 -140
  55. package/dist/repository/base.repository.js.map +0 -1
  56. package/dist/repository/index.d.ts +0 -2
  57. package/dist/repository/index.js +0 -7
  58. package/dist/repository/index.js.map +0 -1
  59. package/dist/testing/index.d.ts +0 -2
  60. package/dist/testing/index.js +0 -11
  61. package/dist/testing/index.js.map +0 -1
  62. package/dist/testing/testing-utils.d.ts +0 -56
  63. package/dist/testing/testing-utils.js +0 -44
  64. package/dist/testing/testing-utils.js.map +0 -1
  65. package/dist/typeorm/base-typeorm-options-factory.d.ts +0 -18
  66. package/dist/typeorm/base-typeorm-options-factory.js +0 -42
  67. package/dist/typeorm/base-typeorm-options-factory.js.map +0 -1
  68. package/dist/typeorm/constants.d.ts +0 -16
  69. package/dist/typeorm/constants.js +0 -20
  70. package/dist/typeorm/constants.js.map +0 -1
  71. package/dist/typeorm/index.d.ts +0 -5
  72. package/dist/typeorm/index.js +0 -16
  73. package/dist/typeorm/index.js.map +0 -1
  74. package/dist/typeorm/typeorm-ex.module.d.ts +0 -13
  75. package/dist/typeorm/typeorm-ex.module.js +0 -75
  76. package/dist/typeorm/typeorm-ex.module.js.map +0 -1
  77. package/dist/typeorm/typeorm-utils.d.ts +0 -26
  78. package/dist/typeorm/typeorm-utils.js +0 -16
  79. package/dist/typeorm/typeorm-utils.js.map +0 -1
  80. package/index.d.ts +0 -1
  81. package/index.js +0 -6
@@ -1,123 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.Page = exports.PageOption = exports.TransformOptions = void 0;
13
- exports.Paginate = Paginate;
14
- const class_transformer_1 = require("class-transformer");
15
- const typeorm_1 = require("typeorm");
16
- class TransformOptions {
17
- }
18
- exports.TransformOptions = TransformOptions;
19
- class PageOption {
20
- constructor(current, size) {
21
- this.current = 1;
22
- this.size = 10;
23
- this.current = current;
24
- this.size = size;
25
- }
26
- static from(current, size) {
27
- return new PageOption(current, size);
28
- }
29
- }
30
- exports.PageOption = PageOption;
31
- class Page {
32
- constructor(page, total, records, transformOptions, extractDefault) {
33
- this.hasNext = false;
34
- this.hasPrev = false;
35
- this.size = Number(page.size);
36
- this.current = Number(page.current);
37
- this.total = Number(total);
38
- this.transformOptions = transformOptions || new TransformOptions();
39
- this.records = records;
40
- this.hasPrev = this.current != 1;
41
- this.hasNext = (this.current * this.size) < this.total;
42
- this.extra = extractDefault || undefined;
43
- }
44
- toInstance(transformOptions) {
45
- var _a, _b;
46
- if (transformOptions === null || transformOptions === void 0 ? void 0 : transformOptions.cls) {
47
- this.records = (0, class_transformer_1.plainToInstance)(transformOptions === null || transformOptions === void 0 ? void 0 : transformOptions.cls, this.records);
48
- }
49
- if ((_a = this.transformOptions) === null || _a === void 0 ? void 0 : _a.cls) {
50
- this.records = (0, class_transformer_1.plainToInstance)((_b = this.transformOptions) === null || _b === void 0 ? void 0 : _b.cls, this.records);
51
- }
52
- delete this.transformOptions;
53
- return this;
54
- }
55
- toPlain() {
56
- this.records = (0, class_transformer_1.instanceToPlain)(this.records);
57
- delete this.transformOptions;
58
- return this;
59
- }
60
- mapTo(mapFunc, cls) {
61
- const results = this.records.map(mapFunc);
62
- return cls ? (0, class_transformer_1.plainToInstance)(cls, results) : results;
63
- }
64
- remap(mapFunc, cls, extra) {
65
- const records = this.records.map(mapFunc);
66
- return new Page({ current: this.current, size: this.size }, this.total, cls ? (0, class_transformer_1.plainToInstance)(cls, records) : records, extra || this.extra);
67
- }
68
- }
69
- exports.Page = Page;
70
- __decorate([
71
- (0, class_transformer_1.Exclude)(),
72
- __metadata("design:type", TransformOptions)
73
- ], Page.prototype, "transformOptions", void 0);
74
- async function Paginate(repositoryOrQueryBuilder, options, searchOptions, transformOptions) {
75
- if (repositoryOrQueryBuilder instanceof typeorm_1.MongoRepository) {
76
- return paginateMongoRepository(repositoryOrQueryBuilder, options, searchOptions, transformOptions);
77
- }
78
- else if (repositoryOrQueryBuilder instanceof typeorm_1.Repository) {
79
- return paginateRepository(repositoryOrQueryBuilder, options, searchOptions, transformOptions);
80
- }
81
- else {
82
- return paginateQueryBuilder(repositoryOrQueryBuilder, options, transformOptions);
83
- }
84
- }
85
- async function paginateRepository(repository, options, searchOptions, transformOptions) {
86
- const { take, skip } = resolvePageOption(options);
87
- const [result, total] = await repository.findAndCount({
88
- skip,
89
- take,
90
- ...searchOptions,
91
- });
92
- return new Page(options, total, result, transformOptions);
93
- }
94
- async function paginateQueryBuilder(queryBuilder, options, transformOptions) {
95
- const { take, skip } = resolvePageOption(options);
96
- const total = await queryBuilder.getCount();
97
- const result = await queryBuilder.skip(skip).take(take).getMany();
98
- return new Page(options, total, result, transformOptions);
99
- }
100
- async function paginateMongoRepository(repository, options, searchOptions, transformOptions) {
101
- const { take, skip } = resolvePageOption(options);
102
- const [result, total] = await repository.findAndCount({
103
- skip,
104
- take,
105
- ...searchOptions,
106
- });
107
- return new Page(options, total, result, transformOptions);
108
- }
109
- function resolvePageOption(pageOption) {
110
- let { current, size } = pageOption;
111
- current = Number(current) || 1;
112
- size = Number(size) || 10;
113
- const pageIndex = current - 1;
114
- const skip = size * (pageIndex < 0 ? 0 : pageIndex);
115
- const take = size;
116
- return {
117
- current,
118
- size,
119
- skip,
120
- take,
121
- };
122
- }
123
- //# sourceMappingURL=page.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"page.js","sourceRoot":"","sources":["../../lib/pagination/page.ts"],"names":[],"mappings":";;;;;;;;;;;;AAoIA,4BA8BC;AAlKD,yDAK2B;AAC3B,qCAMiB;AAIjB,MAAa,gBAAgB;CAE5B;AAFD,4CAEC;AAUD,MAAa,UAAU;IAQrB,YAAY,OAAgB,EAAE,IAAa;QAK3C,YAAO,GAAG,CAAC,CAAC;QAEZ,SAAI,GAAG,EAAE,CAAC;QANR,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,IAAI,GAAI,IAAI,CAAC;IACpB,CAAC;IAMD,MAAM,CAAC,IAAI,CAAC,OAAe,EAAE,IAAY;QACvC,OAAO,IAAI,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACvC,CAAC;CACF;AApBD,gCAoBC;AAGD,MAAa,IAAI;IAmBf,YACE,IAAiB,EACjB,KAAa,EACb,OAAY,EACZ,gBAAsC,EACtC,cAAkB;QAjBpB,YAAO,GAAY,KAAK,CAAC;QAEzB,YAAO,GAAY,KAAK,CAAC;QAiBvB,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC9B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACpC,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC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CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;IAC1B,MAAM,SAAS,GAAG,OAAO,GAAG,CAAC,CAAC;IAC9B,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IACpD,MAAM,IAAI,GAAG,IAAI,CAAC;IAClB,OAAO;QACL,OAAO;QACP,IAAI;QACJ,IAAI;QACJ,IAAI;KACL,CAAC;AACJ,CAAC"}
@@ -1,18 +0,0 @@
1
- import { DataSource } from 'typeorm';
2
- export interface PrepareResult {
3
- formattedSP: string;
4
- paramaters?: any[];
5
- }
6
- export declare abstract class BaseRepository {
7
- readonly dataSource: DataSource;
8
- constructor(dataSource: DataSource);
9
- }
10
- export declare abstract class BaseSpRepository extends BaseRepository {
11
- readonly executeCommand: string;
12
- constructor(dataSource: DataSource, executeCommand?: string);
13
- callQuery(spName: string, formatOrValue?: any, params?: any, rename?: (key: string, depth: number, object: any) => string, objectifyForSignleRecord?: boolean): Promise<any>;
14
- private resolveRecordsets;
15
- private prepare;
16
- private renameKey;
17
- private changeKey;
18
- }
@@ -1,140 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BaseSpRepository = exports.BaseRepository = void 0;
4
- const common_1 = require("@nathapp/common");
5
- class BaseRepository {
6
- constructor(dataSource) {
7
- this.dataSource = dataSource;
8
- }
9
- }
10
- exports.BaseRepository = BaseRepository;
11
- class BaseSpRepository extends BaseRepository {
12
- constructor(dataSource, executeCommand) {
13
- super(dataSource);
14
- this.executeCommand = executeCommand || 'call';
15
- }
16
- async callQuery(spName, formatOrValue, params, rename, objectifyForSignleRecord = false) {
17
- const { formattedSP, paramaters } = await this.prepare(spName, formatOrValue, params);
18
- const results = await this.dataSource.query(formattedSP, paramaters);
19
- return this.resolveRecordsets(results, rename, objectifyForSignleRecord);
20
- }
21
- resolveRecordsets(results, rename, objectifyForSignleRecord = false) {
22
- if (!Array.isArray(results)) {
23
- if (objectifyForSignleRecord) {
24
- return {};
25
- }
26
- return [];
27
- }
28
- const status = results.pop();
29
- if (1 < results.length) {
30
- const recordsets = [];
31
- for (let i = 0; results.length > i; i++) {
32
- const recordset = results[i];
33
- if (!rename) {
34
- recordsets.push(recordset);
35
- }
36
- else {
37
- const result = [];
38
- for (let i = 0; recordset.length > i; i++) {
39
- const record = recordset[i];
40
- result.push(this.renameKey(record, rename));
41
- }
42
- recordsets.push(result);
43
- }
44
- }
45
- return recordsets;
46
- }
47
- const recordset = results[0];
48
- if (objectifyForSignleRecord) {
49
- if (1 == recordset.length) {
50
- if (rename) {
51
- return this.renameKey(recordset[0], rename);
52
- }
53
- return recordset[0];
54
- }
55
- }
56
- if (rename) {
57
- const result = [];
58
- for (let i = 0; recordset.length > i; i++) {
59
- result.push(this.renameKey(recordset[i], rename));
60
- }
61
- return result;
62
- }
63
- return recordset;
64
- }
65
- async prepare(spName, formatOrValue, params) {
66
- let paramaters = [];
67
- if (!(0, common_1.isUndefinedOrNullOrEmpty)(formatOrValue) &&
68
- Array.isArray(formatOrValue)) {
69
- paramaters = formatOrValue;
70
- }
71
- else {
72
- if (!(0, common_1.isUndefinedOrNullOrEmpty)(params)) {
73
- if (!(0, common_1.isUndefinedOrNullOrEmpty)(formatOrValue)) {
74
- params = (0, common_1.checkFormat)(formatOrValue, params);
75
- for (const key of Object.keys(params)) {
76
- paramaters.push(params[key]);
77
- }
78
- }
79
- }
80
- }
81
- let qm;
82
- if (0 >= paramaters.length) {
83
- qm = '';
84
- }
85
- else {
86
- qm = '?';
87
- if (1 < paramaters.length) {
88
- qm += ',?'.repeat(paramaters.length - 1);
89
- }
90
- }
91
- return {
92
- formattedSP: `${this.executeCommand} ${spName}(${qm})`,
93
- paramaters,
94
- };
95
- }
96
- renameKey(object, rename, depth) {
97
- for (const key in object) {
98
- try {
99
- if (undefined == depth) {
100
- depth = 0;
101
- }
102
- if (object[key] && 'object' === typeof object[key]) {
103
- const type = object[key].constructor
104
- ? object[key].constructor.name
105
- : '';
106
- switch (type) {
107
- case 'Object':
108
- case 'Array':
109
- this.renameKey(object[key], rename, depth + 1);
110
- }
111
- }
112
- const newKey = rename(key, depth, object);
113
- this.changeKey(object, key, newKey);
114
- }
115
- catch (error) {
116
- error.checkKey = key;
117
- error.checkValue = object[key];
118
- throw error;
119
- }
120
- }
121
- return object;
122
- }
123
- changeKey(object, name, newName) {
124
- if (!object || name == newName) {
125
- return;
126
- }
127
- if ('object' === typeof object) {
128
- const item = Object.getOwnPropertyDescriptor(object, name);
129
- if (item) {
130
- Object.defineProperty(object, newName, item);
131
- }
132
- }
133
- else {
134
- object[newName] = object[name];
135
- }
136
- delete object[name];
137
- }
138
- }
139
- exports.BaseSpRepository = BaseSpRepository;
140
- //# sourceMappingURL=base.repository.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"base.repository.js","sourceRoot":"","sources":["../../lib/repository/base.repository.ts"],"names":[],"mappings":";;;AAAA,4CAAwE;AAQxE,MAAsB,cAAc;IAElC,YAAY,UAAsB;QAChC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;CACF;AALD,wCAKC;AAED,MAAsB,gBAAiB,SAAQ,cAAc;IAG3D,YAAY,UAAsB,EAAE,cAAuB;QACzD,KAAK,CAAC,UAAU,CAAC,CAAC;QAClB,IAAI,CAAC,cAAc,GAAG,cAAc,IAAI,MAAM,CAAC;IACjD,CAAC;IAED,KAAK,CAAC,SAAS,CACb,MAAc,EACd,aAAmB,EACnB,MAAY,EACZ,MAA4D,EAC5D,wBAAwB,GAAG,KAAK;QAEhC,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,GAAG,MAAM,IAAI,CAAC,OAAO,CACpD,MAAM,EACN,aAAa,EACb,MAAM,CACP,CAAC;QACF,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;QACrE,OA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,CAAC,SAAS,CAAC,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;YACtC,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,KAAK,CAAC,QAAQ,GAAG,GAAG,CAAC;gBACrB,KAAK,CAAC,UAAU,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;gBAC/B,MAAM,KAAK,CAAC;YACd,CAAC;QACH,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAEO,SAAS,CAAC,MAAW,EAAE,IAAY,EAAE,OAAe;QAC1D,IAAI,CAAC,MAAM,IAAI,IAAI,IAAI,OAAO,EAAE,CAAC;YAC/B,OAAO;QACT,CAAC;QACD,IAAI,QAAQ,KAAK,OAAO,MAAM,EAAE,CAAC;YAC/B,MAAM,IAAI,GAAG,MAAM,CAAC,wBAAwB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;YAC3D,IAAI,IAAI,EAAE,CAAC;gBACT,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;YAC/C,CAAC;QACH,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,OAAO,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;QACjC,CAAC;QACD,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC;IACtB,CAAC;CACF;AA9KD,4CA8KC"}
@@ -1,2 +0,0 @@
1
- import { BaseRepository, BaseSpRepository } from "./base.repository";
2
- export { BaseRepository, BaseSpRepository, };
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BaseSpRepository = exports.BaseRepository = void 0;
4
- const base_repository_1 = require("./base.repository");
5
- Object.defineProperty(exports, "BaseRepository", { enumerable: true, get: function () { return base_repository_1.BaseRepository; } });
6
- Object.defineProperty(exports, "BaseSpRepository", { enumerable: true, get: function () { return base_repository_1.BaseSpRepository; } });
7
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/repository/index.ts"],"names":[],"mappings":";;;AAAA,uDAAqE;AAGnE,+FAHO,gCAAc,OAGP;AACd,iGAJuB,kCAAgB,OAIvB"}
@@ -1,2 +0,0 @@
1
- import { sqlQueryResult, resolveQuerySingleResult, resolveQueryArrayResult, resolveEmptySingleResult, createInMemorySqliteDataSource, createInMemoryPgDataSource } from "./testing-utils";
2
- export { sqlQueryResult, resolveQuerySingleResult, resolveQueryArrayResult, resolveEmptySingleResult, createInMemorySqliteDataSource, createInMemoryPgDataSource, };
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createInMemoryPgDataSource = exports.createInMemorySqliteDataSource = exports.resolveEmptySingleResult = exports.resolveQueryArrayResult = exports.resolveQuerySingleResult = exports.sqlQueryResult = void 0;
4
- const testing_utils_1 = require("./testing-utils");
5
- Object.defineProperty(exports, "sqlQueryResult", { enumerable: true, get: function () { return testing_utils_1.sqlQueryResult; } });
6
- Object.defineProperty(exports, "resolveQuerySingleResult", { enumerable: true, get: function () { return testing_utils_1.resolveQuerySingleResult; } });
7
- Object.defineProperty(exports, "resolveQueryArrayResult", { enumerable: true, get: function () { return testing_utils_1.resolveQueryArrayResult; } });
8
- Object.defineProperty(exports, "resolveEmptySingleResult", { enumerable: true, get: function () { return testing_utils_1.resolveEmptySingleResult; } });
9
- Object.defineProperty(exports, "createInMemorySqliteDataSource", { enumerable: true, get: function () { return testing_utils_1.createInMemorySqliteDataSource; } });
10
- Object.defineProperty(exports, "createInMemoryPgDataSource", { enumerable: true, get: function () { return testing_utils_1.createInMemoryPgDataSource; } });
11
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/testing/index.ts"],"names":[],"mappings":";;;AAAA,mDAA0L;AAGxL,+FAHO,8BAAc,OAGP;AACd,yGAJuB,wCAAwB,OAIvB;AACxB,wGALiD,uCAAuB,OAKjD;AACvB,yGAN0E,wCAAwB,OAM1E;AACxB,+GAPoG,8CAA8B,OAOpG;AAC9B,2GARoI,0CAA0B,OAQpI"}
@@ -1,56 +0,0 @@
1
- import { DataSource, DataSourceOptions } from "typeorm";
2
- export declare const sqlQueryResult: {
3
- fieldCount: number;
4
- affectedRows: number;
5
- insertId: number;
6
- info: string;
7
- serverStatus: number;
8
- warningStatus: number;
9
- };
10
- export declare const resolveQuerySingleResult: (result: any, statusQueryResult?: {
11
- fieldCount: number;
12
- affectedRows: number;
13
- insertId: number;
14
- info: string;
15
- serverStatus: number;
16
- warningStatus: number;
17
- }) => (any[] | {
18
- fieldCount: number;
19
- affectedRows: number;
20
- insertId: number;
21
- info: string;
22
- serverStatus: number;
23
- warningStatus: number;
24
- })[];
25
- export declare const resolveQueryArrayResult: (results: any[], statusQueryResult?: {
26
- fieldCount: number;
27
- affectedRows: number;
28
- insertId: number;
29
- info: string;
30
- serverStatus: number;
31
- warningStatus: number;
32
- }) => (any[] | {
33
- fieldCount: number;
34
- affectedRows: number;
35
- insertId: number;
36
- info: string;
37
- serverStatus: number;
38
- warningStatus: number;
39
- })[];
40
- export declare const resolveEmptySingleResult: (statusQueryResult?: {
41
- fieldCount: number;
42
- affectedRows: number;
43
- insertId: number;
44
- info: string;
45
- serverStatus: number;
46
- warningStatus: number;
47
- }) => (any[] | {
48
- fieldCount: number;
49
- affectedRows: number;
50
- insertId: number;
51
- info: string;
52
- serverStatus: number;
53
- warningStatus: number;
54
- })[];
55
- export declare const createInMemorySqliteDataSource: (options?: DataSourceOptions) => Promise<DataSource>;
56
- export declare const createInMemoryPgDataSource: (options?: DataSourceOptions) => Promise<DataSource>;
@@ -1,44 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createInMemoryPgDataSource = exports.createInMemorySqliteDataSource = exports.resolveEmptySingleResult = exports.resolveQueryArrayResult = exports.resolveQuerySingleResult = exports.sqlQueryResult = void 0;
4
- const typeorm_1 = require("typeorm");
5
- const load_package_util_1 = require("@nestjs/common/utils/load-package.util");
6
- exports.sqlQueryResult = {
7
- fieldCount: 0,
8
- affectedRows: 0,
9
- insertId: 0,
10
- info: '',
11
- serverStatus: 34,
12
- warningStatus: 0,
13
- };
14
- const resolveQuerySingleResult = (result, statusQueryResult = exports.sqlQueryResult) => {
15
- return [[result], statusQueryResult];
16
- };
17
- exports.resolveQuerySingleResult = resolveQuerySingleResult;
18
- const resolveQueryArrayResult = (results, statusQueryResult = exports.sqlQueryResult) => {
19
- return [results, statusQueryResult];
20
- };
21
- exports.resolveQueryArrayResult = resolveQueryArrayResult;
22
- const resolveEmptySingleResult = (statusQueryResult = exports.sqlQueryResult) => {
23
- return [[], statusQueryResult];
24
- };
25
- exports.resolveEmptySingleResult = resolveEmptySingleResult;
26
- const createInMemorySqliteDataSource = async (options) => {
27
- const dbOptions = Object.assign({}, { type: "sqlite", database: ":memory:", }, options);
28
- return new typeorm_1.DataSource(dbOptions);
29
- };
30
- exports.createInMemorySqliteDataSource = createInMemorySqliteDataSource;
31
- const createInMemoryPgDataSource = (options) => {
32
- const dbOptions = Object.assign({}, { type: "postgres", synchronize: true, }, options);
33
- const pgMem = (0, load_package_util_1.loadPackage)('pg-mem', 'createInMemoryPgDataSource', () => require('pg-mem'));
34
- const db = pgMem.newDb();
35
- db.public.registerFunction({
36
- name: 'current_database',
37
- args: [],
38
- returns: pgMem.DataType.text,
39
- implementation: (x) => `hello world ${x}`,
40
- });
41
- return db.adapters.createTypeormDataSource(dbOptions);
42
- };
43
- exports.createInMemoryPgDataSource = createInMemoryPgDataSource;
44
- //# sourceMappingURL=testing-utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"testing-utils.js","sourceRoot":"","sources":["../../lib/testing/testing-utils.ts"],"names":[],"mappings":";;;AAAA,qCAAwD;AACxD,8EAAqE;AAExD,QAAA,cAAc,GAAG;IAC5B,UAAU,EAAE,CAAC;IACb,YAAY,EAAE,CAAC;IACf,Q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AAC;IAC3F,MAAM,EAAE,GAAG,KAAK,CAAC,KAAK,EAAE,CAAC;IACzB,EAAE,CAAC,MAAM,CAAC,gBAAgB,CAAC;QACzB,IAAI,EAAE,kBAAkB;QACxB,IAAI,EAAE,EAAE;QACR,OAAO,EAAE,KAAK,CAAC,QAAQ,CAAC,IAAI;QAC5B,cAAc,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,eAAe,CAAC,EAAE;KAC1C,CAAC,CAAC;IAEH,OAAO,EAAE,CAAC,QAAQ,CAAC,uBAAuB,CAAC,SAAS,CAAC,CAAC;AACxD,CAAC,CAAA;AAZY,QAAA,0BAA0B,8BAYtC"}
@@ -1,18 +0,0 @@
1
- import { TypeOrmModuleOptions, TypeOrmOptionsFactory } from "@nestjs/typeorm";
2
- import { EntitySchema, MixedList } from "typeorm";
3
- import { BaseDataSourceOptions } from "typeorm/data-source/BaseDataSourceOptions";
4
- import { MysqlConnectionOptions } from "typeorm/driver/mysql/MysqlConnectionOptions";
5
- import { MongoConnectionOptions } from "typeorm/driver/mongodb/MongoConnectionOptions";
6
- import { PostgresConnectionOptions } from "typeorm/driver/postgres/PostgresConnectionOptions";
7
- export type OptionWithoutEntities = Omit<Partial<BaseDataSourceOptions>, "entities" | "type"> | Omit<Partial<MysqlConnectionOptions>, "entities" | "type"> | Omit<Partial<MongoConnectionOptions>, "entities" | "type"> | Omit<Partial<PostgresConnectionOptions>, "entities" | "type">;
8
- export declare class BaseTypeOrmModuleOptionFactory implements TypeOrmOptionsFactory {
9
- private readonly connectionString;
10
- private readonly entities?;
11
- private readonly options?;
12
- private connectionType;
13
- constructor(connectionString: string, entities?: MixedList<Function | string | EntitySchema>, options?: OptionWithoutEntities);
14
- createTypeOrmOptions(connectionName?: string): TypeOrmModuleOptions | Promise<TypeOrmModuleOptions>;
15
- }
16
- export declare class DefaultTypeOrmModuleOptionFactory extends BaseTypeOrmModuleOptionFactory {
17
- constructor(entities?: MixedList<Function | string | EntitySchema>, options?: OptionWithoutEntities);
18
- }
@@ -1,42 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DefaultTypeOrmModuleOptionFactory = exports.BaseTypeOrmModuleOptionFactory = void 0;
4
- const typeorm_utils_1 = require("./typeorm-utils");
5
- class BaseTypeOrmModuleOptionFactory {
6
- constructor(connectionString, entities, options) {
7
- this.connectionString = connectionString;
8
- this.entities = entities;
9
- this.options = options;
10
- if (!connectionString || connectionString == "") {
11
- throw new Error("connectionString is missing");
12
- }
13
- const isPresent = connectionString && connectionString != "";
14
- this.connectionType = (isPresent ? this.connectionString.split(":").shift() : null);
15
- }
16
- createTypeOrmOptions(connectionName) {
17
- const options = (0, typeorm_utils_1.sanatizeTypeOrmOptions)(this.connectionType, this.options);
18
- switch (this.connectionType) {
19
- case "mysql":
20
- case "mariadb":
21
- case "mongodb":
22
- case "postgres":
23
- return {
24
- ...options,
25
- name: connectionName,
26
- type: this.connectionType,
27
- url: this.connectionString,
28
- entities: this.entities || [],
29
- };
30
- default:
31
- throw new Error("Connection Not Supported");
32
- }
33
- }
34
- }
35
- exports.BaseTypeOrmModuleOptionFactory = BaseTypeOrmModuleOptionFactory;
36
- class DefaultTypeOrmModuleOptionFactory extends BaseTypeOrmModuleOptionFactory {
37
- constructor(entities, options) {
38
- super(process.env.MYSQL_URL, entities, options);
39
- }
40
- }
41
- exports.DefaultTypeOrmModuleOptionFactory = DefaultTypeOrmModuleOptionFactory;
42
- //# sourceMappingURL=base-typeorm-options-factory.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"base-typeorm-options-factory.js","sourceRoot":"","sources":["../../lib/typeorm/base-typeorm-options-factory.ts"],"names":[],"mappings":";;;AAIA,mDAAyD;AAQzD,MAAa,8BAA8B;IAGzC,YAA6B,gBAAwB,EAClC,QAAsD,EACtD,OAA+B;QAFrB,qBAAgB,GAAhB,gBAAgB,CAAQ;QAClC,aAAQ,GAAR,QAAQ,CAA8C;QACtD,YAAO,GAAP,OAAO,CAAwB;QAEhD,IAAI,CAAC,gBAAgB,IAAI,gBAAgB,IAAI,EAAE,EAAE,CAAC;YAChD,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;QACjD,CAAC;QAED,MAAM,SAAS,GAAG,gBAAgB,IAAI,gBAAgB,IAAI,EAAE,CAAC;QAC7D,IAAI,CAAC,cAAc,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,EAA6B,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IACjH,CAAC;IAED,oBAAoB,CAAC,cAAuB;QAC1C,MAAM,OAAO,GAAG,IAAA,sCAAsB,EAAC,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QAC1E,QAAQ,IAAI,CAAC,cAAc,EAAE,CAAC;YAC5B,KAAK,OAAO,CAAC;YACb,KAAK,SAAS,CAAC;YACf,KAAK,SAAS,CAAC;YACf,KAAK,UAAU;gBACb,OAAO;oBACL,GAAG,OAAO;oBACV,IAAI,EAAE,cAAc;oBACpB,IAAI,EAAE,IAAI,CAAC,cAAc;oBACzB,GAAG,EAAE,IAAI,CAAC,gBAAgB;oBAC1B,QAAQ,EAAE,IAAI,CAAC,QAAQ,IAAI,EAAE;iBAC9B,CAAA;YACH;gBACE,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;QAChD,CAAC;IACH,CAAC;CACF;AAjCD,wEAiCC;AAED,MAAa,iCAAkC,SAAQ,8BAA8B;IACnF,YAAY,QAAsD,EAC/D,OAA+B;QAC9B,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;IACpD,CAAC;CACF;AALD,8EAKC"}
@@ -1,16 +0,0 @@
1
- import { SnakeNamingStrategy } from "typeorm-naming-strategies";
2
- export declare const defaultExtraOptions: {
3
- entities: any[];
4
- logging: boolean;
5
- synchronize: boolean;
6
- autoLoadEntities: boolean;
7
- namingStrategy: SnakeNamingStrategy;
8
- };
9
- export declare const defaultMysqlExtraOptions: {
10
- supportBigNumbers: boolean;
11
- bigNumberStrings: boolean;
12
- };
13
- export declare const defaultMongoExtraOptions: {
14
- useNewUrlParser: boolean;
15
- useUnifiedTopology: boolean;
16
- };
@@ -1,20 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.defaultMongoExtraOptions = exports.defaultMysqlExtraOptions = exports.defaultExtraOptions = void 0;
4
- const typeorm_naming_strategies_1 = require("typeorm-naming-strategies");
5
- exports.defaultExtraOptions = {
6
- entities: [],
7
- logging: false,
8
- synchronize: false,
9
- autoLoadEntities: true,
10
- namingStrategy: new typeorm_naming_strategies_1.SnakeNamingStrategy(),
11
- };
12
- exports.defaultMysqlExtraOptions = {
13
- supportBigNumbers: true,
14
- bigNumberStrings: true,
15
- };
16
- exports.defaultMongoExtraOptions = {
17
- useNewUrlParser: true,
18
- useUnifiedTopology: true,
19
- };
20
- //# sourceMappingURL=constants.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../lib/typeorm/constants.ts"],"names":[],"mappings":";;;AAAA,yEAA+D;AAElD,QAAA,mBAAmB,GAAG;IACjC,QAAQ,EAAE,EAAE;IACZ,OAAO,EAAE,KAAK;IACd,WAAW,EAAE,KAAK;IAClB,gBAAgB,EAAE,IAAI;IACtB,cAAc,EAAE,IAAI,+CAAmB,EAAE;CAC1C,CAAA;AAEY,QAAA,wBAAwB,GAAG;IACtC,iBAAiB,EAAE,IAAI;IACvB,gBAAgB,EAAE,IAAI;CACvB,CAAA;AAEY,QAAA,wBAAwB,GAAG;IACtC,eAAe,EAAE,IAAI;IACrB,kBAAkB,EAAE,IAAI;CACzB,CAAA"}
@@ -1,5 +0,0 @@
1
- import { BaseTypeOrmModuleOptionFactory, DefaultTypeOrmModuleOptionFactory, OptionWithoutEntities } from "./base-typeorm-options-factory";
2
- import { defaultExtraOptions, defaultMongoExtraOptions, defaultMysqlExtraOptions } from "./constants";
3
- import { DEFAULT_DATA_SOURCE_NAME, SupportedConnectionType, TypeOrmExModule } from "./typeorm-ex.module";
4
- import { sanatizeTypeOrmOptions } from "./typeorm-utils";
5
- export { TypeOrmExModule, DEFAULT_DATA_SOURCE_NAME, defaultExtraOptions, defaultMysqlExtraOptions, defaultMongoExtraOptions, SupportedConnectionType, sanatizeTypeOrmOptions, BaseTypeOrmModuleOptionFactory, OptionWithoutEntities, DefaultTypeOrmModuleOptionFactory, };
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DefaultTypeOrmModuleOptionFactory = exports.BaseTypeOrmModuleOptionFactory = exports.sanatizeTypeOrmOptions = exports.defaultMongoExtraOptions = exports.defaultMysqlExtraOptions = exports.defaultExtraOptions = exports.DEFAULT_DATA_SOURCE_NAME = exports.TypeOrmExModule = void 0;
4
- const base_typeorm_options_factory_1 = require("./base-typeorm-options-factory");
5
- Object.defineProperty(exports, "BaseTypeOrmModuleOptionFactory", { enumerable: true, get: function () { return base_typeorm_options_factory_1.BaseTypeOrmModuleOptionFactory; } });
6
- Object.defineProperty(exports, "DefaultTypeOrmModuleOptionFactory", { enumerable: true, get: function () { return base_typeorm_options_factory_1.DefaultTypeOrmModuleOptionFactory; } });
7
- const constants_1 = require("./constants");
8
- Object.defineProperty(exports, "defaultExtraOptions", { enumerable: true, get: function () { return constants_1.defaultExtraOptions; } });
9
- Object.defineProperty(exports, "defaultMongoExtraOptions", { enumerable: true, get: function () { return constants_1.defaultMongoExtraOptions; } });
10
- Object.defineProperty(exports, "defaultMysqlExtraOptions", { enumerable: true, get: function () { return constants_1.defaultMysqlExtraOptions; } });
11
- const typeorm_ex_module_1 = require("./typeorm-ex.module");
12
- Object.defineProperty(exports, "DEFAULT_DATA_SOURCE_NAME", { enumerable: true, get: function () { return typeorm_ex_module_1.DEFAULT_DATA_SOURCE_NAME; } });
13
- Object.defineProperty(exports, "TypeOrmExModule", { enumerable: true, get: function () { return typeorm_ex_module_1.TypeOrmExModule; } });
14
- const typeorm_utils_1 = require("./typeorm-utils");
15
- Object.defineProperty(exports, "sanatizeTypeOrmOptions", { enumerable: true, get: function () { return typeorm_utils_1.sanatizeTypeOrmOptions; } });
16
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/typeorm/index.ts"],"names":[],"mappings":";;;AAAA,iFAA0I;AAaxI,+GAbO,6DAA8B,OAaP;AAE9B,kHAfuC,gEAAiC,OAevC;AAdnC,2CAAsG;AAOpG,oGAPO,+BAAmB,OAOP;AAEnB,yGAT4B,oCAAwB,OAS5B;AADxB,yGARsD,oCAAwB,OAQtD;AAP1B,2DAAyG;AAKvG,yGALO,4CAAwB,OAKP;AADxB,gGAJ0D,mCAAe,OAI1D;AAHjB,mDAAyD;AASvD,uGATO,sCAAsB,OASP"}
@@ -1,13 +0,0 @@
1
- import { DynamicModule } from "@nestjs/common";
2
- import { TypeOrmModuleAsyncOptions, TypeOrmModuleOptions } from "@nestjs/typeorm";
3
- import { DataSource, DataSourceOptions } from "typeorm";
4
- import { EntityClassOrSchema } from "@nestjs/typeorm/dist/interfaces/entity-class-or-schema.type";
5
- export declare const DEFAULT_DATA_SOURCE_NAME = "default";
6
- export type SupportedConnectionType = "mysql" | "mariadb" | "mongodb" | "postgres";
7
- export declare class TypeOrmExModule {
8
- static forRoot(options?: TypeOrmModuleOptions): DynamicModule;
9
- static forRootAsync(options?: TypeOrmModuleAsyncOptions): DynamicModule;
10
- static forFeature(entities?: EntityClassOrSchema[], dataSource?: string): DynamicModule;
11
- static forCustomRepository<T extends new (...args: any[]) => any>(repositories: T[], dataSource?: DataSource | DataSourceOptions | string): DynamicModule;
12
- private static sanitizeOptions;
13
- }