@7365admin1/core 2.81.0 → 2.82.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
@@ -537,13 +537,13 @@ var require_logger = __commonJS({
537
537
  "use strict";
538
538
  exports.__esModule = true;
539
539
  var _utils = require_utils();
540
- var logger197 = {
540
+ var logger198 = {
541
541
  methodMap: ["debug", "info", "warn", "error"],
542
542
  level: "info",
543
543
  // Maps a given level value to the `methodMap` indexes above.
544
544
  lookupLevel: function lookupLevel(level) {
545
545
  if (typeof level === "string") {
546
- var levelMap = _utils.indexOf(logger197.methodMap, level.toLowerCase());
546
+ var levelMap = _utils.indexOf(logger198.methodMap, level.toLowerCase());
547
547
  if (levelMap >= 0) {
548
548
  level = levelMap;
549
549
  } else {
@@ -554,9 +554,9 @@ var require_logger = __commonJS({
554
554
  },
555
555
  // Can be overridden in the host environment
556
556
  log: function log(level) {
557
- level = logger197.lookupLevel(level);
558
- if (typeof console !== "undefined" && logger197.lookupLevel(logger197.level) <= level) {
559
- var method = logger197.methodMap[level];
557
+ level = logger198.lookupLevel(level);
558
+ if (typeof console !== "undefined" && logger198.lookupLevel(logger198.level) <= level) {
559
+ var method = logger198.methodMap[level];
560
560
  if (!console[method]) {
561
561
  method = "log";
562
562
  }
@@ -567,7 +567,7 @@ var require_logger = __commonJS({
567
567
  }
568
568
  }
569
569
  };
570
- exports["default"] = logger197;
570
+ exports["default"] = logger198;
571
571
  module.exports = exports["default"];
572
572
  }
573
573
  });
@@ -9062,27 +9062,23 @@ function useMemberRepo() {
9062
9062
  limit = 10,
9063
9063
  user = "",
9064
9064
  org = "",
9065
+ siteId = "",
9065
9066
  type = "",
9066
9067
  status = ""
9067
9068
  }) {
9068
9069
  limit = limit > 0 ? limit : 10;
9069
9070
  search = search || "";
9070
9071
  page = page > 0 ? page - 1 : 0;
9071
- const query = { type, status };
9072
+ const query = {
9073
+ type,
9074
+ status
9075
+ };
9072
9076
  const cacheOptions = {
9073
9077
  page,
9074
9078
  limit,
9075
9079
  type,
9076
9080
  status
9077
9081
  };
9078
- if (user) {
9079
- try {
9080
- query.user = new ObjectId11(user);
9081
- cacheOptions.user = user.toString();
9082
- } catch (error) {
9083
- throw new BadRequestError11("Invalid user ID format.");
9084
- }
9085
- }
9086
9082
  if (org) {
9087
9083
  try {
9088
9084
  query.org = new ObjectId11(org);
@@ -9091,6 +9087,22 @@ function useMemberRepo() {
9091
9087
  throw new BadRequestError11("Invalid organization ID format.");
9092
9088
  }
9093
9089
  }
9090
+ if (siteId) {
9091
+ try {
9092
+ query.siteId = new ObjectId11(siteId);
9093
+ cacheOptions.siteId = siteId.toString();
9094
+ } catch (error) {
9095
+ throw new BadRequestError11("Invalid site ID format.");
9096
+ }
9097
+ }
9098
+ if (user) {
9099
+ try {
9100
+ query.user = new ObjectId11(user);
9101
+ cacheOptions.user = user.toString();
9102
+ } catch (error) {
9103
+ throw new BadRequestError11("Invalid user ID format.");
9104
+ }
9105
+ }
9094
9106
  if (search) {
9095
9107
  query.$text = { $search: search };
9096
9108
  cacheOptions.search = search;
@@ -14073,6 +14085,7 @@ function useMemberController() {
14073
14085
  limit: Joi15.number().integer().min(1).max(50).allow("", null).default(10),
14074
14086
  user: Joi15.string().hex().optional().allow("", null),
14075
14087
  org: Joi15.string().hex().optional().allow("", null),
14088
+ siteId: Joi15.string().hex().optional().allow("", null),
14076
14089
  type: Joi15.string().required(),
14077
14090
  status: Joi15.string().required()
14078
14091
  });
@@ -14088,6 +14101,7 @@ function useMemberController() {
14088
14101
  const limit = parseInt(req.query.limit ?? "10");
14089
14102
  const user = req.query.user ?? "";
14090
14103
  const org = req.query.org ?? "";
14104
+ const siteId = req.query.siteId ?? "";
14091
14105
  const type = req.query.type ?? "main";
14092
14106
  const status = req.query.status ?? "active";
14093
14107
  try {
@@ -14097,6 +14111,7 @@ function useMemberController() {
14097
14111
  limit,
14098
14112
  user,
14099
14113
  org,
14114
+ siteId,
14100
14115
  type,
14101
14116
  status
14102
14117
  });
@@ -63852,57 +63867,145 @@ function useChatPrelovedController() {
63852
63867
  return { add, updateById, deleteById };
63853
63868
  }
63854
63869
 
63855
- // src/models/online-forms-v2.model.ts
63870
+ // src/models/channel-preloved.model.ts
63856
63871
  import Joi143 from "joi";
63857
63872
  import { ObjectId as ObjectId143 } from "mongodb";
63873
+ var schemaChannelPreloved = Joi143.object({
63874
+ receiverId: Joi143.string().hex().length(24).required(),
63875
+ senderId: Joi143.string().hex().length(24).required(),
63876
+ postId: Joi143.string().hex().length(24).required()
63877
+ });
63878
+ function toObjectId22(value, label) {
63879
+ if (typeof value === "string") {
63880
+ try {
63881
+ return new ObjectId143(value);
63882
+ } catch {
63883
+ throw new Error(`Invalid ${label}.`);
63884
+ }
63885
+ }
63886
+ return value;
63887
+ }
63888
+ function MChannelPreloved(value) {
63889
+ const { error } = schemaChannelPreloved.validate(value);
63890
+ if (error)
63891
+ throw new Error(error.details[0].message);
63892
+ if (value.receiverId)
63893
+ value.receiverId = toObjectId22(value.receiverId, "receiver ID");
63894
+ if (value.senderId)
63895
+ value.senderId = toObjectId22(value.senderId, "sender ID");
63896
+ if (value.postId)
63897
+ value.postId = toObjectId22(value.postId, "post ID");
63898
+ return {
63899
+ _id: new ObjectId143(),
63900
+ name: `seven365-${(/* @__PURE__ */ new Date()).getTime()}`,
63901
+ receiverId: value.receiverId,
63902
+ senderId: value.senderId,
63903
+ postId: value.postId,
63904
+ createdAt: /* @__PURE__ */ new Date(),
63905
+ updatedAt: null
63906
+ };
63907
+ }
63908
+
63909
+ // src/repositories/channel-preloved.repo.ts
63910
+ import {
63911
+ InternalServerError as InternalServerError80,
63912
+ useAtlas as useAtlas125
63913
+ } from "@7365admin1/node-server-utils";
63914
+ function useChannelPrelovedRepo() {
63915
+ const db = useAtlas125.getDb();
63916
+ if (!db)
63917
+ throw new InternalServerError80("Unable to connect to server.");
63918
+ const CHANNEL_COLLECTION = "channel-preloved";
63919
+ const collection = db.collection(CHANNEL_COLLECTION);
63920
+ async function add(value, session) {
63921
+ try {
63922
+ const doc = MChannelPreloved(value);
63923
+ const res = await collection.insertOne(doc, { session });
63924
+ return res.insertedId;
63925
+ } catch (error) {
63926
+ throw error;
63927
+ }
63928
+ }
63929
+ return { add };
63930
+ }
63931
+
63932
+ // src/controllers/channel-preloved.controller.ts
63933
+ import { BadRequestError as BadRequestError222, logger as logger194 } from "@7365admin1/node-server-utils";
63934
+ function useChannelPrelovedController() {
63935
+ const { add: _add } = useChannelPrelovedRepo();
63936
+ async function add(req, res, next) {
63937
+ const { error, value } = schemaChannelPreloved.validate(req.body, {
63938
+ abortEarly: false
63939
+ });
63940
+ if (error) {
63941
+ const messages = error.details.map((d) => d.message).join(", ");
63942
+ logger194.log({ level: "error", message: messages });
63943
+ next(new BadRequestError222(messages));
63944
+ return;
63945
+ }
63946
+ try {
63947
+ const data = await _add(value);
63948
+ res.status(201).json(data);
63949
+ } catch (error2) {
63950
+ logger194.log({ level: "error", message: error2.message });
63951
+ next(error2);
63952
+ }
63953
+ }
63954
+ return { add };
63955
+ }
63956
+
63957
+ // src/models/online-forms-v2.model.ts
63958
+ import Joi144 from "joi";
63959
+ import { ObjectId as ObjectId144 } from "mongodb";
63858
63960
  var FormEntryStatus = /* @__PURE__ */ ((FormEntryStatus2) => {
63859
63961
  FormEntryStatus2["ACTIVE"] = "active";
63860
63962
  FormEntryStatus2["INACTIVE"] = "inactive";
63861
63963
  FormEntryStatus2["DELETED"] = "deleted";
63862
63964
  return FormEntryStatus2;
63863
63965
  })(FormEntryStatus || {});
63864
- var schemaFormEntry = Joi143.object({
63865
- _id: Joi143.string().hex().optional().allow("", null),
63866
- formType: Joi143.string().required(),
63867
- block: Joi143.string().optional().allow(null, ""),
63868
- level: Joi143.string().optional().allow(null, ""),
63869
- unit: Joi143.string().optional().allow(null, ""),
63870
- name: Joi143.string().optional().allow(null, ""),
63871
- phoneNumber: Joi143.string().optional().allow(null, ""),
63872
- fields: Joi143.object().pattern(
63873
- Joi143.string(),
63874
- Joi143.alternatives().try(
63875
- Joi143.string(),
63876
- Joi143.number(),
63877
- Joi143.boolean(),
63878
- Joi143.valid(null)
63966
+ var schemaFormEntry = Joi144.object({
63967
+ _id: Joi144.string().hex().optional().allow("", null),
63968
+ formType: Joi144.string().required(),
63969
+ block: Joi144.string().optional().allow(null, ""),
63970
+ level: Joi144.string().optional().allow(null, ""),
63971
+ unit: Joi144.string().optional().allow(null, ""),
63972
+ name: Joi144.string().optional().allow(null, ""),
63973
+ phoneNumber: Joi144.string().optional().allow(null, ""),
63974
+ createdBy: Joi144.string().required(),
63975
+ fields: Joi144.object().pattern(
63976
+ Joi144.string(),
63977
+ Joi144.alternatives().try(
63978
+ Joi144.string(),
63979
+ Joi144.number(),
63980
+ Joi144.boolean(),
63981
+ Joi144.valid(null)
63879
63982
  )
63880
63983
  ).required(),
63881
- status: Joi143.string().optional().allow("", null),
63882
- org: Joi143.string().hex().optional().allow("", null),
63883
- site: Joi143.string().hex().optional().allow("", null),
63884
- createdAt: Joi143.date().optional().allow("", null),
63885
- updatedAt: Joi143.date().optional().allow("", null),
63886
- deletedAt: Joi143.date().optional().allow("", null)
63984
+ status: Joi144.string().optional().allow("", null),
63985
+ org: Joi144.string().hex().optional().allow("", null),
63986
+ site: Joi144.string().hex().optional().allow("", null),
63987
+ createdAt: Joi144.date().optional().allow("", null),
63988
+ updatedAt: Joi144.date().optional().allow("", null),
63989
+ deletedAt: Joi144.date().optional().allow("", null)
63887
63990
  });
63888
- var schemaUpdateFormEntry = Joi143.object({
63889
- _id: Joi143.string().hex().required(),
63890
- formType: Joi143.string().optional().allow("", null),
63891
- block: Joi143.string().optional().allow(null, ""),
63892
- level: Joi143.string().optional().allow(null, ""),
63893
- unit: Joi143.string().optional().allow(null, ""),
63894
- fields: Joi143.object().pattern(
63895
- Joi143.string(),
63896
- Joi143.alternatives().try(
63897
- Joi143.string(),
63898
- Joi143.number(),
63899
- Joi143.boolean(),
63900
- Joi143.valid(null)
63991
+ var schemaUpdateFormEntry = Joi144.object({
63992
+ _id: Joi144.string().hex().required(),
63993
+ formType: Joi144.string().optional().allow("", null),
63994
+ block: Joi144.string().optional().allow(null, ""),
63995
+ level: Joi144.string().optional().allow(null, ""),
63996
+ unit: Joi144.string().optional().allow(null, ""),
63997
+ fields: Joi144.object().pattern(
63998
+ Joi144.string(),
63999
+ Joi144.alternatives().try(
64000
+ Joi144.string(),
64001
+ Joi144.number(),
64002
+ Joi144.boolean(),
64003
+ Joi144.valid(null)
63901
64004
  )
63902
64005
  ).optional(),
63903
- status: Joi143.string().optional().allow("", null),
63904
- updatedAt: Joi143.date().optional().allow("", null),
63905
- deletedAt: Joi143.date().optional().allow("", null)
64006
+ status: Joi144.string().optional().allow("", null),
64007
+ updatedAt: Joi144.date().optional().allow("", null),
64008
+ deletedAt: Joi144.date().optional().allow("", null)
63906
64009
  });
63907
64010
  function MFormEntry(value) {
63908
64011
  const { error } = schemaFormEntry.validate(value);
@@ -63911,21 +64014,21 @@ function MFormEntry(value) {
63911
64014
  }
63912
64015
  if (value._id && typeof value._id === "string") {
63913
64016
  try {
63914
- value._id = new ObjectId143(value._id);
64017
+ value._id = new ObjectId144(value._id);
63915
64018
  } catch {
63916
64019
  throw new Error("Invalid ID.");
63917
64020
  }
63918
64021
  }
63919
64022
  if (value.org && typeof value.org === "string") {
63920
64023
  try {
63921
- value.org = new ObjectId143(value.org);
64024
+ value.org = new ObjectId144(value.org);
63922
64025
  } catch {
63923
64026
  throw new Error("Invalid org ID.");
63924
64027
  }
63925
64028
  }
63926
64029
  if (value.site && typeof value.site === "string") {
63927
64030
  try {
63928
- value.site = new ObjectId143(value.site);
64031
+ value.site = new ObjectId144(value.site);
63929
64032
  } catch {
63930
64033
  throw new Error("Invalid site ID.");
63931
64034
  }
@@ -63950,21 +64053,21 @@ function MFormEntry(value) {
63950
64053
 
63951
64054
  // src/repositories/online-forms-v2.repository.ts
63952
64055
  import {
63953
- BadRequestError as BadRequestError222,
63954
- InternalServerError as InternalServerError80,
63955
- logger as logger194,
64056
+ BadRequestError as BadRequestError223,
64057
+ InternalServerError as InternalServerError81,
64058
+ logger as logger195,
63956
64059
  makeCacheKey as makeCacheKey66,
63957
64060
  NotFoundError as NotFoundError61,
63958
64061
  paginate as paginate62,
63959
- useAtlas as useAtlas125,
64062
+ useAtlas as useAtlas126,
63960
64063
  useCache as useCache70
63961
64064
  } from "@7365admin1/node-server-utils";
63962
- import { ObjectId as ObjectId144 } from "mongodb";
64065
+ import { ObjectId as ObjectId145 } from "mongodb";
63963
64066
  var online_forms_namespace_collection = "online-forms";
63964
64067
  function useFormEntryRepo() {
63965
- const db = useAtlas125.getDb();
64068
+ const db = useAtlas126.getDb();
63966
64069
  if (!db) {
63967
- throw new InternalServerError80("Unable to connect to server.");
64070
+ throw new InternalServerError81("Unable to connect to server.");
63968
64071
  }
63969
64072
  const collection = db.collection(online_forms_namespace_collection);
63970
64073
  const { delNamespace, getCache, setCache } = useCache70(
@@ -63976,7 +64079,7 @@ function useFormEntryRepo() {
63976
64079
  name: "text"
63977
64080
  });
63978
64081
  } catch (error) {
63979
- throw new InternalServerError80(
64082
+ throw new InternalServerError81(
63980
64083
  "Failed to create text index on online form."
63981
64084
  );
63982
64085
  }
@@ -63986,11 +64089,11 @@ function useFormEntryRepo() {
63986
64089
  value = MFormEntry(value);
63987
64090
  const res = await collection.insertOne(value, { session });
63988
64091
  delNamespace().then(() => {
63989
- logger194.info(
64092
+ logger195.info(
63990
64093
  `Cache cleared for namespace: ${online_forms_namespace_collection}`
63991
64094
  );
63992
64095
  }).catch((err) => {
63993
- logger194.error(
64096
+ logger195.error(
63994
64097
  `Failed to clear cache for namespace: ${online_forms_namespace_collection}`,
63995
64098
  err
63996
64099
  );
@@ -63999,7 +64102,7 @@ function useFormEntryRepo() {
63999
64102
  } catch (error) {
64000
64103
  const isDuplicated = error.message.includes("duplicate");
64001
64104
  if (isDuplicated) {
64002
- throw new BadRequestError222("Online Form already exists.");
64105
+ throw new BadRequestError223("Online Form already exists.");
64003
64106
  }
64004
64107
  throw error;
64005
64108
  }
@@ -64025,7 +64128,7 @@ function useFormEntryRepo() {
64025
64128
  };
64026
64129
  const query = {
64027
64130
  ...status ? { $and: [{ status }, { status: { $ne: "deleted" } }] } : { status: { $ne: "deleted" } },
64028
- ...site && { site: new ObjectId144(site) },
64131
+ ...site && { site: new ObjectId145(site) },
64029
64132
  ...search && { search: [{ name: { $regex: search, $options: "i" } }] }
64030
64133
  };
64031
64134
  const cacheKey = makeCacheKey66(
@@ -64034,7 +64137,7 @@ function useFormEntryRepo() {
64034
64137
  );
64035
64138
  const cachedData = await getCache(cacheKey);
64036
64139
  if (cachedData) {
64037
- logger194.info(`Cache hit for key: ${cacheKey}`);
64140
+ logger195.info(`Cache hit for key: ${cacheKey}`);
64038
64141
  return cachedData;
64039
64142
  }
64040
64143
  try {
@@ -64047,9 +64150,9 @@ function useFormEntryRepo() {
64047
64150
  const length = await collection.countDocuments(query);
64048
64151
  const data = paginate62(items, page, limit, length);
64049
64152
  setCache(cacheKey, data, 15 * 60).then(() => {
64050
- logger194.info(`Cache set for key: ${cacheKey}`);
64153
+ logger195.info(`Cache set for key: ${cacheKey}`);
64051
64154
  }).catch((err) => {
64052
- logger194.error(`Failed to set cache for key: ${cacheKey}`, err);
64155
+ logger195.error(`Failed to set cache for key: ${cacheKey}`, err);
64053
64156
  });
64054
64157
  return data;
64055
64158
  } catch (error) {
@@ -64060,13 +64163,13 @@ function useFormEntryRepo() {
64060
64163
  const cacheKey = makeCacheKey66(online_forms_namespace_collection, { _id });
64061
64164
  const cachedData = await getCache(cacheKey);
64062
64165
  if (cachedData) {
64063
- logger194.info(`Cache hit for key: ${cacheKey}`);
64166
+ logger195.info(`Cache hit for key: ${cacheKey}`);
64064
64167
  return cachedData;
64065
64168
  }
64066
64169
  try {
64067
- _id = new ObjectId144(_id);
64170
+ _id = new ObjectId145(_id);
64068
64171
  } catch (error) {
64069
- throw new BadRequestError222("Invalid online form ID format.");
64172
+ throw new BadRequestError223("Invalid online form ID format.");
64070
64173
  }
64071
64174
  const query = { _id, status: { $ne: "deleted" } };
64072
64175
  try {
@@ -64075,9 +64178,9 @@ function useFormEntryRepo() {
64075
64178
  throw new NotFoundError61("Document not found.");
64076
64179
  }
64077
64180
  setCache(cacheKey, data, 15 * 60).then(() => {
64078
- logger194.info(`Cache set for key: ${cacheKey}`);
64181
+ logger195.info(`Cache set for key: ${cacheKey}`);
64079
64182
  }).catch((err) => {
64080
- logger194.error(`Failed to set cache for key: ${cacheKey}`, err);
64183
+ logger195.error(`Failed to set cache for key: ${cacheKey}`, err);
64081
64184
  });
64082
64185
  return data;
64083
64186
  } catch (error) {
@@ -64086,9 +64189,9 @@ function useFormEntryRepo() {
64086
64189
  }
64087
64190
  async function updateFormEntryById(_id, value) {
64088
64191
  try {
64089
- _id = new ObjectId144(_id);
64192
+ _id = new ObjectId145(_id);
64090
64193
  } catch (error) {
64091
- throw new BadRequestError222("Invalid online form ID format.");
64194
+ throw new BadRequestError223("Invalid online form ID format.");
64092
64195
  }
64093
64196
  try {
64094
64197
  const updateValue = {
@@ -64097,14 +64200,14 @@ function useFormEntryRepo() {
64097
64200
  };
64098
64201
  const res = await collection.updateOne({ _id }, { $set: updateValue });
64099
64202
  if (res.modifiedCount === 0) {
64100
- throw new InternalServerError80("Unable to update online form.");
64203
+ throw new InternalServerError81("Unable to update online form.");
64101
64204
  }
64102
64205
  delNamespace().then(() => {
64103
- logger194.info(
64206
+ logger195.info(
64104
64207
  `Cache cleared for namespace: ${online_forms_namespace_collection}`
64105
64208
  );
64106
64209
  }).catch((err) => {
64107
- logger194.error(
64210
+ logger195.error(
64108
64211
  `Failed to clear cache for namespace: ${online_forms_namespace_collection}`,
64109
64212
  err
64110
64213
  );
@@ -64116,9 +64219,9 @@ function useFormEntryRepo() {
64116
64219
  }
64117
64220
  async function deleteOnlineFormById(_id, session) {
64118
64221
  try {
64119
- _id = new ObjectId144(_id);
64222
+ _id = new ObjectId145(_id);
64120
64223
  } catch (error) {
64121
- throw new BadRequestError222("Invalid online form ID format.");
64224
+ throw new BadRequestError223("Invalid online form ID format.");
64122
64225
  }
64123
64226
  try {
64124
64227
  const updateValue = {
@@ -64132,12 +64235,12 @@ function useFormEntryRepo() {
64132
64235
  { session }
64133
64236
  );
64134
64237
  if (res.modifiedCount === 0) {
64135
- throw new InternalServerError80("Unable to delete online form.");
64238
+ throw new InternalServerError81("Unable to delete online form.");
64136
64239
  }
64137
64240
  delNamespace().then(() => {
64138
- logger194.info(`Cache cleared for namespace: ${online_forms_namespace_collection}`);
64241
+ logger195.info(`Cache cleared for namespace: ${online_forms_namespace_collection}`);
64139
64242
  }).catch((err) => {
64140
- logger194.error(
64243
+ logger195.error(
64141
64244
  `Failed to clear cache for namespace: ${online_forms_namespace_collection}`,
64142
64245
  err
64143
64246
  );
@@ -64158,8 +64261,8 @@ function useFormEntryRepo() {
64158
64261
  }
64159
64262
 
64160
64263
  // src/controllers/online-forms-v2.controller.ts
64161
- import { BadRequestError as BadRequestError223, logger as logger195 } from "@7365admin1/node-server-utils";
64162
- import Joi144 from "joi";
64264
+ import { BadRequestError as BadRequestError224, logger as logger196 } from "@7365admin1/node-server-utils";
64265
+ import Joi145 from "joi";
64163
64266
  import ExcelJS3 from "exceljs";
64164
64267
  import fs6 from "fs";
64165
64268
  function useFormEntryController() {
@@ -64183,14 +64286,14 @@ function useFormEntryController() {
64183
64286
  async function uploadFormEntrys(req, res, next) {
64184
64287
  try {
64185
64288
  if (!req.file) {
64186
- next(new BadRequestError223("Excel file is required."));
64289
+ next(new BadRequestError224("Excel file is required."));
64187
64290
  return;
64188
64291
  }
64189
64292
  const workbook = new ExcelJS3.Workbook();
64190
64293
  await workbook.xlsx.readFile(req.file.path);
64191
64294
  const worksheet = workbook.worksheets[0];
64192
64295
  if (!worksheet) {
64193
- next(new BadRequestError223("No worksheet found in uploaded Excel file."));
64296
+ next(new BadRequestError224("No worksheet found in uploaded Excel file."));
64194
64297
  return;
64195
64298
  }
64196
64299
  const headerRow = worksheet.getRow(1);
@@ -64218,8 +64321,8 @@ function useFormEntryController() {
64218
64321
  });
64219
64322
  if (error) {
64220
64323
  const messages = error.details.map((d) => d.message).join(", ");
64221
- logger195.log({ level: "error", message: messages });
64222
- next(new BadRequestError223(messages));
64324
+ logger196.log({ level: "error", message: messages });
64325
+ next(new BadRequestError224(messages));
64223
64326
  return;
64224
64327
  }
64225
64328
  const result = await _add(value);
@@ -64227,25 +64330,25 @@ function useFormEntryController() {
64227
64330
  fs6.unlink(req.file.path, () => {
64228
64331
  });
64229
64332
  } catch (error) {
64230
- logger195.log({ level: "error", message: error.message });
64333
+ logger196.log({ level: "error", message: error.message });
64231
64334
  next(error);
64232
64335
  }
64233
64336
  }
64234
64337
  async function getAll(req, res, next) {
64235
64338
  try {
64236
- const schema2 = Joi144.object({
64237
- search: Joi144.string().optional().allow("", null),
64238
- page: Joi144.number().integer().min(1).allow("", null).default(1),
64239
- limit: Joi144.number().integer().min(1).max(100).allow("", null).default(10),
64240
- status: Joi144.string().optional().allow(null, ""),
64241
- org: Joi144.string().hex().optional().allow("", null),
64242
- site: Joi144.string().hex().optional().allow("", null)
64339
+ const schema2 = Joi145.object({
64340
+ search: Joi145.string().optional().allow("", null),
64341
+ page: Joi145.number().integer().min(1).allow("", null).default(1),
64342
+ limit: Joi145.number().integer().min(1).max(100).allow("", null).default(10),
64343
+ status: Joi145.string().optional().allow(null, ""),
64344
+ org: Joi145.string().hex().optional().allow("", null),
64345
+ site: Joi145.string().hex().optional().allow("", null)
64243
64346
  });
64244
64347
  const { error, value } = schema2.validate(req.query);
64245
64348
  if (error) {
64246
64349
  const messages = error.details.map((d) => d.message).join(", ");
64247
- logger195.log({ level: "error", message: messages });
64248
- next(new BadRequestError223(messages));
64350
+ logger196.log({ level: "error", message: messages });
64351
+ next(new BadRequestError224(messages));
64249
64352
  return;
64250
64353
  }
64251
64354
  const { search, page, limit, status, org, site } = value;
@@ -64253,21 +64356,21 @@ function useFormEntryController() {
64253
64356
  res.json(data);
64254
64357
  return;
64255
64358
  } catch (error) {
64256
- logger195.log({ level: "error", message: error.message });
64359
+ logger196.log({ level: "error", message: error.message });
64257
64360
  next(error);
64258
64361
  return;
64259
64362
  }
64260
64363
  }
64261
64364
  async function getFormEntryById(req, res, next) {
64262
64365
  try {
64263
- const schema2 = Joi144.object({
64264
- _id: Joi144.string().hex().length(24).required()
64366
+ const schema2 = Joi145.object({
64367
+ _id: Joi145.string().hex().length(24).required()
64265
64368
  });
64266
64369
  const { error, value } = schema2.validate({ _id: req.params.id });
64267
64370
  if (error) {
64268
64371
  const messages = error.details.map((d) => d.message).join(", ");
64269
- logger195.log({ level: "error", message: messages });
64270
- next(new BadRequestError223(messages));
64372
+ logger196.log({ level: "error", message: messages });
64373
+ next(new BadRequestError224(messages));
64271
64374
  return;
64272
64375
  }
64273
64376
  const { _id } = value;
@@ -64275,7 +64378,7 @@ function useFormEntryController() {
64275
64378
  res.json(data);
64276
64379
  return;
64277
64380
  } catch (error) {
64278
- logger195.log({ level: "error", message: error.message });
64381
+ logger196.log({ level: "error", message: error.message });
64279
64382
  next(error);
64280
64383
  return;
64281
64384
  }
@@ -64288,8 +64391,8 @@ function useFormEntryController() {
64288
64391
  });
64289
64392
  if (error) {
64290
64393
  const messages = error.details.map((d) => d.message).join(", ");
64291
- logger195.log({ level: "error", message: messages });
64292
- next(new BadRequestError223(messages));
64394
+ logger196.log({ level: "error", message: messages });
64395
+ next(new BadRequestError224(messages));
64293
64396
  return;
64294
64397
  }
64295
64398
  const { _id, ...rest } = value;
@@ -64297,31 +64400,58 @@ function useFormEntryController() {
64297
64400
  res.json({ message: "Successfully updated online form." });
64298
64401
  return;
64299
64402
  } catch (error) {
64300
- logger195.log({ level: "error", message: error.message });
64403
+ logger196.log({ level: "error", message: error.message });
64301
64404
  next(error);
64302
64405
  return;
64303
64406
  }
64304
64407
  }
64305
64408
  async function deleteFormEntryById(req, res, next) {
64306
64409
  try {
64307
- const validation = Joi144.string().hex().required();
64410
+ const validation = Joi145.string().hex().required();
64308
64411
  const _id = req.params.id;
64309
64412
  const { error } = validation.validate(_id);
64310
64413
  if (error) {
64311
- logger195.log({ level: "error", message: error.message });
64312
- next(new BadRequestError223(error.message));
64414
+ logger196.log({ level: "error", message: error.message });
64415
+ next(new BadRequestError224(error.message));
64313
64416
  return;
64314
64417
  }
64315
64418
  await _deleteOnlineFormById(_id);
64316
64419
  res.json({ message: "Successfully deleted online form." });
64317
64420
  return;
64318
64421
  } catch (error) {
64319
- logger195.log({ level: "error", message: error.message });
64422
+ logger196.log({ level: "error", message: error.message });
64320
64423
  next(error);
64321
64424
  return;
64322
64425
  }
64323
64426
  }
64427
+ async function add(req, res, next) {
64428
+ const cookies = req.headers.cookie?.split(";").map((cookie) => cookie.trim().split("=")).reduce(
64429
+ (acc, [key, value]) => ({ ...acc, [key]: value }),
64430
+ {}
64431
+ );
64432
+ const createdBy = cookies?.["user"].toString() ?? "";
64433
+ const payload = { ...req.body, createdBy };
64434
+ const { error } = schemaFormEntry.validate(payload, {
64435
+ abortEarly: false
64436
+ });
64437
+ if (error) {
64438
+ const messages = error.details.map((d) => d.message).join(", ");
64439
+ logger196.log({ level: "error", message: messages });
64440
+ next(new BadRequestError224(messages));
64441
+ return;
64442
+ }
64443
+ try {
64444
+ const data = await _add(payload);
64445
+ res.status(201).json({ message: data });
64446
+ return;
64447
+ } catch (error2) {
64448
+ logger196.log({ level: "error", message: error2.message });
64449
+ next(error2);
64450
+ return;
64451
+ }
64452
+ }
64324
64453
  return {
64454
+ add,
64325
64455
  uploadFormEntrys,
64326
64456
  getAll,
64327
64457
  getFormEntryById,
@@ -64331,11 +64461,11 @@ function useFormEntryController() {
64331
64461
  }
64332
64462
 
64333
64463
  // src/services/building-level.service.ts
64334
- import { useAtlas as useAtlas126 } from "@7365admin1/node-server-utils";
64464
+ import { useAtlas as useAtlas127 } from "@7365admin1/node-server-utils";
64335
64465
  function useBuildingLevelService() {
64336
64466
  const { add: _add, updateLevelById: _updateLevelById } = useBuildingLevelRepo();
64337
64467
  async function add(value) {
64338
- const session = useAtlas126.getClient()?.startSession();
64468
+ const session = useAtlas127.getClient()?.startSession();
64339
64469
  try {
64340
64470
  session?.startTransaction();
64341
64471
  await _add(value, session);
@@ -64349,7 +64479,7 @@ function useBuildingLevelService() {
64349
64479
  }
64350
64480
  }
64351
64481
  async function updateLevelById(_id, value) {
64352
- const session = useAtlas126.getClient()?.startSession();
64482
+ const session = useAtlas127.getClient()?.startSession();
64353
64483
  try {
64354
64484
  session?.startTransaction();
64355
64485
  await _updateLevelById(_id, value, session);
@@ -64369,8 +64499,8 @@ function useBuildingLevelService() {
64369
64499
  }
64370
64500
 
64371
64501
  // src/controllers/building-level.controller.ts
64372
- import { BadRequestError as BadRequestError224, logger as logger196 } from "@7365admin1/node-server-utils";
64373
- import Joi145 from "joi";
64502
+ import { BadRequestError as BadRequestError225, logger as logger197 } from "@7365admin1/node-server-utils";
64503
+ import Joi146 from "joi";
64374
64504
  function useBuildingLevelController() {
64375
64505
  const { add: _add, updateLevelById: _updateLevelById } = useBuildingLevelService();
64376
64506
  const {
@@ -64385,8 +64515,8 @@ function useBuildingLevelController() {
64385
64515
  });
64386
64516
  if (error) {
64387
64517
  const messages = error.details.map((d) => d.message).join(", ");
64388
- logger196.log({ level: "error", message: messages });
64389
- next(new BadRequestError224(messages));
64518
+ logger197.log({ level: "error", message: messages });
64519
+ next(new BadRequestError225(messages));
64390
64520
  return;
64391
64521
  }
64392
64522
  const result = await _add(value);
@@ -64397,20 +64527,20 @@ function useBuildingLevelController() {
64397
64527
  }
64398
64528
  async function getAll(req, res, next) {
64399
64529
  try {
64400
- const validation = Joi145.object({
64401
- page: Joi145.number().min(1).optional().default(1),
64402
- limit: Joi145.number().min(1).optional().default(20),
64403
- search: Joi145.string().optional().allow("", null),
64404
- site: Joi145.string().hex().length(24).optional().allow("", null),
64405
- status: Joi145.string().valid(...Object.values(BuildingLevelStatus)).default("active" /* ACTIVE */)
64530
+ const validation = Joi146.object({
64531
+ page: Joi146.number().min(1).optional().default(1),
64532
+ limit: Joi146.number().min(1).optional().default(20),
64533
+ search: Joi146.string().optional().allow("", null),
64534
+ site: Joi146.string().hex().length(24).optional().allow("", null),
64535
+ status: Joi146.string().valid(...Object.values(BuildingLevelStatus)).default("active" /* ACTIVE */)
64406
64536
  });
64407
64537
  const { error, value } = validation.validate(req.query, {
64408
64538
  abortEarly: false
64409
64539
  });
64410
64540
  if (error) {
64411
64541
  const messages = error.details.map((d) => d.message);
64412
- logger196.log({ level: "error", message: messages.join(", ") });
64413
- next(new BadRequestError224(messages.join(", ")));
64542
+ logger197.log({ level: "error", message: messages.join(", ") });
64543
+ next(new BadRequestError225(messages.join(", ")));
64414
64544
  return;
64415
64545
  }
64416
64546
  const { page, limit, status, site, search } = value;
@@ -64429,14 +64559,14 @@ function useBuildingLevelController() {
64429
64559
  }
64430
64560
  async function getById(req, res, next) {
64431
64561
  try {
64432
- const schema2 = Joi145.object({
64433
- id: Joi145.string().hex().length(24).required()
64562
+ const schema2 = Joi146.object({
64563
+ id: Joi146.string().hex().length(24).required()
64434
64564
  });
64435
64565
  const { error, value } = schema2.validate({ id: req.params.id });
64436
64566
  if (error) {
64437
64567
  const messages = error.details.map((d) => d.message);
64438
- logger196.log({ level: "error", message: messages.join(", ") });
64439
- next(new BadRequestError224(messages.join(", ")));
64568
+ logger197.log({ level: "error", message: messages.join(", ") });
64569
+ next(new BadRequestError225(messages.join(", ")));
64440
64570
  return;
64441
64571
  }
64442
64572
  const { id } = value;
@@ -64455,8 +64585,8 @@ function useBuildingLevelController() {
64455
64585
  });
64456
64586
  if (error) {
64457
64587
  const messages = error.details.map((d) => d.message);
64458
- logger196.log({ level: "error", message: messages.join(", ") });
64459
- next(new BadRequestError224(messages.join(", ")));
64588
+ logger197.log({ level: "error", message: messages.join(", ") });
64589
+ next(new BadRequestError225(messages.join(", ")));
64460
64590
  return;
64461
64591
  }
64462
64592
  const { _id, ...rest } = value;
@@ -64468,14 +64598,14 @@ function useBuildingLevelController() {
64468
64598
  }
64469
64599
  async function deleteById(req, res, next) {
64470
64600
  try {
64471
- const schema2 = Joi145.object({
64472
- id: Joi145.string().hex().required()
64601
+ const schema2 = Joi146.object({
64602
+ id: Joi146.string().hex().required()
64473
64603
  });
64474
64604
  const { error, value } = schema2.validate({ id: req.params.id });
64475
64605
  if (error) {
64476
64606
  const messages = error.details.map((d) => d.message);
64477
- logger196.log({ level: "error", message: messages.join(", ") });
64478
- next(new BadRequestError224(messages.join(", ")));
64607
+ logger197.log({ level: "error", message: messages.join(", ") });
64608
+ next(new BadRequestError225(messages.join(", ")));
64479
64609
  return;
64480
64610
  }
64481
64611
  const { id } = value;
@@ -64537,6 +64667,7 @@ export {
64537
64667
  MBulletinBoard,
64538
64668
  MBulletinVideo,
64539
64669
  MCategoryPreloved,
64670
+ MChannelPreloved,
64540
64671
  MChat,
64541
64672
  MChatPreloved,
64542
64673
  MCustomer,
@@ -64683,6 +64814,7 @@ export {
64683
64814
  schemaBulletinBoard,
64684
64815
  schemaBulletinVideo,
64685
64816
  schemaCategoryPreloved,
64817
+ schemaChannelPreloved,
64686
64818
  schemaChatPreloved,
64687
64819
  schemaCustomerSite,
64688
64820
  schemaDocumentManagement,
@@ -64791,6 +64923,8 @@ export {
64791
64923
  useBulletinVideoService,
64792
64924
  useCategoryPrelovedController,
64793
64925
  useCategoryPrelovedRepo,
64926
+ useChannelPrelovedController,
64927
+ useChannelPrelovedRepo,
64794
64928
  useChatController,
64795
64929
  useChatPrelovedController,
64796
64930
  useChatPrelovedRepo,