@7365admin1/core 2.73.0 → 2.74.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
@@ -4193,6 +4193,8 @@ var orgSchema = Joi8.object({
4193
4193
  busInst: Joi8.string().optional().allow("", null),
4194
4194
  status: Joi8.string().optional().allow("", null),
4195
4195
  defaultSite: Joi8.string().hex().optional().allow("", null),
4196
+ terms: Joi8.string().optional().allow("", null),
4197
+ policies: Joi8.string().optional().allow("", null),
4196
4198
  createdAt: Joi8.string().optional().allow("", null),
4197
4199
  updatedAt: Joi8.string().optional().allow("", null),
4198
4200
  deletedAt: Joi8.string().optional().allow("", null)
@@ -4220,6 +4222,8 @@ function MOrg(value) {
4220
4222
  busInst: value.busInst,
4221
4223
  status: value.status || "active",
4222
4224
  defaultSite: value.defaultSite,
4225
+ terms: value.terms ?? "",
4226
+ policies: value.policies ?? "",
4223
4227
  createdAt: value.createdAt || /* @__PURE__ */ new Date(),
4224
4228
  updatedAt: "",
4225
4229
  deletedAt: ""
@@ -4235,6 +4239,7 @@ function useOrgRepo() {
4235
4239
  }
4236
4240
  const namespace_collection = "organizations";
4237
4241
  const collection = db.collection(namespace_collection);
4242
+ const rolesCollection = db.collection("roles");
4238
4243
  const { delNamespace, getCache, setCache } = useCache9(namespace_collection);
4239
4244
  async function createIndex() {
4240
4245
  try {
@@ -4714,6 +4719,26 @@ function useOrgRepo() {
4714
4719
  throw error;
4715
4720
  }
4716
4721
  }
4722
+ async function getAdminOrgForResident() {
4723
+ const role = await rolesCollection.findOne({ type: "admin" });
4724
+ if (!role)
4725
+ throw new NotFoundError7("Admin role not found.");
4726
+ let orgId;
4727
+ try {
4728
+ orgId = new ObjectId15(role.org);
4729
+ } catch {
4730
+ throw new InternalServerError9(
4731
+ "Invalid organization reference in admin role."
4732
+ );
4733
+ }
4734
+ const org = await collection.findOne(
4735
+ { _id: orgId },
4736
+ { projection: { terms: 1, policies: 1, _id: 0 } }
4737
+ );
4738
+ if (!org)
4739
+ throw new NotFoundError7("Organization not found.");
4740
+ return org;
4741
+ }
4717
4742
  return {
4718
4743
  createIndex,
4719
4744
  createTextIndex,
@@ -4728,7 +4753,8 @@ function useOrgRepo() {
4728
4753
  updateStatusById,
4729
4754
  deleteById,
4730
4755
  getOrgsByEmail,
4731
- getOrganizationsWithSubscription
4756
+ getOrganizationsWithSubscription,
4757
+ getAdminOrgForResident
4732
4758
  };
4733
4759
  }
4734
4760
 
@@ -5347,7 +5373,7 @@ function useSiteRepo() {
5347
5373
  try {
5348
5374
  const items = await collection.aggregate([
5349
5375
  ...basePipeline,
5350
- { $project: { _id: 1, name: 1, orgId: 1 } },
5376
+ { $project: { _id: 1, name: 1, orgId: 1, category: 1 } },
5351
5377
  { $skip: page * limit },
5352
5378
  { $limit: limit }
5353
5379
  ]).toArray();
@@ -8870,7 +8896,8 @@ function useOrgController() {
8870
8896
  getAll: _getAll,
8871
8897
  add: _add,
8872
8898
  update: _update,
8873
- getOrgsByEmail: _getOrgsByEmail
8899
+ getOrgsByEmail: _getOrgsByEmail,
8900
+ getAdminOrgForResident: _getAdminOrgForResident
8874
8901
  } = useOrgRepo();
8875
8902
  async function add(req, res, next) {
8876
8903
  const validation = Joi18.object({
@@ -8878,7 +8905,9 @@ function useOrgController() {
8878
8905
  type: Joi18.string().required(),
8879
8906
  nature: Joi18.string().valid(...allowedNatures).required(),
8880
8907
  email: Joi18.string().email().optional().allow("", null),
8881
- contact: Joi18.string().optional().allow("", null)
8908
+ contact: Joi18.string().optional().allow("", null),
8909
+ terms: Joi18.string().optional().allow("", null),
8910
+ policies: Joi18.string().optional().allow("", null)
8882
8911
  });
8883
8912
  const { error } = validation.validate(req.body);
8884
8913
  if (error) {
@@ -9084,7 +9113,9 @@ function useOrgController() {
9084
9113
  type: Joi18.string().optional(),
9085
9114
  nature: Joi18.string().valid(...allowedNatures).optional(),
9086
9115
  email: Joi18.string().email().allow("", null).optional(),
9087
- contact: Joi18.string().allow("", null).optional()
9116
+ contact: Joi18.string().allow("", null).optional(),
9117
+ terms: Joi18.string().optional().allow("", null),
9118
+ policies: Joi18.string().optional().allow("", null)
9088
9119
  });
9089
9120
  const { error } = validation.validate(req.body);
9090
9121
  if (error) {
@@ -9103,6 +9134,15 @@ function useOrgController() {
9103
9134
  next(err);
9104
9135
  }
9105
9136
  }
9137
+ async function getAdminOrgForResident(_req, res, next) {
9138
+ try {
9139
+ const data = await _getAdminOrgForResident();
9140
+ res.status(200).json(data);
9141
+ } catch (error) {
9142
+ logger25.log({ level: "error", message: error.message });
9143
+ next(error);
9144
+ }
9145
+ }
9106
9146
  return {
9107
9147
  add,
9108
9148
  addOnboardingOrg,
@@ -9112,7 +9152,8 @@ function useOrgController() {
9112
9152
  getById,
9113
9153
  getByEmail,
9114
9154
  update,
9115
- getOrgsByEmail
9155
+ getOrgsByEmail,
9156
+ getAdminOrgForResident
9116
9157
  };
9117
9158
  }
9118
9159
 
@@ -14463,7 +14504,8 @@ var schemaPerson = Joi36.object({
14463
14504
  plateNumber: Joi36.string().optional().allow(null, ""),
14464
14505
  platform: Joi36.string().valid("web", "mobile").optional().allow(null, ""),
14465
14506
  approvedBy: schemaApprover.optional().allow(null, ""),
14466
- countryCode: Joi36.string().optional().allow(null, "")
14507
+ countryCode: Joi36.string().optional().allow(null, ""),
14508
+ callingCode: Joi36.string().optional().allow(null, "")
14467
14509
  });
14468
14510
  var schemaUpdatePerson = Joi36.object({
14469
14511
  _id: Joi36.string().hex().required(),
@@ -14487,7 +14529,8 @@ var schemaUpdatePerson = Joi36.object({
14487
14529
  plateNumber: Joi36.string().optional().allow(null, ""),
14488
14530
  platform: Joi36.string().valid("web", "mobile").optional().allow(null, ""),
14489
14531
  approvedBy: schemaApprover.optional().allow(null, ""),
14490
- countryCode: Joi36.string().optional().allow(null, "")
14532
+ countryCode: Joi36.string().optional().allow(null, ""),
14533
+ callingCode: Joi36.string().optional().allow(null, "")
14491
14534
  });
14492
14535
  function MPerson(value) {
14493
14536
  const { error } = schemaPerson.validate(value);
@@ -14561,6 +14604,7 @@ function MPerson(value) {
14561
14604
  platForm: value.platform ?? "",
14562
14605
  approvedBy: value.approvedBy ?? { id: "", name: "" },
14563
14606
  countryCode: value.countryCode ?? "",
14607
+ callingCode: value.callingCode ?? "",
14564
14608
  createdAt: value.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
14565
14609
  updatedAt: value.updatedAt,
14566
14610
  deletedAt: value.deletedAt
@@ -56788,6 +56832,11 @@ var FormEntryStatus = /* @__PURE__ */ ((FormEntryStatus2) => {
56788
56832
  var schemaFormEntry = Joi141.object({
56789
56833
  _id: Joi141.string().hex().optional().allow("", null),
56790
56834
  formType: Joi141.string().required(),
56835
+ block: Joi141.string().optional().allow(null, ""),
56836
+ level: Joi141.string().optional().allow(null, ""),
56837
+ unit: Joi141.string().optional().allow(null, ""),
56838
+ name: Joi141.string().optional().allow(null, ""),
56839
+ phoneNumber: Joi141.string().optional().allow(null, ""),
56791
56840
  fields: Joi141.object().pattern(
56792
56841
  Joi141.string(),
56793
56842
  Joi141.alternatives().try(
@@ -56949,15 +56998,22 @@ function useFormEntryController() {
56949
56998
  }
56950
56999
  const headerRow = worksheet.getRow(1);
56951
57000
  const headers = headerRow.values.slice(1).map((h) => String(h ?? "").trim());
57001
+ const knownKeys = ["block", "level", "unit", "name", "phoneNumber"];
57002
+ const topLevel = {};
56952
57003
  const fields = {};
56953
57004
  headers.forEach((header) => {
56954
- fields[header] = null;
57005
+ const normalized = toCamelCase(header);
57006
+ if (knownKeys.includes(normalized)) {
57007
+ topLevel[normalized] = null;
57008
+ } else {
57009
+ fields[normalized] = null;
57010
+ }
56955
57011
  });
56956
57012
  const formType = req.file.originalname.replace(/\.[^/.]+$/, "");
56957
- const normalizedFields = normalizeKeys(fields);
56958
57013
  const payload = {
56959
57014
  formType,
56960
- fields: normalizedFields,
57015
+ ...topLevel,
57016
+ fields,
56961
57017
  status: "active" /* ACTIVE */
56962
57018
  };
56963
57019
  const { error, value } = schemaFormEntry.validate(payload, {