@7365admin1/core 2.47.0 → 2.48.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 +42 -11
- package/dist/index.js +234 -32
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +234 -32
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -173,13 +173,13 @@ declare function useUserController(): {
|
|
|
173
173
|
|
|
174
174
|
declare function useUserService(): {
|
|
175
175
|
createDefaultUser: () => Promise<void>;
|
|
176
|
-
createUserBySignUp: ({ id, name, password
|
|
176
|
+
createUserBySignUp: ({ id, name, password }?: {
|
|
177
177
|
id?: string | undefined;
|
|
178
178
|
name?: string | undefined;
|
|
179
179
|
password?: string | undefined;
|
|
180
180
|
}) => Promise<bson.ObjectId>;
|
|
181
181
|
resetPassword: (id: string, newPassword: string, passwordConfirmation: string) => Promise<string>;
|
|
182
|
-
updateUserProfile: ({ file, user, previousProfile
|
|
182
|
+
updateUserProfile: ({ file, user, previousProfile }: {
|
|
183
183
|
file: Express.Multer.File;
|
|
184
184
|
user: string;
|
|
185
185
|
previousProfile?: string | undefined;
|
|
@@ -397,7 +397,7 @@ type TKeyValuePair<K extends string | number | symbol = string, V = any> = {
|
|
|
397
397
|
};
|
|
398
398
|
|
|
399
399
|
declare function useVerificationService(): {
|
|
400
|
-
createUserInvite: ({ email, metadata
|
|
400
|
+
createUserInvite: ({ email, metadata }: {
|
|
401
401
|
email: string;
|
|
402
402
|
metadata: TKeyValuePair;
|
|
403
403
|
}) => Promise<bson.ObjectId>;
|
|
@@ -412,11 +412,15 @@ declare function useVerificationService(): {
|
|
|
412
412
|
verify: (id: string) => Promise<TVerification>;
|
|
413
413
|
cancelUserInvitation: (id: string) => Promise<void>;
|
|
414
414
|
updateStatusById: (_id: string, status: string) => Promise<string>;
|
|
415
|
-
signUp: ({ email, metadata
|
|
415
|
+
signUp: ({ email, metadata }: {
|
|
416
416
|
email: string;
|
|
417
417
|
metadata: TKeyValuePair;
|
|
418
418
|
}) => Promise<bson.ObjectId>;
|
|
419
419
|
checkExpiredInvitation: () => Promise<string>;
|
|
420
|
+
createSimpleUserInvite: ({ email, metadata }: {
|
|
421
|
+
email: string;
|
|
422
|
+
metadata: TKeyValuePair;
|
|
423
|
+
}) => Promise<bson.ObjectId>;
|
|
420
424
|
};
|
|
421
425
|
|
|
422
426
|
declare function useVerificationController(): {
|
|
@@ -426,6 +430,7 @@ declare function useVerificationController(): {
|
|
|
426
430
|
createForgetPassword: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
427
431
|
verify: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
428
432
|
cancelUserInvitation: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
433
|
+
createSimpleUserInvite: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
429
434
|
};
|
|
430
435
|
|
|
431
436
|
type TFile = {
|
|
@@ -6054,13 +6059,6 @@ declare function useHrmLabsAttendanceSrvc(): {
|
|
|
6054
6059
|
pages?: undefined;
|
|
6055
6060
|
pageRange?: undefined;
|
|
6056
6061
|
count?: undefined;
|
|
6057
|
-
} | {
|
|
6058
|
-
success: boolean;
|
|
6059
|
-
message: string;
|
|
6060
|
-
items: never[];
|
|
6061
|
-
pages: number;
|
|
6062
|
-
pageRange: string;
|
|
6063
|
-
count: {};
|
|
6064
6062
|
} | {
|
|
6065
6063
|
items: any[];
|
|
6066
6064
|
pages: number;
|
|
@@ -6068,6 +6066,13 @@ declare function useHrmLabsAttendanceSrvc(): {
|
|
|
6068
6066
|
success?: undefined;
|
|
6069
6067
|
message?: undefined;
|
|
6070
6068
|
count?: undefined;
|
|
6069
|
+
} | {
|
|
6070
|
+
success: boolean;
|
|
6071
|
+
message: any;
|
|
6072
|
+
items: never[];
|
|
6073
|
+
pages: number;
|
|
6074
|
+
pageRange: string;
|
|
6075
|
+
count: {};
|
|
6071
6076
|
}>;
|
|
6072
6077
|
getAttendanceDataCount: (payload: any) => Promise<{
|
|
6073
6078
|
success: boolean;
|
|
@@ -6090,6 +6095,10 @@ declare function useHrmLabsAttendanceSrvc(): {
|
|
|
6090
6095
|
};
|
|
6091
6096
|
success?: undefined;
|
|
6092
6097
|
message?: undefined;
|
|
6098
|
+
} | {
|
|
6099
|
+
success: boolean;
|
|
6100
|
+
message: any;
|
|
6101
|
+
totalCount: null;
|
|
6093
6102
|
}>;
|
|
6094
6103
|
getAllAttendance: (payload: any) => Promise<{
|
|
6095
6104
|
success: boolean;
|
|
@@ -6161,6 +6170,14 @@ declare function useHrmLabsAttendanceSrvc(): {
|
|
|
6161
6170
|
success?: undefined;
|
|
6162
6171
|
message?: undefined;
|
|
6163
6172
|
count?: undefined;
|
|
6173
|
+
} | {
|
|
6174
|
+
success: boolean;
|
|
6175
|
+
message: any;
|
|
6176
|
+
items: never[];
|
|
6177
|
+
count: {};
|
|
6178
|
+
countPerJobTitle: {};
|
|
6179
|
+
totalCount: null;
|
|
6180
|
+
countPerStatus: {};
|
|
6164
6181
|
}>;
|
|
6165
6182
|
getChartAttendanceData: (payload: any) => Promise<{
|
|
6166
6183
|
success: boolean;
|
|
@@ -6192,6 +6209,14 @@ declare function useHrmLabsAttendanceSrvc(): {
|
|
|
6192
6209
|
pages?: undefined;
|
|
6193
6210
|
pageRange?: undefined;
|
|
6194
6211
|
count?: undefined;
|
|
6212
|
+
} | {
|
|
6213
|
+
success: boolean;
|
|
6214
|
+
message: any;
|
|
6215
|
+
chartCount: null;
|
|
6216
|
+
items?: undefined;
|
|
6217
|
+
pages?: undefined;
|
|
6218
|
+
pageRange?: undefined;
|
|
6219
|
+
count?: undefined;
|
|
6195
6220
|
}>;
|
|
6196
6221
|
};
|
|
6197
6222
|
|
|
@@ -6477,6 +6502,7 @@ declare function useVerificationRepoV2(): {
|
|
|
6477
6502
|
email?: string | undefined;
|
|
6478
6503
|
}) => Promise<{}>;
|
|
6479
6504
|
updateStatusById: (_id: string | ObjectId, status: string, session?: ClientSession) => Promise<mongodb.UpdateResult<bson.Document>>;
|
|
6505
|
+
countPendingOrgInvites: (orgId: string | ObjectId) => Promise<number>;
|
|
6480
6506
|
};
|
|
6481
6507
|
|
|
6482
6508
|
declare function useVerificationServiceV2(): {
|
|
@@ -6498,6 +6524,10 @@ declare function useVerificationServiceV2(): {
|
|
|
6498
6524
|
email: string;
|
|
6499
6525
|
metadata: TVerificationMetadataV2;
|
|
6500
6526
|
}) => Promise<bson.ObjectId>;
|
|
6527
|
+
createOrganizationInvite: ({ email, metadata, }: {
|
|
6528
|
+
email: string;
|
|
6529
|
+
metadata: TVerificationMetadataV2;
|
|
6530
|
+
}) => Promise<bson.ObjectId>;
|
|
6501
6531
|
createServiceProviderInvite: ({ email, orgId, siteId, siteName, }: {
|
|
6502
6532
|
email: string;
|
|
6503
6533
|
orgId: string;
|
|
@@ -6511,6 +6541,7 @@ declare function useVerificationServiceV2(): {
|
|
|
6511
6541
|
declare function useVerificationControllerV2(): {
|
|
6512
6542
|
verify: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
6513
6543
|
createUserInvite: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
6544
|
+
createOrganizationInvite: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
6514
6545
|
createServiceProviderInvite: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
6515
6546
|
createForgetPassword: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
6516
6547
|
getVerifications: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
package/dist/index.js
CHANGED
|
@@ -3155,6 +3155,7 @@ var APP_POOL_MAINTENANCE = process.env.APP_POOL_MAINTENANCE ?? "http://localhost
|
|
|
3155
3155
|
var ENCRYPTION_KEY = process.env.ENCRYPTION_KEY ?? "";
|
|
3156
3156
|
var DOMAIN = process.env.DOMAIN ?? "localhost";
|
|
3157
3157
|
var OPEN_AI_API_KEY = process.env.OPEN_AI_API_KEY;
|
|
3158
|
+
var STORAGE_API = process.env.STORAGE_API;
|
|
3158
3159
|
|
|
3159
3160
|
// src/services/auth.service.ts
|
|
3160
3161
|
var import_jsonwebtoken = __toESM(require("jsonwebtoken"));
|
|
@@ -5502,6 +5503,39 @@ function useVerificationRepoV2() {
|
|
|
5502
5503
|
throw new import_node_server_utils20.InternalServerError("Error updating verification status.");
|
|
5503
5504
|
}
|
|
5504
5505
|
}
|
|
5506
|
+
async function countPendingOrgInvites(orgId) {
|
|
5507
|
+
try {
|
|
5508
|
+
orgId = new import_mongodb18.ObjectId(orgId);
|
|
5509
|
+
} catch (error) {
|
|
5510
|
+
throw new import_node_server_utils20.BadRequestError("Invalid organization ID format.");
|
|
5511
|
+
}
|
|
5512
|
+
const query = {
|
|
5513
|
+
status: "pending" /* PENDING */,
|
|
5514
|
+
type: { $in: ["user-invite", "member-invite"] },
|
|
5515
|
+
"metadata.org": orgId
|
|
5516
|
+
};
|
|
5517
|
+
const cacheKey = (0, import_node_server_utils20.makeCacheKey)(namespace_collection, {
|
|
5518
|
+
status: "pending" /* PENDING */,
|
|
5519
|
+
type: JSON.stringify(["user-invite", "member-invite"]),
|
|
5520
|
+
org: orgId.toString()
|
|
5521
|
+
});
|
|
5522
|
+
const cachedData = await getCache(cacheKey);
|
|
5523
|
+
if (typeof cachedData === "number") {
|
|
5524
|
+
import_node_server_utils20.logger.info(`Cache hit for key: ${cacheKey}`);
|
|
5525
|
+
return cachedData;
|
|
5526
|
+
}
|
|
5527
|
+
try {
|
|
5528
|
+
const count = await collection.countDocuments(query);
|
|
5529
|
+
setCache(cacheKey, count, 15 * 60).then(() => {
|
|
5530
|
+
import_node_server_utils20.logger.info(`Cache set for key: ${cacheKey}`);
|
|
5531
|
+
}).catch((err) => {
|
|
5532
|
+
import_node_server_utils20.logger.error(`Failed to set cache for key: ${cacheKey}`, err);
|
|
5533
|
+
});
|
|
5534
|
+
return count;
|
|
5535
|
+
} catch (error) {
|
|
5536
|
+
throw new import_node_server_utils20.InternalServerError("Failed to count pending invitations.");
|
|
5537
|
+
}
|
|
5538
|
+
}
|
|
5505
5539
|
return {
|
|
5506
5540
|
createIndex,
|
|
5507
5541
|
createTextIndex,
|
|
@@ -5510,7 +5544,8 @@ function useVerificationRepoV2() {
|
|
|
5510
5544
|
getByVerificationCode,
|
|
5511
5545
|
getVerificationById,
|
|
5512
5546
|
getVerifications,
|
|
5513
|
-
updateStatusById
|
|
5547
|
+
updateStatusById,
|
|
5548
|
+
countPendingOrgInvites
|
|
5514
5549
|
};
|
|
5515
5550
|
}
|
|
5516
5551
|
|
|
@@ -5588,6 +5623,46 @@ function useVerificationService() {
|
|
|
5588
5623
|
throw error;
|
|
5589
5624
|
}
|
|
5590
5625
|
}
|
|
5626
|
+
async function createSimpleUserInvite({
|
|
5627
|
+
email,
|
|
5628
|
+
metadata
|
|
5629
|
+
}) {
|
|
5630
|
+
const type = "user-invite";
|
|
5631
|
+
const value = {
|
|
5632
|
+
type,
|
|
5633
|
+
email,
|
|
5634
|
+
metadata,
|
|
5635
|
+
expireAt: new Date(
|
|
5636
|
+
(/* @__PURE__ */ new Date()).getTime() + 72 * 60 * 60 * 1e3
|
|
5637
|
+
).toISOString(),
|
|
5638
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
5639
|
+
};
|
|
5640
|
+
if (value.metadata?.org) {
|
|
5641
|
+
await getOrgById(value.metadata?.org);
|
|
5642
|
+
}
|
|
5643
|
+
if (value.metadata?.siteId) {
|
|
5644
|
+
await getSiteById(value.metadata?.siteId);
|
|
5645
|
+
}
|
|
5646
|
+
const res = await add(value);
|
|
5647
|
+
const dir = __dirname;
|
|
5648
|
+
const filePath = (0, import_node_server_utils21.getDirectory)(dir, "./public/handlebars/user-invite");
|
|
5649
|
+
const link = `${APP_MAIN}/verify/invitation/${res}`;
|
|
5650
|
+
const emailContent = (0, import_node_server_utils21.compileHandlebar)({
|
|
5651
|
+
context: {
|
|
5652
|
+
email,
|
|
5653
|
+
validity: VERIFICATION_USER_INVITE_DURATION,
|
|
5654
|
+
link
|
|
5655
|
+
},
|
|
5656
|
+
filePath
|
|
5657
|
+
});
|
|
5658
|
+
mailer.sendMail({
|
|
5659
|
+
to: email,
|
|
5660
|
+
subject: "User Invite",
|
|
5661
|
+
html: emailContent,
|
|
5662
|
+
sender: "iService365"
|
|
5663
|
+
});
|
|
5664
|
+
return res;
|
|
5665
|
+
}
|
|
5591
5666
|
const {
|
|
5592
5667
|
add: _add,
|
|
5593
5668
|
updateVerificationStatusById: _updateVerificationStatusById,
|
|
@@ -5881,7 +5956,8 @@ function useVerificationService() {
|
|
|
5881
5956
|
cancelUserInvitation,
|
|
5882
5957
|
updateStatusById,
|
|
5883
5958
|
signUp,
|
|
5884
|
-
checkExpiredInvitation
|
|
5959
|
+
checkExpiredInvitation,
|
|
5960
|
+
createSimpleUserInvite
|
|
5885
5961
|
};
|
|
5886
5962
|
}
|
|
5887
5963
|
|
|
@@ -7102,7 +7178,16 @@ function useUserController() {
|
|
|
7102
7178
|
async function updateUserFieldById(req, res, next) {
|
|
7103
7179
|
const validation = import_joi13.default.object({
|
|
7104
7180
|
_id: import_joi13.default.string().hex().required(),
|
|
7105
|
-
field: import_joi13.default.string().valid(
|
|
7181
|
+
field: import_joi13.default.string().valid(
|
|
7182
|
+
"name",
|
|
7183
|
+
"email",
|
|
7184
|
+
"contact",
|
|
7185
|
+
"nric",
|
|
7186
|
+
"dateOfBirth",
|
|
7187
|
+
"profile",
|
|
7188
|
+
"gender",
|
|
7189
|
+
"defaultOrg"
|
|
7190
|
+
).required(),
|
|
7106
7191
|
value: import_joi13.default.when("field", {
|
|
7107
7192
|
switch: [
|
|
7108
7193
|
{ is: "email", then: import_joi13.default.string().email().required() },
|
|
@@ -7706,6 +7791,7 @@ var import_joi16 = __toESM(require("joi"));
|
|
|
7706
7791
|
function useVerificationController() {
|
|
7707
7792
|
const {
|
|
7708
7793
|
createUserInvite: _createUserInvite,
|
|
7794
|
+
createSimpleUserInvite: _createSimpleUserInvite,
|
|
7709
7795
|
createServiceProviderInvite: _createServiceProviderInvite,
|
|
7710
7796
|
createForgetPassword: _createForgetPassword,
|
|
7711
7797
|
verify: _verify,
|
|
@@ -7756,6 +7842,58 @@ function useVerificationController() {
|
|
|
7756
7842
|
return;
|
|
7757
7843
|
}
|
|
7758
7844
|
}
|
|
7845
|
+
async function createSimpleUserInvite(req, res, next) {
|
|
7846
|
+
const payload = { ...req.body };
|
|
7847
|
+
const validation = import_joi16.default.object({
|
|
7848
|
+
email: import_joi16.default.string().email().required(),
|
|
7849
|
+
app: import_joi16.default.string().optional().allow("", null),
|
|
7850
|
+
role: import_joi16.default.string().hex().optional().allow("", null),
|
|
7851
|
+
name: import_joi16.default.string().optional().allow("", null),
|
|
7852
|
+
org: import_joi16.default.string().hex().optional().allow("", null),
|
|
7853
|
+
siteId: import_joi16.default.string().hex().optional().allow("", null),
|
|
7854
|
+
siteName: import_joi16.default.string().optional().allow("", null)
|
|
7855
|
+
});
|
|
7856
|
+
const { error } = validation.validate(payload);
|
|
7857
|
+
if (error) {
|
|
7858
|
+
import_node_server_utils32.logger.log({
|
|
7859
|
+
level: "error",
|
|
7860
|
+
message: `${error.message}`
|
|
7861
|
+
});
|
|
7862
|
+
next(new import_node_server_utils32.BadRequestError(error.message));
|
|
7863
|
+
return;
|
|
7864
|
+
}
|
|
7865
|
+
const email = req.body.email ?? "";
|
|
7866
|
+
const app = req.body.app ?? "";
|
|
7867
|
+
const role = req.body.role ?? "";
|
|
7868
|
+
const name = req.body.name ?? "";
|
|
7869
|
+
const org = req.body.org ?? "";
|
|
7870
|
+
const siteId = req.body.siteId ?? "";
|
|
7871
|
+
const siteName = req.body.siteName ?? "";
|
|
7872
|
+
try {
|
|
7873
|
+
await _createSimpleUserInvite({
|
|
7874
|
+
email,
|
|
7875
|
+
metadata: {
|
|
7876
|
+
app,
|
|
7877
|
+
role,
|
|
7878
|
+
name,
|
|
7879
|
+
org,
|
|
7880
|
+
siteId,
|
|
7881
|
+
siteName
|
|
7882
|
+
}
|
|
7883
|
+
});
|
|
7884
|
+
res.status(201).json({
|
|
7885
|
+
message: "Successfully invited user."
|
|
7886
|
+
});
|
|
7887
|
+
return;
|
|
7888
|
+
} catch (error2) {
|
|
7889
|
+
import_node_server_utils32.logger.log({
|
|
7890
|
+
level: "error",
|
|
7891
|
+
message: `${error2.message}`
|
|
7892
|
+
});
|
|
7893
|
+
next(error2);
|
|
7894
|
+
return;
|
|
7895
|
+
}
|
|
7896
|
+
}
|
|
7759
7897
|
async function createServiceProviderInvite(req, res, next) {
|
|
7760
7898
|
const payload = req.body;
|
|
7761
7899
|
const validation = import_joi16.default.object({
|
|
@@ -7897,7 +8035,8 @@ function useVerificationController() {
|
|
|
7897
8035
|
createServiceProviderInvite,
|
|
7898
8036
|
createForgetPassword,
|
|
7899
8037
|
verify,
|
|
7900
|
-
cancelUserInvitation
|
|
8038
|
+
cancelUserInvitation,
|
|
8039
|
+
createSimpleUserInvite
|
|
7901
8040
|
};
|
|
7902
8041
|
}
|
|
7903
8042
|
|
|
@@ -19701,7 +19840,7 @@ function useVehicleController() {
|
|
|
19701
19840
|
next(new import_node_server_utils87.BadRequestError("Spreadsheet file is required."));
|
|
19702
19841
|
return;
|
|
19703
19842
|
}
|
|
19704
|
-
const { originalname, path:
|
|
19843
|
+
const { originalname, path: path4 } = req.file;
|
|
19705
19844
|
const lowerName = originalname.toLowerCase();
|
|
19706
19845
|
const rowSchema = import_joi46.default.object({
|
|
19707
19846
|
fullName: import_joi46.default.string().trim().required(),
|
|
@@ -19740,7 +19879,7 @@ function useVehicleController() {
|
|
|
19740
19879
|
let rows = [];
|
|
19741
19880
|
if (lowerName.endsWith(".xlsx") || lowerName.endsWith(".xls")) {
|
|
19742
19881
|
const workbook = new import_exceljs.default.Workbook();
|
|
19743
|
-
await workbook.xlsx.readFile(
|
|
19882
|
+
await workbook.xlsx.readFile(path4);
|
|
19744
19883
|
const worksheet = workbook.worksheets[0];
|
|
19745
19884
|
if (!worksheet) {
|
|
19746
19885
|
next(
|
|
@@ -19766,7 +19905,7 @@ function useVehicleController() {
|
|
|
19766
19905
|
} else if (lowerName.endsWith(".csv")) {
|
|
19767
19906
|
rows = await new Promise((resolve, reject) => {
|
|
19768
19907
|
const parsed = [];
|
|
19769
|
-
import_fs2.default.createReadStream(
|
|
19908
|
+
import_fs2.default.createReadStream(path4).pipe((0, import_csv_parser.default)()).on("data", (row) => parsed.push(row)).on("end", () => resolve(parsed)).on("error", reject);
|
|
19770
19909
|
});
|
|
19771
19910
|
} else {
|
|
19772
19911
|
next(
|
|
@@ -19805,7 +19944,7 @@ function useVehicleController() {
|
|
|
19805
19944
|
validationErrors: invalidRows,
|
|
19806
19945
|
data
|
|
19807
19946
|
});
|
|
19808
|
-
import_fs2.default.unlink(
|
|
19947
|
+
import_fs2.default.unlink(path4, () => {
|
|
19809
19948
|
});
|
|
19810
19949
|
} catch (error) {
|
|
19811
19950
|
import_node_server_utils87.logger.log({ level: "error", message: error.message });
|
|
@@ -24198,7 +24337,6 @@ var import_node_server_utils108 = require("@7365admin1/node-server-utils");
|
|
|
24198
24337
|
|
|
24199
24338
|
// src/services/person.service.ts
|
|
24200
24339
|
var import_node_server_utils107 = require("@7365admin1/node-server-utils");
|
|
24201
|
-
var import_path = __toESM(require("path"));
|
|
24202
24340
|
function usePersonService() {
|
|
24203
24341
|
const MailerConfig = {
|
|
24204
24342
|
host: MAILER_TRANSPORT_HOST,
|
|
@@ -24413,13 +24551,8 @@ function usePersonService() {
|
|
|
24413
24551
|
value.status = "active";
|
|
24414
24552
|
}
|
|
24415
24553
|
await _reviewResidentPerson(id, value, session);
|
|
24416
|
-
const logoPath =
|
|
24417
|
-
|
|
24418
|
-
"public",
|
|
24419
|
-
"images",
|
|
24420
|
-
"seven-365.svg"
|
|
24421
|
-
);
|
|
24422
|
-
const statusIconPath = import_path.default.join(__dirname, "public", "icons");
|
|
24554
|
+
const logoPath = `${STORAGE_API}/seven-365.svg`;
|
|
24555
|
+
const statusIconPath = STORAGE_API;
|
|
24423
24556
|
let title = "";
|
|
24424
24557
|
let message2 = "";
|
|
24425
24558
|
let hideLogin = true;
|
|
@@ -31900,9 +32033,8 @@ function useEventManagementController() {
|
|
|
31900
32033
|
}
|
|
31901
32034
|
}
|
|
31902
32035
|
async function updateEventManagementById(req, res, next) {
|
|
31903
|
-
const
|
|
31904
|
-
const
|
|
31905
|
-
const { error } = schemaUpdateEventManagement.validate(payload, {
|
|
32036
|
+
const payload = { _id: req.params.id, ...req.body };
|
|
32037
|
+
const { error, value } = schemaUpdateEventManagement.validate(payload, {
|
|
31906
32038
|
abortEarly: false
|
|
31907
32039
|
});
|
|
31908
32040
|
if (error) {
|
|
@@ -31911,8 +32043,9 @@ function useEventManagementController() {
|
|
|
31911
32043
|
next(new import_node_server_utils148.BadRequestError(messages));
|
|
31912
32044
|
return;
|
|
31913
32045
|
}
|
|
32046
|
+
const { _id, ...rest } = value;
|
|
31914
32047
|
try {
|
|
31915
|
-
const result = await _updateEventManagementById(_id,
|
|
32048
|
+
const result = await _updateEventManagementById(_id, rest);
|
|
31916
32049
|
res.status(200).json({ message: result });
|
|
31917
32050
|
return;
|
|
31918
32051
|
} catch (error2) {
|
|
@@ -33240,7 +33373,7 @@ var import_mongodb90 = require("mongodb");
|
|
|
33240
33373
|
|
|
33241
33374
|
// src/utils/access-management.ts
|
|
33242
33375
|
var import_fs3 = __toESM(require("fs"));
|
|
33243
|
-
var
|
|
33376
|
+
var import_path = __toESM(require("path"));
|
|
33244
33377
|
var import_axios = __toESM(require("axios"));
|
|
33245
33378
|
var import_xml2js = require("xml2js");
|
|
33246
33379
|
var import_crypto = __toESM(require("crypto"));
|
|
@@ -33270,7 +33403,7 @@ var minifyXml = (xml) => {
|
|
|
33270
33403
|
};
|
|
33271
33404
|
var readTemplate = (name, params) => {
|
|
33272
33405
|
const template = import_fs3.default.readFileSync(
|
|
33273
|
-
|
|
33406
|
+
import_path.default.join(__dirname, `../dist/public/xml-templates/${name}.xml`),
|
|
33274
33407
|
"utf-8"
|
|
33275
33408
|
);
|
|
33276
33409
|
if (!params)
|
|
@@ -33401,9 +33534,9 @@ var import_xml2js2 = require("xml2js");
|
|
|
33401
33534
|
// src/utils/rsa-encryption.ts
|
|
33402
33535
|
var crypto2 = __toESM(require("crypto"));
|
|
33403
33536
|
var import_fs4 = __toESM(require("fs"));
|
|
33404
|
-
var
|
|
33405
|
-
var pub =
|
|
33406
|
-
var priv =
|
|
33537
|
+
var import_path2 = __toESM(require("path"));
|
|
33538
|
+
var pub = import_path2.default.resolve(process.cwd(), "./src/public/rsa-keys/new_rsa_512_pub.pem");
|
|
33539
|
+
var priv = import_path2.default.resolve(process.cwd(), "./src/public/rsa-keys/new_rsa_512_priv.pem");
|
|
33407
33540
|
var EncryptionCredentials = class {
|
|
33408
33541
|
};
|
|
33409
33542
|
EncryptionCredentials.RAW_PUBLIC_KEY = import_fs4.default.readFileSync(pub, "utf8");
|
|
@@ -44471,14 +44604,15 @@ async function hrmLabsAuthentication({
|
|
|
44471
44604
|
showPassword: false
|
|
44472
44605
|
},
|
|
44473
44606
|
{
|
|
44474
|
-
headers: { "Content-Type": "application/json" }
|
|
44607
|
+
headers: { "Content-Type": "application/json" },
|
|
44608
|
+
validateStatus: () => true
|
|
44475
44609
|
}
|
|
44476
44610
|
);
|
|
44477
44611
|
if (res.data?.success && res.data.data?.token) {
|
|
44478
44612
|
return res.data.data.token;
|
|
44479
44613
|
}
|
|
44480
44614
|
throw new Error(
|
|
44481
|
-
"HRMLabs Authentication failed. Please check your credentials."
|
|
44615
|
+
res.status === 401 || res.status === 403 ? "HRMLabs Authentication failed. Please check your credentials." : `HRMLabs Authentication failed with status ${res.status}.`
|
|
44482
44616
|
);
|
|
44483
44617
|
}
|
|
44484
44618
|
async function fetchAttendanceData({
|
|
@@ -46669,7 +46803,7 @@ function useHrmLabsAttendanceSrvc() {
|
|
|
46669
46803
|
} catch (error) {
|
|
46670
46804
|
import_node_server_utils209.logger.error(error.message || error);
|
|
46671
46805
|
console.log("Error fetching attendance data:", error);
|
|
46672
|
-
|
|
46806
|
+
return { success: false, message: error?.message || "Internal Server Error!", items: [], pages: 0, pageRange: "0-0 of 0", count: {} };
|
|
46673
46807
|
}
|
|
46674
46808
|
}
|
|
46675
46809
|
async function getAttendanceDataCount(payload) {
|
|
@@ -46783,7 +46917,7 @@ function useHrmLabsAttendanceSrvc() {
|
|
|
46783
46917
|
} catch (error) {
|
|
46784
46918
|
import_node_server_utils209.logger.error(error.message || error);
|
|
46785
46919
|
console.log("Error fetching attendance data count:", error);
|
|
46786
|
-
|
|
46920
|
+
return { success: false, message: error?.message || "Internal Server Error!", totalCount: null };
|
|
46787
46921
|
}
|
|
46788
46922
|
}
|
|
46789
46923
|
async function getAllAttendance(payload) {
|
|
@@ -46955,7 +47089,7 @@ function useHrmLabsAttendanceSrvc() {
|
|
|
46955
47089
|
} catch (error) {
|
|
46956
47090
|
import_node_server_utils209.logger.error(error.message || error);
|
|
46957
47091
|
console.log("Error fetching attendance data:", error);
|
|
46958
|
-
|
|
47092
|
+
return { success: false, message: error?.message || "Internal Server Error!", items: [], count: {}, countPerJobTitle: {}, totalCount: null, countPerStatus: {} };
|
|
46959
47093
|
}
|
|
46960
47094
|
}
|
|
46961
47095
|
async function getChartAttendanceData(payload) {
|
|
@@ -47062,7 +47196,7 @@ function useHrmLabsAttendanceSrvc() {
|
|
|
47062
47196
|
} catch (error) {
|
|
47063
47197
|
import_node_server_utils209.logger.error(error.message || error);
|
|
47064
47198
|
console.log("Error fetching attendance data:", error);
|
|
47065
|
-
|
|
47199
|
+
return { success: false, message: error?.message || "Internal Server Error!", chartCount: null };
|
|
47066
47200
|
}
|
|
47067
47201
|
}
|
|
47068
47202
|
return {
|
|
@@ -48692,7 +48826,8 @@ function useVerificationServiceV2() {
|
|
|
48692
48826
|
add: _add,
|
|
48693
48827
|
updateVerificationStatusById: _updateVerificationStatusById,
|
|
48694
48828
|
getByVerificationCode: _getByVerificationCode,
|
|
48695
|
-
updateStatusById: _updateStatusById
|
|
48829
|
+
updateStatusById: _updateStatusById,
|
|
48830
|
+
countPendingOrgInvites: _countPendingOrgInvites
|
|
48696
48831
|
} = useVerificationRepoV2();
|
|
48697
48832
|
const {
|
|
48698
48833
|
getUserByEmailStatus: _getUserByEmailStatus,
|
|
@@ -48700,6 +48835,8 @@ function useVerificationServiceV2() {
|
|
|
48700
48835
|
} = useUserRepo();
|
|
48701
48836
|
const { getById: getOrgById, getByEmail: _getByEmail } = useOrgRepo();
|
|
48702
48837
|
const { getSiteById } = useSiteRepo();
|
|
48838
|
+
const { getByOrgId: _getSubscriptionByOrgId } = useSubscriptionRepo();
|
|
48839
|
+
const { countByOrg: _countMemberByOrg } = useMemberRepo();
|
|
48703
48840
|
function errorByType(type, status) {
|
|
48704
48841
|
if ((type === "user-invite" /* USER_INVITE */ || type === "member-invite" /* MEMBER_INVITE */ || type === "service-provider-invite" /* SERVICE_PROVIDER_INVITE */ || type === "service-provider-create-org" /* SERVICE_PROVIDER_CREATE_ORG */) && status === "expired" /* EXPIRED */) {
|
|
48705
48842
|
throw new import_node_server_utils221.BadRequestError(
|
|
@@ -48963,6 +49100,30 @@ function useVerificationServiceV2() {
|
|
|
48963
49100
|
throw error2;
|
|
48964
49101
|
}
|
|
48965
49102
|
}
|
|
49103
|
+
async function createOrganizationInvite({
|
|
49104
|
+
email,
|
|
49105
|
+
metadata
|
|
49106
|
+
}) {
|
|
49107
|
+
const orgId = metadata.org?.toString() ?? "";
|
|
49108
|
+
if (!orgId) {
|
|
49109
|
+
throw new import_node_server_utils221.BadRequestError("Organization is required.");
|
|
49110
|
+
}
|
|
49111
|
+
await getOrgById(orgId);
|
|
49112
|
+
const [subscription, memberCount, pendingInviteCount] = await Promise.all([
|
|
49113
|
+
_getSubscriptionByOrgId(orgId),
|
|
49114
|
+
_countMemberByOrg(orgId),
|
|
49115
|
+
_countPendingOrgInvites(orgId)
|
|
49116
|
+
]);
|
|
49117
|
+
const maxSeats = subscription?.maxSeats ?? 0;
|
|
49118
|
+
if (!maxSeats) {
|
|
49119
|
+
throw new import_node_server_utils221.BadRequestError("No seats configured for organization.");
|
|
49120
|
+
}
|
|
49121
|
+
const usedSeats = memberCount + pendingInviteCount;
|
|
49122
|
+
if (usedSeats >= maxSeats) {
|
|
49123
|
+
throw new import_node_server_utils221.BadRequestError("No available seats for new invitation.");
|
|
49124
|
+
}
|
|
49125
|
+
return createUserInvite({ email, metadata });
|
|
49126
|
+
}
|
|
48966
49127
|
async function createForgetPassword(email) {
|
|
48967
49128
|
const value = {
|
|
48968
49129
|
type: "forget-password" /* FORGET_PASSWORD */,
|
|
@@ -49013,6 +49174,7 @@ function useVerificationServiceV2() {
|
|
|
49013
49174
|
signUp,
|
|
49014
49175
|
verify,
|
|
49015
49176
|
createUserInvite,
|
|
49177
|
+
createOrganizationInvite,
|
|
49016
49178
|
createServiceProviderInvite,
|
|
49017
49179
|
createForgetPassword,
|
|
49018
49180
|
cancelUserInvitation
|
|
@@ -49026,6 +49188,7 @@ function useVerificationControllerV2() {
|
|
|
49026
49188
|
const {
|
|
49027
49189
|
verify: _verify,
|
|
49028
49190
|
createUserInvite: _createUserInvite,
|
|
49191
|
+
createOrganizationInvite: _createOrganizationInvite,
|
|
49029
49192
|
createServiceProviderInvite: _createServiceProviderInvite,
|
|
49030
49193
|
createForgetPassword: _createForgetPassword,
|
|
49031
49194
|
cancelUserInvitation: _cancelUserInvitation
|
|
@@ -49122,6 +49285,44 @@ function useVerificationControllerV2() {
|
|
|
49122
49285
|
return;
|
|
49123
49286
|
}
|
|
49124
49287
|
}
|
|
49288
|
+
async function createOrganizationInvite(req, res, next) {
|
|
49289
|
+
const schema2 = import_joi127.default.object({
|
|
49290
|
+
email: import_joi127.default.string().email().lowercase().required(),
|
|
49291
|
+
role: import_joi127.default.string().hex().length(24).required(),
|
|
49292
|
+
org: import_joi127.default.string().hex().length(24).required(),
|
|
49293
|
+
app: import_joi127.default.string().optional().allow("", null).default("organization"),
|
|
49294
|
+
name: import_joi127.default.string().optional().allow("", null),
|
|
49295
|
+
siteId: import_joi127.default.string().hex().length(24).optional().allow("", null),
|
|
49296
|
+
siteName: import_joi127.default.string().optional().allow("", null)
|
|
49297
|
+
});
|
|
49298
|
+
const { error, value } = schema2.validate(req.body, { abortEarly: false });
|
|
49299
|
+
if (error) {
|
|
49300
|
+
const messages = error.details.map((d) => d.message).join(", ");
|
|
49301
|
+
import_node_server_utils222.logger.log({ level: "error", message: messages });
|
|
49302
|
+
next(new import_node_server_utils222.BadRequestError(messages));
|
|
49303
|
+
return;
|
|
49304
|
+
}
|
|
49305
|
+
try {
|
|
49306
|
+
const { email, app, role, name, org, siteId, siteName } = value;
|
|
49307
|
+
await _createOrganizationInvite({
|
|
49308
|
+
email,
|
|
49309
|
+
metadata: {
|
|
49310
|
+
app,
|
|
49311
|
+
role,
|
|
49312
|
+
name,
|
|
49313
|
+
org,
|
|
49314
|
+
siteId,
|
|
49315
|
+
siteName
|
|
49316
|
+
}
|
|
49317
|
+
});
|
|
49318
|
+
res.status(201).json({ message: "Successfully invited user." });
|
|
49319
|
+
return;
|
|
49320
|
+
} catch (error2) {
|
|
49321
|
+
import_node_server_utils222.logger.log({ level: "error", message: `${error2.message}` });
|
|
49322
|
+
next(error2);
|
|
49323
|
+
return;
|
|
49324
|
+
}
|
|
49325
|
+
}
|
|
49125
49326
|
async function createForgetPassword(req, res, next) {
|
|
49126
49327
|
const schema2 = import_joi127.default.object({
|
|
49127
49328
|
email: import_joi127.default.string().email().lowercase().required()
|
|
@@ -49207,6 +49408,7 @@ function useVerificationControllerV2() {
|
|
|
49207
49408
|
return {
|
|
49208
49409
|
verify,
|
|
49209
49410
|
createUserInvite,
|
|
49411
|
+
createOrganizationInvite,
|
|
49210
49412
|
createServiceProviderInvite,
|
|
49211
49413
|
createForgetPassword,
|
|
49212
49414
|
getVerifications,
|