@eeplatform/basic-edu 1.3.0 → 1.3.1
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 +6 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +43 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +49 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -4604,8 +4604,10 @@ var schemaSchool = Joi11.object({
|
|
|
4604
4604
|
principalName: Joi11.string().min(1).max(100).optional().allow(null, ""),
|
|
4605
4605
|
street: Joi11.string().max(200).optional().allow(null, ""),
|
|
4606
4606
|
barangay: Joi11.string().max(200).optional().allow(null, ""),
|
|
4607
|
-
|
|
4607
|
+
cityMunicipality: Joi11.string().max(100).optional().allow(null, ""),
|
|
4608
4608
|
province: Joi11.string().max(100).optional().allow(null, ""),
|
|
4609
|
+
provincePSGC: Joi11.number().optional().allow(null, ""),
|
|
4610
|
+
cityMunicipalityPSGC: Joi11.number().optional().allow(null, ""),
|
|
4609
4611
|
postalCode: Joi11.string().max(20).optional().allow(null, ""),
|
|
4610
4612
|
contactNumber: Joi11.string().max(20).optional().allow(null, ""),
|
|
4611
4613
|
email: Joi11.string().email().max(100).optional().allow(null, ""),
|
|
@@ -4626,8 +4628,10 @@ var schemaSchoolUpdate = Joi11.object({
|
|
|
4626
4628
|
principalName: Joi11.string().min(1).max(100).optional().allow(null, ""),
|
|
4627
4629
|
street: Joi11.string().max(200).optional().allow(null, ""),
|
|
4628
4630
|
barangay: Joi11.string().max(200).optional().allow(null, ""),
|
|
4629
|
-
|
|
4631
|
+
cityMunicipality: Joi11.string().max(100).optional().allow(null, ""),
|
|
4630
4632
|
province: Joi11.string().max(100).optional().allow(null, ""),
|
|
4633
|
+
provincePSGC: Joi11.number().optional().allow(null, ""),
|
|
4634
|
+
cityMunicipalityPSGC: Joi11.number().optional().allow(null, ""),
|
|
4631
4635
|
postalCode: Joi11.string().max(20).optional().allow(null, ""),
|
|
4632
4636
|
contactNumber: Joi11.string().max(20).optional().allow(null, ""),
|
|
4633
4637
|
email: Joi11.string().email().max(100).optional().allow(null, "")
|
|
@@ -4677,12 +4681,14 @@ function modelSchool(value) {
|
|
|
4677
4681
|
principalName: value.principalName ?? "",
|
|
4678
4682
|
street: value.street ?? "",
|
|
4679
4683
|
barangay: value.barangay ?? "",
|
|
4680
|
-
|
|
4684
|
+
cityMunicipality: value.cityMunicipality ?? "",
|
|
4681
4685
|
province: value.province ?? "",
|
|
4682
4686
|
postalCode: value.postalCode ?? "",
|
|
4683
4687
|
contactNumber: value.contactNumber ?? "",
|
|
4684
4688
|
email: value.email ?? "",
|
|
4685
4689
|
status: value.status ?? "active",
|
|
4690
|
+
provincePSGC: value.provincePSGC ?? 0,
|
|
4691
|
+
cityMunicipalityPSGC: value.cityMunicipalityPSGC ?? 0,
|
|
4686
4692
|
createdBy: value.createdBy ?? "",
|
|
4687
4693
|
createdAt: value.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
4688
4694
|
updatedAt: value.updatedAt ?? "",
|
|
@@ -5057,7 +5063,12 @@ function useSchoolRepo() {
|
|
|
5057
5063
|
|
|
5058
5064
|
// src/resources/school/school.service.ts
|
|
5059
5065
|
import { BadRequestError as BadRequestError19, useAtlas as useAtlas9, logger as logger14 } from "@eeplatform/nodejs-utils";
|
|
5060
|
-
import {
|
|
5066
|
+
import {
|
|
5067
|
+
useRoleRepo as useRoleRepo2,
|
|
5068
|
+
useUserRepo,
|
|
5069
|
+
useMemberRepo,
|
|
5070
|
+
usePSGCRepo
|
|
5071
|
+
} from "@eeplatform/core";
|
|
5061
5072
|
|
|
5062
5073
|
// node_modules/xlsx/xlsx.mjs
|
|
5063
5074
|
var XLSX = {};
|
|
@@ -33403,6 +33414,8 @@ function useSchoolService() {
|
|
|
33403
33414
|
const rowNum = i + 1;
|
|
33404
33415
|
const schoolId = (row.schoolId || row.id || "").toString().trim();
|
|
33405
33416
|
const name = (row.name || "").toString().trim();
|
|
33417
|
+
const province = (row.province || "").toString().trim();
|
|
33418
|
+
const cityMunicipality = (row.cityMunicipality || "").toString().trim();
|
|
33406
33419
|
if (!schoolId) {
|
|
33407
33420
|
errors.push(`Row ${rowNum}: schoolId is required`);
|
|
33408
33421
|
continue;
|
|
@@ -33411,6 +33424,14 @@ function useSchoolService() {
|
|
|
33411
33424
|
errors.push(`Row ${rowNum}: name is required`);
|
|
33412
33425
|
continue;
|
|
33413
33426
|
}
|
|
33427
|
+
if (!province) {
|
|
33428
|
+
errors.push(`Row ${rowNum}: province is required`);
|
|
33429
|
+
continue;
|
|
33430
|
+
}
|
|
33431
|
+
if (!cityMunicipality) {
|
|
33432
|
+
errors.push(`Row ${rowNum}: city/municipality is required`);
|
|
33433
|
+
continue;
|
|
33434
|
+
}
|
|
33414
33435
|
const school = {
|
|
33415
33436
|
id: schoolId,
|
|
33416
33437
|
name,
|
|
@@ -33418,6 +33439,8 @@ function useSchoolService() {
|
|
|
33418
33439
|
regionName: payload.regionName,
|
|
33419
33440
|
division: payload.division,
|
|
33420
33441
|
divisionName: payload.divisionName,
|
|
33442
|
+
province,
|
|
33443
|
+
cityMunicipality,
|
|
33421
33444
|
status: "active"
|
|
33422
33445
|
};
|
|
33423
33446
|
const { error } = schemaSchool.validate(school);
|
|
@@ -33440,6 +33463,7 @@ ${errors.slice(0, 5).join("\n")}${errors.length > 5 ? `
|
|
|
33440
33463
|
skipped: 0,
|
|
33441
33464
|
errors: []
|
|
33442
33465
|
};
|
|
33466
|
+
const { getByName: getPSGCByName } = usePSGCRepo();
|
|
33443
33467
|
for (let i = 0; i < schools.length; i++) {
|
|
33444
33468
|
const session = useAtlas9.getClient()?.startSession();
|
|
33445
33469
|
if (!session) {
|
|
@@ -33448,6 +33472,27 @@ ${errors.slice(0, 5).join("\n")}${errors.length > 5 ? `
|
|
|
33448
33472
|
session.startTransaction();
|
|
33449
33473
|
const school = schools[i];
|
|
33450
33474
|
try {
|
|
33475
|
+
const provincePSGC = await getPSGCByName({
|
|
33476
|
+
name: school.province ?? "",
|
|
33477
|
+
type: "Prov"
|
|
33478
|
+
});
|
|
33479
|
+
if (!provincePSGC) {
|
|
33480
|
+
throw new BadRequestError19(
|
|
33481
|
+
`Province '${school.province}' not found in PSGC data.`
|
|
33482
|
+
);
|
|
33483
|
+
}
|
|
33484
|
+
const cityMunPSGC = await getPSGCByName({
|
|
33485
|
+
name: school.cityMunicipality ?? "",
|
|
33486
|
+
cityMunicipality: true,
|
|
33487
|
+
code: provincePSGC.code
|
|
33488
|
+
});
|
|
33489
|
+
if (!cityMunPSGC) {
|
|
33490
|
+
throw new BadRequestError19(
|
|
33491
|
+
`City/Municipality '${school.cityMunicipality}' not found in PSGC data.`
|
|
33492
|
+
);
|
|
33493
|
+
}
|
|
33494
|
+
school.provincePSGC = provincePSGC.code ?? 0;
|
|
33495
|
+
school.cityMunicipalityPSGC = cityMunPSGC.code ?? 0;
|
|
33451
33496
|
const schoolId = await addSchool(school, session, false);
|
|
33452
33497
|
await addRole(
|
|
33453
33498
|
{
|