@lovrabet/sdk 1.3.0-beta.2 → 1.3.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.
@@ -23,18 +23,30 @@ export declare enum SortOrder {
23
23
  /** 降序 */
24
24
  DESC = "desc"
25
25
  }
26
+ /**
27
+ * 排序方向类型(同时支持枚举和字符串)
28
+ * @description 支持使用 SortOrder.ASC/DESC 或直接使用 "asc"/"desc" 字符串
29
+ */
30
+ export type SortOrderValue = SortOrder | "asc" | "desc";
26
31
  /**
27
32
  * 排序配置类型
28
33
  * @description 定义排序规则的 key-value 格式,key 为字段名,value 为排序方向
29
34
  * @example
30
35
  * ```typescript
31
- * const sortList: SortList = [
36
+ * // 使用枚举
37
+ * const sortList1: SortList = [
32
38
  * { "id": SortOrder.DESC },
33
39
  * { "name": SortOrder.ASC }
34
40
  * ];
41
+ *
42
+ * // 使用字符串(更简洁)
43
+ * const sortList2: SortList = [
44
+ * { "id": "desc" },
45
+ * { "name": "asc" }
46
+ * ];
35
47
  * ```
36
48
  */
37
- export type SortList = Record<string, SortOrder>[];
49
+ export type SortList = Record<string, SortOrderValue>[];
38
50
  /**
39
51
  * 列表查询参数接口
40
52
  * @description 用于分页查询的通用参数接口
@@ -109,16 +121,15 @@ export type WhereCondition = {
109
121
  * @description 用于 filter 方法的查询参数
110
122
  * @example
111
123
  * ```typescript
112
- * const filterParams: FilterParams = {
124
+ * // 使用枚举
125
+ * const filterParams1: FilterParams = {
113
126
  * where: {
114
127
  * $and: [
115
128
  * { age: { $gte: 18, $lte: 45 } },
116
- * { country: { $in: ['中国', '美国', '日本'] } },
117
- * { vip: { $ne: null } },
118
- * { name: { $contain: 'hello' } }
129
+ * { country: { $in: ['中国', '美国', '日本'] } }
119
130
  * ]
120
131
  * },
121
- * select: ['id', 'name', 'age', 'country', 'lastLoginAt'],
132
+ * select: ['id', 'name', 'age', 'country'],
122
133
  * orderBy: [
123
134
  * { lastLoginAt: SortOrder.DESC },
124
135
  * { name: SortOrder.ASC }
@@ -126,6 +137,14 @@ export type WhereCondition = {
126
137
  * currentPage: 1,
127
138
  * pageSize: 20
128
139
  * };
140
+ *
141
+ * // 或使用字符串(更简洁)
142
+ * const filterParams2: FilterParams = {
143
+ * orderBy: [
144
+ * { lastLoginAt: "desc" },
145
+ * { name: "asc" }
146
+ * ]
147
+ * };
129
148
  * ```
130
149
  */
131
150
  export interface FilterParams {
@@ -190,7 +209,8 @@ export interface HavingCondition {
190
209
  * @description 用于 aggregate 方法的聚合查询参数
191
210
  * @example
192
211
  * ```typescript
193
- * const aggregateParams: AggregateParams = {
212
+ * // 使用枚举
213
+ * const aggregateParams1: AggregateParams = {
194
214
  * select: ['category_id'],
195
215
  * aggregate: [
196
216
  * { type: 'SUM', field: 'amount', alias: 'total_amount', round: true, precision: 2 }
@@ -204,6 +224,11 @@ export interface HavingCondition {
204
224
  * currentPage: 1,
205
225
  * pageSize: 20
206
226
  * };
227
+ *
228
+ * // 或使用字符串
229
+ * const aggregateParams2: AggregateParams = {
230
+ * orderBy: [{ total_amount: "desc" }]
231
+ * };
207
232
  * ```
208
233
  */
209
234
  export interface AggregateParams {
@@ -402,7 +427,8 @@ export interface BaseModelMethods {
402
427
  * @description 提供比 getList 更强大的查询能力,支持复杂的 where 条件、字段选择等(仅 WebAPI 模式支持)
403
428
  * @example
404
429
  * ```typescript
405
- * const result = await model.filter({
430
+ * // 使用枚举
431
+ * const result1 = await model.filter({
406
432
  * where: {
407
433
  * $and: [
408
434
  * { age: { $gte: 18, $lte: 45 } },
@@ -415,6 +441,11 @@ export interface BaseModelMethods {
415
441
  * currentPage: 1,
416
442
  * pageSize: 20
417
443
  * });
444
+ *
445
+ * // 或使用字符串(更简洁)
446
+ * const result2 = await model.filter({
447
+ * orderBy: [{ lastLoginAt: "desc" }]
448
+ * });
418
449
  * ```
419
450
  */
420
451
  filter<T = any>(params?: FilterParams): Promise<ListResponse<T>>;
@@ -491,7 +522,8 @@ export interface BaseModelMethods {
491
522
  * @returns 返回分页数据
492
523
  * @example
493
524
  * ```typescript
494
- * const result = await model.aggregate({
525
+ * // 使用枚举
526
+ * const result1 = await model.aggregate({
495
527
  * select: ['category_id'],
496
528
  * aggregate: [
497
529
  * { type: 'SUM', field: 'amount', alias: 'total_amount', round: true, precision: 2 }
@@ -500,6 +532,11 @@ export interface BaseModelMethods {
500
532
  * having: [{ columnName: 'total_amount', condition: { $gte: 1000 } }],
501
533
  * orderBy: [{ total_amount: SortOrder.DESC }]
502
534
  * });
535
+ *
536
+ * // 或使用字符串
537
+ * const result2 = await model.aggregate({
538
+ * orderBy: [{ total_amount: "desc" }]
539
+ * });
503
540
  * ```
504
541
  */
505
542
  aggregate<T = any>(params?: AggregateParams): Promise<ListResponse<T>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lovrabet/sdk",
3
- "version": "1.3.0-beta.2",
3
+ "version": "1.3.0",
4
4
  "license": "SEE LICENSE IN LICENSE",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",