@eeplatform/basic-edu 1.1.2 → 1.2.0

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/dist/index.mjs CHANGED
@@ -3566,19 +3566,18 @@ import { ObjectId as ObjectId7 } from "mongodb";
3566
3566
  var schemaRegion = Joi7.object({
3567
3567
  _id: Joi7.string().hex().optional().allow(null, ""),
3568
3568
  name: Joi7.string().min(1).max(100).required(),
3569
- code: Joi7.string().length(10).required(),
3570
3569
  createdAt: Joi7.string().isoDate().optional(),
3571
3570
  updatedAt: Joi7.string().isoDate().optional(),
3572
3571
  deletedAt: Joi7.string().isoDate().optional().allow(null, "")
3573
3572
  });
3574
- function MRegion(value) {
3573
+ function modelRegion(value) {
3575
3574
  const { error } = schemaRegion.validate(value);
3576
3575
  if (error) {
3577
3576
  throw new BadRequestError11(`Invalid region data: ${error.message}`);
3578
3577
  }
3579
3578
  if (value._id && typeof value._id === "string") {
3580
3579
  try {
3581
- value._id = new ObjectId7(value._id);
3580
+ value._id = ObjectId7.createFromTime(value._id);
3582
3581
  } catch (error2) {
3583
3582
  throw new Error("Invalid _id.");
3584
3583
  }
@@ -3586,7 +3585,7 @@ function MRegion(value) {
3586
3585
  return {
3587
3586
  _id: value._id,
3588
3587
  name: value.name,
3589
- code: value.code,
3588
+ status: "active",
3590
3589
  createdAt: value.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
3591
3590
  updatedAt: value.updatedAt ?? "",
3592
3591
  deletedAt: value.deletedAt ?? ""
@@ -3610,18 +3609,16 @@ function useRegionRepo() {
3610
3609
  if (!db) {
3611
3610
  throw new Error("Unable to connect to server.");
3612
3611
  }
3613
- const namespace_collection = "regions";
3612
+ const namespace_collection = "deped.regions";
3614
3613
  const collection = db.collection(namespace_collection);
3615
3614
  const { getCache, setCache, delNamespace } = useCache4(namespace_collection);
3616
3615
  async function createIndexes() {
3617
3616
  try {
3618
3617
  await collection.createIndexes([
3619
3618
  { key: { name: 1 } },
3620
- { key: { code: 1 } },
3621
3619
  { key: { createdAt: 1 } },
3622
3620
  { key: { name: "text" } },
3623
- { key: { code: 1 }, unique: true, name: "unique_code" },
3624
- { key: { name: 1 }, unique: true, name: "unique_name" }
3621
+ { key: { name: 1, status: 1 }, unique: true, name: "unique_region" }
3625
3622
  ]);
3626
3623
  } catch (error) {
3627
3624
  throw new Error("Failed to create index on regions.");
@@ -3642,7 +3639,7 @@ function useRegionRepo() {
3642
3639
  }
3643
3640
  async function add(value, session) {
3644
3641
  try {
3645
- value = MRegion(value);
3642
+ value = modelRegion(value);
3646
3643
  const res = await collection.insertOne(value, { session });
3647
3644
  delCachedData();
3648
3645
  return res.insertedId;
@@ -3662,19 +3659,30 @@ function useRegionRepo() {
3662
3659
  }
3663
3660
  }
3664
3661
  }
3665
- async function getAll({ search = "", page = 1, limit = 10, sort = {} } = {}) {
3662
+ async function getAll({
3663
+ search = "",
3664
+ page = 1,
3665
+ limit = 10,
3666
+ sort = {},
3667
+ status = "active"
3668
+ } = {}) {
3666
3669
  page = page > 0 ? page - 1 : 0;
3667
- const query = { deletedAt: { $in: ["", null] } };
3670
+ const query = {
3671
+ deletedAt: { $in: ["", null] },
3672
+ status
3673
+ };
3668
3674
  sort = Object.keys(sort).length > 0 ? sort : { _id: 1 };
3669
- if (search) {
3670
- query.$text = { $search: search };
3671
- }
3672
- const cacheKey = makeCacheKey4(namespace_collection, {
3673
- search,
3675
+ const cacheKeyOptions = {
3676
+ status,
3674
3677
  page,
3675
3678
  limit,
3676
3679
  sort: JSON.stringify(sort)
3677
- });
3680
+ };
3681
+ if (search) {
3682
+ query.$text = { $search: search };
3683
+ cacheKeyOptions.search = search;
3684
+ }
3685
+ const cacheKey = makeCacheKey4(namespace_collection, cacheKeyOptions);
3678
3686
  logger11.log({
3679
3687
  level: "info",
3680
3688
  message: `Cache key for getAll regions: ${cacheKey}`
@@ -3692,17 +3700,7 @@ function useRegionRepo() {
3692
3700
  { $match: query },
3693
3701
  { $sort: sort },
3694
3702
  { $skip: page * limit },
3695
- { $limit: limit },
3696
- {
3697
- $project: {
3698
- _id: 1,
3699
- name: 1,
3700
- director: 1,
3701
- directorName: 1,
3702
- createdAt: 1,
3703
- updatedAt: 1
3704
- }
3705
- }
3703
+ { $limit: limit }
3706
3704
  ]).toArray();
3707
3705
  const length = await collection.countDocuments(query);
3708
3706
  const data = paginate4(items, page, limit, length);
@@ -3837,7 +3835,7 @@ function useRegionRepo() {
3837
3835
  try {
3838
3836
  await collection.updateOne(
3839
3837
  { _id },
3840
- { $set: { deletedAt: (/* @__PURE__ */ new Date()).toISOString() } }
3838
+ { $set: { status: "deleted", deletedAt: (/* @__PURE__ */ new Date()).toISOString() } }
3841
3839
  );
3842
3840
  delCachedData();
3843
3841
  return "Successfully deleted region.";
@@ -3876,10 +3874,10 @@ function useRegionController() {
3876
3874
  return;
3877
3875
  }
3878
3876
  try {
3879
- const regionId = await _add(value);
3877
+ const data = await _add(value);
3880
3878
  res.json({
3881
3879
  message: "Successfully created region.",
3882
- data: { regionId }
3880
+ data
3883
3881
  });
3884
3882
  return;
3885
3883
  } catch (error2) {
@@ -3891,12 +3889,14 @@ function useRegionController() {
3891
3889
  const validation = Joi8.object({
3892
3890
  page: Joi8.number().min(1).optional().allow("", null),
3893
3891
  limit: Joi8.number().min(1).optional().allow("", null),
3894
- search: Joi8.string().optional().allow("", null)
3892
+ search: Joi8.string().optional().allow("", null),
3893
+ status: Joi8.string().optional().allow("", null)
3895
3894
  });
3896
3895
  const { error } = validation.validate(query);
3897
3896
  const page = typeof req.query.page === "string" ? Number(req.query.page) : 1;
3898
3897
  const limit = typeof req.query.limit === "string" ? Number(req.query.limit) : 10;
3899
3898
  const search = req.query.search ?? "";
3899
+ const status = req.query.status ?? "active";
3900
3900
  const isPageNumber = isFinite(page);
3901
3901
  if (!isPageNumber) {
3902
3902
  next(new BadRequestError13("Invalid page number."));
@@ -3912,8 +3912,8 @@ function useRegionController() {
3912
3912
  return;
3913
3913
  }
3914
3914
  try {
3915
- const regions = await _getAll({ page, limit, search });
3916
- res.json(regions);
3915
+ const data = await _getAll({ page, limit, search, status });
3916
+ res.json(data);
3917
3917
  return;
3918
3918
  } catch (error2) {
3919
3919
  next(error2);
@@ -3930,10 +3930,10 @@ function useRegionController() {
3930
3930
  return;
3931
3931
  }
3932
3932
  try {
3933
- const region = await _getById(id);
3933
+ const data = await _getById(id);
3934
3934
  res.json({
3935
3935
  message: "Successfully retrieved region.",
3936
- data: { region }
3936
+ data
3937
3937
  });
3938
3938
  return;
3939
3939
  } catch (error2) {
@@ -3951,10 +3951,10 @@ function useRegionController() {
3951
3951
  return;
3952
3952
  }
3953
3953
  try {
3954
- const region = await _getByName(name);
3954
+ const data = await _getByName(name);
3955
3955
  res.json({
3956
3956
  message: "Successfully retrieved region.",
3957
- data: { region }
3957
+ data
3958
3958
  });
3959
3959
  return;
3960
3960
  } catch (error2) {
@@ -4017,47 +4017,42 @@ import { ObjectId as ObjectId9 } from "mongodb";
4017
4017
  var schemaDivision = Joi9.object({
4018
4018
  _id: Joi9.string().hex().optional().allow(null, ""),
4019
4019
  name: Joi9.string().min(1).max(100).required(),
4020
- region: Joi9.string().hex().optional().allow(null, ""),
4021
- regionName: Joi9.string().min(1).max(100).optional().allow(null, ""),
4020
+ region: Joi9.string().hex().required(),
4021
+ regionName: Joi9.string().min(1).max(100).required(),
4022
4022
  superintendent: Joi9.string().hex().optional().allow(null, ""),
4023
4023
  superintendentName: Joi9.string().min(1).max(100).optional().allow(null, ""),
4024
4024
  createdAt: Joi9.string().isoDate().optional(),
4025
4025
  updatedAt: Joi9.string().isoDate().optional(),
4026
4026
  deletedAt: Joi9.string().isoDate().optional().allow(null, "")
4027
4027
  });
4028
- function MDivision(value) {
4028
+ var schemaDivisionUpdate = Joi9.object({
4029
+ _id: Joi9.string().hex().optional().allow(null, ""),
4030
+ name: Joi9.string().min(1).max(100).required(),
4031
+ region: Joi9.string().hex().required(),
4032
+ regionName: Joi9.string().min(1).max(100).required(),
4033
+ superintendent: Joi9.string().hex().optional().allow(null, ""),
4034
+ superintendentName: Joi9.string().min(1).max(100).optional().allow(null, "")
4035
+ });
4036
+ function modelDivision(value) {
4029
4037
  const { error } = schemaDivision.validate(value);
4030
4038
  if (error) {
4031
- throw new BadRequestError14(`Invalid division data: ${error.message}`);
4039
+ throw new BadRequestError14(`Invalid sdo data: ${error.message}`);
4032
4040
  }
4033
4041
  if (value._id && typeof value._id === "string") {
4034
4042
  try {
4035
- value._id = new ObjectId9(value._id);
4043
+ value._id = ObjectId9.createFromTime(value._id);
4036
4044
  } catch (error2) {
4037
4045
  throw new Error("Invalid _id.");
4038
4046
  }
4039
4047
  }
4040
- if (value.region && typeof value.region === "string") {
4041
- try {
4042
- value.region = new ObjectId9(value.region);
4043
- } catch (error2) {
4044
- throw new Error("Invalid region.");
4045
- }
4046
- }
4047
- if (value.superintendent && typeof value.superintendent === "string") {
4048
- try {
4049
- value.superintendent = new ObjectId9(value.superintendent);
4050
- } catch (error2) {
4051
- throw new Error("Invalid superintendent.");
4052
- }
4053
- }
4054
4048
  return {
4055
4049
  _id: value._id,
4056
4050
  name: value.name,
4057
- region: value.region ?? "",
4051
+ region: value.region,
4058
4052
  regionName: value.regionName ?? "",
4059
- superintendent: value.superintendent ?? "",
4053
+ superintendent: value.superintendent,
4060
4054
  superintendentName: value.superintendentName ?? "",
4055
+ status: value.status ?? "active",
4061
4056
  createdAt: value.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
4062
4057
  updatedAt: value.updatedAt ?? "",
4063
4058
  deletedAt: value.deletedAt ?? ""
@@ -4081,46 +4076,25 @@ function useDivisionRepo() {
4081
4076
  if (!db) {
4082
4077
  throw new Error("Unable to connect to server.");
4083
4078
  }
4084
- const namespace_collection = "divisions";
4079
+ const namespace_collection = "deped.divisions";
4085
4080
  const collection = db.collection(namespace_collection);
4086
4081
  const { getCache, setCache, delNamespace } = useCache5(namespace_collection);
4087
- async function createIndex() {
4082
+ async function createIndexes() {
4088
4083
  try {
4089
- await collection.createIndex([
4090
- { name: 1 },
4091
- { region: 1 },
4092
- { superintendent: 1 },
4093
- { createdAt: 1 }
4084
+ await collection.createIndexes([
4085
+ { key: { name: 1 } },
4086
+ { key: { createdAt: 1 } },
4087
+ { key: { name: "text", regionName: "text" } },
4088
+ {
4089
+ key: { name: 1, region: 1, status: 1 },
4090
+ unique: true,
4091
+ name: "unique_division"
4092
+ }
4094
4093
  ]);
4095
4094
  } catch (error) {
4096
4095
  throw new Error("Failed to create index on divisions.");
4097
4096
  }
4098
4097
  }
4099
- async function createTextIndex() {
4100
- try {
4101
- await collection.createIndex({
4102
- name: "text",
4103
- regionName: "text",
4104
- superintendentName: "text"
4105
- });
4106
- } catch (error) {
4107
- throw new Error(
4108
- "Failed to create text index on division name and superintendent name."
4109
- );
4110
- }
4111
- }
4112
- async function createUniqueIndex() {
4113
- try {
4114
- await collection.createIndex(
4115
- {
4116
- name: 1
4117
- },
4118
- { unique: true }
4119
- );
4120
- } catch (error) {
4121
- throw new Error("Failed to create unique index on division name.");
4122
- }
4123
- }
4124
4098
  function delCachedData() {
4125
4099
  delNamespace().then(() => {
4126
4100
  logger12.log({
@@ -4136,7 +4110,7 @@ function useDivisionRepo() {
4136
4110
  }
4137
4111
  async function add(value, session) {
4138
4112
  try {
4139
- value = MDivision(value);
4113
+ value = modelDivision(value);
4140
4114
  const res = await collection.insertOne(value, { session });
4141
4115
  delCachedData();
4142
4116
  return res.insertedId;
@@ -4161,28 +4135,25 @@ function useDivisionRepo() {
4161
4135
  page = 1,
4162
4136
  limit = 10,
4163
4137
  sort = {},
4164
- region = ""
4138
+ status = "active"
4165
4139
  } = {}) {
4166
4140
  page = page > 0 ? page - 1 : 0;
4167
- const query = { deletedAt: { $in: ["", null] } };
4168
- sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
4141
+ const query = {
4142
+ deletedAt: { $in: ["", null] },
4143
+ status
4144
+ };
4145
+ sort = Object.keys(sort).length > 0 ? sort : { _id: 1 };
4146
+ const cacheKeyOptions = {
4147
+ status,
4148
+ page,
4149
+ limit,
4150
+ sort: JSON.stringify(sort)
4151
+ };
4169
4152
  if (search) {
4170
4153
  query.$text = { $search: search };
4154
+ cacheKeyOptions.search = search;
4171
4155
  }
4172
- if (region) {
4173
- try {
4174
- query.region = new ObjectId10(region);
4175
- } catch (error) {
4176
- throw new BadRequestError15("Invalid region ID.");
4177
- }
4178
- }
4179
- const cacheKey = makeCacheKey5(namespace_collection, {
4180
- search,
4181
- page,
4182
- limit,
4183
- sort: JSON.stringify(sort),
4184
- region
4185
- });
4156
+ const cacheKey = makeCacheKey5(namespace_collection, cacheKeyOptions);
4186
4157
  logger12.log({
4187
4158
  level: "info",
4188
4159
  message: `Cache key for getAll divisions: ${cacheKey}`
@@ -4200,19 +4171,7 @@ function useDivisionRepo() {
4200
4171
  { $match: query },
4201
4172
  { $sort: sort },
4202
4173
  { $skip: page * limit },
4203
- { $limit: limit },
4204
- {
4205
- $project: {
4206
- _id: 1,
4207
- name: 1,
4208
- region: 1,
4209
- regionName: 1,
4210
- superintendent: 1,
4211
- superintendentName: 1,
4212
- createdAt: 1,
4213
- updatedAt: 1
4214
- }
4215
- }
4174
+ { $limit: limit }
4216
4175
  ]).toArray();
4217
4176
  const length = await collection.countDocuments(query);
4218
4177
  const data = paginate5(items, page, limit, length);
@@ -4315,13 +4274,7 @@ function useDivisionRepo() {
4315
4274
  }
4316
4275
  }
4317
4276
  async function updateFieldById({ _id, field, value } = {}, session) {
4318
- const allowedFields = [
4319
- "name",
4320
- "region",
4321
- "regionName",
4322
- "superintendent",
4323
- "superintendentName"
4324
- ];
4277
+ const allowedFields = ["name"];
4325
4278
  if (!allowedFields.includes(field)) {
4326
4279
  throw new BadRequestError15(
4327
4280
  `Field "${field}" is not allowed to be updated.`
@@ -4344,6 +4297,27 @@ function useDivisionRepo() {
4344
4297
  throw new InternalServerError6(`Failed to update division ${field}.`);
4345
4298
  }
4346
4299
  }
4300
+ async function updateById(_id, options, session) {
4301
+ const { error } = schemaDivisionUpdate.validate({
4302
+ _id: String(_id),
4303
+ ...options
4304
+ });
4305
+ if (error) {
4306
+ throw new BadRequestError15(`Invalid division data: ${error.message}`);
4307
+ }
4308
+ try {
4309
+ _id = new ObjectId10(_id);
4310
+ } catch (error2) {
4311
+ throw new BadRequestError15("Invalid ID.");
4312
+ }
4313
+ try {
4314
+ await collection.updateOne({ _id }, { $set: options }, { session });
4315
+ delCachedData();
4316
+ return `Successfully updated division.`;
4317
+ } catch (error2) {
4318
+ throw new InternalServerError6(`Failed to update division.`);
4319
+ }
4320
+ }
4347
4321
  async function deleteById(_id) {
4348
4322
  try {
4349
4323
  _id = new ObjectId10(_id);
@@ -4353,7 +4327,7 @@ function useDivisionRepo() {
4353
4327
  try {
4354
4328
  await collection.updateOne(
4355
4329
  { _id },
4356
- { $set: { deletedAt: (/* @__PURE__ */ new Date()).toISOString() } }
4330
+ { $set: { status: "deleted", deletedAt: (/* @__PURE__ */ new Date()).toISOString() } }
4357
4331
  );
4358
4332
  delCachedData();
4359
4333
  return "Successfully deleted division.";
@@ -4362,13 +4336,12 @@ function useDivisionRepo() {
4362
4336
  }
4363
4337
  }
4364
4338
  return {
4365
- createIndex,
4366
- createTextIndex,
4367
- createUniqueIndex,
4339
+ createIndexes,
4368
4340
  add,
4369
4341
  getAll,
4370
4342
  getById,
4371
4343
  updateFieldById,
4344
+ updateById,
4372
4345
  deleteById,
4373
4346
  getByName
4374
4347
  };
@@ -4417,33 +4390,27 @@ function useDivisionService() {
4417
4390
  import { BadRequestError as BadRequestError16 } from "@eeplatform/nodejs-utils";
4418
4391
  import Joi10 from "joi";
4419
4392
  function useDivisionController() {
4393
+ const { add: _add } = useDivisionService();
4420
4394
  const {
4421
4395
  getAll: _getAll,
4422
4396
  getById: _getById,
4423
4397
  getByName: _getByName,
4424
4398
  updateFieldById: _updateFieldById,
4399
+ updateById: _updateById,
4425
4400
  deleteById: _deleteById
4426
4401
  } = useDivisionRepo();
4427
- const { add: _createDivision } = useDivisionService();
4428
- async function createDivision(req, res, next) {
4402
+ async function add(req, res, next) {
4429
4403
  const value = req.body;
4430
- const validation = Joi10.object({
4431
- name: Joi10.string().min(1).max(100).required(),
4432
- region: Joi10.string().hex().optional().allow("", null),
4433
- regionName: Joi10.string().min(1).max(100).optional().allow("", null),
4434
- superintendent: Joi10.string().hex().optional().allow("", null),
4435
- superintendentName: Joi10.string().min(1).max(100).optional().allow("", null)
4436
- });
4437
- const { error } = validation.validate(value);
4404
+ const { error } = schemaDivision.validate(value);
4438
4405
  if (error) {
4439
4406
  next(new BadRequestError16(error.message));
4440
4407
  return;
4441
4408
  }
4442
4409
  try {
4443
- const divisionId = await _createDivision(value);
4410
+ const data = await _add(value);
4444
4411
  res.json({
4445
4412
  message: "Successfully created division.",
4446
- data: { divisionId }
4413
+ data
4447
4414
  });
4448
4415
  return;
4449
4416
  } catch (error2) {
@@ -4456,13 +4423,13 @@ function useDivisionController() {
4456
4423
  page: Joi10.number().min(1).optional().allow("", null),
4457
4424
  limit: Joi10.number().min(1).optional().allow("", null),
4458
4425
  search: Joi10.string().optional().allow("", null),
4459
- region: Joi10.string().hex().optional().allow("", null)
4426
+ status: Joi10.string().optional().allow("", null)
4460
4427
  });
4461
4428
  const { error } = validation.validate(query);
4462
4429
  const page = typeof req.query.page === "string" ? Number(req.query.page) : 1;
4463
4430
  const limit = typeof req.query.limit === "string" ? Number(req.query.limit) : 10;
4464
4431
  const search = req.query.search ?? "";
4465
- const region = req.query.region ?? "";
4432
+ const status = req.query.status ?? "active";
4466
4433
  const isPageNumber = isFinite(page);
4467
4434
  if (!isPageNumber) {
4468
4435
  next(new BadRequestError16("Invalid page number."));
@@ -4478,8 +4445,8 @@ function useDivisionController() {
4478
4445
  return;
4479
4446
  }
4480
4447
  try {
4481
- const divisions = await _getAll({ page, limit, search, region });
4482
- res.json(divisions);
4448
+ const data = await _getAll({ page, limit, search, status });
4449
+ res.json(data);
4483
4450
  return;
4484
4451
  } catch (error2) {
4485
4452
  next(error2);
@@ -4497,7 +4464,10 @@ function useDivisionController() {
4497
4464
  }
4498
4465
  try {
4499
4466
  const data = await _getById(id);
4500
- res.json(data);
4467
+ res.json({
4468
+ message: "Successfully retrieved division.",
4469
+ data
4470
+ });
4501
4471
  return;
4502
4472
  } catch (error2) {
4503
4473
  next(error2);
@@ -4514,10 +4484,10 @@ function useDivisionController() {
4514
4484
  return;
4515
4485
  }
4516
4486
  try {
4517
- const division = await _getByName(name);
4487
+ const data = await _getByName(name);
4518
4488
  res.json({
4519
4489
  message: "Successfully retrieved division.",
4520
- data: { division }
4490
+ data
4521
4491
  });
4522
4492
  return;
4523
4493
  } catch (error2) {
@@ -4529,13 +4499,7 @@ function useDivisionController() {
4529
4499
  const { field, value } = req.body;
4530
4500
  const validation = Joi10.object({
4531
4501
  _id: Joi10.string().hex().required(),
4532
- field: Joi10.string().valid(
4533
- "name",
4534
- "region",
4535
- "regionName",
4536
- "superintendent",
4537
- "superintendentName"
4538
- ).required(),
4502
+ field: Joi10.string().valid("name", "director", "directorName").required(),
4539
4503
  value: Joi10.string().required()
4540
4504
  });
4541
4505
  const { error } = validation.validate({ _id, field, value });
@@ -4551,7 +4515,23 @@ function useDivisionController() {
4551
4515
  next(error2);
4552
4516
  }
4553
4517
  }
4554
- async function deleteDivision(req, res, next) {
4518
+ async function updateById(req, res, next) {
4519
+ const _id = req.params.id;
4520
+ const payload = req.body;
4521
+ const { error } = schemaDivisionUpdate.validate({ _id, ...payload });
4522
+ if (error) {
4523
+ next(new BadRequestError16(error.message));
4524
+ return;
4525
+ }
4526
+ try {
4527
+ const message = await _updateById(_id, payload);
4528
+ res.json({ message });
4529
+ return;
4530
+ } catch (error2) {
4531
+ next(error2);
4532
+ }
4533
+ }
4534
+ async function deleteById(req, res, next) {
4555
4535
  const _id = req.params.id;
4556
4536
  const validation = Joi10.object({
4557
4537
  _id: Joi10.string().hex().required()
@@ -4570,103 +4550,84 @@ function useDivisionController() {
4570
4550
  }
4571
4551
  }
4572
4552
  return {
4573
- createDivision,
4553
+ add,
4574
4554
  getAll,
4575
4555
  getById,
4576
4556
  getByName,
4577
4557
  updateField,
4578
- deleteDivision
4558
+ updateById,
4559
+ deleteById
4579
4560
  };
4580
4561
  }
4581
4562
 
4582
4563
  // src/resources/school/school.model.ts
4564
+ import { BadRequestError as BadRequestError17 } from "@eeplatform/nodejs-utils";
4583
4565
  import Joi11 from "joi";
4584
4566
  import { ObjectId as ObjectId11 } from "mongodb";
4585
4567
  var schemaSchool = Joi11.object({
4586
- _id: Joi11.string().hex().optional().allow("", null),
4587
- id: Joi11.string().optional().allow("", null),
4588
- name: Joi11.string().optional().allow("", null),
4589
- country: Joi11.string().optional().allow("", null),
4590
- address: Joi11.string().optional().allow("", null),
4591
- continuedAddress: Joi11.string().optional().allow("", null),
4592
- city: Joi11.string().required().allow("", null),
4593
- province: Joi11.string().required().allow("", null),
4594
- district: Joi11.string().optional().allow("", null),
4595
- postalCode: Joi11.string().required().allow("", null),
4596
- courses: Joi11.array().items(Joi11.string()).optional(),
4597
- principalName: Joi11.string().required().allow("", null),
4598
- principalEmail: Joi11.string().email().optional().allow("", null),
4599
- principalNumber: Joi11.string().optional().allow("", null),
4600
- region: Joi11.string().hex().required(),
4601
- regionName: Joi11.string().optional().allow("", null),
4602
- division: Joi11.string().hex().required(),
4603
- divisionName: Joi11.string().optional().allow("", null),
4604
- status: Joi11.string().optional().allow(null, ""),
4605
- createdAt: Joi11.date().optional().allow("", null),
4606
- updatedAt: Joi11.date().optional().allow("", null),
4607
- createdBy: Joi11.string().hex().optional().allow("", null)
4568
+ _id: Joi11.string().hex().optional().allow(null, ""),
4569
+ id: Joi11.string().min(1).max(50).required(),
4570
+ name: Joi11.string().min(1).max(100).required(),
4571
+ region: Joi11.string().hex().optional().allow(null, ""),
4572
+ regionName: Joi11.string().min(1).max(100).optional().allow(null, ""),
4573
+ division: Joi11.string().hex().optional().allow(null, ""),
4574
+ divisionName: Joi11.string().min(1).max(100).optional().allow(null, ""),
4575
+ principal: Joi11.string().hex().optional().allow(null, ""),
4576
+ principalName: Joi11.string().min(1).max(100).optional().allow(null, ""),
4577
+ street: Joi11.string().max(200).optional().allow(null, ""),
4578
+ barangay: Joi11.string().max(200).optional().allow(null, ""),
4579
+ city: Joi11.string().max(100).optional().allow(null, ""),
4580
+ province: Joi11.string().max(100).optional().allow(null, ""),
4581
+ postalCode: Joi11.string().max(20).optional().allow(null, ""),
4582
+ contactNumber: Joi11.string().max(20).optional().allow(null, ""),
4583
+ email: Joi11.string().email().max(100).optional().allow(null, ""),
4584
+ createdBy: Joi11.string().optional().allow(null, ""),
4585
+ createdAt: Joi11.string().isoDate().optional().allow(null, ""),
4586
+ updatedAt: Joi11.string().isoDate().optional().allow(null, ""),
4587
+ deletedAt: Joi11.string().isoDate().optional().allow(null, "")
4608
4588
  });
4609
- function MSchool(value) {
4589
+ function modelSchool(value) {
4610
4590
  const { error } = schemaSchool.validate(value);
4611
4591
  if (error) {
4612
- throw new Error(`Validation error: ${error.message}`);
4592
+ throw new BadRequestError17(`Invalid sdo data: ${error.message}`);
4613
4593
  }
4614
- if (value._id) {
4594
+ if (value._id && typeof value._id === "string") {
4615
4595
  try {
4616
- value._id = new ObjectId11(value._id);
4596
+ value._id = ObjectId11.createFromTime(value._id);
4617
4597
  } catch (error2) {
4618
4598
  throw new Error("Invalid _id.");
4619
4599
  }
4620
4600
  }
4621
- if (value.region) {
4622
- try {
4623
- value.region = new ObjectId11(value.region);
4624
- } catch (error2) {
4625
- throw new Error("Invalid region.");
4626
- }
4627
- }
4628
- if (value.division) {
4629
- try {
4630
- value.division = new ObjectId11(value.division);
4631
- } catch (error2) {
4632
- throw new Error("Invalid division.");
4633
- }
4634
- }
4635
- if (value.createdBy) {
4636
- try {
4637
- value.createdBy = new ObjectId11(value.createdBy);
4638
- } catch (error2) {
4639
- throw new Error("Invalid createdBy.");
4640
- }
4641
- }
4642
4601
  return {
4643
- _id: value._id ? value._id : new ObjectId11(),
4602
+ _id: value._id,
4644
4603
  id: value.id,
4645
4604
  name: value.name,
4646
- country: value.country ?? "",
4647
- address: value.address ?? "",
4648
- continuedAddress: value.continuedAddress ?? "",
4649
- city: value.city ?? "",
4650
- province: value.province ?? "",
4651
- postalCode: value.postalCode ?? "",
4652
- courses: value.courses || [],
4653
- principalName: value.principalName ?? "",
4654
- principalEmail: value.principalEmail ?? "",
4655
- principalNumber: value.principalNumber ?? "",
4656
4605
  region: value.region,
4657
4606
  regionName: value.regionName ?? "",
4658
4607
  division: value.division,
4659
4608
  divisionName: value.divisionName ?? "",
4609
+ principal: value.principal,
4610
+ principalName: value.principalName ?? "",
4611
+ status: value.status ?? "active",
4612
+ street: value.street ?? "",
4613
+ barangay: value.barangay ?? "",
4614
+ city: value.city ?? "",
4615
+ province: value.province ?? "",
4616
+ postalCode: value.postalCode ?? "",
4617
+ contactNumber: value.contactNumber ?? "",
4618
+ email: value.email ?? "",
4619
+ createdBy: value.createdBy ?? "",
4660
4620
  createdAt: value.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
4661
4621
  updatedAt: value.updatedAt ?? "",
4662
- status: value.status ?? "pending",
4663
- createdBy: value.createdBy ?? ""
4622
+ deletedAt: value.deletedAt ?? ""
4664
4623
  };
4665
4624
  }
4666
4625
 
4667
4626
  // src/resources/school/school.repository.ts
4668
4627
  import {
4669
- BadRequestError as BadRequestError17,
4628
+ AppError as AppError6,
4629
+ BadRequestError as BadRequestError18,
4630
+ InternalServerError as InternalServerError7,
4670
4631
  logger as logger13,
4671
4632
  makeCacheKey as makeCacheKey6,
4672
4633
  paginate as paginate6,
@@ -4677,11 +4638,23 @@ import { ObjectId as ObjectId12 } from "mongodb";
4677
4638
  function useSchoolRepo() {
4678
4639
  const db = useAtlas8.getDb();
4679
4640
  if (!db) {
4680
- throw new BadRequestError17("Unable to connect to server.");
4641
+ throw new Error("Unable to connect to server.");
4681
4642
  }
4682
- const namespace_collection = "schools";
4643
+ const namespace_collection = "deped.schools";
4683
4644
  const collection = db.collection(namespace_collection);
4684
4645
  const { getCache, setCache, delNamespace } = useCache6(namespace_collection);
4646
+ async function createIndexes() {
4647
+ try {
4648
+ await collection.createIndexes([
4649
+ { key: { name: 1 } },
4650
+ { key: { createdAt: 1 } },
4651
+ { key: { name: "text" } },
4652
+ { key: { name: 1 }, unique: true, name: "unique_name" }
4653
+ ]);
4654
+ } catch (error) {
4655
+ throw new Error("Failed to create index on schools.");
4656
+ }
4657
+ }
4685
4658
  function delCachedData() {
4686
4659
  delNamespace().then(() => {
4687
4660
  logger13.log({
@@ -4695,85 +4668,64 @@ function useSchoolRepo() {
4695
4668
  });
4696
4669
  });
4697
4670
  }
4698
- async function createIndex() {
4699
- try {
4700
- await collection.createIndexes([
4701
- { key: { name: 1 } },
4702
- { key: { id: 1 }, unique: true },
4703
- { key: { region: 1 } },
4704
- { key: { division: 1 } },
4705
- {
4706
- key: {
4707
- name: "text",
4708
- address: "text",
4709
- continuedAddress: "text",
4710
- city: "text",
4711
- province: "text",
4712
- postalCode: "text",
4713
- regionName: "text",
4714
- divisionName: "text"
4715
- }
4716
- }
4717
- ]);
4718
- } catch (error) {
4719
- throw new BadRequestError17("Failed to create index on school.");
4720
- }
4721
- }
4722
4671
  async function add(value, session) {
4723
4672
  try {
4724
- value = MSchool(value);
4673
+ value = modelSchool(value);
4725
4674
  const res = await collection.insertOne(value, { session });
4726
4675
  delCachedData();
4727
4676
  return res.insertedId;
4728
4677
  } catch (error) {
4729
4678
  logger13.log({
4730
4679
  level: "error",
4731
- message: `Failed to add school: ${error}`
4680
+ message: error.message
4732
4681
  });
4733
- const isDuplicated = error.message.includes("duplicate");
4734
- if (isDuplicated) {
4735
- throw new BadRequestError17("School already exist.");
4682
+ if (error instanceof AppError6) {
4683
+ throw error;
4684
+ } else {
4685
+ const isDuplicated = error.message.includes("duplicate");
4686
+ if (isDuplicated) {
4687
+ throw new BadRequestError18("School already exists.");
4688
+ }
4689
+ throw new Error("Failed to create school.");
4736
4690
  }
4737
- throw error;
4738
4691
  }
4739
4692
  }
4740
4693
  async function getAll({
4694
+ search = "",
4741
4695
  page = 1,
4742
- limit = 20,
4696
+ limit = 10,
4743
4697
  sort = {},
4744
- status = "active",
4745
- org = "",
4746
- app = "admin",
4747
- search = ""
4698
+ status = "active"
4748
4699
  } = {}) {
4749
- page = Math.max(0, page - 1);
4750
- if (sort && Object.keys(sort).length === 0) {
4751
- sort = { name: 1 };
4752
- }
4753
- const query = { status };
4700
+ page = page > 0 ? page - 1 : 0;
4701
+ const query = {
4702
+ deletedAt: { $in: ["", null] },
4703
+ status
4704
+ };
4705
+ sort = Object.keys(sort).length > 0 ? sort : { _id: 1 };
4754
4706
  const cacheKeyOptions = {
4707
+ status,
4755
4708
  page,
4756
4709
  limit,
4757
- sort: JSON.stringify(sort),
4758
- status
4710
+ sort: JSON.stringify(sort)
4759
4711
  };
4760
4712
  if (search) {
4761
4713
  query.$text = { $search: search };
4762
4714
  cacheKeyOptions.search = search;
4763
4715
  }
4764
- if (org) {
4765
- try {
4766
- query[app] = new ObjectId12(org);
4767
- cacheKeyOptions[app] = org;
4768
- } catch (error) {
4769
- throw new BadRequestError17("Invalid org.");
4770
- }
4771
- }
4716
+ const cacheKey = makeCacheKey6(namespace_collection, cacheKeyOptions);
4717
+ logger13.log({
4718
+ level: "info",
4719
+ message: `Cache key for getAll schools: ${cacheKey}`
4720
+ });
4772
4721
  try {
4773
- const cacheKey = makeCacheKey6(namespace_collection, cacheKeyOptions);
4774
- const cachedData = await getCache(cacheKey);
4775
- if (cachedData) {
4776
- return cachedData;
4722
+ const cached = await getCache(cacheKey);
4723
+ if (cached) {
4724
+ logger13.log({
4725
+ level: "info",
4726
+ message: `Cache hit for getAll schools: ${cacheKey}`
4727
+ });
4728
+ return cached;
4777
4729
  }
4778
4730
  const items = await collection.aggregate([
4779
4731
  { $match: query },
@@ -4786,155 +4738,228 @@ function useSchoolRepo() {
4786
4738
  setCache(cacheKey, data, 600).then(() => {
4787
4739
  logger13.log({
4788
4740
  level: "info",
4789
- message: `Cache set for key ${cacheKey}`
4741
+ message: `Cache set for getAll schools: ${cacheKey}`
4790
4742
  });
4791
4743
  }).catch((err) => {
4792
4744
  logger13.log({
4793
4745
  level: "error",
4794
- message: `Failed to set cache for key ${cacheKey}: ${err.message}`
4746
+ message: `Failed to set cache for getAll schools: ${err.message}`
4795
4747
  });
4796
4748
  });
4797
4749
  return data;
4798
4750
  } catch (error) {
4799
- logger13.log({
4800
- level: "error",
4801
- message: `Failed to get all schools: ${error}`
4802
- });
4751
+ logger13.log({ level: "error", message: `${error}` });
4803
4752
  throw error;
4804
4753
  }
4805
4754
  }
4806
- async function updateStatusById(_id, status, session) {
4755
+ async function getById(_id, status) {
4807
4756
  try {
4808
4757
  _id = new ObjectId12(_id);
4809
4758
  } catch (error) {
4810
- throw new BadRequestError17("Invalid school ID.");
4811
- }
4812
- const result = await collection.updateOne(
4813
- { _id },
4814
- { $set: { status, updatedAt: /* @__PURE__ */ new Date() } },
4815
- { session }
4816
- );
4817
- delCachedData();
4818
- return result;
4819
- }
4820
- async function updateFieldById({ _id, field, value } = {}, session) {
4821
- const allowedFields = [
4822
- "name",
4823
- "country",
4824
- "address",
4825
- "continuedAddress",
4826
- "city",
4827
- "province",
4828
- "postalCode",
4829
- "courses",
4830
- "email",
4831
- "principalName",
4832
- "principalEmail",
4833
- "principalNumber",
4834
- "region",
4835
- "regionName",
4836
- "division",
4837
- "divisionName"
4838
- ];
4839
- if (!allowedFields.includes(field)) {
4840
- throw new BadRequestError17(
4841
- `Field "${field}" is not allowed to be updated.`
4842
- );
4759
+ throw new BadRequestError18("Invalid ID.");
4843
4760
  }
4844
- try {
4845
- _id = new ObjectId12(_id);
4846
- } catch (error) {
4847
- throw new BadRequestError17("Invalid ID.");
4761
+ const query = { _id };
4762
+ const cacheKeyOptions = {
4763
+ _id: String(_id),
4764
+ deletedAt: { $in: ["", null] }
4765
+ };
4766
+ if (status) {
4767
+ query.status = status;
4768
+ cacheKeyOptions.status = status;
4848
4769
  }
4770
+ const cacheKey = makeCacheKey6(namespace_collection, cacheKeyOptions);
4849
4771
  try {
4850
- const result = await collection.updateOne(
4851
- { _id },
4852
- { $set: { [field]: value } },
4853
- { session }
4854
- );
4855
- delCachedData();
4772
+ const cached = await getCache(cacheKey);
4773
+ if (cached) {
4774
+ logger13.log({
4775
+ level: "info",
4776
+ message: `Cache hit for getById school: ${cacheKey}`
4777
+ });
4778
+ return cached;
4779
+ }
4780
+ const result = await collection.findOne(query);
4781
+ if (!result) {
4782
+ throw new BadRequestError18("School not found.");
4783
+ }
4784
+ setCache(cacheKey, result, 300).then(() => {
4785
+ logger13.log({
4786
+ level: "info",
4787
+ message: `Cache set for school by id: ${cacheKey}`
4788
+ });
4789
+ }).catch((err) => {
4790
+ logger13.log({
4791
+ level: "error",
4792
+ message: `Failed to set cache for school by id: ${err.message}`
4793
+ });
4794
+ });
4856
4795
  return result;
4857
4796
  } catch (error) {
4858
- throw new BadRequestError17(`Failed to update school ${field}.`);
4797
+ if (error instanceof AppError6) {
4798
+ throw error;
4799
+ } else {
4800
+ throw new InternalServerError7("Failed to get school.");
4801
+ }
4859
4802
  }
4860
4803
  }
4861
4804
  async function getPendingByCreatedBy(createdBy) {
4862
4805
  try {
4863
4806
  createdBy = new ObjectId12(createdBy);
4864
4807
  } catch (error) {
4865
- throw new BadRequestError17("Invalid createdBy ID.");
4866
- }
4867
- const cacheKey = makeCacheKey6(namespace_collection, {
4868
- createdBy,
4869
- status: "pending"
4870
- });
4871
- const cachedData = await getCache(cacheKey);
4872
- if (cachedData) {
4873
- return cachedData;
4808
+ throw new BadRequestError18("Invalid ID.");
4874
4809
  }
4810
+ const cacheKey = makeCacheKey6(namespace_collection, { createdBy });
4875
4811
  try {
4876
- const school = await collection.findOne({ createdBy, status: "pending" });
4877
- setCache(cacheKey, school, 600).then(() => {
4812
+ const cached = await getCache(cacheKey);
4813
+ if (cached) {
4878
4814
  logger13.log({
4879
4815
  level: "info",
4880
- message: `Cache set for school by createdBy: ${cacheKey}`
4816
+ message: `Cache hit for getById school: ${cacheKey}`
4817
+ });
4818
+ return cached;
4819
+ }
4820
+ const result = await collection.findOne({
4821
+ createdBy,
4822
+ status: "pending"
4823
+ });
4824
+ if (!result) {
4825
+ throw new BadRequestError18("School not found.");
4826
+ }
4827
+ setCache(cacheKey, result, 300).then(() => {
4828
+ logger13.log({
4829
+ level: "info",
4830
+ message: `Cache set for school by id: ${cacheKey}`
4881
4831
  });
4882
4832
  }).catch((err) => {
4883
4833
  logger13.log({
4884
4834
  level: "error",
4885
- message: `Failed to set cache for school by createdBy: ${err.message}`
4835
+ message: `Failed to set cache for school by id: ${err.message}`
4886
4836
  });
4887
4837
  });
4888
- return school;
4838
+ return result;
4889
4839
  } catch (error) {
4890
- throw error;
4840
+ if (error instanceof AppError6) {
4841
+ throw error;
4842
+ } else {
4843
+ throw new InternalServerError7("Failed to get school.");
4844
+ }
4891
4845
  }
4892
4846
  }
4893
- async function getPendingById(_id) {
4894
- try {
4895
- _id = new ObjectId12(_id);
4896
- } catch (error) {
4897
- throw new BadRequestError17("Invalid ID.");
4898
- }
4899
- const cacheKey = makeCacheKey6(namespace_collection, {
4900
- _id,
4901
- status: "pending"
4902
- });
4903
- const cachedData = await getCache(cacheKey);
4904
- if (cachedData) {
4905
- return cachedData;
4906
- }
4847
+ async function getByName(name) {
4848
+ const cacheKey = makeCacheKey6(namespace_collection, { name });
4907
4849
  try {
4908
- const school = await collection.findOne({ _id, status: "pending" });
4909
- setCache(cacheKey, school, 600).then(() => {
4850
+ const cached = await getCache(cacheKey);
4851
+ if (cached) {
4852
+ logger13.log({
4853
+ level: "info",
4854
+ message: `Cache hit for getByName school: ${cacheKey}`
4855
+ });
4856
+ return cached;
4857
+ }
4858
+ const result = await collection.findOne({
4859
+ name,
4860
+ deletedAt: { $in: ["", null] }
4861
+ });
4862
+ if (!result) {
4863
+ throw new BadRequestError18("School not found.");
4864
+ }
4865
+ setCache(cacheKey, result, 300).then(() => {
4910
4866
  logger13.log({
4911
4867
  level: "info",
4912
- message: `Cache set for school by ID: ${cacheKey}`
4868
+ message: `Cache set for school by name: ${cacheKey}`
4913
4869
  });
4914
4870
  }).catch((err) => {
4915
4871
  logger13.log({
4916
4872
  level: "error",
4917
- message: `Failed to set cache for school by ID: ${err.message}`
4873
+ message: `Failed to set cache for school by name: ${err.message}`
4918
4874
  });
4919
4875
  });
4920
- return school;
4876
+ return result;
4921
4877
  } catch (error) {
4922
- throw error;
4878
+ if (error instanceof AppError6) {
4879
+ throw error;
4880
+ } else {
4881
+ throw new InternalServerError7("Failed to get school.");
4882
+ }
4883
+ }
4884
+ }
4885
+ async function updateStatusById(_id, status, session) {
4886
+ try {
4887
+ _id = new ObjectId12(_id);
4888
+ } catch (error) {
4889
+ throw new BadRequestError18("Invalid ID.");
4890
+ }
4891
+ try {
4892
+ await collection.updateOne(
4893
+ { _id },
4894
+ { $set: { status, updatedAt: (/* @__PURE__ */ new Date()).toISOString() } },
4895
+ { session }
4896
+ );
4897
+ delCachedData();
4898
+ return `Successfully updated school status to ${status}.`;
4899
+ } catch (error) {
4900
+ if (error instanceof AppError6) {
4901
+ throw error;
4902
+ } else {
4903
+ throw new InternalServerError7("Failed to update school status.");
4904
+ }
4905
+ }
4906
+ }
4907
+ async function updateFieldById({ _id, field, value } = {}, session) {
4908
+ const allowedFields = ["name"];
4909
+ if (!allowedFields.includes(field)) {
4910
+ throw new BadRequestError18(
4911
+ `Field "${field}" is not allowed to be updated.`
4912
+ );
4913
+ }
4914
+ try {
4915
+ _id = new ObjectId12(_id);
4916
+ } catch (error) {
4917
+ throw new BadRequestError18("Invalid ID.");
4918
+ }
4919
+ try {
4920
+ await collection.updateOne(
4921
+ { _id, deletedAt: { $in: ["", null] } },
4922
+ { $set: { [field]: value, updatedAt: (/* @__PURE__ */ new Date()).toISOString() } },
4923
+ { session }
4924
+ );
4925
+ delCachedData();
4926
+ return `Successfully updated school ${field}.`;
4927
+ } catch (error) {
4928
+ throw new InternalServerError7(`Failed to update school ${field}.`);
4929
+ }
4930
+ }
4931
+ async function deleteById(_id) {
4932
+ try {
4933
+ _id = new ObjectId12(_id);
4934
+ } catch (error) {
4935
+ throw new BadRequestError18("Invalid ID.");
4936
+ }
4937
+ try {
4938
+ await collection.updateOne(
4939
+ { _id },
4940
+ { $set: { deletedAt: (/* @__PURE__ */ new Date()).toISOString() } }
4941
+ );
4942
+ delCachedData();
4943
+ return "Successfully deleted school.";
4944
+ } catch (error) {
4945
+ throw new InternalServerError7("Failed to delete school.");
4923
4946
  }
4924
4947
  }
4925
4948
  return {
4926
- createIndex,
4949
+ createIndexes,
4927
4950
  add,
4928
4951
  getAll,
4952
+ getById,
4953
+ getPendingByCreatedBy,
4929
4954
  updateStatusById,
4930
4955
  updateFieldById,
4931
- getPendingByCreatedBy,
4932
- getPendingById
4956
+ deleteById,
4957
+ getByName
4933
4958
  };
4934
4959
  }
4935
4960
 
4936
4961
  // src/resources/school/school.service.ts
4937
- import { BadRequestError as BadRequestError18, useAtlas as useAtlas9, logger as logger14 } from "@eeplatform/nodejs-utils";
4962
+ import { BadRequestError as BadRequestError19, useAtlas as useAtlas9, logger as logger14 } from "@eeplatform/nodejs-utils";
4938
4963
  import { useRoleRepo as useRoleRepo2, useUserRepo, useMemberRepo } from "@eeplatform/core";
4939
4964
 
4940
4965
  // node_modules/xlsx/xlsx.mjs
@@ -36303,7 +36328,7 @@ function useSchoolService() {
36303
36328
  add: addSchool,
36304
36329
  getPendingByCreatedBy,
36305
36330
  updateStatusById,
36306
- getPendingById
36331
+ getById
36307
36332
  } = useSchoolRepo();
36308
36333
  const { addRole } = useRoleRepo2();
36309
36334
  const { getUserById } = useUserRepo();
@@ -36311,11 +36336,11 @@ function useSchoolService() {
36311
36336
  async function register(value) {
36312
36337
  const { error } = schemaSchool.validate(value);
36313
36338
  if (error) {
36314
- throw new BadRequestError18(error.message);
36339
+ throw new BadRequestError19(error.message);
36315
36340
  }
36316
36341
  const existingSchool = await getPendingByCreatedBy(value.createdBy ?? "");
36317
36342
  if (existingSchool) {
36318
- throw new BadRequestError18(
36343
+ throw new BadRequestError19(
36319
36344
  "You already have a pending school registration."
36320
36345
  );
36321
36346
  }
@@ -36328,9 +36353,9 @@ function useSchoolService() {
36328
36353
  }
36329
36354
  }
36330
36355
  async function approve(id) {
36331
- const school = await getPendingById(id);
36356
+ const school = await getById(id, "pending");
36332
36357
  if (!school) {
36333
- throw new BadRequestError18("School registration not found.");
36358
+ throw new BadRequestError19("School registration not found.");
36334
36359
  }
36335
36360
  const session = useAtlas9.getClient()?.startSession();
36336
36361
  if (!session) {
@@ -36354,11 +36379,11 @@ function useSchoolService() {
36354
36379
  session
36355
36380
  );
36356
36381
  if (!school.createdBy) {
36357
- throw new BadRequestError18("School must have a creator.");
36382
+ throw new BadRequestError19("School must have a creator.");
36358
36383
  }
36359
36384
  const user = await getUserById(school.createdBy ?? "");
36360
36385
  if (!user) {
36361
- throw new BadRequestError18("User not found for the school creator.");
36386
+ throw new BadRequestError19("User not found for the school creator.");
36362
36387
  }
36363
36388
  await addMember(
36364
36389
  {
@@ -36388,7 +36413,7 @@ function useSchoolService() {
36388
36413
  async function add(value) {
36389
36414
  const { error } = schemaSchool.validate(value);
36390
36415
  if (error) {
36391
- throw new BadRequestError18(error.message);
36416
+ throw new BadRequestError19(error.message);
36392
36417
  }
36393
36418
  const session = useAtlas9.getClient()?.startSession();
36394
36419
  if (!session) {
@@ -36412,11 +36437,11 @@ function useSchoolService() {
36412
36437
  session
36413
36438
  );
36414
36439
  if (!value.createdBy) {
36415
- throw new BadRequestError18("School must have a creator.");
36440
+ throw new BadRequestError19("School must have a creator.");
36416
36441
  }
36417
36442
  const user = await getUserById(value.createdBy ?? "");
36418
36443
  if (!user) {
36419
- throw new BadRequestError18("User not found for the school creator.");
36444
+ throw new BadRequestError19("User not found for the school creator.");
36420
36445
  }
36421
36446
  await addMember(
36422
36447
  {
@@ -36446,7 +36471,7 @@ function useSchoolService() {
36446
36471
  async function addBulk(file, region, division) {
36447
36472
  const MAX_SIZE = 16 * 1024 * 1024;
36448
36473
  if (file.size > MAX_SIZE) {
36449
- throw new BadRequestError18(
36474
+ throw new BadRequestError19(
36450
36475
  "File size exceeds 16MB limit. Please use a smaller file to ensure transaction compatibility."
36451
36476
  );
36452
36477
  }
@@ -36470,18 +36495,18 @@ function useSchoolService() {
36470
36495
  transformHeader: (header) => header.trim()
36471
36496
  });
36472
36497
  if (parseResult.errors.length > 0) {
36473
- throw new BadRequestError18(
36498
+ throw new BadRequestError19(
36474
36499
  `CSV parsing error: ${parseResult.errors[0].message}`
36475
36500
  );
36476
36501
  }
36477
36502
  schools = parseResult.data;
36478
36503
  } else {
36479
- throw new BadRequestError18(
36504
+ throw new BadRequestError19(
36480
36505
  "Unsupported file type. Please upload an Excel (.xlsx, .xls) or CSV (.csv) file."
36481
36506
  );
36482
36507
  }
36483
36508
  if (!schools || schools.length === 0) {
36484
- throw new BadRequestError18("No data found in the uploaded file.");
36509
+ throw new BadRequestError19("No data found in the uploaded file.");
36485
36510
  }
36486
36511
  const errors = [];
36487
36512
  for (let i = 0; i < schools.length; i++) {
@@ -36506,21 +36531,17 @@ function useSchoolService() {
36506
36531
  const school = {
36507
36532
  id: schoolId.trim(),
36508
36533
  name: schoolName.trim(),
36509
- country: "Philippines",
36510
- // Default country
36511
- address: district.trim(),
36512
- // Use district as address
36513
- continuedAddress: "",
36534
+ street: district.trim(),
36535
+ // Use district as street
36536
+ barangay: "",
36514
36537
  city: district.trim(),
36515
36538
  // Use district as city
36516
36539
  province: "",
36517
36540
  // Will need to be set based on region/division
36518
36541
  postalCode: "",
36519
- courses: [],
36520
- // Empty array for courses
36521
36542
  principalName: "",
36522
- principalEmail: "",
36523
- principalNumber: "",
36543
+ email: "",
36544
+ contactNumber: "",
36524
36545
  region,
36525
36546
  regionName: "",
36526
36547
  // Will be populated from region lookup
@@ -36542,29 +36563,29 @@ function useSchoolService() {
36542
36563
  }
36543
36564
  }
36544
36565
  if (errors.length > 0) {
36545
- throw new BadRequestError18(
36566
+ throw new BadRequestError19(
36546
36567
  `Validation errors found:
36547
36568
  ${errors.slice(0, 10).join("\n")}${errors.length > 10 ? `
36548
36569
  ... and ${errors.length - 10} more errors` : ""}`
36549
36570
  );
36550
36571
  }
36551
36572
  if (validatedSchools.length === 0) {
36552
- throw new BadRequestError18(
36573
+ throw new BadRequestError19(
36553
36574
  "No valid school records found after validation."
36554
36575
  );
36555
36576
  }
36556
36577
  if (totalSize > MAX_SIZE) {
36557
- throw new BadRequestError18(
36578
+ throw new BadRequestError19(
36558
36579
  `Data payload (${Math.round(
36559
36580
  totalSize / 1024 / 1024
36560
36581
  )}MB) exceeds MongoDB transaction limit of 16MB. Please reduce the number of records or split into smaller files.`
36561
36582
  );
36562
36583
  }
36563
36584
  } catch (error) {
36564
- if (error instanceof BadRequestError18) {
36585
+ if (error instanceof BadRequestError19) {
36565
36586
  throw error;
36566
36587
  }
36567
- throw new BadRequestError18(`File processing error: ${error.message}`);
36588
+ throw new BadRequestError19(`File processing error: ${error.message}`);
36568
36589
  }
36569
36590
  const session = useAtlas9.getClient()?.startSession();
36570
36591
  if (!session) {
@@ -36628,7 +36649,7 @@ ${errors.slice(0, 10).join("\n")}${errors.length > 10 ? `
36628
36649
  }
36629
36650
 
36630
36651
  // src/resources/school/school.controller.ts
36631
- import { BadRequestError as BadRequestError19 } from "@eeplatform/nodejs-utils";
36652
+ import { BadRequestError as BadRequestError20 } from "@eeplatform/nodejs-utils";
36632
36653
  import Joi12 from "joi";
36633
36654
  function useSchoolController() {
36634
36655
  const {
@@ -36646,7 +36667,7 @@ function useSchoolController() {
36646
36667
  const payload = req.body;
36647
36668
  const { error } = schemaSchool.validate(payload);
36648
36669
  if (error) {
36649
- next(new BadRequestError19(`Validation error: ${error.message}`));
36670
+ next(new BadRequestError20(`Validation error: ${error.message}`));
36650
36671
  return;
36651
36672
  }
36652
36673
  try {
@@ -36671,7 +36692,7 @@ function useSchoolController() {
36671
36692
  });
36672
36693
  const { error } = validation.validate(req.query);
36673
36694
  if (error) {
36674
- next(new BadRequestError19(`Validation error: ${error.message}`));
36695
+ next(new BadRequestError20(`Validation error: ${error.message}`));
36675
36696
  return;
36676
36697
  }
36677
36698
  const page = parseInt(req.query.page) ?? 1;
@@ -36686,8 +36707,6 @@ function useSchoolController() {
36686
36707
  });
36687
36708
  }
36688
36709
  const status = req.query.status ?? "active";
36689
- const org = req.query.org ?? "";
36690
- const app = req.query.app ?? "admin";
36691
36710
  const search = req.query.search ?? "";
36692
36711
  try {
36693
36712
  const schools = await _getAll({
@@ -36695,8 +36714,6 @@ function useSchoolController() {
36695
36714
  limit,
36696
36715
  sort: sortObj,
36697
36716
  status,
36698
- org,
36699
- app,
36700
36717
  search
36701
36718
  });
36702
36719
  res.status(200).json(schools);
@@ -36710,7 +36727,7 @@ function useSchoolController() {
36710
36727
  const validation = Joi12.string().hex().required();
36711
36728
  const { error } = validation.validate(createdBy);
36712
36729
  if (error) {
36713
- next(new BadRequestError19(`Validation error: ${error.message}`));
36730
+ next(new BadRequestError20(`Validation error: ${error.message}`));
36714
36731
  return;
36715
36732
  }
36716
36733
  try {
@@ -36730,7 +36747,7 @@ function useSchoolController() {
36730
36747
  });
36731
36748
  const { error } = validation.validate({ id: schoolId, status });
36732
36749
  if (error) {
36733
- next(new BadRequestError19(`Validation error: ${error.message}`));
36750
+ next(new BadRequestError20(`Validation error: ${error.message}`));
36734
36751
  return;
36735
36752
  }
36736
36753
  try {
@@ -36745,7 +36762,7 @@ function useSchoolController() {
36745
36762
  const payload = req.body;
36746
36763
  const { error } = schemaSchool.validate(payload);
36747
36764
  if (error) {
36748
- next(new BadRequestError19(`Validation error: ${error.message}`));
36765
+ next(new BadRequestError20(`Validation error: ${error.message}`));
36749
36766
  return;
36750
36767
  }
36751
36768
  try {
@@ -36764,7 +36781,7 @@ function useSchoolController() {
36764
36781
  });
36765
36782
  const { error } = validation.validate({ id: schoolId });
36766
36783
  if (error) {
36767
- next(new BadRequestError19(`Validation error: ${error.message}`));
36784
+ next(new BadRequestError20(`Validation error: ${error.message}`));
36768
36785
  return;
36769
36786
  }
36770
36787
  try {
@@ -36787,7 +36804,7 @@ function useSchoolController() {
36787
36804
  });
36788
36805
  const { error } = validation.validate({ region, division });
36789
36806
  if (error) {
36790
- next(new BadRequestError19(`Validation error: ${error.message}`));
36807
+ next(new BadRequestError20(`Validation error: ${error.message}`));
36791
36808
  return;
36792
36809
  }
36793
36810
  try {
@@ -36811,7 +36828,7 @@ function useSchoolController() {
36811
36828
  }
36812
36829
 
36813
36830
  // src/resources/asset/asset.model.ts
36814
- import { BadRequestError as BadRequestError20 } from "@eeplatform/nodejs-utils";
36831
+ import { BadRequestError as BadRequestError21 } from "@eeplatform/nodejs-utils";
36815
36832
  import Joi13 from "joi";
36816
36833
  import { ObjectId as ObjectId14 } from "mongodb";
36817
36834
  var schemaAsset = Joi13.object({
@@ -36859,19 +36876,19 @@ var schemaAssetUpdateOption = Joi13.object({
36859
36876
  function MAsset(value) {
36860
36877
  const { error } = schemaAsset.validate(value);
36861
36878
  if (error) {
36862
- throw new BadRequestError20(error.message);
36879
+ throw new BadRequestError21(error.message);
36863
36880
  }
36864
36881
  if (value._id && typeof value._id === "string") {
36865
36882
  try {
36866
36883
  value._id = new ObjectId14();
36867
36884
  } catch (error2) {
36868
- throw new BadRequestError20("Invalid ID.");
36885
+ throw new BadRequestError21("Invalid ID.");
36869
36886
  }
36870
36887
  }
36871
36888
  try {
36872
36889
  value.school = new ObjectId14(value.school);
36873
36890
  } catch (error2) {
36874
- throw new BadRequestError20("Invalid school ID.");
36891
+ throw new BadRequestError21("Invalid school ID.");
36875
36892
  }
36876
36893
  value.createdAt = value.createdAt ? new Date(value.createdAt) : /* @__PURE__ */ new Date();
36877
36894
  value.updatedAt = value.updatedAt ? new Date(value.updatedAt) : "";
@@ -36902,7 +36919,7 @@ function MAsset(value) {
36902
36919
 
36903
36920
  // src/resources/asset/asset.repository.ts
36904
36921
  import {
36905
- BadRequestError as BadRequestError21,
36922
+ BadRequestError as BadRequestError22,
36906
36923
  logger as logger15,
36907
36924
  makeCacheKey as makeCacheKey7,
36908
36925
  paginate as paginate7,
@@ -36913,7 +36930,7 @@ import { ObjectId as ObjectId15 } from "mongodb";
36913
36930
  function useAssetRepo() {
36914
36931
  const db = useAtlas10.getDb();
36915
36932
  if (!db) {
36916
- throw new BadRequestError21("Unable to connect to server.");
36933
+ throw new BadRequestError22("Unable to connect to server.");
36917
36934
  }
36918
36935
  const namespace_collection = "school.assets";
36919
36936
  const collection = db.collection(namespace_collection);
@@ -36939,7 +36956,7 @@ function useAssetRepo() {
36939
36956
  { key: { name: "text" } }
36940
36957
  ]);
36941
36958
  } catch (error) {
36942
- throw new BadRequestError21("Failed to create index on asset.");
36959
+ throw new BadRequestError22("Failed to create index on asset.");
36943
36960
  }
36944
36961
  }
36945
36962
  async function add(value) {
@@ -36949,18 +36966,18 @@ function useAssetRepo() {
36949
36966
  delCachedData();
36950
36967
  return res.insertedId;
36951
36968
  } catch (error) {
36952
- throw new BadRequestError21("Failed to create asset item.");
36969
+ throw new BadRequestError22("Failed to create asset item.");
36953
36970
  }
36954
36971
  }
36955
36972
  async function updateById(_id, value, session) {
36956
36973
  const { error } = schemaAssetUpdateOption.validate(value);
36957
36974
  if (error) {
36958
- throw new BadRequestError21(error.message);
36975
+ throw new BadRequestError22(error.message);
36959
36976
  }
36960
36977
  try {
36961
36978
  _id = new ObjectId15(_id);
36962
36979
  } catch (error2) {
36963
- throw new BadRequestError21("Invalid ID.");
36980
+ throw new BadRequestError22("Invalid ID.");
36964
36981
  }
36965
36982
  try {
36966
36983
  const res = await collection.updateOne(
@@ -36973,14 +36990,14 @@ function useAssetRepo() {
36973
36990
  }
36974
36991
  return "Successfully updated asset item.";
36975
36992
  } catch (error2) {
36976
- throw new BadRequestError21("Failed to update asset item.");
36993
+ throw new BadRequestError22("Failed to update asset item.");
36977
36994
  }
36978
36995
  }
36979
36996
  async function deleteById(_id) {
36980
36997
  try {
36981
36998
  _id = new ObjectId15(_id);
36982
36999
  } catch (error) {
36983
- throw new BadRequestError21("Invalid ID.");
37000
+ throw new BadRequestError22("Invalid ID.");
36984
37001
  }
36985
37002
  try {
36986
37003
  const res = await collection.deleteOne({ _id });
@@ -36990,14 +37007,14 @@ function useAssetRepo() {
36990
37007
  }
36991
37008
  return "Successfully deleted asset item.";
36992
37009
  } catch (error) {
36993
- throw new BadRequestError21("Failed to delete asset item.");
37010
+ throw new BadRequestError22("Failed to delete asset item.");
36994
37011
  }
36995
37012
  }
36996
37013
  async function getById(_id) {
36997
37014
  try {
36998
37015
  _id = new ObjectId15(_id);
36999
37016
  } catch (error) {
37000
- throw new BadRequestError21("Invalid ID.");
37017
+ throw new BadRequestError22("Invalid ID.");
37001
37018
  }
37002
37019
  const cacheKey = makeCacheKey7(namespace_collection, { _id: String(_id) });
37003
37020
  const cachedData = await getCache(cacheKey);
@@ -37007,7 +37024,7 @@ function useAssetRepo() {
37007
37024
  try {
37008
37025
  const res = await collection.findOne({ _id });
37009
37026
  if (!res) {
37010
- throw new BadRequestError21("Asset item not found.");
37027
+ throw new BadRequestError22("Asset item not found.");
37011
37028
  }
37012
37029
  setCache(cacheKey, res).then(() => {
37013
37030
  logger15.log({
@@ -37022,10 +37039,10 @@ function useAssetRepo() {
37022
37039
  });
37023
37040
  return res;
37024
37041
  } catch (error) {
37025
- if (error instanceof BadRequestError21) {
37042
+ if (error instanceof BadRequestError22) {
37026
37043
  throw error;
37027
37044
  }
37028
- throw new BadRequestError21("Failed to retrieve asset item.");
37045
+ throw new BadRequestError22("Failed to retrieve asset item.");
37029
37046
  }
37030
37047
  }
37031
37048
  async function getAll({
@@ -37041,7 +37058,7 @@ function useAssetRepo() {
37041
37058
  try {
37042
37059
  school = new ObjectId15(school);
37043
37060
  } catch (error) {
37044
- throw new BadRequestError21("Invalid school ID.");
37061
+ throw new BadRequestError22("Invalid school ID.");
37045
37062
  }
37046
37063
  const query = {
37047
37064
  school,
@@ -37098,14 +37115,14 @@ function useAssetRepo() {
37098
37115
  return data;
37099
37116
  } catch (error) {
37100
37117
  console.log("Error in getAll:", error);
37101
- throw new BadRequestError21("Failed to retrieve asset items.");
37118
+ throw new BadRequestError22("Failed to retrieve asset items.");
37102
37119
  }
37103
37120
  }
37104
37121
  async function getCategories(school, asset_type) {
37105
37122
  try {
37106
37123
  school = new ObjectId15(school);
37107
37124
  } catch (error) {
37108
- throw new BadRequestError21("Invalid school ID.");
37125
+ throw new BadRequestError22("Invalid school ID.");
37109
37126
  }
37110
37127
  const cacheKey = makeCacheKey7(namespace_collection, {
37111
37128
  school,
@@ -37152,17 +37169,17 @@ function useAssetRepo() {
37152
37169
  });
37153
37170
  return categories;
37154
37171
  } catch (error) {
37155
- if (error instanceof BadRequestError21) {
37172
+ if (error instanceof BadRequestError22) {
37156
37173
  throw error;
37157
37174
  }
37158
- throw new BadRequestError21("Failed to retrieve asset categories.");
37175
+ throw new BadRequestError22("Failed to retrieve asset categories.");
37159
37176
  }
37160
37177
  }
37161
37178
  async function getTypes(school, asset_type) {
37162
37179
  try {
37163
37180
  school = new ObjectId15(school);
37164
37181
  } catch (error) {
37165
- throw new BadRequestError21("Invalid school ID.");
37182
+ throw new BadRequestError22("Invalid school ID.");
37166
37183
  }
37167
37184
  const cacheKey = makeCacheKey7(namespace_collection, {
37168
37185
  school,
@@ -37212,17 +37229,17 @@ function useAssetRepo() {
37212
37229
  });
37213
37230
  return categories;
37214
37231
  } catch (error) {
37215
- if (error instanceof BadRequestError21) {
37232
+ if (error instanceof BadRequestError22) {
37216
37233
  throw error;
37217
37234
  }
37218
- throw new BadRequestError21("Failed to retrieve asset categories.");
37235
+ throw new BadRequestError22("Failed to retrieve asset categories.");
37219
37236
  }
37220
37237
  }
37221
37238
  async function getUnitsBySchool(school) {
37222
37239
  try {
37223
37240
  school = new ObjectId15(school);
37224
37241
  } catch (error) {
37225
- throw new BadRequestError21("Invalid school ID.");
37242
+ throw new BadRequestError22("Invalid school ID.");
37226
37243
  }
37227
37244
  const cacheKey = makeCacheKey7(namespace_collection, {
37228
37245
  school,
@@ -37269,10 +37286,10 @@ function useAssetRepo() {
37269
37286
  return categories;
37270
37287
  } catch (error) {
37271
37288
  console.log(error);
37272
- if (error instanceof BadRequestError21) {
37289
+ if (error instanceof BadRequestError22) {
37273
37290
  throw error;
37274
37291
  }
37275
- throw new BadRequestError21(
37292
+ throw new BadRequestError22(
37276
37293
  "Failed to retrieve asset unit of measurements."
37277
37294
  );
37278
37295
  }
@@ -37291,7 +37308,7 @@ function useAssetRepo() {
37291
37308
  }
37292
37309
 
37293
37310
  // src/resources/asset/asset.controller.ts
37294
- import { BadRequestError as BadRequestError22 } from "@eeplatform/nodejs-utils";
37311
+ import { BadRequestError as BadRequestError23 } from "@eeplatform/nodejs-utils";
37295
37312
  import Joi14 from "joi";
37296
37313
  function useAssetController() {
37297
37314
  const {
@@ -37308,7 +37325,7 @@ function useAssetController() {
37308
37325
  const value = req.body;
37309
37326
  const { error } = schemaAsset.validate(value);
37310
37327
  if (error) {
37311
- next(new BadRequestError22(error.message));
37328
+ next(new BadRequestError23(error.message));
37312
37329
  return;
37313
37330
  }
37314
37331
  try {
@@ -37337,16 +37354,16 @@ function useAssetController() {
37337
37354
  const asset_type = req.query.asset_type ?? "supply";
37338
37355
  const isPageNumber = isFinite(page);
37339
37356
  if (!isPageNumber) {
37340
- next(new BadRequestError22("Invalid page number."));
37357
+ next(new BadRequestError23("Invalid page number."));
37341
37358
  return;
37342
37359
  }
37343
37360
  const isLimitNumber = isFinite(limit);
37344
37361
  if (!isLimitNumber) {
37345
- next(new BadRequestError22("Invalid limit number."));
37362
+ next(new BadRequestError23("Invalid limit number."));
37346
37363
  return;
37347
37364
  }
37348
37365
  if (error) {
37349
- next(new BadRequestError22(error.message));
37366
+ next(new BadRequestError23(error.message));
37350
37367
  return;
37351
37368
  }
37352
37369
  try {
@@ -37369,7 +37386,7 @@ function useAssetController() {
37369
37386
  const validation = Joi14.string().hex().required();
37370
37387
  const { error } = validation.validate(id);
37371
37388
  if (error) {
37372
- next(new BadRequestError22(error.message));
37389
+ next(new BadRequestError23(error.message));
37373
37390
  return;
37374
37391
  }
37375
37392
  try {
@@ -37384,7 +37401,7 @@ function useAssetController() {
37384
37401
  const validation = Joi14.string().hex().required();
37385
37402
  const { error } = validation.validate(id);
37386
37403
  if (error) {
37387
- next(new BadRequestError22(error.message));
37404
+ next(new BadRequestError23(error.message));
37388
37405
  return;
37389
37406
  }
37390
37407
  try {
@@ -37399,7 +37416,7 @@ function useAssetController() {
37399
37416
  const value = req.body;
37400
37417
  const { error } = schemaAssetUpdateOption.validate(value);
37401
37418
  if (error) {
37402
- next(new BadRequestError22(error.message));
37419
+ next(new BadRequestError23(error.message));
37403
37420
  return;
37404
37421
  }
37405
37422
  try {
@@ -37415,7 +37432,7 @@ function useAssetController() {
37415
37432
  const validation = Joi14.string().hex().required();
37416
37433
  const { error } = validation.validate(school);
37417
37434
  if (error) {
37418
- next(new BadRequestError22(error.message));
37435
+ next(new BadRequestError23(error.message));
37419
37436
  return;
37420
37437
  }
37421
37438
  try {
@@ -37431,7 +37448,7 @@ function useAssetController() {
37431
37448
  const validation = Joi14.string().hex().required();
37432
37449
  const { error } = validation.validate(school);
37433
37450
  if (error) {
37434
- next(new BadRequestError22(error.message));
37451
+ next(new BadRequestError23(error.message));
37435
37452
  return;
37436
37453
  }
37437
37454
  try {
@@ -37446,7 +37463,7 @@ function useAssetController() {
37446
37463
  const validation = Joi14.string().hex().required();
37447
37464
  const { error } = validation.validate(school);
37448
37465
  if (error) {
37449
- next(new BadRequestError22(error.message));
37466
+ next(new BadRequestError23(error.message));
37450
37467
  return;
37451
37468
  }
37452
37469
  try {
@@ -37469,7 +37486,7 @@ function useAssetController() {
37469
37486
  }
37470
37487
 
37471
37488
  // src/resources/stock-card/stock-card.model.ts
37472
- import { BadRequestError as BadRequestError23 } from "@eeplatform/nodejs-utils";
37489
+ import { BadRequestError as BadRequestError24 } from "@eeplatform/nodejs-utils";
37473
37490
  import Joi15 from "joi";
37474
37491
  import { ObjectId as ObjectId16 } from "mongodb";
37475
37492
  var schemaStockCard = Joi15.object({
@@ -37494,24 +37511,24 @@ var schemaStockCard = Joi15.object({
37494
37511
  function MStockCard(value) {
37495
37512
  const { error } = schemaStockCard.validate(value);
37496
37513
  if (error) {
37497
- throw new BadRequestError23(`Invalid stock card data: ${error.message}`);
37514
+ throw new BadRequestError24(`Invalid stock card data: ${error.message}`);
37498
37515
  }
37499
37516
  if (value._id && typeof value._id === "string") {
37500
37517
  try {
37501
37518
  value._id = new ObjectId16(value._id);
37502
37519
  } catch (err) {
37503
- throw new BadRequestError23("Invalid stock card ID.");
37520
+ throw new BadRequestError24("Invalid stock card ID.");
37504
37521
  }
37505
37522
  }
37506
37523
  try {
37507
37524
  value.item = new ObjectId16(value.item);
37508
37525
  } catch (err) {
37509
- throw new BadRequestError23("Invalid item ID.");
37526
+ throw new BadRequestError24("Invalid item ID.");
37510
37527
  }
37511
37528
  try {
37512
37529
  value.school = new ObjectId16(value.school);
37513
37530
  } catch (err) {
37514
- throw new BadRequestError23("Invalid school ID.");
37531
+ throw new BadRequestError24("Invalid school ID.");
37515
37532
  }
37516
37533
  return {
37517
37534
  _id: value._id ?? void 0,
@@ -37536,7 +37553,7 @@ function MStockCard(value) {
37536
37553
 
37537
37554
  // src/resources/stock-card/stock-card.repository.ts
37538
37555
  import {
37539
- BadRequestError as BadRequestError24,
37556
+ BadRequestError as BadRequestError25,
37540
37557
  logger as logger16,
37541
37558
  makeCacheKey as makeCacheKey8,
37542
37559
  paginate as paginate8,
@@ -37547,7 +37564,7 @@ import { ObjectId as ObjectId17 } from "mongodb";
37547
37564
  function useStockCardRepository() {
37548
37565
  const db = useAtlas11.getDb();
37549
37566
  if (!db) {
37550
- throw new BadRequestError24("Unable to connect to server.");
37567
+ throw new BadRequestError25("Unable to connect to server.");
37551
37568
  }
37552
37569
  const namespace_collection = "school.assets.stock-cards";
37553
37570
  const collection = db.collection(namespace_collection);
@@ -37572,7 +37589,7 @@ function useStockCardRepository() {
37572
37589
  { key: { item: 1 } }
37573
37590
  ]);
37574
37591
  } catch (error) {
37575
- throw new BadRequestError24("Failed to create index on stock card.");
37592
+ throw new BadRequestError25("Failed to create index on stock card.");
37576
37593
  }
37577
37594
  }
37578
37595
  async function add(value, session) {
@@ -37582,14 +37599,14 @@ function useStockCardRepository() {
37582
37599
  delCachedData();
37583
37600
  return res.insertedId;
37584
37601
  } catch (error) {
37585
- throw new BadRequestError24("Failed to create stock card.");
37602
+ throw new BadRequestError25("Failed to create stock card.");
37586
37603
  }
37587
37604
  }
37588
37605
  async function getById(_id) {
37589
37606
  try {
37590
37607
  _id = new ObjectId17(_id);
37591
37608
  } catch (error) {
37592
- throw new BadRequestError24("Invalid ID.");
37609
+ throw new BadRequestError25("Invalid ID.");
37593
37610
  }
37594
37611
  const cacheKey = makeCacheKey8(namespace_collection, { _id: String(_id) });
37595
37612
  const cachedData = await getCache(cacheKey);
@@ -37599,7 +37616,7 @@ function useStockCardRepository() {
37599
37616
  try {
37600
37617
  const res = await collection.findOne({ _id });
37601
37618
  if (!res) {
37602
- throw new BadRequestError24("Asset item not found.");
37619
+ throw new BadRequestError25("Asset item not found.");
37603
37620
  }
37604
37621
  setCache(cacheKey, res).then(() => {
37605
37622
  logger16.log({
@@ -37614,10 +37631,10 @@ function useStockCardRepository() {
37614
37631
  });
37615
37632
  return res;
37616
37633
  } catch (error) {
37617
- if (error instanceof BadRequestError24) {
37634
+ if (error instanceof BadRequestError25) {
37618
37635
  throw error;
37619
37636
  }
37620
- throw new BadRequestError24("Failed to retrieve stock card.");
37637
+ throw new BadRequestError25("Failed to retrieve stock card.");
37621
37638
  }
37622
37639
  }
37623
37640
  async function getAll({ page = 1, limit = 20, school = "", sort = { _id: 1 }, id = "" } = {}) {
@@ -37625,12 +37642,12 @@ function useStockCardRepository() {
37625
37642
  try {
37626
37643
  school = new ObjectId17(school);
37627
37644
  } catch (error) {
37628
- throw new BadRequestError24("Invalid school ID.");
37645
+ throw new BadRequestError25("Invalid school ID.");
37629
37646
  }
37630
37647
  try {
37631
37648
  id = new ObjectId17(id);
37632
37649
  } catch (error) {
37633
- throw new BadRequestError24("Invalid ID.");
37650
+ throw new BadRequestError25("Invalid ID.");
37634
37651
  }
37635
37652
  const query = {
37636
37653
  school,
@@ -37681,14 +37698,14 @@ function useStockCardRepository() {
37681
37698
  return data;
37682
37699
  } catch (error) {
37683
37700
  console.log("Error in getAll:", error);
37684
- throw new BadRequestError24("Failed to retrieve stock cards.");
37701
+ throw new BadRequestError25("Failed to retrieve stock cards.");
37685
37702
  }
37686
37703
  }
37687
37704
  async function getSuppliers(school) {
37688
37705
  try {
37689
37706
  school = new ObjectId17(school);
37690
37707
  } catch (error) {
37691
- throw new BadRequestError24("Invalid school ID.");
37708
+ throw new BadRequestError25("Invalid school ID.");
37692
37709
  }
37693
37710
  const cacheKey = makeCacheKey8(namespace_collection, {
37694
37711
  school,
@@ -37734,10 +37751,10 @@ function useStockCardRepository() {
37734
37751
  });
37735
37752
  return suppliers;
37736
37753
  } catch (error) {
37737
- if (error instanceof BadRequestError24) {
37754
+ if (error instanceof BadRequestError25) {
37738
37755
  throw error;
37739
37756
  }
37740
- throw new BadRequestError24("Failed to retrieve asset suppliers.");
37757
+ throw new BadRequestError25("Failed to retrieve asset suppliers.");
37741
37758
  }
37742
37759
  }
37743
37760
  return {
@@ -37751,7 +37768,7 @@ function useStockCardRepository() {
37751
37768
 
37752
37769
  // src/resources/stock-card/stock-card.service.ts
37753
37770
  import {
37754
- BadRequestError as BadRequestError25,
37771
+ BadRequestError as BadRequestError26,
37755
37772
  NotFoundError as NotFoundError2,
37756
37773
  useAtlas as useAtlas12
37757
37774
  } from "@eeplatform/nodejs-utils";
@@ -37761,7 +37778,7 @@ function useStockCardService() {
37761
37778
  async function add(data) {
37762
37779
  const session = useAtlas12.getClient()?.startSession();
37763
37780
  if (!session) {
37764
- throw new BadRequestError25("Unable to start database session.");
37781
+ throw new BadRequestError26("Unable to start database session.");
37765
37782
  }
37766
37783
  session.startTransaction();
37767
37784
  try {
@@ -37776,7 +37793,7 @@ function useStockCardService() {
37776
37793
  return "Successfully added stock card.";
37777
37794
  } catch (error) {
37778
37795
  await session.abortTransaction();
37779
- throw new BadRequestError25("Failed to add stock card.");
37796
+ throw new BadRequestError26("Failed to add stock card.");
37780
37797
  } finally {
37781
37798
  session.endSession();
37782
37799
  }
@@ -37787,7 +37804,7 @@ function useStockCardService() {
37787
37804
  }
37788
37805
 
37789
37806
  // src/resources/stock-card/stock-card.controller.ts
37790
- import { BadRequestError as BadRequestError26 } from "@eeplatform/nodejs-utils";
37807
+ import { BadRequestError as BadRequestError27 } from "@eeplatform/nodejs-utils";
37791
37808
  import Joi16 from "joi";
37792
37809
  function useStockCardController() {
37793
37810
  const {
@@ -37800,7 +37817,7 @@ function useStockCardController() {
37800
37817
  const value = req.body;
37801
37818
  const { error } = schemaStockCard.validate(value);
37802
37819
  if (error) {
37803
- next(new BadRequestError26(error.message));
37820
+ next(new BadRequestError27(error.message));
37804
37821
  return;
37805
37822
  }
37806
37823
  try {
@@ -37825,16 +37842,16 @@ function useStockCardController() {
37825
37842
  const id = req.query.id ?? "supply";
37826
37843
  const isPageNumber = isFinite(page);
37827
37844
  if (!isPageNumber) {
37828
- next(new BadRequestError26("Invalid page number."));
37845
+ next(new BadRequestError27("Invalid page number."));
37829
37846
  return;
37830
37847
  }
37831
37848
  const isLimitNumber = isFinite(limit);
37832
37849
  if (!isLimitNumber) {
37833
- next(new BadRequestError26("Invalid limit number."));
37850
+ next(new BadRequestError27("Invalid limit number."));
37834
37851
  return;
37835
37852
  }
37836
37853
  if (error) {
37837
- next(new BadRequestError26(error.message));
37854
+ next(new BadRequestError27(error.message));
37838
37855
  return;
37839
37856
  }
37840
37857
  try {
@@ -37855,7 +37872,7 @@ function useStockCardController() {
37855
37872
  const validation = Joi16.string().hex().required();
37856
37873
  const { error } = validation.validate(id);
37857
37874
  if (error) {
37858
- next(new BadRequestError26(error.message));
37875
+ next(new BadRequestError27(error.message));
37859
37876
  return;
37860
37877
  }
37861
37878
  try {
@@ -37870,7 +37887,7 @@ function useStockCardController() {
37870
37887
  const validation = Joi16.string().hex().required();
37871
37888
  const { error } = validation.validate(school);
37872
37889
  if (error) {
37873
- next(new BadRequestError26(error.message));
37890
+ next(new BadRequestError27(error.message));
37874
37891
  return;
37875
37892
  }
37876
37893
  try {
@@ -37889,7 +37906,7 @@ function useStockCardController() {
37889
37906
  }
37890
37907
 
37891
37908
  // src/resources/plantilla/plantilla.model.ts
37892
- import { BadRequestError as BadRequestError27 } from "@eeplatform/nodejs-utils";
37909
+ import { BadRequestError as BadRequestError28 } from "@eeplatform/nodejs-utils";
37893
37910
  import Joi17 from "joi";
37894
37911
  import { ObjectId as ObjectId18 } from "mongodb";
37895
37912
  var schemaPlantilla = Joi17.object({
@@ -37918,13 +37935,13 @@ var schemaPlantilla = Joi17.object({
37918
37935
  function MPlantilla(data) {
37919
37936
  const { error } = schemaPlantilla.validate(data);
37920
37937
  if (error) {
37921
- throw new BadRequestError27(error.message);
37938
+ throw new BadRequestError28(error.message);
37922
37939
  }
37923
37940
  if (data._id && typeof data._id === "string") {
37924
37941
  try {
37925
37942
  data._id = new ObjectId18(data._id);
37926
37943
  } catch (error2) {
37927
- throw new BadRequestError27("Invalid _id.");
37944
+ throw new BadRequestError28("Invalid _id.");
37928
37945
  }
37929
37946
  }
37930
37947
  return {
@@ -37954,9 +37971,9 @@ function MPlantilla(data) {
37954
37971
 
37955
37972
  // src/resources/plantilla/plantilla.repository.ts
37956
37973
  import {
37957
- AppError as AppError6,
37958
- BadRequestError as BadRequestError28,
37959
- InternalServerError as InternalServerError7,
37974
+ AppError as AppError7,
37975
+ BadRequestError as BadRequestError29,
37976
+ InternalServerError as InternalServerError8,
37960
37977
  logger as logger17,
37961
37978
  makeCacheKey as makeCacheKey9,
37962
37979
  paginate as paginate9,
@@ -37997,12 +38014,12 @@ function usePlantillaRepo() {
37997
38014
  level: "error",
37998
38015
  message: error.message
37999
38016
  });
38000
- if (error instanceof AppError6) {
38017
+ if (error instanceof AppError7) {
38001
38018
  throw error;
38002
38019
  } else {
38003
38020
  const isDuplicated = error.message.includes("duplicate");
38004
38021
  if (isDuplicated) {
38005
- throw new BadRequestError28("Plantilla already exists.");
38022
+ throw new BadRequestError29("Plantilla already exists.");
38006
38023
  }
38007
38024
  throw new Error("Failed to create plantilla.");
38008
38025
  }
@@ -38012,7 +38029,7 @@ function usePlantillaRepo() {
38012
38029
  try {
38013
38030
  _id = new ObjectId19(_id);
38014
38031
  } catch (error) {
38015
- throw new BadRequestError28("Invalid ID.");
38032
+ throw new BadRequestError29("Invalid ID.");
38016
38033
  }
38017
38034
  value.updatedAt = /* @__PURE__ */ new Date();
38018
38035
  try {
@@ -38028,7 +38045,7 @@ function usePlantillaRepo() {
38028
38045
  level: "error",
38029
38046
  message: error.message
38030
38047
  });
38031
- if (error instanceof AppError6) {
38048
+ if (error instanceof AppError7) {
38032
38049
  throw error;
38033
38050
  } else {
38034
38051
  throw new Error("Failed to update plantilla.");
@@ -38055,7 +38072,7 @@ function usePlantillaRepo() {
38055
38072
  try {
38056
38073
  query.org = new ObjectId19(org);
38057
38074
  } catch (error) {
38058
- throw new BadRequestError28("Invalid org ID.");
38075
+ throw new BadRequestError29("Invalid org ID.");
38059
38076
  }
38060
38077
  }
38061
38078
  const cacheParams = {
@@ -38112,7 +38129,7 @@ function usePlantillaRepo() {
38112
38129
  try {
38113
38130
  _id = new ObjectId19(_id);
38114
38131
  } catch (error) {
38115
- throw new BadRequestError28("Invalid ID.");
38132
+ throw new BadRequestError29("Invalid ID.");
38116
38133
  }
38117
38134
  const cacheKey = makeCacheKey9(namespace_collection, { _id: String(_id) });
38118
38135
  try {
@@ -38140,10 +38157,10 @@ function usePlantillaRepo() {
38140
38157
  });
38141
38158
  return result;
38142
38159
  } catch (error) {
38143
- if (error instanceof AppError6) {
38160
+ if (error instanceof AppError7) {
38144
38161
  throw error;
38145
38162
  } else {
38146
- throw new InternalServerError7("Failed to get plantilla.");
38163
+ throw new InternalServerError8("Failed to get plantilla.");
38147
38164
  }
38148
38165
  }
38149
38166
  }
@@ -38151,7 +38168,7 @@ function usePlantillaRepo() {
38151
38168
  try {
38152
38169
  _id = new ObjectId19(_id);
38153
38170
  } catch (error) {
38154
- throw new BadRequestError28("Invalid ID.");
38171
+ throw new BadRequestError29("Invalid ID.");
38155
38172
  }
38156
38173
  try {
38157
38174
  const res = await collection.updateOne(
@@ -38165,10 +38182,10 @@ function usePlantillaRepo() {
38165
38182
  level: "error",
38166
38183
  message: error.message
38167
38184
  });
38168
- if (error instanceof AppError6) {
38185
+ if (error instanceof AppError7) {
38169
38186
  throw error;
38170
38187
  } else {
38171
- throw new InternalServerError7("Failed to delete plantilla.");
38188
+ throw new InternalServerError8("Failed to delete plantilla.");
38172
38189
  }
38173
38190
  }
38174
38191
  }
@@ -38197,7 +38214,7 @@ function usePlantillaRepo() {
38197
38214
  }
38198
38215
 
38199
38216
  // src/resources/plantilla/plantilla.service.ts
38200
- import { BadRequestError as BadRequestError29, useAtlas as useAtlas14, logger as logger18 } from "@eeplatform/nodejs-utils";
38217
+ import { BadRequestError as BadRequestError30, useAtlas as useAtlas14, logger as logger18 } from "@eeplatform/nodejs-utils";
38201
38218
  var Papa2 = __toESM(require_papaparse());
38202
38219
  function usePlantillaService() {
38203
38220
  const { add: addPlantilla, delCachedData } = usePlantillaRepo();
@@ -38211,7 +38228,7 @@ function usePlantillaService() {
38211
38228
  let totalSize = 0;
38212
38229
  let validatedPlantillas = [];
38213
38230
  if (!file.buffer) {
38214
- throw new BadRequestError29("File buffer is empty or corrupted");
38231
+ throw new BadRequestError30("File buffer is empty or corrupted");
38215
38232
  }
38216
38233
  try {
38217
38234
  const fileExtension = file.originalname.split(".").pop()?.toLowerCase();
@@ -38226,7 +38243,7 @@ function usePlantillaService() {
38226
38243
  }
38227
38244
  });
38228
38245
  if (parseResult.errors.length > 0) {
38229
- throw new BadRequestError29(
38246
+ throw new BadRequestError30(
38230
38247
  `CSV parsing errors: ${parseResult.errors.map((e) => e.message).join(", ")}`
38231
38248
  );
38232
38249
  }
@@ -38241,7 +38258,7 @@ function usePlantillaService() {
38241
38258
  defval: ""
38242
38259
  });
38243
38260
  if (plantillas.length === 0) {
38244
- throw new BadRequestError29("Excel file is empty.");
38261
+ throw new BadRequestError30("Excel file is empty.");
38245
38262
  }
38246
38263
  const headers = plantillas[0];
38247
38264
  const normalizedHeaders = headers.map(
@@ -38255,12 +38272,12 @@ function usePlantillaService() {
38255
38272
  return obj;
38256
38273
  });
38257
38274
  } else {
38258
- throw new BadRequestError29(
38275
+ throw new BadRequestError30(
38259
38276
  "Unsupported file type. Please upload an Excel (.xlsx, .xls) or CSV (.csv) file."
38260
38277
  );
38261
38278
  }
38262
38279
  if (!plantillas || plantillas.length === 0) {
38263
- throw new BadRequestError29("No data found in the uploaded file.");
38280
+ throw new BadRequestError30("No data found in the uploaded file.");
38264
38281
  }
38265
38282
  const errors = [];
38266
38283
  for (let i = 0; i < plantillas.length; i++) {
@@ -38329,29 +38346,29 @@ function usePlantillaService() {
38329
38346
  }
38330
38347
  }
38331
38348
  if (errors.length > 0) {
38332
- throw new BadRequestError29(
38349
+ throw new BadRequestError30(
38333
38350
  `Validation errors found:
38334
38351
  ${errors.slice(0, 10).join("\n")}${errors.length > 10 ? `
38335
38352
  ... and ${errors.length - 10} more errors` : ""}`
38336
38353
  );
38337
38354
  }
38338
38355
  if (validatedPlantillas.length === 0) {
38339
- throw new BadRequestError29(
38356
+ throw new BadRequestError30(
38340
38357
  "No valid plantilla records found after validation."
38341
38358
  );
38342
38359
  }
38343
38360
  if (totalSize > MAX_SIZE) {
38344
- throw new BadRequestError29(
38361
+ throw new BadRequestError30(
38345
38362
  `Data payload (${Math.round(
38346
38363
  totalSize / 1024 / 1024
38347
38364
  )}MB) exceeds MongoDB transaction limit of 16MB. Please reduce the number of records or split into smaller files.`
38348
38365
  );
38349
38366
  }
38350
38367
  } catch (error) {
38351
- if (error instanceof BadRequestError29) {
38368
+ if (error instanceof BadRequestError30) {
38352
38369
  throw error;
38353
38370
  }
38354
- throw new BadRequestError29(`File processing error: ${error.message}`);
38371
+ throw new BadRequestError30(`File processing error: ${error.message}`);
38355
38372
  }
38356
38373
  const session = useAtlas14.getClient()?.startSession();
38357
38374
  if (!session) {
@@ -38403,7 +38420,7 @@ ${errors.slice(0, 10).join("\n")}${errors.length > 10 ? `
38403
38420
  }
38404
38421
 
38405
38422
  // src/resources/plantilla/plantilla.controller.ts
38406
- import { BadRequestError as BadRequestError30 } from "@eeplatform/nodejs-utils";
38423
+ import { BadRequestError as BadRequestError31 } from "@eeplatform/nodejs-utils";
38407
38424
  import Joi18 from "joi";
38408
38425
  function usePlantillaController() {
38409
38426
  const {
@@ -38424,7 +38441,7 @@ function usePlantillaController() {
38424
38441
  });
38425
38442
  const { error } = validation.validate(value);
38426
38443
  if (error) {
38427
- next(new BadRequestError30(error.message));
38444
+ next(new BadRequestError31(error.message));
38428
38445
  return;
38429
38446
  }
38430
38447
  try {
@@ -38442,12 +38459,12 @@ function usePlantillaController() {
38442
38459
  const org = req.query.org ?? "";
38443
38460
  const isPageNumber = isFinite(page);
38444
38461
  if (!isPageNumber) {
38445
- next(new BadRequestError30("Invalid page number."));
38462
+ next(new BadRequestError31("Invalid page number."));
38446
38463
  return;
38447
38464
  }
38448
38465
  const isLimitNumber = isFinite(limit);
38449
38466
  if (!isLimitNumber) {
38450
- next(new BadRequestError30("Invalid limit number."));
38467
+ next(new BadRequestError31("Invalid limit number."));
38451
38468
  return;
38452
38469
  }
38453
38470
  const validation = Joi18.object({
@@ -38458,7 +38475,7 @@ function usePlantillaController() {
38458
38475
  });
38459
38476
  const { error } = validation.validate({ page, limit, search, org });
38460
38477
  if (error) {
38461
- next(new BadRequestError30(error.message));
38478
+ next(new BadRequestError31(error.message));
38462
38479
  return;
38463
38480
  }
38464
38481
  try {
@@ -38481,13 +38498,13 @@ function usePlantillaController() {
38481
38498
  });
38482
38499
  const { error } = validation.validate({ id });
38483
38500
  if (error) {
38484
- next(new BadRequestError30(error.message));
38501
+ next(new BadRequestError31(error.message));
38485
38502
  return;
38486
38503
  }
38487
38504
  try {
38488
38505
  const plantilla = await _getPlantillaById(id);
38489
38506
  if (!plantilla) {
38490
- next(new BadRequestError30("Plantilla not found."));
38507
+ next(new BadRequestError31("Plantilla not found."));
38491
38508
  return;
38492
38509
  }
38493
38510
  res.json(plantilla);
@@ -38508,13 +38525,13 @@ function usePlantillaController() {
38508
38525
  });
38509
38526
  const { error } = validation.validate({ id, ...value });
38510
38527
  if (error) {
38511
- next(new BadRequestError30(error.message));
38528
+ next(new BadRequestError31(error.message));
38512
38529
  return;
38513
38530
  }
38514
38531
  try {
38515
38532
  const result = await _updatePlantillaById(id, value);
38516
38533
  if (result.matchedCount === 0) {
38517
- next(new BadRequestError30("Plantilla not found."));
38534
+ next(new BadRequestError31("Plantilla not found."));
38518
38535
  return;
38519
38536
  }
38520
38537
  res.json({ message: "Plantilla updated successfully" });
@@ -38530,13 +38547,13 @@ function usePlantillaController() {
38530
38547
  });
38531
38548
  const { error } = validation.validate({ id });
38532
38549
  if (error) {
38533
- next(new BadRequestError30(error.message));
38550
+ next(new BadRequestError31(error.message));
38534
38551
  return;
38535
38552
  }
38536
38553
  try {
38537
38554
  const result = await _deletePlantillaById(id);
38538
38555
  if (result.matchedCount === 0) {
38539
- next(new BadRequestError30("Plantilla not found."));
38556
+ next(new BadRequestError31("Plantilla not found."));
38540
38557
  return;
38541
38558
  }
38542
38559
  res.json({ message: "Plantilla deleted successfully" });
@@ -38557,12 +38574,12 @@ function usePlantillaController() {
38557
38574
  });
38558
38575
  const { error } = validation.validate({ region, division });
38559
38576
  if (error) {
38560
- next(new BadRequestError30(`Validation error: ${error.message}`));
38577
+ next(new BadRequestError31(`Validation error: ${error.message}`));
38561
38578
  return;
38562
38579
  }
38563
38580
  if (!region && !division) {
38564
38581
  next(
38565
- new BadRequestError30(
38582
+ new BadRequestError31(
38566
38583
  "At least one of region or division must be provided"
38567
38584
  )
38568
38585
  );
@@ -38593,17 +38610,18 @@ dotenv.config();
38593
38610
  export {
38594
38611
  MAsset,
38595
38612
  MCurriculum,
38596
- MDivision,
38597
38613
  MEnrollment,
38598
38614
  MGradeLevel,
38599
38615
  MPlantilla,
38600
- MRegion,
38601
- MSchool,
38602
38616
  MStockCard,
38617
+ modelDivision,
38618
+ modelRegion,
38619
+ modelSchool,
38603
38620
  schemaAsset,
38604
38621
  schemaAssetUpdateOption,
38605
38622
  schemaCurriculum,
38606
38623
  schemaDivision,
38624
+ schemaDivisionUpdate,
38607
38625
  schemaEnrollment,
38608
38626
  schemaGradeLevel,
38609
38627
  schemaPlantilla,