@7365admin1/core 2.69.0 → 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.js CHANGED
@@ -105,6 +105,7 @@ __export(src_exports, {
105
105
  MPatrolRoute: () => MPatrolRoute,
106
106
  MPerson: () => MPerson,
107
107
  MPost: () => MPost,
108
+ MPostFavorite: () => MPostFavorite,
108
109
  MPromoCode: () => MPromoCode,
109
110
  MRobot: () => MRobot,
110
111
  MRole: () => MRole,
@@ -240,6 +241,7 @@ __export(src_exports, {
240
241
  schemaPerson: () => schemaPerson,
241
242
  schemaPlate: () => schemaPlate,
242
243
  schemaPost: () => schemaPost,
244
+ schemaPostFavorite: () => schemaPostFavorite,
243
245
  schemaServiceProvider: () => schemaServiceProvider,
244
246
  schemaServiceProviderBilling: () => schemaServiceProviderBilling,
245
247
  schemaSiteCamera: () => schemaSiteCamera,
@@ -411,6 +413,9 @@ __export(src_exports, {
411
413
  usePatrolRouteRepo: () => usePatrolRouteRepo,
412
414
  usePersonController: () => usePersonController,
413
415
  usePersonRepo: () => usePersonRepo,
416
+ usePostFavoriteController: () => usePostFavoriteController,
417
+ usePostFavoriteRepo: () => usePostFavoriteRepo,
418
+ usePostFavoriteService: () => usePostFavoriteService,
414
419
  usePostPrelovedController: () => usePostPrelovedController,
415
420
  usePostPrelovedRepo: () => usePostPrelovedRepo,
416
421
  usePriceController: () => usePriceController,
@@ -6995,6 +7000,7 @@ var MFile = class {
6995
7000
  this._id = value._id;
6996
7001
  this.name = value.name ?? "";
6997
7002
  this.type = value.type ?? "public";
7003
+ this.size = value.size ?? 0;
6998
7004
  this.status = value.status ?? "draft";
6999
7005
  this.createdAt = value.createdAt ?? (/* @__PURE__ */ new Date()).toISOString();
7000
7006
  }
@@ -8994,6 +9000,7 @@ function useFileService() {
8994
9000
  session?.startTransaction();
8995
9001
  const file = {
8996
9002
  name: value.originalname,
9003
+ size: value.size ?? (value.buffer ? value.buffer.length : 0),
8997
9004
  createdAt: (/* @__PURE__ */ new Date()).toISOString()
8998
9005
  };
8999
9006
  try {
@@ -32019,6 +32026,7 @@ var schemaDocumentManagement = import_joi75.default.object({
32019
32026
  _id: import_joi75.default.string().hex().optional().allow("", null),
32020
32027
  name: import_joi75.default.string().required(),
32021
32028
  type: import_joi75.default.string().optional().allow("", null),
32029
+ size: import_joi75.default.number().optional().allow(null, "").default(0),
32022
32030
  attachment: import_joi75.default.when("type", { is: "folder", then: import_joi75.default.forbidden(), otherwise: import_joi75.default.string().optional().allow("", null) }),
32023
32031
  remarks: import_joi75.default.string().optional().allow("", null),
32024
32032
  org: import_joi75.default.string().hex().optional().allow("", null),
@@ -32034,6 +32042,7 @@ var schemaUpdateDocumentManagement = import_joi75.default.object({
32034
32042
  _id: import_joi75.default.string().hex().required(),
32035
32043
  name: import_joi75.default.string().optional().allow("", null),
32036
32044
  type: import_joi75.default.string().optional().allow("", null),
32045
+ size: import_joi75.default.number().optional().allow(null, ""),
32037
32046
  attachment: import_joi75.default.when("type", { is: "folder", then: import_joi75.default.forbidden(), otherwise: import_joi75.default.string().optional().allow("", null) }),
32038
32047
  remarks: import_joi75.default.string().optional().allow("", null),
32039
32048
  org: import_joi75.default.string().hex().optional().allow("", null),
@@ -32080,6 +32089,7 @@ function MDocumentManagement(value) {
32080
32089
  _id: value._id,
32081
32090
  name: value.name,
32082
32091
  type: value.type,
32092
+ size: value.size ?? 0,
32083
32093
  attachment: value.attachment,
32084
32094
  remarks: value.remarks ?? "",
32085
32095
  org: value.org,
@@ -32203,7 +32213,7 @@ function useDocumentManagementRepo() {
32203
32213
  try {
32204
32214
  const items = await collection.aggregate([
32205
32215
  { $match: query },
32206
- { $sort: { _id: -1 } },
32216
+ { $sort: { createdAt: -1 } },
32207
32217
  {
32208
32218
  $project: {
32209
32219
  parentId: 1,
@@ -32215,7 +32225,9 @@ function useDocumentManagementRepo() {
32215
32225
  remarks: 1,
32216
32226
  attachment: 1
32217
32227
  }
32218
- }
32228
+ },
32229
+ { $skip: page * limit },
32230
+ { $limit: limit }
32219
32231
  ]).toArray();
32220
32232
  const length = await collection.countDocuments(query);
32221
32233
  const data = (0, import_node_server_utils136.paginate)(items, page, limit, length);
@@ -32243,32 +32255,21 @@ function useDocumentManagementRepo() {
32243
32255
  }
32244
32256
  try {
32245
32257
  const data = await collection.aggregate([
32246
- { $match: { _id, status: { $ne: "deleted" } } },
32247
- {
32248
- $lookup: {
32249
- from: "users",
32250
- localField: "createdBy",
32251
- foreignField: "_id",
32252
- as: "userInfo",
32253
- pipeline: [{ $project: { name: 1 } }]
32254
- }
32255
- },
32256
32258
  {
32257
- $unwind: {
32258
- path: "$userInfo",
32259
- preserveNullAndEmptyArrays: true
32259
+ $match: {
32260
+ _id,
32261
+ status: { $ne: "deleted" }
32260
32262
  }
32261
32263
  },
32262
32264
  {
32263
32265
  $project: {
32264
32266
  name: 1,
32265
32267
  type: 1,
32266
- status: 1,
32267
- attachment: 1,
32268
+ size: 1,
32268
32269
  createdAt: 1,
32269
32270
  updatedAt: 1,
32270
- createdBy: 1,
32271
- createdByName: "$userInfo.name"
32271
+ attachment: 1,
32272
+ remarks: 1
32272
32273
  }
32273
32274
  }
32274
32275
  ]).toArray();
@@ -32397,8 +32398,8 @@ function useDocumentManagementRepo() {
32397
32398
  // src/services/document-management.service.ts
32398
32399
  var import_node_server_utils137 = require("@7365admin1/node-server-utils");
32399
32400
  function useDocumentManagementService() {
32400
- const { add: _add } = useDocumentManagementRepo();
32401
- const { updateStatusById } = useFileRepo();
32401
+ const { add: _add, updateDocumentById: _updateDocumentById } = useDocumentManagementRepo();
32402
+ const { updateStatusById, getFileById } = useFileRepo();
32402
32403
  async function createDocument(value) {
32403
32404
  const session = import_node_server_utils137.useAtlas.getClient()?.startSession();
32404
32405
  if (!session) {
@@ -32416,6 +32417,9 @@ function useDocumentManagementService() {
32416
32417
  if (!file) {
32417
32418
  throw new import_node_server_utils137.NotFoundError("File not found.");
32418
32419
  }
32420
+ const { getFileById: getFileById2 } = useFileRepo();
32421
+ const storedFile = await getFileById2(document2);
32422
+ value.size = storedFile?.size ?? storedFile?.file_size ?? 0;
32419
32423
  }
32420
32424
  await _add(value, session);
32421
32425
  await session?.commitTransaction();
@@ -32427,8 +32431,35 @@ function useDocumentManagementService() {
32427
32431
  session?.endSession();
32428
32432
  }
32429
32433
  }
32434
+ async function updateDocumentById(_id, value) {
32435
+ if (value?.name) {
32436
+ value.name = value.name.toString().trim();
32437
+ }
32438
+ if (value?.type === "folder") {
32439
+ delete value.attachment;
32440
+ delete value.size;
32441
+ } else {
32442
+ if (Array.isArray(value.attachment)) {
32443
+ value.attachment = value.attachment[0];
32444
+ } else if (!value.attachment) {
32445
+ value.attachment = "";
32446
+ }
32447
+ if (value.attachment) {
32448
+ try {
32449
+ const f = await getFileById(value.attachment);
32450
+ value.size = f?.size ?? f?.file_size ?? 0;
32451
+ } catch (err) {
32452
+ value.size = 0;
32453
+ }
32454
+ } else {
32455
+ value.size = 0;
32456
+ }
32457
+ }
32458
+ return await _updateDocumentById(_id, value);
32459
+ }
32430
32460
  return {
32431
- createDocument
32461
+ createDocument,
32462
+ updateDocumentById
32432
32463
  };
32433
32464
  }
32434
32465
 
@@ -32436,11 +32467,10 @@ function useDocumentManagementService() {
32436
32467
  var import_node_server_utils138 = require("@7365admin1/node-server-utils");
32437
32468
  var import_joi76 = __toESM(require("joi"));
32438
32469
  function useDocumentManagementController() {
32439
- const { createDocument: _add } = useDocumentManagementService();
32470
+ const { createDocument: _add, updateDocumentById: _updateDocumentById } = useDocumentManagementService();
32440
32471
  const {
32441
32472
  getAll: _getDocuments,
32442
32473
  getDocumentById: _getDocumentById,
32443
- updateDocumentById: _updateDocumentById,
32444
32474
  deleteDocumentById: _deleteDocumentById,
32445
32475
  getDocumentManagementBySiteId: _getDocumentManagementBySiteId
32446
32476
  } = useDocumentManagementRepo();
@@ -32456,6 +32486,9 @@ function useDocumentManagementController() {
32456
32486
  createdBy = req.body.createdBy;
32457
32487
  }
32458
32488
  const payload = { ...req.body, createdBy };
32489
+ if (payload.size !== void 0) {
32490
+ delete payload.size;
32491
+ }
32459
32492
  if (payload.type === "folder") {
32460
32493
  delete payload.attachment;
32461
32494
  } else {
@@ -32572,14 +32605,8 @@ function useDocumentManagementController() {
32572
32605
  }
32573
32606
  const _id = req.params.id;
32574
32607
  const payload = { ...req.body, updatedBy };
32575
- if (payload.type === "folder") {
32576
- delete payload.attachment;
32577
- } else {
32578
- if (Array.isArray(payload.attachment)) {
32579
- payload.attachment = payload.attachment[0];
32580
- } else if (!payload.attachment) {
32581
- payload.attachment = "";
32582
- }
32608
+ if (payload.size !== void 0) {
32609
+ delete payload.size;
32583
32610
  }
32584
32611
  const { error } = validation.validate({ _id, ...payload });
32585
32612
  if (error) {
@@ -39422,6 +39449,15 @@ function UseAccessManagementRepo() {
39422
39449
  throw new Error(error.message);
39423
39450
  }
39424
39451
  }
39452
+ async function removeTemplateRepo({ site }) {
39453
+ site = new import_mongodb92.ObjectId(site);
39454
+ try {
39455
+ const result = await collectionName("entrypass-settings").updateOne({ _id: site }, { $set: { "settings.template": {} } });
39456
+ return result;
39457
+ } catch (error) {
39458
+ throw new Error(error.message);
39459
+ }
39460
+ }
39425
39461
  return {
39426
39462
  createIndexes,
39427
39463
  createIndexForEntrypass,
@@ -39459,7 +39495,8 @@ function UseAccessManagementRepo() {
39459
39495
  visitorCheckoutRepo,
39460
39496
  uploadTemplateRepo,
39461
39497
  getResidentsRepo,
39462
- userAccessCardsRepo
39498
+ userAccessCardsRepo,
39499
+ removeTemplateRepo
39463
39500
  };
39464
39501
  }
39465
39502
 
@@ -39505,7 +39542,8 @@ function useAccessManagementSvc() {
39505
39542
  visitorCheckoutRepo,
39506
39543
  uploadTemplateRepo,
39507
39544
  getResidentsRepo,
39508
- userAccessCardsRepo
39545
+ userAccessCardsRepo,
39546
+ removeTemplateRepo
39509
39547
  } = UseAccessManagementRepo();
39510
39548
  const addPhysicalCardSvc = async (payload) => {
39511
39549
  try {
@@ -39883,6 +39921,14 @@ function useAccessManagementSvc() {
39883
39921
  throw new Error(err.message);
39884
39922
  }
39885
39923
  };
39924
+ const removeTemplateSvc = async ({ site }) => {
39925
+ try {
39926
+ const response = await removeTemplateRepo({ site });
39927
+ return response;
39928
+ } catch (err) {
39929
+ throw new Error(err.message);
39930
+ }
39931
+ };
39886
39932
  return {
39887
39933
  addPhysicalCardSvc,
39888
39934
  addNonPhysicalCardSvc,
@@ -39923,7 +39969,8 @@ function useAccessManagementSvc() {
39923
39969
  visitorCheckoutSvc,
39924
39970
  uploadTemplateSvc,
39925
39971
  getResidentsSvc,
39926
- userAccessCardsSvc
39972
+ userAccessCardsSvc,
39973
+ removeTemplateSvc
39927
39974
  };
39928
39975
  }
39929
39976
 
@@ -39969,7 +40016,8 @@ function useAccessManagementController() {
39969
40016
  visitorCheckoutSvc,
39970
40017
  uploadTemplateSvc,
39971
40018
  getResidentsSvc,
39972
- userAccessCardsSvc
40019
+ userAccessCardsSvc,
40020
+ removeTemplateSvc
39973
40021
  } = useAccessManagementSvc();
39974
40022
  const addPhysicalCard = async (req, res) => {
39975
40023
  try {
@@ -41019,6 +41067,25 @@ function useAccessManagementController() {
41019
41067
  });
41020
41068
  }
41021
41069
  };
41070
+ const removeTemplate = async (req, res) => {
41071
+ try {
41072
+ const { site } = req.query;
41073
+ const schema2 = import_joi87.default.object({
41074
+ site: import_joi87.default.string().hex().required()
41075
+ });
41076
+ const { error } = schema2.validate({ site });
41077
+ if (error) {
41078
+ return res.status(400).json({ message: error.message });
41079
+ }
41080
+ const result = await removeTemplateSvc({ site });
41081
+ return res.status(200).json({ data: result });
41082
+ } catch (error) {
41083
+ return res.status(400).json({
41084
+ data: null,
41085
+ message: error.message
41086
+ });
41087
+ }
41088
+ };
41022
41089
  return {
41023
41090
  addPhysicalCard,
41024
41091
  addNonPhysicalCard,
@@ -41057,7 +41124,8 @@ function useAccessManagementController() {
41057
41124
  visitorCheckout,
41058
41125
  uploadTemplate,
41059
41126
  getResidents,
41060
- userAccessCards
41127
+ userAccessCards,
41128
+ removeTemplate
41061
41129
  };
41062
41130
  }
41063
41131
 
@@ -45409,7 +45477,7 @@ function useIncidentReportRepo() {
45409
45477
  },
45410
45478
  ...dateExpr
45411
45479
  };
45412
- sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
45480
+ sort = Object.keys(sort).length > 0 ? sort : { updatedAt: -1, createdAt: -1, _id: -1 };
45413
45481
  const cacheOptions = {
45414
45482
  site: site.toString(),
45415
45483
  sort: JSON.stringify(sort),
@@ -45510,7 +45578,7 @@ function useIncidentReportRepo() {
45510
45578
  },
45511
45579
  ...dateExpr
45512
45580
  };
45513
- sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
45581
+ sort = Object.keys(sort).length > 0 ? sort : { updatedAt: -1, createdAt: -1, _id: -1 };
45514
45582
  try {
45515
45583
  const items = await collection.aggregate(
45516
45584
  [
@@ -45910,7 +45978,7 @@ function useIncidentReportController() {
45910
45978
  }
45911
45979
  }
45912
45980
  async function getAll(req, res, next) {
45913
- const allowedFields = ["createdAt", "name"];
45981
+ const allowedFields = ["updatedAt", "createdAt", "name"];
45914
45982
  const allowedOrder = ["asc", "desc"];
45915
45983
  const validation = import_joi102.default.object({
45916
45984
  search: import_joi102.default.string().optional().allow("", null),
@@ -45966,7 +46034,7 @@ function useIncidentReportController() {
45966
46034
  }
45967
46035
  }
45968
46036
  async function getAllForVirtualPatrolLogs(req, res, next) {
45969
- const allowedFields = ["createdAt", "name"];
46037
+ const allowedFields = ["updatedAt", "createdAt", "name"];
45970
46038
  const allowedOrder = ["asc", "desc"];
45971
46039
  const validation = import_joi102.default.object({
45972
46040
  search: import_joi102.default.string().optional().allow("", null),
@@ -55618,17 +55686,181 @@ function usePostPrelovedController() {
55618
55686
  };
55619
55687
  }
55620
55688
 
55621
- // src/models/category-preloved.model.ts
55689
+ // src/models/post-favorite.model.ts
55622
55690
  var import_joi135 = __toESM(require("joi"));
55623
55691
  var import_mongodb133 = require("mongodb");
55624
- var schemaCategoryPreloved = import_joi135.default.object({
55625
- name: import_joi135.default.string().required(),
55626
- createdBy: import_joi135.default.string().hex().optional().allow("", null),
55627
- site: import_joi135.default.string().hex().optional().allow("", null)
55692
+ var schemaPostFavorite = import_joi135.default.object({
55693
+ _id: import_joi135.default.string().hex().optional().allow("", null),
55694
+ postId: import_joi135.default.string().hex().required(),
55695
+ userIds: import_joi135.default.array().items(import_joi135.default.string().hex().optional()).optional().allow(null),
55696
+ createdAt: import_joi135.default.date().optional().allow(null),
55697
+ updatedAt: import_joi135.default.date().optional().allow(null)
55698
+ });
55699
+ function MPostFavorite(value) {
55700
+ const { error } = schemaPostFavorite.validate(value);
55701
+ if (error) {
55702
+ throw new Error(error.details[0].message);
55703
+ }
55704
+ if (value._id && typeof value._id === "string") {
55705
+ try {
55706
+ value._id = new import_mongodb133.ObjectId(value._id);
55707
+ } catch {
55708
+ throw new Error("Invalid ID.");
55709
+ }
55710
+ }
55711
+ if (value.postId && typeof value.postId === "string") {
55712
+ try {
55713
+ value.postId = new import_mongodb133.ObjectId(value.postId);
55714
+ } catch {
55715
+ throw new Error("Invalid post ID.");
55716
+ }
55717
+ }
55718
+ if (value.userIds && Array.isArray(value.userIds)) {
55719
+ value.userIds = value.userIds.map((id) => {
55720
+ if (typeof id === "string") {
55721
+ try {
55722
+ return new import_mongodb133.ObjectId(id);
55723
+ } catch {
55724
+ throw new Error("Invalid user ID.");
55725
+ }
55726
+ }
55727
+ return id;
55728
+ });
55729
+ }
55730
+ return {
55731
+ _id: value._id ?? new import_mongodb133.ObjectId(),
55732
+ postId: value.postId ?? "",
55733
+ userIds: value.userIds ?? [],
55734
+ createdAt: value.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
55735
+ updatedAt: value.updatedAt ?? null
55736
+ };
55737
+ }
55738
+
55739
+ // src/repositories/post-favorite.repo.ts
55740
+ var import_node_server_utils237 = require("@7365admin1/node-server-utils");
55741
+ var import_mongodb134 = require("mongodb");
55742
+ function usePostFavoriteRepo() {
55743
+ const db = import_node_server_utils237.useAtlas.getDb();
55744
+ if (!db) {
55745
+ throw new import_node_server_utils237.InternalServerError("Unable to connect to server.");
55746
+ }
55747
+ const FAVORITE_COLLECTION = "post-favorites";
55748
+ const collection = db.collection(FAVORITE_COLLECTION);
55749
+ async function addFavorite(value, session) {
55750
+ try {
55751
+ const doc = MPostFavorite(value);
55752
+ const res = await collection.insertOne(doc, { session });
55753
+ return res.insertedId;
55754
+ } catch (error) {
55755
+ const isDuplicated = error.message?.includes("duplicate");
55756
+ if (isDuplicated)
55757
+ throw new import_node_server_utils237.BadRequestError("Post Favorite already exists.");
55758
+ throw error;
55759
+ }
55760
+ }
55761
+ async function getById(_id) {
55762
+ try {
55763
+ _id = new import_mongodb134.ObjectId(_id);
55764
+ } catch {
55765
+ throw new import_node_server_utils237.BadRequestError("Invalid favorite ID format.");
55766
+ }
55767
+ const result = await collection.findOne({ _id });
55768
+ if (!result)
55769
+ throw new import_node_server_utils237.NotFoundError("Favorite not found.");
55770
+ return result;
55771
+ }
55772
+ return {
55773
+ addFavorite,
55774
+ getById
55775
+ };
55776
+ }
55777
+
55778
+ // src/services/post-favorite.service.ts
55779
+ var import_node_server_utils238 = require("@7365admin1/node-server-utils");
55780
+ function usePostFavoriteService() {
55781
+ const { addFavorite: _addFavorite } = usePostFavoriteRepo();
55782
+ async function addFavorite(value) {
55783
+ const session = import_node_server_utils238.useAtlas.getClient()?.startSession();
55784
+ session?.startTransaction();
55785
+ try {
55786
+ await _addFavorite(value, session);
55787
+ await session?.commitTransaction();
55788
+ return "Successfully added to favorites.";
55789
+ } catch (error) {
55790
+ await session?.abortTransaction();
55791
+ throw error;
55792
+ } finally {
55793
+ session?.endSession();
55794
+ }
55795
+ }
55796
+ return {
55797
+ addFavorite
55798
+ };
55799
+ }
55800
+
55801
+ // src/controllers/post-favorite.controller.ts
55802
+ var import_node_server_utils239 = require("@7365admin1/node-server-utils");
55803
+ var import_joi136 = __toESM(require("joi"));
55804
+ function usePostFavoriteController() {
55805
+ const { addFavorite: _addFavorite } = usePostFavoriteService();
55806
+ const { getById: _getById } = usePostFavoriteRepo();
55807
+ async function addFavorite(req, res, next) {
55808
+ const { error, value } = schemaPostFavorite.validate(req.body, {
55809
+ abortEarly: false
55810
+ });
55811
+ if (error) {
55812
+ const messages = error.details.map((d) => d.message).join(", ");
55813
+ import_node_server_utils239.logger.log({ level: "error", message: messages });
55814
+ next(new import_node_server_utils239.BadRequestError(messages));
55815
+ return;
55816
+ }
55817
+ try {
55818
+ const data = await _addFavorite(value);
55819
+ res.status(201).json(data);
55820
+ return;
55821
+ } catch (error2) {
55822
+ import_node_server_utils239.logger.log({ level: "error", message: error2.message });
55823
+ next(error2);
55824
+ return;
55825
+ }
55826
+ }
55827
+ async function getById(req, res, next) {
55828
+ const schema2 = import_joi136.default.object({
55829
+ _id: import_joi136.default.string().hex().length(24).required()
55830
+ });
55831
+ const { error, value } = schema2.validate({ _id: req.params.id });
55832
+ if (error) {
55833
+ import_node_server_utils239.logger.log({ level: "error", message: error.message });
55834
+ next(new import_node_server_utils239.BadRequestError(error.message));
55835
+ return;
55836
+ }
55837
+ try {
55838
+ const data = await _getById(value._id);
55839
+ res.status(200).json(data);
55840
+ return;
55841
+ } catch (error2) {
55842
+ import_node_server_utils239.logger.log({ level: "error", message: error2.message });
55843
+ next(error2);
55844
+ return;
55845
+ }
55846
+ }
55847
+ return {
55848
+ addFavorite,
55849
+ getById
55850
+ };
55851
+ }
55852
+
55853
+ // src/models/category-preloved.model.ts
55854
+ var import_joi137 = __toESM(require("joi"));
55855
+ var import_mongodb135 = require("mongodb");
55856
+ var schemaCategoryPreloved = import_joi137.default.object({
55857
+ name: import_joi137.default.string().required(),
55858
+ createdBy: import_joi137.default.string().hex().optional().allow("", null),
55859
+ site: import_joi137.default.string().hex().optional().allow("", null)
55628
55860
  });
55629
- var schemaUpdateCategoryPreloved = import_joi135.default.object({
55630
- name: import_joi135.default.string().optional().allow("", null),
55631
- site: import_joi135.default.string().hex().optional().allow("", null)
55861
+ var schemaUpdateCategoryPreloved = import_joi137.default.object({
55862
+ name: import_joi137.default.string().optional().allow("", null),
55863
+ site: import_joi137.default.string().hex().optional().allow("", null)
55632
55864
  });
55633
55865
  function MCategoryPreloved(value) {
55634
55866
  const { error } = schemaCategoryPreloved.validate(value);
@@ -55637,14 +55869,14 @@ function MCategoryPreloved(value) {
55637
55869
  }
55638
55870
  if (value.createdBy && typeof value.createdBy === "string") {
55639
55871
  try {
55640
- value.createdBy = new import_mongodb133.ObjectId(value.createdBy);
55872
+ value.createdBy = new import_mongodb135.ObjectId(value.createdBy);
55641
55873
  } catch {
55642
55874
  throw new Error("Invalid createdBy ID.");
55643
55875
  }
55644
55876
  }
55645
55877
  if (value.site && typeof value.site === "string") {
55646
55878
  try {
55647
- value.site = new import_mongodb133.ObjectId(value.site);
55879
+ value.site = new import_mongodb135.ObjectId(value.site);
55648
55880
  } catch {
55649
55881
  throw new Error("Invalid site ID.");
55650
55882
  }
@@ -55659,12 +55891,12 @@ function MCategoryPreloved(value) {
55659
55891
  }
55660
55892
 
55661
55893
  // src/repositories/category-preloved.repo.ts
55662
- var import_node_server_utils237 = require("@7365admin1/node-server-utils");
55663
- var import_mongodb134 = require("mongodb");
55894
+ var import_node_server_utils240 = require("@7365admin1/node-server-utils");
55895
+ var import_mongodb136 = require("mongodb");
55664
55896
  function useCategoryPrelovedRepo() {
55665
- const db = import_node_server_utils237.useAtlas.getDb();
55897
+ const db = import_node_server_utils240.useAtlas.getDb();
55666
55898
  if (!db) {
55667
- throw new import_node_server_utils237.InternalServerError("Unable to connect to server.");
55899
+ throw new import_node_server_utils240.InternalServerError("Unable to connect to server.");
55668
55900
  }
55669
55901
  const CATEGORY_COLLECTION = "category-preloved";
55670
55902
  const collection = db.collection(CATEGORY_COLLECTION);
@@ -55674,9 +55906,9 @@ function useCategoryPrelovedRepo() {
55674
55906
  } = {}) {
55675
55907
  if (site) {
55676
55908
  try {
55677
- site = new import_mongodb134.ObjectId(site);
55909
+ site = new import_mongodb136.ObjectId(site);
55678
55910
  } catch {
55679
- throw new import_node_server_utils237.BadRequestError("Invalid site ID format.");
55911
+ throw new import_node_server_utils240.BadRequestError("Invalid site ID format.");
55680
55912
  }
55681
55913
  }
55682
55914
  const query = {
@@ -55693,14 +55925,14 @@ function useCategoryPrelovedRepo() {
55693
55925
  async function getById(_id) {
55694
55926
  let objectId2;
55695
55927
  try {
55696
- objectId2 = new import_mongodb134.ObjectId(_id);
55928
+ objectId2 = new import_mongodb136.ObjectId(_id);
55697
55929
  } catch {
55698
- throw new import_node_server_utils237.BadRequestError("Invalid category-preloved ID format.");
55930
+ throw new import_node_server_utils240.BadRequestError("Invalid category-preloved ID format.");
55699
55931
  }
55700
55932
  try {
55701
55933
  const data = await collection.findOne({ _id: objectId2 });
55702
55934
  if (!data) {
55703
- throw new import_node_server_utils237.NotFoundError("Category not found.");
55935
+ throw new import_node_server_utils240.NotFoundError("Category not found.");
55704
55936
  }
55705
55937
  return data;
55706
55938
  } catch (error) {
@@ -55712,20 +55944,20 @@ function useCategoryPrelovedRepo() {
55712
55944
  }
55713
55945
 
55714
55946
  // src/controllers/category-preloved.controller.ts
55715
- var import_node_server_utils238 = require("@7365admin1/node-server-utils");
55716
- var import_joi136 = __toESM(require("joi"));
55947
+ var import_node_server_utils241 = require("@7365admin1/node-server-utils");
55948
+ var import_joi138 = __toESM(require("joi"));
55717
55949
  function useCategoryPrelovedController() {
55718
55950
  const { getAll: _getAll, getById: _getById } = useCategoryPrelovedRepo();
55719
55951
  async function getAll(req, res, next) {
55720
- const schema2 = import_joi136.default.object({
55721
- search: import_joi136.default.string().optional().allow("", null),
55722
- site: import_joi136.default.string().hex().length(24).optional().allow("", null)
55952
+ const schema2 = import_joi138.default.object({
55953
+ search: import_joi138.default.string().optional().allow("", null),
55954
+ site: import_joi138.default.string().hex().length(24).optional().allow("", null)
55723
55955
  });
55724
55956
  const { error, value } = schema2.validate(req.query, { abortEarly: false });
55725
55957
  if (error) {
55726
55958
  const messages = error.details.map((d) => d.message).join(", ");
55727
- import_node_server_utils238.logger.log({ level: "error", message: messages });
55728
- next(new import_node_server_utils238.BadRequestError(messages));
55959
+ import_node_server_utils241.logger.log({ level: "error", message: messages });
55960
+ next(new import_node_server_utils241.BadRequestError(messages));
55729
55961
  return;
55730
55962
  }
55731
55963
  try {
@@ -55733,19 +55965,19 @@ function useCategoryPrelovedController() {
55733
55965
  res.status(200).json({ data });
55734
55966
  return;
55735
55967
  } catch (error2) {
55736
- import_node_server_utils238.logger.log({ level: "error", message: error2.message });
55968
+ import_node_server_utils241.logger.log({ level: "error", message: error2.message });
55737
55969
  next(error2);
55738
55970
  return;
55739
55971
  }
55740
55972
  }
55741
55973
  async function getById(req, res, next) {
55742
- const schema2 = import_joi136.default.object({
55743
- _id: import_joi136.default.string().hex().length(24).required()
55974
+ const schema2 = import_joi138.default.object({
55975
+ _id: import_joi138.default.string().hex().length(24).required()
55744
55976
  });
55745
55977
  const { error, value } = schema2.validate({ _id: req.params.id });
55746
55978
  if (error) {
55747
- import_node_server_utils238.logger.log({ level: "error", message: error.message });
55748
- next(new import_node_server_utils238.BadRequestError(error.message));
55979
+ import_node_server_utils241.logger.log({ level: "error", message: error.message });
55980
+ next(new import_node_server_utils241.BadRequestError(error.message));
55749
55981
  return;
55750
55982
  }
55751
55983
  try {
@@ -55753,7 +55985,7 @@ function useCategoryPrelovedController() {
55753
55985
  res.status(200).json({ data });
55754
55986
  return;
55755
55987
  } catch (error2) {
55756
- import_node_server_utils238.logger.log({ level: "error", message: error2.message });
55988
+ import_node_server_utils241.logger.log({ level: "error", message: error2.message });
55757
55989
  next(error2);
55758
55990
  return;
55759
55991
  }
@@ -55762,18 +55994,18 @@ function useCategoryPrelovedController() {
55762
55994
  }
55763
55995
 
55764
55996
  // src/models/subcategory-preloved.model.ts
55765
- var import_joi137 = __toESM(require("joi"));
55766
- var import_mongodb135 = require("mongodb");
55767
- var schemaSubcategoryPreloved = import_joi137.default.object({
55768
- name: import_joi137.default.string().required(),
55769
- createdBy: import_joi137.default.string().hex().optional().allow("", null),
55770
- site: import_joi137.default.string().hex().optional().allow("", null),
55771
- category_id: import_joi137.default.string().hex().required()
55997
+ var import_joi139 = __toESM(require("joi"));
55998
+ var import_mongodb137 = require("mongodb");
55999
+ var schemaSubcategoryPreloved = import_joi139.default.object({
56000
+ name: import_joi139.default.string().required(),
56001
+ createdBy: import_joi139.default.string().hex().optional().allow("", null),
56002
+ site: import_joi139.default.string().hex().optional().allow("", null),
56003
+ category_id: import_joi139.default.string().hex().required()
55772
56004
  });
55773
- var schemaUpdateSubcategoryPreloved = import_joi137.default.object({
55774
- name: import_joi137.default.string().optional().allow("", null),
55775
- site: import_joi137.default.string().hex().optional().allow("", null),
55776
- category_id: import_joi137.default.string().hex().optional().allow("", null)
56005
+ var schemaUpdateSubcategoryPreloved = import_joi139.default.object({
56006
+ name: import_joi139.default.string().optional().allow("", null),
56007
+ site: import_joi139.default.string().hex().optional().allow("", null),
56008
+ category_id: import_joi139.default.string().hex().optional().allow("", null)
55777
56009
  });
55778
56010
  function MSubcategoryPreloved(value) {
55779
56011
  const { error } = schemaSubcategoryPreloved.validate(value);
@@ -55782,21 +56014,21 @@ function MSubcategoryPreloved(value) {
55782
56014
  }
55783
56015
  if (value.createdBy && typeof value.createdBy === "string") {
55784
56016
  try {
55785
- value.createdBy = new import_mongodb135.ObjectId(value.createdBy);
56017
+ value.createdBy = new import_mongodb137.ObjectId(value.createdBy);
55786
56018
  } catch {
55787
56019
  throw new Error("Invalid createdBy ID.");
55788
56020
  }
55789
56021
  }
55790
56022
  if (value.site && typeof value.site === "string") {
55791
56023
  try {
55792
- value.site = new import_mongodb135.ObjectId(value.site);
56024
+ value.site = new import_mongodb137.ObjectId(value.site);
55793
56025
  } catch {
55794
56026
  throw new Error("Invalid site ID.");
55795
56027
  }
55796
56028
  }
55797
56029
  if (value.category_id && typeof value.category_id === "string") {
55798
56030
  try {
55799
- value.category_id = new import_mongodb135.ObjectId(value.category_id);
56031
+ value.category_id = new import_mongodb137.ObjectId(value.category_id);
55800
56032
  } catch {
55801
56033
  throw new Error("Invalid category ID.");
55802
56034
  }
@@ -55812,12 +56044,12 @@ function MSubcategoryPreloved(value) {
55812
56044
  }
55813
56045
 
55814
56046
  // src/repositories/subcategory-preloved.repo.ts
55815
- var import_node_server_utils239 = require("@7365admin1/node-server-utils");
55816
- var import_mongodb136 = require("mongodb");
56047
+ var import_node_server_utils242 = require("@7365admin1/node-server-utils");
56048
+ var import_mongodb138 = require("mongodb");
55817
56049
  function useSubcategoryPrelovedRepo() {
55818
- const db = import_node_server_utils239.useAtlas.getDb();
56050
+ const db = import_node_server_utils242.useAtlas.getDb();
55819
56051
  if (!db) {
55820
- throw new import_node_server_utils239.InternalServerError("Unable to connect to server.");
56052
+ throw new import_node_server_utils242.InternalServerError("Unable to connect to server.");
55821
56053
  }
55822
56054
  const SUBCATEGORY_COLLECTION = "subcategory-preloved";
55823
56055
  const collection = db.collection(SUBCATEGORY_COLLECTION);
@@ -55828,16 +56060,16 @@ function useSubcategoryPrelovedRepo() {
55828
56060
  } = {}) {
55829
56061
  if (site) {
55830
56062
  try {
55831
- site = new import_mongodb136.ObjectId(site);
56063
+ site = new import_mongodb138.ObjectId(site);
55832
56064
  } catch {
55833
- throw new import_node_server_utils239.BadRequestError("Invalid site ID format.");
56065
+ throw new import_node_server_utils242.BadRequestError("Invalid site ID format.");
55834
56066
  }
55835
56067
  }
55836
56068
  if (category_id) {
55837
56069
  try {
55838
- category_id = new import_mongodb136.ObjectId(category_id);
56070
+ category_id = new import_mongodb138.ObjectId(category_id);
55839
56071
  } catch {
55840
- throw new import_node_server_utils239.BadRequestError("Invalid category ID format.");
56072
+ throw new import_node_server_utils242.BadRequestError("Invalid category ID format.");
55841
56073
  }
55842
56074
  }
55843
56075
  const query = {
@@ -55854,14 +56086,14 @@ function useSubcategoryPrelovedRepo() {
55854
56086
  async function getById(_id) {
55855
56087
  let objectId2;
55856
56088
  try {
55857
- objectId2 = new import_mongodb136.ObjectId(_id);
56089
+ objectId2 = new import_mongodb138.ObjectId(_id);
55858
56090
  } catch {
55859
- throw new import_node_server_utils239.BadRequestError("Invalid subcategory-preloved ID format.");
56091
+ throw new import_node_server_utils242.BadRequestError("Invalid subcategory-preloved ID format.");
55860
56092
  }
55861
56093
  try {
55862
56094
  const data = await collection.findOne({ _id: objectId2 });
55863
56095
  if (!data) {
55864
- throw new import_node_server_utils239.NotFoundError("Subcategory not found.");
56096
+ throw new import_node_server_utils242.NotFoundError("Subcategory not found.");
55865
56097
  }
55866
56098
  return data;
55867
56099
  } catch (error) {
@@ -55872,21 +56104,21 @@ function useSubcategoryPrelovedRepo() {
55872
56104
  }
55873
56105
 
55874
56106
  // src/controllers/subcategory-preloved.controller.ts
55875
- var import_node_server_utils240 = require("@7365admin1/node-server-utils");
55876
- var import_joi138 = __toESM(require("joi"));
56107
+ var import_node_server_utils243 = require("@7365admin1/node-server-utils");
56108
+ var import_joi140 = __toESM(require("joi"));
55877
56109
  function useSubcategoryPrelovedController() {
55878
56110
  const { getAll: _getAll, getById: _getById } = useSubcategoryPrelovedRepo();
55879
56111
  async function getAll(req, res, next) {
55880
- const schema2 = import_joi138.default.object({
55881
- search: import_joi138.default.string().optional().allow("", null),
55882
- site: import_joi138.default.string().hex().length(24).optional().allow("", null),
55883
- category_id: import_joi138.default.string().hex().length(24).optional().allow("", null)
56112
+ const schema2 = import_joi140.default.object({
56113
+ search: import_joi140.default.string().optional().allow("", null),
56114
+ site: import_joi140.default.string().hex().length(24).optional().allow("", null),
56115
+ category_id: import_joi140.default.string().hex().length(24).optional().allow("", null)
55884
56116
  });
55885
56117
  const { error, value } = schema2.validate(req.query, { abortEarly: false });
55886
56118
  if (error) {
55887
56119
  const messages = error.details.map((d) => d.message).join(", ");
55888
- import_node_server_utils240.logger.log({ level: "error", message: messages });
55889
- next(new import_node_server_utils240.BadRequestError(messages));
56120
+ import_node_server_utils243.logger.log({ level: "error", message: messages });
56121
+ next(new import_node_server_utils243.BadRequestError(messages));
55890
56122
  return;
55891
56123
  }
55892
56124
  try {
@@ -55894,19 +56126,19 @@ function useSubcategoryPrelovedController() {
55894
56126
  res.status(200).json({ data });
55895
56127
  return;
55896
56128
  } catch (error2) {
55897
- import_node_server_utils240.logger.log({ level: "error", message: error2.message });
56129
+ import_node_server_utils243.logger.log({ level: "error", message: error2.message });
55898
56130
  next(error2);
55899
56131
  return;
55900
56132
  }
55901
56133
  }
55902
56134
  async function getById(req, res, next) {
55903
- const schema2 = import_joi138.default.object({
55904
- _id: import_joi138.default.string().hex().length(24).required()
56135
+ const schema2 = import_joi140.default.object({
56136
+ _id: import_joi140.default.string().hex().length(24).required()
55905
56137
  });
55906
56138
  const { error, value } = schema2.validate({ _id: req.params.id });
55907
56139
  if (error) {
55908
- import_node_server_utils240.logger.log({ level: "error", message: error.message });
55909
- next(new import_node_server_utils240.BadRequestError(error.message));
56140
+ import_node_server_utils243.logger.log({ level: "error", message: error.message });
56141
+ next(new import_node_server_utils243.BadRequestError(error.message));
55910
56142
  return;
55911
56143
  }
55912
56144
  try {
@@ -55914,7 +56146,7 @@ function useSubcategoryPrelovedController() {
55914
56146
  res.status(200).json({ data });
55915
56147
  return;
55916
56148
  } catch (error2) {
55917
- import_node_server_utils240.logger.log({ level: "error", message: error2.message });
56149
+ import_node_server_utils243.logger.log({ level: "error", message: error2.message });
55918
56150
  next(error2);
55919
56151
  return;
55920
56152
  }
@@ -55923,49 +56155,49 @@ function useSubcategoryPrelovedController() {
55923
56155
  }
55924
56156
 
55925
56157
  // src/models/online-forms-v2.model.ts
55926
- var import_joi139 = __toESM(require("joi"));
55927
- var import_mongodb137 = require("mongodb");
56158
+ var import_joi141 = __toESM(require("joi"));
56159
+ var import_mongodb139 = require("mongodb");
55928
56160
  var FormEntryStatus = /* @__PURE__ */ ((FormEntryStatus2) => {
55929
56161
  FormEntryStatus2["ACTIVE"] = "active";
55930
56162
  FormEntryStatus2["INACTIVE"] = "inactive";
55931
56163
  FormEntryStatus2["DELETED"] = "deleted";
55932
56164
  return FormEntryStatus2;
55933
56165
  })(FormEntryStatus || {});
55934
- var schemaFormEntry = import_joi139.default.object({
55935
- _id: import_joi139.default.string().hex().optional().allow("", null),
55936
- formType: import_joi139.default.string().required(),
55937
- fields: import_joi139.default.object().pattern(
55938
- import_joi139.default.string(),
55939
- import_joi139.default.alternatives().try(
55940
- import_joi139.default.string(),
55941
- import_joi139.default.number(),
55942
- import_joi139.default.boolean(),
55943
- import_joi139.default.valid(null)
56166
+ var schemaFormEntry = import_joi141.default.object({
56167
+ _id: import_joi141.default.string().hex().optional().allow("", null),
56168
+ formType: import_joi141.default.string().required(),
56169
+ fields: import_joi141.default.object().pattern(
56170
+ import_joi141.default.string(),
56171
+ import_joi141.default.alternatives().try(
56172
+ import_joi141.default.string(),
56173
+ import_joi141.default.number(),
56174
+ import_joi141.default.boolean(),
56175
+ import_joi141.default.valid(null)
55944
56176
  )
55945
56177
  ).required(),
55946
- status: import_joi139.default.string().optional().allow("", null),
55947
- org: import_joi139.default.string().hex().optional().allow("", null),
55948
- site: import_joi139.default.string().hex().optional().allow("", null),
55949
- createdAt: import_joi139.default.date().optional().allow("", null),
55950
- updatedAt: import_joi139.default.date().optional().allow("", null),
55951
- deletedAt: import_joi139.default.date().optional().allow("", null)
56178
+ status: import_joi141.default.string().optional().allow("", null),
56179
+ org: import_joi141.default.string().hex().optional().allow("", null),
56180
+ site: import_joi141.default.string().hex().optional().allow("", null),
56181
+ createdAt: import_joi141.default.date().optional().allow("", null),
56182
+ updatedAt: import_joi141.default.date().optional().allow("", null),
56183
+ deletedAt: import_joi141.default.date().optional().allow("", null)
55952
56184
  });
55953
- var schemaUpdateFormEntry = import_joi139.default.object({
55954
- _id: import_joi139.default.string().hex().required(),
55955
- formType: import_joi139.default.string().optional().allow("", null),
55956
- fields: import_joi139.default.object().pattern(
55957
- import_joi139.default.string(),
55958
- import_joi139.default.alternatives().try(
55959
- import_joi139.default.string(),
55960
- import_joi139.default.number(),
55961
- import_joi139.default.boolean(),
55962
- import_joi139.default.valid(null)
56185
+ var schemaUpdateFormEntry = import_joi141.default.object({
56186
+ _id: import_joi141.default.string().hex().required(),
56187
+ formType: import_joi141.default.string().optional().allow("", null),
56188
+ fields: import_joi141.default.object().pattern(
56189
+ import_joi141.default.string(),
56190
+ import_joi141.default.alternatives().try(
56191
+ import_joi141.default.string(),
56192
+ import_joi141.default.number(),
56193
+ import_joi141.default.boolean(),
56194
+ import_joi141.default.valid(null)
55963
56195
  )
55964
56196
  ).optional(),
55965
- status: import_joi139.default.string().optional().allow("", null),
55966
- createdAt: import_joi139.default.date().optional().allow("", null),
55967
- updatedAt: import_joi139.default.date().optional().allow("", null),
55968
- deletedAt: import_joi139.default.date().optional().allow("", null)
56197
+ status: import_joi141.default.string().optional().allow("", null),
56198
+ createdAt: import_joi141.default.date().optional().allow("", null),
56199
+ updatedAt: import_joi141.default.date().optional().allow("", null),
56200
+ deletedAt: import_joi141.default.date().optional().allow("", null)
55969
56201
  });
55970
56202
  function MFormEntry(value) {
55971
56203
  const { error } = schemaFormEntry.validate(value);
@@ -55974,21 +56206,21 @@ function MFormEntry(value) {
55974
56206
  }
55975
56207
  if (value._id && typeof value._id === "string") {
55976
56208
  try {
55977
- value._id = new import_mongodb137.ObjectId(value._id);
56209
+ value._id = new import_mongodb139.ObjectId(value._id);
55978
56210
  } catch {
55979
56211
  throw new Error("Invalid ID.");
55980
56212
  }
55981
56213
  }
55982
56214
  if (value.org && typeof value.org === "string") {
55983
56215
  try {
55984
- value.org = new import_mongodb137.ObjectId(value.org);
56216
+ value.org = new import_mongodb139.ObjectId(value.org);
55985
56217
  } catch {
55986
56218
  throw new Error("Invalid org ID.");
55987
56219
  }
55988
56220
  }
55989
56221
  if (value.site && typeof value.site === "string") {
55990
56222
  try {
55991
- value.site = new import_mongodb137.ObjectId(value.site);
56223
+ value.site = new import_mongodb139.ObjectId(value.site);
55992
56224
  } catch {
55993
56225
  throw new Error("Invalid site ID.");
55994
56226
  }
@@ -56007,15 +56239,15 @@ function MFormEntry(value) {
56007
56239
  }
56008
56240
 
56009
56241
  // src/repositories/online-forms-v2.repository.ts
56010
- var import_node_server_utils241 = require("@7365admin1/node-server-utils");
56242
+ var import_node_server_utils244 = require("@7365admin1/node-server-utils");
56011
56243
  var online_forms_namespace_collection = "online-forms";
56012
56244
  function useFormEntryRepo() {
56013
- const db = import_node_server_utils241.useAtlas.getDb();
56245
+ const db = import_node_server_utils244.useAtlas.getDb();
56014
56246
  if (!db) {
56015
- throw new import_node_server_utils241.InternalServerError("Unable to connect to server.");
56247
+ throw new import_node_server_utils244.InternalServerError("Unable to connect to server.");
56016
56248
  }
56017
56249
  const collection = db.collection(online_forms_namespace_collection);
56018
- const { delNamespace, getCache, setCache } = (0, import_node_server_utils241.useCache)(
56250
+ const { delNamespace, getCache, setCache } = (0, import_node_server_utils244.useCache)(
56019
56251
  online_forms_namespace_collection
56020
56252
  );
56021
56253
  async function createTextIndex() {
@@ -56024,7 +56256,7 @@ function useFormEntryRepo() {
56024
56256
  name: "text"
56025
56257
  });
56026
56258
  } catch (error) {
56027
- throw new import_node_server_utils241.InternalServerError(
56259
+ throw new import_node_server_utils244.InternalServerError(
56028
56260
  "Failed to create text index on online form."
56029
56261
  );
56030
56262
  }
@@ -56034,11 +56266,11 @@ function useFormEntryRepo() {
56034
56266
  value = MFormEntry(value);
56035
56267
  const res = await collection.insertOne(value, { session });
56036
56268
  delNamespace().then(() => {
56037
- import_node_server_utils241.logger.info(
56269
+ import_node_server_utils244.logger.info(
56038
56270
  `Cache cleared for namespace: ${online_forms_namespace_collection}`
56039
56271
  );
56040
56272
  }).catch((err) => {
56041
- import_node_server_utils241.logger.error(
56273
+ import_node_server_utils244.logger.error(
56042
56274
  `Failed to clear cache for namespace: ${online_forms_namespace_collection}`,
56043
56275
  err
56044
56276
  );
@@ -56047,7 +56279,7 @@ function useFormEntryRepo() {
56047
56279
  } catch (error) {
56048
56280
  const isDuplicated = error.message.includes("duplicate");
56049
56281
  if (isDuplicated) {
56050
- throw new import_node_server_utils241.BadRequestError("Online Form already exists.");
56282
+ throw new import_node_server_utils244.BadRequestError("Online Form already exists.");
56051
56283
  }
56052
56284
  throw error;
56053
56285
  }
@@ -56059,7 +56291,7 @@ function useFormEntryRepo() {
56059
56291
  }
56060
56292
 
56061
56293
  // src/controllers/online-forms-v2.controller.ts
56062
- var import_node_server_utils242 = require("@7365admin1/node-server-utils");
56294
+ var import_node_server_utils245 = require("@7365admin1/node-server-utils");
56063
56295
  var import_exceljs3 = __toESM(require("exceljs"));
56064
56296
  var import_fs6 = __toESM(require("fs"));
56065
56297
  function useFormEntryController() {
@@ -56077,14 +56309,14 @@ function useFormEntryController() {
56077
56309
  async function uploadFormEntrys(req, res, next) {
56078
56310
  try {
56079
56311
  if (!req.file) {
56080
- next(new import_node_server_utils242.BadRequestError("Excel file is required."));
56312
+ next(new import_node_server_utils245.BadRequestError("Excel file is required."));
56081
56313
  return;
56082
56314
  }
56083
56315
  const workbook = new import_exceljs3.default.Workbook();
56084
56316
  await workbook.xlsx.readFile(req.file.path);
56085
56317
  const worksheet = workbook.worksheets[0];
56086
56318
  if (!worksheet) {
56087
- next(new import_node_server_utils242.BadRequestError("No worksheet found in uploaded Excel file."));
56319
+ next(new import_node_server_utils245.BadRequestError("No worksheet found in uploaded Excel file."));
56088
56320
  return;
56089
56321
  }
56090
56322
  const headerRow = worksheet.getRow(1);
@@ -56105,8 +56337,8 @@ function useFormEntryController() {
56105
56337
  });
56106
56338
  if (error) {
56107
56339
  const messages = error.details.map((d) => d.message).join(", ");
56108
- import_node_server_utils242.logger.log({ level: "error", message: messages });
56109
- next(new import_node_server_utils242.BadRequestError(messages));
56340
+ import_node_server_utils245.logger.log({ level: "error", message: messages });
56341
+ next(new import_node_server_utils245.BadRequestError(messages));
56110
56342
  return;
56111
56343
  }
56112
56344
  const result = await _add(value);
@@ -56114,7 +56346,7 @@ function useFormEntryController() {
56114
56346
  import_fs6.default.unlink(req.file.path, () => {
56115
56347
  });
56116
56348
  } catch (error) {
56117
- import_node_server_utils242.logger.log({ level: "error", message: error.message });
56349
+ import_node_server_utils245.logger.log({ level: "error", message: error.message });
56118
56350
  next(error);
56119
56351
  }
56120
56352
  }
@@ -56124,11 +56356,11 @@ function useFormEntryController() {
56124
56356
  }
56125
56357
 
56126
56358
  // src/services/building-level.service.ts
56127
- var import_node_server_utils243 = require("@7365admin1/node-server-utils");
56359
+ var import_node_server_utils246 = require("@7365admin1/node-server-utils");
56128
56360
  function useBuildingLevelService() {
56129
56361
  const { add: _add, updateLevelById: _updateLevelById } = useBuildingLevelRepo();
56130
56362
  async function add(value) {
56131
- const session = import_node_server_utils243.useAtlas.getClient()?.startSession();
56363
+ const session = import_node_server_utils246.useAtlas.getClient()?.startSession();
56132
56364
  try {
56133
56365
  session?.startTransaction();
56134
56366
  await _add(value, session);
@@ -56142,7 +56374,7 @@ function useBuildingLevelService() {
56142
56374
  }
56143
56375
  }
56144
56376
  async function updateLevelById(_id, value) {
56145
- const session = import_node_server_utils243.useAtlas.getClient()?.startSession();
56377
+ const session = import_node_server_utils246.useAtlas.getClient()?.startSession();
56146
56378
  try {
56147
56379
  session?.startTransaction();
56148
56380
  await _updateLevelById(_id, value, session);
@@ -56162,8 +56394,8 @@ function useBuildingLevelService() {
56162
56394
  }
56163
56395
 
56164
56396
  // src/controllers/building-level.controller.ts
56165
- var import_node_server_utils244 = require("@7365admin1/node-server-utils");
56166
- var import_joi140 = __toESM(require("joi"));
56397
+ var import_node_server_utils247 = require("@7365admin1/node-server-utils");
56398
+ var import_joi142 = __toESM(require("joi"));
56167
56399
  function useBuildingLevelController() {
56168
56400
  const { add: _add, updateLevelById: _updateLevelById } = useBuildingLevelService();
56169
56401
  const {
@@ -56178,8 +56410,8 @@ function useBuildingLevelController() {
56178
56410
  });
56179
56411
  if (error) {
56180
56412
  const messages = error.details.map((d) => d.message).join(", ");
56181
- import_node_server_utils244.logger.log({ level: "error", message: messages });
56182
- next(new import_node_server_utils244.BadRequestError(messages));
56413
+ import_node_server_utils247.logger.log({ level: "error", message: messages });
56414
+ next(new import_node_server_utils247.BadRequestError(messages));
56183
56415
  return;
56184
56416
  }
56185
56417
  const result = await _add(value);
@@ -56190,20 +56422,20 @@ function useBuildingLevelController() {
56190
56422
  }
56191
56423
  async function getAll(req, res, next) {
56192
56424
  try {
56193
- const validation = import_joi140.default.object({
56194
- page: import_joi140.default.number().min(1).optional().default(1),
56195
- limit: import_joi140.default.number().min(1).optional().default(20),
56196
- search: import_joi140.default.string().optional().allow("", null),
56197
- site: import_joi140.default.string().hex().length(24).optional().allow("", null),
56198
- status: import_joi140.default.string().valid(...Object.values(BuildingLevelStatus)).default("active" /* ACTIVE */)
56425
+ const validation = import_joi142.default.object({
56426
+ page: import_joi142.default.number().min(1).optional().default(1),
56427
+ limit: import_joi142.default.number().min(1).optional().default(20),
56428
+ search: import_joi142.default.string().optional().allow("", null),
56429
+ site: import_joi142.default.string().hex().length(24).optional().allow("", null),
56430
+ status: import_joi142.default.string().valid(...Object.values(BuildingLevelStatus)).default("active" /* ACTIVE */)
56199
56431
  });
56200
56432
  const { error, value } = validation.validate(req.query, {
56201
56433
  abortEarly: false
56202
56434
  });
56203
56435
  if (error) {
56204
56436
  const messages = error.details.map((d) => d.message);
56205
- import_node_server_utils244.logger.log({ level: "error", message: messages.join(", ") });
56206
- next(new import_node_server_utils244.BadRequestError(messages.join(", ")));
56437
+ import_node_server_utils247.logger.log({ level: "error", message: messages.join(", ") });
56438
+ next(new import_node_server_utils247.BadRequestError(messages.join(", ")));
56207
56439
  return;
56208
56440
  }
56209
56441
  const { page, limit, status, site, search } = value;
@@ -56222,14 +56454,14 @@ function useBuildingLevelController() {
56222
56454
  }
56223
56455
  async function getById(req, res, next) {
56224
56456
  try {
56225
- const schema2 = import_joi140.default.object({
56226
- id: import_joi140.default.string().hex().length(24).required()
56457
+ const schema2 = import_joi142.default.object({
56458
+ id: import_joi142.default.string().hex().length(24).required()
56227
56459
  });
56228
56460
  const { error, value } = schema2.validate({ id: req.params.id });
56229
56461
  if (error) {
56230
56462
  const messages = error.details.map((d) => d.message);
56231
- import_node_server_utils244.logger.log({ level: "error", message: messages.join(", ") });
56232
- next(new import_node_server_utils244.BadRequestError(messages.join(", ")));
56463
+ import_node_server_utils247.logger.log({ level: "error", message: messages.join(", ") });
56464
+ next(new import_node_server_utils247.BadRequestError(messages.join(", ")));
56233
56465
  return;
56234
56466
  }
56235
56467
  const { id } = value;
@@ -56248,8 +56480,8 @@ function useBuildingLevelController() {
56248
56480
  });
56249
56481
  if (error) {
56250
56482
  const messages = error.details.map((d) => d.message);
56251
- import_node_server_utils244.logger.log({ level: "error", message: messages.join(", ") });
56252
- next(new import_node_server_utils244.BadRequestError(messages.join(", ")));
56483
+ import_node_server_utils247.logger.log({ level: "error", message: messages.join(", ") });
56484
+ next(new import_node_server_utils247.BadRequestError(messages.join(", ")));
56253
56485
  return;
56254
56486
  }
56255
56487
  const { _id, ...rest } = value;
@@ -56261,14 +56493,14 @@ function useBuildingLevelController() {
56261
56493
  }
56262
56494
  async function deleteById(req, res, next) {
56263
56495
  try {
56264
- const schema2 = import_joi140.default.object({
56265
- id: import_joi140.default.string().hex().required()
56496
+ const schema2 = import_joi142.default.object({
56497
+ id: import_joi142.default.string().hex().required()
56266
56498
  });
56267
56499
  const { error, value } = schema2.validate({ id: req.params.id });
56268
56500
  if (error) {
56269
56501
  const messages = error.details.map((d) => d.message);
56270
- import_node_server_utils244.logger.log({ level: "error", message: messages.join(", ") });
56271
- next(new import_node_server_utils244.BadRequestError(messages.join(", ")));
56502
+ import_node_server_utils247.logger.log({ level: "error", message: messages.join(", ") });
56503
+ next(new import_node_server_utils247.BadRequestError(messages.join(", ")));
56272
56504
  return;
56273
56505
  }
56274
56506
  const { id } = value;
@@ -56364,6 +56596,7 @@ function useBuildingLevelController() {
56364
56596
  MPatrolRoute,
56365
56597
  MPerson,
56366
56598
  MPost,
56599
+ MPostFavorite,
56367
56600
  MPromoCode,
56368
56601
  MRobot,
56369
56602
  MRole,
@@ -56499,6 +56732,7 @@ function useBuildingLevelController() {
56499
56732
  schemaPerson,
56500
56733
  schemaPlate,
56501
56734
  schemaPost,
56735
+ schemaPostFavorite,
56502
56736
  schemaServiceProvider,
56503
56737
  schemaServiceProviderBilling,
56504
56738
  schemaSiteCamera,
@@ -56670,6 +56904,9 @@ function useBuildingLevelController() {
56670
56904
  usePatrolRouteRepo,
56671
56905
  usePersonController,
56672
56906
  usePersonRepo,
56907
+ usePostFavoriteController,
56908
+ usePostFavoriteRepo,
56909
+ usePostFavoriteService,
56673
56910
  usePostPrelovedController,
56674
56911
  usePostPrelovedRepo,
56675
56912
  usePriceController,