@7365admin1/core 3.3.0 → 3.4.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
@@ -8751,6 +8751,9 @@ function MMember(value) {
8751
8751
  siteId: Joi7.string().hex().optional().allow("", null),
8752
8752
  siteName: Joi7.string().optional().allow("", null),
8753
8753
  status: Joi7.string().optional().allow("", null),
8754
+ onboardingRequired: Joi7.boolean().optional(),
8755
+ onboardingCompleted: Joi7.boolean().optional(),
8756
+ onboardingCompletedAt: Joi7.string().optional().allow("", null),
8754
8757
  createdAt: Joi7.string().optional().allow("", null),
8755
8758
  updatedAt: Joi7.string().optional().allow("", null),
8756
8759
  deletedAt: Joi7.string().optional().allow("", null)
@@ -8798,6 +8801,9 @@ function MMember(value) {
8798
8801
  siteId: value.siteId ?? "",
8799
8802
  siteName: value.siteName ?? "",
8800
8803
  status: value.status || "active",
8804
+ onboardingRequired: value.onboardingRequired ?? false,
8805
+ onboardingCompleted: value.onboardingCompleted ?? !value.onboardingRequired,
8806
+ onboardingCompletedAt: value.onboardingCompletedAt ?? "",
8801
8807
  createdAt: value.createdAt || (/* @__PURE__ */ new Date()).toISOString(),
8802
8808
  updatedAt: "",
8803
8809
  deletedAt: ""
@@ -9648,6 +9654,35 @@ function useMemberRepo() {
9648
9654
  );
9649
9655
  }
9650
9656
  }
9657
+ async function completeOnboardingById(_id, session) {
9658
+ try {
9659
+ _id = new ObjectId11(_id);
9660
+ } catch {
9661
+ throw new BadRequestError11("Invalid member ID format.");
9662
+ }
9663
+ const result = await collection.updateOne(
9664
+ {
9665
+ _id,
9666
+ onboardingRequired: true,
9667
+ onboardingCompleted: false
9668
+ },
9669
+ {
9670
+ $set: {
9671
+ onboardingCompleted: true,
9672
+ onboardingCompletedAt: (/* @__PURE__ */ new Date()).toISOString(),
9673
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString()
9674
+ }
9675
+ },
9676
+ { session }
9677
+ );
9678
+ if (!result.matchedCount) {
9679
+ throw new NotFoundError5(
9680
+ "Member not found or onboarding is not required."
9681
+ );
9682
+ }
9683
+ await delNamespace();
9684
+ return "Successfully completed onboarding.";
9685
+ }
9651
9686
  return {
9652
9687
  createIndex,
9653
9688
  createUniqueIndex,
@@ -9669,7 +9704,8 @@ function useMemberRepo() {
9669
9704
  updateRoleById,
9670
9705
  getByRoles,
9671
9706
  updateSiteById,
9672
- getByUserIdTypeOrg
9707
+ getByUserIdTypeOrg,
9708
+ completeOnboardingById
9673
9709
  };
9674
9710
  }
9675
9711
 
