@7365admin1/core 3.34.1 → 3.34.3
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.js +67 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +78 -17
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -8747,6 +8747,9 @@ var MAILER_TRANSPORT_SECURE = process.env.MAILER_TRANSPORT_SECURE === "true";
|
|
|
8747
8747
|
var MAILER_EMAIL = process.env.MAILER_EMAIL ?? "default@gmail.com";
|
|
8748
8748
|
var MAILER_PASSWORD = process.env.MAILER_PASSWORD ?? "password";
|
|
8749
8749
|
var MAILER_FROM_EMAIL = process.env.MAILER_FROM_EMAIL || void 0;
|
|
8750
|
+
var MANPOWER_ALERT_DAILY_LIMIT = Number(
|
|
8751
|
+
process.env.MANPOWER_ALERT_DAILY_LIMIT ?? 50
|
|
8752
|
+
);
|
|
8750
8753
|
var ACCESS_TOKEN_SECRET = process.env.ACCESS_TOKEN_SECRET ?? "access_token_secret";
|
|
8751
8754
|
var REFRESH_TOKEN_SECRET = process.env.REFRESH_TOKEN_SECRET ?? "refresh_token_secret";
|
|
8752
8755
|
var ACCESS_TOKEN_EXPIRY = process.env.ACCESS_TOKEN_EXPIRY ?? "15s";
|
|
@@ -14686,6 +14689,10 @@ function useVerificationController() {
|
|
|
14686
14689
|
}
|
|
14687
14690
|
async function createSimpleUserInvite(req, res, next) {
|
|
14688
14691
|
const payload = { ...req.body };
|
|
14692
|
+
logger22.log({
|
|
14693
|
+
level: "info",
|
|
14694
|
+
message: `[invite/user] payload: ${JSON.stringify(payload)}`
|
|
14695
|
+
});
|
|
14689
14696
|
const validation = Joi16.object({
|
|
14690
14697
|
email: Joi16.string().email().required(),
|
|
14691
14698
|
app: Joi16.array().items(Joi16.string()).min(1).required(),
|
|
@@ -14725,16 +14732,21 @@ function useVerificationController() {
|
|
|
14725
14732
|
siteName
|
|
14726
14733
|
}
|
|
14727
14734
|
});
|
|
14728
|
-
|
|
14735
|
+
const responseBody = {
|
|
14729
14736
|
message: "Successfully invited user.",
|
|
14730
14737
|
totalInvites: verificationIds.length,
|
|
14731
14738
|
verificationIds
|
|
14739
|
+
};
|
|
14740
|
+
logger22.log({
|
|
14741
|
+
level: "info",
|
|
14742
|
+
message: `[invite/user] response: ${JSON.stringify(responseBody)}`
|
|
14732
14743
|
});
|
|
14744
|
+
res.status(201).json(responseBody);
|
|
14733
14745
|
return;
|
|
14734
14746
|
} catch (error2) {
|
|
14735
14747
|
logger22.log({
|
|
14736
14748
|
level: "error",
|
|
14737
|
-
message:
|
|
14749
|
+
message: `[invite/user] error for payload ${JSON.stringify(payload)}: ${error2.message}`
|
|
14738
14750
|
});
|
|
14739
14751
|
next(error2);
|
|
14740
14752
|
return;
|
|
@@ -14742,6 +14754,10 @@ function useVerificationController() {
|
|
|
14742
14754
|
}
|
|
14743
14755
|
async function createSimpleMemberInvite(req, res, next) {
|
|
14744
14756
|
const payload = { ...req.body };
|
|
14757
|
+
logger22.log({
|
|
14758
|
+
level: "info",
|
|
14759
|
+
message: `[invite/member] payload: ${JSON.stringify(payload)}`
|
|
14760
|
+
});
|
|
14745
14761
|
const validation = Joi16.object({
|
|
14746
14762
|
email: Joi16.string().email().required(),
|
|
14747
14763
|
app: Joi16.string().optional().allow("", null),
|
|
@@ -14779,14 +14795,19 @@ function useVerificationController() {
|
|
|
14779
14795
|
siteName
|
|
14780
14796
|
}
|
|
14781
14797
|
});
|
|
14782
|
-
|
|
14798
|
+
const responseBody = {
|
|
14783
14799
|
message: "Successfully invited member."
|
|
14800
|
+
};
|
|
14801
|
+
logger22.log({
|
|
14802
|
+
level: "info",
|
|
14803
|
+
message: `[invite/member] response: ${JSON.stringify(responseBody)}`
|
|
14784
14804
|
});
|
|
14805
|
+
res.status(201).json(responseBody);
|
|
14785
14806
|
return;
|
|
14786
14807
|
} catch (error2) {
|
|
14787
14808
|
logger22.log({
|
|
14788
14809
|
level: "error",
|
|
14789
|
-
message:
|
|
14810
|
+
message: `[invite/member] error for payload ${JSON.stringify(payload)}: ${error2.message}`
|
|
14790
14811
|
});
|
|
14791
14812
|
next(error2);
|
|
14792
14813
|
return;
|
|
@@ -14794,6 +14815,10 @@ function useVerificationController() {
|
|
|
14794
14815
|
}
|
|
14795
14816
|
async function createServiceProviderInvite(req, res, next) {
|
|
14796
14817
|
const payload = req.body;
|
|
14818
|
+
logger22.log({
|
|
14819
|
+
level: "info",
|
|
14820
|
+
message: `[service-providers/invite] payload: ${JSON.stringify(payload)}`
|
|
14821
|
+
});
|
|
14797
14822
|
const validation = Joi16.object({
|
|
14798
14823
|
email: Joi16.string().email().required(),
|
|
14799
14824
|
orgId: Joi16.string().hex().required(),
|
|
@@ -14833,14 +14858,19 @@ function useVerificationController() {
|
|
|
14833
14858
|
secure: true,
|
|
14834
14859
|
maxAge: 4 * 60 * 60 * 1e3
|
|
14835
14860
|
};
|
|
14836
|
-
|
|
14861
|
+
const responseBody = {
|
|
14837
14862
|
message: "Successfully invited service provider."
|
|
14863
|
+
};
|
|
14864
|
+
logger22.log({
|
|
14865
|
+
level: "info",
|
|
14866
|
+
message: `[service-providers/invite] response: ${JSON.stringify(responseBody)}`
|
|
14838
14867
|
});
|
|
14868
|
+
res.cookie("service-provider-email", email, cookieOptions).json(responseBody);
|
|
14839
14869
|
return;
|
|
14840
14870
|
} catch (error2) {
|
|
14841
14871
|
logger22.log({
|
|
14842
14872
|
level: "error",
|
|
14843
|
-
message: `
|
|
14873
|
+
message: `[service-providers/invite] error for payload ${JSON.stringify(payload)}: ${error2.message}`
|
|
14844
14874
|
});
|
|
14845
14875
|
next(error2);
|
|
14846
14876
|
return;
|
|
@@ -63949,6 +63979,7 @@ function useManpowerSitesCtrl() {
|
|
|
63949
63979
|
import {
|
|
63950
63980
|
useAtlas as useAtlas111,
|
|
63951
63981
|
useMailer as useMailer4,
|
|
63982
|
+
useCache as useCache67,
|
|
63952
63983
|
compileHandlebar as compileHandlebar4,
|
|
63953
63984
|
getDirectory as getDirectory4,
|
|
63954
63985
|
logger as logger178
|
|
@@ -63979,7 +64010,16 @@ var createManpowerRemarksDaily = async () => {
|
|
|
63979
64010
|
serviceProviderId: servideProvider._id,
|
|
63980
64011
|
status: "active"
|
|
63981
64012
|
}).toArray();
|
|
64013
|
+
const existingToday = await remarks.find({ createdAtSGT: nowSGT.format("DD-MM-YYYY") }).project({ siteId: 1 }).toArray();
|
|
64014
|
+
const skipSiteIds = new Set(
|
|
64015
|
+
existingToday.map((doc) => doc.siteId.toString())
|
|
64016
|
+
);
|
|
63982
64017
|
for (const site of remark) {
|
|
64018
|
+
const siteKey = site.siteId.toString();
|
|
64019
|
+
if (skipSiteIds.has(siteKey)) {
|
|
64020
|
+
continue;
|
|
64021
|
+
}
|
|
64022
|
+
skipSiteIds.add(siteKey);
|
|
63983
64023
|
const existingRemark = await settings.findOne({
|
|
63984
64024
|
siteId: site.siteId,
|
|
63985
64025
|
enabled: true
|
|
@@ -64046,7 +64086,7 @@ var createManpowerRemarksDaily = async () => {
|
|
|
64046
64086
|
}
|
|
64047
64087
|
}
|
|
64048
64088
|
if (items.length > 0) {
|
|
64049
|
-
await remarks.insertMany(items);
|
|
64089
|
+
await remarks.insertMany(items, { ordered: false });
|
|
64050
64090
|
}
|
|
64051
64091
|
console.log("Daily manpower remarks created successfully.");
|
|
64052
64092
|
} catch (error) {
|
|
@@ -64110,12 +64150,30 @@ var updateRemarksisAcknowledged = async () => {
|
|
|
64110
64150
|
},
|
|
64111
64151
|
{ $set: { "remarks.2.remark.isAcknowledged": false } }
|
|
64112
64152
|
);
|
|
64153
|
+
const { getCache, setCache } = useCache67("manpower-alerts");
|
|
64154
|
+
const capKey = `manpower-alert-count:${nowSGT}`;
|
|
64155
|
+
let sentToday = await getCache(capKey) ?? 0;
|
|
64156
|
+
const emailedSites = /* @__PURE__ */ new Set();
|
|
64113
64157
|
for (const id of updatedIds) {
|
|
64114
64158
|
const doc = await remarks.findOne({ _id: id });
|
|
64159
|
+
const docSiteKey = doc?.siteId?.toString() ?? "";
|
|
64160
|
+
if (emailedSites.has(docSiteKey)) {
|
|
64161
|
+
continue;
|
|
64162
|
+
}
|
|
64115
64163
|
const setting = await settings.findOne(
|
|
64116
64164
|
{ siteId: new ObjectId131(doc?.siteId) },
|
|
64117
64165
|
{ projection: { emails: 1 } }
|
|
64118
64166
|
);
|
|
64167
|
+
if (!setting?.emails?.length) {
|
|
64168
|
+
continue;
|
|
64169
|
+
}
|
|
64170
|
+
if (sentToday >= MANPOWER_ALERT_DAILY_LIMIT) {
|
|
64171
|
+
logger178.log({
|
|
64172
|
+
level: "warn",
|
|
64173
|
+
message: `Manpower alert daily limit (${MANPOWER_ALERT_DAILY_LIMIT}) reached, skipping remaining alerts for ${nowSGT}`
|
|
64174
|
+
});
|
|
64175
|
+
break;
|
|
64176
|
+
}
|
|
64119
64177
|
const payload = {
|
|
64120
64178
|
startDate: doc?.createdAtSGT,
|
|
64121
64179
|
endDate: doc?.createdAtSGT,
|
|
@@ -64156,6 +64214,9 @@ var updateRemarksisAcknowledged = async () => {
|
|
|
64156
64214
|
expected,
|
|
64157
64215
|
status: newStatus
|
|
64158
64216
|
});
|
|
64217
|
+
emailedSites.add(docSiteKey);
|
|
64218
|
+
sentToday++;
|
|
64219
|
+
await setCache(capKey, sentToday, 86400);
|
|
64159
64220
|
}
|
|
64160
64221
|
} catch (error) {
|
|
64161
64222
|
console.error("Error updating remarks:", error);
|
|
@@ -65714,7 +65775,7 @@ import {
|
|
|
65714
65775
|
comparePassword as comparePassword3,
|
|
65715
65776
|
InternalServerError as InternalServerError72,
|
|
65716
65777
|
NotFoundError as NotFoundError55,
|
|
65717
|
-
useCache as
|
|
65778
|
+
useCache as useCache69
|
|
65718
65779
|
} from "@7365admin1/node-server-utils";
|
|
65719
65780
|
import { v4 as uuidv42 } from "uuid";
|
|
65720
65781
|
|
|
@@ -65728,7 +65789,7 @@ import {
|
|
|
65728
65789
|
paginate as paginate60,
|
|
65729
65790
|
NotFoundError as NotFoundError54,
|
|
65730
65791
|
AppError as AppError29,
|
|
65731
|
-
useCache as
|
|
65792
|
+
useCache as useCache68,
|
|
65732
65793
|
makeCacheKey as makeCacheKey65,
|
|
65733
65794
|
toObjectId as toObjectId20
|
|
65734
65795
|
} from "@7365admin1/node-server-utils";
|
|
@@ -65742,7 +65803,7 @@ function useUserRepoV2() {
|
|
|
65742
65803
|
}
|
|
65743
65804
|
const namespace_collection = "users";
|
|
65744
65805
|
const collection = db.collection(namespace_collection);
|
|
65745
|
-
const { delNamespace, setCache, getCache, delCache } =
|
|
65806
|
+
const { delNamespace, setCache, getCache, delCache } = useCache68(namespace_collection);
|
|
65746
65807
|
async function createIndex() {
|
|
65747
65808
|
try {
|
|
65748
65809
|
await collection.createIndexes([{ key: { email: 1 } }]);
|
|
@@ -66189,7 +66250,7 @@ function useUserRepoV2() {
|
|
|
66189
66250
|
function useAuthServiceV2() {
|
|
66190
66251
|
const { getUserByEmail, getUserById: _getUserById } = useUserRepoV2();
|
|
66191
66252
|
const expiresIn = "15m";
|
|
66192
|
-
const { setCache, delCache } =
|
|
66253
|
+
const { setCache, delCache } = useCache69("sessions");
|
|
66193
66254
|
const { getByUserIdType } = useMemberRepo();
|
|
66194
66255
|
async function login({
|
|
66195
66256
|
email,
|
|
@@ -66962,7 +67023,7 @@ import {
|
|
|
66962
67023
|
InternalServerError as InternalServerError74,
|
|
66963
67024
|
useAtlas as useAtlas118,
|
|
66964
67025
|
logger as logger187,
|
|
66965
|
-
useCache as
|
|
67026
|
+
useCache as useCache70
|
|
66966
67027
|
} from "@7365admin1/node-server-utils";
|
|
66967
67028
|
function useRoleRepoV2() {
|
|
66968
67029
|
const db = useAtlas118.getDb();
|
|
@@ -66999,7 +67060,7 @@ function useRoleRepoV2() {
|
|
|
66999
67060
|
throw new InternalServerError74("Failed to create unique index on role.");
|
|
67000
67061
|
}
|
|
67001
67062
|
}
|
|
67002
|
-
const { delNamespace } =
|
|
67063
|
+
const { delNamespace } = useCache70(namespace_collection);
|
|
67003
67064
|
async function addRole(value, session) {
|
|
67004
67065
|
value = new MRoleV2(value);
|
|
67005
67066
|
try {
|
|
@@ -69271,7 +69332,7 @@ function useChatPrelovedController() {
|
|
|
69271
69332
|
|
|
69272
69333
|
// src/events/chat-preloved.event.ts
|
|
69273
69334
|
import Joi144 from "joi";
|
|
69274
|
-
import { logger as logger194, useCache as
|
|
69335
|
+
import { logger as logger194, useCache as useCache71 } from "@7365admin1/node-server-utils";
|
|
69275
69336
|
function parseSid(cookieHeader) {
|
|
69276
69337
|
const match = cookieHeader.match(/(?:^|;\s*)sid=([^;]*)/);
|
|
69277
69338
|
return match ? decodeURIComponent(match[1]) : null;
|
|
@@ -69315,7 +69376,7 @@ function chatPrelovedEvents(io) {
|
|
|
69315
69376
|
if (!sid) {
|
|
69316
69377
|
return next(new Error("Unauthorized"));
|
|
69317
69378
|
}
|
|
69318
|
-
const { getCache } =
|
|
69379
|
+
const { getCache } = useCache71("sessions");
|
|
69319
69380
|
const sessionData = await getCache(`sid:${sid}`);
|
|
69320
69381
|
if (!sessionData) {
|
|
69321
69382
|
return next(new Error("Session expired or invalid"));
|
|
@@ -69864,7 +69925,7 @@ import {
|
|
|
69864
69925
|
NotFoundError as NotFoundError63,
|
|
69865
69926
|
paginate as paginate64,
|
|
69866
69927
|
useAtlas as useAtlas130,
|
|
69867
|
-
useCache as
|
|
69928
|
+
useCache as useCache72
|
|
69868
69929
|
} from "@7365admin1/node-server-utils";
|
|
69869
69930
|
import { ObjectId as ObjectId153 } from "mongodb";
|
|
69870
69931
|
var online_forms_namespace_collection = "online-forms";
|
|
@@ -69874,7 +69935,7 @@ function useFormEntryRepo() {
|
|
|
69874
69935
|
throw new InternalServerError84("Unable to connect to server.");
|
|
69875
69936
|
}
|
|
69876
69937
|
const collection = db.collection(online_forms_namespace_collection);
|
|
69877
|
-
const { delNamespace, getCache, setCache } =
|
|
69938
|
+
const { delNamespace, getCache, setCache } = useCache72(
|
|
69878
69939
|
online_forms_namespace_collection
|
|
69879
69940
|
);
|
|
69880
69941
|
const { getUserById } = useUserRepo();
|