@7365admin1/core 3.32.0 → 3.32.2-staging.2
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/.github/workflows/publish-staging.yml +36 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +72 -30
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +116 -74
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
name: Publish Staging
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
branches:
|
|
5
|
+
- staging
|
|
6
|
+
|
|
7
|
+
concurrency: ${{ github.workflow }}-${{ github.ref }}
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
publish:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
steps:
|
|
13
|
+
- uses: actions/checkout@v4
|
|
14
|
+
|
|
15
|
+
- uses: actions/setup-node@v4
|
|
16
|
+
with:
|
|
17
|
+
node-version: 20.x
|
|
18
|
+
cache: "yarn"
|
|
19
|
+
cache-dependency-path: yarn.lock
|
|
20
|
+
|
|
21
|
+
- run: yarn install --immutable
|
|
22
|
+
|
|
23
|
+
- run: yarn build
|
|
24
|
+
|
|
25
|
+
- name: Create .npmrc for publishing
|
|
26
|
+
run: |
|
|
27
|
+
echo '//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}' > ~/.npmrc
|
|
28
|
+
|
|
29
|
+
- name: Set staging prerelease version
|
|
30
|
+
run: |
|
|
31
|
+
BASE=$(node -p "const [x,y,z]=require('./package.json').version.split('-')[0].split('.'); [x,y,+z+1].join('.')")
|
|
32
|
+
npm version "$BASE-staging.${{ github.run_number }}" --no-git-tag-version
|
|
33
|
+
node -p "'Publishing ' + require('./package.json').version"
|
|
34
|
+
|
|
35
|
+
- name: Publish to npm with staging tag
|
|
36
|
+
run: npm publish --tag staging --registry https://registry.npmjs.org
|
package/dist/index.d.ts
CHANGED
|
@@ -2622,6 +2622,8 @@ type TGetAttendancesQuery = {
|
|
|
2622
2622
|
page?: number;
|
|
2623
2623
|
limit?: number;
|
|
2624
2624
|
search?: string;
|
|
2625
|
+
startDate?: string | Date;
|
|
2626
|
+
endDate?: string | Date;
|
|
2625
2627
|
} & Pick<TAttendance, "site" | "serviceType">;
|
|
2626
2628
|
type TGetAttendancesByUserQuery = Pick<TGetAttendancesQuery, "page" | "limit" | "search" | "site" | "serviceType"> & Pick<TAttendance, "user">;
|
|
2627
2629
|
declare const attendanceSchema: Joi.ObjectSchema<any>;
|
|
@@ -2682,7 +2684,7 @@ declare function useAttendanceSettingsController(): {
|
|
|
2682
2684
|
declare function useAttendanceRepository(): {
|
|
2683
2685
|
createIndex: () => Promise<void>;
|
|
2684
2686
|
checkInAttendance: (value: TAttendanceCheckIn, session?: ClientSession) => Promise<ObjectId>;
|
|
2685
|
-
getAllAttendances: ({ page, limit, search, site, serviceType, }: TGetAttendancesQuery) => Promise<{}>;
|
|
2687
|
+
getAllAttendances: ({ page, limit, search, site, startDate, endDate, serviceType, }: TGetAttendancesQuery) => Promise<{}>;
|
|
2686
2688
|
getAttendanceByUser: ({ page, limit, search, site, serviceType, user, }: TGetAttendancesByUserQuery) => Promise<{}>;
|
|
2687
2689
|
getAttendanceById: (_id: string | ObjectId, session?: ClientSession) => Promise<{}>;
|
|
2688
2690
|
getRawAttendanceById: (_id: string | ObjectId, session?: ClientSession) => Promise<TAttendance>;
|
package/dist/index.js
CHANGED
|
@@ -32939,6 +32939,7 @@ function MAttendance(value) {
|
|
|
32939
32939
|
// src/repositories/attendance.repository.ts
|
|
32940
32940
|
var import_mongodb60 = require("mongodb");
|
|
32941
32941
|
var import_node_server_utils103 = require("@7365admin1/node-server-utils");
|
|
32942
|
+
var import_moment = __toESM(require("moment"));
|
|
32942
32943
|
function useAttendanceRepository() {
|
|
32943
32944
|
const db = import_node_server_utils103.useAtlas.getDb();
|
|
32944
32945
|
if (!db) {
|
|
@@ -32980,6 +32981,8 @@ function useAttendanceRepository() {
|
|
|
32980
32981
|
limit = 10,
|
|
32981
32982
|
search = "",
|
|
32982
32983
|
site,
|
|
32984
|
+
startDate = "",
|
|
32985
|
+
endDate = "",
|
|
32983
32986
|
serviceType
|
|
32984
32987
|
}) {
|
|
32985
32988
|
page = page > 0 ? page - 1 : 0;
|
|
@@ -32999,6 +33002,37 @@ function useAttendanceRepository() {
|
|
|
32999
33002
|
if (search) {
|
|
33000
33003
|
cacheOptions.search = search;
|
|
33001
33004
|
}
|
|
33005
|
+
const singaporeTz = "Asia/Singapore";
|
|
33006
|
+
const normalizedStartDate = typeof startDate === "string" ? startDate : (0, import_moment.default)(startDate).tz(singaporeTz).format("YYYY-MM-DD");
|
|
33007
|
+
const normalizedEndDate = typeof endDate === "string" ? endDate : (0, import_moment.default)(endDate).tz(singaporeTz).format("YYYY-MM-DD");
|
|
33008
|
+
if (startDate && endDate) {
|
|
33009
|
+
const startOfDay = import_moment.default.tz(normalizedStartDate, "YYYY-MM-DD", singaporeTz).startOf("day").toDate();
|
|
33010
|
+
const endOfDay = import_moment.default.tz(normalizedEndDate, "YYYY-MM-DD", singaporeTz).endOf("day").toDate();
|
|
33011
|
+
query.$expr = {
|
|
33012
|
+
$and: [
|
|
33013
|
+
{ $gte: [{ $toDate: "$checkIn.timestamp" }, startOfDay] },
|
|
33014
|
+
{ $lte: [{ $toDate: "$checkIn.timestamp" }, endOfDay] }
|
|
33015
|
+
]
|
|
33016
|
+
};
|
|
33017
|
+
cacheOptions.startDate = normalizedStartDate;
|
|
33018
|
+
cacheOptions.endDate = normalizedEndDate;
|
|
33019
|
+
} else if (startDate) {
|
|
33020
|
+
query.$expr = {
|
|
33021
|
+
$gte: [
|
|
33022
|
+
{ $toDate: "$checkIn.timestamp" },
|
|
33023
|
+
import_moment.default.tz(normalizedStartDate, "YYYY-MM-DD", singaporeTz).startOf("day").toDate()
|
|
33024
|
+
]
|
|
33025
|
+
};
|
|
33026
|
+
cacheOptions.startDate = normalizedStartDate;
|
|
33027
|
+
} else if (endDate) {
|
|
33028
|
+
query.$expr = {
|
|
33029
|
+
$lte: [
|
|
33030
|
+
{ $toDate: "$checkIn.timestamp" },
|
|
33031
|
+
import_moment.default.tz(normalizedEndDate, "YYYY-MM-DD", singaporeTz).endOf("day").toDate()
|
|
33032
|
+
]
|
|
33033
|
+
};
|
|
33034
|
+
cacheOptions.endDate = normalizedEndDate;
|
|
33035
|
+
}
|
|
33002
33036
|
const cacheKey = (0, import_node_server_utils103.makeCacheKey)(namespace_collection, cacheOptions);
|
|
33003
33037
|
const cachedData = await getCache(cacheKey);
|
|
33004
33038
|
if (cachedData) {
|
|
@@ -33500,7 +33534,9 @@ function useAttendanceController() {
|
|
|
33500
33534
|
limit: import_joi56.default.number().min(1).optional().allow("", null),
|
|
33501
33535
|
search: import_joi56.default.string().optional().allow("", null),
|
|
33502
33536
|
site: import_joi56.default.string().hex().required(),
|
|
33503
|
-
serviceType: import_joi56.default.string().valid(...Object.values(AppServiceType)).required()
|
|
33537
|
+
serviceType: import_joi56.default.string().valid(...Object.values(AppServiceType)).required(),
|
|
33538
|
+
dateFrom: import_joi56.default.alternatives().try(import_joi56.default.date(), import_joi56.default.string()).optional().allow("", null),
|
|
33539
|
+
dateTo: import_joi56.default.alternatives().try(import_joi56.default.date(), import_joi56.default.string()).optional().allow("", null)
|
|
33504
33540
|
});
|
|
33505
33541
|
const { error } = validation.validate(query);
|
|
33506
33542
|
if (error) {
|
|
@@ -33513,13 +33549,17 @@ function useAttendanceController() {
|
|
|
33513
33549
|
const search = req.query.search ?? "";
|
|
33514
33550
|
const site = req.params.site ?? "";
|
|
33515
33551
|
const serviceType = req.query.serviceType ?? "";
|
|
33552
|
+
const startDate = req.query.dateFrom ?? "";
|
|
33553
|
+
const endDate = req.query.dateTo ?? "";
|
|
33516
33554
|
try {
|
|
33517
33555
|
const data = await _getAllAttendances({
|
|
33518
33556
|
page,
|
|
33519
33557
|
limit,
|
|
33520
33558
|
search,
|
|
33521
33559
|
site,
|
|
33522
|
-
serviceType
|
|
33560
|
+
serviceType,
|
|
33561
|
+
startDate,
|
|
33562
|
+
endDate
|
|
33523
33563
|
});
|
|
33524
33564
|
res.json(data);
|
|
33525
33565
|
return;
|
|
@@ -58685,6 +58725,7 @@ function useNfcPatrolLogController() {
|
|
|
58685
58725
|
const query = {
|
|
58686
58726
|
site: req.query.site,
|
|
58687
58727
|
date: req.query.date,
|
|
58728
|
+
type: req.query.type,
|
|
58688
58729
|
route: {
|
|
58689
58730
|
_id: req.query["route._id"],
|
|
58690
58731
|
startTime: req.query["route.startTime"]
|
|
@@ -58699,13 +58740,14 @@ function useNfcPatrolLogController() {
|
|
|
58699
58740
|
next(new import_node_server_utils200.BadRequestError(messages));
|
|
58700
58741
|
return;
|
|
58701
58742
|
}
|
|
58702
|
-
const { page, limit, site, date, route } = value;
|
|
58743
|
+
const { page, limit, site, date, type, route } = value;
|
|
58703
58744
|
try {
|
|
58704
58745
|
const data = await _getAllBySite({
|
|
58705
58746
|
page,
|
|
58706
58747
|
limit,
|
|
58707
58748
|
site,
|
|
58708
58749
|
date,
|
|
58750
|
+
type,
|
|
58709
58751
|
route
|
|
58710
58752
|
});
|
|
58711
58753
|
res.status(200).json(data);
|
|
@@ -58767,7 +58809,7 @@ function useNfcPatrolLogController() {
|
|
|
58767
58809
|
// src/repositories/new-dashboard.repo.ts
|
|
58768
58810
|
var import_node_server_utils201 = require("@7365admin1/node-server-utils");
|
|
58769
58811
|
var import_mongodb122 = require("mongodb");
|
|
58770
|
-
var
|
|
58812
|
+
var import_moment2 = __toESM(require("moment"));
|
|
58771
58813
|
var Period = /* @__PURE__ */ ((Period2) => {
|
|
58772
58814
|
Period2["TODAY"] = "today";
|
|
58773
58815
|
Period2["THIS_WEEK"] = "thisWeek";
|
|
@@ -58804,7 +58846,7 @@ function useNewDashboardRepo() {
|
|
|
58804
58846
|
const dateWithoutTimezone = date.replace(/\s*\+\d{2}:\d{2}$/, "");
|
|
58805
58847
|
date = new Date(dateWithoutTimezone);
|
|
58806
58848
|
}
|
|
58807
|
-
const singaporeMoment =
|
|
58849
|
+
const singaporeMoment = import_moment2.default.tz(date, "Asia/Singapore");
|
|
58808
58850
|
singaporeMoment.set({
|
|
58809
58851
|
hour: 23,
|
|
58810
58852
|
minute: 59,
|
|
@@ -58814,7 +58856,7 @@ function useNewDashboardRepo() {
|
|
|
58814
58856
|
return singaporeMoment.toDate();
|
|
58815
58857
|
}
|
|
58816
58858
|
function getDateRange(p) {
|
|
58817
|
-
const now = (0,
|
|
58859
|
+
const now = (0, import_moment2.default)().tz("Asia/Singapore");
|
|
58818
58860
|
if (p === "thisWeek" /* THIS_WEEK */) {
|
|
58819
58861
|
return {
|
|
58820
58862
|
$gte: now.clone().startOf("isoWeek").toDate(),
|
|
@@ -58832,7 +58874,7 @@ function useNewDashboardRepo() {
|
|
|
58832
58874
|
$lte: now.clone().endOf("day").toDate()
|
|
58833
58875
|
};
|
|
58834
58876
|
}
|
|
58835
|
-
function getSiteDayRange(date =
|
|
58877
|
+
function getSiteDayRange(date = import_moment2.default.tz("Asia/Singapore")) {
|
|
58836
58878
|
return {
|
|
58837
58879
|
$gte: date.clone().startOf("day").toDate(),
|
|
58838
58880
|
$lte: date.clone().endOf("day").toDate()
|
|
@@ -59103,8 +59145,8 @@ function useNewDashboardRepo() {
|
|
|
59103
59145
|
const todayCompliance = tTotal > 0 ? tCompleted / tTotal * 100 : 0;
|
|
59104
59146
|
let activePatrolItems = [];
|
|
59105
59147
|
if (period === "today" /* TODAY */) {
|
|
59106
|
-
const todayString =
|
|
59107
|
-
const dayIndex =
|
|
59148
|
+
const todayString = import_moment2.default.tz("Asia/Singapore").format("YYYY-MM-DD");
|
|
59149
|
+
const dayIndex = import_moment2.default.tz("Asia/Singapore").day();
|
|
59108
59150
|
const repeatDay = dayIndex === 0 ? 7 : dayIndex;
|
|
59109
59151
|
const routes = await db.collection("patrol.route").find({
|
|
59110
59152
|
site: { $in: [siteIdObj, siteId] },
|
|
@@ -59156,12 +59198,12 @@ function useNewDashboardRepo() {
|
|
|
59156
59198
|
status = "completed";
|
|
59157
59199
|
}
|
|
59158
59200
|
} else {
|
|
59159
|
-
const routeTime =
|
|
59201
|
+
const routeTime = import_moment2.default.tz(
|
|
59160
59202
|
`${todayString} ${startTime}`,
|
|
59161
59203
|
"YYYY-MM-DD HH:mm",
|
|
59162
59204
|
"Asia/Singapore"
|
|
59163
59205
|
);
|
|
59164
|
-
const nowSg =
|
|
59206
|
+
const nowSg = import_moment2.default.tz("Asia/Singapore");
|
|
59165
59207
|
const diffMinutes = nowSg.diff(routeTime, "minutes");
|
|
59166
59208
|
if (diffMinutes >= 0) {
|
|
59167
59209
|
if (diffMinutes <= 120) {
|
|
@@ -59209,8 +59251,8 @@ function useNewDashboardRepo() {
|
|
|
59209
59251
|
if (log.status) {
|
|
59210
59252
|
status = Array.isArray(log.status) ? log.status.join(", ") : log.status;
|
|
59211
59253
|
}
|
|
59212
|
-
const logTime = (0,
|
|
59213
|
-
const logDate = (0,
|
|
59254
|
+
const logTime = (0, import_moment2.default)(log.createdAt).tz("Asia/Singapore").format("HH:mm");
|
|
59255
|
+
const logDate = (0, import_moment2.default)(log.createdAt).tz("Asia/Singapore").format("DD/MM/YYYY");
|
|
59214
59256
|
return {
|
|
59215
59257
|
id: log._id.toString(),
|
|
59216
59258
|
title: log.name,
|
|
@@ -59262,11 +59304,11 @@ function useNewDashboardRepo() {
|
|
|
59262
59304
|
}
|
|
59263
59305
|
async function getPropertyManagementDashboard(siteId, period = "today" /* TODAY */, type, facility) {
|
|
59264
59306
|
const siteIdObj = (0, import_node_server_utils201.toObjectId)(siteId);
|
|
59265
|
-
const startOfToday =
|
|
59266
|
-
const endOfToday =
|
|
59307
|
+
const startOfToday = import_moment2.default.tz("Asia/Singapore").startOf("day").toDate();
|
|
59308
|
+
const endOfToday = import_moment2.default.tz("Asia/Singapore").endOf("day").toDate();
|
|
59267
59309
|
const facilityTodayRange = getSiteDayRange();
|
|
59268
59310
|
const facilityYesterdayRange = getSiteDayRange(
|
|
59269
|
-
|
|
59311
|
+
import_moment2.default.tz("Asia/Singapore").subtract(1, "day")
|
|
59270
59312
|
);
|
|
59271
59313
|
const facilityTodayStart = facilityTodayRange.$gte;
|
|
59272
59314
|
const facilityTodayEnd = facilityTodayRange.$lte;
|
|
@@ -59278,13 +59320,13 @@ function useNewDashboardRepo() {
|
|
|
59278
59320
|
};
|
|
59279
59321
|
if (period === "thisWeek" /* THIS_WEEK */) {
|
|
59280
59322
|
facilityPeriodRange = {
|
|
59281
|
-
$gte:
|
|
59282
|
-
$lte:
|
|
59323
|
+
$gte: import_moment2.default.tz("Asia/Singapore").startOf("isoWeek").toDate(),
|
|
59324
|
+
$lte: import_moment2.default.tz("Asia/Singapore").endOf("isoWeek").toDate()
|
|
59283
59325
|
};
|
|
59284
59326
|
} else if (period === "thisMonth" /* THIS_MONTH */) {
|
|
59285
59327
|
facilityPeriodRange = {
|
|
59286
|
-
$gte:
|
|
59287
|
-
$lte:
|
|
59328
|
+
$gte: import_moment2.default.tz("Asia/Singapore").startOf("month").toDate(),
|
|
59329
|
+
$lte: import_moment2.default.tz("Asia/Singapore").endOf("month").toDate()
|
|
59288
59330
|
};
|
|
59289
59331
|
}
|
|
59290
59332
|
const upcomingEvents = await db.collection(events_namespace_collection).find({
|
|
@@ -59916,28 +59958,28 @@ function useNewDashboardRepo() {
|
|
|
59916
59958
|
let labels = [];
|
|
59917
59959
|
let getIntervalIndex;
|
|
59918
59960
|
if (period === "today" /* TODAY */) {
|
|
59919
|
-
rangeStart =
|
|
59920
|
-
rangeEnd =
|
|
59961
|
+
rangeStart = import_moment2.default.tz("Asia/Singapore").startOf("day").toDate();
|
|
59962
|
+
rangeEnd = import_moment2.default.tz("Asia/Singapore").endOf("day").toDate();
|
|
59921
59963
|
labels = ["12 AM", "4 AM", "8 AM", "12 PM", "4 PM", "8 PM"];
|
|
59922
59964
|
getIntervalIndex = (date) => {
|
|
59923
|
-
const hour = (0,
|
|
59965
|
+
const hour = (0, import_moment2.default)(date).tz("Asia/Singapore").hour();
|
|
59924
59966
|
return Math.floor(hour / 4);
|
|
59925
59967
|
};
|
|
59926
59968
|
} else if (period === "thisWeek" /* THIS_WEEK */) {
|
|
59927
|
-
rangeStart =
|
|
59928
|
-
rangeEnd =
|
|
59969
|
+
rangeStart = import_moment2.default.tz("Asia/Singapore").startOf("isoWeek").toDate();
|
|
59970
|
+
rangeEnd = import_moment2.default.tz("Asia/Singapore").endOf("isoWeek").toDate();
|
|
59929
59971
|
labels = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"];
|
|
59930
59972
|
getIntervalIndex = (date) => {
|
|
59931
|
-
const day = (0,
|
|
59973
|
+
const day = (0, import_moment2.default)(date).tz("Asia/Singapore").isoWeekday();
|
|
59932
59974
|
return day - 1;
|
|
59933
59975
|
};
|
|
59934
59976
|
} else if (period === "thisMonth" /* THIS_MONTH */) {
|
|
59935
|
-
rangeStart =
|
|
59936
|
-
rangeEnd =
|
|
59937
|
-
const daysInMonth =
|
|
59977
|
+
rangeStart = import_moment2.default.tz("Asia/Singapore").startOf("month").toDate();
|
|
59978
|
+
rangeEnd = import_moment2.default.tz("Asia/Singapore").endOf("month").toDate();
|
|
59979
|
+
const daysInMonth = import_moment2.default.tz("Asia/Singapore").daysInMonth();
|
|
59938
59980
|
labels = Array.from({ length: daysInMonth }, (_, i) => String(i + 1));
|
|
59939
59981
|
getIntervalIndex = (date) => {
|
|
59940
|
-
return (0,
|
|
59982
|
+
return (0, import_moment2.default)(date).tz("Asia/Singapore").date() - 1;
|
|
59941
59983
|
};
|
|
59942
59984
|
} else {
|
|
59943
59985
|
throw new import_node_server_utils201.BadRequestError("Invalid period.");
|