@lovrabet/cli 1.1.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.
Files changed (76) hide show
  1. package/README.md +28 -0
  2. package/lib/add-page/input-page-router.js +1 -0
  3. package/lib/add-page/main.js +1 -0
  4. package/lib/add-page/select-page-template.js +1 -0
  5. package/lib/api/api-pull-ui.js +1 -0
  6. package/lib/api/format-dataset.js +1 -0
  7. package/lib/api/generate-api-file.js +1 -0
  8. package/lib/api/main.js +1 -0
  9. package/lib/api/pull-silent.js +1 -0
  10. package/lib/api/pull.js +1 -0
  11. package/lib/api/types.js +1 -0
  12. package/lib/auth/auth-server-ui.js +1 -0
  13. package/lib/auth/auth-server.js +1 -0
  14. package/lib/auth/constant.js +1 -0
  15. package/lib/auth/get-cookie.js +1 -0
  16. package/lib/auth/is-session-valid.js +1 -0
  17. package/lib/auth/logout.js +1 -0
  18. package/lib/cli.js +2 -0
  19. package/lib/cmd/build-watch.js +1 -0
  20. package/lib/cmd/build.js +1 -0
  21. package/lib/cmd/logs.js +1 -0
  22. package/lib/cmd/preview.js +1 -0
  23. package/lib/cmd/start.js +1 -0
  24. package/lib/config/config-help.js +1 -0
  25. package/lib/config/main.js +1 -0
  26. package/lib/constant/domain.js +1 -0
  27. package/lib/constant/env.js +1 -0
  28. package/lib/create-app/enhanced-guided-create.js +1 -0
  29. package/lib/create-app/format-elapsed.js +1 -0
  30. package/lib/create-app/main.js +1 -0
  31. package/lib/create-app/task-finished.js +1 -0
  32. package/lib/create-app/task-loading.js +1 -0
  33. package/lib/create-app/task-running.js +1 -0
  34. package/lib/create-app/task-time.js +1 -0
  35. package/lib/create-app/use-copy-project-template.js +1 -0
  36. package/lib/create-app/use-format-code.js +1 -0
  37. package/lib/create-app/use-install-dependencies.js +1 -0
  38. package/lib/help.js +1 -0
  39. package/lib/utils/config.js +1 -0
  40. package/lib/utils/copy-directory.js +1 -0
  41. package/lib/utils/logger.js +1 -0
  42. package/lib/utils/router-updater.js +1 -0
  43. package/lib/utils/template-replacer.js +1 -0
  44. package/package.json +41 -0
  45. package/templates/README.md +115 -0
  46. package/templates/generate-api/api.ts.tpl +42 -0
  47. package/templates/generate-api/client.ts.tpl +64 -0
  48. package/templates/pages/blank/index.tsx.tpl +13 -0
  49. package/templates/pages/sdk-fetch/index.tsx.tpl +82 -0
  50. package/templates/projects/sub-app-react-demo/.prettierrc +1 -0
  51. package/templates/projects/sub-app-react-demo/.vscode/extensions.json +3 -0
  52. package/templates/projects/sub-app-react-demo/.vscode/settings.json +57 -0
  53. package/templates/projects/sub-app-react-demo/CHANGELOG.md +37 -0
  54. package/templates/projects/sub-app-react-demo/README.md +209 -0
  55. package/templates/projects/sub-app-react-demo/bun.lock +600 -0
  56. package/templates/projects/sub-app-react-demo/docs/API_RULE_CHANGE.md +212 -0
  57. package/templates/projects/sub-app-react-demo/docs/quick-start.md +526 -0
  58. package/templates/projects/sub-app-react-demo/index.html +39 -0
  59. package/templates/projects/sub-app-react-demo/package.json +34 -0
  60. package/templates/projects/sub-app-react-demo/public/vite.svg +1 -0
  61. package/templates/projects/sub-app-react-demo/src/api/api.ts +66 -0
  62. package/templates/projects/sub-app-react-demo/src/api/client.ts +63 -0
  63. package/templates/projects/sub-app-react-demo/src/components/ApiUrlDisplay.tsx +111 -0
  64. package/templates/projects/sub-app-react-demo/src/layouts/MainLayout.tsx +116 -0
  65. package/templates/projects/sub-app-react-demo/src/main.tsx +48 -0
  66. package/templates/projects/sub-app-react-demo/src/pages/chart-fetch/index.tsx +137 -0
  67. package/templates/projects/sub-app-react-demo/src/pages/dashboard/index.tsx +572 -0
  68. package/templates/projects/sub-app-react-demo/src/pages/index.tsx +129 -0
  69. package/templates/projects/sub-app-react-demo/src/pages/sdk-demo/index.tsx +182 -0
  70. package/templates/projects/sub-app-react-demo/src/pages/table-display.tsx +130 -0
  71. package/templates/projects/sub-app-react-demo/src/router/index.tsx +30 -0
  72. package/templates/projects/sub-app-react-demo/src/style.css +47 -0
  73. package/templates/projects/sub-app-react-demo/src/utils/api.ts +12 -0
  74. package/templates/projects/sub-app-react-demo/src/vite-env.d.ts +2 -0
  75. package/templates/projects/sub-app-react-demo/tsconfig.json +26 -0
  76. package/templates/projects/sub-app-react-demo/vite.config.ts +88 -0
