@switchbot/openapi-cli 3.2.1 → 3.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.
Files changed (332) hide show
  1. package/README.md +3 -1
  2. package/dist/index.js +57419 -170
  3. package/package.json +9 -5
  4. package/dist/api/client.d.ts +0 -31
  5. package/dist/api/client.js +0 -236
  6. package/dist/api/client.js.map +0 -1
  7. package/dist/auth.d.ts +0 -1
  8. package/dist/auth.js +0 -21
  9. package/dist/auth.js.map +0 -1
  10. package/dist/commands/agent-bootstrap.d.ts +0 -10
  11. package/dist/commands/agent-bootstrap.js +0 -200
  12. package/dist/commands/agent-bootstrap.js.map +0 -1
  13. package/dist/commands/auth.d.ts +0 -18
  14. package/dist/commands/auth.js +0 -355
  15. package/dist/commands/auth.js.map +0 -1
  16. package/dist/commands/batch.d.ts +0 -2
  17. package/dist/commands/batch.js +0 -414
  18. package/dist/commands/batch.js.map +0 -1
  19. package/dist/commands/cache.d.ts +0 -2
  20. package/dist/commands/cache.js +0 -127
  21. package/dist/commands/cache.js.map +0 -1
  22. package/dist/commands/capabilities.d.ts +0 -31
  23. package/dist/commands/capabilities.js +0 -383
  24. package/dist/commands/capabilities.js.map +0 -1
  25. package/dist/commands/catalog.d.ts +0 -2
  26. package/dist/commands/catalog.js +0 -360
  27. package/dist/commands/catalog.js.map +0 -1
  28. package/dist/commands/completion.d.ts +0 -2
  29. package/dist/commands/completion.js +0 -386
  30. package/dist/commands/completion.js.map +0 -1
  31. package/dist/commands/config.d.ts +0 -21
  32. package/dist/commands/config.js +0 -377
  33. package/dist/commands/config.js.map +0 -1
  34. package/dist/commands/daemon.d.ts +0 -2
  35. package/dist/commands/daemon.js +0 -411
  36. package/dist/commands/daemon.js.map +0 -1
  37. package/dist/commands/device-meta.d.ts +0 -2
  38. package/dist/commands/device-meta.js +0 -160
  39. package/dist/commands/device-meta.js.map +0 -1
  40. package/dist/commands/devices.d.ts +0 -2
  41. package/dist/commands/devices.js +0 -949
  42. package/dist/commands/devices.js.map +0 -1
  43. package/dist/commands/doctor.d.ts +0 -3
  44. package/dist/commands/doctor.js +0 -1016
  45. package/dist/commands/doctor.js.map +0 -1
  46. package/dist/commands/events.d.ts +0 -31
  47. package/dist/commands/events.js +0 -564
  48. package/dist/commands/events.js.map +0 -1
  49. package/dist/commands/expand.d.ts +0 -2
  50. package/dist/commands/expand.js +0 -131
  51. package/dist/commands/expand.js.map +0 -1
  52. package/dist/commands/explain.d.ts +0 -2
  53. package/dist/commands/explain.js +0 -140
  54. package/dist/commands/explain.js.map +0 -1
  55. package/dist/commands/health.d.ts +0 -8
  56. package/dist/commands/health.js +0 -114
  57. package/dist/commands/health.js.map +0 -1
  58. package/dist/commands/history.d.ts +0 -2
  59. package/dist/commands/history.js +0 -321
  60. package/dist/commands/history.js.map +0 -1
  61. package/dist/commands/identity.d.ts +0 -45
  62. package/dist/commands/identity.js +0 -60
  63. package/dist/commands/identity.js.map +0 -1
  64. package/dist/commands/install.d.ts +0 -20
  65. package/dist/commands/install.js +0 -247
  66. package/dist/commands/install.js.map +0 -1
  67. package/dist/commands/mcp.d.ts +0 -14
  68. package/dist/commands/mcp.js +0 -2018
  69. package/dist/commands/mcp.js.map +0 -1
  70. package/dist/commands/plan.d.ts +0 -51
  71. package/dist/commands/plan.js +0 -654
  72. package/dist/commands/plan.js.map +0 -1
  73. package/dist/commands/policy.d.ts +0 -24
  74. package/dist/commands/policy.js +0 -587
  75. package/dist/commands/policy.js.map +0 -1
  76. package/dist/commands/quota.d.ts +0 -2
  77. package/dist/commands/quota.js +0 -79
  78. package/dist/commands/quota.js.map +0 -1
  79. package/dist/commands/rules.d.ts +0 -2
  80. package/dist/commands/rules.js +0 -876
  81. package/dist/commands/rules.js.map +0 -1
  82. package/dist/commands/scenes.d.ts +0 -2
  83. package/dist/commands/scenes.js +0 -265
  84. package/dist/commands/scenes.js.map +0 -1
  85. package/dist/commands/schema.d.ts +0 -2
  86. package/dist/commands/schema.js +0 -185
  87. package/dist/commands/schema.js.map +0 -1
  88. package/dist/commands/status-sync.d.ts +0 -2
  89. package/dist/commands/status-sync.js +0 -132
  90. package/dist/commands/status-sync.js.map +0 -1
  91. package/dist/commands/uninstall.d.ts +0 -20
  92. package/dist/commands/uninstall.js +0 -238
  93. package/dist/commands/uninstall.js.map +0 -1
  94. package/dist/commands/upgrade-check.d.ts +0 -2
  95. package/dist/commands/upgrade-check.js +0 -107
  96. package/dist/commands/upgrade-check.js.map +0 -1
  97. package/dist/commands/watch.d.ts +0 -2
  98. package/dist/commands/watch.js +0 -195
  99. package/dist/commands/watch.js.map +0 -1
  100. package/dist/commands/webhook.d.ts +0 -2
  101. package/dist/commands/webhook.js +0 -183
  102. package/dist/commands/webhook.js.map +0 -1
  103. package/dist/config.d.ts +0 -57
  104. package/dist/config.js +0 -259
  105. package/dist/config.js.map +0 -1
  106. package/dist/credentials/backends/file.d.ts +0 -18
  107. package/dist/credentials/backends/file.js +0 -102
  108. package/dist/credentials/backends/file.js.map +0 -1
  109. package/dist/credentials/backends/linux.d.ts +0 -16
  110. package/dist/credentials/backends/linux.js +0 -130
  111. package/dist/credentials/backends/linux.js.map +0 -1
  112. package/dist/credentials/backends/macos.d.ts +0 -18
  113. package/dist/credentials/backends/macos.js +0 -130
  114. package/dist/credentials/backends/macos.js.map +0 -1
  115. package/dist/credentials/backends/windows.d.ts +0 -23
  116. package/dist/credentials/backends/windows.js +0 -216
  117. package/dist/credentials/backends/windows.js.map +0 -1
  118. package/dist/credentials/keychain.d.ts +0 -83
  119. package/dist/credentials/keychain.js +0 -89
  120. package/dist/credentials/keychain.js.map +0 -1
  121. package/dist/credentials/prime.d.ts +0 -32
  122. package/dist/credentials/prime.js +0 -53
  123. package/dist/credentials/prime.js.map +0 -1
  124. package/dist/devices/cache.d.ts +0 -79
  125. package/dist/devices/cache.js +0 -294
  126. package/dist/devices/cache.js.map +0 -1
  127. package/dist/devices/catalog.d.ts +0 -138
  128. package/dist/devices/catalog.js +0 -768
  129. package/dist/devices/catalog.js.map +0 -1
  130. package/dist/devices/device-meta.d.ts +0 -15
  131. package/dist/devices/device-meta.js +0 -57
  132. package/dist/devices/device-meta.js.map +0 -1
  133. package/dist/devices/history-agg.d.ts +0 -37
  134. package/dist/devices/history-agg.js +0 -139
  135. package/dist/devices/history-agg.js.map +0 -1
  136. package/dist/devices/history-query.d.ts +0 -45
  137. package/dist/devices/history-query.js +0 -182
  138. package/dist/devices/history-query.js.map +0 -1
  139. package/dist/devices/param-validator.d.ts +0 -40
  140. package/dist/devices/param-validator.js +0 -434
  141. package/dist/devices/param-validator.js.map +0 -1
  142. package/dist/devices/resources.d.ts +0 -74
  143. package/dist/devices/resources.js +0 -271
  144. package/dist/devices/resources.js.map +0 -1
  145. package/dist/index.d.ts +0 -1
  146. package/dist/index.js.map +0 -1
  147. package/dist/install/default-steps.d.ts +0 -66
  148. package/dist/install/default-steps.js +0 -258
  149. package/dist/install/default-steps.js.map +0 -1
  150. package/dist/install/preflight.d.ts +0 -60
  151. package/dist/install/preflight.js +0 -213
  152. package/dist/install/preflight.js.map +0 -1
  153. package/dist/install/steps.d.ts +0 -61
  154. package/dist/install/steps.js +0 -68
  155. package/dist/install/steps.js.map +0 -1
  156. package/dist/lib/command-keywords.d.ts +0 -5
  157. package/dist/lib/command-keywords.js +0 -18
  158. package/dist/lib/command-keywords.js.map +0 -1
  159. package/dist/lib/daemon-state.d.ts +0 -24
  160. package/dist/lib/daemon-state.js +0 -47
  161. package/dist/lib/daemon-state.js.map +0 -1
  162. package/dist/lib/destructive-mode.d.ts +0 -2
  163. package/dist/lib/destructive-mode.js +0 -13
  164. package/dist/lib/destructive-mode.js.map +0 -1
  165. package/dist/lib/devices.d.ts +0 -151
  166. package/dist/lib/devices.js +0 -383
  167. package/dist/lib/devices.js.map +0 -1
  168. package/dist/lib/idempotency.d.ts +0 -46
  169. package/dist/lib/idempotency.js +0 -107
  170. package/dist/lib/idempotency.js.map +0 -1
  171. package/dist/lib/plan-store.d.ts +0 -19
  172. package/dist/lib/plan-store.js +0 -69
  173. package/dist/lib/plan-store.js.map +0 -1
  174. package/dist/lib/request-context.d.ts +0 -7
  175. package/dist/lib/request-context.js +0 -13
  176. package/dist/lib/request-context.js.map +0 -1
  177. package/dist/lib/scenes.d.ts +0 -7
  178. package/dist/lib/scenes.js +0 -11
  179. package/dist/lib/scenes.js.map +0 -1
  180. package/dist/logger.d.ts +0 -4
  181. package/dist/logger.js +0 -17
  182. package/dist/logger.js.map +0 -1
  183. package/dist/mcp/device-history.d.ts +0 -36
  184. package/dist/mcp/device-history.js +0 -146
  185. package/dist/mcp/device-history.js.map +0 -1
  186. package/dist/mcp/events-subscription.d.ts +0 -45
  187. package/dist/mcp/events-subscription.js +0 -214
  188. package/dist/mcp/events-subscription.js.map +0 -1
  189. package/dist/mqtt/client.d.ts +0 -25
  190. package/dist/mqtt/client.js +0 -181
  191. package/dist/mqtt/client.js.map +0 -1
  192. package/dist/mqtt/credential.d.ts +0 -16
  193. package/dist/mqtt/credential.js +0 -31
  194. package/dist/mqtt/credential.js.map +0 -1
  195. package/dist/policy/add-rule.d.ts +0 -21
  196. package/dist/policy/add-rule.js +0 -125
  197. package/dist/policy/add-rule.js.map +0 -1
  198. package/dist/policy/diff.d.ts +0 -21
  199. package/dist/policy/diff.js +0 -92
  200. package/dist/policy/diff.js.map +0 -1
  201. package/dist/policy/format.d.ts +0 -6
  202. package/dist/policy/format.js +0 -58
  203. package/dist/policy/format.js.map +0 -1
  204. package/dist/policy/load.d.ts +0 -32
  205. package/dist/policy/load.js +0 -62
  206. package/dist/policy/load.js.map +0 -1
  207. package/dist/policy/migrate.d.ts +0 -21
  208. package/dist/policy/migrate.js +0 -68
  209. package/dist/policy/migrate.js.map +0 -1
  210. package/dist/policy/schema.d.ts +0 -5
  211. package/dist/policy/schema.js +0 -19
  212. package/dist/policy/schema.js.map +0 -1
  213. package/dist/policy/validate.d.ts +0 -19
  214. package/dist/policy/validate.js +0 -263
  215. package/dist/policy/validate.js.map +0 -1
  216. package/dist/rules/action.d.ts +0 -65
  217. package/dist/rules/action.js +0 -217
  218. package/dist/rules/action.js.map +0 -1
  219. package/dist/rules/audit-query.d.ts +0 -51
  220. package/dist/rules/audit-query.js +0 -90
  221. package/dist/rules/audit-query.js.map +0 -1
  222. package/dist/rules/conflict-analyzer.d.ts +0 -57
  223. package/dist/rules/conflict-analyzer.js +0 -215
  224. package/dist/rules/conflict-analyzer.js.map +0 -1
  225. package/dist/rules/cron-scheduler.d.ts +0 -62
  226. package/dist/rules/cron-scheduler.js +0 -187
  227. package/dist/rules/cron-scheduler.js.map +0 -1
  228. package/dist/rules/destructive.d.ts +0 -20
  229. package/dist/rules/destructive.js +0 -53
  230. package/dist/rules/destructive.js.map +0 -1
  231. package/dist/rules/engine.d.ts +0 -193
  232. package/dist/rules/engine.js +0 -758
  233. package/dist/rules/engine.js.map +0 -1
  234. package/dist/rules/matcher.d.ts +0 -56
  235. package/dist/rules/matcher.js +0 -231
  236. package/dist/rules/matcher.js.map +0 -1
  237. package/dist/rules/pid-file.d.ts +0 -43
  238. package/dist/rules/pid-file.js +0 -96
  239. package/dist/rules/pid-file.js.map +0 -1
  240. package/dist/rules/quiet-hours.d.ts +0 -26
  241. package/dist/rules/quiet-hours.js +0 -46
  242. package/dist/rules/quiet-hours.js.map +0 -1
  243. package/dist/rules/suggest.d.ts +0 -20
  244. package/dist/rules/suggest.js +0 -96
  245. package/dist/rules/suggest.js.map +0 -1
  246. package/dist/rules/throttle.d.ts +0 -61
  247. package/dist/rules/throttle.js +0 -117
  248. package/dist/rules/throttle.js.map +0 -1
  249. package/dist/rules/types.d.ts +0 -117
  250. package/dist/rules/types.js +0 -35
  251. package/dist/rules/types.js.map +0 -1
  252. package/dist/rules/webhook-listener.d.ts +0 -63
  253. package/dist/rules/webhook-listener.js +0 -224
  254. package/dist/rules/webhook-listener.js.map +0 -1
  255. package/dist/rules/webhook-token.d.ts +0 -50
  256. package/dist/rules/webhook-token.js +0 -91
  257. package/dist/rules/webhook-token.js.map +0 -1
  258. package/dist/schema/field-aliases.d.ts +0 -34
  259. package/dist/schema/field-aliases.js +0 -132
  260. package/dist/schema/field-aliases.js.map +0 -1
  261. package/dist/sinks/dispatcher.d.ts +0 -7
  262. package/dist/sinks/dispatcher.js +0 -13
  263. package/dist/sinks/dispatcher.js.map +0 -1
  264. package/dist/sinks/file.d.ts +0 -6
  265. package/dist/sinks/file.js +0 -20
  266. package/dist/sinks/file.js.map +0 -1
  267. package/dist/sinks/format.d.ts +0 -20
  268. package/dist/sinks/format.js +0 -57
  269. package/dist/sinks/format.js.map +0 -1
  270. package/dist/sinks/homeassistant.d.ts +0 -18
  271. package/dist/sinks/homeassistant.js +0 -45
  272. package/dist/sinks/homeassistant.js.map +0 -1
  273. package/dist/sinks/openclaw.d.ts +0 -13
  274. package/dist/sinks/openclaw.js +0 -34
  275. package/dist/sinks/openclaw.js.map +0 -1
  276. package/dist/sinks/stdout.d.ts +0 -4
  277. package/dist/sinks/stdout.js +0 -6
  278. package/dist/sinks/stdout.js.map +0 -1
  279. package/dist/sinks/telegram.d.ts +0 -11
  280. package/dist/sinks/telegram.js +0 -29
  281. package/dist/sinks/telegram.js.map +0 -1
  282. package/dist/sinks/types.d.ts +0 -13
  283. package/dist/sinks/types.js +0 -2
  284. package/dist/sinks/types.js.map +0 -1
  285. package/dist/sinks/webhook.d.ts +0 -6
  286. package/dist/sinks/webhook.js +0 -23
  287. package/dist/sinks/webhook.js.map +0 -1
  288. package/dist/status-sync/manager.d.ts +0 -48
  289. package/dist/status-sync/manager.js +0 -269
  290. package/dist/status-sync/manager.js.map +0 -1
  291. package/dist/utils/arg-parsers.d.ts +0 -16
  292. package/dist/utils/arg-parsers.js +0 -67
  293. package/dist/utils/arg-parsers.js.map +0 -1
  294. package/dist/utils/audit.d.ts +0 -69
  295. package/dist/utils/audit.js +0 -122
  296. package/dist/utils/audit.js.map +0 -1
  297. package/dist/utils/filter.d.ts +0 -81
  298. package/dist/utils/filter.js +0 -190
  299. package/dist/utils/filter.js.map +0 -1
  300. package/dist/utils/flags.d.ts +0 -72
  301. package/dist/utils/flags.js +0 -187
  302. package/dist/utils/flags.js.map +0 -1
  303. package/dist/utils/format.d.ts +0 -9
  304. package/dist/utils/format.js +0 -118
  305. package/dist/utils/format.js.map +0 -1
  306. package/dist/utils/health.d.ts +0 -48
  307. package/dist/utils/health.js +0 -102
  308. package/dist/utils/health.js.map +0 -1
  309. package/dist/utils/help-json.d.ts +0 -39
  310. package/dist/utils/help-json.js +0 -55
  311. package/dist/utils/help-json.js.map +0 -1
  312. package/dist/utils/name-resolver.d.ts +0 -26
  313. package/dist/utils/name-resolver.js +0 -138
  314. package/dist/utils/name-resolver.js.map +0 -1
  315. package/dist/utils/output.d.ts +0 -73
  316. package/dist/utils/output.js +0 -405
  317. package/dist/utils/output.js.map +0 -1
  318. package/dist/utils/quota.d.ts +0 -61
  319. package/dist/utils/quota.js +0 -228
  320. package/dist/utils/quota.js.map +0 -1
  321. package/dist/utils/redact.d.ts +0 -23
  322. package/dist/utils/redact.js +0 -69
  323. package/dist/utils/redact.js.map +0 -1
  324. package/dist/utils/retry.d.ts +0 -72
  325. package/dist/utils/retry.js +0 -141
  326. package/dist/utils/retry.js.map +0 -1
  327. package/dist/utils/string.d.ts +0 -2
  328. package/dist/utils/string.js +0 -23
  329. package/dist/utils/string.js.map +0 -1
  330. package/dist/version.d.ts +0 -2
  331. package/dist/version.js +0 -5
  332. package/dist/version.js.map +0 -1
