@lovrabet/sdk 1.1.19-beta.0 → 1.1.19

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/README.md CHANGED
@@ -499,6 +499,97 @@ const client = createClient({ token });
499
499
 
500
500
  ## 📝 What's New
501
501
 
502
+ ### v1.1.19 (2025-11-10)
503
+
504
+ **新增功能 (New Features):**
505
+
506
+ - ✨ **SQL API 支持** - 新增 `client.api.executeSql()` 方法,支持执行自定义 SQL 查询
507
+
508
+ ```typescript
509
+ // 执行 SQL 查询
510
+ const data = await client.api.executeSql('fc8e7777-06e3847d');
511
+
512
+ // 应用层检查执行结果
513
+ if (data.execSuccess && data.execResult) {
514
+ data.execResult.forEach(row => {
515
+ console.log(row);
516
+ });
517
+ }
518
+ ```
519
+
520
+ **核心特性:**
521
+ - 支持参数化查询,防止 SQL 注入
522
+ - 完整的 TypeScript 类型支持(泛型)
523
+ - 返回 `{ execSuccess: boolean, execResult?: T[] }` 结构
524
+ - 应用层负责检查 `execSuccess` 状态
525
+
526
+ **适用场景:**
527
+ - 复杂数据统计和聚合查询
528
+ - 跨表关联查询
529
+ - 自定义报表数据获取
530
+ - 灵活的数据分析需求
531
+
532
+ - 🏗️ **API 命名空间架构** - 新增 `client.api` 命名空间,用于管理通用 API 调用
533
+
534
+ ```typescript
535
+ const client = createClient({ /* ... */ });
536
+
537
+ // 通过 api 命名空间访问
538
+ const data = await client.api.executeSql('sqlCode');
539
+ ```
540
+
541
+ - 统一的 API 调用入口
542
+ - 为未来扩展预留空间(executeFunction、callWebhook 等)
543
+ - 与 Model API 保持一致的设计风格
544
+
545
+ **类型定义 (Type Definitions):**
546
+
547
+ - 新增 `SqlExecuteRequest` 接口:
548
+
549
+ ```typescript
550
+ interface SqlExecuteRequest {
551
+ sqlCode: string | number; // SQL 代码
552
+ params?: Record<string, string | number>; // SQL 参数
553
+ }
554
+ ```
555
+
556
+ - 新增 `SqlExecuteResult<T>` 接口:
557
+
558
+ ```typescript
559
+ interface SqlExecuteResult<T = Record<string, any>> {
560
+ execSuccess: boolean; // SQL 执行是否成功
561
+ execResult?: T[]; // 查询结果数组
562
+ }
563
+ ```
564
+
565
+ - 导出 `ApiNamespace` 类供高级用户使用
566
+
567
+ **重要说明 (Important Notes):**
568
+
569
+ :::warning SDK 返回值设计原则
570
+
571
+ SDK 的 `executeSql()` 方法返回包含 `execSuccess` 和 `execResult` 的对象,**不直接返回结果数组**。
572
+
573
+ 这是因为:
574
+ 1. **分离职责** - SDK 负责 HTTP 通信,应用层负责业务逻辑判断
575
+ 2. **错误处理** - `execSuccess: false` 表示 SQL 执行失败(业务错误),HTTP 失败才抛异常
576
+ 3. **灵活性** - 应用层可以根据 `execSuccess` 自行决定如何处理
577
+
578
+ ```typescript
579
+ // ✅ 正确使用方式
580
+ const data = await client.api.executeSql('sqlCode');
581
+ if (data.execSuccess && data.execResult) {
582
+ // 使用 execResult
583
+ }
584
+
585
+ // ❌ 错误使用方式
586
+ const data = await client.api.executeSql('sqlCode');
587
+ data.execResult.forEach(...); // 没有检查 execSuccess!
588
+ ```
589
+ :::
590
+
591
+ ---
592
+
502
593
  ### v1.1.18 (2025-10-18)
503
594
 
504
595
  **新增功能 (New Features):**