@7365admin1/core 2.69.1 → 2.70.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/dist/index.mjs CHANGED
@@ -6637,6 +6637,7 @@ var MFile = class {
6637
6637
  this._id = value._id;
6638
6638
  this.name = value.name ?? "";
6639
6639
  this.type = value.type ?? "public";
6640
+ this.size = value.size ?? 0;
6640
6641
  this.status = value.status ?? "draft";
6641
6642
  this.createdAt = value.createdAt ?? (/* @__PURE__ */ new Date()).toISOString();
6642
6643
  }
@@ -8636,6 +8637,7 @@ function useFileService() {
8636
8637
  session?.startTransaction();
8637
8638
  const file = {
8638
8639
  name: value.originalname,
8640
+ size: value.size ?? (value.buffer ? value.buffer.length : 0),
8639
8641
  createdAt: (/* @__PURE__ */ new Date()).toISOString()
8640
8642
  };
8641
8643
  try {
@@ -31965,6 +31967,7 @@ var schemaDocumentManagement = Joi75.object({
31965
31967
  _id: Joi75.string().hex().optional().allow("", null),
31966
31968
  name: Joi75.string().required(),
31967
31969
  type: Joi75.string().optional().allow("", null),
31970
+ size: Joi75.number().optional().allow(null, "").default(0),
31968
31971
  attachment: Joi75.when("type", { is: "folder", then: Joi75.forbidden(), otherwise: Joi75.string().optional().allow("", null) }),
31969
31972
  remarks: Joi75.string().optional().allow("", null),
31970
31973
  org: Joi75.string().hex().optional().allow("", null),
@@ -31980,6 +31983,7 @@ var schemaUpdateDocumentManagement = Joi75.object({
31980
31983
  _id: Joi75.string().hex().required(),
31981
31984
  name: Joi75.string().optional().allow("", null),
31982
31985
  type: Joi75.string().optional().allow("", null),
31986
+ size: Joi75.number().optional().allow(null, ""),
31983
31987
  attachment: Joi75.when("type", { is: "folder", then: Joi75.forbidden(), otherwise: Joi75.string().optional().allow("", null) }),
31984
31988
  remarks: Joi75.string().optional().allow("", null),
31985
31989
  org: Joi75.string().hex().optional().allow("", null),
@@ -32026,6 +32030,7 @@ function MDocumentManagement(value) {
32026
32030
  _id: value._id,
32027
32031
  name: value.name,
32028
32032
  type: value.type,
32033
+ size: value.size ?? 0,
32029
32034
  attachment: value.attachment,
32030
32035
  remarks: value.remarks ?? "",
32031
32036
  org: value.org,
@@ -32158,7 +32163,7 @@ function useDocumentManagementRepo() {
32158
32163
  try {
32159
32164
  const items = await collection.aggregate([
32160
32165
  { $match: query },
32161
- { $sort: { _id: -1 } },
32166
+ { $sort: { createdAt: -1 } },
32162
32167
  {
32163
32168
  $project: {
32164
32169
  parentId: 1,
@@ -32170,7 +32175,9 @@ function useDocumentManagementRepo() {
32170
32175
  remarks: 1,
32171
32176
  attachment: 1
32172
32177
  }
32173
- }
32178
+ },
32179
+ { $skip: page * limit },
32180
+ { $limit: limit }
32174
32181
  ]).toArray();
32175
32182
  const length = await collection.countDocuments(query);
32176
32183
  const data = paginate34(items, page, limit, length);
@@ -32198,32 +32205,21 @@ function useDocumentManagementRepo() {
32198
32205
  }
32199
32206
  try {
32200
32207
  const data = await collection.aggregate([
32201
- { $match: { _id, status: { $ne: "deleted" } } },
32202
32208
  {
32203
- $lookup: {
32204
- from: "users",
32205
- localField: "createdBy",
32206
- foreignField: "_id",
32207
- as: "userInfo",
32208
- pipeline: [{ $project: { name: 1 } }]
32209
- }
32210
- },
32211
- {
32212
- $unwind: {
32213
- path: "$userInfo",
32214
- preserveNullAndEmptyArrays: true
32209
+ $match: {
32210
+ _id,
32211
+ status: { $ne: "deleted" }
32215
32212
  }
32216
32213
  },
32217
32214
  {
32218
32215
  $project: {
32219
32216
  name: 1,
32220
32217
  type: 1,
32221
- status: 1,
32222
- attachment: 1,
32218
+ size: 1,
32223
32219
  createdAt: 1,
32224
32220
  updatedAt: 1,
32225
- createdBy: 1,
32226
- createdByName: "$userInfo.name"
32221
+ attachment: 1,
32222
+ remarks: 1
32227
32223
  }
32228
32224
  }
32229
32225
  ]).toArray();
@@ -32356,8 +32352,8 @@ import {
32356
32352
  NotFoundError as NotFoundError29
32357
32353
  } from "@7365admin1/node-server-utils";
32358
32354
  function useDocumentManagementService() {
32359
- const { add: _add } = useDocumentManagementRepo();
32360
- const { updateStatusById } = useFileRepo();
32355
+ const { add: _add, updateDocumentById: _updateDocumentById } = useDocumentManagementRepo();
32356
+ const { updateStatusById, getFileById } = useFileRepo();
32361
32357
  async function createDocument(value) {
32362
32358
  const session = useAtlas66.getClient()?.startSession();
32363
32359
  if (!session) {
@@ -32375,6 +32371,9 @@ function useDocumentManagementService() {
32375
32371
  if (!file) {
32376
32372
  throw new NotFoundError29("File not found.");
32377
32373
  }
32374
+ const { getFileById: getFileById2 } = useFileRepo();
32375
+ const storedFile = await getFileById2(document2);
32376
+ value.size = storedFile?.size ?? storedFile?.file_size ?? 0;
32378
32377
  }
32379
32378
  await _add(value, session);
32380
32379
  await session?.commitTransaction();
@@ -32386,8 +32385,35 @@ function useDocumentManagementService() {
32386
32385
  session?.endSession();
32387
32386
  }
32388
32387
  }
32388
+ async function updateDocumentById(_id, value) {
32389
+ if (value?.name) {
32390
+ value.name = value.name.toString().trim();
32391
+ }
32392
+ if (value?.type === "folder") {
32393
+ delete value.attachment;
32394
+ delete value.size;
32395
+ } else {
32396
+ if (Array.isArray(value.attachment)) {
32397
+ value.attachment = value.attachment[0];
32398
+ } else if (!value.attachment) {
32399
+ value.attachment = "";
32400
+ }
32401
+ if (value.attachment) {
32402
+ try {
32403
+ const f = await getFileById(value.attachment);
32404
+ value.size = f?.size ?? f?.file_size ?? 0;
32405
+ } catch (err) {
32406
+ value.size = 0;
32407
+ }
32408
+ } else {
32409
+ value.size = 0;
32410
+ }
32411
+ }
32412
+ return await _updateDocumentById(_id, value);
32413
+ }
32389
32414
  return {
32390
- createDocument
32415
+ createDocument,
32416
+ updateDocumentById
32391
32417
  };
32392
32418
  }
32393
32419
 
@@ -32395,11 +32421,10 @@ function useDocumentManagementService() {
32395
32421
  import { BadRequestError as BadRequestError128, logger as logger106 } from "@7365admin1/node-server-utils";
32396
32422
  import Joi76 from "joi";
32397
32423
  function useDocumentManagementController() {
32398
- const { createDocument: _add } = useDocumentManagementService();
32424
+ const { createDocument: _add, updateDocumentById: _updateDocumentById } = useDocumentManagementService();
32399
32425
  const {
32400
32426
  getAll: _getDocuments,
32401
32427
  getDocumentById: _getDocumentById,
32402
- updateDocumentById: _updateDocumentById,
32403
32428
  deleteDocumentById: _deleteDocumentById,
32404
32429
  getDocumentManagementBySiteId: _getDocumentManagementBySiteId
32405
32430
  } = useDocumentManagementRepo();
@@ -32415,6 +32440,9 @@ function useDocumentManagementController() {
32415
32440
  createdBy = req.body.createdBy;
32416
32441
  }
32417
32442
  const payload = { ...req.body, createdBy };
32443
+ if (payload.size !== void 0) {
32444
+ delete payload.size;
32445
+ }
32418
32446
  if (payload.type === "folder") {
32419
32447
  delete payload.attachment;
32420
32448
  } else {
@@ -32531,14 +32559,8 @@ function useDocumentManagementController() {
32531
32559
  }
32532
32560
  const _id = req.params.id;
32533
32561
  const payload = { ...req.body, updatedBy };
32534
- if (payload.type === "folder") {
32535
- delete payload.attachment;
32536
- } else {
32537
- if (Array.isArray(payload.attachment)) {
32538
- payload.attachment = payload.attachment[0];
32539
- } else if (!payload.attachment) {
32540
- payload.attachment = "";
32541
- }
32562
+ if (payload.size !== void 0) {
32563
+ delete payload.size;
32542
32564
  }
32543
32565
  const { error } = validation.validate({ _id, ...payload });
32544
32566
  if (error) {
@@ -39442,6 +39464,15 @@ function UseAccessManagementRepo() {
39442
39464
  throw new Error(error.message);
39443
39465
  }
39444
39466
  }
39467
+ async function removeTemplateRepo({ site }) {
39468
+ site = new ObjectId92(site);
39469
+ try {
39470
+ const result = await collectionName("entrypass-settings").updateOne({ _id: site }, { $set: { "settings.template": {} } });
39471
+ return result;
39472
+ } catch (error) {
39473
+ throw new Error(error.message);
39474
+ }
39475
+ }
39445
39476
  return {
39446
39477
  createIndexes,
39447
39478
  createIndexForEntrypass,
@@ -39479,7 +39510,8 @@ function UseAccessManagementRepo() {
39479
39510
  visitorCheckoutRepo,
39480
39511
  uploadTemplateRepo,
39481
39512
  getResidentsRepo,
39482
- userAccessCardsRepo
39513
+ userAccessCardsRepo,
39514
+ removeTemplateRepo
39483
39515
  };
39484
39516
  }
39485
39517
 
@@ -39525,7 +39557,8 @@ function useAccessManagementSvc() {
39525
39557
  visitorCheckoutRepo,
39526
39558
  uploadTemplateRepo,
39527
39559
  getResidentsRepo,
39528
- userAccessCardsRepo
39560
+ userAccessCardsRepo,
39561
+ removeTemplateRepo
39529
39562
  } = UseAccessManagementRepo();
39530
39563
  const addPhysicalCardSvc = async (payload) => {
39531
39564
  try {
@@ -39903,6 +39936,14 @@ function useAccessManagementSvc() {
39903
39936
  throw new Error(err.message);
39904
39937
  }
39905
39938
  };
39939
+ const removeTemplateSvc = async ({ site }) => {
39940
+ try {
39941
+ const response = await removeTemplateRepo({ site });
39942
+ return response;
39943
+ } catch (err) {
39944
+ throw new Error(err.message);
39945
+ }
39946
+ };
39906
39947
  return {
39907
39948
  addPhysicalCardSvc,
39908
39949
  addNonPhysicalCardSvc,
@@ -39943,7 +39984,8 @@ function useAccessManagementSvc() {
39943
39984
  visitorCheckoutSvc,
39944
39985
  uploadTemplateSvc,
39945
39986
  getResidentsSvc,
39946
- userAccessCardsSvc
39987
+ userAccessCardsSvc,
39988
+ removeTemplateSvc
39947
39989
  };
39948
39990
  }
39949
39991
 
@@ -39989,7 +40031,8 @@ function useAccessManagementController() {
39989
40031
  visitorCheckoutSvc,
39990
40032
  uploadTemplateSvc,
39991
40033
  getResidentsSvc,
39992
- userAccessCardsSvc
40034
+ userAccessCardsSvc,
40035
+ removeTemplateSvc
39993
40036
  } = useAccessManagementSvc();
39994
40037
  const addPhysicalCard = async (req, res) => {
39995
40038
  try {
@@ -41039,6 +41082,25 @@ function useAccessManagementController() {
41039
41082
  });
41040
41083
  }
41041
41084
  };
41085
+ const removeTemplate = async (req, res) => {
41086
+ try {
41087
+ const { site } = req.query;
41088
+ const schema2 = Joi87.object({
41089
+ site: Joi87.string().hex().required()
41090
+ });
41091
+ const { error } = schema2.validate({ site });
41092
+ if (error) {
41093
+ return res.status(400).json({ message: error.message });
41094
+ }
41095
+ const result = await removeTemplateSvc({ site });
41096
+ return res.status(200).json({ data: result });
41097
+ } catch (error) {
41098
+ return res.status(400).json({
41099
+ data: null,
41100
+ message: error.message
41101
+ });
41102
+ }
41103
+ };
41042
41104
  return {
41043
41105
  addPhysicalCard,
41044
41106
  addNonPhysicalCard,
@@ -41077,7 +41139,8 @@ function useAccessManagementController() {
41077
41139
  visitorCheckout,
41078
41140
  uploadTemplate,
41079
41141
  getResidents,
41080
- userAccessCards
41142
+ userAccessCards,
41143
+ removeTemplate
41081
41144
  };
41082
41145
  }
41083
41146
 
@@ -45514,7 +45577,7 @@ function useIncidentReportRepo() {
45514
45577
  },
45515
45578
  ...dateExpr
45516
45579
  };
45517
- sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
45580
+ sort = Object.keys(sort).length > 0 ? sort : { updatedAt: -1, createdAt: -1, _id: -1 };
45518
45581
  const cacheOptions = {
45519
45582
  site: site.toString(),
45520
45583
  sort: JSON.stringify(sort),
@@ -45615,7 +45678,7 @@ function useIncidentReportRepo() {
45615
45678
  },
45616
45679
  ...dateExpr
45617
45680
  };
45618
- sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
45681
+ sort = Object.keys(sort).length > 0 ? sort : { updatedAt: -1, createdAt: -1, _id: -1 };
45619
45682
  try {
45620
45683
  const items = await collection.aggregate(
45621
45684
  [
@@ -46015,7 +46078,7 @@ function useIncidentReportController() {
46015
46078
  }
46016
46079
  }
46017
46080
  async function getAll(req, res, next) {
46018
- const allowedFields = ["createdAt", "name"];
46081
+ const allowedFields = ["updatedAt", "createdAt", "name"];
46019
46082
  const allowedOrder = ["asc", "desc"];
46020
46083
  const validation = Joi102.object({
46021
46084
  search: Joi102.string().optional().allow("", null),
@@ -46071,7 +46134,7 @@ function useIncidentReportController() {
46071
46134
  }
46072
46135
  }
46073
46136
  async function getAllForVirtualPatrolLogs(req, res, next) {
46074
- const allowedFields = ["createdAt", "name"];
46137
+ const allowedFields = ["updatedAt", "createdAt", "name"];
46075
46138
  const allowedOrder = ["asc", "desc"];
46076
46139
  const validation = Joi102.object({
46077
46140
  search: Joi102.string().optional().allow("", null),
@@ -55878,17 +55941,186 @@ function usePostPrelovedController() {
55878
55941
  };
55879
55942
  }
55880
55943
 
55881
- // src/models/category-preloved.model.ts
55944
+ // src/models/post-favorite.model.ts
55882
55945
  import Joi135 from "joi";
55883
55946
  import { ObjectId as ObjectId133 } from "mongodb";
55884
- var schemaCategoryPreloved = Joi135.object({
55885
- name: Joi135.string().required(),
55886
- createdBy: Joi135.string().hex().optional().allow("", null),
55887
- site: Joi135.string().hex().optional().allow("", null)
55947
+ var schemaPostFavorite = Joi135.object({
55948
+ _id: Joi135.string().hex().optional().allow("", null),
55949
+ postId: Joi135.string().hex().required(),
55950
+ userIds: Joi135.array().items(Joi135.string().hex().optional()).optional().allow(null),
55951
+ createdAt: Joi135.date().optional().allow(null),
55952
+ updatedAt: Joi135.date().optional().allow(null)
55953
+ });
55954
+ function MPostFavorite(value) {
55955
+ const { error } = schemaPostFavorite.validate(value);
55956
+ if (error) {
55957
+ throw new Error(error.details[0].message);
55958
+ }
55959
+ if (value._id && typeof value._id === "string") {
55960
+ try {
55961
+ value._id = new ObjectId133(value._id);
55962
+ } catch {
55963
+ throw new Error("Invalid ID.");
55964
+ }
55965
+ }
55966
+ if (value.postId && typeof value.postId === "string") {
55967
+ try {
55968
+ value.postId = new ObjectId133(value.postId);
55969
+ } catch {
55970
+ throw new Error("Invalid post ID.");
55971
+ }
55972
+ }
55973
+ if (value.userIds && Array.isArray(value.userIds)) {
55974
+ value.userIds = value.userIds.map((id) => {
55975
+ if (typeof id === "string") {
55976
+ try {
55977
+ return new ObjectId133(id);
55978
+ } catch {
55979
+ throw new Error("Invalid user ID.");
55980
+ }
55981
+ }
55982
+ return id;
55983
+ });
55984
+ }
55985
+ return {
55986
+ _id: value._id ?? new ObjectId133(),
55987
+ postId: value.postId ?? "",
55988
+ userIds: value.userIds ?? [],
55989
+ createdAt: value.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
55990
+ updatedAt: value.updatedAt ?? null
55991
+ };
55992
+ }
55993
+
55994
+ // src/repositories/post-favorite.repo.ts
55995
+ import {
55996
+ BadRequestError as BadRequestError214,
55997
+ InternalServerError as InternalServerError76,
55998
+ NotFoundError as NotFoundError58,
55999
+ useAtlas as useAtlas119
56000
+ } from "@7365admin1/node-server-utils";
56001
+ import { ObjectId as ObjectId134 } from "mongodb";
56002
+ function usePostFavoriteRepo() {
56003
+ const db = useAtlas119.getDb();
56004
+ if (!db) {
56005
+ throw new InternalServerError76("Unable to connect to server.");
56006
+ }
56007
+ const FAVORITE_COLLECTION = "post-favorites";
56008
+ const collection = db.collection(FAVORITE_COLLECTION);
56009
+ async function addFavorite(value, session) {
56010
+ try {
56011
+ const doc = MPostFavorite(value);
56012
+ const res = await collection.insertOne(doc, { session });
56013
+ return res.insertedId;
56014
+ } catch (error) {
56015
+ const isDuplicated = error.message?.includes("duplicate");
56016
+ if (isDuplicated)
56017
+ throw new BadRequestError214("Post Favorite already exists.");
56018
+ throw error;
56019
+ }
56020
+ }
56021
+ async function getById(_id) {
56022
+ try {
56023
+ _id = new ObjectId134(_id);
56024
+ } catch {
56025
+ throw new BadRequestError214("Invalid favorite ID format.");
56026
+ }
56027
+ const result = await collection.findOne({ _id });
56028
+ if (!result)
56029
+ throw new NotFoundError58("Favorite not found.");
56030
+ return result;
56031
+ }
56032
+ return {
56033
+ addFavorite,
56034
+ getById
56035
+ };
56036
+ }
56037
+
56038
+ // src/services/post-favorite.service.ts
56039
+ import { useAtlas as useAtlas120 } from "@7365admin1/node-server-utils";
56040
+ function usePostFavoriteService() {
56041
+ const { addFavorite: _addFavorite } = usePostFavoriteRepo();
56042
+ async function addFavorite(value) {
56043
+ const session = useAtlas120.getClient()?.startSession();
56044
+ session?.startTransaction();
56045
+ try {
56046
+ await _addFavorite(value, session);
56047
+ await session?.commitTransaction();
56048
+ return "Successfully added to favorites.";
56049
+ } catch (error) {
56050
+ await session?.abortTransaction();
56051
+ throw error;
56052
+ } finally {
56053
+ session?.endSession();
56054
+ }
56055
+ }
56056
+ return {
56057
+ addFavorite
56058
+ };
56059
+ }
56060
+
56061
+ // src/controllers/post-favorite.controller.ts
56062
+ import { BadRequestError as BadRequestError215, logger as logger189 } from "@7365admin1/node-server-utils";
56063
+ import Joi136 from "joi";
56064
+ function usePostFavoriteController() {
56065
+ const { addFavorite: _addFavorite } = usePostFavoriteService();
56066
+ const { getById: _getById } = usePostFavoriteRepo();
56067
+ async function addFavorite(req, res, next) {
56068
+ const { error, value } = schemaPostFavorite.validate(req.body, {
56069
+ abortEarly: false
56070
+ });
56071
+ if (error) {
56072
+ const messages = error.details.map((d) => d.message).join(", ");
56073
+ logger189.log({ level: "error", message: messages });
56074
+ next(new BadRequestError215(messages));
56075
+ return;
56076
+ }
56077
+ try {
56078
+ const data = await _addFavorite(value);
56079
+ res.status(201).json(data);
56080
+ return;
56081
+ } catch (error2) {
56082
+ logger189.log({ level: "error", message: error2.message });
56083
+ next(error2);
56084
+ return;
56085
+ }
56086
+ }
56087
+ async function getById(req, res, next) {
56088
+ const schema2 = Joi136.object({
56089
+ _id: Joi136.string().hex().length(24).required()
56090
+ });
56091
+ const { error, value } = schema2.validate({ _id: req.params.id });
56092
+ if (error) {
56093
+ logger189.log({ level: "error", message: error.message });
56094
+ next(new BadRequestError215(error.message));
56095
+ return;
56096
+ }
56097
+ try {
56098
+ const data = await _getById(value._id);
56099
+ res.status(200).json(data);
56100
+ return;
56101
+ } catch (error2) {
56102
+ logger189.log({ level: "error", message: error2.message });
56103
+ next(error2);
56104
+ return;
56105
+ }
56106
+ }
56107
+ return {
56108
+ addFavorite,
56109
+ getById
56110
+ };
56111
+ }
56112
+
56113
+ // src/models/category-preloved.model.ts
56114
+ import Joi137 from "joi";
56115
+ import { ObjectId as ObjectId135 } from "mongodb";
56116
+ var schemaCategoryPreloved = Joi137.object({
56117
+ name: Joi137.string().required(),
56118
+ createdBy: Joi137.string().hex().optional().allow("", null),
56119
+ site: Joi137.string().hex().optional().allow("", null)
55888
56120
  });
55889
- var schemaUpdateCategoryPreloved = Joi135.object({
55890
- name: Joi135.string().optional().allow("", null),
55891
- site: Joi135.string().hex().optional().allow("", null)
56121
+ var schemaUpdateCategoryPreloved = Joi137.object({
56122
+ name: Joi137.string().optional().allow("", null),
56123
+ site: Joi137.string().hex().optional().allow("", null)
55892
56124
  });
55893
56125
  function MCategoryPreloved(value) {
55894
56126
  const { error } = schemaCategoryPreloved.validate(value);
@@ -55897,14 +56129,14 @@ function MCategoryPreloved(value) {
55897
56129
  }
55898
56130
  if (value.createdBy && typeof value.createdBy === "string") {
55899
56131
  try {
55900
- value.createdBy = new ObjectId133(value.createdBy);
56132
+ value.createdBy = new ObjectId135(value.createdBy);
55901
56133
  } catch {
55902
56134
  throw new Error("Invalid createdBy ID.");
55903
56135
  }
55904
56136
  }
55905
56137
  if (value.site && typeof value.site === "string") {
55906
56138
  try {
55907
- value.site = new ObjectId133(value.site);
56139
+ value.site = new ObjectId135(value.site);
55908
56140
  } catch {
55909
56141
  throw new Error("Invalid site ID.");
55910
56142
  }
@@ -55920,16 +56152,16 @@ function MCategoryPreloved(value) {
55920
56152
 
55921
56153
  // src/repositories/category-preloved.repo.ts
55922
56154
  import {
55923
- BadRequestError as BadRequestError214,
55924
- InternalServerError as InternalServerError76,
55925
- NotFoundError as NotFoundError58,
55926
- useAtlas as useAtlas119
56155
+ BadRequestError as BadRequestError216,
56156
+ InternalServerError as InternalServerError77,
56157
+ NotFoundError as NotFoundError59,
56158
+ useAtlas as useAtlas121
55927
56159
  } from "@7365admin1/node-server-utils";
55928
- import { ObjectId as ObjectId134 } from "mongodb";
56160
+ import { ObjectId as ObjectId136 } from "mongodb";
55929
56161
  function useCategoryPrelovedRepo() {
55930
- const db = useAtlas119.getDb();
56162
+ const db = useAtlas121.getDb();
55931
56163
  if (!db) {
55932
- throw new InternalServerError76("Unable to connect to server.");
56164
+ throw new InternalServerError77("Unable to connect to server.");
55933
56165
  }
55934
56166
  const CATEGORY_COLLECTION = "category-preloved";
55935
56167
  const collection = db.collection(CATEGORY_COLLECTION);
@@ -55939,9 +56171,9 @@ function useCategoryPrelovedRepo() {
55939
56171
  } = {}) {
55940
56172
  if (site) {
55941
56173
  try {
55942
- site = new ObjectId134(site);
56174
+ site = new ObjectId136(site);
55943
56175
  } catch {
55944
- throw new BadRequestError214("Invalid site ID format.");
56176
+ throw new BadRequestError216("Invalid site ID format.");
55945
56177
  }
55946
56178
  }
55947
56179
  const query = {
@@ -55958,14 +56190,14 @@ function useCategoryPrelovedRepo() {
55958
56190
  async function getById(_id) {
55959
56191
  let objectId2;
55960
56192
  try {
55961
- objectId2 = new ObjectId134(_id);
56193
+ objectId2 = new ObjectId136(_id);
55962
56194
  } catch {
55963
- throw new BadRequestError214("Invalid category-preloved ID format.");
56195
+ throw new BadRequestError216("Invalid category-preloved ID format.");
55964
56196
  }
55965
56197
  try {
55966
56198
  const data = await collection.findOne({ _id: objectId2 });
55967
56199
  if (!data) {
55968
- throw new NotFoundError58("Category not found.");
56200
+ throw new NotFoundError59("Category not found.");
55969
56201
  }
55970
56202
  return data;
55971
56203
  } catch (error) {
@@ -55977,20 +56209,20 @@ function useCategoryPrelovedRepo() {
55977
56209
  }
55978
56210
 
55979
56211
  // src/controllers/category-preloved.controller.ts
55980
- import { BadRequestError as BadRequestError215, logger as logger189 } from "@7365admin1/node-server-utils";
55981
- import Joi136 from "joi";
56212
+ import { BadRequestError as BadRequestError217, logger as logger190 } from "@7365admin1/node-server-utils";
56213
+ import Joi138 from "joi";
55982
56214
  function useCategoryPrelovedController() {
55983
56215
  const { getAll: _getAll, getById: _getById } = useCategoryPrelovedRepo();
55984
56216
  async function getAll(req, res, next) {
55985
- const schema2 = Joi136.object({
55986
- search: Joi136.string().optional().allow("", null),
55987
- site: Joi136.string().hex().length(24).optional().allow("", null)
56217
+ const schema2 = Joi138.object({
56218
+ search: Joi138.string().optional().allow("", null),
56219
+ site: Joi138.string().hex().length(24).optional().allow("", null)
55988
56220
  });
55989
56221
  const { error, value } = schema2.validate(req.query, { abortEarly: false });
55990
56222
  if (error) {
55991
56223
  const messages = error.details.map((d) => d.message).join(", ");
55992
- logger189.log({ level: "error", message: messages });
55993
- next(new BadRequestError215(messages));
56224
+ logger190.log({ level: "error", message: messages });
56225
+ next(new BadRequestError217(messages));
55994
56226
  return;
55995
56227
  }
55996
56228
  try {
@@ -55998,19 +56230,19 @@ function useCategoryPrelovedController() {
55998
56230
  res.status(200).json({ data });
55999
56231
  return;
56000
56232
  } catch (error2) {
56001
- logger189.log({ level: "error", message: error2.message });
56233
+ logger190.log({ level: "error", message: error2.message });
56002
56234
  next(error2);
56003
56235
  return;
56004
56236
  }
56005
56237
  }
56006
56238
  async function getById(req, res, next) {
56007
- const schema2 = Joi136.object({
56008
- _id: Joi136.string().hex().length(24).required()
56239
+ const schema2 = Joi138.object({
56240
+ _id: Joi138.string().hex().length(24).required()
56009
56241
  });
56010
56242
  const { error, value } = schema2.validate({ _id: req.params.id });
56011
56243
  if (error) {
56012
- logger189.log({ level: "error", message: error.message });
56013
- next(new BadRequestError215(error.message));
56244
+ logger190.log({ level: "error", message: error.message });
56245
+ next(new BadRequestError217(error.message));
56014
56246
  return;
56015
56247
  }
56016
56248
  try {
@@ -56018,7 +56250,7 @@ function useCategoryPrelovedController() {
56018
56250
  res.status(200).json({ data });
56019
56251
  return;
56020
56252
  } catch (error2) {
56021
- logger189.log({ level: "error", message: error2.message });
56253
+ logger190.log({ level: "error", message: error2.message });
56022
56254
  next(error2);
56023
56255
  return;
56024
56256
  }
@@ -56027,18 +56259,18 @@ function useCategoryPrelovedController() {
56027
56259
  }
56028
56260
 
56029
56261
  // src/models/subcategory-preloved.model.ts
56030
- import Joi137 from "joi";
56031
- import { ObjectId as ObjectId135 } from "mongodb";
56032
- var schemaSubcategoryPreloved = Joi137.object({
56033
- name: Joi137.string().required(),
56034
- createdBy: Joi137.string().hex().optional().allow("", null),
56035
- site: Joi137.string().hex().optional().allow("", null),
56036
- category_id: Joi137.string().hex().required()
56262
+ import Joi139 from "joi";
56263
+ import { ObjectId as ObjectId137 } from "mongodb";
56264
+ var schemaSubcategoryPreloved = Joi139.object({
56265
+ name: Joi139.string().required(),
56266
+ createdBy: Joi139.string().hex().optional().allow("", null),
56267
+ site: Joi139.string().hex().optional().allow("", null),
56268
+ category_id: Joi139.string().hex().required()
56037
56269
  });
56038
- var schemaUpdateSubcategoryPreloved = Joi137.object({
56039
- name: Joi137.string().optional().allow("", null),
56040
- site: Joi137.string().hex().optional().allow("", null),
56041
- category_id: Joi137.string().hex().optional().allow("", null)
56270
+ var schemaUpdateSubcategoryPreloved = Joi139.object({
56271
+ name: Joi139.string().optional().allow("", null),
56272
+ site: Joi139.string().hex().optional().allow("", null),
56273
+ category_id: Joi139.string().hex().optional().allow("", null)
56042
56274
  });
56043
56275
  function MSubcategoryPreloved(value) {
56044
56276
  const { error } = schemaSubcategoryPreloved.validate(value);
@@ -56047,21 +56279,21 @@ function MSubcategoryPreloved(value) {
56047
56279
  }
56048
56280
  if (value.createdBy && typeof value.createdBy === "string") {
56049
56281
  try {
56050
- value.createdBy = new ObjectId135(value.createdBy);
56282
+ value.createdBy = new ObjectId137(value.createdBy);
56051
56283
  } catch {
56052
56284
  throw new Error("Invalid createdBy ID.");
56053
56285
  }
56054
56286
  }
56055
56287
  if (value.site && typeof value.site === "string") {
56056
56288
  try {
56057
- value.site = new ObjectId135(value.site);
56289
+ value.site = new ObjectId137(value.site);
56058
56290
  } catch {
56059
56291
  throw new Error("Invalid site ID.");
56060
56292
  }
56061
56293
  }
56062
56294
  if (value.category_id && typeof value.category_id === "string") {
56063
56295
  try {
56064
- value.category_id = new ObjectId135(value.category_id);
56296
+ value.category_id = new ObjectId137(value.category_id);
56065
56297
  } catch {
56066
56298
  throw new Error("Invalid category ID.");
56067
56299
  }
@@ -56078,16 +56310,16 @@ function MSubcategoryPreloved(value) {
56078
56310
 
56079
56311
  // src/repositories/subcategory-preloved.repo.ts
56080
56312
  import {
56081
- BadRequestError as BadRequestError216,
56082
- InternalServerError as InternalServerError77,
56083
- NotFoundError as NotFoundError59,
56084
- useAtlas as useAtlas120
56313
+ BadRequestError as BadRequestError218,
56314
+ InternalServerError as InternalServerError78,
56315
+ NotFoundError as NotFoundError60,
56316
+ useAtlas as useAtlas122
56085
56317
  } from "@7365admin1/node-server-utils";
56086
- import { ObjectId as ObjectId136 } from "mongodb";
56318
+ import { ObjectId as ObjectId138 } from "mongodb";
56087
56319
  function useSubcategoryPrelovedRepo() {
56088
- const db = useAtlas120.getDb();
56320
+ const db = useAtlas122.getDb();
56089
56321
  if (!db) {
56090
- throw new InternalServerError77("Unable to connect to server.");
56322
+ throw new InternalServerError78("Unable to connect to server.");
56091
56323
  }
56092
56324
  const SUBCATEGORY_COLLECTION = "subcategory-preloved";
56093
56325
  const collection = db.collection(SUBCATEGORY_COLLECTION);
@@ -56098,16 +56330,16 @@ function useSubcategoryPrelovedRepo() {
56098
56330
  } = {}) {
56099
56331
  if (site) {
56100
56332
  try {
56101
- site = new ObjectId136(site);
56333
+ site = new ObjectId138(site);
56102
56334
  } catch {
56103
- throw new BadRequestError216("Invalid site ID format.");
56335
+ throw new BadRequestError218("Invalid site ID format.");
56104
56336
  }
56105
56337
  }
56106
56338
  if (category_id) {
56107
56339
  try {
56108
- category_id = new ObjectId136(category_id);
56340
+ category_id = new ObjectId138(category_id);
56109
56341
  } catch {
56110
- throw new BadRequestError216("Invalid category ID format.");
56342
+ throw new BadRequestError218("Invalid category ID format.");
56111
56343
  }
56112
56344
  }
56113
56345
  const query = {
@@ -56124,14 +56356,14 @@ function useSubcategoryPrelovedRepo() {
56124
56356
  async function getById(_id) {
56125
56357
  let objectId2;
56126
56358
  try {
56127
- objectId2 = new ObjectId136(_id);
56359
+ objectId2 = new ObjectId138(_id);
56128
56360
  } catch {
56129
- throw new BadRequestError216("Invalid subcategory-preloved ID format.");
56361
+ throw new BadRequestError218("Invalid subcategory-preloved ID format.");
56130
56362
  }
56131
56363
  try {
56132
56364
  const data = await collection.findOne({ _id: objectId2 });
56133
56365
  if (!data) {
56134
- throw new NotFoundError59("Subcategory not found.");
56366
+ throw new NotFoundError60("Subcategory not found.");
56135
56367
  }
56136
56368
  return data;
56137
56369
  } catch (error) {
@@ -56142,21 +56374,21 @@ function useSubcategoryPrelovedRepo() {
56142
56374
  }
56143
56375
 
56144
56376
  // src/controllers/subcategory-preloved.controller.ts
56145
- import { BadRequestError as BadRequestError217, logger as logger190 } from "@7365admin1/node-server-utils";
56146
- import Joi138 from "joi";
56377
+ import { BadRequestError as BadRequestError219, logger as logger191 } from "@7365admin1/node-server-utils";
56378
+ import Joi140 from "joi";
56147
56379
  function useSubcategoryPrelovedController() {
56148
56380
  const { getAll: _getAll, getById: _getById } = useSubcategoryPrelovedRepo();
56149
56381
  async function getAll(req, res, next) {
56150
- const schema2 = Joi138.object({
56151
- search: Joi138.string().optional().allow("", null),
56152
- site: Joi138.string().hex().length(24).optional().allow("", null),
56153
- category_id: Joi138.string().hex().length(24).optional().allow("", null)
56382
+ const schema2 = Joi140.object({
56383
+ search: Joi140.string().optional().allow("", null),
56384
+ site: Joi140.string().hex().length(24).optional().allow("", null),
56385
+ category_id: Joi140.string().hex().length(24).optional().allow("", null)
56154
56386
  });
56155
56387
  const { error, value } = schema2.validate(req.query, { abortEarly: false });
56156
56388
  if (error) {
56157
56389
  const messages = error.details.map((d) => d.message).join(", ");
56158
- logger190.log({ level: "error", message: messages });
56159
- next(new BadRequestError217(messages));
56390
+ logger191.log({ level: "error", message: messages });
56391
+ next(new BadRequestError219(messages));
56160
56392
  return;
56161
56393
  }
56162
56394
  try {
@@ -56164,19 +56396,19 @@ function useSubcategoryPrelovedController() {
56164
56396
  res.status(200).json({ data });
56165
56397
  return;
56166
56398
  } catch (error2) {
56167
- logger190.log({ level: "error", message: error2.message });
56399
+ logger191.log({ level: "error", message: error2.message });
56168
56400
  next(error2);
56169
56401
  return;
56170
56402
  }
56171
56403
  }
56172
56404
  async function getById(req, res, next) {
56173
- const schema2 = Joi138.object({
56174
- _id: Joi138.string().hex().length(24).required()
56405
+ const schema2 = Joi140.object({
56406
+ _id: Joi140.string().hex().length(24).required()
56175
56407
  });
56176
56408
  const { error, value } = schema2.validate({ _id: req.params.id });
56177
56409
  if (error) {
56178
- logger190.log({ level: "error", message: error.message });
56179
- next(new BadRequestError217(error.message));
56410
+ logger191.log({ level: "error", message: error.message });
56411
+ next(new BadRequestError219(error.message));
56180
56412
  return;
56181
56413
  }
56182
56414
  try {
@@ -56184,7 +56416,7 @@ function useSubcategoryPrelovedController() {
56184
56416
  res.status(200).json({ data });
56185
56417
  return;
56186
56418
  } catch (error2) {
56187
- logger190.log({ level: "error", message: error2.message });
56419
+ logger191.log({ level: "error", message: error2.message });
56188
56420
  next(error2);
56189
56421
  return;
56190
56422
  }
@@ -56193,49 +56425,49 @@ function useSubcategoryPrelovedController() {
56193
56425
  }
56194
56426
 
56195
56427
  // src/models/online-forms-v2.model.ts
56196
- import Joi139 from "joi";
56197
- import { ObjectId as ObjectId137 } from "mongodb";
56428
+ import Joi141 from "joi";
56429
+ import { ObjectId as ObjectId139 } from "mongodb";
56198
56430
  var FormEntryStatus = /* @__PURE__ */ ((FormEntryStatus2) => {
56199
56431
  FormEntryStatus2["ACTIVE"] = "active";
56200
56432
  FormEntryStatus2["INACTIVE"] = "inactive";
56201
56433
  FormEntryStatus2["DELETED"] = "deleted";
56202
56434
  return FormEntryStatus2;
56203
56435
  })(FormEntryStatus || {});
56204
- var schemaFormEntry = Joi139.object({
56205
- _id: Joi139.string().hex().optional().allow("", null),
56206
- formType: Joi139.string().required(),
56207
- fields: Joi139.object().pattern(
56208
- Joi139.string(),
56209
- Joi139.alternatives().try(
56210
- Joi139.string(),
56211
- Joi139.number(),
56212
- Joi139.boolean(),
56213
- Joi139.valid(null)
56436
+ var schemaFormEntry = Joi141.object({
56437
+ _id: Joi141.string().hex().optional().allow("", null),
56438
+ formType: Joi141.string().required(),
56439
+ fields: Joi141.object().pattern(
56440
+ Joi141.string(),
56441
+ Joi141.alternatives().try(
56442
+ Joi141.string(),
56443
+ Joi141.number(),
56444
+ Joi141.boolean(),
56445
+ Joi141.valid(null)
56214
56446
  )
56215
56447
  ).required(),
56216
- status: Joi139.string().optional().allow("", null),
56217
- org: Joi139.string().hex().optional().allow("", null),
56218
- site: Joi139.string().hex().optional().allow("", null),
56219
- createdAt: Joi139.date().optional().allow("", null),
56220
- updatedAt: Joi139.date().optional().allow("", null),
56221
- deletedAt: Joi139.date().optional().allow("", null)
56448
+ status: Joi141.string().optional().allow("", null),
56449
+ org: Joi141.string().hex().optional().allow("", null),
56450
+ site: Joi141.string().hex().optional().allow("", null),
56451
+ createdAt: Joi141.date().optional().allow("", null),
56452
+ updatedAt: Joi141.date().optional().allow("", null),
56453
+ deletedAt: Joi141.date().optional().allow("", null)
56222
56454
  });
56223
- var schemaUpdateFormEntry = Joi139.object({
56224
- _id: Joi139.string().hex().required(),
56225
- formType: Joi139.string().optional().allow("", null),
56226
- fields: Joi139.object().pattern(
56227
- Joi139.string(),
56228
- Joi139.alternatives().try(
56229
- Joi139.string(),
56230
- Joi139.number(),
56231
- Joi139.boolean(),
56232
- Joi139.valid(null)
56455
+ var schemaUpdateFormEntry = Joi141.object({
56456
+ _id: Joi141.string().hex().required(),
56457
+ formType: Joi141.string().optional().allow("", null),
56458
+ fields: Joi141.object().pattern(
56459
+ Joi141.string(),
56460
+ Joi141.alternatives().try(
56461
+ Joi141.string(),
56462
+ Joi141.number(),
56463
+ Joi141.boolean(),
56464
+ Joi141.valid(null)
56233
56465
  )
56234
56466
  ).optional(),
56235
- status: Joi139.string().optional().allow("", null),
56236
- createdAt: Joi139.date().optional().allow("", null),
56237
- updatedAt: Joi139.date().optional().allow("", null),
56238
- deletedAt: Joi139.date().optional().allow("", null)
56467
+ status: Joi141.string().optional().allow("", null),
56468
+ createdAt: Joi141.date().optional().allow("", null),
56469
+ updatedAt: Joi141.date().optional().allow("", null),
56470
+ deletedAt: Joi141.date().optional().allow("", null)
56239
56471
  });
56240
56472
  function MFormEntry(value) {
56241
56473
  const { error } = schemaFormEntry.validate(value);
@@ -56244,21 +56476,21 @@ function MFormEntry(value) {
56244
56476
  }
56245
56477
  if (value._id && typeof value._id === "string") {
56246
56478
  try {
56247
- value._id = new ObjectId137(value._id);
56479
+ value._id = new ObjectId139(value._id);
56248
56480
  } catch {
56249
56481
  throw new Error("Invalid ID.");
56250
56482
  }
56251
56483
  }
56252
56484
  if (value.org && typeof value.org === "string") {
56253
56485
  try {
56254
- value.org = new ObjectId137(value.org);
56486
+ value.org = new ObjectId139(value.org);
56255
56487
  } catch {
56256
56488
  throw new Error("Invalid org ID.");
56257
56489
  }
56258
56490
  }
56259
56491
  if (value.site && typeof value.site === "string") {
56260
56492
  try {
56261
- value.site = new ObjectId137(value.site);
56493
+ value.site = new ObjectId139(value.site);
56262
56494
  } catch {
56263
56495
  throw new Error("Invalid site ID.");
56264
56496
  }
@@ -56278,17 +56510,17 @@ function MFormEntry(value) {
56278
56510
 
56279
56511
  // src/repositories/online-forms-v2.repository.ts
56280
56512
  import {
56281
- BadRequestError as BadRequestError218,
56282
- InternalServerError as InternalServerError78,
56283
- logger as logger191,
56284
- useAtlas as useAtlas121,
56513
+ BadRequestError as BadRequestError220,
56514
+ InternalServerError as InternalServerError79,
56515
+ logger as logger192,
56516
+ useAtlas as useAtlas123,
56285
56517
  useCache as useCache70
56286
56518
  } from "@7365admin1/node-server-utils";
56287
56519
  var online_forms_namespace_collection = "online-forms";
56288
56520
  function useFormEntryRepo() {
56289
- const db = useAtlas121.getDb();
56521
+ const db = useAtlas123.getDb();
56290
56522
  if (!db) {
56291
- throw new InternalServerError78("Unable to connect to server.");
56523
+ throw new InternalServerError79("Unable to connect to server.");
56292
56524
  }
56293
56525
  const collection = db.collection(online_forms_namespace_collection);
56294
56526
  const { delNamespace, getCache, setCache } = useCache70(
@@ -56300,7 +56532,7 @@ function useFormEntryRepo() {
56300
56532
  name: "text"
56301
56533
  });
56302
56534
  } catch (error) {
56303
- throw new InternalServerError78(
56535
+ throw new InternalServerError79(
56304
56536
  "Failed to create text index on online form."
56305
56537
  );
56306
56538
  }
@@ -56310,11 +56542,11 @@ function useFormEntryRepo() {
56310
56542
  value = MFormEntry(value);
56311
56543
  const res = await collection.insertOne(value, { session });
56312
56544
  delNamespace().then(() => {
56313
- logger191.info(
56545
+ logger192.info(
56314
56546
  `Cache cleared for namespace: ${online_forms_namespace_collection}`
56315
56547
  );
56316
56548
  }).catch((err) => {
56317
- logger191.error(
56549
+ logger192.error(
56318
56550
  `Failed to clear cache for namespace: ${online_forms_namespace_collection}`,
56319
56551
  err
56320
56552
  );
@@ -56323,7 +56555,7 @@ function useFormEntryRepo() {
56323
56555
  } catch (error) {
56324
56556
  const isDuplicated = error.message.includes("duplicate");
56325
56557
  if (isDuplicated) {
56326
- throw new BadRequestError218("Online Form already exists.");
56558
+ throw new BadRequestError220("Online Form already exists.");
56327
56559
  }
56328
56560
  throw error;
56329
56561
  }
@@ -56335,7 +56567,7 @@ function useFormEntryRepo() {
56335
56567
  }
56336
56568
 
56337
56569
  // src/controllers/online-forms-v2.controller.ts
56338
- import { BadRequestError as BadRequestError219, logger as logger192 } from "@7365admin1/node-server-utils";
56570
+ import { BadRequestError as BadRequestError221, logger as logger193 } from "@7365admin1/node-server-utils";
56339
56571
  import ExcelJS3 from "exceljs";
56340
56572
  import fs5 from "fs";
56341
56573
  function useFormEntryController() {
@@ -56353,14 +56585,14 @@ function useFormEntryController() {
56353
56585
  async function uploadFormEntrys(req, res, next) {
56354
56586
  try {
56355
56587
  if (!req.file) {
56356
- next(new BadRequestError219("Excel file is required."));
56588
+ next(new BadRequestError221("Excel file is required."));
56357
56589
  return;
56358
56590
  }
56359
56591
  const workbook = new ExcelJS3.Workbook();
56360
56592
  await workbook.xlsx.readFile(req.file.path);
56361
56593
  const worksheet = workbook.worksheets[0];
56362
56594
  if (!worksheet) {
56363
- next(new BadRequestError219("No worksheet found in uploaded Excel file."));
56595
+ next(new BadRequestError221("No worksheet found in uploaded Excel file."));
56364
56596
  return;
56365
56597
  }
56366
56598
  const headerRow = worksheet.getRow(1);
@@ -56381,8 +56613,8 @@ function useFormEntryController() {
56381
56613
  });
56382
56614
  if (error) {
56383
56615
  const messages = error.details.map((d) => d.message).join(", ");
56384
- logger192.log({ level: "error", message: messages });
56385
- next(new BadRequestError219(messages));
56616
+ logger193.log({ level: "error", message: messages });
56617
+ next(new BadRequestError221(messages));
56386
56618
  return;
56387
56619
  }
56388
56620
  const result = await _add(value);
@@ -56390,7 +56622,7 @@ function useFormEntryController() {
56390
56622
  fs5.unlink(req.file.path, () => {
56391
56623
  });
56392
56624
  } catch (error) {
56393
- logger192.log({ level: "error", message: error.message });
56625
+ logger193.log({ level: "error", message: error.message });
56394
56626
  next(error);
56395
56627
  }
56396
56628
  }
@@ -56400,11 +56632,11 @@ function useFormEntryController() {
56400
56632
  }
56401
56633
 
56402
56634
  // src/services/building-level.service.ts
56403
- import { useAtlas as useAtlas122 } from "@7365admin1/node-server-utils";
56635
+ import { useAtlas as useAtlas124 } from "@7365admin1/node-server-utils";
56404
56636
  function useBuildingLevelService() {
56405
56637
  const { add: _add, updateLevelById: _updateLevelById } = useBuildingLevelRepo();
56406
56638
  async function add(value) {
56407
- const session = useAtlas122.getClient()?.startSession();
56639
+ const session = useAtlas124.getClient()?.startSession();
56408
56640
  try {
56409
56641
  session?.startTransaction();
56410
56642
  await _add(value, session);
@@ -56418,7 +56650,7 @@ function useBuildingLevelService() {
56418
56650
  }
56419
56651
  }
56420
56652
  async function updateLevelById(_id, value) {
56421
- const session = useAtlas122.getClient()?.startSession();
56653
+ const session = useAtlas124.getClient()?.startSession();
56422
56654
  try {
56423
56655
  session?.startTransaction();
56424
56656
  await _updateLevelById(_id, value, session);
@@ -56438,8 +56670,8 @@ function useBuildingLevelService() {
56438
56670
  }
56439
56671
 
56440
56672
  // src/controllers/building-level.controller.ts
56441
- import { BadRequestError as BadRequestError220, logger as logger193 } from "@7365admin1/node-server-utils";
56442
- import Joi140 from "joi";
56673
+ import { BadRequestError as BadRequestError222, logger as logger194 } from "@7365admin1/node-server-utils";
56674
+ import Joi142 from "joi";
56443
56675
  function useBuildingLevelController() {
56444
56676
  const { add: _add, updateLevelById: _updateLevelById } = useBuildingLevelService();
56445
56677
  const {
@@ -56454,8 +56686,8 @@ function useBuildingLevelController() {
56454
56686
  });
56455
56687
  if (error) {
56456
56688
  const messages = error.details.map((d) => d.message).join(", ");
56457
- logger193.log({ level: "error", message: messages });
56458
- next(new BadRequestError220(messages));
56689
+ logger194.log({ level: "error", message: messages });
56690
+ next(new BadRequestError222(messages));
56459
56691
  return;
56460
56692
  }
56461
56693
  const result = await _add(value);
@@ -56466,20 +56698,20 @@ function useBuildingLevelController() {
56466
56698
  }
56467
56699
  async function getAll(req, res, next) {
56468
56700
  try {
56469
- const validation = Joi140.object({
56470
- page: Joi140.number().min(1).optional().default(1),
56471
- limit: Joi140.number().min(1).optional().default(20),
56472
- search: Joi140.string().optional().allow("", null),
56473
- site: Joi140.string().hex().length(24).optional().allow("", null),
56474
- status: Joi140.string().valid(...Object.values(BuildingLevelStatus)).default("active" /* ACTIVE */)
56701
+ const validation = Joi142.object({
56702
+ page: Joi142.number().min(1).optional().default(1),
56703
+ limit: Joi142.number().min(1).optional().default(20),
56704
+ search: Joi142.string().optional().allow("", null),
56705
+ site: Joi142.string().hex().length(24).optional().allow("", null),
56706
+ status: Joi142.string().valid(...Object.values(BuildingLevelStatus)).default("active" /* ACTIVE */)
56475
56707
  });
56476
56708
  const { error, value } = validation.validate(req.query, {
56477
56709
  abortEarly: false
56478
56710
  });
56479
56711
  if (error) {
56480
56712
  const messages = error.details.map((d) => d.message);
56481
- logger193.log({ level: "error", message: messages.join(", ") });
56482
- next(new BadRequestError220(messages.join(", ")));
56713
+ logger194.log({ level: "error", message: messages.join(", ") });
56714
+ next(new BadRequestError222(messages.join(", ")));
56483
56715
  return;
56484
56716
  }
56485
56717
  const { page, limit, status, site, search } = value;
@@ -56498,14 +56730,14 @@ function useBuildingLevelController() {
56498
56730
  }
56499
56731
  async function getById(req, res, next) {
56500
56732
  try {
56501
- const schema2 = Joi140.object({
56502
- id: Joi140.string().hex().length(24).required()
56733
+ const schema2 = Joi142.object({
56734
+ id: Joi142.string().hex().length(24).required()
56503
56735
  });
56504
56736
  const { error, value } = schema2.validate({ id: req.params.id });
56505
56737
  if (error) {
56506
56738
  const messages = error.details.map((d) => d.message);
56507
- logger193.log({ level: "error", message: messages.join(", ") });
56508
- next(new BadRequestError220(messages.join(", ")));
56739
+ logger194.log({ level: "error", message: messages.join(", ") });
56740
+ next(new BadRequestError222(messages.join(", ")));
56509
56741
  return;
56510
56742
  }
56511
56743
  const { id } = value;
@@ -56524,8 +56756,8 @@ function useBuildingLevelController() {
56524
56756
  });
56525
56757
  if (error) {
56526
56758
  const messages = error.details.map((d) => d.message);
56527
- logger193.log({ level: "error", message: messages.join(", ") });
56528
- next(new BadRequestError220(messages.join(", ")));
56759
+ logger194.log({ level: "error", message: messages.join(", ") });
56760
+ next(new BadRequestError222(messages.join(", ")));
56529
56761
  return;
56530
56762
  }
56531
56763
  const { _id, ...rest } = value;
@@ -56537,14 +56769,14 @@ function useBuildingLevelController() {
56537
56769
  }
56538
56770
  async function deleteById(req, res, next) {
56539
56771
  try {
56540
- const schema2 = Joi140.object({
56541
- id: Joi140.string().hex().required()
56772
+ const schema2 = Joi142.object({
56773
+ id: Joi142.string().hex().required()
56542
56774
  });
56543
56775
  const { error, value } = schema2.validate({ id: req.params.id });
56544
56776
  if (error) {
56545
56777
  const messages = error.details.map((d) => d.message);
56546
- logger193.log({ level: "error", message: messages.join(", ") });
56547
- next(new BadRequestError220(messages.join(", ")));
56778
+ logger194.log({ level: "error", message: messages.join(", ") });
56779
+ next(new BadRequestError222(messages.join(", ")));
56548
56780
  return;
56549
56781
  }
56550
56782
  const { id } = value;
@@ -56639,6 +56871,7 @@ export {
56639
56871
  MPatrolRoute,
56640
56872
  MPerson,
56641
56873
  MPost,
56874
+ MPostFavorite,
56642
56875
  MPromoCode,
56643
56876
  MRobot,
56644
56877
  MRole,
@@ -56774,6 +57007,7 @@ export {
56774
57007
  schemaPerson,
56775
57008
  schemaPlate,
56776
57009
  schemaPost,
57010
+ schemaPostFavorite,
56777
57011
  schemaServiceProvider,
56778
57012
  schemaServiceProviderBilling,
56779
57013
  schemaSiteCamera,
@@ -56945,6 +57179,9 @@ export {
56945
57179
  usePatrolRouteRepo,
56946
57180
  usePersonController,
56947
57181
  usePersonRepo,
57182
+ usePostFavoriteController,
57183
+ usePostFavoriteRepo,
57184
+ usePostFavoriteService,
56948
57185
  usePostPrelovedController,
56949
57186
  usePostPrelovedRepo,
56950
57187
  usePriceController,