@lovrabet/sdk 1.1.19-beta.0 → 1.1.20

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.
Files changed (3) hide show
  1. package/README.md +56 -16
  2. package/dist/index.js +1 -1
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -246,7 +246,7 @@ SDK 提供了 `client.api` 命名空间,用于执行自定义 SQL 查询和其
246
246
 
247
247
  ```typescript
248
248
  // 执行 SQL 查询,返回结果数组
249
- const results = await client.api.executeSql('fc8e7777-06e3847d');
249
+ const results = await client.api.executeSql("fc8e7777-06e3847d");
250
250
  console.log(results);
251
251
  // [
252
252
  // { creation_date: '2025-08-13', page_count: 2 },
@@ -259,9 +259,9 @@ console.log(results);
259
259
 
260
260
  ```typescript
261
261
  // 传递参数到 SQL
262
- const results = await client.api.executeSql('fc8e7777-xxxxx', {
263
- userId: '123',
264
- startDate: '2025-01-01'
262
+ const results = await client.api.executeSql("fc8e7777-xxxxx", {
263
+ userId: "123",
264
+ startDate: "2025-01-01",
265
265
  });
266
266
  ```
267
267
 
@@ -275,9 +275,9 @@ interface PageStat {
275
275
  }
276
276
 
277
277
  // 使用泛型获得类型安全
278
- const stats = await client.api.executeSql<PageStat>('fc8e7777-06e3847d');
279
- stats.forEach(stat => {
280
- console.log(stat.creation_date); // TypeScript 自动补全
278
+ const stats = await client.api.executeSql<PageStat>("fc8e7777-06e3847d");
279
+ stats.forEach((stat) => {
280
+ console.log(stat.creation_date); // TypeScript 自动补全
281
281
  console.log(stat.page_count);
282
282
  });
283
283
  ```
@@ -286,31 +286,33 @@ stats.forEach(stat => {
286
286
 
287
287
  ```typescript
288
288
  // 获取第一条结果
289
- const results = await client.api.executeSql<PageStat>('fc8e7777-xxxxx');
289
+ const results = await client.api.executeSql<PageStat>("fc8e7777-xxxxx");
290
290
  const firstResult = results[0];
291
291
 
292
292
  if (firstResult) {
293
- console.log(`日期: ${firstResult.creation_date}, 数量: ${firstResult.page_count}`);
293
+ console.log(
294
+ `日期: ${firstResult.creation_date}, 数量: ${firstResult.page_count}`
295
+ );
294
296
  } else {
295
- console.log('无结果');
297
+ console.log("无结果");
296
298
  }
297
299
 
298
300
  // 过滤结果
299
- const activeItems = results.filter(item => item.status === 'active');
301
+ const activeItems = results.filter((item) => item.status === "active");
300
302
 
301
303
  // 查找特定结果
302
- const targetItem = results.find(item => item.id === '123');
304
+ const targetItem = results.find((item) => item.id === "123");
303
305
  ```
304
306
 
305
307
  #### 错误处理
306
308
 
307
309
  ```typescript
308
310
  try {
309
- const results = await client.api.executeSql('fc8e7777-xxxxx');
311
+ const results = await client.api.executeSql("fc8e7777-xxxxx");
310
312
  } catch (error) {
311
313
  if (error instanceof LovrabetError) {
312
- console.error('SQL执行失败:', error.message);
313
- console.error('错误代码:', error.code);
314
+ console.error("SQL执行失败:", error.message);
315
+ console.error("错误代码:", error.code);
314
316
  }
315
317
  }
316
318
  ```
@@ -499,7 +501,45 @@ const client = createClient({ token });
499
501
 
500
502
  ## 📝 What's New
501
503
 
502
- ### v1.1.18 (2025-10-18)
504
+ ### v1.1.19 (2025-11-10)
505
+
506
+ **新增功能 (New Features):**
507
+
508
+ - ✨ **SQL API 支持** - 新增 `client.api.executeSql()` 方法,支持执行自定义 SQL 查询
509
+
510
+ ```typescript
511
+ // 执行 SQL 查询
512
+ const data = await client.api.executeSql("fc8e7777-06e3847d");
513
+
514
+ // 应用层检查执行结果
515
+ if (data.execSuccess && data.execResult) {
516
+ data.execResult.forEach((row) => {
517
+ console.log(row);
518
+ });
519
+ }
520
+ ```
521
+
522
+ **核心特性:**
523
+
524
+ - 支持参数化查询,防止 SQL 注入
525
+ - 完整的 TypeScript 类型支持(泛型)
526
+ - 返回 `{ execSuccess: boolean, execResult?: T[] }` 结构
527
+ - 应用层负责检查 `execSuccess` 状态
528
+
529
+ **适用场景:**
530
+
531
+ - 复杂数据统计和聚合查询
532
+ - 跨表关联查询
533
+ - 自定义报表数据获取
534
+ - 灵活的数据分析需求
535
+
536
+ - 🏗️ **API 命名空间架构** - 新增 `client.api` 命名空间,用于管理通用 API 调用
537
+
538
+ 详细说明参考:[说明文档](https://open.lovrabet.com/docs/lovrabet-sdk/sql-api)
539
+
540
+ ---
541
+
542
+ ### v1.1.17 (2025-10-18)
503
543
 
504
544
  **新增功能 (New Features):**
505
545