elseware-nodejs 1.8.1 → 1.8.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +78 -64
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +70 -42
- package/dist/index.d.ts +70 -42
- package/dist/index.js +79 -64
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
package/dist/index.cjs
CHANGED
|
@@ -344,7 +344,8 @@ function loadEnv(options) {
|
|
|
344
344
|
handleError(result.error);
|
|
345
345
|
}
|
|
346
346
|
logger.success("Env Configurations validated");
|
|
347
|
-
|
|
347
|
+
const env = result.data;
|
|
348
|
+
return options.transform ? options.transform(env) : env;
|
|
348
349
|
}
|
|
349
350
|
function handleError(error) {
|
|
350
351
|
logger.danger("Env validation failed");
|
|
@@ -354,20 +355,17 @@ function handleError(error) {
|
|
|
354
355
|
const rawValue = key !== "unknown" ? process.env[key] : void 0;
|
|
355
356
|
const isSecret = key.toLowerCase().includes("secret");
|
|
356
357
|
const safeValue = isSecret ? "***" : rawValue;
|
|
357
|
-
const
|
|
358
|
+
const message = [
|
|
358
359
|
`message: ${err.message}`,
|
|
359
360
|
`code: ${err.code}`,
|
|
360
361
|
rawValue !== void 0 ? `value: ${JSON.stringify(safeValue)}` : null
|
|
361
|
-
].filter(Boolean);
|
|
362
|
-
const fullMessage = messageParts.join(" | ");
|
|
362
|
+
].filter(Boolean).join(" | ");
|
|
363
363
|
if (!grouped[key]) grouped[key] = [];
|
|
364
|
-
grouped[key].push(
|
|
364
|
+
grouped[key].push(message);
|
|
365
365
|
});
|
|
366
366
|
Object.entries(grouped).forEach(([key, messages]) => {
|
|
367
|
-
logger.info(
|
|
368
|
-
messages.forEach((msg) => {
|
|
369
|
-
logger.log(` - ${msg}`);
|
|
370
|
-
});
|
|
367
|
+
logger.info(key);
|
|
368
|
+
messages.forEach((msg) => logger.log(` - ${msg}`));
|
|
371
369
|
});
|
|
372
370
|
logger.danger("Application startup aborted!");
|
|
373
371
|
process.exit(1);
|
|
@@ -5177,81 +5175,98 @@ var validate = (schema) => (req, _res, next) => {
|
|
|
5177
5175
|
next();
|
|
5178
5176
|
};
|
|
5179
5177
|
|
|
5180
|
-
// src/repositories/mongo.repository.ts
|
|
5178
|
+
// src/repositories/providers/mongo.repository.ts
|
|
5181
5179
|
var BaseMongoRepository = class {
|
|
5182
5180
|
model;
|
|
5183
5181
|
constructor(model) {
|
|
5184
5182
|
this.model = model;
|
|
5185
5183
|
}
|
|
5186
|
-
|
|
5187
|
-
|
|
5188
|
-
if (
|
|
5184
|
+
buildSelect(select) {
|
|
5185
|
+
if (!select) return void 0;
|
|
5186
|
+
if (Array.isArray(select)) {
|
|
5187
|
+
return select.join(" ");
|
|
5188
|
+
}
|
|
5189
|
+
return select;
|
|
5190
|
+
}
|
|
5191
|
+
applyQueryOptions(query, options) {
|
|
5192
|
+
const select = this.buildSelect(options.select);
|
|
5193
|
+
if (select) query = query.select(select);
|
|
5189
5194
|
if (options.sort) query = query.sort(options.sort);
|
|
5190
5195
|
if (options.limit) query = query.limit(options.limit);
|
|
5191
5196
|
if (options.skip) query = query.skip(options.skip);
|
|
5192
|
-
return query
|
|
5197
|
+
return query;
|
|
5193
5198
|
}
|
|
5194
|
-
|
|
5195
|
-
return
|
|
5196
|
-
}
|
|
5197
|
-
async findOne(filter) {
|
|
5198
|
-
return this.model.findOne(filter).exec();
|
|
5199
|
+
toPlain(doc) {
|
|
5200
|
+
return doc.toObject();
|
|
5199
5201
|
}
|
|
5202
|
+
/**
|
|
5203
|
+
* Create
|
|
5204
|
+
*/
|
|
5200
5205
|
async create(data) {
|
|
5201
|
-
|
|
5206
|
+
const doc = await this.model.create(data);
|
|
5207
|
+
return this.toPlain(doc);
|
|
5202
5208
|
}
|
|
5203
|
-
async
|
|
5204
|
-
|
|
5205
|
-
|
|
5206
|
-
runValidators: true
|
|
5207
|
-
}).exec();
|
|
5209
|
+
async createMany(data) {
|
|
5210
|
+
const docs = await this.model.insertMany(data);
|
|
5211
|
+
return docs.map((doc) => this.toPlain(doc));
|
|
5208
5212
|
}
|
|
5209
|
-
|
|
5210
|
-
|
|
5213
|
+
/**
|
|
5214
|
+
* Read
|
|
5215
|
+
*/
|
|
5216
|
+
async findAll(filter = {}, options = {}) {
|
|
5217
|
+
let query = this.model.find(filter);
|
|
5218
|
+
query = this.applyQueryOptions(query, options);
|
|
5219
|
+
return query.exec();
|
|
5211
5220
|
}
|
|
5212
|
-
}
|
|
5213
|
-
|
|
5214
|
-
|
|
5215
|
-
|
|
5216
|
-
model;
|
|
5217
|
-
// prisma model (e.g. prisma.testPost)
|
|
5218
|
-
constructor(model) {
|
|
5219
|
-
this.model = model;
|
|
5221
|
+
async findById(id, options = {}) {
|
|
5222
|
+
let query = this.model.findById(id);
|
|
5223
|
+
query = this.applyQueryOptions(query, options);
|
|
5224
|
+
return query.exec();
|
|
5220
5225
|
}
|
|
5221
|
-
async
|
|
5222
|
-
|
|
5223
|
-
|
|
5224
|
-
|
|
5225
|
-
orderBy: options.sort,
|
|
5226
|
-
take: options.limit,
|
|
5227
|
-
skip: options.skip
|
|
5228
|
-
});
|
|
5226
|
+
async findOne(filter = {}, options = {}) {
|
|
5227
|
+
let query = this.model.findOne(filter);
|
|
5228
|
+
query = this.applyQueryOptions(query, options);
|
|
5229
|
+
return query.exec();
|
|
5229
5230
|
}
|
|
5230
|
-
async
|
|
5231
|
-
|
|
5232
|
-
|
|
5233
|
-
|
|
5231
|
+
async findManyByIds(ids, options = {}) {
|
|
5232
|
+
let query = this.model.find({ _id: { $in: ids } });
|
|
5233
|
+
query = this.applyQueryOptions(query, options);
|
|
5234
|
+
return query.exec();
|
|
5234
5235
|
}
|
|
5235
|
-
async
|
|
5236
|
-
return this.model.
|
|
5237
|
-
where: filter
|
|
5238
|
-
});
|
|
5236
|
+
async count(filter) {
|
|
5237
|
+
return this.model.countDocuments(filter).exec();
|
|
5239
5238
|
}
|
|
5240
|
-
async
|
|
5241
|
-
|
|
5242
|
-
|
|
5243
|
-
});
|
|
5239
|
+
async exists(filter) {
|
|
5240
|
+
const result = await this.model.exists(filter);
|
|
5241
|
+
return result !== null;
|
|
5244
5242
|
}
|
|
5245
|
-
|
|
5246
|
-
|
|
5247
|
-
|
|
5248
|
-
|
|
5249
|
-
}
|
|
5243
|
+
/**
|
|
5244
|
+
* Update
|
|
5245
|
+
*/
|
|
5246
|
+
async updateById(id, data, options) {
|
|
5247
|
+
const finalOptions = { new: true, runValidators: true, ...options };
|
|
5248
|
+
return this.model.findByIdAndUpdate(id, data, finalOptions).exec();
|
|
5249
|
+
}
|
|
5250
|
+
async updateOne(filter, data, options) {
|
|
5251
|
+
const finalOptions = { new: true, runValidators: true, ...options };
|
|
5252
|
+
return this.model.findOneAndUpdate(filter, data, finalOptions).exec();
|
|
5250
5253
|
}
|
|
5254
|
+
async updateMany(filter, data) {
|
|
5255
|
+
const result = await this.model.updateMany(filter, data).exec();
|
|
5256
|
+
return result.modifiedCount;
|
|
5257
|
+
}
|
|
5258
|
+
/**
|
|
5259
|
+
* Delete
|
|
5260
|
+
*/
|
|
5251
5261
|
async deleteById(id) {
|
|
5252
|
-
return this.model.
|
|
5253
|
-
|
|
5254
|
-
|
|
5262
|
+
return this.model.findByIdAndDelete(id).exec();
|
|
5263
|
+
}
|
|
5264
|
+
async deleteOne(filter) {
|
|
5265
|
+
return this.model.findOneAndDelete(filter).exec();
|
|
5266
|
+
}
|
|
5267
|
+
async deleteMany(filter) {
|
|
5268
|
+
const result = await this.model.deleteMany(filter).exec();
|
|
5269
|
+
return result.deletedCount ?? 0;
|
|
5255
5270
|
}
|
|
5256
5271
|
};
|
|
5257
5272
|
var AzureBlobStorageService = class {
|
|
@@ -5717,7 +5732,6 @@ exports.AzureBlobStorageService = AzureBlobStorageService;
|
|
|
5717
5732
|
exports.BPlusTree = BPlusTree;
|
|
5718
5733
|
exports.BTree = BTree;
|
|
5719
5734
|
exports.BaseMongoRepository = BaseMongoRepository;
|
|
5720
|
-
exports.BasePostgresRepository = BasePostgresRepository;
|
|
5721
5735
|
exports.BinaryHeap = BinaryHeap;
|
|
5722
5736
|
exports.BinarySearchTree = BinarySearchTree;
|
|
5723
5737
|
exports.BinaryTree = BinaryTree;
|