@switchbot/openapi-cli 3.2.0 → 3.2.1

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 (331) hide show
  1. package/dist/api/client.d.ts +31 -0
  2. package/dist/api/client.js +236 -0
  3. package/dist/api/client.js.map +1 -0
  4. package/dist/auth.d.ts +1 -0
  5. package/dist/auth.js +21 -0
  6. package/dist/auth.js.map +1 -0
  7. package/dist/commands/agent-bootstrap.d.ts +10 -0
  8. package/dist/commands/agent-bootstrap.js +200 -0
  9. package/dist/commands/agent-bootstrap.js.map +1 -0
  10. package/dist/commands/auth.d.ts +18 -0
  11. package/dist/commands/auth.js +355 -0
  12. package/dist/commands/auth.js.map +1 -0
  13. package/dist/commands/batch.d.ts +2 -0
  14. package/dist/commands/batch.js +414 -0
  15. package/dist/commands/batch.js.map +1 -0
  16. package/dist/commands/cache.d.ts +2 -0
  17. package/dist/commands/cache.js +127 -0
  18. package/dist/commands/cache.js.map +1 -0
  19. package/dist/commands/capabilities.d.ts +31 -0
  20. package/dist/commands/capabilities.js +383 -0
  21. package/dist/commands/capabilities.js.map +1 -0
  22. package/dist/commands/catalog.d.ts +2 -0
  23. package/dist/commands/catalog.js +360 -0
  24. package/dist/commands/catalog.js.map +1 -0
  25. package/dist/commands/completion.d.ts +2 -0
  26. package/dist/commands/completion.js +386 -0
  27. package/dist/commands/completion.js.map +1 -0
  28. package/dist/commands/config.d.ts +21 -0
  29. package/dist/commands/config.js +377 -0
  30. package/dist/commands/config.js.map +1 -0
  31. package/dist/commands/daemon.d.ts +2 -0
  32. package/dist/commands/daemon.js +411 -0
  33. package/dist/commands/daemon.js.map +1 -0
  34. package/dist/commands/device-meta.d.ts +2 -0
  35. package/dist/commands/device-meta.js +160 -0
  36. package/dist/commands/device-meta.js.map +1 -0
  37. package/dist/commands/devices.d.ts +2 -0
  38. package/dist/commands/devices.js +949 -0
  39. package/dist/commands/devices.js.map +1 -0
  40. package/dist/commands/doctor.d.ts +3 -0
  41. package/dist/commands/doctor.js +1016 -0
  42. package/dist/commands/doctor.js.map +1 -0
  43. package/dist/commands/events.d.ts +31 -0
  44. package/dist/commands/events.js +564 -0
  45. package/dist/commands/events.js.map +1 -0
  46. package/dist/commands/expand.d.ts +2 -0
  47. package/dist/commands/expand.js +131 -0
  48. package/dist/commands/expand.js.map +1 -0
  49. package/dist/commands/explain.d.ts +2 -0
  50. package/dist/commands/explain.js +140 -0
  51. package/dist/commands/explain.js.map +1 -0
  52. package/dist/commands/health.d.ts +8 -0
  53. package/dist/commands/health.js +114 -0
  54. package/dist/commands/health.js.map +1 -0
  55. package/dist/commands/history.d.ts +2 -0
  56. package/dist/commands/history.js +321 -0
  57. package/dist/commands/history.js.map +1 -0
  58. package/dist/commands/identity.d.ts +45 -0
  59. package/dist/commands/identity.js +60 -0
  60. package/dist/commands/identity.js.map +1 -0
  61. package/dist/commands/install.d.ts +20 -0
  62. package/dist/commands/install.js +247 -0
  63. package/dist/commands/install.js.map +1 -0
  64. package/dist/commands/mcp.d.ts +14 -0
  65. package/dist/commands/mcp.js +2018 -0
  66. package/dist/commands/mcp.js.map +1 -0
  67. package/dist/commands/plan.d.ts +51 -0
  68. package/dist/commands/plan.js +654 -0
  69. package/dist/commands/plan.js.map +1 -0
  70. package/dist/commands/policy.d.ts +24 -0
  71. package/dist/commands/policy.js +587 -0
  72. package/dist/commands/policy.js.map +1 -0
  73. package/dist/commands/quota.d.ts +2 -0
  74. package/dist/commands/quota.js +79 -0
  75. package/dist/commands/quota.js.map +1 -0
  76. package/dist/commands/rules.d.ts +2 -0
  77. package/dist/commands/rules.js +876 -0
  78. package/dist/commands/rules.js.map +1 -0
  79. package/dist/commands/scenes.d.ts +2 -0
  80. package/dist/commands/scenes.js +265 -0
  81. package/dist/commands/scenes.js.map +1 -0
  82. package/dist/commands/schema.d.ts +2 -0
  83. package/dist/commands/schema.js +185 -0
  84. package/dist/commands/schema.js.map +1 -0
  85. package/dist/commands/status-sync.d.ts +2 -0
  86. package/dist/commands/status-sync.js +132 -0
  87. package/dist/commands/status-sync.js.map +1 -0
  88. package/dist/commands/uninstall.d.ts +20 -0
  89. package/dist/commands/uninstall.js +238 -0
  90. package/dist/commands/uninstall.js.map +1 -0
  91. package/dist/commands/upgrade-check.d.ts +2 -0
  92. package/dist/commands/upgrade-check.js +107 -0
  93. package/dist/commands/upgrade-check.js.map +1 -0
  94. package/dist/commands/watch.d.ts +2 -0
  95. package/dist/commands/watch.js +195 -0
  96. package/dist/commands/watch.js.map +1 -0
  97. package/dist/commands/webhook.d.ts +2 -0
  98. package/dist/commands/webhook.js +183 -0
  99. package/dist/commands/webhook.js.map +1 -0
  100. package/dist/config.d.ts +57 -0
  101. package/dist/config.js +259 -0
  102. package/dist/config.js.map +1 -0
  103. package/dist/credentials/backends/file.d.ts +18 -0
  104. package/dist/credentials/backends/file.js +102 -0
  105. package/dist/credentials/backends/file.js.map +1 -0
  106. package/dist/credentials/backends/linux.d.ts +16 -0
  107. package/dist/credentials/backends/linux.js +130 -0
  108. package/dist/credentials/backends/linux.js.map +1 -0
  109. package/dist/credentials/backends/macos.d.ts +18 -0
  110. package/dist/credentials/backends/macos.js +130 -0
  111. package/dist/credentials/backends/macos.js.map +1 -0
  112. package/dist/credentials/backends/windows.d.ts +23 -0
  113. package/dist/credentials/backends/windows.js +216 -0
  114. package/dist/credentials/backends/windows.js.map +1 -0
  115. package/dist/credentials/keychain.d.ts +83 -0
  116. package/dist/credentials/keychain.js +89 -0
  117. package/dist/credentials/keychain.js.map +1 -0
  118. package/dist/credentials/prime.d.ts +32 -0
  119. package/dist/credentials/prime.js +53 -0
  120. package/dist/credentials/prime.js.map +1 -0
  121. package/dist/devices/cache.d.ts +79 -0
  122. package/dist/devices/cache.js +294 -0
  123. package/dist/devices/cache.js.map +1 -0
  124. package/dist/devices/catalog.d.ts +138 -0
  125. package/dist/devices/catalog.js +768 -0
  126. package/dist/devices/catalog.js.map +1 -0
  127. package/dist/devices/device-meta.d.ts +15 -0
  128. package/dist/devices/device-meta.js +57 -0
  129. package/dist/devices/device-meta.js.map +1 -0
  130. package/dist/devices/history-agg.d.ts +37 -0
  131. package/dist/devices/history-agg.js +139 -0
  132. package/dist/devices/history-agg.js.map +1 -0
  133. package/dist/devices/history-query.d.ts +45 -0
  134. package/dist/devices/history-query.js +182 -0
  135. package/dist/devices/history-query.js.map +1 -0
  136. package/dist/devices/param-validator.d.ts +40 -0
  137. package/dist/devices/param-validator.js +434 -0
  138. package/dist/devices/param-validator.js.map +1 -0
  139. package/dist/devices/resources.d.ts +74 -0
  140. package/dist/devices/resources.js +271 -0
  141. package/dist/devices/resources.js.map +1 -0
  142. package/dist/index.d.ts +1 -0
  143. package/dist/index.js +170 -56946
  144. package/dist/index.js.map +1 -0
  145. package/dist/install/default-steps.d.ts +66 -0
  146. package/dist/install/default-steps.js +258 -0
  147. package/dist/install/default-steps.js.map +1 -0
  148. package/dist/install/preflight.d.ts +60 -0
  149. package/dist/install/preflight.js +213 -0
  150. package/dist/install/preflight.js.map +1 -0
  151. package/dist/install/steps.d.ts +61 -0
  152. package/dist/install/steps.js +68 -0
  153. package/dist/install/steps.js.map +1 -0
  154. package/dist/lib/command-keywords.d.ts +5 -0
  155. package/dist/lib/command-keywords.js +18 -0
  156. package/dist/lib/command-keywords.js.map +1 -0
  157. package/dist/lib/daemon-state.d.ts +24 -0
  158. package/dist/lib/daemon-state.js +47 -0
  159. package/dist/lib/daemon-state.js.map +1 -0
  160. package/dist/lib/destructive-mode.d.ts +2 -0
  161. package/dist/lib/destructive-mode.js +13 -0
  162. package/dist/lib/destructive-mode.js.map +1 -0
  163. package/dist/lib/devices.d.ts +151 -0
  164. package/dist/lib/devices.js +383 -0
  165. package/dist/lib/devices.js.map +1 -0
  166. package/dist/lib/idempotency.d.ts +46 -0
  167. package/dist/lib/idempotency.js +107 -0
  168. package/dist/lib/idempotency.js.map +1 -0
  169. package/dist/lib/plan-store.d.ts +19 -0
  170. package/dist/lib/plan-store.js +69 -0
  171. package/dist/lib/plan-store.js.map +1 -0
  172. package/dist/lib/request-context.d.ts +7 -0
  173. package/dist/lib/request-context.js +13 -0
  174. package/dist/lib/request-context.js.map +1 -0
  175. package/dist/lib/scenes.d.ts +7 -0
  176. package/dist/lib/scenes.js +11 -0
  177. package/dist/lib/scenes.js.map +1 -0
  178. package/dist/logger.d.ts +4 -0
  179. package/dist/logger.js +17 -0
  180. package/dist/logger.js.map +1 -0
  181. package/dist/mcp/device-history.d.ts +36 -0
  182. package/dist/mcp/device-history.js +146 -0
  183. package/dist/mcp/device-history.js.map +1 -0
  184. package/dist/mcp/events-subscription.d.ts +45 -0
  185. package/dist/mcp/events-subscription.js +214 -0
  186. package/dist/mcp/events-subscription.js.map +1 -0
  187. package/dist/mqtt/client.d.ts +25 -0
  188. package/dist/mqtt/client.js +181 -0
  189. package/dist/mqtt/client.js.map +1 -0
  190. package/dist/mqtt/credential.d.ts +16 -0
  191. package/dist/mqtt/credential.js +31 -0
  192. package/dist/mqtt/credential.js.map +1 -0
  193. package/dist/policy/add-rule.d.ts +21 -0
  194. package/dist/policy/add-rule.js +125 -0
  195. package/dist/policy/add-rule.js.map +1 -0
  196. package/dist/policy/diff.d.ts +21 -0
  197. package/dist/policy/diff.js +92 -0
  198. package/dist/policy/diff.js.map +1 -0
  199. package/dist/policy/format.d.ts +6 -0
  200. package/dist/policy/format.js +58 -0
  201. package/dist/policy/format.js.map +1 -0
  202. package/dist/policy/load.d.ts +32 -0
  203. package/dist/policy/load.js +62 -0
  204. package/dist/policy/load.js.map +1 -0
  205. package/dist/policy/migrate.d.ts +21 -0
  206. package/dist/policy/migrate.js +68 -0
  207. package/dist/policy/migrate.js.map +1 -0
  208. package/dist/policy/schema.d.ts +5 -0
  209. package/dist/policy/schema.js +19 -0
  210. package/dist/policy/schema.js.map +1 -0
  211. package/dist/policy/validate.d.ts +19 -0
  212. package/dist/policy/validate.js +263 -0
  213. package/dist/policy/validate.js.map +1 -0
  214. package/dist/rules/action.d.ts +65 -0
  215. package/dist/rules/action.js +217 -0
  216. package/dist/rules/action.js.map +1 -0
  217. package/dist/rules/audit-query.d.ts +51 -0
  218. package/dist/rules/audit-query.js +90 -0
  219. package/dist/rules/audit-query.js.map +1 -0
  220. package/dist/rules/conflict-analyzer.d.ts +57 -0
  221. package/dist/rules/conflict-analyzer.js +215 -0
  222. package/dist/rules/conflict-analyzer.js.map +1 -0
  223. package/dist/rules/cron-scheduler.d.ts +62 -0
  224. package/dist/rules/cron-scheduler.js +187 -0
  225. package/dist/rules/cron-scheduler.js.map +1 -0
  226. package/dist/rules/destructive.d.ts +20 -0
  227. package/dist/rules/destructive.js +53 -0
  228. package/dist/rules/destructive.js.map +1 -0
  229. package/dist/rules/engine.d.ts +193 -0
  230. package/dist/rules/engine.js +758 -0
  231. package/dist/rules/engine.js.map +1 -0
  232. package/dist/rules/matcher.d.ts +56 -0
  233. package/dist/rules/matcher.js +231 -0
  234. package/dist/rules/matcher.js.map +1 -0
  235. package/dist/rules/pid-file.d.ts +43 -0
  236. package/dist/rules/pid-file.js +96 -0
  237. package/dist/rules/pid-file.js.map +1 -0
  238. package/dist/rules/quiet-hours.d.ts +26 -0
  239. package/dist/rules/quiet-hours.js +46 -0
  240. package/dist/rules/quiet-hours.js.map +1 -0
  241. package/dist/rules/suggest.d.ts +20 -0
  242. package/dist/rules/suggest.js +96 -0
  243. package/dist/rules/suggest.js.map +1 -0
  244. package/dist/rules/throttle.d.ts +61 -0
  245. package/dist/rules/throttle.js +117 -0
  246. package/dist/rules/throttle.js.map +1 -0
  247. package/dist/rules/types.d.ts +117 -0
  248. package/dist/rules/types.js +35 -0
  249. package/dist/rules/types.js.map +1 -0
  250. package/dist/rules/webhook-listener.d.ts +63 -0
  251. package/dist/rules/webhook-listener.js +224 -0
  252. package/dist/rules/webhook-listener.js.map +1 -0
  253. package/dist/rules/webhook-token.d.ts +50 -0
  254. package/dist/rules/webhook-token.js +91 -0
  255. package/dist/rules/webhook-token.js.map +1 -0
  256. package/dist/schema/field-aliases.d.ts +34 -0
  257. package/dist/schema/field-aliases.js +132 -0
  258. package/dist/schema/field-aliases.js.map +1 -0
  259. package/dist/sinks/dispatcher.d.ts +7 -0
  260. package/dist/sinks/dispatcher.js +13 -0
  261. package/dist/sinks/dispatcher.js.map +1 -0
  262. package/dist/sinks/file.d.ts +6 -0
  263. package/dist/sinks/file.js +20 -0
  264. package/dist/sinks/file.js.map +1 -0
  265. package/dist/sinks/format.d.ts +20 -0
  266. package/dist/sinks/format.js +57 -0
  267. package/dist/sinks/format.js.map +1 -0
  268. package/dist/sinks/homeassistant.d.ts +18 -0
  269. package/dist/sinks/homeassistant.js +45 -0
  270. package/dist/sinks/homeassistant.js.map +1 -0
  271. package/dist/sinks/openclaw.d.ts +13 -0
  272. package/dist/sinks/openclaw.js +34 -0
  273. package/dist/sinks/openclaw.js.map +1 -0
  274. package/dist/sinks/stdout.d.ts +4 -0
  275. package/dist/sinks/stdout.js +6 -0
  276. package/dist/sinks/stdout.js.map +1 -0
  277. package/dist/sinks/telegram.d.ts +11 -0
  278. package/dist/sinks/telegram.js +29 -0
  279. package/dist/sinks/telegram.js.map +1 -0
  280. package/dist/sinks/types.d.ts +13 -0
  281. package/dist/sinks/types.js +2 -0
  282. package/dist/sinks/types.js.map +1 -0
  283. package/dist/sinks/webhook.d.ts +6 -0
  284. package/dist/sinks/webhook.js +23 -0
  285. package/dist/sinks/webhook.js.map +1 -0
  286. package/dist/status-sync/manager.d.ts +48 -0
  287. package/dist/status-sync/manager.js +269 -0
  288. package/dist/status-sync/manager.js.map +1 -0
  289. package/dist/utils/arg-parsers.d.ts +16 -0
  290. package/dist/utils/arg-parsers.js +67 -0
  291. package/dist/utils/arg-parsers.js.map +1 -0
  292. package/dist/utils/audit.d.ts +69 -0
  293. package/dist/utils/audit.js +122 -0
  294. package/dist/utils/audit.js.map +1 -0
  295. package/dist/utils/filter.d.ts +81 -0
  296. package/dist/utils/filter.js +190 -0
  297. package/dist/utils/filter.js.map +1 -0
  298. package/dist/utils/flags.d.ts +72 -0
  299. package/dist/utils/flags.js +187 -0
  300. package/dist/utils/flags.js.map +1 -0
  301. package/dist/utils/format.d.ts +9 -0
  302. package/dist/utils/format.js +118 -0
  303. package/dist/utils/format.js.map +1 -0
  304. package/dist/utils/health.d.ts +48 -0
  305. package/dist/utils/health.js +102 -0
  306. package/dist/utils/health.js.map +1 -0
  307. package/dist/utils/help-json.d.ts +39 -0
  308. package/dist/utils/help-json.js +55 -0
  309. package/dist/utils/help-json.js.map +1 -0
  310. package/dist/utils/name-resolver.d.ts +26 -0
  311. package/dist/utils/name-resolver.js +138 -0
  312. package/dist/utils/name-resolver.js.map +1 -0
  313. package/dist/utils/output.d.ts +73 -0
  314. package/dist/utils/output.js +405 -0
  315. package/dist/utils/output.js.map +1 -0
  316. package/dist/utils/quota.d.ts +61 -0
  317. package/dist/utils/quota.js +228 -0
  318. package/dist/utils/quota.js.map +1 -0
  319. package/dist/utils/redact.d.ts +23 -0
  320. package/dist/utils/redact.js +69 -0
  321. package/dist/utils/redact.js.map +1 -0
  322. package/dist/utils/retry.d.ts +72 -0
  323. package/dist/utils/retry.js +141 -0
  324. package/dist/utils/retry.js.map +1 -0
  325. package/dist/utils/string.d.ts +2 -0
  326. package/dist/utils/string.js +23 -0
  327. package/dist/utils/string.js.map +1 -0
  328. package/dist/version.d.ts +2 -0
  329. package/dist/version.js +5 -0
  330. package/dist/version.js.map +1 -0
  331. package/package.json +2 -2
@@ -0,0 +1,386 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,21 @@
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;