Commit c00618f
committed
refactor(sandbox): migrate API methods to object-based parameters with backward compatibility
This commit refactors the sandbox client and template classes to use object-based API parameters instead of positional arguments. The changes maintain backward compatibility by supporting both the new object-based API and legacy parameter formats, while adding deprecation warnings for the old usage patterns.
The client methods now accept parameters as objects ({ input, config }) rather than positional arguments (input, config), improving type safety and parameter clarity. The template class numeric field normalization was also improved to properly handle invalid numeric values by setting them to undefined.
Additionally, the test suite was updated to mock the SandboxClient directly instead of the lower-level control API, providing better test isolation and more accurate testing of the actual API usage patterns.
refactor(sandbox): 将API方法迁移到基于对象的参数并保持向后兼容性
此提交重构了sandbox客户端和模板类,使用基于对象的API参数而不是位置参数。这些更改通过支持新的基于对象的API和旧的参数格式来保持向后兼容性,同时为旧的使用模式添加弃用警告。
客户端方法现在接受参数作为对象({ input, config})而不是位置参数(input, config),提高了类型安全性和参数清晰度。模板类数值字段规范化也得到了改进,通过将无效的数值设置为undefined来正确处理它们。
此外,测试套件已更新为直接模拟SandboxClient而不是底层控制API,提供更好的测试隔离和更准确的实际API使用模式测试。
Change-Id: I8fd2bad5dac5c898328fe64d6d7f40b82ee00fe4
Signed-off-by: OhYee <oyohyee@oyohyee.com>1 parent d97ab7a commit c00618f
5 files changed
Lines changed: 468 additions & 125 deletions
File tree
- src/sandbox
- tests/unittests/sandbox
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
340 | 340 | | |
341 | 341 | | |
342 | 342 | | |
343 | | - | |
344 | | - | |
345 | | - | |
346 | | - | |
347 | | - | |
348 | | - | |
349 | | - | |
| 343 | + | |
| 344 | + | |
350 | 345 | | |
351 | 346 | | |
352 | 347 | | |
| |||
355 | 350 | | |
356 | 351 | | |
357 | 352 | | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
358 | 360 | | |
359 | 361 | | |
360 | 362 | | |
| |||
483 | 485 | | |
484 | 486 | | |
485 | 487 | | |
486 | | - | |
487 | | - | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
488 | 494 | | |
489 | | - | |
| 495 | + | |
490 | 496 | | |
491 | 497 | | |
492 | 498 | | |
493 | | - | |
494 | | - | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
495 | 504 | | |
496 | 505 | | |
497 | | - | |
498 | | - | |
499 | 506 | | |
500 | 507 | | |
501 | 508 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
175 | 175 | | |
176 | 176 | | |
177 | 177 | | |
178 | | - | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
179 | 187 | | |
180 | 188 | | |
181 | 189 | | |
| |||
193 | 201 | | |
194 | 202 | | |
195 | 203 | | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
196 | 207 | | |
197 | 208 | | |
198 | 209 | | |
| |||
211 | 222 | | |
212 | 223 | | |
213 | 224 | | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
214 | 228 | | |
215 | 229 | | |
216 | 230 | | |
| |||
347 | 361 | | |
348 | 362 | | |
349 | 363 | | |
350 | | - | |
| 364 | + | |
| 365 | + | |
351 | 366 | | |
352 | 367 | | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
353 | 371 | | |
354 | 372 | | |
355 | 373 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
251 | 251 | | |
252 | 252 | | |
253 | 253 | | |
254 | | - | |
255 | | - | |
256 | | - | |
257 | | - | |
258 | | - | |
259 | | - | |
260 | | - | |
261 | | - | |
262 | | - | |
263 | | - | |
264 | | - | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
265 | 264 | | |
266 | 265 | | |
0 commit comments