@lovrabet/sdk 1.4.1 → 1.4.2

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.
@@ -30,6 +30,7 @@ export declare abstract class AbstractBaseModel implements BaseModelMethods {
30
30
  * 规范化列表响应:确保 paging 字段存在(兜底空对象)
31
31
  */
32
32
  private normalizeListResponse;
33
+ private normalizeAggregateParams;
33
34
  getList<T = any>(params?: ListParams, sortList?: SortList): Promise<ListResponse<T>>;
34
35
  filter<T = any>(params?: FilterParams): Promise<ListResponse<T>>;
35
36
  getOne<T = any>(idOrParams: string | number | {
@@ -187,15 +187,20 @@ export interface FilterParams {
187
187
  /**
188
188
  * 聚合类型
189
189
  */
190
- export type AggregateType = 'SUM' | 'COUNT' | 'AVG';
190
+ export type AggregateType = 'SUM' | 'COUNT' | 'AVG' | 'MIN' | 'MAX';
191
191
  /**
192
192
  * 聚合字段配置
193
193
  */
194
194
  export interface AggregateField {
195
195
  /** 聚合类型 */
196
196
  type: AggregateType;
197
- /** 字段名 */
198
- field: string;
197
+ /** 聚合列名 */
198
+ column?: string;
199
+ /**
200
+ * 聚合列名的旧别名。
201
+ * @deprecated Use `column`. The SDK normalizes `field` to `column` before sending requests.
202
+ */
203
+ field?: string;
199
204
  /** 字段别名 */
200
205
  alias?: string;
201
206
  /** 是否 distinct */
@@ -238,7 +243,7 @@ export interface HavingCondition {
238
243
  * const aggregateParams1: AggregateParams = {
239
244
  * select: ['category_id'],
240
245
  * aggregate: [
241
- * { type: 'SUM', field: 'amount', alias: 'total_amount', round: true, precision: 2 }
246
+ * { type: 'SUM', column: 'amount', alias: 'total_amount', round: true, precision: 2 }
242
247
  * ],
243
248
  * where: { status: { $eq: 'active' } },
244
249
  * groupBy: ['category_id'],
@@ -622,7 +627,7 @@ export interface BaseModelMethods {
622
627
  /**
623
628
  * 聚合查询
624
629
  * @template T 返回数据的类型
625
- * @param params 聚合查询参数,支持 SUM、COUNT、AVG 等聚合函数,以及 GROUP BY、HAVING、JOIN
630
+ * @param params 聚合查询参数,支持 SUM、COUNT、AVG、MIN、MAX 等聚合函数,以及 GROUP BY、HAVING、JOIN
626
631
  * @returns 返回分页数据
627
632
  * @example
628
633
  * ```typescript
@@ -630,7 +635,7 @@ export interface BaseModelMethods {
630
635
  * const result1 = await model.aggregate({
631
636
  * select: ['category_id'],
632
637
  * aggregate: [
633
- * { type: 'SUM', field: 'amount', alias: 'total_amount', round: true, precision: 2 }
638
+ * { type: 'SUM', column: 'amount', alias: 'total_amount', round: true, precision: 2 }
634
639
  * ],
635
640
  * groupBy: ['category_id'],
636
641
  * having: [{ columnName: 'total_amount', condition: { $gte: 1000 } }],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lovrabet/sdk",
3
- "version": "1.4.1",
3
+ "version": "1.4.2",
4
4
  "license": "SEE LICENSE IN LICENSE",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",