@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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @eeplatform/basic-edu
2
2
 
3
+ ## 1.3.1
4
+
5
+ ### Patch Changes
6
+
7
+ - cdc678a: Update dependencies
8
+
3
9
  ## 1.3.0
4
10
 
5
11
  ### Minor Changes
package/dist/index.d.ts CHANGED
@@ -469,8 +469,10 @@ type TSchool = {
469
469
  principalName?: string;
470
470
  street?: string;
471
471
  barangay?: string;
472
- city?: string;
472
+ cityMunicipality?: string;
473
473
  province?: string;
474
+ provincePSGC?: number;
475
+ cityMunicipalityPSGC?: number;
474
476
  postalCode?: string;
475
477
  contactNumber?: string;
476
478
  email?: string;
package/dist/index.js CHANGED
@@ -4603,8 +4603,10 @@ var schemaSchool = import_joi11.default.object({
4603
4603
  principalName: import_joi11.default.string().min(1).max(100).optional().allow(null, ""),
4604
4604
  street: import_joi11.default.string().max(200).optional().allow(null, ""),
4605
4605
  barangay: import_joi11.default.string().max(200).optional().allow(null, ""),
4606
- city: import_joi11.default.string().max(100).optional().allow(null, ""),
4606
+ cityMunicipality: import_joi11.default.string().max(100).optional().allow(null, ""),
4607
4607
  province: import_joi11.default.string().max(100).optional().allow(null, ""),
4608
+ provincePSGC: import_joi11.default.number().optional().allow(null, ""),
4609
+ cityMunicipalityPSGC: import_joi11.default.number().optional().allow(null, ""),
4608
4610
  postalCode: import_joi11.default.string().max(20).optional().allow(null, ""),
4609
4611
  contactNumber: import_joi11.default.string().max(20).optional().allow(null, ""),
4610
4612
  email: import_joi11.default.string().email().max(100).optional().allow(null, ""),
@@ -4625,8 +4627,10 @@ var schemaSchoolUpdate = import_joi11.default.object({
4625
4627
  principalName: import_joi11.default.string().min(1).max(100).optional().allow(null, ""),
4626
4628
  street: import_joi11.default.string().max(200).optional().allow(null, ""),
4627
4629
  barangay: import_joi11.default.string().max(200).optional().allow(null, ""),
4628
- city: import_joi11.default.string().max(100).optional().allow(null, ""),
4630
+ cityMunicipality: import_joi11.default.string().max(100).optional().allow(null, ""),
4629
4631
  province: import_joi11.default.string().max(100).optional().allow(null, ""),
4632
+ provincePSGC: import_joi11.default.number().optional().allow(null, ""),
4633
+ cityMunicipalityPSGC: import_joi11.default.number().optional().allow(null, ""),
4630
4634
  postalCode: import_joi11.default.string().max(20).optional().allow(null, ""),
4631
4635
  contactNumber: import_joi11.default.string().max(20).optional().allow(null, ""),
4632
4636
  email: import_joi11.default.string().email().max(100).optional().allow(null, "")
@@ -4676,12 +4680,14 @@ function modelSchool(value) {
4676
4680
  principalName: value.principalName ?? "",
4677
4681
  street: value.street ?? "",
4678
4682
  barangay: value.barangay ?? "",
4679
- city: value.city ?? "",
4683
+ cityMunicipality: value.cityMunicipality ?? "",
4680
4684
  province: value.province ?? "",
4681
4685
  postalCode: value.postalCode ?? "",
4682
4686
  contactNumber: value.contactNumber ?? "",
4683
4687
  email: value.email ?? "",
4684
4688
  status: value.status ?? "active",
4689
+ provincePSGC: value.provincePSGC ?? 0,
4690
+ cityMunicipalityPSGC: value.cityMunicipalityPSGC ?? 0,
4685
4691
  createdBy: value.createdBy ?? "",
4686
4692
  createdAt: value.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
4687
4693
  updatedAt: value.updatedAt ?? "",
@@ -33393,6 +33399,8 @@ function useSchoolService() {
33393
33399
  const rowNum = i + 1;
33394
33400
  const schoolId = (row.schoolId || row.id || "").toString().trim();
33395
33401
  const name = (row.name || "").toString().trim();
33402
+ const province = (row.province || "").toString().trim();
33403
+ const cityMunicipality = (row.cityMunicipality || "").toString().trim();
33396
33404
  if (!schoolId) {
33397
33405
  errors.push(`Row ${rowNum}: schoolId is required`);
33398
33406
  continue;
@@ -33401,6 +33409,14 @@ function useSchoolService() {
33401
33409
  errors.push(`Row ${rowNum}: name is required`);
33402
33410
  continue;
33403
33411
  }
33412
+ if (!province) {
33413
+ errors.push(`Row ${rowNum}: province is required`);
33414
+ continue;
33415
+ }
33416
+ if (!cityMunicipality) {
33417
+ errors.push(`Row ${rowNum}: city/municipality is required`);
33418
+ continue;
33419
+ }
33404
33420
  const school = {
33405
33421
  id: schoolId,
33406
33422
  name,
@@ -33408,6 +33424,8 @@ function useSchoolService() {
33408
33424
  regionName: payload.regionName,
33409
33425
  division: payload.division,
33410
33426
  divisionName: payload.divisionName,
33427
+ province,
33428
+ cityMunicipality,
33411
33429
  status: "active"
33412
33430
  };
33413
33431
  const { error } = schemaSchool.validate(school);
@@ -33430,6 +33448,7 @@ ${errors.slice(0, 5).join("\n")}${errors.length > 5 ? `
33430
33448
  skipped: 0,
33431
33449
  errors: []
33432
33450
  };
33451
+ const { getByName: getPSGCByName } = (0, import_core2.usePSGCRepo)();
33433
33452
  for (let i = 0; i < schools.length; i++) {
33434
33453
  const session = import_nodejs_utils20.useAtlas.getClient()?.startSession();
33435
33454
  if (!session) {
@@ -33438,6 +33457,27 @@ ${errors.slice(0, 5).join("\n")}${errors.length > 5 ? `
33438
33457
  session.startTransaction();
33439
33458
  const school = schools[i];
33440
33459
  try {
33460
+ const provincePSGC = await getPSGCByName({
33461
+ name: school.province ?? "",
33462
+ type: "Prov"
33463
+ });
33464
+ if (!provincePSGC) {
33465
+ throw new import_nodejs_utils20.BadRequestError(
33466
+ `Province '${school.province}' not found in PSGC data.`
33467
+ );
33468
+ }
33469
+ const cityMunPSGC = await getPSGCByName({
33470
+ name: school.cityMunicipality ?? "",
33471
+ cityMunicipality: true,
33472
+ code: provincePSGC.code
33473
+ });
33474
+ if (!cityMunPSGC) {
33475
+ throw new import_nodejs_utils20.BadRequestError(
33476
+ `City/Municipality '${school.cityMunicipality}' not found in PSGC data.`
33477
+ );
33478
+ }
33479
+ school.provincePSGC = provincePSGC.code ?? 0;
33480
+ school.cityMunicipalityPSGC = cityMunPSGC.code ?? 0;
33441
33481
  const schoolId = await addSchool(school, session, false);
33442
33482
  await addRole(
33443
33483
  {