@@ -10147,9 +10183,6 @@ var orgSchema = Joi8.object({
10147
10183
  busInst: Joi8.string().optional().allow("", null),
10148
10184
  status: Joi8.string().optional().allow("", null),
10149
10185
  defaultSite: Joi8.string().hex().optional().allow("", null),
10150
- onboardingRequired: Joi8.boolean().optional(),
10151
- onboardingCompleted: Joi8.boolean().optional(),
10152
- onboardingCompletedAt: Joi8.date().optional().allow(null),
10153
10186
  terms: Joi8.string().optional().allow("", null),
10154
10187
  policies: Joi8.string().optional().allow("", null),
10155
10188
  createdAt: Joi8.string().optional().allow("", null),
@@ -10179,9 +10212,6 @@ function MOrg(value) {
10179
10212
  busInst: value.busInst,
10180
10213
  status: value.status || "active",
10181
10214
  defaultSite: value.defaultSite,
10182
- onboardingRequired: value.onboardingRequired || false,
10183
- onboardingCompleted: value.onboardingCompleted || false,
10184
- onboardingCompletedAt: value.onboardingCompletedAt || null,
10185
10215
  terms: value.terms ?? "",
10186
10216
  policies: value.policies ?? "",
10187
10217
  createdAt: value.createdAt || /* @__PURE__ */ new Date(),
@@ -13838,7 +13868,8 @@ function useMemberService() {
13838
13868
  updateRoleById: _updateRoleById,
13839
13869
  getByRoles,
13840
13870
  updateSiteById: _updateSiteById,
13841
- getAllByUserId: _getAllByUserId
13871
+ getAllByUserId: _getAllByUserId,
13872
+ completeOnboardingById: _completeOnboardingById
13842
13873
  } = useMemberRepo();
13843
13874
  const { getById: _getVerificationById, updateStatusById } = useVerificationRepo();
13844
13875
  const { getUserByEmail, updateDefaultOrgByEmail, getUserById } = useUserRepo();
@@ -13909,7 +13940,8 @@ function useMemberService() {
13909
13940
  roleId,
13910
13941
  app,
13911
13942
  siteId,
13912
- siteName
13943
+ siteName,
13944
+ onboardingRequired
13913
13945
  }) {
13914
13946
  const session = useAtlas15.getClient()?.startSession();
13915
13947
  session?.startTransaction();
@@ -13929,7 +13961,10 @@ function useMemberService() {
13929
13961
  role: roleId,
13930
13962
  type: app,
13931
13963
  siteId: siteId ?? "",
13932
- siteName: siteName ?? ""
13964
+ siteName: siteName ?? "",
13965
+ onboardingRequired,
13966
+ onboardingCompleted: false,
13967
+ onboardingCompletedAt: ""
13933
13968
  },
13934
13969
  session
13935
13970
  );
@@ -13999,12 +14034,19 @@ function useMemberService() {
13999
14034
  throw error;
14000
14035
  }
14001
14036
  }
14037
+ async function completeOnboarding(memberId) {
14038
+ await _completeOnboardingById(memberId);
14039
+ return {
14040
+ message: "Member onboarding completed."
14041
+ };
14042
+ }
14002
14043
  return {
14003
14044
  createMember,
14004
14045
  createMemberDirect,
14005
14046
  updateRoleById,
14006
14047
  updateSiteById,
14007
- getAllByUser
14048
+ getAllByUser,
14049
+ completeOnboarding
14008
14050
  };
14009
14051
  }
14010
14052
 
@@ -14020,7 +14062,7 @@ function useMemberController() {
14020
14062
  updateStatusByUserId: _updateStatusByUserId,
14021
14063
  updateSiteById: _updateSiteById
14022
14064
  } = useMemberRepo();
14023
- const { createMember: _createMember, createMemberDirect: _createMemberDirect, updateRoleById: _updateRoleById, getAllByUser: _getAllByUser } = useMemberService();
14065
+ const { createMember: _createMember, createMemberDirect: _createMemberDirect, updateRoleById: _updateRoleById, getAllByUser: _getAllByUser, completeOnboarding: _completeOnboarding } = useMemberService();
14024
14066
  async function createMember(req, res, next) {
14025
14067
  const validation = Joi15.string().hex().required();
14026
14068
  const _id = req.params.id;
@@ -14244,7 +14286,8 @@ function useMemberController() {
14244
14286
  roleId: Joi15.string().hex().required(),
14245
14287
  app: Joi15.string().required(),
14246
14288
  siteId: Joi15.string().hex().optional().allow("", null),
14247
- siteName: Joi15.string().optional().allow("", null)
14289
+ siteName: Joi15.string().optional().allow("", null),
14290
+ onboardingRequired: Joi15.boolean().optional()
14248
14291
  });
14249
14292
  const { error } = validation.validate(req.body);
