@7365admin1/core 3.2.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 +12 -0
- package/dist/index.d.ts +20 -7
- package/dist/index.js +271 -246
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +270 -246
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
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(
|
|
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
|
-
|
|
21286
|
-
|
|
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
|
-
|
|
21302
|
-
|
|
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
|
-
|
|
21318
|
-
|
|
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
|
-
|
|
21380
|
-
|
|
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
|
-
|
|
21396
|
-
|
|
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
|
-
|
|
21412
|
-
|
|
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
|
-
|
|
22089
|
-
|
|
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
|
-
|
|
22105
|
-
|
|
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
|
-
|
|
22121
|
-
|
|
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
|
-
|
|
22394
|
-
|
|
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
|
-
|
|
22410
|
-
|
|
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
|
-
|
|
22426
|
-
|
|
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
|
-
|
|
24413
|
-
|
|
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
|
-
|
|
24429
|
-
|
|
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
|
-
|
|
24445
|
-
|
|
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
|
-
|
|
24660
|
-
|
|
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
|
-
|
|
24676
|
-
|
|
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
|
-
|
|
24692
|
-
|
|
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
|
-
|
|
24750
|
-
|
|
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
|
-
|
|
24766
|
-
|
|
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
|
-
|
|
24782
|
-
|
|
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
|
},
|
|
@@ -35049,10 +34954,37 @@ function usePersonService() {
|
|
|
35049
34954
|
session?.endSession();
|
|
35050
34955
|
}
|
|
35051
34956
|
}
|
|
34957
|
+
async function suspendResidentById(id) {
|
|
34958
|
+
const session = useAtlas53.getClient()?.startSession();
|
|
34959
|
+
if (!session) {
|
|
34960
|
+
throw new BadRequestError104("Database session not available.");
|
|
34961
|
+
}
|
|
34962
|
+
try {
|
|
34963
|
+
session.startTransaction();
|
|
34964
|
+
const person = await _getByUserId(id.toString());
|
|
34965
|
+
if (!person)
|
|
34966
|
+
throw new NotFoundError23("Person not found.");
|
|
34967
|
+
await _updateById(person._id, { status: "deleted" }, session);
|
|
34968
|
+
if (person.user) {
|
|
34969
|
+
await _updateUserFieldById(
|
|
34970
|
+
{ _id: person.user.toString(), field: "status", value: "suspended" },
|
|
34971
|
+
session
|
|
34972
|
+
);
|
|
34973
|
+
}
|
|
34974
|
+
await session.commitTransaction();
|
|
34975
|
+
return "Resident suspended successfully.";
|
|
34976
|
+
} catch (error) {
|
|
34977
|
+
await session.abortTransaction();
|
|
34978
|
+
throw error;
|
|
34979
|
+
} finally {
|
|
34980
|
+
session.endSession();
|
|
34981
|
+
}
|
|
34982
|
+
}
|
|
35052
34983
|
return {
|
|
35053
34984
|
add,
|
|
35054
34985
|
updateById,
|
|
35055
|
-
reviewResidentPerson
|
|
34986
|
+
reviewResidentPerson,
|
|
34987
|
+
suspendResidentById
|
|
35056
34988
|
};
|
|
35057
34989
|
}
|
|
35058
34990
|
|
|
@@ -35072,7 +35004,8 @@ function usePersonController() {
|
|
|
35072
35004
|
const {
|
|
35073
35005
|
add: _add,
|
|
35074
35006
|
updateById: _updateById,
|
|
35075
|
-
reviewResidentPerson: _reviewResidentPerson
|
|
35007
|
+
reviewResidentPerson: _reviewResidentPerson,
|
|
35008
|
+
suspendResidentById: _suspendResidentById
|
|
35076
35009
|
} = usePersonService();
|
|
35077
35010
|
async function add(req, res, next) {
|
|
35078
35011
|
const payload = { ...req.body };
|
|
@@ -35416,6 +35349,26 @@ function usePersonController() {
|
|
|
35416
35349
|
const result = await _reviewResidentPerson(_id, req.body);
|
|
35417
35350
|
res.status(200).json({ message: result });
|
|
35418
35351
|
return;
|
|
35352
|
+
} catch (error2) {
|
|
35353
|
+
console.log("error", error2.message);
|
|
35354
|
+
console.log("error", error2);
|
|
35355
|
+
logger85.log({ level: "error", message: error2.message });
|
|
35356
|
+
next(error2);
|
|
35357
|
+
return;
|
|
35358
|
+
}
|
|
35359
|
+
}
|
|
35360
|
+
async function suspendResidentById(req, res, next) {
|
|
35361
|
+
const _id = req.params.id;
|
|
35362
|
+
const { error } = Joi60.string().hex().required().validate(_id);
|
|
35363
|
+
if (error) {
|
|
35364
|
+
logger85.log({ level: "error", message: error.message });
|
|
35365
|
+
next(new BadRequestError105(error.message));
|
|
35366
|
+
return;
|
|
35367
|
+
}
|
|
35368
|
+
try {
|
|
35369
|
+
const result = await _suspendResidentById(_id);
|
|
35370
|
+
res.status(200).json({ message: result });
|
|
35371
|
+
return;
|
|
35419
35372
|
} catch (error2) {
|
|
35420
35373
|
logger85.log({ level: "error", message: error2.message });
|
|
35421
35374
|
next(error2);
|
|
@@ -35434,7 +35387,8 @@ function usePersonController() {
|
|
|
35434
35387
|
getPeopleByPlateNumber,
|
|
35435
35388
|
getPeopleByNRIC,
|
|
35436
35389
|
getPersonByUserId,
|
|
35437
|
-
reviewResidentPerson
|
|
35390
|
+
reviewResidentPerson,
|
|
35391
|
+
suspendResidentById
|
|
35438
35392
|
};
|
|
35439
35393
|
}
|
|
35440
35394
|
|
|
@@ -53411,7 +53365,7 @@ function MIncidentReport(value) {
|
|
|
53411
53365
|
approvedByName: value.approvedByName ?? "",
|
|
53412
53366
|
remarks: value.remarks ?? null,
|
|
53413
53367
|
status: value.status ?? "pending",
|
|
53414
|
-
|
|
53368
|
+
platform: value.platform ?? "",
|
|
53415
53369
|
createdAt: value.createdAt ?? /* @__PURE__ */ new Date(),
|
|
53416
53370
|
updatedAt: value.updatedAt,
|
|
53417
53371
|
deletedAt: value.deletedAt
|
|
@@ -65324,6 +65278,26 @@ function MFormEntry(value) {
|
|
|
65324
65278
|
deletedAt: value.deletedAt ?? null
|
|
65325
65279
|
};
|
|
65326
65280
|
}
|
|
65281
|
+
var residentFormEntry = Joi144.object({
|
|
65282
|
+
_id: Joi144.string().hex().optional().allow("", null),
|
|
65283
|
+
typeOfForm: Joi144.string().optional().allow("", null),
|
|
65284
|
+
unitNumber: Joi144.string().optional().allow(null, ""),
|
|
65285
|
+
fields: Joi144.object().pattern(
|
|
65286
|
+
Joi144.string(),
|
|
65287
|
+
Joi144.alternatives().try(
|
|
65288
|
+
Joi144.string(),
|
|
65289
|
+
Joi144.number(),
|
|
65290
|
+
Joi144.boolean(),
|
|
65291
|
+
Joi144.valid(null)
|
|
65292
|
+
)
|
|
65293
|
+
).optional().allow(null, ""),
|
|
65294
|
+
status: Joi144.string().optional().allow("", null),
|
|
65295
|
+
org: Joi144.string().hex().optional().allow("", null),
|
|
65296
|
+
site: Joi144.string().hex().optional().allow("", null),
|
|
65297
|
+
createdAt: Joi144.date().optional().allow("", null),
|
|
65298
|
+
updatedAt: Joi144.date().optional().allow("", null),
|
|
65299
|
+
deletedAt: Joi144.date().optional().allow("", null)
|
|
65300
|
+
});
|
|
65327
65301
|
|
|
65328
65302
|
// src/repositories/online-forms-v2.repository.ts
|
|
65329
65303
|
import {
|
|
@@ -65409,7 +65383,8 @@ function useFormEntryRepo() {
|
|
|
65409
65383
|
};
|
|
65410
65384
|
if (search && search !== "") {
|
|
65411
65385
|
query.$or = [
|
|
65412
|
-
{
|
|
65386
|
+
{ typeOfForm: { $regex: search, $options: "i" } },
|
|
65387
|
+
{ unitNumber: { $regex: search, $options: "i" } }
|
|
65413
65388
|
];
|
|
65414
65389
|
}
|
|
65415
65390
|
const cacheKey = makeCacheKey66(
|
|
@@ -65531,13 +65506,38 @@ function useFormEntryRepo() {
|
|
|
65531
65506
|
throw new Error(error.message);
|
|
65532
65507
|
}
|
|
65533
65508
|
}
|
|
65509
|
+
async function addResidentForm(value, session) {
|
|
65510
|
+
try {
|
|
65511
|
+
value.site = new ObjectId146(value.site);
|
|
65512
|
+
value.org = new ObjectId146(value.org);
|
|
65513
|
+
const res = await collection.insertOne(value, { session });
|
|
65514
|
+
delNamespace().then(() => {
|
|
65515
|
+
logger195.info(
|
|
65516
|
+
`Cache cleared for namespace: ${online_forms_namespace_collection}`
|
|
65517
|
+
);
|
|
65518
|
+
}).catch((err) => {
|
|
65519
|
+
logger195.error(
|
|
65520
|
+
`Failed to clear cache for namespace: ${online_forms_namespace_collection}`,
|
|
65521
|
+
err
|
|
65522
|
+
);
|
|
65523
|
+
});
|
|
65524
|
+
return res.insertedId;
|
|
65525
|
+
} catch (error) {
|
|
65526
|
+
const isDuplicated = error.message.includes("duplicate");
|
|
65527
|
+
if (isDuplicated) {
|
|
65528
|
+
throw new BadRequestError223("Online Form already exists.");
|
|
65529
|
+
}
|
|
65530
|
+
throw error;
|
|
65531
|
+
}
|
|
65532
|
+
}
|
|
65534
65533
|
return {
|
|
65535
65534
|
add,
|
|
65536
65535
|
getAll,
|
|
65537
65536
|
getFormEntryById,
|
|
65538
65537
|
updateFormEntryById,
|
|
65539
65538
|
createTextIndex,
|
|
65540
|
-
deleteOnlineFormById
|
|
65539
|
+
deleteOnlineFormById,
|
|
65540
|
+
addResidentForm
|
|
65541
65541
|
};
|
|
65542
65542
|
}
|
|
65543
65543
|
|
|
@@ -65552,7 +65552,8 @@ function useFormEntryController() {
|
|
|
65552
65552
|
getAll: _getAll,
|
|
65553
65553
|
getFormEntryById: _getFormEntryById,
|
|
65554
65554
|
updateFormEntryById: _updateFormEntryById,
|
|
65555
|
-
deleteOnlineFormById: _deleteOnlineFormById
|
|
65555
|
+
deleteOnlineFormById: _deleteOnlineFormById,
|
|
65556
|
+
addResidentForm: _addResidentForm
|
|
65556
65557
|
} = useFormEntryRepo();
|
|
65557
65558
|
function toCamelCase(str) {
|
|
65558
65559
|
return str.replace(/\s(.)/g, (_, char) => char.toUpperCase()).replace(/\s+/g, "").replace(/^(.)/, (_, char) => char.toLowerCase());
|
|
@@ -65666,7 +65667,7 @@ function useFormEntryController() {
|
|
|
65666
65667
|
}
|
|
65667
65668
|
async function updateFormEntryById(req, res, next) {
|
|
65668
65669
|
try {
|
|
65669
|
-
const { error, value } =
|
|
65670
|
+
const { error, value } = residentFormEntry.validate({
|
|
65670
65671
|
_id: req.params.id,
|
|
65671
65672
|
...req.body
|
|
65672
65673
|
});
|
|
@@ -65731,13 +65732,35 @@ function useFormEntryController() {
|
|
|
65731
65732
|
return;
|
|
65732
65733
|
}
|
|
65733
65734
|
}
|
|
65735
|
+
async function residentFormSubmission(req, res, next) {
|
|
65736
|
+
const payload = { ...req.body };
|
|
65737
|
+
const { error } = residentFormEntry.validate(payload, {
|
|
65738
|
+
abortEarly: false
|
|
65739
|
+
});
|
|
65740
|
+
if (error) {
|
|
65741
|
+
const messages = error.details.map((d) => d.message).join(", ");
|
|
65742
|
+
logger196.log({ level: "error", message: messages });
|
|
65743
|
+
next(new BadRequestError224(messages));
|
|
65744
|
+
return;
|
|
65745
|
+
}
|
|
65746
|
+
try {
|
|
65747
|
+
const data = await _addResidentForm(payload);
|
|
65748
|
+
res.status(201).json({ message: data });
|
|
65749
|
+
return;
|
|
65750
|
+
} catch (error2) {
|
|
65751
|
+
logger196.log({ level: "error", message: error2.message });
|
|
65752
|
+
next(error2);
|
|
65753
|
+
return;
|
|
65754
|
+
}
|
|
65755
|
+
}
|
|
65734
65756
|
return {
|
|
65735
65757
|
add,
|
|
65736
65758
|
uploadFormEntrys,
|
|
65737
65759
|
getAll,
|
|
65738
65760
|
getFormEntryById,
|
|
65739
65761
|
updateFormEntryById,
|
|
65740
|
-
deleteFormEntryById
|
|
65762
|
+
deleteFormEntryById,
|
|
65763
|
+
residentFormSubmission
|
|
65741
65764
|
};
|
|
65742
65765
|
}
|
|
65743
65766
|
|
|
@@ -66136,6 +66159,7 @@ export {
|
|
|
66136
66159
|
poolDashboardCollection,
|
|
66137
66160
|
promoCodeSchema,
|
|
66138
66161
|
remarksSchema,
|
|
66162
|
+
residentFormEntry,
|
|
66139
66163
|
robotSchema,
|
|
66140
66164
|
schema,
|
|
66141
66165
|
schemaApprovedBy,
|