@@ -1,386 +0,0 @@
1
- const BASH_SCRIPT = `# switchbot bash completion
2
- # Install: source <(switchbot completion bash)
3
- # Or add to ~/.bashrc:
4
- # source <(switchbot completion bash)
5
-
6
- _switchbot_completion() {
7
- local cur prev words cword
8
- _get_comp_words_by_ref -n : cur prev words cword 2>/dev/null || {
9
- cur="\${COMP_WORDS[COMP_CWORD]}"
10
- prev="\${COMP_WORDS[COMP_CWORD-1]}"
11
- words=("\${COMP_WORDS[@]}")
12
- cword="\${COMP_CWORD}"
13
- }
14
-
15
- local top_cmds="config devices scenes webhook completion mcp quota catalog cache events doctor schema history plan capabilities help"
16
- local config_sub="set-token show list-profiles"
17
- local devices_sub="list ls status command types commands describe batch watch explain expand meta"
18
- local scenes_sub="list execute"
19
- local webhook_sub="setup query update delete"
20
- local events_sub="tail mqtt-tail"
21
- local quota_sub="status reset"
22
- local catalog_sub="path show diff refresh"
23
- local cache_sub="show clear"
24
- local history_sub="show replay"
25
- local plan_sub="schema validate run"
26
- local completion_shells="bash zsh fish powershell"
27
- local global_opts="--json --format --fields --verbose -v --dry-run --timeout --retry-on-429 --backoff --no-retry --no-quota --cache --no-cache --config --profile --audit-log --audit-log-path --help -h --version -V"
28
-
29
- if [[ \${cword} -eq 1 ]]; then
30
- COMPREPLY=( $(compgen -W "\${top_cmds} \${global_opts}" -- "\${cur}") )
31
- return
32
- fi
33
-
34
- case "\${words[1]}" in
35
- config)
36
- if [[ \${cword} -eq 2 ]]; then
37
- COMPREPLY=( $(compgen -W "\${config_sub}" -- "\${cur}") )
38
- fi
39
- ;;
40
- devices)
41
- if [[ \${cword} -eq 2 ]]; then
42
- COMPREPLY=( $(compgen -W "\${devices_sub}" -- "\${cur}") )
43
- elif [[ "\${words[2]}" == "command" && "\${prev}" == "--type" ]]; then
44
- COMPREPLY=( $(compgen -W "command customize" -- "\${cur}") )
45
- fi
46
- ;;
47
- scenes)
48
- if [[ \${cword} -eq 2 ]]; then
49
- COMPREPLY=( $(compgen -W "\${scenes_sub}" -- "\${cur}") )
50
- fi
51
- ;;
52
- events)
53
- if [[ \${cword} -eq 2 ]]; then
54
- COMPREPLY=( $(compgen -W "\${events_sub}" -- "\${cur}") )
55
- fi
56
- ;;
57
- quota)
58
- if [[ \${cword} -eq 2 ]]; then
59
- COMPREPLY=( $(compgen -W "\${quota_sub}" -- "\${cur}") )
60
- fi
61
- ;;
62
- catalog)
63
- if [[ \${cword} -eq 2 ]]; then
64
- COMPREPLY=( $(compgen -W "\${catalog_sub}" -- "\${cur}") )
65
- fi
66
- ;;
67
- cache)
68
- if [[ \${cword} -eq 2 ]]; then
69
- COMPREPLY=( $(compgen -W "\${cache_sub}" -- "\${cur}") )
70
- fi
71
- ;;
72
- history)
73
- if [[ \${cword} -eq 2 ]]; then
74
- COMPREPLY=( $(compgen -W "\${history_sub}" -- "\${cur}") )
75
- fi
76
- ;;
77
- plan)
78
- if [[ \${cword} -eq 2 ]]; then
79
- COMPREPLY=( $(compgen -W "\${plan_sub}" -- "\${cur}") )
80
- fi
81
- ;;
82
- webhook)
83
- if [[ \${cword} -eq 2 ]]; then
84
- COMPREPLY=( $(compgen -W "\${webhook_sub}" -- "\${cur}") )
85
- elif [[ "\${words[2]}" == "update" ]]; then
86
- COMPREPLY=( $(compgen -W "--enable --disable \${global_opts}" -- "\${cur}") )
87
- fi
88
- ;;
89
- completion)
90
- if [[ \${cword} -eq 2 ]]; then
91
- COMPREPLY=( $(compgen -W "\${completion_shells}" -- "\${cur}") )
92
- fi
93
- ;;
94
- *)
95
- COMPREPLY=( $(compgen -W "\${global_opts}" -- "\${cur}") )
96
- ;;
97
- esac
98
- }
99
-
100
- complete -F _switchbot_completion switchbot
101
- `;
102
- const ZSH_SCRIPT = `# switchbot zsh completion
103
- # Install: source <(switchbot completion zsh)
104
- # Or add to ~/.zshrc:
105
- # source <(switchbot completion zsh)
106
-
107
- _switchbot() {
108
- local -a top_cmds config_sub devices_sub scenes_sub webhook_sub events_sub quota_sub catalog_sub cache_sub history_sub plan_sub completion_shells
109
- top_cmds=(
110
- 'config:Manage API credentials'
111
- 'devices:List and control devices'
112
- 'scenes:List and execute scenes'
113
- 'webhook:Manage webhook configuration'
114
- 'completion:Print a shell completion script'
115
- 'mcp:Run the MCP server'
116
- 'quota:Inspect local request quota'
117
- 'catalog:Inspect the built-in device catalog'
118
- 'cache:Inspect local caches'
119
- 'events:Receive webhook or MQTT events'
120
- 'doctor:Run self-checks'
121
- 'schema:Export the device catalog as JSON'
122
- 'history:View and replay audited commands'
123
- 'plan:Validate and run batch plans'
124
- 'capabilities:Print a machine-readable manifest'
125
- 'help:Show help for a command'
126
- )
127
- config_sub=('set-token:Save token + secret' 'show:Show current credential source' 'list-profiles:List named credential profiles')
128
- devices_sub=(
129
- 'list:List all devices'
130
- 'ls:Alias for list'
131
- 'status:Query device status'
132
- 'command:Send a control command'
133
- 'types:List known device types (offline)'
134
- 'commands:Show commands for a device type (offline)'
135
- 'describe:Show metadata + supported commands for one device'
136
- 'batch:Send one command to many devices'
137
- 'watch:Poll device status and emit changes'
138
- 'explain:One-shot device summary'
139
- 'expand:Build wire-format params from semantic flags'
140
- 'meta:Manage local device metadata'
141
- )
142
- scenes_sub=('list:List manual scenes' 'execute:Run a scene')
143
- webhook_sub=(
144
- 'setup:Register a webhook URL'
145
- 'query:Query configured webhooks'
146
- 'update:Enable/disable a webhook'
147
- 'delete:Delete a webhook'
148
- )
149
- events_sub=('tail:Run a local webhook receiver' 'mqtt-tail:Stream MQTT shadow events')
150
- quota_sub=('status:Show today and recent quota usage' 'reset:Delete the local quota counter')
151
- catalog_sub=('path:Show overlay path' 'show:Show built-in/overlay/effective catalog' 'diff:Show overlay changes' 'refresh:Clear overlay cache')
152
- cache_sub=('show:Summarize cache files' 'clear:Delete cache files')
153
- history_sub=('show:Print recent audit entries' 'replay:Re-run one audited command')
154
- plan_sub=('schema:Print the plan schema' 'validate:Validate a plan file' 'run:Validate and execute a plan')
155
- completion_shells=('bash' 'zsh' 'fish' 'powershell')
156
-
157
- local global_opts
158
- global_opts=(
159
- '--json[Raw JSON output]'
160
- '--format[Output format]:type:(table json jsonl tsv yaml id)'
161
- '--fields[Comma-separated output columns]:csv:'
162
- '(-v --verbose)'{-v,--verbose}'[Log HTTP details to stderr]'
163
- '--dry-run[Print mutating requests without sending]'
164
- '--timeout[HTTP timeout in ms]:ms:'
165
- '--retry-on-429[Max 429 retries]:n:'
166
- '--backoff[Retry backoff strategy]:strategy:(linear exponential)'
167
- '--no-retry[Disable 429 retries]'
168
- '--no-quota[Disable the local quota counter]'
169
- '--cache[Cache mode]:mode:'
170
- '--no-cache[Disable cache reads]'
171
- '--config[Override credential file path]:path:_files'
172
- '--profile[Use a named credential profile]:name:'
173
- '--audit-log[Append mutating commands to ~/.switchbot/audit.log]'
174
- '--audit-log-path[Custom audit log file path]:path:_files'
175
- '(-h --help)'{-h,--help}'[Show help]'
176
- '(-V --version)'{-V,--version}'[Show version]'
177
- )
178
-
179
- _arguments -C \\
180
- "1:command:->top" \\
181
- "2:subcommand:->sub" \\
182
- "*::arg:->rest" \\
183
- $global_opts
184
-
185
- case "$state" in
186
- top)
187
- _describe 'command' top_cmds
188
- ;;
189
- sub)
190
- case "$words[2]" in
191
- config) _describe 'config' config_sub ;;
192
- devices) _describe 'devices' devices_sub ;;
193
- scenes) _describe 'scenes' scenes_sub ;;
194
- webhook) _describe 'webhook' webhook_sub ;;
195
- events) _describe 'events' events_sub ;;
196
- quota) _describe 'quota' quota_sub ;;
197
- catalog) _describe 'catalog' catalog_sub ;;
198
- cache) _describe 'cache' cache_sub ;;
199
- history) _describe 'history' history_sub ;;
200
- plan) _describe 'plan' plan_sub ;;
201
- completion) _values 'shell' $completion_shells ;;
202
- esac
203
- ;;
204
- rest)
205
- if [[ "$words[2]" == "webhook" && "$words[3]" == "update" ]]; then
206
- _values 'flag' '--enable' '--disable'
207
- fi
208
- ;;
209
- esac
210
- }
211
-
212
- compdef _switchbot switchbot
213
- `;
214
- const FISH_SCRIPT = `# switchbot fish completion
215
- # Install:
216
- # switchbot completion fish > ~/.config/fish/completions/switchbot.fish
217
-
218
- complete -c switchbot -f
219
-
220
- # Global options
221
- complete -c switchbot -l json -d 'Raw JSON output'
222
- complete -c switchbot -l format -r -d 'Output format'
223
- complete -c switchbot -l fields -r -d 'Comma-separated output columns'
224
- complete -c switchbot -s v -l verbose -d 'Log HTTP details to stderr'
225
- complete -c switchbot -l dry-run -d 'Print mutating requests without sending'
226
- complete -c switchbot -l timeout -r -d 'HTTP timeout in ms'
227
- complete -c switchbot -l retry-on-429 -r -d 'Max 429 retries'
228
- complete -c switchbot -l backoff -r -d 'Retry backoff strategy'
229
- complete -c switchbot -l no-retry -d 'Disable 429 retries'
230
- complete -c switchbot -l no-quota -d 'Disable the local quota counter'
231
- complete -c switchbot -l cache -r -d 'Cache mode'
232
- complete -c switchbot -l no-cache -d 'Disable cache reads'
233
- complete -c switchbot -l config -r -d 'Credential file path'
234
- complete -c switchbot -l profile -r -d 'Named credential profile'
235
- complete -c switchbot -l audit-log -d 'Append mutating commands to audit log'
236
- complete -c switchbot -l audit-log-path -r -d 'Custom audit log file path'
237
- complete -c switchbot -s h -l help -d 'Show help'
238
- complete -c switchbot -s V -l version -d 'Show version'
239
-
240
- # Top-level commands
241
- complete -c switchbot -n '__fish_use_subcommand' -a 'config' -d 'Manage API credentials'
242
- complete -c switchbot -n '__fish_use_subcommand' -a 'devices' -d 'List and control devices'
243
- complete -c switchbot -n '__fish_use_subcommand' -a 'scenes' -d 'List and execute scenes'
244
- complete -c switchbot -n '__fish_use_subcommand' -a 'webhook' -d 'Manage webhook configuration'
245
- complete -c switchbot -n '__fish_use_subcommand' -a 'completion' -d 'Print a shell completion script'
246
- complete -c switchbot -n '__fish_use_subcommand' -a 'mcp' -d 'Run the MCP server'
247
- complete -c switchbot -n '__fish_use_subcommand' -a 'quota' -d 'Inspect local request quota'
248
- complete -c switchbot -n '__fish_use_subcommand' -a 'catalog' -d 'Inspect the built-in device catalog'
249
- complete -c switchbot -n '__fish_use_subcommand' -a 'cache' -d 'Inspect local caches'
250
- complete -c switchbot -n '__fish_use_subcommand' -a 'events' -d 'Receive webhook or MQTT events'
251
- complete -c switchbot -n '__fish_use_subcommand' -a 'doctor' -d 'Run self-checks'
252
- complete -c switchbot -n '__fish_use_subcommand' -a 'schema' -d 'Export the device catalog as JSON'
253
- complete -c switchbot -n '__fish_use_subcommand' -a 'history' -d 'View and replay audited commands'
254
- complete -c switchbot -n '__fish_use_subcommand' -a 'plan' -d 'Validate and run batch plans'
255
- complete -c switchbot -n '__fish_use_subcommand' -a 'capabilities' -d 'Print a machine-readable manifest'
256
- complete -c switchbot -n '__fish_use_subcommand' -a 'help' -d 'Show help'
257
-
258
- # config
259
- complete -c switchbot -n '__fish_seen_subcommand_from config' -a 'set-token show list-profiles'
260
-
261
- # devices
262
- complete -c switchbot -n '__fish_seen_subcommand_from devices' -a 'list ls status command types commands describe batch watch explain expand meta'
263
-
264
- # scenes
265
- complete -c switchbot -n '__fish_seen_subcommand_from scenes' -a 'list execute'
266
-
267
- # webhook
268
- complete -c switchbot -n '__fish_seen_subcommand_from webhook' -a 'setup query update delete'
269
- complete -c switchbot -n '__fish_seen_subcommand_from webhook; and __fish_seen_subcommand_from update' -l enable -d 'Enable the webhook'
270
- complete -c switchbot -n '__fish_seen_subcommand_from webhook; and __fish_seen_subcommand_from update' -l disable -d 'Disable the webhook'
271
-
272
- # events
273
- complete -c switchbot -n '__fish_seen_subcommand_from events' -a 'tail mqtt-tail'
274
-
275
- # quota
276
- complete -c switchbot -n '__fish_seen_subcommand_from quota' -a 'status reset'
277
-
278
- # catalog
279
- complete -c switchbot -n '__fish_seen_subcommand_from catalog' -a 'path show diff refresh'
280
-
281
- # cache
282
- complete -c switchbot -n '__fish_seen_subcommand_from cache' -a 'show clear'
283
-
284
- # history
285
- complete -c switchbot -n '__fish_seen_subcommand_from history' -a 'show replay'
286
-
287
- # plan
288
- complete -c switchbot -n '__fish_seen_subcommand_from plan' -a 'schema validate run'
289
-
290
- # completion
291
- complete -c switchbot -n '__fish_seen_subcommand_from completion' -a 'bash zsh fish powershell'
292
- `;
293
- const POWERSHELL_SCRIPT = `# switchbot PowerShell completion
294
- # Install: switchbot completion powershell | Out-String | Invoke-Expression
295
- # Or add to your profile:
296
- # switchbot completion powershell >> $PROFILE
297
-
298
- Register-ArgumentCompleter -Native -CommandName switchbot -ScriptBlock {
299
- param($wordToComplete, $commandAst, $cursorPosition)
300
-
301
- $tokens = $commandAst.CommandElements | ForEach-Object { $_.ToString() }
302
- $count = $tokens.Count
303
-
304
- $top = 'config','devices','scenes','webhook','completion','mcp','quota','catalog','cache','events','doctor','schema','history','plan','capabilities','help'
305
- $configSub = 'set-token','show','list-profiles'
306
- $devicesSub = 'list','ls','status','command','types','commands','describe','batch','watch','explain','expand','meta'
307
- $scenesSub = 'list','execute'
308
- $webhookSub = 'setup','query','update','delete'
309
- $eventsSub = 'tail','mqtt-tail'
310
- $quotaSub = 'status','reset'
311
- $catalogSub = 'path','show','diff','refresh'
312
- $cacheSub = 'show','clear'
313
- $historySub = 'show','replay'
314
- $planSub = 'schema','validate','run'
315
- $shells = 'bash','zsh','fish','powershell'
316
- $globalOpts = '--json','--format','--fields','--verbose','-v','--dry-run','--timeout','--retry-on-429','--backoff','--no-retry','--no-quota','--cache','--no-cache','--config','--profile','--audit-log','--audit-log-path','--help','-h','--version','-V'
317
-
318
- function _emit($values) {
319
- $values |
320
- Where-Object { $_ -like "$wordToComplete*" } |
321
- ForEach-Object { [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_) }
322
- }
323
-
324
- if ($count -le 2) { return _emit ($top + $globalOpts) }
325
-
326
- switch ($tokens[1]) {
327
- 'config' { if ($count -eq 3) { return _emit $configSub } }
328
- 'devices' { if ($count -eq 3) { return _emit $devicesSub } }
329
- 'scenes' { if ($count -eq 3) { return _emit $scenesSub } }
330
- 'events' { if ($count -eq 3) { return _emit $eventsSub } }
331
- 'quota' { if ($count -eq 3) { return _emit $quotaSub } }
332
- 'catalog' { if ($count -eq 3) { return _emit $catalogSub } }
333
- 'cache' { if ($count -eq 3) { return _emit $cacheSub } }
334
- 'history' { if ($count -eq 3) { return _emit $historySub } }
335
- 'plan' { if ($count -eq 3) { return _emit $planSub } }
336
- 'webhook' {
337
- if ($count -eq 3) { return _emit $webhookSub }
338
- if ($tokens[2] -eq 'update') { return _emit ('--enable','--disable' + $globalOpts) }
339
- }
340
- 'completion' { if ($count -eq 3) { return _emit $shells } }
341
- }
342
-
343
- return _emit $globalOpts
344
- }
345
- `;
346
- export function registerCompletionCommand(program) {
347
- const completion = program
348
- .command('completion')
349
- .description('Print a shell completion script for bash, zsh, fish, or powershell')
350
- .argument('<shell>', 'Shell to generate completion for: bash | zsh | fish | powershell')
351
- .addHelpText('after', `
352
- The command writes the completion script to stdout. Redirect it to a file or
353
- source it directly:
354
-
355
- bash source <(switchbot completion bash)
356
- # persist: echo 'source <(switchbot completion bash)' >> ~/.bashrc
357
-
358
- zsh source <(switchbot completion zsh)
359
- # persist: echo 'source <(switchbot completion zsh)' >> ~/.zshrc
360
-
361
- fish switchbot completion fish > ~/.config/fish/completions/switchbot.fish
362
-
363
- powershell switchbot completion powershell | Out-String | Invoke-Expression
364
- # persist: switchbot completion powershell >> $PROFILE
365
- `)
366
- .action((shell) => {
367
- switch (shell.toLowerCase()) {
368
- case 'bash':
369
- process.stdout.write(BASH_SCRIPT);
370
- return;
371
- case 'zsh':
372
- process.stdout.write(ZSH_SCRIPT);
373
- return;
374
- case 'fish':
375
- process.stdout.write(FISH_SCRIPT);
376
- return;
377
- case 'powershell':
378
- case 'pwsh':
379
- process.stdout.write(POWERSHELL_SCRIPT);
380
- return;
381
- default:
382
- completion.error(`error: unsupported shell "${shell}" (choose from: bash, zsh, fish, powershell)`, { exitCode: 2, code: 'switchbot.unsupportedShell' });
383
- }
384
- });
385
- }
386
- //# sourceMappingURL=completion.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"completion.js","sourceRoot":"","sources":["../../src/commands/completion.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoGnB,CAAC;AAEF,MAAM,UAAU,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+GlB,CAAC;AAEF,MAAM,WAAW,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8EnB,CAAC;AAEF,MAAM,iBAAiB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoDzB,CAAC;AAEF,MAAM,UAAU,yBAAyB,CAAC,OAAgB;IACxD,MAAM,UAAU,GAAG,OAAO;SACvB,OAAO,CAAC,YAAY,CAAC;SACrB,WAAW,CAAC,oEAAoE,CAAC;SACjF,QAAQ,CAAC,SAAS,EAAE,kEAAkE,CAAC;SACvF,WAAW,CAAC,OAAO,EAAE;;;;;;;;;;;;;;CAczB,CAAC;SACG,MAAM,CAAC,CAAC,KAAa,EAAE,EAAE;QACxB,QAAQ,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC;YAC5B,KAAK,MAAM;gBACT,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;gBAClC,OAAO;YACT,KAAK,KAAK;gBACR,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;gBACjC,OAAO;YACT,KAAK,MAAM;gBACT,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;gBAClC,OAAO;YACT,KAAK,YAAY,CAAC;YAClB,KAAK,MAAM;gBACT,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;gBACxC,OAAO;YACT;gBACE,UAAU,CAAC,KAAK,CACd,6BAA6B,KAAK,8CAA8C,EAChF,EAAE,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,4BAA4B,EAAE,CACpD,CAAC;QACN,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -1,21 +0,0 @@
1
- import { Command } from 'commander';
2
- /**
3
- * Interactive echo-off prompt for token + secret. Used by both
4
- * `switchbot config set-token` and the install orchestrator. Throws if
5
- * stdin is not a TTY.
6
- */
7
- export declare function promptTokenAndSecret(): Promise<{
8
- token: string;
9
- secret: string;
10
- }>;
11
- /**
12
- * Read a two-line credential file (line 1 = token, line 2 = secret)
13
- * and unlink it on success. The installer's `--token-file` escape
14
- * hatch uses this; keeps credentials off the command line and shell
15
- * history for CI-style installs.
16
- */
17
- export declare function readCredentialsFile(filePath: string): {
18
- token: string;
19
- secret: string;
20
- };
21
- export declare function registerConfigCommand(program: Command): void;