@eeplatform/basic-edu 1.10.11 → 1.10.13
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 +13 -0
- package/dist/index.d.ts +6 -2
- package/dist/index.js +44 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +44 -16
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1347,6 +1347,7 @@ import Joi from "joi";
|
|
|
1347
1347
|
import { ObjectId } from "mongodb";
|
|
1348
1348
|
var schemaCurriculum = Joi.object({
|
|
1349
1349
|
_id: Joi.string().hex().optional(),
|
|
1350
|
+
school: Joi.string().hex().required(),
|
|
1350
1351
|
name: Joi.string().required(),
|
|
1351
1352
|
effectiveSchoolYear: Joi.string().required(),
|
|
1352
1353
|
maxTeachingHoursPerDay: Joi.number().integer().min(1).required(),
|
|
@@ -1373,8 +1374,14 @@ function MCurriculum(value) {
|
|
|
1373
1374
|
throw new BadRequestError("Invalid _id format");
|
|
1374
1375
|
}
|
|
1375
1376
|
}
|
|
1377
|
+
try {
|
|
1378
|
+
value.school = new ObjectId(value.school);
|
|
1379
|
+
} catch (error2) {
|
|
1380
|
+
throw new BadRequestError("Invalid school format");
|
|
1381
|
+
}
|
|
1376
1382
|
return {
|
|
1377
1383
|
_id: value._id ?? void 0,
|
|
1384
|
+
school: value.school,
|
|
1378
1385
|
name: value.name ?? "",
|
|
1379
1386
|
effectiveSchoolYear: value.effectiveSchoolYear ?? "",
|
|
1380
1387
|
maxTeachingHoursPerDay: value.maxTeachingHoursPerDay ?? 0,
|
|
@@ -1416,6 +1423,7 @@ function useCurriculumRepo() {
|
|
|
1416
1423
|
{
|
|
1417
1424
|
key: {
|
|
1418
1425
|
name: 1,
|
|
1426
|
+
school: 1,
|
|
1419
1427
|
effectiveSchoolYear: 1,
|
|
1420
1428
|
status: 1
|
|
1421
1429
|
},
|
|
@@ -1488,12 +1496,19 @@ function useCurriculumRepo() {
|
|
|
1488
1496
|
page = 1,
|
|
1489
1497
|
limit = 10,
|
|
1490
1498
|
sort = {},
|
|
1491
|
-
status = "active"
|
|
1499
|
+
status = "active",
|
|
1500
|
+
school = ""
|
|
1492
1501
|
} = {}) {
|
|
1493
1502
|
page = page > 0 ? page - 1 : 0;
|
|
1494
1503
|
const query = {
|
|
1495
1504
|
status
|
|
1496
1505
|
};
|
|
1506
|
+
const cacheKeyOptions = {
|
|
1507
|
+
page,
|
|
1508
|
+
limit,
|
|
1509
|
+
sort: JSON.stringify(sort),
|
|
1510
|
+
status
|
|
1511
|
+
};
|
|
1497
1512
|
sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
|
|
1498
1513
|
if (search) {
|
|
1499
1514
|
query.$or = [
|
|
@@ -1501,16 +1516,17 @@ function useCurriculumRepo() {
|
|
|
1501
1516
|
{ effectiveSchoolYear: { $regex: search, $options: "i" } },
|
|
1502
1517
|
{ curriculumMemoRef: { $regex: search, $options: "i" } }
|
|
1503
1518
|
];
|
|
1519
|
+
cacheKeyOptions.search = search;
|
|
1504
1520
|
}
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1521
|
+
if (school) {
|
|
1522
|
+
try {
|
|
1523
|
+
query.school = new ObjectId2(school);
|
|
1524
|
+
} catch (error) {
|
|
1525
|
+
throw new BadRequestError2("Invalid school ID format.");
|
|
1526
|
+
}
|
|
1527
|
+
cacheKeyOptions.school = school;
|
|
1528
|
+
}
|
|
1529
|
+
const cacheParams = cacheKeyOptions;
|
|
1514
1530
|
const cacheKey = makeCacheKey(namespace_collection, cacheParams);
|
|
1515
1531
|
logger2.log({
|
|
1516
1532
|
level: "info",
|
|
@@ -1860,6 +1876,7 @@ function useCurriculumController() {
|
|
|
1860
1876
|
limit = isNaN(limit) ? 20 : limit;
|
|
1861
1877
|
const sort = req.query.sort ? String(req.query.sort).split(",") : "";
|
|
1862
1878
|
const sortOrder = req.query.sortOrder ? String(req.query.sortOrder).split(",") : "";
|
|
1879
|
+
const school = req.query.school;
|
|
1863
1880
|
const sortObj = {};
|
|
1864
1881
|
if (sort && Array.isArray(sort) && sort.length && sortOrder && Array.isArray(sortOrder) && sortOrder.length) {
|
|
1865
1882
|
sort.forEach((field, index) => {
|
|
@@ -1874,7 +1891,8 @@ function useCurriculumController() {
|
|
|
1874
1891
|
limit,
|
|
1875
1892
|
sort: sortObj,
|
|
1876
1893
|
status,
|
|
1877
|
-
search
|
|
1894
|
+
search,
|
|
1895
|
+
school
|
|
1878
1896
|
});
|
|
1879
1897
|
res.json(curriculums);
|
|
1880
1898
|
return;
|
|
@@ -2070,7 +2088,7 @@ var schemaSubjectAdd = Joi3.object({
|
|
|
2070
2088
|
curriculum: Joi3.string().hex().required(),
|
|
2071
2089
|
curriculumName: Joi3.string().required(),
|
|
2072
2090
|
effectiveSchoolYear: Joi3.array().items(Joi3.number().integer().min(1900)).optional(),
|
|
2073
|
-
gradeLevel: Joi3.array().items(Joi3.string()).required(),
|
|
2091
|
+
gradeLevel: Joi3.array().items(Joi3.string()).min(1).required(),
|
|
2074
2092
|
track: Joi3.string().hex().optional().allow("", null),
|
|
2075
2093
|
trackName: Joi3.string().optional().allow("", null),
|
|
2076
2094
|
strand: Joi3.string().hex().optional().allow("", null),
|
|
@@ -5060,11 +5078,13 @@ function useProgramRepo() {
|
|
|
5060
5078
|
{
|
|
5061
5079
|
key: { name: 1, school: 1, status: 1 },
|
|
5062
5080
|
unique: true,
|
|
5081
|
+
partialFilterExpression: { status: "active" },
|
|
5063
5082
|
name: "unique_program_per_school"
|
|
5064
5083
|
},
|
|
5065
5084
|
{
|
|
5066
5085
|
key: { code: 1, school: 1, status: 1 },
|
|
5067
5086
|
unique: true,
|
|
5087
|
+
partialFilterExpression: { status: "active" },
|
|
5068
5088
|
name: "unique_program_code_per_school"
|
|
5069
5089
|
}
|
|
5070
5090
|
]);
|
|
@@ -5114,7 +5134,8 @@ function useProgramRepo() {
|
|
|
5114
5134
|
sort = {},
|
|
5115
5135
|
status = "active",
|
|
5116
5136
|
school = "",
|
|
5117
|
-
isDefault
|
|
5137
|
+
isDefault,
|
|
5138
|
+
gradeLevel = []
|
|
5118
5139
|
} = {}) {
|
|
5119
5140
|
page = page > 0 ? page - 1 : 0;
|
|
5120
5141
|
const query = {
|
|
@@ -5144,6 +5165,10 @@ function useProgramRepo() {
|
|
|
5144
5165
|
query.isDefault = isDefault;
|
|
5145
5166
|
cacheKeyOptions.isDefault = isDefault;
|
|
5146
5167
|
}
|
|
5168
|
+
if (gradeLevel && Array.isArray(gradeLevel) && gradeLevel.length > 0) {
|
|
5169
|
+
query.gradeLevels = { $in: gradeLevel };
|
|
5170
|
+
cacheKeyOptions.gradeLevel = gradeLevel.join(",");
|
|
5171
|
+
}
|
|
5147
5172
|
const cacheKey = makeCacheKey7(namespace_collection, cacheKeyOptions);
|
|
5148
5173
|
logger12.log({
|
|
5149
5174
|
level: "info",
|
|
@@ -5393,7 +5418,8 @@ function useProgramController() {
|
|
|
5393
5418
|
search: Joi13.string().optional().allow("", null),
|
|
5394
5419
|
status: Joi13.string().optional().allow("", null),
|
|
5395
5420
|
school: Joi13.string().hex().optional().allow("", null),
|
|
5396
|
-
isDefault: Joi13.boolean().optional().allow("", null)
|
|
5421
|
+
isDefault: Joi13.boolean().optional().allow("", null),
|
|
5422
|
+
gradeLevel: Joi13.string().optional().allow("", null)
|
|
5397
5423
|
});
|
|
5398
5424
|
const { error } = validation.validate(query);
|
|
5399
5425
|
const page = typeof req.query.page === "string" ? Number(req.query.page) : 1;
|
|
@@ -5402,6 +5428,7 @@ function useProgramController() {
|
|
|
5402
5428
|
const status = req.query.status ?? "active";
|
|
5403
5429
|
const school = req.query.school ?? "";
|
|
5404
5430
|
const isDefault = req.query.isDefault === "true" ? true : req.query.isDefault === "false" ? false : void 0;
|
|
5431
|
+
const gradeLevel = req.query.gradeLevel?.split(",") ?? [];
|
|
5405
5432
|
const isPageNumber = isFinite(page);
|
|
5406
5433
|
if (!isPageNumber) {
|
|
5407
5434
|
next(new BadRequestError19("Invalid page number."));
|
|
@@ -5423,7 +5450,8 @@ function useProgramController() {
|
|
|
5423
5450
|
search,
|
|
5424
5451
|
status,
|
|
5425
5452
|
school,
|
|
5426
|
-
isDefault
|
|
5453
|
+
isDefault,
|
|
5454
|
+
gradeLevel
|
|
5427
5455
|
});
|
|
5428
5456
|
res.json(data);
|
|
5429
5457
|
return;
|
|
@@ -5684,7 +5712,7 @@ function useSchoolRepo() {
|
|
|
5684
5712
|
await collection.createIndexes([
|
|
5685
5713
|
{ key: { name: 1 } },
|
|
5686
5714
|
{ key: { createdAt: 1 } },
|
|
5687
|
-
{ key: { name: "text" } },
|
|
5715
|
+
{ key: { name: "text", id: "text" } },
|
|
5688
5716
|
{ key: { id: 1, status: 1 }, unique: true, name: "unique_school_id" }
|
|
5689
5717
|
]);
|
|
5690
5718
|
} catch (error) {
|