@@ -0,0 +1,212 @@
1
+ # Lovrabet API 地址规则变更通知
2
+
3
+ ## 📢 重要变更通知
4
+
5
+ **生效日期**:2025-09-12
6
+ **影响范围**:所有调用 Lovrabet API 的合作商和开发者
7
+
8
+ **变更概要**:为了简化API架构,我们将原有的 smartapi/dbapi 双调用方式统一为单一 api 接口,同时迁移域名并简化URL路径结构。
9
+
10
+ **快速替换指南**:开发者需要将所有的
11
+ - `https://api.yuntooai.com/smartapi/runtime/[tenantCode]/`
12
+ - `https://api.yuntooai.com/dbapi/runtime/[tenantCode]/`
13
+
14
+ 批量替换为 `https://runtime.lovrabet.com/api/`
15
+
16
+ ---
17
+
18
+ ## 🔄 API 地址规则变更
19
+
20
+ ### 原规则(已废弃)
21
+
22
+ ```diff
23
+ - https://api.yuntooai.com/{callMethod}/runtime/{tenant}/{appCode}/{datasetCode}/{apiName}
24
+ ```
25
+
26
+ **参数说明**:
27
+
28
+ - <span style="color: red">~~`callMethod`: API调用类型(smartapi/dbapi)~~</span> ❌ **已删除**
29
+ - <span style="color: red">~~`runtime`: 固定前缀,运行时标识~~</span> ❌ **已删除**
30
+ - <span style="color: red">~~`tenant`: 租户名称~~</span> ❌ **已删除**
31
+ - `appCode`: 应用代码
32
+ - `datasetCode`: 数据集代码
33
+ - `apiName`: 接口名称
34
+
35
+ **示例**:
36
+
37
+ ```diff
38
+ - https://api.yuntooai.com/dbapi/runtime/yuntoo/app-f4c03acb/6c6c94a6ef064fe898cfa895fe5a38f5/getList
39
+ ```
40
+
41
+ ### 新规则(当前生效)
42
+
43
+ ```diff
44
+ + https://runtime.lovrabet.com/api/{appCode}/{datasetCode}/{apiName}
45
+ ```
46
+
47
+ **参数说明**:
48
+
49
+ - <span style="color: green">**`api`: 固定前缀(所有API统一使用)**</span> ✅ **新增**
50
+ - `appCode`: 应用代码(格式:app-{应用ID})
51
+ - `datasetCode`: 数据集唯一标识
52
+ - `apiName`: 具体的API接口名
53
+
54
+ **示例**:
55
+
56
+ ```diff
57
+ + https://runtime.lovrabet.com/api/app-c4055413/76a873945291498498737bc85677983d/getList
58
+ ```
59
+
60
+ ---
61
+
62
+ ## 📋 变更对比
63
+
64
+ | 项目 | 原规则 | 新规则 | 说明 |
65
+ | -------------- | ------------------- | ------------------ | -------------- |
66
+ | **URL结构** | 6个路径段 | 4个路径段 | 简化URL结构 |
67
+ | **调用方式** | smartapi/dbapi 区分 | 统一使用 api | 简化调用方式 |
68
+ | **固定前缀** | runtime | api | 更直观的前缀 |
69
+ | **租户标识** | 需要租户名称 | 已包含在应用代码中 | 减少参数复杂度 |
70
+ | **应用代码** | app-{id} | app-{id} | 保持不变 |
71
+ | **数据集代码** | 保持不变 | 保持不变 | 保持不变 |
72
+ | **接口名称** | 保持不变 | 保持不变 | 保持不变 |
73
+
74
+ ---
75
+
76
+ ## 🛠️ 需要修改的地方
77
+
78
+ ### 1. API请求地址更新
79
+
80
+ **原代码**:
81
+
82
+ ```diff
83
+ const apiUrl =
84
+ - "/dbapi/runtime/yuntoo/app-f4c03acb/6c6c94a6ef064fe898cfa895fe5a38f5/getList";
85
+ const response = await fetch(`https://api.yuntooai.com${apiUrl}`);
86
+ ```
87
+
88
+ **新代码**:
89
+
90
+ ```diff
91
+ const apiUrl =
92
+ + "/api/app-c4055413/76a873945291498498737bc85677983d/getList";
93
+ const response = await fetch(`https://runtime.lovrabet.com${apiUrl}`);
94
+ ```
95
+
96
+ ### 2. 配置文件更新
97
+
98
+ 如果你有配置文件存储API地址模板,需要更新:
99
+
100
+ **原模板**:
101
+
102
+ ```diff
103
+ {
104
+ - "apiTemplate": "/{callMethod}/runtime/{tenant}/{appCode}/{datasetCode}/{apiName}"
105
+ }
106
+ ```
107
+
108
+ **新模板**:
109
+
110
+ ```diff
111
+ {
112
+ + "apiTemplate": "/api/{appCode}/{datasetCode}/{apiName}"
113
+ }
114
+ ```
115
+
116
+ ### 3. API解析逻辑更新
117
+
118
+ 如果你的代码中有解析API地址的逻辑:
119
+
120
+ **原解析逻辑**:
121
+
122
+ ```diff
123
+ const urlParts = apiUrl.split("/");
124
+ - const callMethod = urlParts[1]; // smartapi/dbapi
125
+ - const runtime = urlParts[2]; // runtime
126
+ - const tenant = urlParts[3]; // 租户名称
127
+ - const appCode = urlParts[4]; // 应用代码
128
+ - const datasetCode = urlParts[5]; // 数据集代码
129
+ - const apiName = urlParts[6]; // 接口名称
130
+ ```
131
+
132
+ **新解析逻辑**:
133
+
134
+ ```diff
135
+ const urlParts = apiUrl.split("/");
136
+ + const apiPrefix = urlParts[1]; // api (固定)
137
+ + const appCode = urlParts[2]; // 应用代码
138
+ + const datasetCode = urlParts[3]; // 数据集代码
139
+ + const apiName = urlParts[4]; // 接口名称
140
+ ```
141
+
142
+ ---
143
+
144
+ ## ⚠️ 重要提醒
145
+
146
+ ### 1. 兼容性说明
147
+
148
+ - 旧格式API地址将在 **2024年12月31日** 后停止支持
149
+ - 请务必在此日期前完成所有API地址的更新
150
+
151
+ ### 2. 测试验证
152
+
153
+ 更新API地址后,请务必进行以下验证:
154
+
155
+ - ✅ 接口调用正常
156
+ - ✅ 数据返回格式一致
157
+ - ✅ 权限验证通过
158
+ - ✅ 错误处理正常
159
+
160
+ ### 3. 权限说明
161
+
162
+ - 新规则下的权限验证机制保持不变
163
+ - 仍需要在 `app.lovrabet.com` 中登录获取权限
164
+ - 跨域请求仍需要配置 `credentials: 'include'`
165
+
166
+ ---
167
+
168
+ ## 🔗 获取新API地址
169
+
170
+ ### 方式一:从管理后台获取
171
+
172
+ 1. 访问:`https://app.lovrabet.com/app/{你的appCode}/admin/dataset`
173
+ 2. 找到对应的数据集
174
+ 3. 复制新格式的API地址
175
+
176
+ ### 方式二:API地址转换
177
+
178
+ 如果你有原格式的API地址,可以按以下规则转换:
179
+
180
+ **转换规则**:
181
+
182
+ ```diff
183
+ - 原: https://api.yuntooai.com/{callMethod}/runtime/{tenant}/{appCode}/{datasetCode}/{apiName}
184
+ + 新: https://runtime.lovrabet.com/api/{appCode}/{datasetCode}/{apiName}
185
+ ```
186
+
187
+ **转换示例**:
188
+
189
+ ```diff
190
+ - 原: https://api.yuntooai.com/dbapi/runtime/yuntoo/app-f4c03acb/6c6c94a6ef064fe898cfa895fe5a38f5/getList
191
+ + 新: https://runtime.lovrabet.com/api/app-f4c03acb/6c6c94a6ef064fe898cfa895fe5a38f5/getList
192
+ ```
193
+
194
+ ---
195
+
196
+ ## 📝 更新检查清单
197
+
198
+ 请在完成API地址更新后,使用以下清单进行检查:
199
+
200
+ - [ ] 所有API请求地址已更新为新格式
201
+ - [ ] 相关配置文件已更新
202
+ - [ ] API地址解析逻辑已修改
203
+ - [ ] 本地环境测试通过
204
+ - [ ] 生产环境验证通过
205
+ - [ ] 错误处理逻辑正常
206
+ - [ ] 权限验证功能正常
207
+ - [ ] 用户文档已更新(如有)
208
+
209
+ ---
210
+
211
+ _最后更新时间:2024年9月12日_
212
+ _版本:v2.0_