@eeplatform/basic-edu 1.10.14 → 1.10.16

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,17 @@
1
1
  # @eeplatform/basic-edu
2
2
 
3
+ ## 1.10.16
4
+
5
+ ### Patch Changes
6
+
7
+ - 7d830d3: Add removeProgramById to enrollment repo and service
8
+
9
+ ## 1.10.15
10
+
11
+ ### Patch Changes
12
+
13
+ - 95ccd7a: Fix kindergarten routine and domain
14
+
3
15
  ## 1.10.14
4
16
 
5
17
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -383,6 +383,7 @@ declare function useEnrollmentRepo(): {
383
383
  }>;
384
384
  updateStatusById: (_id: string | ObjectId, status: string, session?: ClientSession) => Promise<mongodb.UpdateResult<bson.Document>>;
385
385
  getById: (_id: string | ObjectId, status?: string) => Promise<TEnrollment | null>;
386
+ removeProgramById: (_id: string | ObjectId, session?: ClientSession) => Promise<mongodb.UpdateResult<bson.Document>>;
386
387
  };
387
388
 
388
389
  declare function useEnrollmentService(): {
@@ -1846,7 +1847,7 @@ declare function useKindergartenDomainRepo(): {
1846
1847
  };
1847
1848
 
1848
1849
  declare function useKindergartenDomainService(): {
1849
- deleteById: (id: string) => Promise<void>;
1850
+ deleteById: (id: string) => Promise<string>;
1850
1851
  };
1851
1852
 
1852
1853
  declare function useKindergartenDomainController(): {
package/dist/index.js CHANGED
@@ -3607,13 +3607,38 @@ function useEnrollmentRepo() {
3607
3607
  throw new Error("Failed to update enrollment status.");
3608
3608
  }
3609
3609
  }
3610
+ async function removeProgramById(_id, session) {
3611
+ try {
3612
+ _id = new import_mongodb6.ObjectId(_id);
3613
+ } catch (error) {
3614
+ throw new import_nodejs_utils9.BadRequestError(namespace_collection + " Invalid ID.");
3615
+ }
3616
+ try {
3617
+ const result = await collection.updateOne(
3618
+ { _id },
3619
+ {
3620
+ $set: {
3621
+ specialProgram: "",
3622
+ specialProgramName: "",
3623
+ updatedAt: /* @__PURE__ */ new Date()
3624
+ }
3625
+ },
3626
+ { session }
3627
+ );
3628
+ delCachedData();
3629
+ return result;
3630
+ } catch (error) {
3631
+ throw new Error("Failed to update enrollment program.");
3632
+ }
3633
+ }
3610
3634
  return {
3611
3635
  createIndexes,
3612
3636
  add,
3613
3637
  getAll,
3614
3638
  getByApplicantInfo,
3615
3639
  updateStatusById,
3616
- getById
3640
+ getById,
3641
+ removeProgramById
3617
3642
  };
3618
3643
  }
3619
3644
 
@@ -4767,7 +4792,7 @@ var import_joi11 = __toESM(require("joi"));
4767
4792
  // src/resources/program-screening/program.screening.service.ts
4768
4793
  var import_nodejs_utils16 = require("@eeplatform/nodejs-utils");
4769
4794
  function useProgramScreeningService() {
4770
- const { updateStatusById: updateEnrollmentStatusById } = useEnrollmentRepo();
4795
+ const { updateStatusById: updateEnrollmentStatusById, removeProgramById } = useEnrollmentRepo();
4771
4796
  const { updateFieldById, getById: getProgramScreeningById } = useProgramScreeningRepo();
4772
4797
  async function updateStatusById(id, status) {
4773
4798
  const session = import_nodejs_utils16.useAtlas.getClient()?.startSession();
@@ -4783,6 +4808,9 @@ function useProgramScreeningService() {
4783
4808
  );
4784
4809
  let enrollmentStatus = "pending";
4785
4810
  const ReclassifyCond = status === "reclassified" && application.status && ["failed", "withdrawn"].includes(application.status);
4811
+ if (ReclassifyCond) {
4812
+ await removeProgramById(String(application.applicant), session);
4813
+ }
4786
4814
  if (status === "passed" && application.status === "pending" || ReclassifyCond) {
4787
4815
  enrollmentStatus = "pending";
4788
4816
  }
@@ -46493,7 +46521,6 @@ function useKindergartenRoutineRepo() {
46493
46521
  } = {}) {
46494
46522
  page = page > 0 ? page - 1 : 0;
46495
46523
  const query = {
46496
- deletedAt: { $in: ["", null] },
46497
46524
  status
46498
46525
  };
46499
46526
  sort = Object.keys(sort).length > 0 ? sort : { _id: 1 };
@@ -46842,7 +46869,7 @@ function useKindergartenRoutineController() {
46842
46869
  const limit = typeof req.query.limit === "string" ? Number(req.query.limit) : 10;
46843
46870
  const search = req.query.search ?? "";
46844
46871
  const status = req.query.status ?? "active";
46845
- const school = req.query.school ?? "";
46872
+ const school = req.params.school ?? "";
46846
46873
  const section = req.query.section ?? "";
46847
46874
  const classroom = req.query.classroom ?? "";
46848
46875
  const type = req.query.type ?? "";
@@ -47059,9 +47086,10 @@ function useKindergartenDomainRepo() {
47059
47086
  { key: { createdBy: 1 } },
47060
47087
  { key: { title: "text" } },
47061
47088
  {
47062
- key: { title: 1, school: 1, status: 1 },
47089
+ key: { title: 1, school: 1 },
47063
47090
  unique: true,
47064
- name: "unique_kindergarten_domain"
47091
+ name: "unique_kindergarten_domain",
47092
+ partialFilterExpression: { status: "active" }
47065
47093
  }
47066
47094
  ]);
47067
47095
  } catch (error) {
@@ -47384,6 +47412,8 @@ function useKindergartenDomainService() {
47384
47412
  );
47385
47413
  }
47386
47414
  await _deleteById(id, session);
47415
+ await session.commitTransaction();
47416
+ return "Successfully deleted kindergarten domain.";
47387
47417
  } catch (error) {
47388
47418
  await session.abortTransaction();
47389
47419
  if (error instanceof import_nodejs_utils91.AppError) {
@@ -47444,7 +47474,7 @@ function useKindergartenDomainController() {
47444
47474
  const limit = typeof req.query.limit === "string" ? Number(req.query.limit) : 10;
47445
47475
  const search = req.query.search ?? "";
47446
47476
  const status = req.query.status ?? "active";
47447
- const school = req.query.school ?? "";
47477
+ const school = req.params.school ?? "";
47448
47478
  const createdBy = req.query.createdBy ?? "";
47449
47479
  const isPageNumber = isFinite(page);
47450
47480
  if (!isPageNumber) {