@kipicore/dbcore 1.1.152 → 1.1.154

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.
@@ -146,7 +146,8 @@ export declare function extractFromObject(data: any[], config: {
146
146
  tableTitle: string;
147
147
  columns: {
148
148
  title: string;
149
- field: string;
149
+ field: string | string[];
150
+ joinContent?: string;
150
151
  }[];
151
152
  }): {
152
153
  tableTitle: string;
@@ -555,21 +555,19 @@ function chunkArray(array, size) {
555
555
  function formatDateIfNeeded(value) {
556
556
  if (!value)
557
557
  return value;
558
- let date = null;
559
- // Case 1: Date object
558
+ function isStrictISODate(val) {
559
+ return /^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}:\d{2}(\.\d+)?Z?)?$/.test(val);
560
+ }
560
561
  if (value instanceof Date) {
561
- date = value;
562
+ return value.toLocaleDateString('en-GB');
562
563
  }
563
- // Case 2: ISO string
564
- else if (typeof value === 'string') {
564
+ if (typeof value === 'string' && isStrictISODate(value)) {
565
565
  const parsed = new Date(value);
566
566
  if (!isNaN(parsed.getTime())) {
567
- date = parsed;
567
+ return parsed.toLocaleDateString('en-GB');
568
568
  }
569
569
  }
570
- if (!date)
571
- return value;
572
- return date.toLocaleDateString('en-GB');
570
+ return value;
573
571
  }
574
572
  function resolvePath(value, parts) {
575
573
  if (value === undefined || value === null)
@@ -607,7 +605,13 @@ function extractFromObject(data, config) {
607
605
  const userdata = data.map(item => {
608
606
  const row = {};
609
607
  config.columns.forEach(col => {
610
- row[col.title] = getNestedValueForArray(item, col.field);
608
+ if (Array.isArray(col.field)) {
609
+ const values = col.field.map(path => getNestedValueForArray(item, path)).filter(v => v !== '-' && v !== undefined && v !== null);
610
+ row[col.title] = values.length ? values.join(col.joinContent ?? ' ') : '-';
611
+ }
612
+ else {
613
+ row[col.title] = getNestedValueForArray(item, col.field);
614
+ }
611
615
  });
612
616
  return row;
613
617
  });
@@ -6,4 +6,5 @@ export interface IGenarateIdCardModelAttributes extends IDefaultAttributes, Docu
6
6
  content?: string;
7
7
  instituteId: string;
8
8
  academicCalendarId: string;
9
+ isDefault: boolean;
9
10
  }
@@ -51,6 +51,11 @@ const GenerateIdCardSchema = new mongoose_1.Schema({
51
51
  type: String,
52
52
  required: false,
53
53
  },
54
+ isDefault: {
55
+ type: Boolean,
56
+ default: false,
57
+ required: false,
58
+ },
54
59
  }, {
55
60
  timestamps: true,
56
61
  versionKey: false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kipicore/dbcore",
3
- "version": "1.1.152",
3
+ "version": "1.1.154",
4
4
  "description": "Reusable DB core package with Postgres, MongoDB, models, services, interfaces, and types",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",