@7365admin1/core 2.78.0 → 2.80.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/index.d.ts +65 -4
- package/dist/index.js +364 -138
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +361 -136
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -73,6 +73,7 @@ __export(src_exports, {
|
|
|
73
73
|
MBulletinVideo: () => MBulletinVideo,
|
|
74
74
|
MCategoryPreloved: () => MCategoryPreloved,
|
|
75
75
|
MChat: () => MChat,
|
|
76
|
+
MChatPreloved: () => MChatPreloved,
|
|
76
77
|
MCustomer: () => MCustomer,
|
|
77
78
|
MCustomerSite: () => MCustomerSite,
|
|
78
79
|
MDocumentManagement: () => MDocumentManagement,
|
|
@@ -217,6 +218,7 @@ __export(src_exports, {
|
|
|
217
218
|
schemaBulletinBoard: () => schemaBulletinBoard,
|
|
218
219
|
schemaBulletinVideo: () => schemaBulletinVideo,
|
|
219
220
|
schemaCategoryPreloved: () => schemaCategoryPreloved,
|
|
221
|
+
schemaChatPreloved: () => schemaChatPreloved,
|
|
220
222
|
schemaCustomerSite: () => schemaCustomerSite,
|
|
221
223
|
schemaDocumentManagement: () => schemaDocumentManagement,
|
|
222
224
|
schemaEntryPassSettings: () => schemaEntryPassSettings,
|
|
@@ -324,6 +326,8 @@ __export(src_exports, {
|
|
|
324
326
|
useCategoryPrelovedController: () => useCategoryPrelovedController,
|
|
325
327
|
useCategoryPrelovedRepo: () => useCategoryPrelovedRepo,
|
|
326
328
|
useChatController: () => useChatController,
|
|
329
|
+
useChatPrelovedController: () => useChatPrelovedController,
|
|
330
|
+
useChatPrelovedRepo: () => useChatPrelovedRepo,
|
|
327
331
|
useChatRepo: () => useChatRepo,
|
|
328
332
|
useCounterModel: () => useCounterModel,
|
|
329
333
|
useCounterRepo: () => useCounterRepo,
|
|
@@ -15972,13 +15976,15 @@ function useVehicleRepo() {
|
|
|
15972
15976
|
sort = {},
|
|
15973
15977
|
type = "",
|
|
15974
15978
|
category = "",
|
|
15975
|
-
status = ""
|
|
15979
|
+
status = "",
|
|
15980
|
+
site = ""
|
|
15976
15981
|
}) {
|
|
15977
15982
|
page = page > 0 ? page - 1 : 0;
|
|
15978
15983
|
const baseQuery = {
|
|
15979
15984
|
...status && { status },
|
|
15980
15985
|
...type && { type },
|
|
15981
|
-
...category && { category }
|
|
15986
|
+
...category && { category },
|
|
15987
|
+
...site && { site: new import_mongodb42.ObjectId(site) }
|
|
15982
15988
|
};
|
|
15983
15989
|
let query = { ...baseQuery };
|
|
15984
15990
|
if (search)
|
|
@@ -16011,6 +16017,7 @@ function useVehicleRepo() {
|
|
|
16011
16017
|
recNo: 1,
|
|
16012
16018
|
nric: 1,
|
|
16013
16019
|
plateNumber: 1,
|
|
16020
|
+
site: 1,
|
|
16014
16021
|
createdAt: 1,
|
|
16015
16022
|
updatedAt: 1
|
|
16016
16023
|
}
|
|
@@ -16040,6 +16047,7 @@ function useVehicleRepo() {
|
|
|
16040
16047
|
unit: { $first: "$unit" },
|
|
16041
16048
|
unitName: { $first: "$unitName" },
|
|
16042
16049
|
nric: { $first: "$nric" },
|
|
16050
|
+
site: { $first: "$site" },
|
|
16043
16051
|
createdAt: { $min: "$createdAt" },
|
|
16044
16052
|
updatedAt: { $max: "$updatedAt" },
|
|
16045
16053
|
plates: {
|
|
@@ -16066,6 +16074,7 @@ function useVehicleRepo() {
|
|
|
16066
16074
|
unit: 1,
|
|
16067
16075
|
unitName: 1,
|
|
16068
16076
|
nric: 1,
|
|
16077
|
+
site: 1,
|
|
16069
16078
|
plates: {
|
|
16070
16079
|
$filter: {
|
|
16071
16080
|
input: "$plates",
|
|
@@ -23224,7 +23233,8 @@ function useVehicleController() {
|
|
|
23224
23233
|
order: import_joi48.default.string().optional().valid(...Object.values(SortOrder)),
|
|
23225
23234
|
type: import_joi48.default.string().optional().valid(...Object.values(VehicleType)).allow(null, ""),
|
|
23226
23235
|
category: import_joi48.default.string().optional().valid(...Object.values(VehicleCategory)).allow(null, ""),
|
|
23227
|
-
status: import_joi48.default.string().optional().valid(...Object.values(VehicleStatus)).allow(null, "")
|
|
23236
|
+
status: import_joi48.default.string().optional().valid(...Object.values(VehicleStatus)).allow(null, ""),
|
|
23237
|
+
site: import_joi48.default.string().hex().length(24).optional().allow(null, "")
|
|
23228
23238
|
});
|
|
23229
23239
|
const { error, value } = schema2.validate(req.query, {
|
|
23230
23240
|
abortEarly: false
|
|
@@ -23235,7 +23245,7 @@ function useVehicleController() {
|
|
|
23235
23245
|
next(new import_node_server_utils91.BadRequestError(messages));
|
|
23236
23246
|
return;
|
|
23237
23247
|
}
|
|
23238
|
-
const { search, page, limit, type, category, status, sort, order } = value;
|
|
23248
|
+
const { search, page, limit, type, category, status, sort, order, site } = value;
|
|
23239
23249
|
let sortObj;
|
|
23240
23250
|
if (sort === "updatedAt" /* UPDATED_AT */) {
|
|
23241
23251
|
sortObj = order === "asc" /* ASC */ ? { updatedAt: 1, createdAt: 1, _id: 1 } : { updatedAt: -1, createdAt: -1, _id: -1 };
|
|
@@ -23252,7 +23262,8 @@ function useVehicleController() {
|
|
|
23252
23262
|
// sort: sortObj,
|
|
23253
23263
|
type,
|
|
23254
23264
|
category,
|
|
23255
|
-
status
|
|
23265
|
+
status,
|
|
23266
|
+
site
|
|
23256
23267
|
});
|
|
23257
23268
|
res.json(data);
|
|
23258
23269
|
return;
|
|
@@ -32699,19 +32710,19 @@ function useDocumentManagementRepo() {
|
|
|
32699
32710
|
parentId = ""
|
|
32700
32711
|
}) {
|
|
32701
32712
|
page = page > 0 ? page - 1 : 0;
|
|
32713
|
+
const query = {
|
|
32714
|
+
status: { $ne: "deleted" }
|
|
32715
|
+
};
|
|
32716
|
+
const cacheOptions = {
|
|
32717
|
+
page,
|
|
32718
|
+
limit
|
|
32719
|
+
};
|
|
32702
32720
|
try {
|
|
32703
|
-
site = new import_mongodb80.ObjectId(site);
|
|
32721
|
+
query.site = new import_mongodb80.ObjectId(site);
|
|
32722
|
+
cacheOptions.site = site?.toString();
|
|
32704
32723
|
} catch (error) {
|
|
32705
32724
|
throw new import_node_server_utils136.BadRequestError("Invalid site ID format.");
|
|
32706
32725
|
}
|
|
32707
|
-
const cacheOptions = {
|
|
32708
|
-
page,
|
|
32709
|
-
limit,
|
|
32710
|
-
site: site?.toString()
|
|
32711
|
-
};
|
|
32712
|
-
const query = {
|
|
32713
|
-
status: { $ne: "deleted" }
|
|
32714
|
-
};
|
|
32715
32726
|
if (type && type !== "all") {
|
|
32716
32727
|
query.type = type;
|
|
32717
32728
|
cacheOptions.type = type;
|
|
@@ -56956,14 +56967,29 @@ function useCategoryPrelovedRepo() {
|
|
|
56956
56967
|
throw new import_node_server_utils241.InternalServerError("Unable to update category.");
|
|
56957
56968
|
return "Category updated successfully.";
|
|
56958
56969
|
}
|
|
56959
|
-
|
|
56970
|
+
async function deleteById(_id) {
|
|
56971
|
+
let objectId2;
|
|
56972
|
+
try {
|
|
56973
|
+
objectId2 = new import_mongodb138.ObjectId(_id);
|
|
56974
|
+
} catch {
|
|
56975
|
+
throw new import_node_server_utils241.BadRequestError("Invalid category ID format.");
|
|
56976
|
+
}
|
|
56977
|
+
const existing = await collection.findOne({ _id: objectId2 });
|
|
56978
|
+
if (!existing)
|
|
56979
|
+
throw new import_node_server_utils241.NotFoundError("Category not found.");
|
|
56980
|
+
const res = await collection.deleteOne({ _id: objectId2 });
|
|
56981
|
+
if (res.deletedCount === 0)
|
|
56982
|
+
throw new import_node_server_utils241.InternalServerError("Unable to delete category.");
|
|
56983
|
+
return "Category deleted successfully.";
|
|
56984
|
+
}
|
|
56985
|
+
return { getAll, getById, addCategory, updateById, deleteById };
|
|
56960
56986
|
}
|
|
56961
56987
|
|
|
56962
56988
|
// src/controllers/category-preloved.controller.ts
|
|
56963
56989
|
var import_node_server_utils242 = require("@7365admin1/node-server-utils");
|
|
56964
56990
|
var import_joi138 = __toESM(require("joi"));
|
|
56965
56991
|
function useCategoryPrelovedController() {
|
|
56966
|
-
const { getAll: _getAll, getById: _getById, addCategory: _addCategory, updateById: _updateById } = useCategoryPrelovedRepo();
|
|
56992
|
+
const { getAll: _getAll, getById: _getById, addCategory: _addCategory, updateById: _updateById, deleteById: _deleteById } = useCategoryPrelovedRepo();
|
|
56967
56993
|
async function getAll(req, res, next) {
|
|
56968
56994
|
const schema2 = import_joi138.default.object({
|
|
56969
56995
|
search: import_joi138.default.string().optional().allow("", null),
|
|
@@ -57042,7 +57068,25 @@ function useCategoryPrelovedController() {
|
|
|
57042
57068
|
next(error2);
|
|
57043
57069
|
}
|
|
57044
57070
|
}
|
|
57045
|
-
|
|
57071
|
+
async function deleteById(req, res, next) {
|
|
57072
|
+
const schema2 = import_joi138.default.object({
|
|
57073
|
+
_id: import_joi138.default.string().hex().length(24).required()
|
|
57074
|
+
});
|
|
57075
|
+
const { error, value } = schema2.validate({ _id: req.params.id });
|
|
57076
|
+
if (error) {
|
|
57077
|
+
import_node_server_utils242.logger.log({ level: "error", message: error.message });
|
|
57078
|
+
next(new import_node_server_utils242.BadRequestError(error.message));
|
|
57079
|
+
return;
|
|
57080
|
+
}
|
|
57081
|
+
try {
|
|
57082
|
+
const data = await _deleteById(value._id);
|
|
57083
|
+
res.status(200).json(data);
|
|
57084
|
+
} catch (error2) {
|
|
57085
|
+
import_node_server_utils242.logger.log({ level: "error", message: error2.message });
|
|
57086
|
+
next(error2);
|
|
57087
|
+
}
|
|
57088
|
+
}
|
|
57089
|
+
return { getAll, getById, addCategory, updateById, deleteById };
|
|
57046
57090
|
}
|
|
57047
57091
|
|
|
57048
57092
|
// src/models/subcategory-preloved.model.ts
|
|
@@ -57328,57 +57372,180 @@ function useSubcategoryPrelovedController() {
|
|
|
57328
57372
|
return { getAll, getById, addSubcategory, updateById, deleteById };
|
|
57329
57373
|
}
|
|
57330
57374
|
|
|
57331
|
-
// src/models/
|
|
57375
|
+
// src/models/chat-preloved.model.ts
|
|
57332
57376
|
var import_joi141 = __toESM(require("joi"));
|
|
57333
57377
|
var import_mongodb141 = require("mongodb");
|
|
57378
|
+
var schemaMessage = import_joi141.default.object({
|
|
57379
|
+
text: import_joi141.default.string().required(),
|
|
57380
|
+
date: import_joi141.default.date().optional().allow(null),
|
|
57381
|
+
time: import_joi141.default.string().optional().allow("", null),
|
|
57382
|
+
senderId: import_joi141.default.string().hex().length(24).required()
|
|
57383
|
+
});
|
|
57384
|
+
var schemaChatPreloved = import_joi141.default.object({
|
|
57385
|
+
channelId: import_joi141.default.string().hex().length(24).required(),
|
|
57386
|
+
senderId: import_joi141.default.string().hex().length(24).required(),
|
|
57387
|
+
postId: import_joi141.default.string().hex().length(24).optional().allow("", null),
|
|
57388
|
+
message: schemaMessage.required(),
|
|
57389
|
+
readMessage: import_joi141.default.array().items(import_joi141.default.string().hex()).optional().default([]),
|
|
57390
|
+
viewMessage: import_joi141.default.array().items(import_joi141.default.string().hex()).optional().default([]),
|
|
57391
|
+
attachments: import_joi141.default.array().items(import_joi141.default.string().hex()).optional().default([]),
|
|
57392
|
+
reactions: import_joi141.default.string().optional().allow("", null).default(""),
|
|
57393
|
+
bidId: import_joi141.default.string().hex().length(24).optional().allow("", null),
|
|
57394
|
+
edited: import_joi141.default.boolean().optional().default(false)
|
|
57395
|
+
});
|
|
57396
|
+
function toObjectId21(value, label) {
|
|
57397
|
+
if (typeof value === "string") {
|
|
57398
|
+
try {
|
|
57399
|
+
return new import_mongodb141.ObjectId(value);
|
|
57400
|
+
} catch {
|
|
57401
|
+
throw new Error(`Invalid ${label}.`);
|
|
57402
|
+
}
|
|
57403
|
+
}
|
|
57404
|
+
return value;
|
|
57405
|
+
}
|
|
57406
|
+
function MChatPreloved(value) {
|
|
57407
|
+
const { error } = schemaChatPreloved.validate(value);
|
|
57408
|
+
if (error)
|
|
57409
|
+
throw new Error(error.details[0].message);
|
|
57410
|
+
if (value.channelId)
|
|
57411
|
+
value.channelId = toObjectId21(value.channelId, "channel ID");
|
|
57412
|
+
if (value.senderId)
|
|
57413
|
+
value.senderId = toObjectId21(value.senderId, "sender ID");
|
|
57414
|
+
if (value.postId)
|
|
57415
|
+
value.postId = toObjectId21(value.postId, "post ID");
|
|
57416
|
+
if (value.bidId)
|
|
57417
|
+
value.bidId = toObjectId21(value.bidId, "bid ID");
|
|
57418
|
+
if (value.message?.senderId) {
|
|
57419
|
+
value.message.senderId = toObjectId21(value.message.senderId, "message sender ID");
|
|
57420
|
+
}
|
|
57421
|
+
if (value.readMessage?.length) {
|
|
57422
|
+
value.readMessage = value.readMessage.map((id) => toObjectId21(id, "readMessage ID"));
|
|
57423
|
+
}
|
|
57424
|
+
if (value.viewMessage?.length) {
|
|
57425
|
+
value.viewMessage = value.viewMessage.map((id) => toObjectId21(id, "viewMessage ID"));
|
|
57426
|
+
}
|
|
57427
|
+
if (value.attachments?.length) {
|
|
57428
|
+
value.attachments = value.attachments.map((id) => toObjectId21(id, "attachment ID"));
|
|
57429
|
+
}
|
|
57430
|
+
return {
|
|
57431
|
+
_id: new import_mongodb141.ObjectId(),
|
|
57432
|
+
channelId: value.channelId ?? "",
|
|
57433
|
+
senderId: value.senderId ?? "",
|
|
57434
|
+
postId: value.postId ?? null,
|
|
57435
|
+
message: {
|
|
57436
|
+
text: value.message?.text ?? "",
|
|
57437
|
+
date: value.message?.date ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
57438
|
+
time: value.message?.time ?? "",
|
|
57439
|
+
senderId: value.message?.senderId ?? ""
|
|
57440
|
+
},
|
|
57441
|
+
readMessage: value.readMessage ?? [],
|
|
57442
|
+
viewMessage: value.viewMessage ?? [],
|
|
57443
|
+
attachments: value.attachments ?? [],
|
|
57444
|
+
reactions: value.reactions ?? "",
|
|
57445
|
+
bidId: value.bidId ?? null,
|
|
57446
|
+
edited: value.edited ?? false,
|
|
57447
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
57448
|
+
updatedAt: null,
|
|
57449
|
+
deletedAt: null
|
|
57450
|
+
};
|
|
57451
|
+
}
|
|
57452
|
+
|
|
57453
|
+
// src/repositories/chat-preloved.repo.ts
|
|
57454
|
+
var import_node_server_utils245 = require("@7365admin1/node-server-utils");
|
|
57455
|
+
function useChatPrelovedRepo() {
|
|
57456
|
+
const db = import_node_server_utils245.useAtlas.getDb();
|
|
57457
|
+
if (!db)
|
|
57458
|
+
throw new import_node_server_utils245.InternalServerError("Unable to connect to server.");
|
|
57459
|
+
const CHAT_COLLECTION = "chat-preloved";
|
|
57460
|
+
const collection = db.collection(CHAT_COLLECTION);
|
|
57461
|
+
async function add(value, session) {
|
|
57462
|
+
try {
|
|
57463
|
+
const doc = MChatPreloved(value);
|
|
57464
|
+
const res = await collection.insertOne(doc, { session });
|
|
57465
|
+
return res.insertedId;
|
|
57466
|
+
} catch (error) {
|
|
57467
|
+
throw error;
|
|
57468
|
+
}
|
|
57469
|
+
}
|
|
57470
|
+
return { add };
|
|
57471
|
+
}
|
|
57472
|
+
|
|
57473
|
+
// src/controllers/chat-preloved.controller.ts
|
|
57474
|
+
var import_node_server_utils246 = require("@7365admin1/node-server-utils");
|
|
57475
|
+
function useChatPrelovedController() {
|
|
57476
|
+
const { add: _add } = useChatPrelovedRepo();
|
|
57477
|
+
async function add(req, res, next) {
|
|
57478
|
+
const { error, value } = schemaChatPreloved.validate(req.body, {
|
|
57479
|
+
abortEarly: false
|
|
57480
|
+
});
|
|
57481
|
+
if (error) {
|
|
57482
|
+
const messages = error.details.map((d) => d.message).join(", ");
|
|
57483
|
+
import_node_server_utils246.logger.log({ level: "error", message: messages });
|
|
57484
|
+
next(new import_node_server_utils246.BadRequestError(messages));
|
|
57485
|
+
return;
|
|
57486
|
+
}
|
|
57487
|
+
try {
|
|
57488
|
+
const data = await _add(value);
|
|
57489
|
+
res.status(201).json(data);
|
|
57490
|
+
} catch (error2) {
|
|
57491
|
+
import_node_server_utils246.logger.log({ level: "error", message: error2.message });
|
|
57492
|
+
next(error2);
|
|
57493
|
+
}
|
|
57494
|
+
}
|
|
57495
|
+
return { add };
|
|
57496
|
+
}
|
|
57497
|
+
|
|
57498
|
+
// src/models/online-forms-v2.model.ts
|
|
57499
|
+
var import_joi142 = __toESM(require("joi"));
|
|
57500
|
+
var import_mongodb142 = require("mongodb");
|
|
57334
57501
|
var FormEntryStatus = /* @__PURE__ */ ((FormEntryStatus2) => {
|
|
57335
57502
|
FormEntryStatus2["ACTIVE"] = "active";
|
|
57336
57503
|
FormEntryStatus2["INACTIVE"] = "inactive";
|
|
57337
57504
|
FormEntryStatus2["DELETED"] = "deleted";
|
|
57338
57505
|
return FormEntryStatus2;
|
|
57339
57506
|
})(FormEntryStatus || {});
|
|
57340
|
-
var schemaFormEntry =
|
|
57341
|
-
_id:
|
|
57342
|
-
formType:
|
|
57343
|
-
block:
|
|
57344
|
-
level:
|
|
57345
|
-
unit:
|
|
57346
|
-
name:
|
|
57347
|
-
phoneNumber:
|
|
57348
|
-
fields:
|
|
57349
|
-
|
|
57350
|
-
|
|
57351
|
-
|
|
57352
|
-
|
|
57353
|
-
|
|
57354
|
-
|
|
57507
|
+
var schemaFormEntry = import_joi142.default.object({
|
|
57508
|
+
_id: import_joi142.default.string().hex().optional().allow("", null),
|
|
57509
|
+
formType: import_joi142.default.string().required(),
|
|
57510
|
+
block: import_joi142.default.string().optional().allow(null, ""),
|
|
57511
|
+
level: import_joi142.default.string().optional().allow(null, ""),
|
|
57512
|
+
unit: import_joi142.default.string().optional().allow(null, ""),
|
|
57513
|
+
name: import_joi142.default.string().optional().allow(null, ""),
|
|
57514
|
+
phoneNumber: import_joi142.default.string().optional().allow(null, ""),
|
|
57515
|
+
fields: import_joi142.default.object().pattern(
|
|
57516
|
+
import_joi142.default.string(),
|
|
57517
|
+
import_joi142.default.alternatives().try(
|
|
57518
|
+
import_joi142.default.string(),
|
|
57519
|
+
import_joi142.default.number(),
|
|
57520
|
+
import_joi142.default.boolean(),
|
|
57521
|
+
import_joi142.default.valid(null)
|
|
57355
57522
|
)
|
|
57356
57523
|
).required(),
|
|
57357
|
-
status:
|
|
57358
|
-
org:
|
|
57359
|
-
site:
|
|
57360
|
-
createdAt:
|
|
57361
|
-
updatedAt:
|
|
57362
|
-
deletedAt:
|
|
57524
|
+
status: import_joi142.default.string().optional().allow("", null),
|
|
57525
|
+
org: import_joi142.default.string().hex().optional().allow("", null),
|
|
57526
|
+
site: import_joi142.default.string().hex().optional().allow("", null),
|
|
57527
|
+
createdAt: import_joi142.default.date().optional().allow("", null),
|
|
57528
|
+
updatedAt: import_joi142.default.date().optional().allow("", null),
|
|
57529
|
+
deletedAt: import_joi142.default.date().optional().allow("", null)
|
|
57363
57530
|
});
|
|
57364
|
-
var schemaUpdateFormEntry =
|
|
57365
|
-
_id:
|
|
57366
|
-
formType:
|
|
57367
|
-
block:
|
|
57368
|
-
level:
|
|
57369
|
-
unit:
|
|
57370
|
-
fields:
|
|
57371
|
-
|
|
57372
|
-
|
|
57373
|
-
|
|
57374
|
-
|
|
57375
|
-
|
|
57376
|
-
|
|
57531
|
+
var schemaUpdateFormEntry = import_joi142.default.object({
|
|
57532
|
+
_id: import_joi142.default.string().hex().required(),
|
|
57533
|
+
formType: import_joi142.default.string().optional().allow("", null),
|
|
57534
|
+
block: import_joi142.default.string().optional().allow(null, ""),
|
|
57535
|
+
level: import_joi142.default.string().optional().allow(null, ""),
|
|
57536
|
+
unit: import_joi142.default.string().optional().allow(null, ""),
|
|
57537
|
+
fields: import_joi142.default.object().pattern(
|
|
57538
|
+
import_joi142.default.string(),
|
|
57539
|
+
import_joi142.default.alternatives().try(
|
|
57540
|
+
import_joi142.default.string(),
|
|
57541
|
+
import_joi142.default.number(),
|
|
57542
|
+
import_joi142.default.boolean(),
|
|
57543
|
+
import_joi142.default.valid(null)
|
|
57377
57544
|
)
|
|
57378
57545
|
).optional(),
|
|
57379
|
-
status:
|
|
57380
|
-
updatedAt:
|
|
57381
|
-
deletedAt:
|
|
57546
|
+
status: import_joi142.default.string().optional().allow("", null),
|
|
57547
|
+
updatedAt: import_joi142.default.date().optional().allow("", null),
|
|
57548
|
+
deletedAt: import_joi142.default.date().optional().allow("", null)
|
|
57382
57549
|
});
|
|
57383
57550
|
function MFormEntry(value) {
|
|
57384
57551
|
const { error } = schemaFormEntry.validate(value);
|
|
@@ -57387,21 +57554,21 @@ function MFormEntry(value) {
|
|
|
57387
57554
|
}
|
|
57388
57555
|
if (value._id && typeof value._id === "string") {
|
|
57389
57556
|
try {
|
|
57390
|
-
value._id = new
|
|
57557
|
+
value._id = new import_mongodb142.ObjectId(value._id);
|
|
57391
57558
|
} catch {
|
|
57392
57559
|
throw new Error("Invalid ID.");
|
|
57393
57560
|
}
|
|
57394
57561
|
}
|
|
57395
57562
|
if (value.org && typeof value.org === "string") {
|
|
57396
57563
|
try {
|
|
57397
|
-
value.org = new
|
|
57564
|
+
value.org = new import_mongodb142.ObjectId(value.org);
|
|
57398
57565
|
} catch {
|
|
57399
57566
|
throw new Error("Invalid org ID.");
|
|
57400
57567
|
}
|
|
57401
57568
|
}
|
|
57402
57569
|
if (value.site && typeof value.site === "string") {
|
|
57403
57570
|
try {
|
|
57404
|
-
value.site = new
|
|
57571
|
+
value.site = new import_mongodb142.ObjectId(value.site);
|
|
57405
57572
|
} catch {
|
|
57406
57573
|
throw new Error("Invalid site ID.");
|
|
57407
57574
|
}
|
|
@@ -57425,16 +57592,16 @@ function MFormEntry(value) {
|
|
|
57425
57592
|
}
|
|
57426
57593
|
|
|
57427
57594
|
// src/repositories/online-forms-v2.repository.ts
|
|
57428
|
-
var
|
|
57429
|
-
var
|
|
57595
|
+
var import_node_server_utils247 = require("@7365admin1/node-server-utils");
|
|
57596
|
+
var import_mongodb143 = require("mongodb");
|
|
57430
57597
|
var online_forms_namespace_collection = "online-forms";
|
|
57431
57598
|
function useFormEntryRepo() {
|
|
57432
|
-
const db =
|
|
57599
|
+
const db = import_node_server_utils247.useAtlas.getDb();
|
|
57433
57600
|
if (!db) {
|
|
57434
|
-
throw new
|
|
57601
|
+
throw new import_node_server_utils247.InternalServerError("Unable to connect to server.");
|
|
57435
57602
|
}
|
|
57436
57603
|
const collection = db.collection(online_forms_namespace_collection);
|
|
57437
|
-
const { delNamespace, getCache, setCache } = (0,
|
|
57604
|
+
const { delNamespace, getCache, setCache } = (0, import_node_server_utils247.useCache)(
|
|
57438
57605
|
online_forms_namespace_collection
|
|
57439
57606
|
);
|
|
57440
57607
|
async function createTextIndex() {
|
|
@@ -57443,7 +57610,7 @@ function useFormEntryRepo() {
|
|
|
57443
57610
|
name: "text"
|
|
57444
57611
|
});
|
|
57445
57612
|
} catch (error) {
|
|
57446
|
-
throw new
|
|
57613
|
+
throw new import_node_server_utils247.InternalServerError(
|
|
57447
57614
|
"Failed to create text index on online form."
|
|
57448
57615
|
);
|
|
57449
57616
|
}
|
|
@@ -57453,11 +57620,11 @@ function useFormEntryRepo() {
|
|
|
57453
57620
|
value = MFormEntry(value);
|
|
57454
57621
|
const res = await collection.insertOne(value, { session });
|
|
57455
57622
|
delNamespace().then(() => {
|
|
57456
|
-
|
|
57623
|
+
import_node_server_utils247.logger.info(
|
|
57457
57624
|
`Cache cleared for namespace: ${online_forms_namespace_collection}`
|
|
57458
57625
|
);
|
|
57459
57626
|
}).catch((err) => {
|
|
57460
|
-
|
|
57627
|
+
import_node_server_utils247.logger.error(
|
|
57461
57628
|
`Failed to clear cache for namespace: ${online_forms_namespace_collection}`,
|
|
57462
57629
|
err
|
|
57463
57630
|
);
|
|
@@ -57466,7 +57633,7 @@ function useFormEntryRepo() {
|
|
|
57466
57633
|
} catch (error) {
|
|
57467
57634
|
const isDuplicated = error.message.includes("duplicate");
|
|
57468
57635
|
if (isDuplicated) {
|
|
57469
|
-
throw new
|
|
57636
|
+
throw new import_node_server_utils247.BadRequestError("Online Form already exists.");
|
|
57470
57637
|
}
|
|
57471
57638
|
throw error;
|
|
57472
57639
|
}
|
|
@@ -57492,16 +57659,16 @@ function useFormEntryRepo() {
|
|
|
57492
57659
|
};
|
|
57493
57660
|
const query = {
|
|
57494
57661
|
...status ? { $and: [{ status }, { status: { $ne: "deleted" } }] } : { status: { $ne: "deleted" } },
|
|
57495
|
-
...site && { site: new
|
|
57662
|
+
...site && { site: new import_mongodb143.ObjectId(site) },
|
|
57496
57663
|
...search && { search: [{ name: { $regex: search, $options: "i" } }] }
|
|
57497
57664
|
};
|
|
57498
|
-
const cacheKey = (0,
|
|
57665
|
+
const cacheKey = (0, import_node_server_utils247.makeCacheKey)(
|
|
57499
57666
|
online_forms_namespace_collection,
|
|
57500
57667
|
cacheOptions
|
|
57501
57668
|
);
|
|
57502
57669
|
const cachedData = await getCache(cacheKey);
|
|
57503
57670
|
if (cachedData) {
|
|
57504
|
-
|
|
57671
|
+
import_node_server_utils247.logger.info(`Cache hit for key: ${cacheKey}`);
|
|
57505
57672
|
return cachedData;
|
|
57506
57673
|
}
|
|
57507
57674
|
try {
|
|
@@ -57512,11 +57679,11 @@ function useFormEntryRepo() {
|
|
|
57512
57679
|
{ $limit: limit }
|
|
57513
57680
|
]).toArray();
|
|
57514
57681
|
const length = await collection.countDocuments(query);
|
|
57515
|
-
const data = (0,
|
|
57682
|
+
const data = (0, import_node_server_utils247.paginate)(items, page, limit, length);
|
|
57516
57683
|
setCache(cacheKey, data, 15 * 60).then(() => {
|
|
57517
|
-
|
|
57684
|
+
import_node_server_utils247.logger.info(`Cache set for key: ${cacheKey}`);
|
|
57518
57685
|
}).catch((err) => {
|
|
57519
|
-
|
|
57686
|
+
import_node_server_utils247.logger.error(`Failed to set cache for key: ${cacheKey}`, err);
|
|
57520
57687
|
});
|
|
57521
57688
|
return data;
|
|
57522
57689
|
} catch (error) {
|
|
@@ -57524,27 +57691,27 @@ function useFormEntryRepo() {
|
|
|
57524
57691
|
}
|
|
57525
57692
|
}
|
|
57526
57693
|
async function getFormEntryById(_id) {
|
|
57527
|
-
const cacheKey = (0,
|
|
57694
|
+
const cacheKey = (0, import_node_server_utils247.makeCacheKey)(online_forms_namespace_collection, { _id });
|
|
57528
57695
|
const cachedData = await getCache(cacheKey);
|
|
57529
57696
|
if (cachedData) {
|
|
57530
|
-
|
|
57697
|
+
import_node_server_utils247.logger.info(`Cache hit for key: ${cacheKey}`);
|
|
57531
57698
|
return cachedData;
|
|
57532
57699
|
}
|
|
57533
57700
|
try {
|
|
57534
|
-
_id = new
|
|
57701
|
+
_id = new import_mongodb143.ObjectId(_id);
|
|
57535
57702
|
} catch (error) {
|
|
57536
|
-
throw new
|
|
57703
|
+
throw new import_node_server_utils247.BadRequestError("Invalid online form ID format.");
|
|
57537
57704
|
}
|
|
57538
57705
|
const query = { _id, status: { $ne: "deleted" } };
|
|
57539
57706
|
try {
|
|
57540
57707
|
const [data] = await collection.aggregate([{ $match: query }]).toArray();
|
|
57541
57708
|
if (!data) {
|
|
57542
|
-
throw new
|
|
57709
|
+
throw new import_node_server_utils247.NotFoundError("Document not found.");
|
|
57543
57710
|
}
|
|
57544
57711
|
setCache(cacheKey, data, 15 * 60).then(() => {
|
|
57545
|
-
|
|
57712
|
+
import_node_server_utils247.logger.info(`Cache set for key: ${cacheKey}`);
|
|
57546
57713
|
}).catch((err) => {
|
|
57547
|
-
|
|
57714
|
+
import_node_server_utils247.logger.error(`Failed to set cache for key: ${cacheKey}`, err);
|
|
57548
57715
|
});
|
|
57549
57716
|
return data;
|
|
57550
57717
|
} catch (error) {
|
|
@@ -57553,9 +57720,9 @@ function useFormEntryRepo() {
|
|
|
57553
57720
|
}
|
|
57554
57721
|
async function updateFormEntryById(_id, value) {
|
|
57555
57722
|
try {
|
|
57556
|
-
_id = new
|
|
57723
|
+
_id = new import_mongodb143.ObjectId(_id);
|
|
57557
57724
|
} catch (error) {
|
|
57558
|
-
throw new
|
|
57725
|
+
throw new import_node_server_utils247.BadRequestError("Invalid online form ID format.");
|
|
57559
57726
|
}
|
|
57560
57727
|
try {
|
|
57561
57728
|
const updateValue = {
|
|
@@ -57564,14 +57731,14 @@ function useFormEntryRepo() {
|
|
|
57564
57731
|
};
|
|
57565
57732
|
const res = await collection.updateOne({ _id }, { $set: updateValue });
|
|
57566
57733
|
if (res.modifiedCount === 0) {
|
|
57567
|
-
throw new
|
|
57734
|
+
throw new import_node_server_utils247.InternalServerError("Unable to update online form.");
|
|
57568
57735
|
}
|
|
57569
57736
|
delNamespace().then(() => {
|
|
57570
|
-
|
|
57737
|
+
import_node_server_utils247.logger.info(
|
|
57571
57738
|
`Cache cleared for namespace: ${online_forms_namespace_collection}`
|
|
57572
57739
|
);
|
|
57573
57740
|
}).catch((err) => {
|
|
57574
|
-
|
|
57741
|
+
import_node_server_utils247.logger.error(
|
|
57575
57742
|
`Failed to clear cache for namespace: ${online_forms_namespace_collection}`,
|
|
57576
57743
|
err
|
|
57577
57744
|
);
|
|
@@ -57581,18 +57748,52 @@ function useFormEntryRepo() {
|
|
|
57581
57748
|
throw error;
|
|
57582
57749
|
}
|
|
57583
57750
|
}
|
|
57751
|
+
async function deleteOnlineFormById(_id, session) {
|
|
57752
|
+
try {
|
|
57753
|
+
_id = new import_mongodb143.ObjectId(_id);
|
|
57754
|
+
} catch (error) {
|
|
57755
|
+
throw new import_node_server_utils247.BadRequestError("Invalid online form ID format.");
|
|
57756
|
+
}
|
|
57757
|
+
try {
|
|
57758
|
+
const updateValue = {
|
|
57759
|
+
status: "deleted",
|
|
57760
|
+
updatedAt: /* @__PURE__ */ new Date(),
|
|
57761
|
+
deletedAt: /* @__PURE__ */ new Date()
|
|
57762
|
+
};
|
|
57763
|
+
const res = await collection.updateOne(
|
|
57764
|
+
{ _id },
|
|
57765
|
+
{ $set: updateValue },
|
|
57766
|
+
{ session }
|
|
57767
|
+
);
|
|
57768
|
+
if (res.modifiedCount === 0) {
|
|
57769
|
+
throw new import_node_server_utils247.InternalServerError("Unable to delete online form.");
|
|
57770
|
+
}
|
|
57771
|
+
delNamespace().then(() => {
|
|
57772
|
+
import_node_server_utils247.logger.info(`Cache cleared for namespace: ${online_forms_namespace_collection}`);
|
|
57773
|
+
}).catch((err) => {
|
|
57774
|
+
import_node_server_utils247.logger.error(
|
|
57775
|
+
`Failed to clear cache for namespace: ${online_forms_namespace_collection}`,
|
|
57776
|
+
err
|
|
57777
|
+
);
|
|
57778
|
+
});
|
|
57779
|
+
return res.modifiedCount;
|
|
57780
|
+
} catch (error) {
|
|
57781
|
+
throw new Error(error.message);
|
|
57782
|
+
}
|
|
57783
|
+
}
|
|
57584
57784
|
return {
|
|
57585
57785
|
add,
|
|
57586
57786
|
getAll,
|
|
57587
57787
|
getFormEntryById,
|
|
57588
57788
|
updateFormEntryById,
|
|
57589
|
-
createTextIndex
|
|
57789
|
+
createTextIndex,
|
|
57790
|
+
deleteOnlineFormById
|
|
57590
57791
|
};
|
|
57591
57792
|
}
|
|
57592
57793
|
|
|
57593
57794
|
// src/controllers/online-forms-v2.controller.ts
|
|
57594
|
-
var
|
|
57595
|
-
var
|
|
57795
|
+
var import_node_server_utils248 = require("@7365admin1/node-server-utils");
|
|
57796
|
+
var import_joi143 = __toESM(require("joi"));
|
|
57596
57797
|
var import_exceljs3 = __toESM(require("exceljs"));
|
|
57597
57798
|
var import_fs6 = __toESM(require("fs"));
|
|
57598
57799
|
function useFormEntryController() {
|
|
@@ -57600,7 +57801,8 @@ function useFormEntryController() {
|
|
|
57600
57801
|
add: _add,
|
|
57601
57802
|
getAll: _getAll,
|
|
57602
57803
|
getFormEntryById: _getFormEntryById,
|
|
57603
|
-
updateFormEntryById: _updateFormEntryById
|
|
57804
|
+
updateFormEntryById: _updateFormEntryById,
|
|
57805
|
+
deleteOnlineFormById: _deleteOnlineFormById
|
|
57604
57806
|
} = useFormEntryRepo();
|
|
57605
57807
|
function toCamelCase(str) {
|
|
57606
57808
|
return str.replace(/\s(.)/g, (_, char) => char.toUpperCase()).replace(/\s+/g, "").replace(/^(.)/, (_, char) => char.toLowerCase());
|
|
@@ -57615,14 +57817,14 @@ function useFormEntryController() {
|
|
|
57615
57817
|
async function uploadFormEntrys(req, res, next) {
|
|
57616
57818
|
try {
|
|
57617
57819
|
if (!req.file) {
|
|
57618
|
-
next(new
|
|
57820
|
+
next(new import_node_server_utils248.BadRequestError("Excel file is required."));
|
|
57619
57821
|
return;
|
|
57620
57822
|
}
|
|
57621
57823
|
const workbook = new import_exceljs3.default.Workbook();
|
|
57622
57824
|
await workbook.xlsx.readFile(req.file.path);
|
|
57623
57825
|
const worksheet = workbook.worksheets[0];
|
|
57624
57826
|
if (!worksheet) {
|
|
57625
|
-
next(new
|
|
57827
|
+
next(new import_node_server_utils248.BadRequestError("No worksheet found in uploaded Excel file."));
|
|
57626
57828
|
return;
|
|
57627
57829
|
}
|
|
57628
57830
|
const headerRow = worksheet.getRow(1);
|
|
@@ -57650,8 +57852,8 @@ function useFormEntryController() {
|
|
|
57650
57852
|
});
|
|
57651
57853
|
if (error) {
|
|
57652
57854
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
57653
|
-
|
|
57654
|
-
next(new
|
|
57855
|
+
import_node_server_utils248.logger.log({ level: "error", message: messages });
|
|
57856
|
+
next(new import_node_server_utils248.BadRequestError(messages));
|
|
57655
57857
|
return;
|
|
57656
57858
|
}
|
|
57657
57859
|
const result = await _add(value);
|
|
@@ -57659,25 +57861,25 @@ function useFormEntryController() {
|
|
|
57659
57861
|
import_fs6.default.unlink(req.file.path, () => {
|
|
57660
57862
|
});
|
|
57661
57863
|
} catch (error) {
|
|
57662
|
-
|
|
57864
|
+
import_node_server_utils248.logger.log({ level: "error", message: error.message });
|
|
57663
57865
|
next(error);
|
|
57664
57866
|
}
|
|
57665
57867
|
}
|
|
57666
57868
|
async function getAll(req, res, next) {
|
|
57667
57869
|
try {
|
|
57668
|
-
const schema2 =
|
|
57669
|
-
search:
|
|
57670
|
-
page:
|
|
57671
|
-
limit:
|
|
57672
|
-
status:
|
|
57673
|
-
org:
|
|
57674
|
-
site:
|
|
57870
|
+
const schema2 = import_joi143.default.object({
|
|
57871
|
+
search: import_joi143.default.string().optional().allow("", null),
|
|
57872
|
+
page: import_joi143.default.number().integer().min(1).allow("", null).default(1),
|
|
57873
|
+
limit: import_joi143.default.number().integer().min(1).max(100).allow("", null).default(10),
|
|
57874
|
+
status: import_joi143.default.string().optional().allow(null, ""),
|
|
57875
|
+
org: import_joi143.default.string().hex().optional().allow("", null),
|
|
57876
|
+
site: import_joi143.default.string().hex().optional().allow("", null)
|
|
57675
57877
|
});
|
|
57676
57878
|
const { error, value } = schema2.validate(req.query);
|
|
57677
57879
|
if (error) {
|
|
57678
57880
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
57679
|
-
|
|
57680
|
-
next(new
|
|
57881
|
+
import_node_server_utils248.logger.log({ level: "error", message: messages });
|
|
57882
|
+
next(new import_node_server_utils248.BadRequestError(messages));
|
|
57681
57883
|
return;
|
|
57682
57884
|
}
|
|
57683
57885
|
const { search, page, limit, status, org, site } = value;
|
|
@@ -57685,21 +57887,21 @@ function useFormEntryController() {
|
|
|
57685
57887
|
res.json(data);
|
|
57686
57888
|
return;
|
|
57687
57889
|
} catch (error) {
|
|
57688
|
-
|
|
57890
|
+
import_node_server_utils248.logger.log({ level: "error", message: error.message });
|
|
57689
57891
|
next(error);
|
|
57690
57892
|
return;
|
|
57691
57893
|
}
|
|
57692
57894
|
}
|
|
57693
57895
|
async function getFormEntryById(req, res, next) {
|
|
57694
57896
|
try {
|
|
57695
|
-
const schema2 =
|
|
57696
|
-
_id:
|
|
57897
|
+
const schema2 = import_joi143.default.object({
|
|
57898
|
+
_id: import_joi143.default.string().hex().length(24).required()
|
|
57697
57899
|
});
|
|
57698
57900
|
const { error, value } = schema2.validate({ _id: req.params.id });
|
|
57699
57901
|
if (error) {
|
|
57700
57902
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
57701
|
-
|
|
57702
|
-
next(new
|
|
57903
|
+
import_node_server_utils248.logger.log({ level: "error", message: messages });
|
|
57904
|
+
next(new import_node_server_utils248.BadRequestError(messages));
|
|
57703
57905
|
return;
|
|
57704
57906
|
}
|
|
57705
57907
|
const { _id } = value;
|
|
@@ -57707,7 +57909,7 @@ function useFormEntryController() {
|
|
|
57707
57909
|
res.json(data);
|
|
57708
57910
|
return;
|
|
57709
57911
|
} catch (error) {
|
|
57710
|
-
|
|
57912
|
+
import_node_server_utils248.logger.log({ level: "error", message: error.message });
|
|
57711
57913
|
next(error);
|
|
57712
57914
|
return;
|
|
57713
57915
|
}
|
|
@@ -57720,8 +57922,8 @@ function useFormEntryController() {
|
|
|
57720
57922
|
});
|
|
57721
57923
|
if (error) {
|
|
57722
57924
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
57723
|
-
|
|
57724
|
-
next(new
|
|
57925
|
+
import_node_server_utils248.logger.log({ level: "error", message: messages });
|
|
57926
|
+
next(new import_node_server_utils248.BadRequestError(messages));
|
|
57725
57927
|
return;
|
|
57726
57928
|
}
|
|
57727
57929
|
const { _id, ...rest } = value;
|
|
@@ -57729,7 +57931,26 @@ function useFormEntryController() {
|
|
|
57729
57931
|
res.json({ message: "Successfully updated online form." });
|
|
57730
57932
|
return;
|
|
57731
57933
|
} catch (error) {
|
|
57732
|
-
|
|
57934
|
+
import_node_server_utils248.logger.log({ level: "error", message: error.message });
|
|
57935
|
+
next(error);
|
|
57936
|
+
return;
|
|
57937
|
+
}
|
|
57938
|
+
}
|
|
57939
|
+
async function deleteFormEntryById(req, res, next) {
|
|
57940
|
+
try {
|
|
57941
|
+
const validation = import_joi143.default.string().hex().required();
|
|
57942
|
+
const _id = req.params.id;
|
|
57943
|
+
const { error } = validation.validate(_id);
|
|
57944
|
+
if (error) {
|
|
57945
|
+
import_node_server_utils248.logger.log({ level: "error", message: error.message });
|
|
57946
|
+
next(new import_node_server_utils248.BadRequestError(error.message));
|
|
57947
|
+
return;
|
|
57948
|
+
}
|
|
57949
|
+
await _deleteOnlineFormById(_id);
|
|
57950
|
+
res.json({ message: "Successfully deleted online form." });
|
|
57951
|
+
return;
|
|
57952
|
+
} catch (error) {
|
|
57953
|
+
import_node_server_utils248.logger.log({ level: "error", message: error.message });
|
|
57733
57954
|
next(error);
|
|
57734
57955
|
return;
|
|
57735
57956
|
}
|
|
@@ -57738,16 +57959,17 @@ function useFormEntryController() {
|
|
|
57738
57959
|
uploadFormEntrys,
|
|
57739
57960
|
getAll,
|
|
57740
57961
|
getFormEntryById,
|
|
57741
|
-
updateFormEntryById
|
|
57962
|
+
updateFormEntryById,
|
|
57963
|
+
deleteFormEntryById
|
|
57742
57964
|
};
|
|
57743
57965
|
}
|
|
57744
57966
|
|
|
57745
57967
|
// src/services/building-level.service.ts
|
|
57746
|
-
var
|
|
57968
|
+
var import_node_server_utils249 = require("@7365admin1/node-server-utils");
|
|
57747
57969
|
function useBuildingLevelService() {
|
|
57748
57970
|
const { add: _add, updateLevelById: _updateLevelById } = useBuildingLevelRepo();
|
|
57749
57971
|
async function add(value) {
|
|
57750
|
-
const session =
|
|
57972
|
+
const session = import_node_server_utils249.useAtlas.getClient()?.startSession();
|
|
57751
57973
|
try {
|
|
57752
57974
|
session?.startTransaction();
|
|
57753
57975
|
await _add(value, session);
|
|
@@ -57761,7 +57983,7 @@ function useBuildingLevelService() {
|
|
|
57761
57983
|
}
|
|
57762
57984
|
}
|
|
57763
57985
|
async function updateLevelById(_id, value) {
|
|
57764
|
-
const session =
|
|
57986
|
+
const session = import_node_server_utils249.useAtlas.getClient()?.startSession();
|
|
57765
57987
|
try {
|
|
57766
57988
|
session?.startTransaction();
|
|
57767
57989
|
await _updateLevelById(_id, value, session);
|
|
@@ -57781,8 +58003,8 @@ function useBuildingLevelService() {
|
|
|
57781
58003
|
}
|
|
57782
58004
|
|
|
57783
58005
|
// src/controllers/building-level.controller.ts
|
|
57784
|
-
var
|
|
57785
|
-
var
|
|
58006
|
+
var import_node_server_utils250 = require("@7365admin1/node-server-utils");
|
|
58007
|
+
var import_joi144 = __toESM(require("joi"));
|
|
57786
58008
|
function useBuildingLevelController() {
|
|
57787
58009
|
const { add: _add, updateLevelById: _updateLevelById } = useBuildingLevelService();
|
|
57788
58010
|
const {
|
|
@@ -57797,8 +58019,8 @@ function useBuildingLevelController() {
|
|
|
57797
58019
|
});
|
|
57798
58020
|
if (error) {
|
|
57799
58021
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
57800
|
-
|
|
57801
|
-
next(new
|
|
58022
|
+
import_node_server_utils250.logger.log({ level: "error", message: messages });
|
|
58023
|
+
next(new import_node_server_utils250.BadRequestError(messages));
|
|
57802
58024
|
return;
|
|
57803
58025
|
}
|
|
57804
58026
|
const result = await _add(value);
|
|
@@ -57809,20 +58031,20 @@ function useBuildingLevelController() {
|
|
|
57809
58031
|
}
|
|
57810
58032
|
async function getAll(req, res, next) {
|
|
57811
58033
|
try {
|
|
57812
|
-
const validation =
|
|
57813
|
-
page:
|
|
57814
|
-
limit:
|
|
57815
|
-
search:
|
|
57816
|
-
site:
|
|
57817
|
-
status:
|
|
58034
|
+
const validation = import_joi144.default.object({
|
|
58035
|
+
page: import_joi144.default.number().min(1).optional().default(1),
|
|
58036
|
+
limit: import_joi144.default.number().min(1).optional().default(20),
|
|
58037
|
+
search: import_joi144.default.string().optional().allow("", null),
|
|
58038
|
+
site: import_joi144.default.string().hex().length(24).optional().allow("", null),
|
|
58039
|
+
status: import_joi144.default.string().valid(...Object.values(BuildingLevelStatus)).default("active" /* ACTIVE */)
|
|
57818
58040
|
});
|
|
57819
58041
|
const { error, value } = validation.validate(req.query, {
|
|
57820
58042
|
abortEarly: false
|
|
57821
58043
|
});
|
|
57822
58044
|
if (error) {
|
|
57823
58045
|
const messages = error.details.map((d) => d.message);
|
|
57824
|
-
|
|
57825
|
-
next(new
|
|
58046
|
+
import_node_server_utils250.logger.log({ level: "error", message: messages.join(", ") });
|
|
58047
|
+
next(new import_node_server_utils250.BadRequestError(messages.join(", ")));
|
|
57826
58048
|
return;
|
|
57827
58049
|
}
|
|
57828
58050
|
const { page, limit, status, site, search } = value;
|
|
@@ -57841,14 +58063,14 @@ function useBuildingLevelController() {
|
|
|
57841
58063
|
}
|
|
57842
58064
|
async function getById(req, res, next) {
|
|
57843
58065
|
try {
|
|
57844
|
-
const schema2 =
|
|
57845
|
-
id:
|
|
58066
|
+
const schema2 = import_joi144.default.object({
|
|
58067
|
+
id: import_joi144.default.string().hex().length(24).required()
|
|
57846
58068
|
});
|
|
57847
58069
|
const { error, value } = schema2.validate({ id: req.params.id });
|
|
57848
58070
|
if (error) {
|
|
57849
58071
|
const messages = error.details.map((d) => d.message);
|
|
57850
|
-
|
|
57851
|
-
next(new
|
|
58072
|
+
import_node_server_utils250.logger.log({ level: "error", message: messages.join(", ") });
|
|
58073
|
+
next(new import_node_server_utils250.BadRequestError(messages.join(", ")));
|
|
57852
58074
|
return;
|
|
57853
58075
|
}
|
|
57854
58076
|
const { id } = value;
|
|
@@ -57867,8 +58089,8 @@ function useBuildingLevelController() {
|
|
|
57867
58089
|
});
|
|
57868
58090
|
if (error) {
|
|
57869
58091
|
const messages = error.details.map((d) => d.message);
|
|
57870
|
-
|
|
57871
|
-
next(new
|
|
58092
|
+
import_node_server_utils250.logger.log({ level: "error", message: messages.join(", ") });
|
|
58093
|
+
next(new import_node_server_utils250.BadRequestError(messages.join(", ")));
|
|
57872
58094
|
return;
|
|
57873
58095
|
}
|
|
57874
58096
|
const { _id, ...rest } = value;
|
|
@@ -57880,14 +58102,14 @@ function useBuildingLevelController() {
|
|
|
57880
58102
|
}
|
|
57881
58103
|
async function deleteById(req, res, next) {
|
|
57882
58104
|
try {
|
|
57883
|
-
const schema2 =
|
|
57884
|
-
id:
|
|
58105
|
+
const schema2 = import_joi144.default.object({
|
|
58106
|
+
id: import_joi144.default.string().hex().required()
|
|
57885
58107
|
});
|
|
57886
58108
|
const { error, value } = schema2.validate({ id: req.params.id });
|
|
57887
58109
|
if (error) {
|
|
57888
58110
|
const messages = error.details.map((d) => d.message);
|
|
57889
|
-
|
|
57890
|
-
next(new
|
|
58111
|
+
import_node_server_utils250.logger.log({ level: "error", message: messages.join(", ") });
|
|
58112
|
+
next(new import_node_server_utils250.BadRequestError(messages.join(", ")));
|
|
57891
58113
|
return;
|
|
57892
58114
|
}
|
|
57893
58115
|
const { id } = value;
|
|
@@ -57951,6 +58173,7 @@ function useBuildingLevelController() {
|
|
|
57951
58173
|
MBulletinVideo,
|
|
57952
58174
|
MCategoryPreloved,
|
|
57953
58175
|
MChat,
|
|
58176
|
+
MChatPreloved,
|
|
57954
58177
|
MCustomer,
|
|
57955
58178
|
MCustomerSite,
|
|
57956
58179
|
MDocumentManagement,
|
|
@@ -58095,6 +58318,7 @@ function useBuildingLevelController() {
|
|
|
58095
58318
|
schemaBulletinBoard,
|
|
58096
58319
|
schemaBulletinVideo,
|
|
58097
58320
|
schemaCategoryPreloved,
|
|
58321
|
+
schemaChatPreloved,
|
|
58098
58322
|
schemaCustomerSite,
|
|
58099
58323
|
schemaDocumentManagement,
|
|
58100
58324
|
schemaEntryPassSettings,
|
|
@@ -58202,6 +58426,8 @@ function useBuildingLevelController() {
|
|
|
58202
58426
|
useCategoryPrelovedController,
|
|
58203
58427
|
useCategoryPrelovedRepo,
|
|
58204
58428
|
useChatController,
|
|
58429
|
+
useChatPrelovedController,
|
|
58430
|
+
useChatPrelovedRepo,
|
|
58205
58431
|
useChatRepo,
|
|
58206
58432
|
useCounterModel,
|
|
58207
58433
|
useCounterRepo,
|