@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/CHANGELOG.md +6 -0
- package/dist/index.d.ts +6 -5
- package/dist/index.js +147 -241
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +147 -241
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -9171,6 +9171,9 @@ function MMember(value) {
|
|
|
9171
9171
|
siteId: import_joi7.default.string().hex().optional().allow("", null),
|
|
9172
9172
|
siteName: import_joi7.default.string().optional().allow("", null),
|
|
9173
9173
|
status: import_joi7.default.string().optional().allow("", null),
|
|
9174
|
+
onboardingRequired: import_joi7.default.boolean().optional(),
|
|
9175
|
+
onboardingCompleted: import_joi7.default.boolean().optional(),
|
|
9176
|
+
onboardingCompletedAt: import_joi7.default.string().optional().allow("", null),
|
|
9174
9177
|
createdAt: import_joi7.default.string().optional().allow("", null),
|
|
9175
9178
|
updatedAt: import_joi7.default.string().optional().allow("", null),
|
|
9176
9179
|
deletedAt: import_joi7.default.string().optional().allow("", null)
|
|
@@ -9218,6 +9221,9 @@ function MMember(value) {
|
|
|
9218
9221
|
siteId: value.siteId ?? "",
|
|
9219
9222
|
siteName: value.siteName ?? "",
|
|
9220
9223
|
status: value.status || "active",
|
|
9224
|
+
onboardingRequired: value.onboardingRequired ?? false,
|
|
9225
|
+
onboardingCompleted: value.onboardingCompleted ?? !value.onboardingRequired,
|
|
9226
|
+
onboardingCompletedAt: value.onboardingCompletedAt ?? "",
|
|
9221
9227
|
createdAt: value.createdAt || (/* @__PURE__ */ new Date()).toISOString(),
|
|
9222
9228
|
updatedAt: "",
|
|
9223
9229
|
deletedAt: ""
|
|
@@ -10068,6 +10074,35 @@ function useMemberRepo() {
|
|
|
10068
10074
|
);
|
|
10069
10075
|
}
|
|
10070
10076
|
}
|
|
10077
|
+
async function completeOnboardingById(_id, session) {
|
|
10078
|
+
try {
|
|
10079
|
+
_id = new import_mongodb11.ObjectId(_id);
|
|
10080
|
+
} catch {
|
|
10081
|
+
throw new import_node_server_utils12.BadRequestError("Invalid member ID format.");
|
|
10082
|
+
}
|
|
10083
|
+
const result = await collection.updateOne(
|
|
10084
|
+
{
|
|
10085
|
+
_id,
|
|
10086
|
+
onboardingRequired: true,
|
|
10087
|
+
onboardingCompleted: false
|
|
10088
|
+
},
|
|
10089
|
+
{
|
|
10090
|
+
$set: {
|
|
10091
|
+
onboardingCompleted: true,
|
|
10092
|
+
onboardingCompletedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10093
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
10094
|
+
}
|
|
10095
|
+
},
|
|
10096
|
+
{ session }
|
|
10097
|
+
);
|
|
10098
|
+
if (!result.matchedCount) {
|
|
10099
|
+
throw new import_node_server_utils12.NotFoundError(
|
|
10100
|
+
"Member not found or onboarding is not required."
|
|
10101
|
+
);
|
|
10102
|
+
}
|
|
10103
|
+
await delNamespace();
|
|
10104
|
+
return "Successfully completed onboarding.";
|
|
10105
|
+
}
|
|
10071
10106
|
return {
|
|
10072
10107
|
createIndex,
|
|
10073
10108
|
createUniqueIndex,
|
|
@@ -10089,7 +10124,8 @@ function useMemberRepo() {
|
|
|
10089
10124
|
updateRoleById,
|
|
10090
10125
|
getByRoles,
|
|
10091
10126
|
updateSiteById,
|
|
10092
|
-
getByUserIdTypeOrg
|
|
10127
|
+
getByUserIdTypeOrg,
|
|
10128
|
+
completeOnboardingById
|
|
10093
10129
|
};
|
|
10094
10130
|
}
|
|
10095
10131
|
|
|
@@ -10540,9 +10576,6 @@ var orgSchema = import_joi8.default.object({
|
|
|
10540
10576
|
busInst: import_joi8.default.string().optional().allow("", null),
|
|
10541
10577
|
status: import_joi8.default.string().optional().allow("", null),
|
|
10542
10578
|
defaultSite: import_joi8.default.string().hex().optional().allow("", null),
|
|
10543
|
-
onboardingRequired: import_joi8.default.boolean().optional(),
|
|
10544
|
-
onboardingCompleted: import_joi8.default.boolean().optional(),
|
|
10545
|
-
onboardingCompletedAt: import_joi8.default.date().optional().allow(null),
|
|
10546
10579
|
terms: import_joi8.default.string().optional().allow("", null),
|
|
10547
10580
|
policies: import_joi8.default.string().optional().allow("", null),
|
|
10548
10581
|
createdAt: import_joi8.default.string().optional().allow("", null),
|
|
@@ -10572,9 +10605,6 @@ function MOrg(value) {
|
|
|
10572
10605
|
busInst: value.busInst,
|
|
10573
10606
|
status: value.status || "active",
|
|
10574
10607
|
defaultSite: value.defaultSite,
|
|
10575
|
-
onboardingRequired: value.onboardingRequired || false,
|
|
10576
|
-
onboardingCompleted: value.onboardingCompleted || false,
|
|
10577
|
-
onboardingCompletedAt: value.onboardingCompletedAt || null,
|
|
10578
10608
|
terms: value.terms ?? "",
|
|
10579
10609
|
policies: value.policies ?? "",
|
|
10580
10610
|
createdAt: value.createdAt || /* @__PURE__ */ new Date(),
|
|
@@ -14183,7 +14213,8 @@ function useMemberService() {
|
|
|
14183
14213
|
updateRoleById: _updateRoleById,
|
|
14184
14214
|
getByRoles,
|
|
14185
14215
|
updateSiteById: _updateSiteById,
|
|
14186
|
-
getAllByUserId: _getAllByUserId
|
|
14216
|
+
getAllByUserId: _getAllByUserId,
|
|
14217
|
+
completeOnboardingById: _completeOnboardingById
|
|
14187
14218
|
} = useMemberRepo();
|
|
14188
14219
|
const { getById: _getVerificationById, updateStatusById } = useVerificationRepo();
|
|
14189
14220
|
const { getUserByEmail, updateDefaultOrgByEmail, getUserById } = useUserRepo();
|
|
@@ -14254,7 +14285,8 @@ function useMemberService() {
|
|
|
14254
14285
|
roleId,
|
|
14255
14286
|
app,
|
|
14256
14287
|
siteId,
|
|
14257
|
-
siteName
|
|
14288
|
+
siteName,
|
|
14289
|
+
onboardingRequired
|
|
14258
14290
|
}) {
|
|
14259
14291
|
const session = import_node_server_utils30.useAtlas.getClient()?.startSession();
|
|
14260
14292
|
session?.startTransaction();
|
|
@@ -14274,7 +14306,10 @@ function useMemberService() {
|
|
|
14274
14306
|
role: roleId,
|
|
14275
14307
|
type: app,
|
|
14276
14308
|
siteId: siteId ?? "",
|
|
14277
|
-
siteName: siteName ?? ""
|
|
14309
|
+
siteName: siteName ?? "",
|
|
14310
|
+
onboardingRequired,
|
|
14311
|
+
onboardingCompleted: false,
|
|
14312
|
+
onboardingCompletedAt: ""
|
|
14278
14313
|
},
|
|
14279
14314
|
session
|
|
14280
14315
|
);
|
|
@@ -14344,12 +14379,19 @@ function useMemberService() {
|
|
|
14344
14379
|
throw error;
|
|
14345
14380
|
}
|
|
14346
14381
|
}
|
|
14382
|
+
async function completeOnboarding(memberId) {
|
|
14383
|
+
await _completeOnboardingById(memberId);
|
|
14384
|
+
return {
|
|
14385
|
+
message: "Member onboarding completed."
|
|
14386
|
+
};
|
|
14387
|
+
}
|
|
14347
14388
|
return {
|
|
14348
14389
|
createMember,
|
|
14349
14390
|
createMemberDirect,
|
|
14350
14391
|
updateRoleById,
|
|
14351
14392
|
updateSiteById,
|
|
14352
|
-
getAllByUser
|
|
14393
|
+
getAllByUser,
|
|
14394
|
+
completeOnboarding
|
|
14353
14395
|
};
|
|
14354
14396
|
}
|
|
14355
14397
|
|
|
@@ -14365,7 +14407,7 @@ function useMemberController() {
|
|
|
14365
14407
|
updateStatusByUserId: _updateStatusByUserId,
|
|
14366
14408
|
updateSiteById: _updateSiteById
|
|
14367
14409
|
} = useMemberRepo();
|
|
14368
|
-
const { createMember: _createMember, createMemberDirect: _createMemberDirect, updateRoleById: _updateRoleById, getAllByUser: _getAllByUser } = useMemberService();
|
|
14410
|
+
const { createMember: _createMember, createMemberDirect: _createMemberDirect, updateRoleById: _updateRoleById, getAllByUser: _getAllByUser, completeOnboarding: _completeOnboarding } = useMemberService();
|
|
14369
14411
|
async function createMember(req, res, next) {
|
|
14370
14412
|
const validation = import_joi15.default.string().hex().required();
|
|
14371
14413
|
const _id = req.params.id;
|
|
@@ -14589,7 +14631,8 @@ function useMemberController() {
|
|
|
14589
14631
|
roleId: import_joi15.default.string().hex().required(),
|
|
14590
14632
|
app: import_joi15.default.string().required(),
|
|
14591
14633
|
siteId: import_joi15.default.string().hex().optional().allow("", null),
|
|
14592
|
-
siteName: import_joi15.default.string().optional().allow("", null)
|
|
14634
|
+
siteName: import_joi15.default.string().optional().allow("", null),
|
|
14635
|
+
onboardingRequired: import_joi15.default.boolean().optional()
|
|
14593
14636
|
});
|
|
14594
14637
|
const { error } = validation.validate(req.body);
|
|
14595
14638
|
if (error) {
|
|
@@ -14597,9 +14640,9 @@ function useMemberController() {
|
|
|
14597
14640
|
next(new import_node_server_utils31.BadRequestError(error.message));
|
|
14598
14641
|
return;
|
|
14599
14642
|
}
|
|
14600
|
-
const { userId, orgId, roleId, app, siteId, siteName } = req.body;
|
|
14643
|
+
const { userId, orgId, roleId, app, siteId, siteName, onboardingRequired } = req.body;
|
|
14601
14644
|
try {
|
|
14602
|
-
const data = await _createMemberDirect({ userId, orgId, roleId, app, siteId, siteName });
|
|
14645
|
+
const data = await _createMemberDirect({ userId, orgId, roleId, app, siteId, siteName, onboardingRequired });
|
|
14603
14646
|
res.status(201).json(data);
|
|
14604
14647
|
return;
|
|
14605
14648
|
} catch (error2) {
|
|
@@ -14673,6 +14716,23 @@ function useMemberController() {
|
|
|
14673
14716
|
return;
|
|
14674
14717
|
}
|
|
14675
14718
|
}
|
|
14719
|
+
async function completeOnboarding(req, res, next) {
|
|
14720
|
+
const validation = import_joi15.default.object({
|
|
14721
|
+
id: import_joi15.default.string().hex().required()
|
|
14722
|
+
});
|
|
14723
|
+
const { error } = validation.validate(req.params);
|
|
14724
|
+
if (error) {
|
|
14725
|
+
return next(new import_node_server_utils31.BadRequestError(error.message));
|
|
14726
|
+
}
|
|
14727
|
+
try {
|
|
14728
|
+
const data = await _completeOnboarding(
|
|
14729
|
+
req.params.id
|
|
14730
|
+
);
|
|
14731
|
+
res.json(data);
|
|
14732
|
+
} catch (error2) {
|
|
14733
|
+
next(error2);
|
|
14734
|
+
}
|
|
14735
|
+
}
|
|
14676
14736
|
return {
|
|
14677
14737
|
createMember,
|
|
14678
14738
|
getByUserId,
|
|
@@ -14684,7 +14744,8 @@ function useMemberController() {
|
|
|
14684
14744
|
updateRoleById,
|
|
14685
14745
|
createMemberDirect,
|
|
14686
14746
|
updateSiteById,
|
|
14687
|
-
getByUserIdTypeOrg
|
|
14747
|
+
getByUserIdTypeOrg,
|
|
14748
|
+
completeOnboarding
|
|
14688
14749
|
};
|
|
14689
14750
|
}
|
|
14690
14751
|
|
|
@@ -15329,7 +15390,7 @@ function useOrgController() {
|
|
|
15329
15390
|
return;
|
|
15330
15391
|
}
|
|
15331
15392
|
try {
|
|
15332
|
-
const _id = await _add(
|
|
15393
|
+
const _id = await _add(req.body);
|
|
15333
15394
|
const data = await _getById(_id);
|
|
15334
15395
|
res.status(201).json({
|
|
15335
15396
|
message: "Successfully created organization.",
|
|
@@ -15498,35 +15559,6 @@ function useOrgController() {
|
|
|
15498
15559
|
next(error);
|
|
15499
15560
|
}
|
|
15500
15561
|
}
|
|
15501
|
-
async function completeOnboarding(req, res, next) {
|
|
15502
|
-
const validation = import_joi18.default.string().hex().required();
|
|
15503
|
-
const id = req.params.id;
|
|
15504
|
-
const { error } = validation.validate(id);
|
|
15505
|
-
if (error) {
|
|
15506
|
-
import_node_server_utils35.logger.log({
|
|
15507
|
-
level: "error",
|
|
15508
|
-
message: error.message
|
|
15509
|
-
});
|
|
15510
|
-
next(new import_node_server_utils35.BadRequestError(error.message));
|
|
15511
|
-
return;
|
|
15512
|
-
}
|
|
15513
|
-
try {
|
|
15514
|
-
await _completeOnboardingById(id);
|
|
15515
|
-
const data = await _getById(id);
|
|
15516
|
-
res.json({
|
|
15517
|
-
message: "Organization onboarding completed successfully",
|
|
15518
|
-
data
|
|
15519
|
-
});
|
|
15520
|
-
return;
|
|
15521
|
-
} catch (error2) {
|
|
15522
|
-
import_node_server_utils35.logger.log({
|
|
15523
|
-
level: "error",
|
|
15524
|
-
message: error2.message
|
|
15525
|
-
});
|
|
15526
|
-
next(error2);
|
|
15527
|
-
return;
|
|
15528
|
-
}
|
|
15529
|
-
}
|
|
15530
15562
|
return {
|
|
15531
15563
|
add,
|
|
15532
15564
|
addOnboardingOrg,
|
|
@@ -15537,8 +15569,7 @@ function useOrgController() {
|
|
|
15537
15569
|
getByEmail,
|
|
15538
15570
|
update,
|
|
15539
15571
|
getOrgsByEmail,
|
|
15540
|
-
getAdminOrgForResident
|
|
15541
|
-
completeOnboarding
|
|
15572
|
+
getAdminOrgForResident
|
|
15542
15573
|
};
|
|
15543
15574
|
}
|
|
15544
15575
|
|
|
@@ -21518,15 +21549,9 @@ function useVisitorTransactionRepo() {
|
|
|
21518
21549
|
{
|
|
21519
21550
|
$lookup: {
|
|
21520
21551
|
from: "buildings",
|
|
21521
|
-
|
|
21522
|
-
|
|
21523
|
-
|
|
21524
|
-
$match: {
|
|
21525
|
-
$expr: { $eq: ["$_id", "$$blockId"] }
|
|
21526
|
-
}
|
|
21527
|
-
},
|
|
21528
|
-
{ $project: { _id: 1, name: 1, block: 1 } }
|
|
21529
|
-
],
|
|
21552
|
+
localField: "block",
|
|
21553
|
+
foreignField: "_id",
|
|
21554
|
+
pipeline: [{ $project: { name: 1, block: 1 } }],
|
|
21530
21555
|
as: "block"
|
|
21531
21556
|
}
|
|
21532
21557
|
},
|
|
@@ -21534,15 +21559,9 @@ function useVisitorTransactionRepo() {
|
|
|
21534
21559
|
{
|
|
21535
21560
|
$lookup: {
|
|
21536
21561
|
from: "building-levels",
|
|
21537
|
-
|
|
21538
|
-
|
|
21539
|
-
|
|
21540
|
-
$match: {
|
|
21541
|
-
$expr: { $eq: ["$_id", "$$levelId"] }
|
|
21542
|
-
}
|
|
21543
|
-
},
|
|
21544
|
-
{ $project: { _id: 1, name: 1 } }
|
|
21545
|
-
],
|
|
21562
|
+
localField: "level",
|
|
21563
|
+
foreignField: "_id",
|
|
21564
|
+
pipeline: [{ $project: { name: 1 } }],
|
|
21546
21565
|
as: "level"
|
|
21547
21566
|
}
|
|
21548
21567
|
},
|
|
@@ -21550,15 +21569,9 @@ function useVisitorTransactionRepo() {
|
|
|
21550
21569
|
{
|
|
21551
21570
|
$lookup: {
|
|
21552
21571
|
from: "building-units",
|
|
21553
|
-
|
|
21554
|
-
|
|
21555
|
-
|
|
21556
|
-
$match: {
|
|
21557
|
-
$expr: { $eq: ["$_id", "$$unitId"] }
|
|
21558
|
-
}
|
|
21559
|
-
},
|
|
21560
|
-
{ $project: { _id: 1, name: 1 } }
|
|
21561
|
-
],
|
|
21572
|
+
localField: "unit",
|
|
21573
|
+
foreignField: "_id",
|
|
21574
|
+
pipeline: [{ $project: { name: 1 } }],
|
|
21562
21575
|
as: "unit"
|
|
21563
21576
|
}
|
|
21564
21577
|
},
|
|
@@ -21612,15 +21625,9 @@ function useVisitorTransactionRepo() {
|
|
|
21612
21625
|
{
|
|
21613
21626
|
$lookup: {
|
|
21614
21627
|
from: "buildings",
|
|
21615
|
-
|
|
21616
|
-
|
|
21617
|
-
|
|
21618
|
-
$match: {
|
|
21619
|
-
$expr: { $eq: [{ $toString: "$_id" }, "$$blockId"] }
|
|
21620
|
-
}
|
|
21621
|
-
},
|
|
21622
|
-
{ $project: { _id: 1, name: 1, block: 1 } }
|
|
21623
|
-
],
|
|
21628
|
+
localField: "block",
|
|
21629
|
+
foreignField: "_id",
|
|
21630
|
+
pipeline: [{ $project: { name: 1, block: 1 } }],
|
|
21624
21631
|
as: "block"
|
|
21625
21632
|
}
|
|
21626
21633
|
},
|
|
@@ -21628,15 +21635,9 @@ function useVisitorTransactionRepo() {
|
|
|
21628
21635
|
{
|
|
21629
21636
|
$lookup: {
|
|
21630
21637
|
from: "building-levels",
|
|
21631
|
-
|
|
21632
|
-
|
|
21633
|
-
|
|
21634
|
-
$match: {
|
|
21635
|
-
$expr: { $eq: [{ $toString: "$_id" }, "$$levelId"] }
|
|
21636
|
-
}
|
|
21637
|
-
},
|
|
21638
|
-
{ $project: { _id: 1, name: 1 } }
|
|
21639
|
-
],
|
|
21638
|
+
localField: "level",
|
|
21639
|
+
foreignField: "_id",
|
|
21640
|
+
pipeline: [{ $project: { name: 1 } }],
|
|
21640
21641
|
as: "level"
|
|
21641
21642
|
}
|
|
21642
21643
|
},
|
|
@@ -21644,15 +21645,9 @@ function useVisitorTransactionRepo() {
|
|
|
21644
21645
|
{
|
|
21645
21646
|
$lookup: {
|
|
21646
21647
|
from: "building-units",
|
|
21647
|
-
|
|
21648
|
-
|
|
21649
|
-
|
|
21650
|
-
$match: {
|
|
21651
|
-
$expr: { $eq: [{ $toString: "$_id" }, "$$unitId"] }
|
|
21652
|
-
}
|
|
21653
|
-
},
|
|
21654
|
-
{ $project: { _id: 1, name: 1 } }
|
|
21655
|
-
],
|
|
21648
|
+
localField: "unit",
|
|
21649
|
+
foreignField: "_id",
|
|
21650
|
+
pipeline: [{ $project: { name: 1 } }],
|
|
21656
21651
|
as: "unit"
|
|
21657
21652
|
}
|
|
21658
21653
|
},
|
|
@@ -22312,15 +22307,9 @@ function useVehicleRepo() {
|
|
|
22312
22307
|
{
|
|
22313
22308
|
$lookup: {
|
|
22314
22309
|
from: "buildings",
|
|
22315
|
-
|
|
22316
|
-
|
|
22317
|
-
|
|
22318
|
-
$match: {
|
|
22319
|
-
$expr: { $eq: ["$_id", "$$blockId"] }
|
|
22320
|
-
}
|
|
22321
|
-
},
|
|
22322
|
-
{ $project: { _id: 1, name: 1, block: 1 } }
|
|
22323
|
-
],
|
|
22310
|
+
localField: "block",
|
|
22311
|
+
foreignField: "_id",
|
|
22312
|
+
pipeline: [{ $project: { name: 1, block: 1 } }],
|
|
22324
22313
|
as: "block"
|
|
22325
22314
|
}
|
|
22326
22315
|
},
|
|
@@ -22328,15 +22317,9 @@ function useVehicleRepo() {
|
|
|
22328
22317
|
{
|
|
22329
22318
|
$lookup: {
|
|
22330
22319
|
from: "building-levels",
|
|
22331
|
-
|
|
22332
|
-
|
|
22333
|
-
|
|
22334
|
-
$match: {
|
|
22335
|
-
$expr: { $eq: ["$_id", "$$levelId"] }
|
|
22336
|
-
}
|
|
22337
|
-
},
|
|
22338
|
-
{ $project: { _id: 1, name: 1 } }
|
|
22339
|
-
],
|
|
22320
|
+
localField: "level",
|
|
22321
|
+
foreignField: "_id",
|
|
22322
|
+
pipeline: [{ $project: { name: 1 } }],
|
|
22340
22323
|
as: "level"
|
|
22341
22324
|
}
|
|
22342
22325
|
},
|
|
@@ -22344,15 +22327,9 @@ function useVehicleRepo() {
|
|
|
22344
22327
|
{
|
|
22345
22328
|
$lookup: {
|
|
22346
22329
|
from: "building-units",
|
|
22347
|
-
|
|
22348
|
-
|
|
22349
|
-
|
|
22350
|
-
$match: {
|
|
22351
|
-
$expr: { $eq: ["$_id", "$$unitId"] }
|
|
22352
|
-
}
|
|
22353
|
-
},
|
|
22354
|
-
{ $project: { _id: 1, name: 1 } }
|
|
22355
|
-
],
|
|
22330
|
+
localField: "unit",
|
|
22331
|
+
foreignField: "_id",
|
|
22332
|
+
pipeline: [{ $project: { name: 1 } }],
|
|
22356
22333
|
as: "unit"
|
|
22357
22334
|
}
|
|
22358
22335
|
},
|
|
@@ -22617,15 +22594,9 @@ function useVehicleRepo() {
|
|
|
22617
22594
|
{
|
|
22618
22595
|
$lookup: {
|
|
22619
22596
|
from: "buildings",
|
|
22620
|
-
|
|
22621
|
-
|
|
22622
|
-
|
|
22623
|
-
$match: {
|
|
22624
|
-
$expr: { $eq: [{ $toString: "$_id" }, "$$blockId"] }
|
|
22625
|
-
}
|
|
22626
|
-
},
|
|
22627
|
-
{ $project: { _id: 1, name: 1, block: 1 } }
|
|
22628
|
-
],
|
|
22597
|
+
localField: "block",
|
|
22598
|
+
foreignField: "_id",
|
|
22599
|
+
pipeline: [{ $project: { name: 1, block: 1 } }],
|
|
22629
22600
|
as: "block"
|
|
22630
22601
|
}
|
|
22631
22602
|
},
|
|
@@ -22633,15 +22604,9 @@ function useVehicleRepo() {
|
|
|
22633
22604
|
{
|
|
22634
22605
|
$lookup: {
|
|
22635
22606
|
from: "building-levels",
|
|
22636
|
-
|
|
22637
|
-
|
|
22638
|
-
|
|
22639
|
-
$match: {
|
|
22640
|
-
$expr: { $eq: [{ $toString: "$_id" }, "$$levelId"] }
|
|
22641
|
-
}
|
|
22642
|
-
},
|
|
22643
|
-
{ $project: { _id: 1, name: 1 } }
|
|
22644
|
-
],
|
|
22607
|
+
localField: "level",
|
|
22608
|
+
foreignField: "_id",
|
|
22609
|
+
pipeline: [{ $project: { name: 1 } }],
|
|
22645
22610
|
as: "level"
|
|
22646
22611
|
}
|
|
22647
22612
|
},
|
|
@@ -22649,15 +22614,9 @@ function useVehicleRepo() {
|
|
|
22649
22614
|
{
|
|
22650
22615
|
$lookup: {
|
|
22651
22616
|
from: "building-units",
|
|
22652
|
-
|
|
22653
|
-
|
|
22654
|
-
|
|
22655
|
-
$match: {
|
|
22656
|
-
$expr: { $eq: [{ $toString: "$_id" }, "$$unitId"] }
|
|
22657
|
-
}
|
|
22658
|
-
},
|
|
22659
|
-
{ $project: { _id: 1, name: 1 } }
|
|
22660
|
-
],
|
|
22617
|
+
localField: "unit",
|
|
22618
|
+
foreignField: "_id",
|
|
22619
|
+
pipeline: [{ $project: { name: 1 } }],
|
|
22661
22620
|
as: "unit"
|
|
22662
22621
|
}
|
|
22663
22622
|
},
|
|
@@ -24622,15 +24581,9 @@ function usePersonRepo() {
|
|
|
24622
24581
|
{
|
|
24623
24582
|
$lookup: {
|
|
24624
24583
|
from: "buildings",
|
|
24625
|
-
|
|
24626
|
-
|
|
24627
|
-
|
|
24628
|
-
$match: {
|
|
24629
|
-
$expr: { $eq: ["$_id", "$$blockId"] }
|
|
24630
|
-
}
|
|
24631
|
-
},
|
|
24632
|
-
{ $project: { _id: 1, name: 1, block: 1 } }
|
|
24633
|
-
],
|
|
24584
|
+
localField: "block",
|
|
24585
|
+
foreignField: "_id",
|
|
24586
|
+
pipeline: [{ $project: { _id: 1, name: 1, block: 1 } }],
|
|
24634
24587
|
as: "block"
|
|
24635
24588
|
}
|
|
24636
24589
|
},
|
|
@@ -24638,15 +24591,9 @@ function usePersonRepo() {
|
|
|
24638
24591
|
{
|
|
24639
24592
|
$lookup: {
|
|
24640
24593
|
from: "building-levels",
|
|
24641
|
-
|
|
24642
|
-
|
|
24643
|
-
|
|
24644
|
-
$match: {
|
|
24645
|
-
$expr: { $eq: ["$_id", "$$levelId"] }
|
|
24646
|
-
}
|
|
24647
|
-
},
|
|
24648
|
-
{ $project: { _id: 1, name: 1 } }
|
|
24649
|
-
],
|
|
24594
|
+
localField: "level",
|
|
24595
|
+
foreignField: "_id",
|
|
24596
|
+
pipeline: [{ $project: { _id: 1, name: 1 } }],
|
|
24650
24597
|
as: "level"
|
|
24651
24598
|
}
|
|
24652
24599
|
},
|
|
@@ -24654,15 +24601,9 @@ function usePersonRepo() {
|
|
|
24654
24601
|
{
|
|
24655
24602
|
$lookup: {
|
|
24656
24603
|
from: "building-units",
|
|
24657
|
-
|
|
24658
|
-
|
|
24659
|
-
|
|
24660
|
-
$match: {
|
|
24661
|
-
$expr: { $eq: [{ $toString: "$_id" }, "$$unitId"] }
|
|
24662
|
-
}
|
|
24663
|
-
},
|
|
24664
|
-
{ $project: { _id: 1, name: 1 } }
|
|
24665
|
-
],
|
|
24604
|
+
localField: "unit",
|
|
24605
|
+
foreignField: "_id",
|
|
24606
|
+
pipeline: [{ $project: { _id: 1, name: 1 } }],
|
|
24666
24607
|
as: "unit"
|
|
24667
24608
|
}
|
|
24668
24609
|
},
|
|
@@ -24869,15 +24810,9 @@ function usePersonRepo() {
|
|
|
24869
24810
|
{
|
|
24870
24811
|
$lookup: {
|
|
24871
24812
|
from: "buildings",
|
|
24872
|
-
|
|
24873
|
-
|
|
24874
|
-
|
|
24875
|
-
$match: {
|
|
24876
|
-
$expr: { $eq: ["$_id", "$$blockId"] }
|
|
24877
|
-
}
|
|
24878
|
-
},
|
|
24879
|
-
{ $project: { _id: 1, name: 1, block: 1 } }
|
|
24880
|
-
],
|
|
24813
|
+
localField: "block",
|
|
24814
|
+
foreignField: "_id",
|
|
24815
|
+
pipeline: [{ $project: { _id: 1, name: 1, block: 1 } }],
|
|
24881
24816
|
as: "block"
|
|
24882
24817
|
}
|
|
24883
24818
|
},
|
|
@@ -24885,15 +24820,9 @@ function usePersonRepo() {
|
|
|
24885
24820
|
{
|
|
24886
24821
|
$lookup: {
|
|
24887
24822
|
from: "building-levels",
|
|
24888
|
-
|
|
24889
|
-
|
|
24890
|
-
|
|
24891
|
-
$match: {
|
|
24892
|
-
$expr: { $eq: ["$_id", "$$levelId"] }
|
|
24893
|
-
}
|
|
24894
|
-
},
|
|
24895
|
-
{ $project: { _id: 1, name: 1 } }
|
|
24896
|
-
],
|
|
24823
|
+
localField: "level",
|
|
24824
|
+
foreignField: "_id",
|
|
24825
|
+
pipeline: [{ $project: { _id: 1, name: 1 } }],
|
|
24897
24826
|
as: "level"
|
|
24898
24827
|
}
|
|
24899
24828
|
},
|
|
@@ -24901,15 +24830,9 @@ function usePersonRepo() {
|
|
|
24901
24830
|
{
|
|
24902
24831
|
$lookup: {
|
|
24903
24832
|
from: "building-units",
|
|
24904
|
-
|
|
24905
|
-
|
|
24906
|
-
|
|
24907
|
-
$match: {
|
|
24908
|
-
$expr: { $eq: [{ $toString: "$_id" }, "$$unitId"] }
|
|
24909
|
-
}
|
|
24910
|
-
},
|
|
24911
|
-
{ $project: { _id: 1, name: 1 } }
|
|
24912
|
-
],
|
|
24833
|
+
localField: "unit",
|
|
24834
|
+
foreignField: "_id",
|
|
24835
|
+
pipeline: [{ $project: { _id: 1, name: 1 } }],
|
|
24913
24836
|
as: "unit"
|
|
24914
24837
|
}
|
|
24915
24838
|
},
|
|
@@ -24959,15 +24882,9 @@ function usePersonRepo() {
|
|
|
24959
24882
|
{
|
|
24960
24883
|
$lookup: {
|
|
24961
24884
|
from: "buildings",
|
|
24962
|
-
|
|
24963
|
-
|
|
24964
|
-
|
|
24965
|
-
$match: {
|
|
24966
|
-
$expr: { $eq: ["$_id", "$$blockId"] }
|
|
24967
|
-
}
|
|
24968
|
-
},
|
|
24969
|
-
{ $project: { _id: 1, name: 1, block: 1 } }
|
|
24970
|
-
],
|
|
24885
|
+
localField: "block",
|
|
24886
|
+
foreignField: "_id",
|
|
24887
|
+
pipeline: [{ $project: { _id: 1, name: 1, block: 1 } }],
|
|
24971
24888
|
as: "block"
|
|
24972
24889
|
}
|
|
24973
24890
|
},
|
|
@@ -24975,15 +24892,9 @@ function usePersonRepo() {
|
|
|
24975
24892
|
{
|
|
24976
24893
|
$lookup: {
|
|
24977
24894
|
from: "building-levels",
|
|
24978
|
-
|
|
24979
|
-
|
|
24980
|
-
|
|
24981
|
-
$match: {
|
|
24982
|
-
$expr: { $eq: ["$_id", "$$levelId"] }
|
|
24983
|
-
}
|
|
24984
|
-
},
|
|
24985
|
-
{ $project: { _id: 1, name: 1 } }
|
|
24986
|
-
],
|
|
24895
|
+
localField: "level",
|
|
24896
|
+
foreignField: "_id",
|
|
24897
|
+
pipeline: [{ $project: { _id: 1, name: 1 } }],
|
|
24987
24898
|
as: "level"
|
|
24988
24899
|
}
|
|
24989
24900
|
},
|
|
@@ -24991,15 +24902,9 @@ function usePersonRepo() {
|
|
|
24991
24902
|
{
|
|
24992
24903
|
$lookup: {
|
|
24993
24904
|
from: "building-units",
|
|
24994
|
-
|
|
24995
|
-
|
|
24996
|
-
|
|
24997
|
-
$match: {
|
|
24998
|
-
$expr: { $eq: [{ $toString: "$_id" }, "$$unitId"] }
|
|
24999
|
-
}
|
|
25000
|
-
},
|
|
25001
|
-
{ $project: { _id: 1, name: 1 } }
|
|
25002
|
-
],
|
|
24905
|
+
localField: "unit",
|
|
24906
|
+
foreignField: "_id",
|
|
24907
|
+
pipeline: [{ $project: { _id: 1, name: 1 } }],
|
|
25003
24908
|
as: "unit"
|
|
25004
24909
|
}
|
|
25005
24910
|
},
|
|
@@ -65082,7 +64987,7 @@ function MFormEntry(value) {
|
|
|
65082
64987
|
}
|
|
65083
64988
|
var residentFormEntry = import_joi144.default.object({
|
|
65084
64989
|
_id: import_joi144.default.string().hex().optional().allow("", null),
|
|
65085
|
-
typeOfForm: import_joi144.default.string().
|
|
64990
|
+
typeOfForm: import_joi144.default.string().optional().allow("", null),
|
|
65086
64991
|
unitNumber: import_joi144.default.string().optional().allow(null, ""),
|
|
65087
64992
|
fields: import_joi144.default.object().pattern(
|
|
65088
64993
|
import_joi144.default.string(),
|
|
@@ -65092,7 +64997,7 @@ var residentFormEntry = import_joi144.default.object({
|
|
|
65092
64997
|
import_joi144.default.boolean(),
|
|
65093
64998
|
import_joi144.default.valid(null)
|
|
65094
64999
|
)
|
|
65095
|
-
).
|
|
65000
|
+
).optional().allow(null, ""),
|
|
65096
65001
|
status: import_joi144.default.string().optional().allow("", null),
|
|
65097
65002
|
org: import_joi144.default.string().hex().optional().allow("", null),
|
|
65098
65003
|
site: import_joi144.default.string().hex().optional().allow("", null),
|
|
@@ -65176,7 +65081,8 @@ function useFormEntryRepo() {
|
|
|
65176
65081
|
};
|
|
65177
65082
|
if (search && search !== "") {
|
|
65178
65083
|
query.$or = [
|
|
65179
|
-
{
|
|
65084
|
+
{ typeOfForm: { $regex: search, $options: "i" } },
|
|
65085
|
+
{ unitNumber: { $regex: search, $options: "i" } }
|
|
65180
65086
|
];
|
|
65181
65087
|
}
|
|
65182
65088
|
const cacheKey = (0, import_node_server_utils249.makeCacheKey)(
|
|
@@ -65459,7 +65365,7 @@ function useFormEntryController() {
|
|
|
65459
65365
|
}
|
|
65460
65366
|
async function updateFormEntryById(req, res, next) {
|
|
65461
65367
|
try {
|
|
65462
|
-
const { error, value } =
|
|
65368
|
+
const { error, value } = residentFormEntry.validate({
|
|
65463
65369
|
_id: req.params.id,
|
|
65464
65370
|
...req.body
|
|
65465
65371
|
});
|