nicot 1.2.12 → 1.2.13
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/README.md +408 -0
- package/dist/index.cjs +744 -3
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +1 -0
- package/dist/index.mjs +767 -3
- package/dist/index.mjs.map +4 -4
- package/dist/src/transactional-typeorm.module.d.ts +20 -0
- package/dist/src/utility/create-dynamic-fetcher-proxy.d.ts +1 -0
- package/dist/src/utility/create-inject-from-token-factory.d.ts +4 -0
- package/index.ts +1 -0
- package/package.json +5 -2
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
8
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
9
|
+
}) : x)(function(x) {
|
|
10
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
11
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
12
|
+
});
|
|
13
|
+
var __commonJS = (cb, mod) => function __require2() {
|
|
14
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
15
|
+
};
|
|
16
|
+
var __copyProps = (to, from, except, desc) => {
|
|
17
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
18
|
+
for (let key of __getOwnPropNames(from))
|
|
19
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
20
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
21
|
+
}
|
|
22
|
+
return to;
|
|
23
|
+
};
|
|
24
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
25
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
26
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
27
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
28
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
29
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
30
|
+
mod
|
|
31
|
+
));
|
|
3
32
|
var __decorateClass = (decorators, target, key, kind) => {
|
|
4
33
|
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
5
34
|
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
@@ -9,6 +38,539 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
9
38
|
return result;
|
|
10
39
|
};
|
|
11
40
|
|
|
41
|
+
// node_modules/@nestjs/typeorm/dist/typeorm.constants.js
|
|
42
|
+
var require_typeorm_constants = __commonJS({
|
|
43
|
+
"node_modules/@nestjs/typeorm/dist/typeorm.constants.js"(exports) {
|
|
44
|
+
"use strict";
|
|
45
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
|
+
exports.DEFAULT_DATA_SOURCE_NAME = exports.TYPEORM_MODULE_ID = exports.TYPEORM_MODULE_OPTIONS = void 0;
|
|
47
|
+
exports.TYPEORM_MODULE_OPTIONS = "TypeOrmModuleOptions";
|
|
48
|
+
exports.TYPEORM_MODULE_ID = "TypeOrmModuleId";
|
|
49
|
+
exports.DEFAULT_DATA_SOURCE_NAME = "default";
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
// node_modules/@nestjs/typeorm/dist/exceptions/circular-dependency.exception.js
|
|
54
|
+
var require_circular_dependency_exception = __commonJS({
|
|
55
|
+
"node_modules/@nestjs/typeorm/dist/exceptions/circular-dependency.exception.js"(exports) {
|
|
56
|
+
"use strict";
|
|
57
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
58
|
+
exports.CircularDependencyException = void 0;
|
|
59
|
+
var CircularDependencyException = class extends Error {
|
|
60
|
+
constructor(context) {
|
|
61
|
+
const ctx = context ? ` inside ${context}` : ``;
|
|
62
|
+
super(`A circular dependency has been detected${ctx}. Please, make sure that each side of a bidirectional relationships are decorated with "forwardRef()". Also, try to eliminate barrel files because they can lead to an unexpected behavior too.`);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
exports.CircularDependencyException = CircularDependencyException;
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
// node_modules/@nestjs/typeorm/dist/common/typeorm.utils.js
|
|
70
|
+
var require_typeorm_utils = __commonJS({
|
|
71
|
+
"node_modules/@nestjs/typeorm/dist/common/typeorm.utils.js"(exports) {
|
|
72
|
+
"use strict";
|
|
73
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
74
|
+
exports.generateString = exports.getConnectionToken = void 0;
|
|
75
|
+
exports.getRepositoryToken = getRepositoryToken;
|
|
76
|
+
exports.getCustomRepositoryToken = getCustomRepositoryToken;
|
|
77
|
+
exports.getDataSourceToken = getDataSourceToken;
|
|
78
|
+
exports.getDataSourcePrefix = getDataSourcePrefix;
|
|
79
|
+
exports.getEntityManagerToken = getEntityManagerToken2;
|
|
80
|
+
exports.handleRetry = handleRetry;
|
|
81
|
+
exports.getDataSourceName = getDataSourceName;
|
|
82
|
+
var common_1 = __require("@nestjs/common");
|
|
83
|
+
var operators_1 = __require("rxjs/operators");
|
|
84
|
+
var typeorm_1 = __require("typeorm");
|
|
85
|
+
var circular_dependency_exception_1 = require_circular_dependency_exception();
|
|
86
|
+
var typeorm_constants_1 = require_typeorm_constants();
|
|
87
|
+
var logger = new common_1.Logger("TypeOrmModule");
|
|
88
|
+
function getRepositoryToken(entity, dataSource = typeorm_constants_1.DEFAULT_DATA_SOURCE_NAME) {
|
|
89
|
+
if (entity === null || entity === void 0) {
|
|
90
|
+
throw new circular_dependency_exception_1.CircularDependencyException("@InjectRepository()");
|
|
91
|
+
}
|
|
92
|
+
const dataSourcePrefix = getDataSourcePrefix(dataSource);
|
|
93
|
+
if (entity instanceof Function && (entity.prototype instanceof typeorm_1.Repository || entity.prototype instanceof typeorm_1.AbstractRepository)) {
|
|
94
|
+
if (!dataSourcePrefix) {
|
|
95
|
+
return entity;
|
|
96
|
+
}
|
|
97
|
+
return `${dataSourcePrefix}${getCustomRepositoryToken(entity)}`;
|
|
98
|
+
}
|
|
99
|
+
if (entity instanceof typeorm_1.EntitySchema) {
|
|
100
|
+
return `${dataSourcePrefix}${entity.options.target ? entity.options.target.name : entity.options.name}Repository`;
|
|
101
|
+
}
|
|
102
|
+
return `${dataSourcePrefix}${entity.name}Repository`;
|
|
103
|
+
}
|
|
104
|
+
function getCustomRepositoryToken(repository) {
|
|
105
|
+
if (repository === null || repository === void 0) {
|
|
106
|
+
throw new circular_dependency_exception_1.CircularDependencyException("@InjectRepository()");
|
|
107
|
+
}
|
|
108
|
+
return repository.name;
|
|
109
|
+
}
|
|
110
|
+
function getDataSourceToken(dataSource = typeorm_constants_1.DEFAULT_DATA_SOURCE_NAME) {
|
|
111
|
+
return typeorm_constants_1.DEFAULT_DATA_SOURCE_NAME === dataSource ? typeorm_1.DataSource ?? typeorm_1.Connection : "string" === typeof dataSource ? `${dataSource}DataSource` : typeorm_constants_1.DEFAULT_DATA_SOURCE_NAME === dataSource.name || !dataSource.name ? typeorm_1.DataSource ?? typeorm_1.Connection : `${dataSource.name}DataSource`;
|
|
112
|
+
}
|
|
113
|
+
exports.getConnectionToken = getDataSourceToken;
|
|
114
|
+
function getDataSourcePrefix(dataSource = typeorm_constants_1.DEFAULT_DATA_SOURCE_NAME) {
|
|
115
|
+
if (dataSource === typeorm_constants_1.DEFAULT_DATA_SOURCE_NAME) {
|
|
116
|
+
return "";
|
|
117
|
+
}
|
|
118
|
+
if (typeof dataSource === "string") {
|
|
119
|
+
return dataSource + "_";
|
|
120
|
+
}
|
|
121
|
+
if (dataSource.name === typeorm_constants_1.DEFAULT_DATA_SOURCE_NAME || !dataSource.name) {
|
|
122
|
+
return "";
|
|
123
|
+
}
|
|
124
|
+
return dataSource.name + "_";
|
|
125
|
+
}
|
|
126
|
+
function getEntityManagerToken2(dataSource = typeorm_constants_1.DEFAULT_DATA_SOURCE_NAME) {
|
|
127
|
+
return typeorm_constants_1.DEFAULT_DATA_SOURCE_NAME === dataSource ? typeorm_1.EntityManager : "string" === typeof dataSource ? `${dataSource}EntityManager` : typeorm_constants_1.DEFAULT_DATA_SOURCE_NAME === dataSource.name || !dataSource.name ? typeorm_1.EntityManager : `${dataSource.name}EntityManager`;
|
|
128
|
+
}
|
|
129
|
+
function handleRetry(retryAttempts = 9, retryDelay = 3e3, dataSourceName = typeorm_constants_1.DEFAULT_DATA_SOURCE_NAME, verboseRetryLog = false, toRetry) {
|
|
130
|
+
return (source) => source.pipe((0, operators_1.retryWhen)((e) => e.pipe((0, operators_1.scan)((errorCount, error) => {
|
|
131
|
+
if (toRetry && !toRetry(error)) {
|
|
132
|
+
throw error;
|
|
133
|
+
}
|
|
134
|
+
const dataSourceInfo = dataSourceName === typeorm_constants_1.DEFAULT_DATA_SOURCE_NAME ? "" : ` (${dataSourceName})`;
|
|
135
|
+
const verboseMessage = verboseRetryLog ? ` Message: ${error.message}.` : "";
|
|
136
|
+
logger.error(`Unable to connect to the database${dataSourceInfo}.${verboseMessage} Retrying (${errorCount + 1})...`, error.stack);
|
|
137
|
+
if (errorCount + 1 >= retryAttempts) {
|
|
138
|
+
throw error;
|
|
139
|
+
}
|
|
140
|
+
return errorCount + 1;
|
|
141
|
+
}, 0), (0, operators_1.delay)(retryDelay))));
|
|
142
|
+
}
|
|
143
|
+
function getDataSourceName(options) {
|
|
144
|
+
return options && options.name ? options.name : typeorm_constants_1.DEFAULT_DATA_SOURCE_NAME;
|
|
145
|
+
}
|
|
146
|
+
var generateString = () => crypto.randomUUID();
|
|
147
|
+
exports.generateString = generateString;
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
// node_modules/@nestjs/typeorm/dist/common/typeorm.decorators.js
|
|
152
|
+
var require_typeorm_decorators = __commonJS({
|
|
153
|
+
"node_modules/@nestjs/typeorm/dist/common/typeorm.decorators.js"(exports) {
|
|
154
|
+
"use strict";
|
|
155
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
156
|
+
exports.InjectEntityManager = exports.InjectConnection = exports.InjectDataSource = exports.InjectRepository = void 0;
|
|
157
|
+
var common_1 = __require("@nestjs/common");
|
|
158
|
+
var typeorm_constants_1 = require_typeorm_constants();
|
|
159
|
+
var typeorm_utils_1 = require_typeorm_utils();
|
|
160
|
+
var InjectRepository = (entity, dataSource = typeorm_constants_1.DEFAULT_DATA_SOURCE_NAME) => (0, common_1.Inject)((0, typeorm_utils_1.getRepositoryToken)(entity, dataSource));
|
|
161
|
+
exports.InjectRepository = InjectRepository;
|
|
162
|
+
var InjectDataSource = (dataSource) => (0, common_1.Inject)((0, typeorm_utils_1.getDataSourceToken)(dataSource));
|
|
163
|
+
exports.InjectDataSource = InjectDataSource;
|
|
164
|
+
exports.InjectConnection = exports.InjectDataSource;
|
|
165
|
+
var InjectEntityManager = (dataSource) => (0, common_1.Inject)((0, typeorm_utils_1.getEntityManagerToken)(dataSource));
|
|
166
|
+
exports.InjectEntityManager = InjectEntityManager;
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
// node_modules/@nestjs/typeorm/dist/common/index.js
|
|
171
|
+
var require_common = __commonJS({
|
|
172
|
+
"node_modules/@nestjs/typeorm/dist/common/index.js"(exports) {
|
|
173
|
+
"use strict";
|
|
174
|
+
var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
|
|
175
|
+
if (k2 === void 0) k2 = k;
|
|
176
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
177
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
178
|
+
desc = { enumerable: true, get: function() {
|
|
179
|
+
return m[k];
|
|
180
|
+
} };
|
|
181
|
+
}
|
|
182
|
+
Object.defineProperty(o, k2, desc);
|
|
183
|
+
}) : (function(o, m, k, k2) {
|
|
184
|
+
if (k2 === void 0) k2 = k;
|
|
185
|
+
o[k2] = m[k];
|
|
186
|
+
}));
|
|
187
|
+
var __exportStar = exports && exports.__exportStar || function(m, exports2) {
|
|
188
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p)) __createBinding(exports2, m, p);
|
|
189
|
+
};
|
|
190
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
191
|
+
__exportStar(require_typeorm_decorators(), exports);
|
|
192
|
+
__exportStar(require_typeorm_utils(), exports);
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
// node_modules/@nestjs/typeorm/dist/interfaces/typeorm-options.interface.js
|
|
197
|
+
var require_typeorm_options_interface = __commonJS({
|
|
198
|
+
"node_modules/@nestjs/typeorm/dist/interfaces/typeorm-options.interface.js"(exports) {
|
|
199
|
+
"use strict";
|
|
200
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
// node_modules/@nestjs/typeorm/dist/interfaces/index.js
|
|
205
|
+
var require_interfaces = __commonJS({
|
|
206
|
+
"node_modules/@nestjs/typeorm/dist/interfaces/index.js"(exports) {
|
|
207
|
+
"use strict";
|
|
208
|
+
var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
|
|
209
|
+
if (k2 === void 0) k2 = k;
|
|
210
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
211
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
212
|
+
desc = { enumerable: true, get: function() {
|
|
213
|
+
return m[k];
|
|
214
|
+
} };
|
|
215
|
+
}
|
|
216
|
+
Object.defineProperty(o, k2, desc);
|
|
217
|
+
}) : (function(o, m, k, k2) {
|
|
218
|
+
if (k2 === void 0) k2 = k;
|
|
219
|
+
o[k2] = m[k];
|
|
220
|
+
}));
|
|
221
|
+
var __exportStar = exports && exports.__exportStar || function(m, exports2) {
|
|
222
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p)) __createBinding(exports2, m, p);
|
|
223
|
+
};
|
|
224
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
225
|
+
__exportStar(require_typeorm_options_interface(), exports);
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
// node_modules/@nestjs/typeorm/dist/entities-metadata.storage.js
|
|
230
|
+
var require_entities_metadata_storage = __commonJS({
|
|
231
|
+
"node_modules/@nestjs/typeorm/dist/entities-metadata.storage.js"(exports) {
|
|
232
|
+
"use strict";
|
|
233
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
234
|
+
exports.EntitiesMetadataStorage = void 0;
|
|
235
|
+
var EntitiesMetadataStorage = class {
|
|
236
|
+
static addEntitiesByDataSource(dataSource, entities) {
|
|
237
|
+
const dataSourceToken = typeof dataSource === "string" ? dataSource : dataSource.name;
|
|
238
|
+
if (!dataSourceToken) {
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
let collection = this.storage.get(dataSourceToken);
|
|
242
|
+
if (!collection) {
|
|
243
|
+
collection = [];
|
|
244
|
+
this.storage.set(dataSourceToken, collection);
|
|
245
|
+
}
|
|
246
|
+
entities.forEach((entity) => {
|
|
247
|
+
if (collection.includes(entity)) {
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
collection.push(entity);
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
static getEntitiesByDataSource(dataSource) {
|
|
254
|
+
const dataSourceToken = typeof dataSource === "string" ? dataSource : dataSource.name;
|
|
255
|
+
if (!dataSourceToken) {
|
|
256
|
+
return [];
|
|
257
|
+
}
|
|
258
|
+
return this.storage.get(dataSourceToken) || [];
|
|
259
|
+
}
|
|
260
|
+
};
|
|
261
|
+
exports.EntitiesMetadataStorage = EntitiesMetadataStorage;
|
|
262
|
+
EntitiesMetadataStorage.storage = /* @__PURE__ */ new Map();
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
// node_modules/@nestjs/typeorm/dist/typeorm-core.module.js
|
|
267
|
+
var require_typeorm_core_module = __commonJS({
|
|
268
|
+
"node_modules/@nestjs/typeorm/dist/typeorm-core.module.js"(exports) {
|
|
269
|
+
"use strict";
|
|
270
|
+
var __decorate = exports && exports.__decorate || function(decorators, target, key, desc) {
|
|
271
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
272
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
273
|
+
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;
|
|
274
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
275
|
+
};
|
|
276
|
+
var __metadata = exports && exports.__metadata || function(k, v) {
|
|
277
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
278
|
+
};
|
|
279
|
+
var __param = exports && exports.__param || function(paramIndex, decorator) {
|
|
280
|
+
return function(target, key) {
|
|
281
|
+
decorator(target, key, paramIndex);
|
|
282
|
+
};
|
|
283
|
+
};
|
|
284
|
+
var TypeOrmCoreModule_1;
|
|
285
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
286
|
+
exports.TypeOrmCoreModule = void 0;
|
|
287
|
+
var common_1 = __require("@nestjs/common");
|
|
288
|
+
var core_1 = __require("@nestjs/core");
|
|
289
|
+
var rxjs_1 = __require("rxjs");
|
|
290
|
+
var typeorm_1 = __require("typeorm");
|
|
291
|
+
var typeorm_utils_1 = require_typeorm_utils();
|
|
292
|
+
var entities_metadata_storage_1 = require_entities_metadata_storage();
|
|
293
|
+
var typeorm_constants_1 = require_typeorm_constants();
|
|
294
|
+
var TypeOrmCoreModule = TypeOrmCoreModule_1 = class TypeOrmCoreModule {
|
|
295
|
+
constructor(options, moduleRef) {
|
|
296
|
+
this.options = options;
|
|
297
|
+
this.moduleRef = moduleRef;
|
|
298
|
+
this.logger = new common_1.Logger("TypeOrmModule");
|
|
299
|
+
}
|
|
300
|
+
static forRoot(options = {}) {
|
|
301
|
+
const typeOrmModuleOptions = {
|
|
302
|
+
provide: typeorm_constants_1.TYPEORM_MODULE_OPTIONS,
|
|
303
|
+
useValue: options
|
|
304
|
+
};
|
|
305
|
+
const dataSourceProvider = {
|
|
306
|
+
provide: (0, typeorm_utils_1.getDataSourceToken)(options),
|
|
307
|
+
useFactory: async () => await this.createDataSourceFactory(options)
|
|
308
|
+
};
|
|
309
|
+
const entityManagerProvider = this.createEntityManagerProvider(options);
|
|
310
|
+
const providers = [
|
|
311
|
+
entityManagerProvider,
|
|
312
|
+
dataSourceProvider,
|
|
313
|
+
typeOrmModuleOptions
|
|
314
|
+
];
|
|
315
|
+
const exports2 = [entityManagerProvider, dataSourceProvider];
|
|
316
|
+
if (dataSourceProvider.provide === typeorm_1.DataSource) {
|
|
317
|
+
providers.push({
|
|
318
|
+
provide: typeorm_1.Connection,
|
|
319
|
+
useExisting: typeorm_1.DataSource
|
|
320
|
+
});
|
|
321
|
+
exports2.push(typeorm_1.Connection);
|
|
322
|
+
}
|
|
323
|
+
return {
|
|
324
|
+
module: TypeOrmCoreModule_1,
|
|
325
|
+
providers,
|
|
326
|
+
exports: exports2
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
static forRootAsync(options) {
|
|
330
|
+
const dataSourceProvider = {
|
|
331
|
+
provide: (0, typeorm_utils_1.getDataSourceToken)(options),
|
|
332
|
+
useFactory: async (typeOrmOptions) => {
|
|
333
|
+
if (options.name) {
|
|
334
|
+
return await this.createDataSourceFactory({
|
|
335
|
+
...typeOrmOptions,
|
|
336
|
+
name: options.name
|
|
337
|
+
}, options.dataSourceFactory);
|
|
338
|
+
}
|
|
339
|
+
return await this.createDataSourceFactory(typeOrmOptions, options.dataSourceFactory);
|
|
340
|
+
},
|
|
341
|
+
inject: [typeorm_constants_1.TYPEORM_MODULE_OPTIONS]
|
|
342
|
+
};
|
|
343
|
+
const entityManagerProvider = {
|
|
344
|
+
provide: (0, typeorm_utils_1.getEntityManagerToken)(options),
|
|
345
|
+
useFactory: (dataSource) => dataSource.manager,
|
|
346
|
+
inject: [(0, typeorm_utils_1.getDataSourceToken)(options)]
|
|
347
|
+
};
|
|
348
|
+
const asyncProviders = this.createAsyncProviders(options);
|
|
349
|
+
const providers = [
|
|
350
|
+
...asyncProviders,
|
|
351
|
+
entityManagerProvider,
|
|
352
|
+
dataSourceProvider,
|
|
353
|
+
{
|
|
354
|
+
provide: typeorm_constants_1.TYPEORM_MODULE_ID,
|
|
355
|
+
useValue: (0, typeorm_utils_1.generateString)()
|
|
356
|
+
},
|
|
357
|
+
...options.extraProviders || []
|
|
358
|
+
];
|
|
359
|
+
const exports2 = [
|
|
360
|
+
entityManagerProvider,
|
|
361
|
+
dataSourceProvider
|
|
362
|
+
];
|
|
363
|
+
if (dataSourceProvider.provide === typeorm_1.DataSource) {
|
|
364
|
+
providers.push({
|
|
365
|
+
provide: typeorm_1.Connection,
|
|
366
|
+
useExisting: typeorm_1.DataSource
|
|
367
|
+
});
|
|
368
|
+
exports2.push(typeorm_1.Connection);
|
|
369
|
+
}
|
|
370
|
+
return {
|
|
371
|
+
module: TypeOrmCoreModule_1,
|
|
372
|
+
imports: options.imports,
|
|
373
|
+
providers,
|
|
374
|
+
exports: exports2
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
async onApplicationShutdown() {
|
|
378
|
+
const dataSource = this.moduleRef.get((0, typeorm_utils_1.getDataSourceToken)(this.options));
|
|
379
|
+
try {
|
|
380
|
+
if (dataSource && dataSource.isInitialized) {
|
|
381
|
+
await dataSource.destroy();
|
|
382
|
+
}
|
|
383
|
+
} catch (e) {
|
|
384
|
+
this.logger.error(e?.message);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
static createAsyncProviders(options) {
|
|
388
|
+
if (options.useExisting || options.useFactory) {
|
|
389
|
+
return [this.createAsyncOptionsProvider(options)];
|
|
390
|
+
}
|
|
391
|
+
const useClass = options.useClass;
|
|
392
|
+
return [
|
|
393
|
+
this.createAsyncOptionsProvider(options),
|
|
394
|
+
{
|
|
395
|
+
provide: useClass,
|
|
396
|
+
useClass
|
|
397
|
+
}
|
|
398
|
+
];
|
|
399
|
+
}
|
|
400
|
+
static createAsyncOptionsProvider(options) {
|
|
401
|
+
if (options.useFactory) {
|
|
402
|
+
return {
|
|
403
|
+
provide: typeorm_constants_1.TYPEORM_MODULE_OPTIONS,
|
|
404
|
+
useFactory: options.useFactory,
|
|
405
|
+
inject: options.inject || []
|
|
406
|
+
};
|
|
407
|
+
}
|
|
408
|
+
const inject = [
|
|
409
|
+
options.useClass || options.useExisting
|
|
410
|
+
];
|
|
411
|
+
return {
|
|
412
|
+
provide: typeorm_constants_1.TYPEORM_MODULE_OPTIONS,
|
|
413
|
+
useFactory: async (optionsFactory) => await optionsFactory.createTypeOrmOptions(options.name),
|
|
414
|
+
inject
|
|
415
|
+
};
|
|
416
|
+
}
|
|
417
|
+
static createEntityManagerProvider(options) {
|
|
418
|
+
return {
|
|
419
|
+
provide: (0, typeorm_utils_1.getEntityManagerToken)(options),
|
|
420
|
+
useFactory: (dataSource) => dataSource.manager,
|
|
421
|
+
inject: [(0, typeorm_utils_1.getDataSourceToken)(options)]
|
|
422
|
+
};
|
|
423
|
+
}
|
|
424
|
+
static async createDataSourceFactory(options, dataSourceFactory) {
|
|
425
|
+
const dataSourceToken = (0, typeorm_utils_1.getDataSourceName)(options);
|
|
426
|
+
const createTypeormDataSource = dataSourceFactory ?? ((options2) => {
|
|
427
|
+
return typeorm_1.DataSource === void 0 ? (0, typeorm_1.createConnection)(options2) : new typeorm_1.DataSource(options2);
|
|
428
|
+
});
|
|
429
|
+
return await (0, rxjs_1.lastValueFrom)((0, rxjs_1.defer)(async () => {
|
|
430
|
+
let dataSource;
|
|
431
|
+
if (!options.autoLoadEntities) {
|
|
432
|
+
dataSource = await createTypeormDataSource(options);
|
|
433
|
+
} else {
|
|
434
|
+
let entities = options.entities;
|
|
435
|
+
if (Array.isArray(entities)) {
|
|
436
|
+
entities = entities.concat(entities_metadata_storage_1.EntitiesMetadataStorage.getEntitiesByDataSource(dataSourceToken));
|
|
437
|
+
} else {
|
|
438
|
+
entities = entities_metadata_storage_1.EntitiesMetadataStorage.getEntitiesByDataSource(dataSourceToken);
|
|
439
|
+
}
|
|
440
|
+
dataSource = await createTypeormDataSource({
|
|
441
|
+
...options,
|
|
442
|
+
entities
|
|
443
|
+
});
|
|
444
|
+
}
|
|
445
|
+
return dataSource.initialize && !dataSource.isInitialized && !options.manualInitialization ? dataSource.initialize() : dataSource;
|
|
446
|
+
}).pipe((0, typeorm_utils_1.handleRetry)(options.retryAttempts, options.retryDelay, dataSourceToken, options.verboseRetryLog, options.toRetry)));
|
|
447
|
+
}
|
|
448
|
+
};
|
|
449
|
+
exports.TypeOrmCoreModule = TypeOrmCoreModule;
|
|
450
|
+
exports.TypeOrmCoreModule = TypeOrmCoreModule = TypeOrmCoreModule_1 = __decorate([
|
|
451
|
+
(0, common_1.Global)(),
|
|
452
|
+
(0, common_1.Module)({}),
|
|
453
|
+
__param(0, (0, common_1.Inject)(typeorm_constants_1.TYPEORM_MODULE_OPTIONS)),
|
|
454
|
+
__metadata("design:paramtypes", [Object, core_1.ModuleRef])
|
|
455
|
+
], TypeOrmCoreModule);
|
|
456
|
+
}
|
|
457
|
+
});
|
|
458
|
+
|
|
459
|
+
// node_modules/@nestjs/typeorm/dist/typeorm.providers.js
|
|
460
|
+
var require_typeorm_providers = __commonJS({
|
|
461
|
+
"node_modules/@nestjs/typeorm/dist/typeorm.providers.js"(exports) {
|
|
462
|
+
"use strict";
|
|
463
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
464
|
+
exports.createTypeOrmProviders = createTypeOrmProviders;
|
|
465
|
+
var typeorm_1 = __require("typeorm");
|
|
466
|
+
var typeorm_utils_1 = require_typeorm_utils();
|
|
467
|
+
function createTypeOrmProviders(entities, dataSource) {
|
|
468
|
+
return (entities || []).map((entity) => ({
|
|
469
|
+
provide: (0, typeorm_utils_1.getRepositoryToken)(entity, dataSource),
|
|
470
|
+
useFactory: (dataSource2) => {
|
|
471
|
+
const entityMetadata = dataSource2.entityMetadatas.find((meta) => meta.target === entity);
|
|
472
|
+
const isTreeEntity = typeof entityMetadata?.treeType !== "undefined";
|
|
473
|
+
return isTreeEntity ? dataSource2.getTreeRepository(entity) : dataSource2.options.type === "mongodb" ? dataSource2.getMongoRepository(entity) : dataSource2.getRepository(entity);
|
|
474
|
+
},
|
|
475
|
+
inject: [(0, typeorm_utils_1.getDataSourceToken)(dataSource)],
|
|
476
|
+
/**
|
|
477
|
+
* Extra property to workaround dynamic modules serialisation issue
|
|
478
|
+
* that occurs when "TypeOrm#forFeature()" method is called with the same number
|
|
479
|
+
* of arguments and all entities share the same class names.
|
|
480
|
+
*/
|
|
481
|
+
targetEntitySchema: (0, typeorm_1.getMetadataArgsStorage)().tables.find((item) => item.target === entity)
|
|
482
|
+
}));
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
});
|
|
486
|
+
|
|
487
|
+
// node_modules/@nestjs/typeorm/dist/typeorm.module.js
|
|
488
|
+
var require_typeorm_module = __commonJS({
|
|
489
|
+
"node_modules/@nestjs/typeorm/dist/typeorm.module.js"(exports) {
|
|
490
|
+
"use strict";
|
|
491
|
+
var __decorate = exports && exports.__decorate || function(decorators, target, key, desc) {
|
|
492
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
493
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
494
|
+
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;
|
|
495
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
496
|
+
};
|
|
497
|
+
var TypeOrmModule_1;
|
|
498
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
499
|
+
exports.TypeOrmModule = void 0;
|
|
500
|
+
var common_1 = __require("@nestjs/common");
|
|
501
|
+
var entities_metadata_storage_1 = require_entities_metadata_storage();
|
|
502
|
+
var typeorm_core_module_1 = require_typeorm_core_module();
|
|
503
|
+
var typeorm_constants_1 = require_typeorm_constants();
|
|
504
|
+
var typeorm_providers_1 = require_typeorm_providers();
|
|
505
|
+
var TypeOrmModule2 = TypeOrmModule_1 = class TypeOrmModule {
|
|
506
|
+
static forRoot(options) {
|
|
507
|
+
return {
|
|
508
|
+
module: TypeOrmModule_1,
|
|
509
|
+
imports: [typeorm_core_module_1.TypeOrmCoreModule.forRoot(options)]
|
|
510
|
+
};
|
|
511
|
+
}
|
|
512
|
+
static forFeature(entities = [], dataSource = typeorm_constants_1.DEFAULT_DATA_SOURCE_NAME) {
|
|
513
|
+
const providers = (0, typeorm_providers_1.createTypeOrmProviders)(entities, dataSource);
|
|
514
|
+
entities_metadata_storage_1.EntitiesMetadataStorage.addEntitiesByDataSource(dataSource, [...entities]);
|
|
515
|
+
return {
|
|
516
|
+
module: TypeOrmModule_1,
|
|
517
|
+
providers,
|
|
518
|
+
exports: providers
|
|
519
|
+
};
|
|
520
|
+
}
|
|
521
|
+
static forRootAsync(options) {
|
|
522
|
+
return {
|
|
523
|
+
module: TypeOrmModule_1,
|
|
524
|
+
imports: [typeorm_core_module_1.TypeOrmCoreModule.forRootAsync(options)]
|
|
525
|
+
};
|
|
526
|
+
}
|
|
527
|
+
};
|
|
528
|
+
exports.TypeOrmModule = TypeOrmModule2;
|
|
529
|
+
exports.TypeOrmModule = TypeOrmModule2 = TypeOrmModule_1 = __decorate([
|
|
530
|
+
(0, common_1.Module)({})
|
|
531
|
+
], TypeOrmModule2);
|
|
532
|
+
}
|
|
533
|
+
});
|
|
534
|
+
|
|
535
|
+
// node_modules/@nestjs/typeorm/dist/index.js
|
|
536
|
+
var require_dist = __commonJS({
|
|
537
|
+
"node_modules/@nestjs/typeorm/dist/index.js"(exports) {
|
|
538
|
+
"use strict";
|
|
539
|
+
var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
|
|
540
|
+
if (k2 === void 0) k2 = k;
|
|
541
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
542
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
543
|
+
desc = { enumerable: true, get: function() {
|
|
544
|
+
return m[k];
|
|
545
|
+
} };
|
|
546
|
+
}
|
|
547
|
+
Object.defineProperty(o, k2, desc);
|
|
548
|
+
}) : (function(o, m, k, k2) {
|
|
549
|
+
if (k2 === void 0) k2 = k;
|
|
550
|
+
o[k2] = m[k];
|
|
551
|
+
}));
|
|
552
|
+
var __exportStar = exports && exports.__exportStar || function(m, exports2) {
|
|
553
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p)) __createBinding(exports2, m, p);
|
|
554
|
+
};
|
|
555
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
556
|
+
__exportStar(require_common(), exports);
|
|
557
|
+
__exportStar(require_interfaces(), exports);
|
|
558
|
+
__exportStar(require_typeorm_module(), exports);
|
|
559
|
+
}
|
|
560
|
+
});
|
|
561
|
+
|
|
562
|
+
// node_modules/@nestjs/typeorm/index.js
|
|
563
|
+
var require_typeorm = __commonJS({
|
|
564
|
+
"node_modules/@nestjs/typeorm/index.js"(exports) {
|
|
565
|
+
"use strict";
|
|
566
|
+
function __export(m) {
|
|
567
|
+
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
|
568
|
+
}
|
|
569
|
+
exports.__esModule = true;
|
|
570
|
+
__export(require_dist());
|
|
571
|
+
}
|
|
572
|
+
});
|
|
573
|
+
|
|
12
574
|
// index.ts
|
|
13
575
|
export * from "nesties";
|
|
14
576
|
|
|
@@ -1701,7 +2263,11 @@ var CrudBase = class {
|
|
|
1701
2263
|
const existingEnt = await repo.findOne({
|
|
1702
2264
|
where: { id: ent.id },
|
|
1703
2265
|
select: this.crudOptions.createOrUpdate ? void 0 : ["id", "deleteTime"],
|
|
1704
|
-
withDeleted: true
|
|
2266
|
+
withDeleted: true,
|
|
2267
|
+
lock: {
|
|
2268
|
+
mode: "pessimistic_write",
|
|
2269
|
+
tables: [repo.metadata.tableName]
|
|
2270
|
+
}
|
|
1705
2271
|
});
|
|
1706
2272
|
if (existingEnt) {
|
|
1707
2273
|
if (existingEnt.deleteTime) {
|
|
@@ -2135,7 +2701,8 @@ var CrudBase = class {
|
|
|
2135
2701
|
await flush();
|
|
2136
2702
|
return result;
|
|
2137
2703
|
};
|
|
2138
|
-
const
|
|
2704
|
+
const hasActiveTx = !!this.repo.manager.queryRunner?.isTransactionActive;
|
|
2705
|
+
const res = await (options.repo ? op(options.repo) : hasActiveTx ? op(this.repo) : this.repo.manager.transaction(
|
|
2139
2706
|
(tdb) => op(tdb.getRepository(this.entityClass))
|
|
2140
2707
|
));
|
|
2141
2708
|
return res == null ? new BlankReturnMessageDto2(200, "success") : new GenericReturnMessageDto(200, "success", res);
|
|
@@ -3099,6 +3666,195 @@ var applyQueryMatchBooleanMySQL = createQueryCondition(
|
|
|
3099
3666
|
}
|
|
3100
3667
|
}
|
|
3101
3668
|
);
|
|
3669
|
+
|
|
3670
|
+
// src/transactional-typeorm.module.ts
|
|
3671
|
+
var import_typeorm8 = __toESM(require_typeorm());
|
|
3672
|
+
import { EntityManager } from "typeorm";
|
|
3673
|
+
import {
|
|
3674
|
+
Inject as Inject2,
|
|
3675
|
+
Injectable,
|
|
3676
|
+
Module,
|
|
3677
|
+
Scope
|
|
3678
|
+
} from "@nestjs/common";
|
|
3679
|
+
import { createProvider } from "nesties";
|
|
3680
|
+
import { REQUEST } from "@nestjs/core";
|
|
3681
|
+
|
|
3682
|
+
// src/utility/create-dynamic-fetcher-proxy.ts
|
|
3683
|
+
var createDynamicFetcherProxy = (initial, fetcher) => {
|
|
3684
|
+
return new Proxy(initial, {
|
|
3685
|
+
get(_target, prop, receiver) {
|
|
3686
|
+
const current = fetcher();
|
|
3687
|
+
const value = Reflect.get(current, prop, receiver);
|
|
3688
|
+
if (typeof value === "function") {
|
|
3689
|
+
return value.bind(current);
|
|
3690
|
+
}
|
|
3691
|
+
return value;
|
|
3692
|
+
},
|
|
3693
|
+
set(_target, prop, value, receiver) {
|
|
3694
|
+
const current = fetcher();
|
|
3695
|
+
return Reflect.set(current, prop, value, receiver);
|
|
3696
|
+
},
|
|
3697
|
+
has(_target, prop) {
|
|
3698
|
+
const current = fetcher();
|
|
3699
|
+
return Reflect.has(current, prop);
|
|
3700
|
+
},
|
|
3701
|
+
ownKeys(_target) {
|
|
3702
|
+
const current = fetcher();
|
|
3703
|
+
return Reflect.ownKeys(current);
|
|
3704
|
+
},
|
|
3705
|
+
getOwnPropertyDescriptor(_target, prop) {
|
|
3706
|
+
const current = fetcher();
|
|
3707
|
+
return Reflect.getOwnPropertyDescriptor(current, prop);
|
|
3708
|
+
},
|
|
3709
|
+
defineProperty(_target, prop, descriptor) {
|
|
3710
|
+
const current = fetcher();
|
|
3711
|
+
return Reflect.defineProperty(current, prop, descriptor);
|
|
3712
|
+
},
|
|
3713
|
+
deleteProperty(_target, prop) {
|
|
3714
|
+
const current = fetcher();
|
|
3715
|
+
return Reflect.deleteProperty(current, prop);
|
|
3716
|
+
}
|
|
3717
|
+
});
|
|
3718
|
+
};
|
|
3719
|
+
|
|
3720
|
+
// src/utility/create-inject-from-token-factory.ts
|
|
3721
|
+
import { Inject } from "@nestjs/common";
|
|
3722
|
+
var createInjectFromTokenFactory = (factory) => (...params) => Inject(factory(...params));
|
|
3723
|
+
|
|
3724
|
+
// src/transactional-typeorm.module.ts
|
|
3725
|
+
import { Observable } from "rxjs";
|
|
3726
|
+
var requestWeakMap = /* @__PURE__ */ new WeakMap();
|
|
3727
|
+
var normalizeDataSourceToken = (token) => typeof token === "string" ? token : token.name || token.toString();
|
|
3728
|
+
var TransactionalTypeOrmInterceptor = (dataSource) => {
|
|
3729
|
+
const token = (0, import_typeorm8.getEntityManagerToken)(dataSource);
|
|
3730
|
+
const interceptorClass = class SpecificTransactionalTypeOrmInterceptor {
|
|
3731
|
+
constructor(entityManager) {
|
|
3732
|
+
this.entityManager = entityManager;
|
|
3733
|
+
}
|
|
3734
|
+
intercept(context, next) {
|
|
3735
|
+
const request = context.switchToHttp().getRequest();
|
|
3736
|
+
return new Observable((observer) => {
|
|
3737
|
+
let innerSub = null;
|
|
3738
|
+
let finished = false;
|
|
3739
|
+
let abort;
|
|
3740
|
+
const aborted = new Promise((_6, reject) => {
|
|
3741
|
+
abort = reject;
|
|
3742
|
+
});
|
|
3743
|
+
const run = this.entityManager.transaction(async (txEm) => {
|
|
3744
|
+
requestWeakMap.set(request, txEm);
|
|
3745
|
+
const completion = new Promise((resolve, reject) => {
|
|
3746
|
+
innerSub = next.handle().subscribe({
|
|
3747
|
+
next: (v) => observer.next(v),
|
|
3748
|
+
error: (err) => {
|
|
3749
|
+
finished = true;
|
|
3750
|
+
observer.error(err);
|
|
3751
|
+
reject(err);
|
|
3752
|
+
},
|
|
3753
|
+
complete: () => {
|
|
3754
|
+
finished = true;
|
|
3755
|
+
observer.complete();
|
|
3756
|
+
resolve();
|
|
3757
|
+
}
|
|
3758
|
+
});
|
|
3759
|
+
});
|
|
3760
|
+
await Promise.race([completion, aborted]);
|
|
3761
|
+
}).finally(() => {
|
|
3762
|
+
requestWeakMap.delete(request);
|
|
3763
|
+
}).catch((err) => {
|
|
3764
|
+
if (!finished) observer.error(err);
|
|
3765
|
+
});
|
|
3766
|
+
return () => {
|
|
3767
|
+
try {
|
|
3768
|
+
innerSub?.unsubscribe();
|
|
3769
|
+
} finally {
|
|
3770
|
+
if (!finished) {
|
|
3771
|
+
abort(new Error("Request aborted / subscription unsubscribed"));
|
|
3772
|
+
}
|
|
3773
|
+
}
|
|
3774
|
+
};
|
|
3775
|
+
});
|
|
3776
|
+
}
|
|
3777
|
+
};
|
|
3778
|
+
Object.defineProperty(interceptorClass, "name", {
|
|
3779
|
+
value: `TransactionalTypeOrmInterceptor_${normalizeDataSourceToken(token)}`
|
|
3780
|
+
});
|
|
3781
|
+
Reflect.defineMetadata(
|
|
3782
|
+
"design:paramtypes",
|
|
3783
|
+
[EntityManager],
|
|
3784
|
+
interceptorClass
|
|
3785
|
+
);
|
|
3786
|
+
Inject2(token)(interceptorClass.prototype, void 0, 0);
|
|
3787
|
+
Injectable()(interceptorClass);
|
|
3788
|
+
return interceptorClass;
|
|
3789
|
+
};
|
|
3790
|
+
var getTransactionalEntityManagerToken = (dataSource) => `Transactional${normalizeDataSourceToken((0, import_typeorm8.getEntityManagerToken)(dataSource))}`;
|
|
3791
|
+
var getTransactionalEntityManagerProvider = (dataSource) => createProvider(
|
|
3792
|
+
{
|
|
3793
|
+
provide: getTransactionalEntityManagerToken(dataSource),
|
|
3794
|
+
inject: [(0, import_typeorm8.getEntityManagerToken)(dataSource), REQUEST],
|
|
3795
|
+
scope: Scope.REQUEST
|
|
3796
|
+
},
|
|
3797
|
+
(entityManager, request) => {
|
|
3798
|
+
if (requestWeakMap.has(request)) {
|
|
3799
|
+
return requestWeakMap.get(request);
|
|
3800
|
+
}
|
|
3801
|
+
return createDynamicFetcherProxy(
|
|
3802
|
+
entityManager,
|
|
3803
|
+
() => requestWeakMap.get(request) || entityManager
|
|
3804
|
+
);
|
|
3805
|
+
}
|
|
3806
|
+
);
|
|
3807
|
+
var InjectTransactionalEntityManager = createInjectFromTokenFactory(
|
|
3808
|
+
getTransactionalEntityManagerToken
|
|
3809
|
+
);
|
|
3810
|
+
var getTransactionalRepositoryToken = (entity, dataSource) => `Transactional${normalizeDataSourceToken(
|
|
3811
|
+
(0, import_typeorm8.getEntityManagerToken)(dataSource)
|
|
3812
|
+
)}Repository_${entity.name || entity.toString()}`;
|
|
3813
|
+
var getTransactionalRepositoryProvider = (entity, dataSource) => createProvider(
|
|
3814
|
+
{
|
|
3815
|
+
provide: getTransactionalRepositoryToken(entity, dataSource),
|
|
3816
|
+
inject: [(0, import_typeorm8.getEntityManagerToken)(dataSource), REQUEST],
|
|
3817
|
+
scope: Scope.REQUEST
|
|
3818
|
+
},
|
|
3819
|
+
(entityManager, req) => {
|
|
3820
|
+
if (requestWeakMap.has(req)) {
|
|
3821
|
+
const transactionalEntityManager = requestWeakMap.get(req);
|
|
3822
|
+
return transactionalEntityManager.getRepository(entity);
|
|
3823
|
+
}
|
|
3824
|
+
return createDynamicFetcherProxy(
|
|
3825
|
+
entityManager.getRepository(entity),
|
|
3826
|
+
() => {
|
|
3827
|
+
const transactionalEntityManager = requestWeakMap.get(req) || entityManager;
|
|
3828
|
+
return transactionalEntityManager.getRepository(entity);
|
|
3829
|
+
}
|
|
3830
|
+
);
|
|
3831
|
+
}
|
|
3832
|
+
);
|
|
3833
|
+
var InjectTransactionalRepository = createInjectFromTokenFactory(
|
|
3834
|
+
getTransactionalRepositoryToken
|
|
3835
|
+
);
|
|
3836
|
+
var TransactionalTypeOrmModule = class {
|
|
3837
|
+
static forFeature(entities, dataSource) {
|
|
3838
|
+
const entityArray = Array.isArray(entities) ? entities : [entities];
|
|
3839
|
+
const providers = [
|
|
3840
|
+
getTransactionalEntityManagerProvider(dataSource),
|
|
3841
|
+
...entityArray.map(
|
|
3842
|
+
(entity) => getTransactionalRepositoryProvider(entity, dataSource)
|
|
3843
|
+
)
|
|
3844
|
+
];
|
|
3845
|
+
const moduleImports = entityArray.length ? [import_typeorm8.TypeOrmModule.forFeature(entityArray, dataSource)] : [];
|
|
3846
|
+
const moduleExports = [...providers, ...moduleImports];
|
|
3847
|
+
return {
|
|
3848
|
+
module: TransactionalTypeOrmModule,
|
|
3849
|
+
imports: moduleImports,
|
|
3850
|
+
providers,
|
|
3851
|
+
exports: moduleExports
|
|
3852
|
+
};
|
|
3853
|
+
}
|
|
3854
|
+
};
|
|
3855
|
+
TransactionalTypeOrmModule = __decorateClass([
|
|
3856
|
+
Module({})
|
|
3857
|
+
], TransactionalTypeOrmModule);
|
|
3102
3858
|
export {
|
|
3103
3859
|
BindingColumn,
|
|
3104
3860
|
BindingValue,
|
|
@@ -3127,6 +3883,8 @@ export {
|
|
|
3127
3883
|
ImportDataDto,
|
|
3128
3884
|
ImportEntryBaseDto,
|
|
3129
3885
|
ImportEntryDto,
|
|
3886
|
+
InjectTransactionalEntityManager,
|
|
3887
|
+
InjectTransactionalRepository,
|
|
3130
3888
|
Inner,
|
|
3131
3889
|
IntColumn,
|
|
3132
3890
|
InternalColumn,
|
|
@@ -3174,6 +3932,8 @@ export {
|
|
|
3174
3932
|
StringJsonColumn,
|
|
3175
3933
|
TextColumn,
|
|
3176
3934
|
TimeBase,
|
|
3935
|
+
TransactionalTypeOrmInterceptor,
|
|
3936
|
+
TransactionalTypeOrmModule,
|
|
3177
3937
|
UuidColumn,
|
|
3178
3938
|
applyQueryMatchBoolean,
|
|
3179
3939
|
applyQueryMatchBooleanMySQL,
|
|
@@ -3186,6 +3946,10 @@ export {
|
|
|
3186
3946
|
createQueryCondition,
|
|
3187
3947
|
createQueryOperator,
|
|
3188
3948
|
createQueryOperatorArrayify,
|
|
3189
|
-
createQueryWrap
|
|
3949
|
+
createQueryWrap,
|
|
3950
|
+
getTransactionalEntityManagerProvider,
|
|
3951
|
+
getTransactionalEntityManagerToken,
|
|
3952
|
+
getTransactionalRepositoryProvider,
|
|
3953
|
+
getTransactionalRepositoryToken
|
|
3190
3954
|
};
|
|
3191
3955
|
//# sourceMappingURL=index.mjs.map
|