14250
14293
  if (error) {
@@ -14252,9 +14295,9 @@ function useMemberController() {
14252
14295
  next(new BadRequestError30(error.message));
14253
14296
  return;
14254
14297
  }
14255
- const { userId, orgId, roleId, app, siteId, siteName } = req.body;
14298
+ const { userId, orgId, roleId, app, siteId, siteName, onboardingRequired } = req.body;
14256
14299
  try {
14257
- const data = await _createMemberDirect({ userId, orgId, roleId, app, siteId, siteName });
14300
+ const data = await _createMemberDirect({ userId, orgId, roleId, app, siteId, siteName, onboardingRequired });
14258
14301
  res.status(201).json(data);
14259
14302
  return;
14260
14303
  } catch (error2) {
@@ -14328,6 +14371,23 @@ function useMemberController() {
14328
14371
  return;
14329
14372
  }
14330
14373
  }
14374
+ async function completeOnboarding(req, res, next) {
14375
+ const validation = Joi15.object({
14376
+ id: Joi15.string().hex().required()
14377
+ });
14378
+ const { error } = validation.validate(req.params);
14379
+ if (error) {
14380
+ return next(new BadRequestError30(error.message));
14381
+ }
14382
+ try {
14383
+ const data = await _completeOnboarding(
14384
+ req.params.id
14385
+ );
14386
+ res.json(data);
14387
+ } catch (error2) {
14388
+ next(error2);
14389
+ }
14390
+ }
14331
14391
  return {
14332
14392
  createMember,
14333
14393
  getByUserId,
@@ -14339,7 +14399,8 @@ function useMemberController() {
14339
14399
  updateRoleById,
14340
14400
  createMemberDirect,
14341
14401
  updateSiteById,
14342
- getByUserIdTypeOrg
14402
+ getByUserIdTypeOrg,
14403
+ completeOnboarding
14343
14404
  };
14344
14405
  }
14345
14406
 
@@ -14988,7 +15049,7 @@ function useOrgController() {
14988
15049
  return;
14989
15050
  }
14990
15051
  try {
14991
- const _id = await _add({ ...req.body, onboardingRequired: true, onboardingCompleted: false, onboardingCompletedAt: null });
15052
+ const _id = await _add(req.body);
14992
15053
  const data = await _getById(_id);
14993
15054
  res.status(201).json({
14994
15055
  message: "Successfully created organization.",
@@ -15157,35 +15218,6 @@ function useOrgController() {
15157
15218
  next(error);
15158
15219
  }
15159
15220
  }
15160
- async function completeOnboarding(req, res, next) {
15161
- const validation = Joi18.string().hex().required();
15162
- const id = req.params.id;
15163
- const { error } = validation.validate(id);
15164
- if (error) {
15165
- logger25.log({
15166
- level: "error",
15167
- message: error.message
15168
- });
15169
- next(new BadRequestError33(error.message));
15170
- return;
15171
- }
15172
- try {
15173
- await _completeOnboardingById(id);
15174
- const data = await _getById(id);
15175
- res.json({
15176
- message: "Organization onboarding completed successfully",
15177
- data
15178
- });
15179
- return;
15180
- } catch (error2) {
15181
- logger25.log({
15182
- level: "error",
15183
- message: error2.message
15184
- });
15185
- next(error2);
15186
- return;
15187
- }
15188
- }
15189
15221
  return {
15190
15222
  add,
15191
15223
  addOnboardingOrg,
@@ -15196,8 +15228,7 @@ function useOrgController() {
15196
15228
  getByEmail,
15197
15229
  update,
15198
15230
  getOrgsByEmail,
15199
- getAdminOrgForResident,
15200
- completeOnboarding
15231
+ getAdminOrgForResident
15201
15232
  };
15202
15233
  }
15203
15234
 
@@ -21282,15 +21313,9 @@ function useVisitorTransactionRepo() {
21282
21313
  {
21283
21314
  $lookup: {
21284
21315
  from: "buildings",
21285
- let: { blockId: "$block" },
21286
- pipeline: [
21287
- {
21288
- $match: {
21289
- $expr: { $eq: ["$_id", "$$blockId"] }
21290
- }
21291
- },
21292
- { $project: { _id: 1, name: 1, block: 1 } }
21293
- ],
21316
+ localField: "block",
21317
+ foreignField: "_id",
21318
+ pipeline: [{ $project: { name: 1, block: 1 } }],
21294
21319
  as: "block"
21295
21320
  }
21296
21321
  },
@@ -21298,15 +21323,9 @@ function useVisitorTransactionRepo() {
21298
21323
  {
21299
21324
  $lookup: {
21300
21325
  from: "building-levels",
21301
- let: { levelId: "$level" },
21302
- pipeline: [
21303
- {
21304
- $match: {
21305
- $expr: { $eq: ["$_id", "$$levelId"] }
21306
- }
21307
- },
21308
- { $project: { _id: 1, name: 1 } }
21309
- ],
21326
+ localField: "level",
21327
+ foreignField: "_id",
21328
+ pipeline: [{ $project: { name: 1 } }],
21310
21329
  as: "level"
21311
21330
  }
21312
21331
  },
@@ -21314,15 +21333,9 @@ function useVisitorTransactionRepo() {
21314
21333
  {
21315
21334
  $lookup: {
21316
21335
  from: "building-units",
21317
- let: { unitId: "$unit" },
21318
- pipeline: [
21319
- {
21320
- $match: {
21321
- $expr: { $eq: ["$_id", "$$unitId"] }
21322
- }
21323
- },
21324
- { $project: { _id: 1, name: 1 } }
21325
- ],
21336
+ localField: "unit",
21337
+ foreignField: "_id",
21338
+ pipeline: [{ $project: { name: 1 } }],
21326
21339
  as: "unit"
21327
21340
  }
21328
21341
  },
@@ -21376,15 +21389,9 @@ function useVisitorTransactionRepo() {
21376
21389
  {
21377
21390
  $lookup: {
21378
21391
  from: "buildings",
21379
- let: { blockId: "$block" },
21380
- pipeline: [
21381
- {
21382
- $match: {
21383
- $expr: { $eq: [{ $toString: "$_id" }, "$$blockId"] }
21384
- }
21385
- },
21386
- { $project: { _id: 1, name: 1, block: 1 } }
21387
- ],
21392
+ localField: "block",
21393
+ foreignField: "_id",
21394
+ pipeline: [{ $project: { name: 1, block: 1 } }],
21388
21395
  as: "block"
21389
21396
  }
21390
21397
  },
@@ -21392,15 +21399,9 @@ function useVisitorTransactionRepo() {
21392
21399
  {
21393
21400
  $lookup: {
21394
21401
  from: "building-levels",
21395
- let: { levelId: "$level" },
21396
- pipeline: [
21397
- {
21398
- $match: {
21399
- $expr: { $eq: [{ $toString: "$_id" }, "$$levelId"] }
21400
- }
21401
- },
21402
- { $project: { _id: 1, name: 1 } }
21403
- ],
21402
+ localField: "level",
21403
+ foreignField: "_id",
21404
+ pipeline: [{ $project: { name: 1 } }],
21404
21405
  as: "level"
21405
21406
  }
21406
21407
  },
@@ -21408,15 +21409,9 @@ function useVisitorTransactionRepo() {
21408
21409
  {
21409
21410
  $lookup: {
21410
21411
  from: "building-units",
21411
- let: { unitId: { $toString: "$unit" } },
21412
- pipeline: [
21413
- {
21414
- $match: {
21415
- $expr: { $eq: [{ $toString: "$_id" }, "$$unitId"] }
21416
- }
21417
- },
21418
- { $project: { _id: 1, name: 1 } }
21419
- ],
21412
+ localField: "unit",
21413
+ foreignField: "_id",
21414
+ pipeline: [{ $project: { name: 1 } }],
21420
21415
  as: "unit"
21421
21416
  }
21422
21417
  },
@@ -22085,15 +22080,9 @@ function useVehicleRepo() {
22085
22080
  {
22086
22081
  $lookup: {
22087
22082
  from: "buildings",
22088
- let: { blockId: "$block" },
22089
- pipeline: [
22090
- {
22091
- $match: {
22092
- $expr: { $eq: ["$_id", "$$blockId"] }
22093
- }
22094
- },
22095
- { $project: { _id: 1, name: 1, block: 1 } }
22096
- ],
22083
+ localField: "block",
22084
+ foreignField: "_id",
22085
+ pipeline: [{ $project: { name: 1, block: 1 } }],
22097
22086
  as: "block"
22098
22087
  }
22099
22088
  },
@@ -22101,15 +22090,9 @@ function useVehicleRepo() {
22101
22090
  {
22102
22091
  $lookup: {
22103
22092
  from: "building-levels",
22104
- let: { levelId: "$level" },
22105
- pipeline: [
22106
- {
22107
- $match: {
22108
- $expr: { $eq: ["$_id", "$$levelId"] }
22109
- }
22110
- },
22111
- { $project: { _id: 1, name: 1 } }
22112
- ],
22093
+ localField: "level",
22094
+ foreignField: "_id",
22095
+ pipeline: [{ $project: { name: 1 } }],
22113
22096
  as: "level"
22114
22097
  }
22115
22098
  },
@@ -22117,15 +22100,9 @@ function useVehicleRepo() {
22117
22100
  {
22118
22101
  $lookup: {
22119
22102
  from: "building-units",
22120
- let: { unitId: "$unit" },
22121
- pipeline: [
22122
- {
22123
- $match: {
22124
- $expr: { $eq: ["$_id", "$$unitId"] }
22125
- }
22126
- },
22127
- { $project: { _id: 1, name: 1 } }
22128
- ],
22103
+ localField: "unit",
22104
+ foreignField: "_id",
22105
+ pipeline: [{ $project: { name: 1 } }],
22129
22106
  as: "unit"
22130
22107
  }
22131
22108
  },
@@ -22390,15 +22367,9 @@ function useVehicleRepo() {
22390
22367
  {
22391
22368
  $lookup: {
22392
22369
  from: "buildings",
22393
- let: { blockId: "$block" },
22394
- pipeline: [
22395
- {
22396
- $match: {
22397
- $expr: { $eq: [{ $toString: "$_id" }, "$$blockId"] }
22398
- }
22399
- },
22400
- { $project: { _id: 1, name: 1, block: 1 } }
22401
- ],
22370
+ localField: "block",
22371
+ foreignField: "_id",
22372
+ pipeline: [{ $project: { name: 1, block: 1 } }],
22402
22373
  as: "block"
22403
22374
  }
22404
22375
  },
@@ -22406,15 +22377,9 @@ function useVehicleRepo() {
22406
22377
  {
22407
22378
  $lookup: {
22408
22379
  from: "building-levels",
22409
- let: { levelId: "$level" },
22410
- pipeline: [
22411
- {
22412
- $match: {
22413
- $expr: { $eq: [{ $toString: "$_id" }, "$$levelId"] }
22414
- }
22415
- },
22416
- { $project: { _id: 1, name: 1 } }
22417
- ],
22380
+ localField: "level",
22381
+ foreignField: "_id",
22382
+ pipeline: [{ $project: { name: 1 } }],
22418
22383
  as: "level"
22419
22384
  }
22420
22385
  },
@@ -22422,15 +22387,9 @@ function useVehicleRepo() {
22422
22387
  {
22423
22388
  $lookup: {
22424
22389
  from: "building-units",
22425
- let: { unitId: { $toString: "$unit" } },
22426
- pipeline: [
22427
- {
22428
- $match: {
22429
- $expr: { $eq: [{ $toString: "$_id" }, "$$unitId"] }
22430
- }
22431
- },
22432
- { $project: { _id: 1, name: 1 } }
22433
- ],
22390
+ localField: "unit",
22391
+ foreignField: "_id",
22392
+ pipeline: [{ $project: { name: 1 } }],
22434
22393
  as: "unit"
22435
22394
  }
22436
22395
  },
@@ -24409,15 +24368,9 @@ function usePersonRepo() {
24409
24368
  {
24410
24369
  $lookup: {
24411
24370
  from: "buildings",
24412
- let: { blockId: "$block" },
24413
- pipeline: [
24414
- {
24415
- $match: {
24416
- $expr: { $eq: ["$_id", "$$blockId"] }
24417
- }
24418
- },
24419
- { $project: { _id: 1, name: 1, block: 1 } }
24420
- ],
24371
+ localField: "block",
24372
+ foreignField: "_id",
24373
+ pipeline: [{ $project: { _id: 1, name: 1, block: 1 } }],
24421
24374
  as: "block"
24422
24375
  }
24423
24376
  },
@@ -24425,15 +24378,9 @@ function usePersonRepo() {
24425
24378
  {
24426
24379
  $lookup: {
24427
24380
  from: "building-levels",
24428
- let: { levelId: "$level" },
24429
- pipeline: [
24430
- {
24431
- $match: {
24432
- $expr: { $eq: ["$_id", "$$levelId"] }
24433
- }
24434
- },
24435
- { $project: { _id: 1, name: 1 } }
24436
- ],
24381
+ localField: "level",
24382
+ foreignField: "_id",
24383
+ pipeline: [{ $project: { _id: 1, name: 1 } }],
24437
24384
  as: "level"
24438
24385
  }
24439
24386
  },
@@ -24441,15 +24388,9 @@ function usePersonRepo() {
24441
24388
  {
24442
24389
  $lookup: {
24443
24390
  from: "building-units",
24444
- let: { unitId: { $toString: "$unit" } },
24445
- pipeline: [
24446
- {
24447
- $match: {
24448
- $expr: { $eq: [{ $toString: "$_id" }, "$$unitId"] }
24449
- }
24450
- },
24451
- { $project: { _id: 1, name: 1 } }
24452
- ],
24391
+ localField: "unit",
24392
+ foreignField: "_id",
24393
+ pipeline: [{ $project: { _id: 1, name: 1 } }],
24453
24394
  as: "unit"
24454
24395
  }
24455
24396
  },
@@ -24656,15 +24597,9 @@ function usePersonRepo() {
24656
24597
  {
24657
24598
  $lookup: {
24658
24599
  from: "buildings",
24659
- let: { blockId: "$block" },
24660
- pipeline: [
24661
- {
24662
- $match: {
24663
- $expr: { $eq: ["$_id", "$$blockId"] }
24664
- }
24665
- },
24666
- { $project: { _id: 1, name: 1, block: 1 } }
24667
- ],
24600
+ localField: "block",
24601
+ foreignField: "_id",
24602
+ pipeline: [{ $project: { _id: 1, name: 1, block: 1 } }],
24668
24603
  as: "block"
24669
24604
  }
24670
24605
  },
@@ -24672,15 +24607,9 @@ function usePersonRepo() {
24672
24607
  {
24673
24608
  $lookup: {
24674
24609
  from: "building-levels",
24675
- let: { levelId: "$level" },
24676
- pipeline: [
24677
- {
24678
- $match: {
24679
- $expr: { $eq: ["$_id", "$$levelId"] }
24680
- }
24681
- },
24682
- { $project: { _id: 1, name: 1 } }
24683
- ],
24610
+ localField: "level",
24611
+ foreignField: "_id",
24612
+ pipeline: [{ $project: { _id: 1, name: 1 } }],
24684
24613
  as: "level"
24685
24614
  }
24686
24615
  },
@@ -24688,15 +24617,9 @@ function usePersonRepo() {
24688
24617
  {
24689
24618
  $lookup: {
24690
24619
  from: "building-units",
24691
- let: { unitId: { $toString: "$unit" } },
24692
- pipeline: [
24693
- {
24694
- $match: {
24695
- $expr: { $eq: [{ $toString: "$_id" }, "$$unitId"] }
24696
- }
24697
- },
24698
- { $project: { _id: 1, name: 1 } }
24699
- ],
24620
+ localField: "unit",
24621
+ foreignField: "_id",
24622
+ pipeline: [{ $project: { _id: 1, name: 1 } }],
24700
24623
  as: "unit"
24701
24624
  }
24702
24625
  },
@@ -24746,15 +24669,9 @@ function usePersonRepo() {
24746
24669
  {
24747
24670
  $lookup: {
24748
24671
  from: "buildings",
24749
- let: { blockId: "$block" },
24750
- pipeline: [
24751
- {
24752
- $match: {
24753
- $expr: { $eq: ["$_id", "$$blockId"] }
24754
- }
24755
- },
24756
- { $project: { _id: 1, name: 1, block: 1 } }
24757
- ],
24672
+ localField: "block",
24673
+ foreignField: "_id",
24674
+ pipeline: [{ $project: { _id: 1, name: 1, block: 1 } }],
24758
24675
  as: "block"
24759
24676
  }
24760
24677
  },
@@ -24762,15 +24679,9 @@ function usePersonRepo() {
24762
24679
  {
24763
24680
  $lookup: {
24764
24681
  from: "building-levels",
24765
- let: { levelId: "$level" },
24766
- pipeline: [
24767
- {
24768
- $match: {
24769
- $expr: { $eq: ["$_id", "$$levelId"] }
24770
- }
24771
- },
24772
- { $project: { _id: 1, name: 1 } }
24773
- ],
24682
+ localField: "level",
24683
+ foreignField: "_id",
24684
+ pipeline: [{ $project: { _id: 1, name: 1 } }],
24774
24685
  as: "level"
24775
24686
  }
24776
24687
  },
@@ -24778,15 +24689,9 @@ function usePersonRepo() {
24778
24689
  {
24779
24690
  $lookup: {
24780
24691
  from: "building-units",
24781
- let: { unitId: { $toString: "$unit" } },
24782
- pipeline: [
24783
- {
24784
- $match: {
24785
- $expr: { $eq: [{ $toString: "$_id" }, "$$unitId"] }
24786
- }
24787
- },
24788
- { $project: { _id: 1, name: 1 } }
24789
- ],
24692
+ localField: "unit",
24693
+ foreignField: "_id",
24694
+ pipeline: [{ $project: { _id: 1, name: 1 } }],
24790
24695
  as: "unit"
24791
24696
  }
24792
24697
  },
@@ -65375,7 +65280,7 @@ function MFormEntry(value) {
65375
65280
  }
65376
65281
  var residentFormEntry = Joi144.object({
65377
65282
  _id: Joi144.string().hex().optional().allow("", null),
65378
- typeOfForm: Joi144.string().required(),
65283
+ typeOfForm: Joi144.string().optional().allow("", null),
65379
65284
  unitNumber: Joi144.string().optional().allow(null, ""),
65380
65285
  fields: Joi144.object().pattern(
65381
65286
  Joi144.string(),
@@ -65385,7 +65290,7 @@ var residentFormEntry = Joi144.object({
65385
65290
  Joi144.boolean(),
65386
65291
  Joi144.valid(null)
65387
65292
  )
65388
- ).required(),
65293
+ ).optional().allow(null, ""),
65389
65294
  status: Joi144.string().optional().allow("", null),
65390
65295
  org: Joi144.string().hex().optional().allow("", null),
65391
65296
  site: Joi144.string().hex().optional().allow("", null),
@@ -65478,7 +65383,8 @@ function useFormEntryRepo() {
65478
65383
  };
65479
65384
  if (search && search !== "") {
65480
65385
  query.$or = [
65481
- { formType: { $regex: search, $options: "i" } }
65386
+ { typeOfForm: { $regex: search, $options: "i" } },
65387
+ { unitNumber: { $regex: search, $options: "i" } }
65482
65388
  ];
65483
65389
  }
65484
65390
  const cacheKey = makeCacheKey66(
@@ -65761,7 +65667,7 @@ function useFormEntryController() {
65761
65667
  }
65762
65668
  async function updateFormEntryById(req, res, next) {
65763
65669
  try {
65764
- const { error, value } = schemaUpdateFormEntry.validate({
65670
+ const { error, value } = residentFormEntry.validate({
65765
65671
  _id: req.params.id,
65766
65672
  ...req.body
65767
65673
  });