@7365admin1/core 2.26.0 → 2.27.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
@@ -13474,6 +13474,7 @@ var VehicleSort = /* @__PURE__ */ ((VehicleSort2) => {
13474
13474
  VehicleSort2["NAME"] = "name";
13475
13475
  VehicleSort2["START"] = "start";
13476
13476
  VehicleSort2["END"] = "end";
13477
+ VehicleSort2["UPDATED_AT"] = "updatedAt";
13477
13478
  return VehicleSort2;
13478
13479
  })(VehicleSort || {});
13479
13480
  var OrgNature = /* @__PURE__ */ ((OrgNature2) => {
@@ -13575,7 +13576,7 @@ function MVehicle(value) {
13575
13576
  unitName: value.unitName ?? "",
13576
13577
  peopleId: value.peopleId ?? "",
13577
13578
  createdAt,
13578
- updatedAt: value.updatedAt ?? "",
13579
+ updatedAt: value.updatedAt ?? createdAt,
13579
13580
  deletedAt: value.deletedAt ?? ""
13580
13581
  };
13581
13582
  }
@@ -13725,7 +13726,6 @@ function useVehicleRepo() {
13725
13726
  ...category && { category }
13726
13727
  };
13727
13728
  let query = { ...baseQuery };
13728
- sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
13729
13729
  const cacheOptions = {
13730
13730
  ...status && { status },
13731
13731
  ...type && { type },
@@ -13771,7 +13771,9 @@ function useVehicleRepo() {
13771
13771
  unitName: "$unit.name",
13772
13772
  recNo: 1,
13773
13773
  nric: 1,
13774
- plateNumber: 1
13774
+ plateNumber: 1,
13775
+ createdAt: 1,
13776
+ updatedAt: 1
13775
13777
  }
13776
13778
  },
13777
13779
  {
@@ -13799,6 +13801,8 @@ function useVehicleRepo() {
13799
13801
  unit: { $first: "$unit" },
13800
13802
  unitName: { $first: "$unitName" },
13801
13803
  nric: { $first: "$nric" },
13804
+ createdAt: { $min: "$createdAt" },
13805
+ updatedAt: { $max: "$updatedAt" },
13802
13806
  plates: {
13803
13807
  $addToSet: {
13804
13808
  _id: "$_id",
@@ -13834,10 +13838,19 @@ function useVehicleRepo() {
13834
13838
  ]
13835
13839
  }
13836
13840
  }
13841
+ },
13842
+ createdAt: 1,
13843
+ updatedAt: 1
13844
+ }
13845
+ },
13846
+ {
13847
+ $addFields: {
13848
+ sortDate: {
13849
+ $ifNull: ["$updatedAt", "$createdAt"]
13837
13850
  }
13838
13851
  }
13839
13852
  },
13840
- { $sort: sort },
13853
+ { $sort: { sortDate: -1 } },
13841
13854
  { $skip: page * limit },
13842
13855
  { $limit: limit }
13843
13856
  ];
