@eeplatform/basic-edu 1.4.1 → 1.4.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.d.ts +8 -7
- package/dist/index.js +44 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +44 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1940,6 +1940,27 @@ function MLearner(value) {
|
|
|
1940
1940
|
throw new BadRequestError4("Invalid school format");
|
|
1941
1941
|
}
|
|
1942
1942
|
}
|
|
1943
|
+
if (value.createdBy && typeof value.createdBy === "string") {
|
|
1944
|
+
try {
|
|
1945
|
+
value.createdBy = new ObjectId3(value.createdBy);
|
|
1946
|
+
} catch (error2) {
|
|
1947
|
+
throw new BadRequestError4("Invalid createdBy format");
|
|
1948
|
+
}
|
|
1949
|
+
}
|
|
1950
|
+
if (value.updatedBy && typeof value.updatedBy === "string") {
|
|
1951
|
+
try {
|
|
1952
|
+
value.updatedBy = new ObjectId3(value.updatedBy);
|
|
1953
|
+
} catch (error2) {
|
|
1954
|
+
throw new BadRequestError4("Invalid updatedBy format");
|
|
1955
|
+
}
|
|
1956
|
+
}
|
|
1957
|
+
if (value.deletedBy && typeof value.deletedBy === "string") {
|
|
1958
|
+
try {
|
|
1959
|
+
value.deletedBy = new ObjectId3(value.deletedBy);
|
|
1960
|
+
} catch (error2) {
|
|
1961
|
+
throw new BadRequestError4("Invalid deletedBy format");
|
|
1962
|
+
}
|
|
1963
|
+
}
|
|
1943
1964
|
return {
|
|
1944
1965
|
_id: value._id ?? void 0,
|
|
1945
1966
|
region: value.region,
|
|
@@ -2057,24 +2078,41 @@ function useEnrollmentRepo() {
|
|
|
2057
2078
|
status = "active",
|
|
2058
2079
|
school = "",
|
|
2059
2080
|
schoolYear = "",
|
|
2060
|
-
gradeLevelToEnroll = ""
|
|
2081
|
+
gradeLevelToEnroll = "",
|
|
2082
|
+
createdBy = ""
|
|
2061
2083
|
} = {}) {
|
|
2062
2084
|
page = page > 0 ? page - 1 : 0;
|
|
2063
2085
|
const query = {
|
|
2064
2086
|
status
|
|
2065
2087
|
};
|
|
2088
|
+
const cacheParams = {
|
|
2089
|
+
page,
|
|
2090
|
+
limit,
|
|
2091
|
+
sort: JSON.stringify(sort)
|
|
2092
|
+
};
|
|
2093
|
+
if (createdBy) {
|
|
2094
|
+
try {
|
|
2095
|
+
query.createdBy = new ObjectId4(createdBy);
|
|
2096
|
+
cacheParams.createdBy = createdBy;
|
|
2097
|
+
} catch (error) {
|
|
2098
|
+
throw new BadRequestError5("Invalid createdBy ID.");
|
|
2099
|
+
}
|
|
2100
|
+
}
|
|
2066
2101
|
if (school) {
|
|
2067
2102
|
try {
|
|
2068
2103
|
query.school = new ObjectId4(school);
|
|
2104
|
+
cacheParams.school = school;
|
|
2069
2105
|
} catch (error) {
|
|
2070
2106
|
throw new BadRequestError5("Invalid school ID.");
|
|
2071
2107
|
}
|
|
2072
2108
|
}
|
|
2073
2109
|
if (schoolYear) {
|
|
2074
2110
|
query.schoolYear = schoolYear;
|
|
2111
|
+
cacheParams.schoolYear = schoolYear;
|
|
2075
2112
|
}
|
|
2076
2113
|
if (gradeLevelToEnroll) {
|
|
2077
2114
|
query.gradeLevelToEnroll = gradeLevelToEnroll;
|
|
2115
|
+
cacheParams.gradeLevelToEnroll = gradeLevelToEnroll;
|
|
2078
2116
|
}
|
|
2079
2117
|
sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
|
|
2080
2118
|
if (search) {
|
|
@@ -2086,11 +2124,6 @@ function useEnrollmentRepo() {
|
|
|
2086
2124
|
{ gradeLevelToEnroll: { $regex: search, $options: "i" } }
|
|
2087
2125
|
];
|
|
2088
2126
|
}
|
|
2089
|
-
const cacheParams = {
|
|
2090
|
-
page,
|
|
2091
|
-
limit,
|
|
2092
|
-
sort: JSON.stringify(sort)
|
|
2093
|
-
};
|
|
2094
2127
|
if (search)
|
|
2095
2128
|
cacheParams.search = search;
|
|
2096
2129
|
if (status !== "active")
|
|
@@ -3010,7 +3043,8 @@ function useEnrollmentController() {
|
|
|
3010
3043
|
status: Joi7.string().optional().allow("", null),
|
|
3011
3044
|
school: Joi7.string().hex().optional().allow("", null),
|
|
3012
3045
|
schoolYear: Joi7.string().optional().allow("", null),
|
|
3013
|
-
gradeLevelToEnroll: Joi7.string().optional().allow("", null)
|
|
3046
|
+
gradeLevelToEnroll: Joi7.string().optional().allow("", null),
|
|
3047
|
+
createdBy: Joi7.string().hex().optional().allow("", null)
|
|
3014
3048
|
});
|
|
3015
3049
|
const { error } = validation.validate(query);
|
|
3016
3050
|
if (error) {
|
|
@@ -3022,6 +3056,7 @@ function useEnrollmentController() {
|
|
|
3022
3056
|
limit = isNaN(limit) ? 20 : limit;
|
|
3023
3057
|
const sort = req.query.sort ? String(req.query.sort).split(",") : "";
|
|
3024
3058
|
const sortOrder = req.query.sortOrder ? String(req.query.sortOrder).split(",") : "";
|
|
3059
|
+
const createdBy = req.query.createdBy ?? "";
|
|
3025
3060
|
const sortObj = {};
|
|
3026
3061
|
if (sort && sort.length > 0 && sortOrder && sortOrder.length > 0 && sort.length === sortOrder.length) {
|
|
3027
3062
|
for (let i = 0; i < sort.length; i++) {
|
|
@@ -3038,7 +3073,8 @@ function useEnrollmentController() {
|
|
|
3038
3073
|
status: req.query.status,
|
|
3039
3074
|
school: req.query.school,
|
|
3040
3075
|
schoolYear: req.query.schoolYear,
|
|
3041
|
-
gradeLevelToEnroll: req.query.gradeLevelToEnroll
|
|
3076
|
+
gradeLevelToEnroll: req.query.gradeLevelToEnroll,
|
|
3077
|
+
createdBy
|
|
3042
3078
|
});
|
|
3043
3079
|
res.json(result);
|
|
3044
3080
|
return;
|