@eeplatform/basic-edu 1.4.0 → 1.4.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/CHANGELOG.md +12 -0
- package/dist/index.d.ts +7 -6
- package/dist/index.js +53 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +53 -3
- 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.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- e84952a: Parse createdBy, updatedBy, and deletedBy to ObjectId
|
|
8
|
+
|
|
9
|
+
## 1.4.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 944df9d: Add count reset in enrollment acceptance business logic
|
|
14
|
+
|
|
3
15
|
## 1.4.0
|
|
4
16
|
|
|
5
17
|
### Minor 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,9 +195,9 @@ 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(): {
|
|
@@ -750,6 +750,7 @@ declare function useBasicEduCountRepo(): {
|
|
|
750
750
|
getById: (_id: string | ObjectId, status?: string) => Promise<TBasicEduCount | null>;
|
|
751
751
|
incrementById: (_id: string | ObjectId, session?: ClientSession) => Promise<mongodb.UpdateResult<bson.Document>>;
|
|
752
752
|
getByName: (name: string, session?: ClientSession) => Promise<TBasicEduCount | null>;
|
|
753
|
+
resetById: (_id: string | ObjectId, session?: ClientSession) => Promise<mongodb.UpdateResult<bson.Document>>;
|
|
753
754
|
};
|
|
754
755
|
|
|
755
756
|
export { MAsset, MCurriculum, MGradeLevel, MLearner, MPlantilla, MStockCard, TAddress, TAddressInformation, TAsset, TBasicEduCount, TCurriculum, TCurriculumSubject, TDivision, TGradeLevel, TLearner, TLearnerInfo, TLearningModality, TParentGuardianInfo, TPersonContact, TPlantilla, TRegion, TReturningLearnerInfo, TSchool, TSeniorHighInformation, TStockCard, modelBasicEduCount, modelDivision, modelRegion, modelSchool, schemaAsset, schemaAssetUpdateOption, schemaBasicEduCount, schemaCurriculum, schemaDivision, schemaDivisionUpdate, schemaEnrollment, schemaGradeLevel, schemaPlantilla, schemaRegion, schemaSchool, schemaSchoolUpdate, schemaStockCard, schemaUpdateStatus, useAssetController, useAssetRepo, useBasicEduCountRepo, useCurriculumController, useCurriculumRepo, useDivisionController, useDivisionRepo, useDivisionService, useEnrollmentController, useEnrollmentRepo, useEnrollmentService, useGradeLevelController, useGradeLevelRepo, useLearnerController, useLearnerRepo, usePlantillaController, usePlantillaRepo, usePlantillaService, useRegionController, useRegionRepo, useSchoolController, useSchoolRepo, useSchoolService, useStockCardController, useStockCardRepository, useStockCardService };
|
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,
|
|
@@ -2814,12 +2835,31 @@ function useBasicEduCountRepo() {
|
|
|
2814
2835
|
throw new Error("Failed to increment counter status.");
|
|
2815
2836
|
}
|
|
2816
2837
|
}
|
|
2838
|
+
async function resetById(_id, session) {
|
|
2839
|
+
try {
|
|
2840
|
+
_id = new import_mongodb6.ObjectId(_id);
|
|
2841
|
+
} catch (error) {
|
|
2842
|
+
throw new import_nodejs_utils9.BadRequestError("Invalid ID.");
|
|
2843
|
+
}
|
|
2844
|
+
try {
|
|
2845
|
+
const result = await collection.updateOne(
|
|
2846
|
+
{ _id },
|
|
2847
|
+
{ $set: { updatedAt: /* @__PURE__ */ new Date(), count: 0 } },
|
|
2848
|
+
{ session }
|
|
2849
|
+
);
|
|
2850
|
+
delCachedData();
|
|
2851
|
+
return result;
|
|
2852
|
+
} catch (error) {
|
|
2853
|
+
throw new Error("Failed to reset counter to zero.");
|
|
2854
|
+
}
|
|
2855
|
+
}
|
|
2817
2856
|
return {
|
|
2818
2857
|
createIndexes,
|
|
2819
2858
|
add,
|
|
2820
2859
|
getById,
|
|
2821
2860
|
incrementById,
|
|
2822
|
-
getByName
|
|
2861
|
+
getByName,
|
|
2862
|
+
resetById
|
|
2823
2863
|
};
|
|
2824
2864
|
}
|
|
2825
2865
|
|
|
@@ -2895,7 +2935,7 @@ function useEnrollmentService() {
|
|
|
2895
2935
|
}
|
|
2896
2936
|
}
|
|
2897
2937
|
const { add: addLearner } = useLearnerRepo();
|
|
2898
|
-
const { getByName, incrementById } = useBasicEduCountRepo();
|
|
2938
|
+
const { getByName, incrementById, resetById } = useBasicEduCountRepo();
|
|
2899
2939
|
function padNumber(num) {
|
|
2900
2940
|
const str = String(num);
|
|
2901
2941
|
const pad = 4 - str.length;
|
|
@@ -2939,10 +2979,20 @@ function useEnrollmentService() {
|
|
|
2939
2979
|
"Failed to retrieve enrollment counter"
|
|
2940
2980
|
);
|
|
2941
2981
|
}
|
|
2982
|
+
const counterId = String(counter._id);
|
|
2983
|
+
if (counter.updatedAt) {
|
|
2984
|
+
const countUpdatedAtYear = new Date(
|
|
2985
|
+
counter.updatedAt
|
|
2986
|
+
).getFullYear();
|
|
2987
|
+
const currentYear = (/* @__PURE__ */ new Date()).getFullYear();
|
|
2988
|
+
if (countUpdatedAtYear < currentYear) {
|
|
2989
|
+
counter.count = 0;
|
|
2990
|
+
await resetById(counterId, session);
|
|
2991
|
+
}
|
|
2992
|
+
}
|
|
2942
2993
|
const newCount = padNumber(counter.count + 1);
|
|
2943
2994
|
const lrn = `${enrollment.schoolId}-${(/* @__PURE__ */ new Date()).getFullYear().toString().slice(2, 4)}-${newCount}`;
|
|
2944
2995
|
enrollment.learnerInfo.lrn = lrn;
|
|
2945
|
-
const counterId = String(counter._id);
|
|
2946
2996
|
await incrementById(counterId, session);
|
|
2947
2997
|
}
|
|
2948
2998
|
await addLearner(enrollment, session);
|