@@ -18269,7 +18282,7 @@ function useVehicleController() {
18269
18282
  search: Joi46.string().optional().allow("", null),
18270
18283
  page: Joi46.number().integer().min(1).optional().default(1),
18271
18284
  limit: Joi46.number().integer().min(1).max(100).optional().default(10),
18272
- sort: Joi46.string().optional().valid(...Object.values(VehicleSort)),
18285
+ sort: Joi46.string().optional().valid(...Object.values(VehicleSort)).default("updatedAt" /* UPDATED_AT */),
18273
18286
  order: Joi46.string().optional().valid(...Object.values(SortOrder)),
18274
18287
  type: Joi46.string().optional().valid(...Object.values(VehicleType)).allow(null, ""),
18275
18288
  category: Joi46.string().optional().valid(...Object.values(VehicleCategory)).allow(null, ""),
@@ -18285,15 +18298,20 @@ function useVehicleController() {
18285
18298
  return;
18286
18299
  }
18287
18300
  const { search, page, limit, type, category, status, sort, order } = value;
18288
- const sortObj = {
18289
- [sort ? sort : "_id" /* ID */]: order === "asc" /* ASC */ ? 1 : -1
18290
- };
18301
+ let sortObj;
18302
+ if (sort === "updatedAt" /* UPDATED_AT */) {
18303
+ sortObj = order === "asc" /* ASC */ ? { updatedAt: 1, createdAt: 1, _id: 1 } : { updatedAt: -1, createdAt: -1, _id: -1 };
18304
+ } else {
18305
+ sortObj = {
18306
+ [sort]: order === "asc" /* ASC */ ? 1 : -1
18307
+ };
18308
+ }
18291
18309
  try {
18292
18310
  const data = await _getVehicles({
18293
18311
  search,
18294
18312
  page,
18295
18313
  limit,
18296
- sort: sortObj,
18314
+ // sort: sortObj,
18297
18315
  type,
18298
18316
  category,
18299
18317
  status
@@ -19831,13 +19849,15 @@ function useAttendanceRepository() {
19831
19849
  limit = 10,
19832
19850
  search = "",
19833
19851
  site,
19852
+ serviceType,
19834
19853
  user
19835
19854
  }) {
19836
19855
  page = page > 0 ? page - 1 : 0;
19837
- const query = {};
19856
+ const query = { serviceType };
19838
19857
  const cacheOptions = {
19839
19858
  page,
19840
- limit
19859
+ limit,
19860
+ serviceType
19841
19861
  };
19842
19862
  try {
19843
19863
  site = new ObjectId53(site);
@@ -20298,6 +20318,7 @@ function useAttendanceController() {
20298
20318
  limit: Joi54.number().min(1).optional().allow("", null),
20299
20319
  search: Joi54.string().optional().allow("", null),
20300
20320
  site: Joi54.string().hex().required(),
20321
+ serviceType: Joi54.string().valid(...Object.values(AppServiceType)).required(),
20301
20322
  user: Joi54.string().hex().required()
20302
20323
  });
20303
20324
  const { error } = validation.validate(query);
@@ -20310,12 +20331,14 @@ function useAttendanceController() {
20310
20331
  const limit = parseInt(req.query.limit) ?? 10;
20311
20332
  const search = req.query.search ?? "";
20312
20333
  const site = req.params.site ?? "";
20334
+ const serviceType = req.query.serviceType ?? "";
20313
20335
  try {
20314
20336
  const data = await _getAttendanceByUser({
20315
20337
  page,
20316
20338
  limit,
20317
20339
  search,
20318
20340
  site,
20341
+ serviceType,
20319
20342
  user
20320
20343
  });
20321
20344
  res.json(data);
@@ -33769,6 +33792,11 @@ function useNfcPatrolTagController() {
33769
33792
  // src/models/occurrence-book.model.ts
33770
33793
  import { ObjectId as ObjectId87 } from "mongodb";
33771
33794
  import Joi88 from "joi";
33795
+ var DOBStatus = /* @__PURE__ */ ((DOBStatus3) => {
33796
+ DOBStatus3["OPEN"] = "open";
33797
+ DOBStatus3["CLOSE"] = "close";
33798
+ return DOBStatus3;
33799
+ })(DOBStatus || {});
33772
33800
  var schemaOccurrenceBook = Joi88.object({
33773
33801
  _id: Joi88.string().optional().allow(null, ""),
33774
33802
  site: Joi88.string().hex().required(),
@@ -33835,7 +33863,12 @@ function useOccurrenceBookRepo() {
33835
33863
  async function createIndexes() {
33836
33864
  try {
33837
33865
  await collection.createIndexes([
33838
- { key: { site: 1, status: 1, date: 1, closedAt: 1 } }
33866
+ { key: { site: 1, status: 1, date: 1, closedAt: 1 } },
33867
+ {
33868
+ key: { site: 1, date: 1 },
33869
+ unique: true,
33870
+ name: "unique_site_date"
33871
+ }
33839
33872
  ]);
33840
33873
  } catch (error) {
33841
33874
  throw new InternalServerError48(
@@ -34233,7 +34266,9 @@ function useOccurrenceBookService() {
34233
34266
  site: site._id,
34234
34267
  date: baseDate.toISOString(),
34235
34268
  closedAt: closedAt.toISOString(),
34236
- entryCounter
34269
+ entryCounter,
34270
+ totalInput: 0,
34271
+ status: "open" /* OPEN */
34237
34272
  }));
34238
34273
  await _bulkCreate(payloads, session);
34239
34274
  await session?.commitTransaction();
@@ -45453,6 +45488,7 @@ export {
45453
45488
  BulletinStatus,
45454
45489
  CameraType,
45455
45490
  DEVICE_STATUS,
45491
+ DOBStatus,
45456
45492
  DayOfWeek,
45457
45493
  EAccessCardTypes,
45458
45494
  EAccessCardUserTypes,