@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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @eeplatform/basic-edu
|
|
2
2
|
|
|
3
|
+
## 1.4.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- e813099: Add createdBy filter to enrollment getAll()
|
|
8
|
+
|
|
9
|
+
## 1.4.2
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- e84952a: Parse createdBy, updatedBy, and deletedBy to ObjectId
|
|
14
|
+
|
|
3
15
|
## 1.4.1
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -105,9 +105,9 @@ type TLearner = {
|
|
|
105
105
|
createdAt?: Date | string;
|
|
106
106
|
updatedAt?: Date | string;
|
|
107
107
|
deletedAt?: Date | string;
|
|
108
|
-
createdBy?: string;
|
|
109
|
-
updatedBy?: string;
|
|
110
|
-
deletedBy?: string;
|
|
108
|
+
createdBy?: string | ObjectId;
|
|
109
|
+
updatedBy?: string | ObjectId;
|
|
110
|
+
deletedBy?: string | ObjectId;
|
|
111
111
|
};
|
|
112
112
|
type TLearnerInfo = {
|
|
113
113
|
psaBirthCertificateNo?: string;
|
|
@@ -195,15 +195,15 @@ declare function MLearner(value: TLearner): {
|
|
|
195
195
|
createdAt: string | Date;
|
|
196
196
|
updatedAt: string | Date;
|
|
197
197
|
deletedAt: string | Date;
|
|
198
|
-
createdBy: string;
|
|
199
|
-
updatedBy: string;
|
|
200
|
-
deletedBy: string;
|
|
198
|
+
createdBy: string | ObjectId;
|
|
199
|
+
updatedBy: string | ObjectId;
|
|
200
|
+
deletedBy: string | ObjectId;
|
|
201
201
|
};
|
|
202
202
|
|
|
203
203
|
declare function useEnrollmentRepo(): {
|
|
204
204
|
createIndexes: () => Promise<void>;
|
|
205
205
|
add: (value: TLearner, session?: ClientSession) => Promise<ObjectId>;
|
|
206
|
-
getAll: ({ search, page, limit, sort, status, school, schoolYear, gradeLevelToEnroll, }?: {
|
|
206
|
+
getAll: ({ search, page, limit, sort, status, school, schoolYear, gradeLevelToEnroll, createdBy, }?: {
|
|
207
207
|
search?: string | undefined;
|
|
208
208
|
page?: number | undefined;
|
|
209
209
|
limit?: number | undefined;
|
|
@@ -212,6 +212,7 @@ declare function useEnrollmentRepo(): {
|
|
|
212
212
|
school?: string | undefined;
|
|
213
213
|
schoolYear?: string | undefined;
|
|
214
214
|
gradeLevelToEnroll?: string | undefined;
|
|
215
|
+
createdBy?: string | undefined;
|
|
215
216
|
}) => Promise<Record<string, any> | {
|
|
216
217
|
items: any[];
|
|
217
218
|
pages: number;
|
package/dist/index.js
CHANGED
|
@@ -1986,6 +1986,27 @@ function MLearner(value) {
|
|
|
1986
1986
|
throw new import_nodejs_utils4.BadRequestError("Invalid school format");
|
|
1987
1987
|
}
|
|
1988
1988
|
}
|
|
1989
|
+
if (value.createdBy && typeof value.createdBy === "string") {
|
|
1990
|
+
try {
|
|
1991
|
+
value.createdBy = new import_mongodb3.ObjectId(value.createdBy);
|
|
1992
|
+
} catch (error2) {
|
|
1993
|
+
throw new import_nodejs_utils4.BadRequestError("Invalid createdBy format");
|
|
1994
|
+
}
|
|
1995
|
+
}
|
|
1996
|
+
if (value.updatedBy && typeof value.updatedBy === "string") {
|
|
1997
|
+
try {
|
|
1998
|
+
value.updatedBy = new import_mongodb3.ObjectId(value.updatedBy);
|
|
1999
|
+
} catch (error2) {
|
|
2000
|
+
throw new import_nodejs_utils4.BadRequestError("Invalid updatedBy format");
|
|
2001
|
+
}
|
|
2002
|
+
}
|
|
2003
|
+
if (value.deletedBy && typeof value.deletedBy === "string") {
|
|
2004
|
+
try {
|
|
2005
|
+
value.deletedBy = new import_mongodb3.ObjectId(value.deletedBy);
|
|
2006
|
+
} catch (error2) {
|
|
2007
|
+
throw new import_nodejs_utils4.BadRequestError("Invalid deletedBy format");
|
|
2008
|
+
}
|
|
2009
|
+
}
|
|
1989
2010
|
return {
|
|
1990
2011
|
_id: value._id ?? void 0,
|
|
1991
2012
|
region: value.region,
|
|
@@ -2094,24 +2115,41 @@ function useEnrollmentRepo() {
|
|
|
2094
2115
|
status = "active",
|
|
2095
2116
|
school = "",
|
|
2096
2117
|
schoolYear = "",
|
|
2097
|
-
gradeLevelToEnroll = ""
|
|
2118
|
+
gradeLevelToEnroll = "",
|
|
2119
|
+
createdBy = ""
|
|
2098
2120
|
} = {}) {
|
|
2099
2121
|
page = page > 0 ? page - 1 : 0;
|
|
2100
2122
|
const query = {
|
|
2101
2123
|
status
|
|
2102
2124
|
};
|
|
2125
|
+
const cacheParams = {
|
|
2126
|
+
page,
|
|
2127
|
+
limit,
|
|
2128
|
+
sort: JSON.stringify(sort)
|
|
2129
|
+
};
|
|
2130
|
+
if (createdBy) {
|
|
2131
|
+
try {
|
|
2132
|
+
query.createdBy = new import_mongodb4.ObjectId(createdBy);
|
|
2133
|
+
cacheParams.createdBy = createdBy;
|
|
2134
|
+
} catch (error) {
|
|
2135
|
+
throw new import_nodejs_utils5.BadRequestError("Invalid createdBy ID.");
|
|
2136
|
+
}
|
|
2137
|
+
}
|
|
2103
2138
|
if (school) {
|
|
2104
2139
|
try {
|
|
2105
2140
|
query.school = new import_mongodb4.ObjectId(school);
|
|
2141
|
+
cacheParams.school = school;
|
|
2106
2142
|
} catch (error) {
|
|
2107
2143
|
throw new import_nodejs_utils5.BadRequestError("Invalid school ID.");
|
|
2108
2144
|
}
|
|
2109
2145
|
}
|
|
2110
2146
|
if (schoolYear) {
|
|
2111
2147
|
query.schoolYear = schoolYear;
|
|
2148
|
+
cacheParams.schoolYear = schoolYear;
|
|
2112
2149
|
}
|
|
2113
2150
|
if (gradeLevelToEnroll) {
|
|
2114
2151
|
query.gradeLevelToEnroll = gradeLevelToEnroll;
|
|
2152
|
+
cacheParams.gradeLevelToEnroll = gradeLevelToEnroll;
|
|
2115
2153
|
}
|
|
2116
2154
|
sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
|
|
2117
2155
|
if (search) {
|
|
@@ -2123,11 +2161,6 @@ function useEnrollmentRepo() {
|
|
|
2123
2161
|
{ gradeLevelToEnroll: { $regex: search, $options: "i" } }
|
|
2124
2162
|
];
|
|
2125
2163
|
}
|
|
2126
|
-
const cacheParams = {
|
|
2127
|
-
page,
|
|
2128
|
-
limit,
|
|
2129
|
-
sort: JSON.stringify(sort)
|
|
2130
|
-
};
|
|
2131
2164
|
if (search)
|
|
2132
2165
|
cacheParams.search = search;
|
|
2133
2166
|
if (status !== "active")
|
|
@@ -3025,7 +3058,8 @@ function useEnrollmentController() {
|
|
|
3025
3058
|
status: import_joi7.default.string().optional().allow("", null),
|
|
3026
3059
|
school: import_joi7.default.string().hex().optional().allow("", null),
|
|
3027
3060
|
schoolYear: import_joi7.default.string().optional().allow("", null),
|
|
3028
|
-
gradeLevelToEnroll: import_joi7.default.string().optional().allow("", null)
|
|
3061
|
+
gradeLevelToEnroll: import_joi7.default.string().optional().allow("", null),
|
|
3062
|
+
createdBy: import_joi7.default.string().hex().optional().allow("", null)
|
|
3029
3063
|
});
|
|
3030
3064
|
const { error } = validation.validate(query);
|
|
3031
3065
|
if (error) {
|
|
@@ -3037,6 +3071,7 @@ function useEnrollmentController() {
|
|
|
3037
3071
|
limit = isNaN(limit) ? 20 : limit;
|
|
3038
3072
|
const sort = req.query.sort ? String(req.query.sort).split(",") : "";
|
|
3039
3073
|
const sortOrder = req.query.sortOrder ? String(req.query.sortOrder).split(",") : "";
|
|
3074
|
+
const createdBy = req.query.createdBy ?? "";
|
|
3040
3075
|
const sortObj = {};
|
|
3041
3076
|
if (sort && sort.length > 0 && sortOrder && sortOrder.length > 0 && sort.length === sortOrder.length) {
|
|
3042
3077
|
for (let i = 0; i < sort.length; i++) {
|
|
@@ -3053,7 +3088,8 @@ function useEnrollmentController() {
|
|
|
3053
3088
|
status: req.query.status,
|
|
3054
3089
|
school: req.query.school,
|
|
3055
3090
|
schoolYear: req.query.schoolYear,
|
|
3056
|
-
gradeLevelToEnroll: req.query.gradeLevelToEnroll
|
|
3091
|
+
gradeLevelToEnroll: req.query.gradeLevelToEnroll,
|
|
3092
|
+
createdBy
|
|
3057
3093
|
});
|
|
3058
3094
|
res.json(result);
|
|
3059
3095
|
return;
|