@medyll/idae-engine 1.69.0 → 1.70.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.
@@ -44,14 +44,16 @@ export type DataOpFind<T> = {
44
44
  *
45
45
  * @template T - The type of the data items in the list.
46
46
  *
47
- * @property {T[]} dataList - The list of data items to be grouped.
47
+ * @property {T[]} data - The list of data items to be grouped.
48
48
  * @property {DataOpGroupByOptions<T>} groupBy - The options for grouping the data items.
49
49
  * @property {boolean} [keepUngroupedData] - Optional flag indicating whether to keep ungrouped data items.
50
50
  */
51
51
  export type DataOpGroupBy<T> = {
52
- dataList: T[];
52
+ data: T[];
53
53
  groupBy: DataOpGroupByOptions<T>;
54
54
  keepUngroupedData?: boolean;
55
+ /** @deprecated use data */
56
+ dataList?: T[];
55
57
  };
56
58
  /**
57
59
  * Represents the options for grouping data operations.
@@ -132,7 +134,7 @@ export declare class dataOp {
132
134
  *
133
135
  * @template T - The type of objects in the array, defaults to Data.
134
136
  * @param {Object} options - The grouping options.
135
- * @param {T[]} options.dataList - The array to group.
137
+ * @param {T[]} options.data - The array to group.
136
138
  * @param {((item: T) => { title: string; code: string }) | ResolverPathType<T> | ResolverPathType<T>[]} options.groupBy - The field(s) to group by or a function to determine the group.
137
139
  * @param {boolean} [options.keepUngroupedData=false] - Whether to keep ungrouped data.
138
140
  * @returns {DataOpGroupResult<T>} An object where keys are group codes and values are objects containing title, code, and data array.
@@ -41,7 +41,7 @@ export class dataOp {
41
41
  * @returns {T[] | GroupResult<T>} The resulting array or grouped data.
42
42
  */
43
43
  static do(options) {
44
- let result = options.sort?.arr || options.find?.arr || options.group?.dataList || [];
44
+ let result = options.sort?.arr || options.find?.arr || options.group?.data || [];
45
45
  if (options.sort) {
46
46
  result = this.sortBy(options.sort);
47
47
  }
@@ -49,7 +49,7 @@ export class dataOp {
49
49
  result = this.find({ ...options.find, arr: result });
50
50
  }
51
51
  if (options.group) {
52
- return this.groupBy({ ...options.group, dataList: result });
52
+ return this.groupBy({ ...options.group, data: result });
53
53
  }
54
54
  return result;
55
55
  }
@@ -136,14 +136,14 @@ export class dataOp {
136
136
  *
137
137
  * @template T - The type of objects in the array, defaults to Data.
138
138
  * @param {Object} options - The grouping options.
139
- * @param {T[]} options.dataList - The array to group.
139
+ * @param {T[]} options.data - The array to group.
140
140
  * @param {((item: T) => { title: string; code: string }) | ResolverPathType<T> | ResolverPathType<T>[]} options.groupBy - The field(s) to group by or a function to determine the group.
141
141
  * @param {boolean} [options.keepUngroupedData=false] - Whether to keep ungrouped data.
142
142
  * @returns {DataOpGroupResult<T>} An object where keys are group codes and values are objects containing title, code, and data array.
143
143
  */
144
144
  static groupBy(options) {
145
- const { dataList, groupBy: groupField, keepUngroupedData = false, } = options;
146
- return dataList.reduce((result, currentItem) => {
145
+ const { data, dataList, groupBy: groupField, keepUngroupedData = false, } = options;
146
+ return (dataList ?? data).reduce((result, currentItem) => {
147
147
  let groupInfo;
148
148
  if (typeof groupField === "function") {
149
149
  groupInfo = groupField(currentItem);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@medyll/idae-engine",
3
3
  "scope": "@medyll",
4
- "version": "1.69.0",
4
+ "version": "1.70.0",
5
5
  "description": "A powerful TypeScript library for data manipulation and operations across the idae-engine. Provides utility classes for sorting, finding, grouping, and more.",
6
6
  "scripts": {
7
7
  "dev": "vite dev",