@eeplatform/basic-edu 1.10.2 → 1.10.4
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 +103 -10
- package/dist/index.js +1199 -85
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1207 -84
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -2043,7 +2043,6 @@ var schemaSubject = Joi3.object({
|
|
|
2043
2043
|
curriculum: Joi3.string().hex().required(),
|
|
2044
2044
|
curriculumName: Joi3.string().required(),
|
|
2045
2045
|
effectiveSchoolYear: Joi3.array().items(Joi3.number().integer().min(1900)).optional(),
|
|
2046
|
-
educationLevel: Joi3.string().required(),
|
|
2047
2046
|
gradeLevel: Joi3.string().required(),
|
|
2048
2047
|
program: Joi3.string().hex().optional().allow("", null),
|
|
2049
2048
|
programName: Joi3.string().optional().allow("", null),
|
|
@@ -2065,7 +2064,6 @@ var schemaSubjectAdd = Joi3.object({
|
|
|
2065
2064
|
curriculum: Joi3.string().hex().required(),
|
|
2066
2065
|
curriculumName: Joi3.string().required(),
|
|
2067
2066
|
effectiveSchoolYear: Joi3.array().items(Joi3.number().integer().min(1900)).optional(),
|
|
2068
|
-
educationLevel: Joi3.string().required(),
|
|
2069
2067
|
gradeLevel: Joi3.array().items(Joi3.string()).required(),
|
|
2070
2068
|
program: Joi3.string().hex().optional().allow("", null),
|
|
2071
2069
|
programName: Joi3.string().optional().allow("", null),
|
|
@@ -2117,7 +2115,6 @@ function modelSubject(value) {
|
|
|
2117
2115
|
curriculum: value.curriculum,
|
|
2118
2116
|
curriculumName: value.curriculumName ?? "",
|
|
2119
2117
|
effectiveSchoolYear: value.effectiveSchoolYear ?? [],
|
|
2120
|
-
educationLevel: value.educationLevel ?? "",
|
|
2121
2118
|
gradeLevel: value.gradeLevel ?? "",
|
|
2122
2119
|
program: value.program,
|
|
2123
2120
|
programName: value.programName ?? "",
|
|
@@ -2575,7 +2572,6 @@ function useSubjectService() {
|
|
|
2575
2572
|
curriculum: value.curriculum,
|
|
2576
2573
|
curriculumName: value.curriculumName,
|
|
2577
2574
|
effectiveSchoolYear: value.effectiveSchoolYear,
|
|
2578
|
-
educationLevel: value.educationLevel,
|
|
2579
2575
|
gradeLevel,
|
|
2580
2576
|
subjectCode: value.subjectCode,
|
|
2581
2577
|
subjectName: value.subjectName,
|
|
@@ -2644,7 +2640,6 @@ function useSubjectController() {
|
|
|
2644
2640
|
id: Joi4.string().hex().required(),
|
|
2645
2641
|
value: Joi4.object({
|
|
2646
2642
|
curriculum: Joi4.string().hex().optional(),
|
|
2647
|
-
educationLevel: Joi4.string().optional(),
|
|
2648
2643
|
gradeLevel: Joi4.string().optional(),
|
|
2649
2644
|
subjectCode: Joi4.string().optional(),
|
|
2650
2645
|
subjectName: Joi4.string().optional(),
|
|
@@ -35337,8 +35332,6 @@ var schemaGradeLevel = Joi17.object({
|
|
|
35337
35332
|
school: Joi17.string().hex().optional(),
|
|
35338
35333
|
educationLevel: Joi17.string().required(),
|
|
35339
35334
|
gradeLevel: Joi17.string().required(),
|
|
35340
|
-
tracks: Joi17.array().items(Joi17.string()).optional(),
|
|
35341
|
-
trackStrands: Joi17.array().items(Joi17.string()).optional(),
|
|
35342
35335
|
teachingStyle: Joi17.string().required(),
|
|
35343
35336
|
maxNumberOfLearners: Joi17.number().required(),
|
|
35344
35337
|
minNumberOfLearners: Joi17.number().required(),
|
|
@@ -35382,8 +35375,6 @@ function MGradeLevel(value) {
|
|
|
35382
35375
|
school: value.school ?? void 0,
|
|
35383
35376
|
educationLevel: value.educationLevel ?? "",
|
|
35384
35377
|
gradeLevel: value.gradeLevel ?? "",
|
|
35385
|
-
tracks: value.tracks ?? [],
|
|
35386
|
-
trackStrands: value.trackStrands ?? [],
|
|
35387
35378
|
teachingStyle: value.teachingStyle ?? "",
|
|
35388
35379
|
maxNumberOfLearners: value.maxNumberOfLearners ?? 0,
|
|
35389
35380
|
minNumberOfLearners: value.minNumberOfLearners ?? 0,
|
|
@@ -39445,7 +39436,7 @@ function useSectionRepo() {
|
|
|
39445
39436
|
{ key: { createdAt: 1 } },
|
|
39446
39437
|
{ key: { name: "text", schoolYear: "text", gradeLevel: "text" } },
|
|
39447
39438
|
{
|
|
39448
|
-
key: { school: 1,
|
|
39439
|
+
key: { name: 1, school: 1, gradeLevel: 1, schoolYear: 1, status: 1 },
|
|
39449
39440
|
unique: true,
|
|
39450
39441
|
name: "unique_section"
|
|
39451
39442
|
}
|
|
@@ -39929,6 +39920,13 @@ function modelSectionStudent(value) {
|
|
|
39929
39920
|
throw new Error("Invalid school ID.");
|
|
39930
39921
|
}
|
|
39931
39922
|
}
|
|
39923
|
+
if (value.student && typeof value.student === "string") {
|
|
39924
|
+
try {
|
|
39925
|
+
value.student = new ObjectId31(value.student);
|
|
39926
|
+
} catch (error2) {
|
|
39927
|
+
throw new Error("Invalid student ID.");
|
|
39928
|
+
}
|
|
39929
|
+
}
|
|
39932
39930
|
return {
|
|
39933
39931
|
_id: value._id,
|
|
39934
39932
|
lrn: value.lrn,
|
|
@@ -40106,14 +40104,6 @@ function useSectionStudentRepo() {
|
|
|
40106
40104
|
async function getStudent(options) {
|
|
40107
40105
|
const query = {};
|
|
40108
40106
|
const cacheKeyOptions = { tag: "getStudent" };
|
|
40109
|
-
if (options.learner) {
|
|
40110
|
-
try {
|
|
40111
|
-
query.learner = new ObjectId32(options.learner);
|
|
40112
|
-
cacheKeyOptions.learner = String(options.learner);
|
|
40113
|
-
} catch (error) {
|
|
40114
|
-
throw new BadRequestError51("Invalid learner ID.");
|
|
40115
|
-
}
|
|
40116
|
-
}
|
|
40117
40107
|
if (options.schoolYear) {
|
|
40118
40108
|
query.schoolYear = options.schoolYear;
|
|
40119
40109
|
cacheKeyOptions.schoolYear = options.schoolYear;
|
|
@@ -40185,7 +40175,6 @@ var schemaSectionSubject = Joi34.object({
|
|
|
40185
40175
|
section: Joi34.string().hex().required(),
|
|
40186
40176
|
sectionName: Joi34.string().required(),
|
|
40187
40177
|
gradeLevel: Joi34.string().required(),
|
|
40188
|
-
educationLevel: Joi34.string().required(),
|
|
40189
40178
|
schoolYear: Joi34.string().required(),
|
|
40190
40179
|
subjectCode: Joi34.string().required(),
|
|
40191
40180
|
subjectName: Joi34.string().required(),
|
|
@@ -40258,7 +40247,6 @@ function modelSectionSubject(value) {
|
|
|
40258
40247
|
section: value.section,
|
|
40259
40248
|
sectionName: value.sectionName,
|
|
40260
40249
|
gradeLevel: value.gradeLevel,
|
|
40261
|
-
educationLevel: value.educationLevel,
|
|
40262
40250
|
schoolYear: value.schoolYear,
|
|
40263
40251
|
subjectCode: value.subjectCode,
|
|
40264
40252
|
subjectName: value.subjectName,
|
|
@@ -42423,7 +42411,6 @@ import { BadRequestError as BadRequestError61, logger as logger36 } from "@eepla
|
|
|
42423
42411
|
import Joi41 from "joi";
|
|
42424
42412
|
import { ObjectId as ObjectId39 } from "mongodb";
|
|
42425
42413
|
var schemaPersonnel = Joi41.object({
|
|
42426
|
-
_id: Joi41.string().hex().optional().allow("", null),
|
|
42427
42414
|
school: Joi41.string().hex().required(),
|
|
42428
42415
|
schoolName: Joi41.string().optional().allow("", null),
|
|
42429
42416
|
firstName: Joi41.string().required(),
|
|
@@ -42433,11 +42420,7 @@ var schemaPersonnel = Joi41.object({
|
|
|
42433
42420
|
title: Joi41.string().optional().allow("", null),
|
|
42434
42421
|
classification: Joi41.string().required(),
|
|
42435
42422
|
specializations: Joi41.array().items(Joi41.string()).optional(),
|
|
42436
|
-
gradeLevels: Joi41.array().items(Joi41.string()).optional()
|
|
42437
|
-
status: Joi41.string().optional().allow("", null),
|
|
42438
|
-
createdAt: Joi41.date().optional().allow("", null),
|
|
42439
|
-
updatedAt: Joi41.date().optional().allow("", null),
|
|
42440
|
-
deletedAt: Joi41.date().optional().allow("", null)
|
|
42423
|
+
gradeLevels: Joi41.array().items(Joi41.string()).optional()
|
|
42441
42424
|
});
|
|
42442
42425
|
function MPersonnel(value) {
|
|
42443
42426
|
const { error } = schemaPersonnel.validate(value);
|
|
@@ -43104,22 +43087,22 @@ function useSectionService() {
|
|
|
43104
43087
|
if (existingSection) {
|
|
43105
43088
|
sectionId = existingSection._id?.toString() || "";
|
|
43106
43089
|
sectionsSkipped++;
|
|
43107
|
-
|
|
43090
|
+
} else {
|
|
43091
|
+
sectionId = await createSection(
|
|
43092
|
+
{
|
|
43093
|
+
school: value.school,
|
|
43094
|
+
schoolYear: value.schoolYear,
|
|
43095
|
+
gradeLevel: value.gradeLevel,
|
|
43096
|
+
name: sectionName,
|
|
43097
|
+
students: size
|
|
43098
|
+
},
|
|
43099
|
+
session
|
|
43100
|
+
);
|
|
43101
|
+
sectionsGenerated++;
|
|
43108
43102
|
}
|
|
43109
|
-
sectionId = await createSection(
|
|
43110
|
-
{
|
|
43111
|
-
school: value.school,
|
|
43112
|
-
schoolYear: value.schoolYear,
|
|
43113
|
-
gradeLevel: value.gradeLevel,
|
|
43114
|
-
name: sectionName,
|
|
43115
|
-
students: size
|
|
43116
|
-
},
|
|
43117
|
-
session
|
|
43118
|
-
);
|
|
43119
43103
|
if (!sectionId) {
|
|
43120
43104
|
throw new InternalServerError21("Required section ID is missing.");
|
|
43121
43105
|
}
|
|
43122
|
-
sectionsGenerated++;
|
|
43123
43106
|
const skip = totalStudentsProcessed;
|
|
43124
43107
|
const learners = await getLeanerByGradeLevel(
|
|
43125
43108
|
{
|
|
@@ -43149,24 +43132,24 @@ function useSectionService() {
|
|
|
43149
43132
|
});
|
|
43150
43133
|
if (existingStudent) {
|
|
43151
43134
|
studentSkipped++;
|
|
43152
|
-
|
|
43135
|
+
} else {
|
|
43136
|
+
await assignStudent(
|
|
43137
|
+
{
|
|
43138
|
+
section: sectionId,
|
|
43139
|
+
lrn: student.learnerInfo.lrn,
|
|
43140
|
+
student: student._id?.toString(),
|
|
43141
|
+
studentName: `${student.learnerInfo.firstName} ${student.learnerInfo.lastName}`,
|
|
43142
|
+
school: value.school,
|
|
43143
|
+
schoolName: schoolData.name,
|
|
43144
|
+
gradeLevel: value.gradeLevel,
|
|
43145
|
+
educationLevel: gradeLevelData.educationLevel,
|
|
43146
|
+
schoolYear: value.schoolYear,
|
|
43147
|
+
status: "active"
|
|
43148
|
+
},
|
|
43149
|
+
session
|
|
43150
|
+
);
|
|
43151
|
+
studentCreated++;
|
|
43153
43152
|
}
|
|
43154
|
-
await assignStudent(
|
|
43155
|
-
{
|
|
43156
|
-
section: sectionId,
|
|
43157
|
-
lrn: student.learnerInfo.lrn,
|
|
43158
|
-
student: student._id?.toString(),
|
|
43159
|
-
studentName: `${student.learnerInfo.firstName} ${student.learnerInfo.lastName}`,
|
|
43160
|
-
school: value.school,
|
|
43161
|
-
schoolName: schoolData.name,
|
|
43162
|
-
gradeLevel: value.gradeLevel,
|
|
43163
|
-
educationLevel: gradeLevelData.educationLevel,
|
|
43164
|
-
schoolYear: value.schoolYear,
|
|
43165
|
-
status: "active"
|
|
43166
|
-
},
|
|
43167
|
-
session
|
|
43168
|
-
);
|
|
43169
|
-
studentCreated++;
|
|
43170
43153
|
}
|
|
43171
43154
|
if (value.gradeLevel !== "kindergarten") {
|
|
43172
43155
|
const curriculumSubjects = await getAllCurriculumSubjects({
|
|
@@ -43180,35 +43163,34 @@ function useSectionService() {
|
|
|
43180
43163
|
subjectCode: curriculumSubject.subjectCode,
|
|
43181
43164
|
schoolYear: value.schoolYear
|
|
43182
43165
|
});
|
|
43183
|
-
if (existingSectionSubject) {
|
|
43166
|
+
if (existingSectionSubject && existingSectionSubject.length) {
|
|
43184
43167
|
subjectsSkipped++;
|
|
43185
|
-
|
|
43168
|
+
} else {
|
|
43169
|
+
await addSectionSubject(
|
|
43170
|
+
{
|
|
43171
|
+
curriculum: curriculumSubject.curriculum.toString(),
|
|
43172
|
+
school: value.school,
|
|
43173
|
+
schoolName: schoolData.name,
|
|
43174
|
+
gradeLevel: value.gradeLevel,
|
|
43175
|
+
schoolYear: value.schoolYear,
|
|
43176
|
+
section: sectionId,
|
|
43177
|
+
sectionName,
|
|
43178
|
+
subjectCode: curriculumSubject.subjectCode,
|
|
43179
|
+
subjectName: curriculumSubject.subjectName,
|
|
43180
|
+
teacher: "",
|
|
43181
|
+
teacherName: "",
|
|
43182
|
+
schedule: "",
|
|
43183
|
+
daysOfWeek: [],
|
|
43184
|
+
classroom: "",
|
|
43185
|
+
classroomName: "",
|
|
43186
|
+
sessionDuration: curriculumSubject.sessionDuration,
|
|
43187
|
+
sessionFrequency: curriculumSubject.sessionFrequency,
|
|
43188
|
+
status: "draft"
|
|
43189
|
+
},
|
|
43190
|
+
session
|
|
43191
|
+
);
|
|
43192
|
+
subjectsAssigned++;
|
|
43186
43193
|
}
|
|
43187
|
-
await addSectionSubject(
|
|
43188
|
-
{
|
|
43189
|
-
curriculum: curriculumSubject.curriculum.toString(),
|
|
43190
|
-
school: value.school,
|
|
43191
|
-
schoolName: schoolData.name,
|
|
43192
|
-
gradeLevel: value.gradeLevel,
|
|
43193
|
-
educationLevel: gradeLevelData.educationLevel,
|
|
43194
|
-
schoolYear: value.schoolYear,
|
|
43195
|
-
section: sectionId,
|
|
43196
|
-
sectionName,
|
|
43197
|
-
subjectCode: curriculumSubject.subjectCode,
|
|
43198
|
-
subjectName: curriculumSubject.subjectName,
|
|
43199
|
-
teacher: "",
|
|
43200
|
-
teacherName: "",
|
|
43201
|
-
schedule: "",
|
|
43202
|
-
daysOfWeek: [],
|
|
43203
|
-
classroom: "",
|
|
43204
|
-
classroomName: "",
|
|
43205
|
-
sessionDuration: curriculumSubject.sessionDuration,
|
|
43206
|
-
sessionFrequency: curriculumSubject.sessionFrequency,
|
|
43207
|
-
status: "draft"
|
|
43208
|
-
},
|
|
43209
|
-
session
|
|
43210
|
-
);
|
|
43211
|
-
subjectsAssigned++;
|
|
43212
43194
|
}
|
|
43213
43195
|
}
|
|
43214
43196
|
}
|
|
@@ -43241,7 +43223,7 @@ function useSectionService() {
|
|
|
43241
43223
|
school: value.school,
|
|
43242
43224
|
schoolYear: value.schoolYear
|
|
43243
43225
|
});
|
|
43244
|
-
if (existingLoad) {
|
|
43226
|
+
if (existingLoad && existingLoad.length) {
|
|
43245
43227
|
teachingLoadsSkipped++;
|
|
43246
43228
|
continue;
|
|
43247
43229
|
}
|
|
@@ -46169,6 +46151,1138 @@ function useKindergartenDomainController() {
|
|
|
46169
46151
|
};
|
|
46170
46152
|
}
|
|
46171
46153
|
|
|
46154
|
+
// src/resources/track/track.model.ts
|
|
46155
|
+
import { BadRequestError as BadRequestError80 } from "@eeplatform/nodejs-utils";
|
|
46156
|
+
import Joi52 from "joi";
|
|
46157
|
+
import { ObjectId as ObjectId48 } from "mongodb";
|
|
46158
|
+
var schemaTrack = Joi52.object({
|
|
46159
|
+
name: Joi52.string().max(100).required(),
|
|
46160
|
+
school: Joi52.string().hex().required()
|
|
46161
|
+
});
|
|
46162
|
+
function modelTrack(value) {
|
|
46163
|
+
const { error } = schemaTrack.validate(value);
|
|
46164
|
+
if (error) {
|
|
46165
|
+
throw new BadRequestError80(`Invalid track data: ${error.message}`);
|
|
46166
|
+
}
|
|
46167
|
+
if (value._id && typeof value._id === "string") {
|
|
46168
|
+
try {
|
|
46169
|
+
value._id = new ObjectId48(value._id);
|
|
46170
|
+
} catch (error2) {
|
|
46171
|
+
throw new Error("Invalid _id.");
|
|
46172
|
+
}
|
|
46173
|
+
}
|
|
46174
|
+
if (value.school && typeof value.school === "string") {
|
|
46175
|
+
try {
|
|
46176
|
+
value.school = new ObjectId48(value.school);
|
|
46177
|
+
} catch (error2) {
|
|
46178
|
+
throw new Error("Invalid school.");
|
|
46179
|
+
}
|
|
46180
|
+
}
|
|
46181
|
+
return {
|
|
46182
|
+
_id: value._id,
|
|
46183
|
+
name: value.name,
|
|
46184
|
+
school: value.school,
|
|
46185
|
+
status: value.status ?? "active",
|
|
46186
|
+
createdAt: value.createdAt ?? /* @__PURE__ */ new Date(),
|
|
46187
|
+
updatedAt: value.updatedAt ?? "",
|
|
46188
|
+
deletedAt: value.deletedAt ?? ""
|
|
46189
|
+
};
|
|
46190
|
+
}
|
|
46191
|
+
|
|
46192
|
+
// src/resources/track/track.repository.ts
|
|
46193
|
+
import {
|
|
46194
|
+
AppError as AppError31,
|
|
46195
|
+
BadRequestError as BadRequestError81,
|
|
46196
|
+
InternalServerError as InternalServerError26,
|
|
46197
|
+
logger as logger45,
|
|
46198
|
+
makeCacheKey as makeCacheKey26,
|
|
46199
|
+
paginate as paginate25,
|
|
46200
|
+
useAtlas as useAtlas38,
|
|
46201
|
+
useCache as useCache26
|
|
46202
|
+
} from "@eeplatform/nodejs-utils";
|
|
46203
|
+
import { ObjectId as ObjectId49 } from "mongodb";
|
|
46204
|
+
function useTrackRepo() {
|
|
46205
|
+
const db = useAtlas38.getDb();
|
|
46206
|
+
if (!db) {
|
|
46207
|
+
throw new Error("Unable to connect to server.");
|
|
46208
|
+
}
|
|
46209
|
+
const namespace_collection = "deped.school.tracks";
|
|
46210
|
+
const collection = db.collection(namespace_collection);
|
|
46211
|
+
const { getCache, setCache, delNamespace } = useCache26(namespace_collection);
|
|
46212
|
+
async function createIndexes() {
|
|
46213
|
+
try {
|
|
46214
|
+
await collection.createIndexes([
|
|
46215
|
+
{ key: { school: 1 } },
|
|
46216
|
+
{ key: { name: "text" } },
|
|
46217
|
+
{
|
|
46218
|
+
key: { name: 1, school: 1, status: 1 },
|
|
46219
|
+
unique: true,
|
|
46220
|
+
name: "unique_track"
|
|
46221
|
+
}
|
|
46222
|
+
]);
|
|
46223
|
+
} catch (error) {
|
|
46224
|
+
throw new Error("Failed to create index on tracks.");
|
|
46225
|
+
}
|
|
46226
|
+
}
|
|
46227
|
+
function delCachedData() {
|
|
46228
|
+
delNamespace().then(() => {
|
|
46229
|
+
logger45.log({
|
|
46230
|
+
level: "info",
|
|
46231
|
+
message: `Cache namespace cleared for ${namespace_collection}`
|
|
46232
|
+
});
|
|
46233
|
+
}).catch((err) => {
|
|
46234
|
+
logger45.log({
|
|
46235
|
+
level: "error",
|
|
46236
|
+
message: `Failed to clear cache namespace for ${namespace_collection}: ${err.message}`
|
|
46237
|
+
});
|
|
46238
|
+
});
|
|
46239
|
+
}
|
|
46240
|
+
async function add(value, session) {
|
|
46241
|
+
try {
|
|
46242
|
+
value = modelTrack(value);
|
|
46243
|
+
const res = await collection.insertOne(value, { session });
|
|
46244
|
+
delCachedData();
|
|
46245
|
+
return res.insertedId;
|
|
46246
|
+
} catch (error) {
|
|
46247
|
+
logger45.log({
|
|
46248
|
+
level: "error",
|
|
46249
|
+
message: error.message
|
|
46250
|
+
});
|
|
46251
|
+
if (error instanceof AppError31) {
|
|
46252
|
+
throw error;
|
|
46253
|
+
} else {
|
|
46254
|
+
const isDuplicated = error.message.includes("duplicate");
|
|
46255
|
+
if (isDuplicated) {
|
|
46256
|
+
throw new BadRequestError81("track already exists.");
|
|
46257
|
+
}
|
|
46258
|
+
throw new Error("Failed to create track.");
|
|
46259
|
+
}
|
|
46260
|
+
}
|
|
46261
|
+
}
|
|
46262
|
+
async function getAll({
|
|
46263
|
+
search = "",
|
|
46264
|
+
page = 1,
|
|
46265
|
+
limit = 10,
|
|
46266
|
+
sort = {},
|
|
46267
|
+
status = "active",
|
|
46268
|
+
school = ""
|
|
46269
|
+
} = {}) {
|
|
46270
|
+
page = page > 0 ? page - 1 : 0;
|
|
46271
|
+
const query = {
|
|
46272
|
+
deletedAt: { $in: ["", null] },
|
|
46273
|
+
status
|
|
46274
|
+
};
|
|
46275
|
+
sort = Object.keys(sort).length > 0 ? sort : { _id: 1 };
|
|
46276
|
+
const cacheKeyOptions = {
|
|
46277
|
+
status,
|
|
46278
|
+
page,
|
|
46279
|
+
limit,
|
|
46280
|
+
sort: JSON.stringify(sort)
|
|
46281
|
+
};
|
|
46282
|
+
if (search) {
|
|
46283
|
+
query.$text = { $search: search };
|
|
46284
|
+
cacheKeyOptions.search = search;
|
|
46285
|
+
}
|
|
46286
|
+
if (school) {
|
|
46287
|
+
try {
|
|
46288
|
+
query.school = new ObjectId49(school);
|
|
46289
|
+
} catch (error) {
|
|
46290
|
+
throw new BadRequestError81("Invalid school ID.");
|
|
46291
|
+
}
|
|
46292
|
+
cacheKeyOptions.school = school;
|
|
46293
|
+
}
|
|
46294
|
+
const cacheKey = makeCacheKey26(namespace_collection, cacheKeyOptions);
|
|
46295
|
+
logger45.log({
|
|
46296
|
+
level: "info",
|
|
46297
|
+
message: `Cache key for getAll tracks: ${cacheKey}`
|
|
46298
|
+
});
|
|
46299
|
+
try {
|
|
46300
|
+
const cached = await getCache(cacheKey);
|
|
46301
|
+
if (cached) {
|
|
46302
|
+
logger45.log({
|
|
46303
|
+
level: "info",
|
|
46304
|
+
message: `Cache hit for getAll tracks: ${cacheKey}`
|
|
46305
|
+
});
|
|
46306
|
+
return cached;
|
|
46307
|
+
}
|
|
46308
|
+
const items = await collection.aggregate([
|
|
46309
|
+
{ $match: query },
|
|
46310
|
+
{ $sort: sort },
|
|
46311
|
+
{ $skip: page * limit },
|
|
46312
|
+
{ $limit: limit }
|
|
46313
|
+
]).toArray();
|
|
46314
|
+
const total = await collection.countDocuments(query);
|
|
46315
|
+
const result = paginate25(items, total, page, limit);
|
|
46316
|
+
setCache(cacheKey, result, 300).then(() => {
|
|
46317
|
+
logger45.log({
|
|
46318
|
+
level: "info",
|
|
46319
|
+
message: `Cache set for getAll tracks: ${cacheKey}`
|
|
46320
|
+
});
|
|
46321
|
+
}).catch((err) => {
|
|
46322
|
+
logger45.log({
|
|
46323
|
+
level: "error",
|
|
46324
|
+
message: `Failed to set cache for getAll tracks: ${err.message}`
|
|
46325
|
+
});
|
|
46326
|
+
});
|
|
46327
|
+
return result;
|
|
46328
|
+
} catch (error) {
|
|
46329
|
+
if (error instanceof AppError31) {
|
|
46330
|
+
throw error;
|
|
46331
|
+
} else {
|
|
46332
|
+
throw new InternalServerError26("Failed to get tracks.");
|
|
46333
|
+
}
|
|
46334
|
+
}
|
|
46335
|
+
}
|
|
46336
|
+
async function getById(_id) {
|
|
46337
|
+
try {
|
|
46338
|
+
_id = new ObjectId49(_id);
|
|
46339
|
+
} catch (error) {
|
|
46340
|
+
throw new BadRequestError81(namespace_collection + " Invalid ID.");
|
|
46341
|
+
}
|
|
46342
|
+
const cacheKey = makeCacheKey26(namespace_collection, {
|
|
46343
|
+
_id: _id.toString()
|
|
46344
|
+
});
|
|
46345
|
+
logger45.log({
|
|
46346
|
+
level: "info",
|
|
46347
|
+
message: `Cache key for getById track: ${cacheKey}`
|
|
46348
|
+
});
|
|
46349
|
+
try {
|
|
46350
|
+
const cached = await getCache(cacheKey);
|
|
46351
|
+
if (cached) {
|
|
46352
|
+
logger45.log({
|
|
46353
|
+
level: "info",
|
|
46354
|
+
message: `Cache hit for getById track: ${cacheKey}`
|
|
46355
|
+
});
|
|
46356
|
+
return cached;
|
|
46357
|
+
}
|
|
46358
|
+
const result = await collection.findOne({
|
|
46359
|
+
_id,
|
|
46360
|
+
deletedAt: { $in: ["", null] }
|
|
46361
|
+
});
|
|
46362
|
+
if (!result) {
|
|
46363
|
+
throw new BadRequestError81("track not found.");
|
|
46364
|
+
}
|
|
46365
|
+
setCache(cacheKey, result, 300).then(() => {
|
|
46366
|
+
logger45.log({
|
|
46367
|
+
level: "info",
|
|
46368
|
+
message: `Cache set for getById track: ${cacheKey}`
|
|
46369
|
+
});
|
|
46370
|
+
}).catch((err) => {
|
|
46371
|
+
logger45.log({
|
|
46372
|
+
level: "error",
|
|
46373
|
+
message: `Failed to set cache for getById track: ${err.message}`
|
|
46374
|
+
});
|
|
46375
|
+
});
|
|
46376
|
+
return result;
|
|
46377
|
+
} catch (error) {
|
|
46378
|
+
if (error instanceof AppError31) {
|
|
46379
|
+
throw error;
|
|
46380
|
+
} else {
|
|
46381
|
+
throw new InternalServerError26("Failed to get track.");
|
|
46382
|
+
}
|
|
46383
|
+
}
|
|
46384
|
+
}
|
|
46385
|
+
async function getBySchool(school) {
|
|
46386
|
+
try {
|
|
46387
|
+
school = new ObjectId49(school);
|
|
46388
|
+
} catch (error) {
|
|
46389
|
+
throw new BadRequestError81("Invalid school ID.");
|
|
46390
|
+
}
|
|
46391
|
+
const cacheKey = makeCacheKey26(namespace_collection, {
|
|
46392
|
+
school: school.toString()
|
|
46393
|
+
});
|
|
46394
|
+
logger45.log({
|
|
46395
|
+
level: "info",
|
|
46396
|
+
message: `Cache key for track by school: ${cacheKey}`
|
|
46397
|
+
});
|
|
46398
|
+
try {
|
|
46399
|
+
const cached = await getCache(cacheKey);
|
|
46400
|
+
if (cached) {
|
|
46401
|
+
logger45.log({
|
|
46402
|
+
level: "info",
|
|
46403
|
+
message: `Cache hit for track by school: ${cacheKey}`
|
|
46404
|
+
});
|
|
46405
|
+
return cached;
|
|
46406
|
+
}
|
|
46407
|
+
const result = await collection.find({
|
|
46408
|
+
school,
|
|
46409
|
+
deletedAt: { $in: ["", null] }
|
|
46410
|
+
}).toArray();
|
|
46411
|
+
setCache(cacheKey, result, 300).then(() => {
|
|
46412
|
+
logger45.log({
|
|
46413
|
+
level: "info",
|
|
46414
|
+
message: `Cache set for track by school: ${cacheKey}`
|
|
46415
|
+
});
|
|
46416
|
+
}).catch((err) => {
|
|
46417
|
+
logger45.log({
|
|
46418
|
+
level: "error",
|
|
46419
|
+
message: `Failed to set cache for track by school: ${err.message}`
|
|
46420
|
+
});
|
|
46421
|
+
});
|
|
46422
|
+
return result;
|
|
46423
|
+
} catch (error) {
|
|
46424
|
+
if (error instanceof AppError31) {
|
|
46425
|
+
throw error;
|
|
46426
|
+
} else {
|
|
46427
|
+
throw new InternalServerError26("Failed to get track.");
|
|
46428
|
+
}
|
|
46429
|
+
}
|
|
46430
|
+
}
|
|
46431
|
+
async function updateFieldById({ _id, field, value } = {}, session) {
|
|
46432
|
+
const allowedFields = ["title", "status"];
|
|
46433
|
+
if (!allowedFields.includes(field)) {
|
|
46434
|
+
throw new BadRequestError81(
|
|
46435
|
+
`Field "${field}" is not allowed to be updated.`
|
|
46436
|
+
);
|
|
46437
|
+
}
|
|
46438
|
+
try {
|
|
46439
|
+
_id = new ObjectId49(_id);
|
|
46440
|
+
} catch (error) {
|
|
46441
|
+
throw new BadRequestError81(namespace_collection + " Invalid ID.");
|
|
46442
|
+
}
|
|
46443
|
+
try {
|
|
46444
|
+
await collection.updateOne(
|
|
46445
|
+
{ _id, deletedAt: { $in: ["", null] } },
|
|
46446
|
+
{ $set: { [field]: value, updatedAt: (/* @__PURE__ */ new Date()).toISOString() } },
|
|
46447
|
+
{ session }
|
|
46448
|
+
);
|
|
46449
|
+
delCachedData();
|
|
46450
|
+
return `Successfully updated track ${field}.`;
|
|
46451
|
+
} catch (error) {
|
|
46452
|
+
throw new InternalServerError26(`Failed to update track ${field}.`);
|
|
46453
|
+
}
|
|
46454
|
+
}
|
|
46455
|
+
async function updateById(_id, value, session) {
|
|
46456
|
+
const { error } = schemaTrack.validate(value);
|
|
46457
|
+
if (error) {
|
|
46458
|
+
throw new BadRequestError81(`Invalid track data: ${error.message}`);
|
|
46459
|
+
}
|
|
46460
|
+
try {
|
|
46461
|
+
_id = new ObjectId49(_id);
|
|
46462
|
+
} catch (error2) {
|
|
46463
|
+
throw new BadRequestError81(namespace_collection + " Invalid ID.");
|
|
46464
|
+
}
|
|
46465
|
+
try {
|
|
46466
|
+
await collection.updateOne(
|
|
46467
|
+
{ _id },
|
|
46468
|
+
{ $set: { ...value, updatedAt: (/* @__PURE__ */ new Date()).toISOString() } },
|
|
46469
|
+
{ session }
|
|
46470
|
+
);
|
|
46471
|
+
delCachedData();
|
|
46472
|
+
return `Successfully updated track.`;
|
|
46473
|
+
} catch (error2) {
|
|
46474
|
+
throw new InternalServerError26("Failed to update track.");
|
|
46475
|
+
}
|
|
46476
|
+
}
|
|
46477
|
+
async function deleteById(_id, session) {
|
|
46478
|
+
try {
|
|
46479
|
+
_id = new ObjectId49(_id);
|
|
46480
|
+
} catch (error) {
|
|
46481
|
+
throw new BadRequestError81(namespace_collection + " Invalid ID.");
|
|
46482
|
+
}
|
|
46483
|
+
try {
|
|
46484
|
+
await collection.updateOne(
|
|
46485
|
+
{ _id },
|
|
46486
|
+
{ $set: { status: "deleted", deletedAt: /* @__PURE__ */ new Date() } },
|
|
46487
|
+
{ session }
|
|
46488
|
+
);
|
|
46489
|
+
delCachedData();
|
|
46490
|
+
return "Successfully deleted track.";
|
|
46491
|
+
} catch (error) {
|
|
46492
|
+
throw new InternalServerError26("Failed to delete track.");
|
|
46493
|
+
}
|
|
46494
|
+
}
|
|
46495
|
+
return {
|
|
46496
|
+
createIndexes,
|
|
46497
|
+
add,
|
|
46498
|
+
getAll,
|
|
46499
|
+
getById,
|
|
46500
|
+
getBySchool,
|
|
46501
|
+
updateFieldById,
|
|
46502
|
+
updateById,
|
|
46503
|
+
deleteById
|
|
46504
|
+
};
|
|
46505
|
+
}
|
|
46506
|
+
|
|
46507
|
+
// src/resources/track/track.service.ts
|
|
46508
|
+
import { AppError as AppError33, BadRequestError as BadRequestError84, useAtlas as useAtlas40 } from "@eeplatform/nodejs-utils";
|
|
46509
|
+
|
|
46510
|
+
// src/resources/strand/strand.repository.ts
|
|
46511
|
+
import {
|
|
46512
|
+
AppError as AppError32,
|
|
46513
|
+
BadRequestError as BadRequestError83,
|
|
46514
|
+
InternalServerError as InternalServerError27,
|
|
46515
|
+
logger as logger46,
|
|
46516
|
+
makeCacheKey as makeCacheKey27,
|
|
46517
|
+
paginate as paginate26,
|
|
46518
|
+
useAtlas as useAtlas39,
|
|
46519
|
+
useCache as useCache27
|
|
46520
|
+
} from "@eeplatform/nodejs-utils";
|
|
46521
|
+
|
|
46522
|
+
// src/resources/strand/strand.model.ts
|
|
46523
|
+
import { BadRequestError as BadRequestError82 } from "@eeplatform/nodejs-utils";
|
|
46524
|
+
import Joi53 from "joi";
|
|
46525
|
+
import { ObjectId as ObjectId50 } from "mongodb";
|
|
46526
|
+
var schemaStrand = Joi53.object({
|
|
46527
|
+
track: Joi53.string().hex().required(),
|
|
46528
|
+
trackName: Joi53.string().max(100).optional().allow(null, ""),
|
|
46529
|
+
name: Joi53.string().max(100).required(),
|
|
46530
|
+
school: Joi53.string().hex().required()
|
|
46531
|
+
});
|
|
46532
|
+
function modelStrand(value) {
|
|
46533
|
+
const { error } = schemaStrand.validate(value);
|
|
46534
|
+
if (error) {
|
|
46535
|
+
throw new BadRequestError82(`Invalid strand data: ${error.message}`);
|
|
46536
|
+
}
|
|
46537
|
+
if (value._id && typeof value._id === "string") {
|
|
46538
|
+
try {
|
|
46539
|
+
value._id = new ObjectId50(value._id);
|
|
46540
|
+
} catch (error2) {
|
|
46541
|
+
throw new Error("Invalid _id.");
|
|
46542
|
+
}
|
|
46543
|
+
}
|
|
46544
|
+
if (value.school && typeof value.school === "string") {
|
|
46545
|
+
try {
|
|
46546
|
+
value.school = new ObjectId50(value.school);
|
|
46547
|
+
} catch (error2) {
|
|
46548
|
+
throw new Error("Invalid school.");
|
|
46549
|
+
}
|
|
46550
|
+
}
|
|
46551
|
+
if (value.track && typeof value.track === "string") {
|
|
46552
|
+
try {
|
|
46553
|
+
value.track = new ObjectId50(value.track);
|
|
46554
|
+
} catch (error2) {
|
|
46555
|
+
throw new Error("Invalid track.");
|
|
46556
|
+
}
|
|
46557
|
+
}
|
|
46558
|
+
return {
|
|
46559
|
+
_id: value._id,
|
|
46560
|
+
track: value.track,
|
|
46561
|
+
trackName: value.trackName ?? "",
|
|
46562
|
+
name: value.name,
|
|
46563
|
+
school: value.school,
|
|
46564
|
+
status: value.status ?? "active",
|
|
46565
|
+
createdAt: value.createdAt ?? /* @__PURE__ */ new Date(),
|
|
46566
|
+
updatedAt: value.updatedAt ?? "",
|
|
46567
|
+
deletedAt: value.deletedAt ?? ""
|
|
46568
|
+
};
|
|
46569
|
+
}
|
|
46570
|
+
|
|
46571
|
+
// src/resources/strand/strand.repository.ts
|
|
46572
|
+
import { ObjectId as ObjectId51 } from "mongodb";
|
|
46573
|
+
function useStrandRepo() {
|
|
46574
|
+
const db = useAtlas39.getDb();
|
|
46575
|
+
if (!db) {
|
|
46576
|
+
throw new Error("Unable to connect to server.");
|
|
46577
|
+
}
|
|
46578
|
+
const namespace_collection = "deped.school.strands";
|
|
46579
|
+
const collection = db.collection(namespace_collection);
|
|
46580
|
+
const { getCache, setCache, delNamespace } = useCache27(namespace_collection);
|
|
46581
|
+
async function createIndexes() {
|
|
46582
|
+
try {
|
|
46583
|
+
await collection.createIndexes([
|
|
46584
|
+
{ key: { school: 1 } },
|
|
46585
|
+
{ key: { strand: 1 } },
|
|
46586
|
+
{ key: { name: "text", strand: "text" } },
|
|
46587
|
+
{
|
|
46588
|
+
key: { name: 1, strand: 1, school: 1, status: 1 },
|
|
46589
|
+
unique: true,
|
|
46590
|
+
name: "unique_strand"
|
|
46591
|
+
}
|
|
46592
|
+
]);
|
|
46593
|
+
} catch (error) {
|
|
46594
|
+
throw new Error("Failed to create index on strands.");
|
|
46595
|
+
}
|
|
46596
|
+
}
|
|
46597
|
+
function delCachedData() {
|
|
46598
|
+
delNamespace().then(() => {
|
|
46599
|
+
logger46.log({
|
|
46600
|
+
level: "info",
|
|
46601
|
+
message: `Cache namespace cleared for ${namespace_collection}`
|
|
46602
|
+
});
|
|
46603
|
+
}).catch((err) => {
|
|
46604
|
+
logger46.log({
|
|
46605
|
+
level: "error",
|
|
46606
|
+
message: `Failed to clear cache namespace for ${namespace_collection}: ${err.message}`
|
|
46607
|
+
});
|
|
46608
|
+
});
|
|
46609
|
+
}
|
|
46610
|
+
async function add(value, session) {
|
|
46611
|
+
try {
|
|
46612
|
+
value = modelStrand(value);
|
|
46613
|
+
const res = await collection.insertOne(value, { session });
|
|
46614
|
+
delCachedData();
|
|
46615
|
+
return res.insertedId;
|
|
46616
|
+
} catch (error) {
|
|
46617
|
+
logger46.log({
|
|
46618
|
+
level: "error",
|
|
46619
|
+
message: error.message
|
|
46620
|
+
});
|
|
46621
|
+
if (error instanceof AppError32) {
|
|
46622
|
+
throw error;
|
|
46623
|
+
} else {
|
|
46624
|
+
const isDuplicated = error.message.includes("duplicate");
|
|
46625
|
+
if (isDuplicated) {
|
|
46626
|
+
throw new BadRequestError83("Strand already exists.");
|
|
46627
|
+
}
|
|
46628
|
+
throw new Error("Failed to create strand.");
|
|
46629
|
+
}
|
|
46630
|
+
}
|
|
46631
|
+
}
|
|
46632
|
+
async function getAll({
|
|
46633
|
+
search = "",
|
|
46634
|
+
page = 1,
|
|
46635
|
+
limit = 10,
|
|
46636
|
+
sort = {},
|
|
46637
|
+
status = "active",
|
|
46638
|
+
school = ""
|
|
46639
|
+
} = {}) {
|
|
46640
|
+
page = page > 0 ? page - 1 : 0;
|
|
46641
|
+
const query = {
|
|
46642
|
+
deletedAt: { $in: ["", null] },
|
|
46643
|
+
status
|
|
46644
|
+
};
|
|
46645
|
+
sort = Object.keys(sort).length > 0 ? sort : { _id: 1 };
|
|
46646
|
+
const cacheKeyOptions = {
|
|
46647
|
+
status,
|
|
46648
|
+
page,
|
|
46649
|
+
limit,
|
|
46650
|
+
sort: JSON.stringify(sort)
|
|
46651
|
+
};
|
|
46652
|
+
if (search) {
|
|
46653
|
+
query.$text = { $search: search };
|
|
46654
|
+
cacheKeyOptions.search = search;
|
|
46655
|
+
}
|
|
46656
|
+
if (school) {
|
|
46657
|
+
try {
|
|
46658
|
+
query.school = new ObjectId51(school);
|
|
46659
|
+
} catch (error) {
|
|
46660
|
+
throw new BadRequestError83("Invalid school ID.");
|
|
46661
|
+
}
|
|
46662
|
+
cacheKeyOptions.school = school;
|
|
46663
|
+
}
|
|
46664
|
+
const cacheKey = makeCacheKey27(namespace_collection, cacheKeyOptions);
|
|
46665
|
+
logger46.log({
|
|
46666
|
+
level: "info",
|
|
46667
|
+
message: `Cache key for getAll strands: ${cacheKey}`
|
|
46668
|
+
});
|
|
46669
|
+
try {
|
|
46670
|
+
const cached = await getCache(cacheKey);
|
|
46671
|
+
if (cached) {
|
|
46672
|
+
logger46.log({
|
|
46673
|
+
level: "info",
|
|
46674
|
+
message: `Cache hit for getAll strands: ${cacheKey}`
|
|
46675
|
+
});
|
|
46676
|
+
return cached;
|
|
46677
|
+
}
|
|
46678
|
+
const items = await collection.aggregate([
|
|
46679
|
+
{ $match: query },
|
|
46680
|
+
{ $sort: sort },
|
|
46681
|
+
{ $skip: page * limit },
|
|
46682
|
+
{ $limit: limit }
|
|
46683
|
+
]).toArray();
|
|
46684
|
+
const total = await collection.countDocuments(query);
|
|
46685
|
+
const result = paginate26(items, total, page, limit);
|
|
46686
|
+
setCache(cacheKey, result, 300).then(() => {
|
|
46687
|
+
logger46.log({
|
|
46688
|
+
level: "info",
|
|
46689
|
+
message: `Cache set for getAll strands: ${cacheKey}`
|
|
46690
|
+
});
|
|
46691
|
+
}).catch((err) => {
|
|
46692
|
+
logger46.log({
|
|
46693
|
+
level: "error",
|
|
46694
|
+
message: `Failed to set cache for getAll strands: ${err.message}`
|
|
46695
|
+
});
|
|
46696
|
+
});
|
|
46697
|
+
return result;
|
|
46698
|
+
} catch (error) {
|
|
46699
|
+
if (error instanceof AppError32) {
|
|
46700
|
+
throw error;
|
|
46701
|
+
} else {
|
|
46702
|
+
throw new InternalServerError27("Failed to get strands.");
|
|
46703
|
+
}
|
|
46704
|
+
}
|
|
46705
|
+
}
|
|
46706
|
+
async function getById(_id) {
|
|
46707
|
+
try {
|
|
46708
|
+
_id = new ObjectId51(_id);
|
|
46709
|
+
} catch (error) {
|
|
46710
|
+
throw new BadRequestError83(namespace_collection + " Invalid ID.");
|
|
46711
|
+
}
|
|
46712
|
+
const cacheKey = makeCacheKey27(namespace_collection, {
|
|
46713
|
+
_id: _id.toString()
|
|
46714
|
+
});
|
|
46715
|
+
logger46.log({
|
|
46716
|
+
level: "info",
|
|
46717
|
+
message: `Cache key for getById strand: ${cacheKey}`
|
|
46718
|
+
});
|
|
46719
|
+
try {
|
|
46720
|
+
const cached = await getCache(cacheKey);
|
|
46721
|
+
if (cached) {
|
|
46722
|
+
logger46.log({
|
|
46723
|
+
level: "info",
|
|
46724
|
+
message: `Cache hit for getById strand: ${cacheKey}`
|
|
46725
|
+
});
|
|
46726
|
+
return cached;
|
|
46727
|
+
}
|
|
46728
|
+
const result = await collection.findOne({
|
|
46729
|
+
_id,
|
|
46730
|
+
deletedAt: { $in: ["", null] }
|
|
46731
|
+
});
|
|
46732
|
+
if (!result) {
|
|
46733
|
+
throw new BadRequestError83("strand not found.");
|
|
46734
|
+
}
|
|
46735
|
+
setCache(cacheKey, result, 300).then(() => {
|
|
46736
|
+
logger46.log({
|
|
46737
|
+
level: "info",
|
|
46738
|
+
message: `Cache set for getById strand: ${cacheKey}`
|
|
46739
|
+
});
|
|
46740
|
+
}).catch((err) => {
|
|
46741
|
+
logger46.log({
|
|
46742
|
+
level: "error",
|
|
46743
|
+
message: `Failed to set cache for getById strand: ${err.message}`
|
|
46744
|
+
});
|
|
46745
|
+
});
|
|
46746
|
+
return result;
|
|
46747
|
+
} catch (error) {
|
|
46748
|
+
if (error instanceof AppError32) {
|
|
46749
|
+
throw error;
|
|
46750
|
+
} else {
|
|
46751
|
+
throw new InternalServerError27("Failed to get strand.");
|
|
46752
|
+
}
|
|
46753
|
+
}
|
|
46754
|
+
}
|
|
46755
|
+
async function getBySchool(school) {
|
|
46756
|
+
try {
|
|
46757
|
+
school = new ObjectId51(school);
|
|
46758
|
+
} catch (error) {
|
|
46759
|
+
throw new BadRequestError83("Invalid school ID.");
|
|
46760
|
+
}
|
|
46761
|
+
const cacheKey = makeCacheKey27(namespace_collection, {
|
|
46762
|
+
school: school.toString()
|
|
46763
|
+
});
|
|
46764
|
+
logger46.log({
|
|
46765
|
+
level: "info",
|
|
46766
|
+
message: `Cache key for strand by school: ${cacheKey}`
|
|
46767
|
+
});
|
|
46768
|
+
try {
|
|
46769
|
+
const cached = await getCache(cacheKey);
|
|
46770
|
+
if (cached) {
|
|
46771
|
+
logger46.log({
|
|
46772
|
+
level: "info",
|
|
46773
|
+
message: `Cache hit for strand by school: ${cacheKey}`
|
|
46774
|
+
});
|
|
46775
|
+
return cached;
|
|
46776
|
+
}
|
|
46777
|
+
const result = await collection.find({
|
|
46778
|
+
school,
|
|
46779
|
+
deletedAt: { $in: ["", null] }
|
|
46780
|
+
}).toArray();
|
|
46781
|
+
setCache(cacheKey, result, 300).then(() => {
|
|
46782
|
+
logger46.log({
|
|
46783
|
+
level: "info",
|
|
46784
|
+
message: `Cache set for strand by school: ${cacheKey}`
|
|
46785
|
+
});
|
|
46786
|
+
}).catch((err) => {
|
|
46787
|
+
logger46.log({
|
|
46788
|
+
level: "error",
|
|
46789
|
+
message: `Failed to set cache for strand by school: ${err.message}`
|
|
46790
|
+
});
|
|
46791
|
+
});
|
|
46792
|
+
return result;
|
|
46793
|
+
} catch (error) {
|
|
46794
|
+
if (error instanceof AppError32) {
|
|
46795
|
+
throw error;
|
|
46796
|
+
} else {
|
|
46797
|
+
throw new InternalServerError27("Failed to get strand.");
|
|
46798
|
+
}
|
|
46799
|
+
}
|
|
46800
|
+
}
|
|
46801
|
+
async function updateFieldById({ _id, field, value } = {}, session) {
|
|
46802
|
+
const allowedFields = ["title", "status"];
|
|
46803
|
+
if (!allowedFields.includes(field)) {
|
|
46804
|
+
throw new BadRequestError83(
|
|
46805
|
+
`Field "${field}" is not allowed to be updated.`
|
|
46806
|
+
);
|
|
46807
|
+
}
|
|
46808
|
+
try {
|
|
46809
|
+
_id = new ObjectId51(_id);
|
|
46810
|
+
} catch (error) {
|
|
46811
|
+
throw new BadRequestError83(namespace_collection + " Invalid ID.");
|
|
46812
|
+
}
|
|
46813
|
+
try {
|
|
46814
|
+
await collection.updateOne(
|
|
46815
|
+
{ _id, deletedAt: { $in: ["", null] } },
|
|
46816
|
+
{ $set: { [field]: value, updatedAt: (/* @__PURE__ */ new Date()).toISOString() } },
|
|
46817
|
+
{ session }
|
|
46818
|
+
);
|
|
46819
|
+
delCachedData();
|
|
46820
|
+
return `Successfully updated strand ${field}.`;
|
|
46821
|
+
} catch (error) {
|
|
46822
|
+
throw new InternalServerError27(`Failed to update strand ${field}.`);
|
|
46823
|
+
}
|
|
46824
|
+
}
|
|
46825
|
+
async function updateById(_id, value, session) {
|
|
46826
|
+
const { error } = schemaStrand.validate(value);
|
|
46827
|
+
if (error) {
|
|
46828
|
+
throw new BadRequestError83(`Invalid strand data: ${error.message}`);
|
|
46829
|
+
}
|
|
46830
|
+
try {
|
|
46831
|
+
_id = new ObjectId51(_id);
|
|
46832
|
+
} catch (error2) {
|
|
46833
|
+
throw new BadRequestError83(namespace_collection + " Invalid ID.");
|
|
46834
|
+
}
|
|
46835
|
+
try {
|
|
46836
|
+
await collection.updateOne(
|
|
46837
|
+
{ _id },
|
|
46838
|
+
{ $set: { ...value, updatedAt: (/* @__PURE__ */ new Date()).toISOString() } },
|
|
46839
|
+
{ session }
|
|
46840
|
+
);
|
|
46841
|
+
delCachedData();
|
|
46842
|
+
return `Successfully updated strand.`;
|
|
46843
|
+
} catch (error2) {
|
|
46844
|
+
throw new InternalServerError27("Failed to update strand.");
|
|
46845
|
+
}
|
|
46846
|
+
}
|
|
46847
|
+
async function deleteById(_id, session) {
|
|
46848
|
+
try {
|
|
46849
|
+
_id = new ObjectId51(_id);
|
|
46850
|
+
} catch (error) {
|
|
46851
|
+
throw new BadRequestError83(namespace_collection + " Invalid ID.");
|
|
46852
|
+
}
|
|
46853
|
+
try {
|
|
46854
|
+
await collection.updateOne(
|
|
46855
|
+
{ _id },
|
|
46856
|
+
{ $set: { status: "deleted", deletedAt: (/* @__PURE__ */ new Date()).toISOString() } },
|
|
46857
|
+
{ session }
|
|
46858
|
+
);
|
|
46859
|
+
delCachedData();
|
|
46860
|
+
return "Successfully deleted strand.";
|
|
46861
|
+
} catch (error) {
|
|
46862
|
+
throw new InternalServerError27("Failed to delete strand.");
|
|
46863
|
+
}
|
|
46864
|
+
}
|
|
46865
|
+
async function countByTrack(track) {
|
|
46866
|
+
const query = { status: { $ne: "deleted" } };
|
|
46867
|
+
const cacheKeyOptions = { tag: "countByTrack" };
|
|
46868
|
+
try {
|
|
46869
|
+
query.track = new ObjectId51(track);
|
|
46870
|
+
cacheKeyOptions.track = track;
|
|
46871
|
+
} catch (error) {
|
|
46872
|
+
throw new BadRequestError83("Invalid track ID.");
|
|
46873
|
+
}
|
|
46874
|
+
const cacheKey = makeCacheKey27(namespace_collection, cacheKeyOptions);
|
|
46875
|
+
try {
|
|
46876
|
+
const cached = await getCache(cacheKey);
|
|
46877
|
+
if (cached) {
|
|
46878
|
+
logger46.log({
|
|
46879
|
+
level: "info",
|
|
46880
|
+
message: `Cache hit for getById strand: ${cacheKey}`
|
|
46881
|
+
});
|
|
46882
|
+
return cached;
|
|
46883
|
+
}
|
|
46884
|
+
const result = await collection.countDocuments(query);
|
|
46885
|
+
setCache(cacheKey, result, 300).then(() => {
|
|
46886
|
+
logger46.log({
|
|
46887
|
+
level: "info",
|
|
46888
|
+
message: `Cache set for strand by id: ${cacheKey}`
|
|
46889
|
+
});
|
|
46890
|
+
}).catch((err) => {
|
|
46891
|
+
logger46.log({
|
|
46892
|
+
level: "error",
|
|
46893
|
+
message: `Failed to set cache for strand by id: ${err.message}`
|
|
46894
|
+
});
|
|
46895
|
+
});
|
|
46896
|
+
return result;
|
|
46897
|
+
} catch (error) {
|
|
46898
|
+
if (error instanceof AppError32) {
|
|
46899
|
+
throw error;
|
|
46900
|
+
} else {
|
|
46901
|
+
throw new InternalServerError27("Failed to get strand.");
|
|
46902
|
+
}
|
|
46903
|
+
}
|
|
46904
|
+
}
|
|
46905
|
+
return {
|
|
46906
|
+
createIndexes,
|
|
46907
|
+
add,
|
|
46908
|
+
getAll,
|
|
46909
|
+
getById,
|
|
46910
|
+
getBySchool,
|
|
46911
|
+
updateFieldById,
|
|
46912
|
+
updateById,
|
|
46913
|
+
deleteById,
|
|
46914
|
+
countByTrack
|
|
46915
|
+
};
|
|
46916
|
+
}
|
|
46917
|
+
|
|
46918
|
+
// src/resources/track/track.service.ts
|
|
46919
|
+
function useTrackService() {
|
|
46920
|
+
const { add: _add, deleteById: _deleteById, getById } = useTrackRepo();
|
|
46921
|
+
const { countByTrack } = useStrandRepo();
|
|
46922
|
+
async function deleteById(id) {
|
|
46923
|
+
const session = useAtlas40.getClient()?.startSession();
|
|
46924
|
+
if (!session) {
|
|
46925
|
+
throw new Error("Failed to start database session.");
|
|
46926
|
+
}
|
|
46927
|
+
try {
|
|
46928
|
+
session.startTransaction();
|
|
46929
|
+
const track = await getById(id);
|
|
46930
|
+
if (!track) {
|
|
46931
|
+
throw new BadRequestError84("track not found.");
|
|
46932
|
+
}
|
|
46933
|
+
const usageCount = await countByTrack(id);
|
|
46934
|
+
if (usageCount > 0) {
|
|
46935
|
+
throw new BadRequestError84(
|
|
46936
|
+
"Cannot delete track as it is currently in use."
|
|
46937
|
+
);
|
|
46938
|
+
}
|
|
46939
|
+
const message = await _deleteById(id, session);
|
|
46940
|
+
await session.commitTransaction();
|
|
46941
|
+
return message;
|
|
46942
|
+
} catch (error) {
|
|
46943
|
+
await session.abortTransaction();
|
|
46944
|
+
if (error instanceof AppError33) {
|
|
46945
|
+
throw error;
|
|
46946
|
+
} else {
|
|
46947
|
+
throw new AppError33("Failed to delete track.", 500);
|
|
46948
|
+
}
|
|
46949
|
+
} finally {
|
|
46950
|
+
await session.endSession();
|
|
46951
|
+
}
|
|
46952
|
+
}
|
|
46953
|
+
return {
|
|
46954
|
+
deleteById
|
|
46955
|
+
};
|
|
46956
|
+
}
|
|
46957
|
+
|
|
46958
|
+
// src/resources/track/track.controller.ts
|
|
46959
|
+
import { BadRequestError as BadRequestError85 } from "@eeplatform/nodejs-utils";
|
|
46960
|
+
import Joi54 from "joi";
|
|
46961
|
+
function useTrackController() {
|
|
46962
|
+
const {
|
|
46963
|
+
add: _add,
|
|
46964
|
+
getAll: _getAll,
|
|
46965
|
+
getById: _getById,
|
|
46966
|
+
getBySchool: _getBySchool,
|
|
46967
|
+
updateFieldById: _updateFieldById
|
|
46968
|
+
} = useTrackRepo();
|
|
46969
|
+
async function add(req, res, next) {
|
|
46970
|
+
const value = req.body;
|
|
46971
|
+
const { error } = schemaTrack.validate(value);
|
|
46972
|
+
if (error) {
|
|
46973
|
+
next(new BadRequestError85(error.message));
|
|
46974
|
+
return;
|
|
46975
|
+
}
|
|
46976
|
+
try {
|
|
46977
|
+
const data = await _add(value);
|
|
46978
|
+
res.json({
|
|
46979
|
+
message: "Successfully created track.",
|
|
46980
|
+
data
|
|
46981
|
+
});
|
|
46982
|
+
return;
|
|
46983
|
+
} catch (error2) {
|
|
46984
|
+
next(error2);
|
|
46985
|
+
}
|
|
46986
|
+
}
|
|
46987
|
+
async function getAll(req, res, next) {
|
|
46988
|
+
const query = req.query;
|
|
46989
|
+
const validation = Joi54.object({
|
|
46990
|
+
page: Joi54.number().min(1).optional().allow("", null),
|
|
46991
|
+
limit: Joi54.number().min(1).optional().allow("", null),
|
|
46992
|
+
search: Joi54.string().optional().allow("", null),
|
|
46993
|
+
status: Joi54.string().optional().allow("", null),
|
|
46994
|
+
school: Joi54.string().hex().optional().allow("", null)
|
|
46995
|
+
});
|
|
46996
|
+
const { error } = validation.validate(query);
|
|
46997
|
+
const page = typeof req.query.page === "string" ? Number(req.query.page) : 1;
|
|
46998
|
+
const limit = typeof req.query.limit === "string" ? Number(req.query.limit) : 10;
|
|
46999
|
+
const search = req.query.search ?? "";
|
|
47000
|
+
const status = req.query.status ?? "active";
|
|
47001
|
+
const school = req.query.school ?? "";
|
|
47002
|
+
const isPageNumber = isFinite(page);
|
|
47003
|
+
if (!isPageNumber) {
|
|
47004
|
+
next(new BadRequestError85("Invalid page number."));
|
|
47005
|
+
return;
|
|
47006
|
+
}
|
|
47007
|
+
const isLimitNumber = isFinite(limit);
|
|
47008
|
+
if (!isLimitNumber) {
|
|
47009
|
+
next(new BadRequestError85("Invalid limit number."));
|
|
47010
|
+
return;
|
|
47011
|
+
}
|
|
47012
|
+
if (error) {
|
|
47013
|
+
next(new BadRequestError85(error.message));
|
|
47014
|
+
return;
|
|
47015
|
+
}
|
|
47016
|
+
try {
|
|
47017
|
+
const data = await _getAll({
|
|
47018
|
+
page,
|
|
47019
|
+
limit,
|
|
47020
|
+
search,
|
|
47021
|
+
status,
|
|
47022
|
+
school
|
|
47023
|
+
});
|
|
47024
|
+
res.json(data);
|
|
47025
|
+
return;
|
|
47026
|
+
} catch (error2) {
|
|
47027
|
+
next(error2);
|
|
47028
|
+
}
|
|
47029
|
+
}
|
|
47030
|
+
async function getById(req, res, next) {
|
|
47031
|
+
const id = req.params.id;
|
|
47032
|
+
const validation = Joi54.object({
|
|
47033
|
+
id: Joi54.string().hex().required()
|
|
47034
|
+
});
|
|
47035
|
+
const { error } = validation.validate({ id });
|
|
47036
|
+
if (error) {
|
|
47037
|
+
next(new BadRequestError85(error.message));
|
|
47038
|
+
return;
|
|
47039
|
+
}
|
|
47040
|
+
try {
|
|
47041
|
+
const data = await _getById(id);
|
|
47042
|
+
res.json({
|
|
47043
|
+
message: "Successfully retrieved kindergarten domain.",
|
|
47044
|
+
data
|
|
47045
|
+
});
|
|
47046
|
+
return;
|
|
47047
|
+
} catch (error2) {
|
|
47048
|
+
next(error2);
|
|
47049
|
+
}
|
|
47050
|
+
}
|
|
47051
|
+
async function getBySchool(req, res, next) {
|
|
47052
|
+
const school = req.params.school;
|
|
47053
|
+
const validation = Joi54.object({
|
|
47054
|
+
school: Joi54.string().hex().required()
|
|
47055
|
+
});
|
|
47056
|
+
const { error } = validation.validate({ school });
|
|
47057
|
+
if (error) {
|
|
47058
|
+
next(new BadRequestError85(error.message));
|
|
47059
|
+
return;
|
|
47060
|
+
}
|
|
47061
|
+
try {
|
|
47062
|
+
const data = await _getBySchool(school);
|
|
47063
|
+
res.json({
|
|
47064
|
+
message: "Successfully retrieved kindergarten domains.",
|
|
47065
|
+
data
|
|
47066
|
+
});
|
|
47067
|
+
return;
|
|
47068
|
+
} catch (error2) {
|
|
47069
|
+
next(error2);
|
|
47070
|
+
}
|
|
47071
|
+
}
|
|
47072
|
+
async function updateField(req, res, next) {
|
|
47073
|
+
const _id = req.params.id;
|
|
47074
|
+
const { field, value } = req.body;
|
|
47075
|
+
const validation = Joi54.object({
|
|
47076
|
+
_id: Joi54.string().hex().required(),
|
|
47077
|
+
field: Joi54.string().valid("name").required(),
|
|
47078
|
+
value: Joi54.alternatives().try(Joi54.string(), Joi54.array(), Joi54.object()).required()
|
|
47079
|
+
});
|
|
47080
|
+
const { error } = validation.validate({ _id, field, value });
|
|
47081
|
+
if (error) {
|
|
47082
|
+
next(new BadRequestError85(error.message));
|
|
47083
|
+
return;
|
|
47084
|
+
}
|
|
47085
|
+
try {
|
|
47086
|
+
const message = await _updateFieldById({ _id, field, value });
|
|
47087
|
+
res.json({ message });
|
|
47088
|
+
return;
|
|
47089
|
+
} catch (error2) {
|
|
47090
|
+
next(error2);
|
|
47091
|
+
}
|
|
47092
|
+
}
|
|
47093
|
+
const { deleteById: _deleteById } = useTrackService();
|
|
47094
|
+
async function deleteById(req, res, next) {
|
|
47095
|
+
const id = req.params.id;
|
|
47096
|
+
const validation = Joi54.object({
|
|
47097
|
+
id: Joi54.string().hex().required()
|
|
47098
|
+
});
|
|
47099
|
+
const { error } = validation.validate({ id });
|
|
47100
|
+
if (error) {
|
|
47101
|
+
next(new BadRequestError85(error.message));
|
|
47102
|
+
return;
|
|
47103
|
+
}
|
|
47104
|
+
try {
|
|
47105
|
+
const message = await _deleteById(id);
|
|
47106
|
+
res.json({ message });
|
|
47107
|
+
return;
|
|
47108
|
+
} catch (error2) {
|
|
47109
|
+
next(error2);
|
|
47110
|
+
}
|
|
47111
|
+
}
|
|
47112
|
+
return {
|
|
47113
|
+
add,
|
|
47114
|
+
getAll,
|
|
47115
|
+
getById,
|
|
47116
|
+
getBySchool,
|
|
47117
|
+
updateField,
|
|
47118
|
+
deleteById
|
|
47119
|
+
};
|
|
47120
|
+
}
|
|
47121
|
+
|
|
47122
|
+
// src/resources/strand/strand.controller.ts
|
|
47123
|
+
import { BadRequestError as BadRequestError86 } from "@eeplatform/nodejs-utils";
|
|
47124
|
+
import Joi55 from "joi";
|
|
47125
|
+
function useStrandController() {
|
|
47126
|
+
const {
|
|
47127
|
+
add: _add,
|
|
47128
|
+
getAll: _getAll,
|
|
47129
|
+
getById: _getById,
|
|
47130
|
+
getBySchool: _getBySchool,
|
|
47131
|
+
updateFieldById: _updateFieldById,
|
|
47132
|
+
deleteById: _deleteById
|
|
47133
|
+
} = useStrandRepo();
|
|
47134
|
+
async function add(req, res, next) {
|
|
47135
|
+
const value = req.body;
|
|
47136
|
+
const { error } = schemaStrand.validate(value);
|
|
47137
|
+
if (error) {
|
|
47138
|
+
next(new BadRequestError86(error.message));
|
|
47139
|
+
return;
|
|
47140
|
+
}
|
|
47141
|
+
try {
|
|
47142
|
+
const data = await _add(value);
|
|
47143
|
+
res.json({
|
|
47144
|
+
message: "Successfully created kindergarten domain.",
|
|
47145
|
+
data
|
|
47146
|
+
});
|
|
47147
|
+
return;
|
|
47148
|
+
} catch (error2) {
|
|
47149
|
+
next(error2);
|
|
47150
|
+
}
|
|
47151
|
+
}
|
|
47152
|
+
async function getAll(req, res, next) {
|
|
47153
|
+
const query = req.query;
|
|
47154
|
+
const validation = Joi55.object({
|
|
47155
|
+
page: Joi55.number().min(1).optional().allow("", null),
|
|
47156
|
+
limit: Joi55.number().min(1).optional().allow("", null),
|
|
47157
|
+
search: Joi55.string().optional().allow("", null),
|
|
47158
|
+
status: Joi55.string().optional().allow("", null),
|
|
47159
|
+
school: Joi55.string().hex().optional().allow("", null)
|
|
47160
|
+
});
|
|
47161
|
+
const { error } = validation.validate(query);
|
|
47162
|
+
const page = typeof req.query.page === "string" ? Number(req.query.page) : 1;
|
|
47163
|
+
const limit = typeof req.query.limit === "string" ? Number(req.query.limit) : 10;
|
|
47164
|
+
const search = req.query.search ?? "";
|
|
47165
|
+
const status = req.query.status ?? "active";
|
|
47166
|
+
const school = req.query.school ?? "";
|
|
47167
|
+
const isPageNumber = isFinite(page);
|
|
47168
|
+
if (!isPageNumber) {
|
|
47169
|
+
next(new BadRequestError86("Invalid page number."));
|
|
47170
|
+
return;
|
|
47171
|
+
}
|
|
47172
|
+
const isLimitNumber = isFinite(limit);
|
|
47173
|
+
if (!isLimitNumber) {
|
|
47174
|
+
next(new BadRequestError86("Invalid limit number."));
|
|
47175
|
+
return;
|
|
47176
|
+
}
|
|
47177
|
+
if (error) {
|
|
47178
|
+
next(new BadRequestError86(error.message));
|
|
47179
|
+
return;
|
|
47180
|
+
}
|
|
47181
|
+
try {
|
|
47182
|
+
const data = await _getAll({
|
|
47183
|
+
page,
|
|
47184
|
+
limit,
|
|
47185
|
+
search,
|
|
47186
|
+
status,
|
|
47187
|
+
school
|
|
47188
|
+
});
|
|
47189
|
+
res.json(data);
|
|
47190
|
+
return;
|
|
47191
|
+
} catch (error2) {
|
|
47192
|
+
next(error2);
|
|
47193
|
+
}
|
|
47194
|
+
}
|
|
47195
|
+
async function getById(req, res, next) {
|
|
47196
|
+
const id = req.params.id;
|
|
47197
|
+
const validation = Joi55.object({
|
|
47198
|
+
id: Joi55.string().hex().required()
|
|
47199
|
+
});
|
|
47200
|
+
const { error } = validation.validate({ id });
|
|
47201
|
+
if (error) {
|
|
47202
|
+
next(new BadRequestError86(error.message));
|
|
47203
|
+
return;
|
|
47204
|
+
}
|
|
47205
|
+
try {
|
|
47206
|
+
const data = await _getById(id);
|
|
47207
|
+
res.json({
|
|
47208
|
+
message: "Successfully retrieved kindergarten domain.",
|
|
47209
|
+
data
|
|
47210
|
+
});
|
|
47211
|
+
return;
|
|
47212
|
+
} catch (error2) {
|
|
47213
|
+
next(error2);
|
|
47214
|
+
}
|
|
47215
|
+
}
|
|
47216
|
+
async function getBySchool(req, res, next) {
|
|
47217
|
+
const school = req.params.school;
|
|
47218
|
+
const validation = Joi55.object({
|
|
47219
|
+
school: Joi55.string().hex().required()
|
|
47220
|
+
});
|
|
47221
|
+
const { error } = validation.validate({ school });
|
|
47222
|
+
if (error) {
|
|
47223
|
+
next(new BadRequestError86(error.message));
|
|
47224
|
+
return;
|
|
47225
|
+
}
|
|
47226
|
+
try {
|
|
47227
|
+
const data = await _getBySchool(school);
|
|
47228
|
+
res.json({
|
|
47229
|
+
message: "Successfully retrieved strand.",
|
|
47230
|
+
data
|
|
47231
|
+
});
|
|
47232
|
+
return;
|
|
47233
|
+
} catch (error2) {
|
|
47234
|
+
next(error2);
|
|
47235
|
+
}
|
|
47236
|
+
}
|
|
47237
|
+
async function updateField(req, res, next) {
|
|
47238
|
+
const _id = req.params.id;
|
|
47239
|
+
const { field, value } = req.body;
|
|
47240
|
+
const validation = Joi55.object({
|
|
47241
|
+
_id: Joi55.string().hex().required(),
|
|
47242
|
+
field: Joi55.string().valid("title", "status").required(),
|
|
47243
|
+
value: Joi55.alternatives().try(Joi55.string(), Joi55.array(), Joi55.object()).required()
|
|
47244
|
+
});
|
|
47245
|
+
const { error } = validation.validate({ _id, field, value });
|
|
47246
|
+
if (error) {
|
|
47247
|
+
next(new BadRequestError86(error.message));
|
|
47248
|
+
return;
|
|
47249
|
+
}
|
|
47250
|
+
try {
|
|
47251
|
+
const message = await _updateFieldById({ _id, field, value });
|
|
47252
|
+
res.json({ message });
|
|
47253
|
+
return;
|
|
47254
|
+
} catch (error2) {
|
|
47255
|
+
next(error2);
|
|
47256
|
+
}
|
|
47257
|
+
}
|
|
47258
|
+
async function deleteById(req, res, next) {
|
|
47259
|
+
const _id = req.params.id;
|
|
47260
|
+
const validation = Joi55.object({
|
|
47261
|
+
_id: Joi55.string().hex().required()
|
|
47262
|
+
});
|
|
47263
|
+
const { error } = validation.validate({ _id });
|
|
47264
|
+
if (error) {
|
|
47265
|
+
next(new BadRequestError86(error.message));
|
|
47266
|
+
return;
|
|
47267
|
+
}
|
|
47268
|
+
try {
|
|
47269
|
+
const message = await _deleteById(_id);
|
|
47270
|
+
res.json({ message });
|
|
47271
|
+
return;
|
|
47272
|
+
} catch (error2) {
|
|
47273
|
+
next(error2);
|
|
47274
|
+
}
|
|
47275
|
+
}
|
|
47276
|
+
return {
|
|
47277
|
+
add,
|
|
47278
|
+
getAll,
|
|
47279
|
+
getById,
|
|
47280
|
+
getBySchool,
|
|
47281
|
+
updateField,
|
|
47282
|
+
deleteById
|
|
47283
|
+
};
|
|
47284
|
+
}
|
|
47285
|
+
|
|
46172
47286
|
// src/config.ts
|
|
46173
47287
|
import * as dotenv from "dotenv";
|
|
46174
47288
|
dotenv.config();
|
|
@@ -46195,9 +47309,11 @@ export {
|
|
|
46195
47309
|
modelSectionPreset,
|
|
46196
47310
|
modelSectionStudent,
|
|
46197
47311
|
modelSectionSubject,
|
|
47312
|
+
modelStrand,
|
|
46198
47313
|
modelSubject,
|
|
46199
47314
|
modelTeachingLoad,
|
|
46200
47315
|
modelTeachingLoadSlot,
|
|
47316
|
+
modelTrack,
|
|
46201
47317
|
schemaAsset,
|
|
46202
47318
|
schemaAssetUpdateOption,
|
|
46203
47319
|
schemaBasicEduCount,
|
|
@@ -46227,10 +47343,12 @@ export {
|
|
|
46227
47343
|
schemaSectionSubject,
|
|
46228
47344
|
schemaSectionSubjectSetup,
|
|
46229
47345
|
schemaStockCard,
|
|
47346
|
+
schemaStrand,
|
|
46230
47347
|
schemaSubject,
|
|
46231
47348
|
schemaSubjectAdd,
|
|
46232
47349
|
schemaTeachingLoad,
|
|
46233
47350
|
schemaTeachingLoadSlot,
|
|
47351
|
+
schemaTrack,
|
|
46234
47352
|
schemaUpdateOptions,
|
|
46235
47353
|
schemaUpdateStatus,
|
|
46236
47354
|
statusesProgramScreening,
|
|
@@ -46286,13 +47404,18 @@ export {
|
|
|
46286
47404
|
useStockCardController,
|
|
46287
47405
|
useStockCardRepository,
|
|
46288
47406
|
useStockCardService,
|
|
47407
|
+
useStrandController,
|
|
47408
|
+
useStrandRepo,
|
|
46289
47409
|
useSubjectController,
|
|
46290
47410
|
useSubjectRepo,
|
|
46291
47411
|
useSubjectService,
|
|
46292
47412
|
useTeachingLoadController,
|
|
46293
47413
|
useTeachingLoadRepo,
|
|
46294
47414
|
useTeachingLoadSlotController,
|
|
46295
|
-
useTeachingLoadSlotRepo
|
|
47415
|
+
useTeachingLoadSlotRepo,
|
|
47416
|
+
useTrackController,
|
|
47417
|
+
useTrackRepo,
|
|
47418
|
+
useTrackService
|
|
46296
47419
|
};
|
|
46297
47420
|
/*! Bundled license information:
|
|
46298
47421
|
|