@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.mjs
CHANGED
|
@@ -15725,13 +15725,15 @@ function useVehicleRepo() {
|
|
|
15725
15725
|
sort = {},
|
|
15726
15726
|
type = "",
|
|
15727
15727
|
category = "",
|
|
15728
|
-
status = ""
|
|
15728
|
+
status = "",
|
|
15729
|
+
site = ""
|
|
15729
15730
|
}) {
|
|
15730
15731
|
page = page > 0 ? page - 1 : 0;
|
|
15731
15732
|
const baseQuery = {
|
|
15732
15733
|
...status && { status },
|
|
15733
15734
|
...type && { type },
|
|
15734
|
-
...category && { category }
|
|
15735
|
+
...category && { category },
|
|
15736
|
+
...site && { site: new ObjectId42(site) }
|
|
15735
15737
|
};
|
|
15736
15738
|
let query = { ...baseQuery };
|
|
15737
15739
|
if (search)
|
|
@@ -15764,6 +15766,7 @@ function useVehicleRepo() {
|
|
|
15764
15766
|
recNo: 1,
|
|
15765
15767
|
nric: 1,
|
|
15766
15768
|
plateNumber: 1,
|
|
15769
|
+
site: 1,
|
|
15767
15770
|
createdAt: 1,
|
|
15768
15771
|
updatedAt: 1
|
|
15769
15772
|
}
|
|
@@ -15793,6 +15796,7 @@ function useVehicleRepo() {
|
|
|
15793
15796
|
unit: { $first: "$unit" },
|
|
15794
15797
|
unitName: { $first: "$unitName" },
|
|
15795
15798
|
nric: { $first: "$nric" },
|
|
15799
|
+
site: { $first: "$site" },
|
|
15796
15800
|
createdAt: { $min: "$createdAt" },
|
|
15797
15801
|
updatedAt: { $max: "$updatedAt" },
|
|
15798
15802
|
plates: {
|
|
@@ -15819,6 +15823,7 @@ function useVehicleRepo() {
|
|
|
15819
15823
|
unit: 1,
|
|
15820
15824
|
unitName: 1,
|
|
15821
15825
|
nric: 1,
|
|
15826
|
+
site: 1,
|
|
15822
15827
|
plates: {
|
|
15823
15828
|
$filter: {
|
|
15824
15829
|
input: "$plates",
|
|
@@ -23035,7 +23040,8 @@ function useVehicleController() {
|
|
|
23035
23040
|
order: Joi48.string().optional().valid(...Object.values(SortOrder)),
|
|
23036
23041
|
type: Joi48.string().optional().valid(...Object.values(VehicleType)).allow(null, ""),
|
|
23037
23042
|
category: Joi48.string().optional().valid(...Object.values(VehicleCategory)).allow(null, ""),
|
|
23038
|
-
status: Joi48.string().optional().valid(...Object.values(VehicleStatus)).allow(null, "")
|
|
23043
|
+
status: Joi48.string().optional().valid(...Object.values(VehicleStatus)).allow(null, ""),
|
|
23044
|
+
site: Joi48.string().hex().length(24).optional().allow(null, "")
|
|
23039
23045
|
});
|
|
23040
23046
|
const { error, value } = schema2.validate(req.query, {
|
|
23041
23047
|
abortEarly: false
|
|
@@ -23046,7 +23052,7 @@ function useVehicleController() {
|
|
|
23046
23052
|
next(new BadRequestError87(messages));
|
|
23047
23053
|
return;
|
|
23048
23054
|
}
|
|
23049
|
-
const { search, page, limit, type, category, status, sort, order } = value;
|
|
23055
|
+
const { search, page, limit, type, category, status, sort, order, site } = value;
|
|
23050
23056
|
let sortObj;
|
|
23051
23057
|
if (sort === "updatedAt" /* UPDATED_AT */) {
|
|
23052
23058
|
sortObj = order === "asc" /* ASC */ ? { updatedAt: 1, createdAt: 1, _id: 1 } : { updatedAt: -1, createdAt: -1, _id: -1 };
|
|
@@ -23063,7 +23069,8 @@ function useVehicleController() {
|
|
|
23063
23069
|
// sort: sortObj,
|
|
23064
23070
|
type,
|
|
23065
23071
|
category,
|
|
23066
|
-
status
|
|
23072
|
+
status,
|
|
23073
|
+
site
|
|
23067
23074
|
});
|
|
23068
23075
|
res.json(data);
|
|
23069
23076
|
return;
|
|
@@ -32647,19 +32654,19 @@ function useDocumentManagementRepo() {
|
|
|
32647
32654
|
parentId = ""
|
|
32648
32655
|
}) {
|
|
32649
32656
|
page = page > 0 ? page - 1 : 0;
|
|
32657
|
+
const query = {
|
|
32658
|
+
status: { $ne: "deleted" }
|
|
32659
|
+
};
|
|
32660
|
+
const cacheOptions = {
|
|
32661
|
+
page,
|
|
32662
|
+
limit
|
|
32663
|
+
};
|
|
32650
32664
|
try {
|
|
32651
|
-
site = new ObjectId80(site);
|
|
32665
|
+
query.site = new ObjectId80(site);
|
|
32666
|
+
cacheOptions.site = site?.toString();
|
|
32652
32667
|
} catch (error) {
|
|
32653
32668
|
throw new BadRequestError126("Invalid site ID format.");
|
|
32654
32669
|
}
|
|
32655
|
-
const cacheOptions = {
|
|
32656
|
-
page,
|
|
32657
|
-
limit,
|
|
32658
|
-
site: site?.toString()
|
|
32659
|
-
};
|
|
32660
|
-
const query = {
|
|
32661
|
-
status: { $ne: "deleted" }
|
|
32662
|
-
};
|
|
32663
32670
|
if (type && type !== "all") {
|
|
32664
32671
|
query.type = type;
|
|
32665
32672
|
cacheOptions.type = type;
|
|
@@ -57219,14 +57226,29 @@ function useCategoryPrelovedRepo() {
|
|
|
57219
57226
|
throw new InternalServerError77("Unable to update category.");
|
|
57220
57227
|
return "Category updated successfully.";
|
|
57221
57228
|
}
|
|
57222
|
-
|
|
57229
|
+
async function deleteById(_id) {
|
|
57230
|
+
let objectId2;
|
|
57231
|
+
try {
|
|
57232
|
+
objectId2 = new ObjectId138(_id);
|
|
57233
|
+
} catch {
|
|
57234
|
+
throw new BadRequestError216("Invalid category ID format.");
|
|
57235
|
+
}
|
|
57236
|
+
const existing = await collection.findOne({ _id: objectId2 });
|
|
57237
|
+
if (!existing)
|
|
57238
|
+
throw new NotFoundError58("Category not found.");
|
|
57239
|
+
const res = await collection.deleteOne({ _id: objectId2 });
|
|
57240
|
+
if (res.deletedCount === 0)
|
|
57241
|
+
throw new InternalServerError77("Unable to delete category.");
|
|
57242
|
+
return "Category deleted successfully.";
|
|
57243
|
+
}
|
|
57244
|
+
return { getAll, getById, addCategory, updateById, deleteById };
|
|
57223
57245
|
}
|
|
57224
57246
|
|
|
57225
57247
|
// src/controllers/category-preloved.controller.ts
|
|
57226
57248
|
import { BadRequestError as BadRequestError217, logger as logger191 } from "@7365admin1/node-server-utils";
|
|
57227
57249
|
import Joi138 from "joi";
|
|
57228
57250
|
function useCategoryPrelovedController() {
|
|
57229
|
-
const { getAll: _getAll, getById: _getById, addCategory: _addCategory, updateById: _updateById } = useCategoryPrelovedRepo();
|
|
57251
|
+
const { getAll: _getAll, getById: _getById, addCategory: _addCategory, updateById: _updateById, deleteById: _deleteById } = useCategoryPrelovedRepo();
|
|
57230
57252
|
async function getAll(req, res, next) {
|
|
57231
57253
|
const schema2 = Joi138.object({
|
|
57232
57254
|
search: Joi138.string().optional().allow("", null),
|
|
@@ -57305,7 +57327,25 @@ function useCategoryPrelovedController() {
|
|
|
57305
57327
|
next(error2);
|
|
57306
57328
|
}
|
|
57307
57329
|
}
|
|
57308
|
-
|
|
57330
|
+
async function deleteById(req, res, next) {
|
|
57331
|
+
const schema2 = Joi138.object({
|
|
57332
|
+
_id: Joi138.string().hex().length(24).required()
|
|
57333
|
+
});
|
|
57334
|
+
const { error, value } = schema2.validate({ _id: req.params.id });
|
|
57335
|
+
if (error) {
|
|
57336
|
+
logger191.log({ level: "error", message: error.message });
|
|
57337
|
+
next(new BadRequestError217(error.message));
|
|
57338
|
+
return;
|
|
57339
|
+
}
|
|
57340
|
+
try {
|
|
57341
|
+
const data = await _deleteById(value._id);
|
|
57342
|
+
res.status(200).json(data);
|
|
57343
|
+
} catch (error2) {
|
|
57344
|
+
logger191.log({ level: "error", message: error2.message });
|
|
57345
|
+
next(error2);
|
|
57346
|
+
}
|
|
57347
|
+
}
|
|
57348
|
+
return { getAll, getById, addCategory, updateById, deleteById };
|
|
57309
57349
|
}
|
|
57310
57350
|
|
|
57311
57351
|
// src/models/subcategory-preloved.model.ts
|
|
@@ -57596,57 +57636,183 @@ function useSubcategoryPrelovedController() {
|
|
|
57596
57636
|
return { getAll, getById, addSubcategory, updateById, deleteById };
|
|
57597
57637
|
}
|
|
57598
57638
|
|
|
57599
|
-
// src/models/
|
|
57639
|
+
// src/models/chat-preloved.model.ts
|
|
57600
57640
|
import Joi141 from "joi";
|
|
57601
57641
|
import { ObjectId as ObjectId141 } from "mongodb";
|
|
57642
|
+
var schemaMessage = Joi141.object({
|
|
57643
|
+
text: Joi141.string().required(),
|
|
57644
|
+
date: Joi141.date().optional().allow(null),
|
|
57645
|
+
time: Joi141.string().optional().allow("", null),
|
|
57646
|
+
senderId: Joi141.string().hex().length(24).required()
|
|
57647
|
+
});
|
|
57648
|
+
var schemaChatPreloved = Joi141.object({
|
|
57649
|
+
channelId: Joi141.string().hex().length(24).required(),
|
|
57650
|
+
senderId: Joi141.string().hex().length(24).required(),
|
|
57651
|
+
postId: Joi141.string().hex().length(24).optional().allow("", null),
|
|
57652
|
+
message: schemaMessage.required(),
|
|
57653
|
+
readMessage: Joi141.array().items(Joi141.string().hex()).optional().default([]),
|
|
57654
|
+
viewMessage: Joi141.array().items(Joi141.string().hex()).optional().default([]),
|
|
57655
|
+
attachments: Joi141.array().items(Joi141.string().hex()).optional().default([]),
|
|
57656
|
+
reactions: Joi141.string().optional().allow("", null).default(""),
|
|
57657
|
+
bidId: Joi141.string().hex().length(24).optional().allow("", null),
|
|
57658
|
+
edited: Joi141.boolean().optional().default(false)
|
|
57659
|
+
});
|
|
57660
|
+
function toObjectId21(value, label) {
|
|
57661
|
+
if (typeof value === "string") {
|
|
57662
|
+
try {
|
|
57663
|
+
return new ObjectId141(value);
|
|
57664
|
+
} catch {
|
|
57665
|
+
throw new Error(`Invalid ${label}.`);
|
|
57666
|
+
}
|
|
57667
|
+
}
|
|
57668
|
+
return value;
|
|
57669
|
+
}
|
|
57670
|
+
function MChatPreloved(value) {
|
|
57671
|
+
const { error } = schemaChatPreloved.validate(value);
|
|
57672
|
+
if (error)
|
|
57673
|
+
throw new Error(error.details[0].message);
|
|
57674
|
+
if (value.channelId)
|
|
57675
|
+
value.channelId = toObjectId21(value.channelId, "channel ID");
|
|
57676
|
+
if (value.senderId)
|
|
57677
|
+
value.senderId = toObjectId21(value.senderId, "sender ID");
|
|
57678
|
+
if (value.postId)
|
|
57679
|
+
value.postId = toObjectId21(value.postId, "post ID");
|
|
57680
|
+
if (value.bidId)
|
|
57681
|
+
value.bidId = toObjectId21(value.bidId, "bid ID");
|
|
57682
|
+
if (value.message?.senderId) {
|
|
57683
|
+
value.message.senderId = toObjectId21(value.message.senderId, "message sender ID");
|
|
57684
|
+
}
|
|
57685
|
+
if (value.readMessage?.length) {
|
|
57686
|
+
value.readMessage = value.readMessage.map((id) => toObjectId21(id, "readMessage ID"));
|
|
57687
|
+
}
|
|
57688
|
+
if (value.viewMessage?.length) {
|
|
57689
|
+
value.viewMessage = value.viewMessage.map((id) => toObjectId21(id, "viewMessage ID"));
|
|
57690
|
+
}
|
|
57691
|
+
if (value.attachments?.length) {
|
|
57692
|
+
value.attachments = value.attachments.map((id) => toObjectId21(id, "attachment ID"));
|
|
57693
|
+
}
|
|
57694
|
+
return {
|
|
57695
|
+
_id: new ObjectId141(),
|
|
57696
|
+
channelId: value.channelId ?? "",
|
|
57697
|
+
senderId: value.senderId ?? "",
|
|
57698
|
+
postId: value.postId ?? null,
|
|
57699
|
+
message: {
|
|
57700
|
+
text: value.message?.text ?? "",
|
|
57701
|
+
date: value.message?.date ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
57702
|
+
time: value.message?.time ?? "",
|
|
57703
|
+
senderId: value.message?.senderId ?? ""
|
|
57704
|
+
},
|
|
57705
|
+
readMessage: value.readMessage ?? [],
|
|
57706
|
+
viewMessage: value.viewMessage ?? [],
|
|
57707
|
+
attachments: value.attachments ?? [],
|
|
57708
|
+
reactions: value.reactions ?? "",
|
|
57709
|
+
bidId: value.bidId ?? null,
|
|
57710
|
+
edited: value.edited ?? false,
|
|
57711
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
57712
|
+
updatedAt: null,
|
|
57713
|
+
deletedAt: null
|
|
57714
|
+
};
|
|
57715
|
+
}
|
|
57716
|
+
|
|
57717
|
+
// src/repositories/chat-preloved.repo.ts
|
|
57718
|
+
import {
|
|
57719
|
+
InternalServerError as InternalServerError79,
|
|
57720
|
+
useAtlas as useAtlas124
|
|
57721
|
+
} from "@7365admin1/node-server-utils";
|
|
57722
|
+
function useChatPrelovedRepo() {
|
|
57723
|
+
const db = useAtlas124.getDb();
|
|
57724
|
+
if (!db)
|
|
57725
|
+
throw new InternalServerError79("Unable to connect to server.");
|
|
57726
|
+
const CHAT_COLLECTION = "chat-preloved";
|
|
57727
|
+
const collection = db.collection(CHAT_COLLECTION);
|
|
57728
|
+
async function add(value, session) {
|
|
57729
|
+
try {
|
|
57730
|
+
const doc = MChatPreloved(value);
|
|
57731
|
+
const res = await collection.insertOne(doc, { session });
|
|
57732
|
+
return res.insertedId;
|
|
57733
|
+
} catch (error) {
|
|
57734
|
+
throw error;
|
|
57735
|
+
}
|
|
57736
|
+
}
|
|
57737
|
+
return { add };
|
|
57738
|
+
}
|
|
57739
|
+
|
|
57740
|
+
// src/controllers/chat-preloved.controller.ts
|
|
57741
|
+
import { BadRequestError as BadRequestError221, logger as logger193 } from "@7365admin1/node-server-utils";
|
|
57742
|
+
function useChatPrelovedController() {
|
|
57743
|
+
const { add: _add } = useChatPrelovedRepo();
|
|
57744
|
+
async function add(req, res, next) {
|
|
57745
|
+
const { error, value } = schemaChatPreloved.validate(req.body, {
|
|
57746
|
+
abortEarly: false
|
|
57747
|
+
});
|
|
57748
|
+
if (error) {
|
|
57749
|
+
const messages = error.details.map((d) => d.message).join(", ");
|
|
57750
|
+
logger193.log({ level: "error", message: messages });
|
|
57751
|
+
next(new BadRequestError221(messages));
|
|
57752
|
+
return;
|
|
57753
|
+
}
|
|
57754
|
+
try {
|
|
57755
|
+
const data = await _add(value);
|
|
57756
|
+
res.status(201).json(data);
|
|
57757
|
+
} catch (error2) {
|
|
57758
|
+
logger193.log({ level: "error", message: error2.message });
|
|
57759
|
+
next(error2);
|
|
57760
|
+
}
|
|
57761
|
+
}
|
|
57762
|
+
return { add };
|
|
57763
|
+
}
|
|
57764
|
+
|
|
57765
|
+
// src/models/online-forms-v2.model.ts
|
|
57766
|
+
import Joi142 from "joi";
|
|
57767
|
+
import { ObjectId as ObjectId142 } from "mongodb";
|
|
57602
57768
|
var FormEntryStatus = /* @__PURE__ */ ((FormEntryStatus2) => {
|
|
57603
57769
|
FormEntryStatus2["ACTIVE"] = "active";
|
|
57604
57770
|
FormEntryStatus2["INACTIVE"] = "inactive";
|
|
57605
57771
|
FormEntryStatus2["DELETED"] = "deleted";
|
|
57606
57772
|
return FormEntryStatus2;
|
|
57607
57773
|
})(FormEntryStatus || {});
|
|
57608
|
-
var schemaFormEntry =
|
|
57609
|
-
_id:
|
|
57610
|
-
formType:
|
|
57611
|
-
block:
|
|
57612
|
-
level:
|
|
57613
|
-
unit:
|
|
57614
|
-
name:
|
|
57615
|
-
phoneNumber:
|
|
57616
|
-
fields:
|
|
57617
|
-
|
|
57618
|
-
|
|
57619
|
-
|
|
57620
|
-
|
|
57621
|
-
|
|
57622
|
-
|
|
57774
|
+
var schemaFormEntry = Joi142.object({
|
|
57775
|
+
_id: Joi142.string().hex().optional().allow("", null),
|
|
57776
|
+
formType: Joi142.string().required(),
|
|
57777
|
+
block: Joi142.string().optional().allow(null, ""),
|
|
57778
|
+
level: Joi142.string().optional().allow(null, ""),
|
|
57779
|
+
unit: Joi142.string().optional().allow(null, ""),
|
|
57780
|
+
name: Joi142.string().optional().allow(null, ""),
|
|
57781
|
+
phoneNumber: Joi142.string().optional().allow(null, ""),
|
|
57782
|
+
fields: Joi142.object().pattern(
|
|
57783
|
+
Joi142.string(),
|
|
57784
|
+
Joi142.alternatives().try(
|
|
57785
|
+
Joi142.string(),
|
|
57786
|
+
Joi142.number(),
|
|
57787
|
+
Joi142.boolean(),
|
|
57788
|
+
Joi142.valid(null)
|
|
57623
57789
|
)
|
|
57624
57790
|
).required(),
|
|
57625
|
-
status:
|
|
57626
|
-
org:
|
|
57627
|
-
site:
|
|
57628
|
-
createdAt:
|
|
57629
|
-
updatedAt:
|
|
57630
|
-
deletedAt:
|
|
57791
|
+
status: Joi142.string().optional().allow("", null),
|
|
57792
|
+
org: Joi142.string().hex().optional().allow("", null),
|
|
57793
|
+
site: Joi142.string().hex().optional().allow("", null),
|
|
57794
|
+
createdAt: Joi142.date().optional().allow("", null),
|
|
57795
|
+
updatedAt: Joi142.date().optional().allow("", null),
|
|
57796
|
+
deletedAt: Joi142.date().optional().allow("", null)
|
|
57631
57797
|
});
|
|
57632
|
-
var schemaUpdateFormEntry =
|
|
57633
|
-
_id:
|
|
57634
|
-
formType:
|
|
57635
|
-
block:
|
|
57636
|
-
level:
|
|
57637
|
-
unit:
|
|
57638
|
-
fields:
|
|
57639
|
-
|
|
57640
|
-
|
|
57641
|
-
|
|
57642
|
-
|
|
57643
|
-
|
|
57644
|
-
|
|
57798
|
+
var schemaUpdateFormEntry = Joi142.object({
|
|
57799
|
+
_id: Joi142.string().hex().required(),
|
|
57800
|
+
formType: Joi142.string().optional().allow("", null),
|
|
57801
|
+
block: Joi142.string().optional().allow(null, ""),
|
|
57802
|
+
level: Joi142.string().optional().allow(null, ""),
|
|
57803
|
+
unit: Joi142.string().optional().allow(null, ""),
|
|
57804
|
+
fields: Joi142.object().pattern(
|
|
57805
|
+
Joi142.string(),
|
|
57806
|
+
Joi142.alternatives().try(
|
|
57807
|
+
Joi142.string(),
|
|
57808
|
+
Joi142.number(),
|
|
57809
|
+
Joi142.boolean(),
|
|
57810
|
+
Joi142.valid(null)
|
|
57645
57811
|
)
|
|
57646
57812
|
).optional(),
|
|
57647
|
-
status:
|
|
57648
|
-
updatedAt:
|
|
57649
|
-
deletedAt:
|
|
57813
|
+
status: Joi142.string().optional().allow("", null),
|
|
57814
|
+
updatedAt: Joi142.date().optional().allow("", null),
|
|
57815
|
+
deletedAt: Joi142.date().optional().allow("", null)
|
|
57650
57816
|
});
|
|
57651
57817
|
function MFormEntry(value) {
|
|
57652
57818
|
const { error } = schemaFormEntry.validate(value);
|
|
@@ -57655,21 +57821,21 @@ function MFormEntry(value) {
|
|
|
57655
57821
|
}
|
|
57656
57822
|
if (value._id && typeof value._id === "string") {
|
|
57657
57823
|
try {
|
|
57658
|
-
value._id = new
|
|
57824
|
+
value._id = new ObjectId142(value._id);
|
|
57659
57825
|
} catch {
|
|
57660
57826
|
throw new Error("Invalid ID.");
|
|
57661
57827
|
}
|
|
57662
57828
|
}
|
|
57663
57829
|
if (value.org && typeof value.org === "string") {
|
|
57664
57830
|
try {
|
|
57665
|
-
value.org = new
|
|
57831
|
+
value.org = new ObjectId142(value.org);
|
|
57666
57832
|
} catch {
|
|
57667
57833
|
throw new Error("Invalid org ID.");
|
|
57668
57834
|
}
|
|
57669
57835
|
}
|
|
57670
57836
|
if (value.site && typeof value.site === "string") {
|
|
57671
57837
|
try {
|
|
57672
|
-
value.site = new
|
|
57838
|
+
value.site = new ObjectId142(value.site);
|
|
57673
57839
|
} catch {
|
|
57674
57840
|
throw new Error("Invalid site ID.");
|
|
57675
57841
|
}
|
|
@@ -57694,21 +57860,21 @@ function MFormEntry(value) {
|
|
|
57694
57860
|
|
|
57695
57861
|
// src/repositories/online-forms-v2.repository.ts
|
|
57696
57862
|
import {
|
|
57697
|
-
BadRequestError as
|
|
57698
|
-
InternalServerError as
|
|
57699
|
-
logger as
|
|
57863
|
+
BadRequestError as BadRequestError222,
|
|
57864
|
+
InternalServerError as InternalServerError80,
|
|
57865
|
+
logger as logger194,
|
|
57700
57866
|
makeCacheKey as makeCacheKey66,
|
|
57701
57867
|
NotFoundError as NotFoundError60,
|
|
57702
57868
|
paginate as paginate62,
|
|
57703
|
-
useAtlas as
|
|
57869
|
+
useAtlas as useAtlas125,
|
|
57704
57870
|
useCache as useCache70
|
|
57705
57871
|
} from "@7365admin1/node-server-utils";
|
|
57706
|
-
import { ObjectId as
|
|
57872
|
+
import { ObjectId as ObjectId143 } from "mongodb";
|
|
57707
57873
|
var online_forms_namespace_collection = "online-forms";
|
|
57708
57874
|
function useFormEntryRepo() {
|
|
57709
|
-
const db =
|
|
57875
|
+
const db = useAtlas125.getDb();
|
|
57710
57876
|
if (!db) {
|
|
57711
|
-
throw new
|
|
57877
|
+
throw new InternalServerError80("Unable to connect to server.");
|
|
57712
57878
|
}
|
|
57713
57879
|
const collection = db.collection(online_forms_namespace_collection);
|
|
57714
57880
|
const { delNamespace, getCache, setCache } = useCache70(
|
|
@@ -57720,7 +57886,7 @@ function useFormEntryRepo() {
|
|
|
57720
57886
|
name: "text"
|
|
57721
57887
|
});
|
|
57722
57888
|
} catch (error) {
|
|
57723
|
-
throw new
|
|
57889
|
+
throw new InternalServerError80(
|
|
57724
57890
|
"Failed to create text index on online form."
|
|
57725
57891
|
);
|
|
57726
57892
|
}
|
|
@@ -57730,11 +57896,11 @@ function useFormEntryRepo() {
|
|
|
57730
57896
|
value = MFormEntry(value);
|
|
57731
57897
|
const res = await collection.insertOne(value, { session });
|
|
57732
57898
|
delNamespace().then(() => {
|
|
57733
|
-
|
|
57899
|
+
logger194.info(
|
|
57734
57900
|
`Cache cleared for namespace: ${online_forms_namespace_collection}`
|
|
57735
57901
|
);
|
|
57736
57902
|
}).catch((err) => {
|
|
57737
|
-
|
|
57903
|
+
logger194.error(
|
|
57738
57904
|
`Failed to clear cache for namespace: ${online_forms_namespace_collection}`,
|
|
57739
57905
|
err
|
|
57740
57906
|
);
|
|
@@ -57743,7 +57909,7 @@ function useFormEntryRepo() {
|
|
|
57743
57909
|
} catch (error) {
|
|
57744
57910
|
const isDuplicated = error.message.includes("duplicate");
|
|
57745
57911
|
if (isDuplicated) {
|
|
57746
|
-
throw new
|
|
57912
|
+
throw new BadRequestError222("Online Form already exists.");
|
|
57747
57913
|
}
|
|
57748
57914
|
throw error;
|
|
57749
57915
|
}
|
|
@@ -57769,7 +57935,7 @@ function useFormEntryRepo() {
|
|
|
57769
57935
|
};
|
|
57770
57936
|
const query = {
|
|
57771
57937
|
...status ? { $and: [{ status }, { status: { $ne: "deleted" } }] } : { status: { $ne: "deleted" } },
|
|
57772
|
-
...site && { site: new
|
|
57938
|
+
...site && { site: new ObjectId143(site) },
|
|
57773
57939
|
...search && { search: [{ name: { $regex: search, $options: "i" } }] }
|
|
57774
57940
|
};
|
|
57775
57941
|
const cacheKey = makeCacheKey66(
|
|
@@ -57778,7 +57944,7 @@ function useFormEntryRepo() {
|
|
|
57778
57944
|
);
|
|
57779
57945
|
const cachedData = await getCache(cacheKey);
|
|
57780
57946
|
if (cachedData) {
|
|
57781
|
-
|
|
57947
|
+
logger194.info(`Cache hit for key: ${cacheKey}`);
|
|
57782
57948
|
return cachedData;
|
|
57783
57949
|
}
|
|
57784
57950
|
try {
|
|
@@ -57791,9 +57957,9 @@ function useFormEntryRepo() {
|
|
|
57791
57957
|
const length = await collection.countDocuments(query);
|
|
57792
57958
|
const data = paginate62(items, page, limit, length);
|
|
57793
57959
|
setCache(cacheKey, data, 15 * 60).then(() => {
|
|
57794
|
-
|
|
57960
|
+
logger194.info(`Cache set for key: ${cacheKey}`);
|
|
57795
57961
|
}).catch((err) => {
|
|
57796
|
-
|
|
57962
|
+
logger194.error(`Failed to set cache for key: ${cacheKey}`, err);
|
|
57797
57963
|
});
|
|
57798
57964
|
return data;
|
|
57799
57965
|
} catch (error) {
|
|
@@ -57804,13 +57970,13 @@ function useFormEntryRepo() {
|
|
|
57804
57970
|
const cacheKey = makeCacheKey66(online_forms_namespace_collection, { _id });
|
|
57805
57971
|
const cachedData = await getCache(cacheKey);
|
|
57806
57972
|
if (cachedData) {
|
|
57807
|
-
|
|
57973
|
+
logger194.info(`Cache hit for key: ${cacheKey}`);
|
|
57808
57974
|
return cachedData;
|
|
57809
57975
|
}
|
|
57810
57976
|
try {
|
|
57811
|
-
_id = new
|
|
57977
|
+
_id = new ObjectId143(_id);
|
|
57812
57978
|
} catch (error) {
|
|
57813
|
-
throw new
|
|
57979
|
+
throw new BadRequestError222("Invalid online form ID format.");
|
|
57814
57980
|
}
|
|
57815
57981
|
const query = { _id, status: { $ne: "deleted" } };
|
|
57816
57982
|
try {
|
|
@@ -57819,9 +57985,9 @@ function useFormEntryRepo() {
|
|
|
57819
57985
|
throw new NotFoundError60("Document not found.");
|
|
57820
57986
|
}
|
|
57821
57987
|
setCache(cacheKey, data, 15 * 60).then(() => {
|
|
57822
|
-
|
|
57988
|
+
logger194.info(`Cache set for key: ${cacheKey}`);
|
|
57823
57989
|
}).catch((err) => {
|
|
57824
|
-
|
|
57990
|
+
logger194.error(`Failed to set cache for key: ${cacheKey}`, err);
|
|
57825
57991
|
});
|
|
57826
57992
|
return data;
|
|
57827
57993
|
} catch (error) {
|
|
@@ -57830,9 +57996,9 @@ function useFormEntryRepo() {
|
|
|
57830
57996
|
}
|
|
57831
57997
|
async function updateFormEntryById(_id, value) {
|
|
57832
57998
|
try {
|
|
57833
|
-
_id = new
|
|
57999
|
+
_id = new ObjectId143(_id);
|
|
57834
58000
|
} catch (error) {
|
|
57835
|
-
throw new
|
|
58001
|
+
throw new BadRequestError222("Invalid online form ID format.");
|
|
57836
58002
|
}
|
|
57837
58003
|
try {
|
|
57838
58004
|
const updateValue = {
|
|
@@ -57841,14 +58007,14 @@ function useFormEntryRepo() {
|
|
|
57841
58007
|
};
|
|
57842
58008
|
const res = await collection.updateOne({ _id }, { $set: updateValue });
|
|
57843
58009
|
if (res.modifiedCount === 0) {
|
|
57844
|
-
throw new
|
|
58010
|
+
throw new InternalServerError80("Unable to update online form.");
|
|
57845
58011
|
}
|
|
57846
58012
|
delNamespace().then(() => {
|
|
57847
|
-
|
|
58013
|
+
logger194.info(
|
|
57848
58014
|
`Cache cleared for namespace: ${online_forms_namespace_collection}`
|
|
57849
58015
|
);
|
|
57850
58016
|
}).catch((err) => {
|
|
57851
|
-
|
|
58017
|
+
logger194.error(
|
|
57852
58018
|
`Failed to clear cache for namespace: ${online_forms_namespace_collection}`,
|
|
57853
58019
|
err
|
|
57854
58020
|
);
|
|
@@ -57858,18 +58024,52 @@ function useFormEntryRepo() {
|
|
|
57858
58024
|
throw error;
|
|
57859
58025
|
}
|
|
57860
58026
|
}
|
|
58027
|
+
async function deleteOnlineFormById(_id, session) {
|
|
58028
|
+
try {
|
|
58029
|
+
_id = new ObjectId143(_id);
|
|
58030
|
+
} catch (error) {
|
|
58031
|
+
throw new BadRequestError222("Invalid online form ID format.");
|
|
58032
|
+
}
|
|
58033
|
+
try {
|
|
58034
|
+
const updateValue = {
|
|
58035
|
+
status: "deleted",
|
|
58036
|
+
updatedAt: /* @__PURE__ */ new Date(),
|
|
58037
|
+
deletedAt: /* @__PURE__ */ new Date()
|
|
58038
|
+
};
|
|
58039
|
+
const res = await collection.updateOne(
|
|
58040
|
+
{ _id },
|
|
58041
|
+
{ $set: updateValue },
|
|
58042
|
+
{ session }
|
|
58043
|
+
);
|
|
58044
|
+
if (res.modifiedCount === 0) {
|
|
58045
|
+
throw new InternalServerError80("Unable to delete online form.");
|
|
58046
|
+
}
|
|
58047
|
+
delNamespace().then(() => {
|
|
58048
|
+
logger194.info(`Cache cleared for namespace: ${online_forms_namespace_collection}`);
|
|
58049
|
+
}).catch((err) => {
|
|
58050
|
+
logger194.error(
|
|
58051
|
+
`Failed to clear cache for namespace: ${online_forms_namespace_collection}`,
|
|
58052
|
+
err
|
|
58053
|
+
);
|
|
58054
|
+
});
|
|
58055
|
+
return res.modifiedCount;
|
|
58056
|
+
} catch (error) {
|
|
58057
|
+
throw new Error(error.message);
|
|
58058
|
+
}
|
|
58059
|
+
}
|
|
57861
58060
|
return {
|
|
57862
58061
|
add,
|
|
57863
58062
|
getAll,
|
|
57864
58063
|
getFormEntryById,
|
|
57865
58064
|
updateFormEntryById,
|
|
57866
|
-
createTextIndex
|
|
58065
|
+
createTextIndex,
|
|
58066
|
+
deleteOnlineFormById
|
|
57867
58067
|
};
|
|
57868
58068
|
}
|
|
57869
58069
|
|
|
57870
58070
|
// src/controllers/online-forms-v2.controller.ts
|
|
57871
|
-
import { BadRequestError as
|
|
57872
|
-
import
|
|
58071
|
+
import { BadRequestError as BadRequestError223, logger as logger195 } from "@7365admin1/node-server-utils";
|
|
58072
|
+
import Joi143 from "joi";
|
|
57873
58073
|
import ExcelJS3 from "exceljs";
|
|
57874
58074
|
import fs5 from "fs";
|
|
57875
58075
|
function useFormEntryController() {
|
|
@@ -57877,7 +58077,8 @@ function useFormEntryController() {
|
|
|
57877
58077
|
add: _add,
|
|
57878
58078
|
getAll: _getAll,
|
|
57879
58079
|
getFormEntryById: _getFormEntryById,
|
|
57880
|
-
updateFormEntryById: _updateFormEntryById
|
|
58080
|
+
updateFormEntryById: _updateFormEntryById,
|
|
58081
|
+
deleteOnlineFormById: _deleteOnlineFormById
|
|
57881
58082
|
} = useFormEntryRepo();
|
|
57882
58083
|
function toCamelCase(str) {
|
|
57883
58084
|
return str.replace(/\s(.)/g, (_, char) => char.toUpperCase()).replace(/\s+/g, "").replace(/^(.)/, (_, char) => char.toLowerCase());
|
|
@@ -57892,14 +58093,14 @@ function useFormEntryController() {
|
|
|
57892
58093
|
async function uploadFormEntrys(req, res, next) {
|
|
57893
58094
|
try {
|
|
57894
58095
|
if (!req.file) {
|
|
57895
|
-
next(new
|
|
58096
|
+
next(new BadRequestError223("Excel file is required."));
|
|
57896
58097
|
return;
|
|
57897
58098
|
}
|
|
57898
58099
|
const workbook = new ExcelJS3.Workbook();
|
|
57899
58100
|
await workbook.xlsx.readFile(req.file.path);
|
|
57900
58101
|
const worksheet = workbook.worksheets[0];
|
|
57901
58102
|
if (!worksheet) {
|
|
57902
|
-
next(new
|
|
58103
|
+
next(new BadRequestError223("No worksheet found in uploaded Excel file."));
|
|
57903
58104
|
return;
|
|
57904
58105
|
}
|
|
57905
58106
|
const headerRow = worksheet.getRow(1);
|
|
@@ -57927,8 +58128,8 @@ function useFormEntryController() {
|
|
|
57927
58128
|
});
|
|
57928
58129
|
if (error) {
|
|
57929
58130
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
57930
|
-
|
|
57931
|
-
next(new
|
|
58131
|
+
logger195.log({ level: "error", message: messages });
|
|
58132
|
+
next(new BadRequestError223(messages));
|
|
57932
58133
|
return;
|
|
57933
58134
|
}
|
|
57934
58135
|
const result = await _add(value);
|
|
@@ -57936,25 +58137,25 @@ function useFormEntryController() {
|
|
|
57936
58137
|
fs5.unlink(req.file.path, () => {
|
|
57937
58138
|
});
|
|
57938
58139
|
} catch (error) {
|
|
57939
|
-
|
|
58140
|
+
logger195.log({ level: "error", message: error.message });
|
|
57940
58141
|
next(error);
|
|
57941
58142
|
}
|
|
57942
58143
|
}
|
|
57943
58144
|
async function getAll(req, res, next) {
|
|
57944
58145
|
try {
|
|
57945
|
-
const schema2 =
|
|
57946
|
-
search:
|
|
57947
|
-
page:
|
|
57948
|
-
limit:
|
|
57949
|
-
status:
|
|
57950
|
-
org:
|
|
57951
|
-
site:
|
|
58146
|
+
const schema2 = Joi143.object({
|
|
58147
|
+
search: Joi143.string().optional().allow("", null),
|
|
58148
|
+
page: Joi143.number().integer().min(1).allow("", null).default(1),
|
|
58149
|
+
limit: Joi143.number().integer().min(1).max(100).allow("", null).default(10),
|
|
58150
|
+
status: Joi143.string().optional().allow(null, ""),
|
|
58151
|
+
org: Joi143.string().hex().optional().allow("", null),
|
|
58152
|
+
site: Joi143.string().hex().optional().allow("", null)
|
|
57952
58153
|
});
|
|
57953
58154
|
const { error, value } = schema2.validate(req.query);
|
|
57954
58155
|
if (error) {
|
|
57955
58156
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
57956
|
-
|
|
57957
|
-
next(new
|
|
58157
|
+
logger195.log({ level: "error", message: messages });
|
|
58158
|
+
next(new BadRequestError223(messages));
|
|
57958
58159
|
return;
|
|
57959
58160
|
}
|
|
57960
58161
|
const { search, page, limit, status, org, site } = value;
|
|
@@ -57962,21 +58163,21 @@ function useFormEntryController() {
|
|
|
57962
58163
|
res.json(data);
|
|
57963
58164
|
return;
|
|
57964
58165
|
} catch (error) {
|
|
57965
|
-
|
|
58166
|
+
logger195.log({ level: "error", message: error.message });
|
|
57966
58167
|
next(error);
|
|
57967
58168
|
return;
|
|
57968
58169
|
}
|
|
57969
58170
|
}
|
|
57970
58171
|
async function getFormEntryById(req, res, next) {
|
|
57971
58172
|
try {
|
|
57972
|
-
const schema2 =
|
|
57973
|
-
_id:
|
|
58173
|
+
const schema2 = Joi143.object({
|
|
58174
|
+
_id: Joi143.string().hex().length(24).required()
|
|
57974
58175
|
});
|
|
57975
58176
|
const { error, value } = schema2.validate({ _id: req.params.id });
|
|
57976
58177
|
if (error) {
|
|
57977
58178
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
57978
|
-
|
|
57979
|
-
next(new
|
|
58179
|
+
logger195.log({ level: "error", message: messages });
|
|
58180
|
+
next(new BadRequestError223(messages));
|
|
57980
58181
|
return;
|
|
57981
58182
|
}
|
|
57982
58183
|
const { _id } = value;
|
|
@@ -57984,7 +58185,7 @@ function useFormEntryController() {
|
|
|
57984
58185
|
res.json(data);
|
|
57985
58186
|
return;
|
|
57986
58187
|
} catch (error) {
|
|
57987
|
-
|
|
58188
|
+
logger195.log({ level: "error", message: error.message });
|
|
57988
58189
|
next(error);
|
|
57989
58190
|
return;
|
|
57990
58191
|
}
|
|
@@ -57997,8 +58198,8 @@ function useFormEntryController() {
|
|
|
57997
58198
|
});
|
|
57998
58199
|
if (error) {
|
|
57999
58200
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
58000
|
-
|
|
58001
|
-
next(new
|
|
58201
|
+
logger195.log({ level: "error", message: messages });
|
|
58202
|
+
next(new BadRequestError223(messages));
|
|
58002
58203
|
return;
|
|
58003
58204
|
}
|
|
58004
58205
|
const { _id, ...rest } = value;
|
|
@@ -58006,7 +58207,26 @@ function useFormEntryController() {
|
|
|
58006
58207
|
res.json({ message: "Successfully updated online form." });
|
|
58007
58208
|
return;
|
|
58008
58209
|
} catch (error) {
|
|
58009
|
-
|
|
58210
|
+
logger195.log({ level: "error", message: error.message });
|
|
58211
|
+
next(error);
|
|
58212
|
+
return;
|
|
58213
|
+
}
|
|
58214
|
+
}
|
|
58215
|
+
async function deleteFormEntryById(req, res, next) {
|
|
58216
|
+
try {
|
|
58217
|
+
const validation = Joi143.string().hex().required();
|
|
58218
|
+
const _id = req.params.id;
|
|
58219
|
+
const { error } = validation.validate(_id);
|
|
58220
|
+
if (error) {
|
|
58221
|
+
logger195.log({ level: "error", message: error.message });
|
|
58222
|
+
next(new BadRequestError223(error.message));
|
|
58223
|
+
return;
|
|
58224
|
+
}
|
|
58225
|
+
await _deleteOnlineFormById(_id);
|
|
58226
|
+
res.json({ message: "Successfully deleted online form." });
|
|
58227
|
+
return;
|
|
58228
|
+
} catch (error) {
|
|
58229
|
+
logger195.log({ level: "error", message: error.message });
|
|
58010
58230
|
next(error);
|
|
58011
58231
|
return;
|
|
58012
58232
|
}
|
|
@@ -58015,16 +58235,17 @@ function useFormEntryController() {
|
|
|
58015
58235
|
uploadFormEntrys,
|
|
58016
58236
|
getAll,
|
|
58017
58237
|
getFormEntryById,
|
|
58018
|
-
updateFormEntryById
|
|
58238
|
+
updateFormEntryById,
|
|
58239
|
+
deleteFormEntryById
|
|
58019
58240
|
};
|
|
58020
58241
|
}
|
|
58021
58242
|
|
|
58022
58243
|
// src/services/building-level.service.ts
|
|
58023
|
-
import { useAtlas as
|
|
58244
|
+
import { useAtlas as useAtlas126 } from "@7365admin1/node-server-utils";
|
|
58024
58245
|
function useBuildingLevelService() {
|
|
58025
58246
|
const { add: _add, updateLevelById: _updateLevelById } = useBuildingLevelRepo();
|
|
58026
58247
|
async function add(value) {
|
|
58027
|
-
const session =
|
|
58248
|
+
const session = useAtlas126.getClient()?.startSession();
|
|
58028
58249
|
try {
|
|
58029
58250
|
session?.startTransaction();
|
|
58030
58251
|
await _add(value, session);
|
|
@@ -58038,7 +58259,7 @@ function useBuildingLevelService() {
|
|
|
58038
58259
|
}
|
|
58039
58260
|
}
|
|
58040
58261
|
async function updateLevelById(_id, value) {
|
|
58041
|
-
const session =
|
|
58262
|
+
const session = useAtlas126.getClient()?.startSession();
|
|
58042
58263
|
try {
|
|
58043
58264
|
session?.startTransaction();
|
|
58044
58265
|
await _updateLevelById(_id, value, session);
|
|
@@ -58058,8 +58279,8 @@ function useBuildingLevelService() {
|
|
|
58058
58279
|
}
|
|
58059
58280
|
|
|
58060
58281
|
// src/controllers/building-level.controller.ts
|
|
58061
|
-
import { BadRequestError as
|
|
58062
|
-
import
|
|
58282
|
+
import { BadRequestError as BadRequestError224, logger as logger196 } from "@7365admin1/node-server-utils";
|
|
58283
|
+
import Joi144 from "joi";
|
|
58063
58284
|
function useBuildingLevelController() {
|
|
58064
58285
|
const { add: _add, updateLevelById: _updateLevelById } = useBuildingLevelService();
|
|
58065
58286
|
const {
|
|
@@ -58074,8 +58295,8 @@ function useBuildingLevelController() {
|
|
|
58074
58295
|
});
|
|
58075
58296
|
if (error) {
|
|
58076
58297
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
58077
|
-
|
|
58078
|
-
next(new
|
|
58298
|
+
logger196.log({ level: "error", message: messages });
|
|
58299
|
+
next(new BadRequestError224(messages));
|
|
58079
58300
|
return;
|
|
58080
58301
|
}
|
|
58081
58302
|
const result = await _add(value);
|
|
@@ -58086,20 +58307,20 @@ function useBuildingLevelController() {
|
|
|
58086
58307
|
}
|
|
58087
58308
|
async function getAll(req, res, next) {
|
|
58088
58309
|
try {
|
|
58089
|
-
const validation =
|
|
58090
|
-
page:
|
|
58091
|
-
limit:
|
|
58092
|
-
search:
|
|
58093
|
-
site:
|
|
58094
|
-
status:
|
|
58310
|
+
const validation = Joi144.object({
|
|
58311
|
+
page: Joi144.number().min(1).optional().default(1),
|
|
58312
|
+
limit: Joi144.number().min(1).optional().default(20),
|
|
58313
|
+
search: Joi144.string().optional().allow("", null),
|
|
58314
|
+
site: Joi144.string().hex().length(24).optional().allow("", null),
|
|
58315
|
+
status: Joi144.string().valid(...Object.values(BuildingLevelStatus)).default("active" /* ACTIVE */)
|
|
58095
58316
|
});
|
|
58096
58317
|
const { error, value } = validation.validate(req.query, {
|
|
58097
58318
|
abortEarly: false
|
|
58098
58319
|
});
|
|
58099
58320
|
if (error) {
|
|
58100
58321
|
const messages = error.details.map((d) => d.message);
|
|
58101
|
-
|
|
58102
|
-
next(new
|
|
58322
|
+
logger196.log({ level: "error", message: messages.join(", ") });
|
|
58323
|
+
next(new BadRequestError224(messages.join(", ")));
|
|
58103
58324
|
return;
|
|
58104
58325
|
}
|
|
58105
58326
|
const { page, limit, status, site, search } = value;
|
|
@@ -58118,14 +58339,14 @@ function useBuildingLevelController() {
|
|
|
58118
58339
|
}
|
|
58119
58340
|
async function getById(req, res, next) {
|
|
58120
58341
|
try {
|
|
58121
|
-
const schema2 =
|
|
58122
|
-
id:
|
|
58342
|
+
const schema2 = Joi144.object({
|
|
58343
|
+
id: Joi144.string().hex().length(24).required()
|
|
58123
58344
|
});
|
|
58124
58345
|
const { error, value } = schema2.validate({ id: req.params.id });
|
|
58125
58346
|
if (error) {
|
|
58126
58347
|
const messages = error.details.map((d) => d.message);
|
|
58127
|
-
|
|
58128
|
-
next(new
|
|
58348
|
+
logger196.log({ level: "error", message: messages.join(", ") });
|
|
58349
|
+
next(new BadRequestError224(messages.join(", ")));
|
|
58129
58350
|
return;
|
|
58130
58351
|
}
|
|
58131
58352
|
const { id } = value;
|
|
@@ -58144,8 +58365,8 @@ function useBuildingLevelController() {
|
|
|
58144
58365
|
});
|
|
58145
58366
|
if (error) {
|
|
58146
58367
|
const messages = error.details.map((d) => d.message);
|
|
58147
|
-
|
|
58148
|
-
next(new
|
|
58368
|
+
logger196.log({ level: "error", message: messages.join(", ") });
|
|
58369
|
+
next(new BadRequestError224(messages.join(", ")));
|
|
58149
58370
|
return;
|
|
58150
58371
|
}
|
|
58151
58372
|
const { _id, ...rest } = value;
|
|
@@ -58157,14 +58378,14 @@ function useBuildingLevelController() {
|
|
|
58157
58378
|
}
|
|
58158
58379
|
async function deleteById(req, res, next) {
|
|
58159
58380
|
try {
|
|
58160
|
-
const schema2 =
|
|
58161
|
-
id:
|
|
58381
|
+
const schema2 = Joi144.object({
|
|
58382
|
+
id: Joi144.string().hex().required()
|
|
58162
58383
|
});
|
|
58163
58384
|
const { error, value } = schema2.validate({ id: req.params.id });
|
|
58164
58385
|
if (error) {
|
|
58165
58386
|
const messages = error.details.map((d) => d.message);
|
|
58166
|
-
|
|
58167
|
-
next(new
|
|
58387
|
+
logger196.log({ level: "error", message: messages.join(", ") });
|
|
58388
|
+
next(new BadRequestError224(messages.join(", ")));
|
|
58168
58389
|
return;
|
|
58169
58390
|
}
|
|
58170
58391
|
const { id } = value;
|
|
@@ -58227,6 +58448,7 @@ export {
|
|
|
58227
58448
|
MBulletinVideo,
|
|
58228
58449
|
MCategoryPreloved,
|
|
58229
58450
|
MChat,
|
|
58451
|
+
MChatPreloved,
|
|
58230
58452
|
MCustomer,
|
|
58231
58453
|
MCustomerSite,
|
|
58232
58454
|
MDocumentManagement,
|
|
@@ -58371,6 +58593,7 @@ export {
|
|
|
58371
58593
|
schemaBulletinBoard,
|
|
58372
58594
|
schemaBulletinVideo,
|
|
58373
58595
|
schemaCategoryPreloved,
|
|
58596
|
+
schemaChatPreloved,
|
|
58374
58597
|
schemaCustomerSite,
|
|
58375
58598
|
schemaDocumentManagement,
|
|
58376
58599
|
schemaEntryPassSettings,
|
|
@@ -58478,6 +58701,8 @@ export {
|
|
|
58478
58701
|
useCategoryPrelovedController,
|
|
58479
58702
|
useCategoryPrelovedRepo,
|
|
58480
58703
|
useChatController,
|
|
58704
|
+
useChatPrelovedController,
|
|
58705
|
+
useChatPrelovedRepo,
|
|
58481
58706
|
useChatRepo,
|
|
58482
58707
|
useCounterModel,
|
|
58483
58708
|
useCounterRepo,
|