@seamapi/cli 0.18.1 → 0.19.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 (364) hide show
  1. package/README.md +55 -1
  2. package/bin/cli.js +73 -249
  3. package/bin/cli.js.map +1 -1
  4. package/lib/args/coerce.d.ts +28 -0
  5. package/lib/args/coerce.js +131 -0
  6. package/lib/args/coerce.js.map +1 -0
  7. package/lib/{util/cli-args.d.ts → args/parse.d.ts} +12 -15
  8. package/lib/{util/cli-args.js → args/parse.js} +21 -24
  9. package/lib/args/parse.js.map +1 -0
  10. package/lib/args/validate.d.ts +23 -0
  11. package/lib/args/validate.js +42 -0
  12. package/lib/args/validate.js.map +1 -0
  13. package/lib/auth/operations.d.ts +54 -0
  14. package/lib/auth/operations.js +115 -0
  15. package/lib/auth/operations.js.map +1 -0
  16. package/lib/{validate-token.js → auth/validate-token.js} +2 -2
  17. package/lib/auth/validate-token.js.map +1 -0
  18. package/lib/blueprint/cache.d.ts +16 -0
  19. package/lib/blueprint/cache.js +73 -0
  20. package/lib/blueprint/cache.js.map +1 -0
  21. package/lib/blueprint/endpoint.d.ts +14 -0
  22. package/lib/{get-response-key.js → blueprint/endpoint.js} +11 -2
  23. package/lib/blueprint/endpoint.js.map +1 -0
  24. package/lib/blueprint/index.d.ts +12 -0
  25. package/lib/blueprint/index.js +10 -0
  26. package/lib/blueprint/index.js.map +1 -0
  27. package/lib/blueprint/source-npm.d.ts +10 -0
  28. package/lib/{blueprint.js → blueprint/source-npm.js} +20 -74
  29. package/lib/blueprint/source-npm.js.map +1 -0
  30. package/lib/blueprint/source-remote.d.ts +6 -0
  31. package/lib/blueprint/source-remote.js +14 -0
  32. package/lib/blueprint/source-remote.js.map +1 -0
  33. package/lib/commands/api-command.d.ts +8 -0
  34. package/lib/commands/api-command.js +71 -0
  35. package/lib/commands/api-command.js.map +1 -0
  36. package/lib/commands/local/completion.d.ts +18 -0
  37. package/lib/commands/local/completion.js +35 -0
  38. package/lib/commands/local/completion.js.map +1 -0
  39. package/lib/commands/local/config-reveal-location.d.ts +2 -0
  40. package/lib/commands/local/config-reveal-location.js +15 -0
  41. package/lib/commands/local/config-reveal-location.js.map +1 -0
  42. package/lib/commands/local/config-set-fake-server.d.ts +3 -0
  43. package/lib/commands/local/config-set-fake-server.js +20 -0
  44. package/lib/commands/local/config-set-fake-server.js.map +1 -0
  45. package/lib/commands/local/config-use-remote-api-defs.d.ts +2 -0
  46. package/lib/commands/local/config-use-remote-api-defs.js +20 -0
  47. package/lib/commands/local/config-use-remote-api-defs.js.map +1 -0
  48. package/lib/commands/local/health.d.ts +2 -0
  49. package/lib/commands/local/health.js +18 -0
  50. package/lib/commands/local/health.js.map +1 -0
  51. package/lib/commands/local/login.d.ts +2 -0
  52. package/lib/commands/local/login.js +35 -0
  53. package/lib/commands/local/login.js.map +1 -0
  54. package/lib/commands/local/logout.d.ts +2 -0
  55. package/lib/commands/local/logout.js +17 -0
  56. package/lib/commands/local/logout.js.map +1 -0
  57. package/lib/commands/local/select-server.d.ts +2 -0
  58. package/lib/commands/local/select-server.js +27 -0
  59. package/lib/commands/local/select-server.js.map +1 -0
  60. package/lib/commands/local/select-workspace.d.ts +2 -0
  61. package/lib/commands/local/select-workspace.js +22 -0
  62. package/lib/commands/local/select-workspace.js.map +1 -0
  63. package/lib/commands/local/wizard.d.ts +9 -0
  64. package/lib/commands/local/wizard.js +28 -0
  65. package/lib/commands/local/wizard.js.map +1 -0
  66. package/lib/commands/registry.d.ts +54 -0
  67. package/lib/commands/registry.js +64 -0
  68. package/lib/commands/registry.js.map +1 -0
  69. package/lib/{command-spec.d.ts → commands/spec.d.ts} +8 -12
  70. package/lib/{command-spec.js → commands/spec.js} +27 -120
  71. package/lib/commands/spec.js.map +1 -0
  72. package/lib/config/config-store.d.ts +23 -8
  73. package/lib/config/config-store.js +16 -42
  74. package/lib/config/config-store.js.map +1 -1
  75. package/lib/config/index.d.ts +2 -1
  76. package/lib/config/index.js +2 -1
  77. package/lib/config/index.js.map +1 -1
  78. package/lib/config/memory-config-store.d.ts +21 -0
  79. package/lib/config/memory-config-store.js +48 -0
  80. package/lib/config/memory-config-store.js.map +1 -0
  81. package/lib/config/migrate.js +1 -1
  82. package/lib/config/migrate.js.map +1 -1
  83. package/lib/config/values.d.ts +12 -0
  84. package/lib/config/values.js +50 -0
  85. package/lib/config/values.js.map +1 -0
  86. package/lib/context.d.ts +37 -0
  87. package/lib/context.js +31 -0
  88. package/lib/context.js.map +1 -0
  89. package/lib/env.d.ts +5 -0
  90. package/lib/env.js +5 -0
  91. package/lib/env.js.map +1 -1
  92. package/lib/errors.d.ts +31 -0
  93. package/lib/errors.js +58 -0
  94. package/lib/errors.js.map +1 -0
  95. package/lib/http/api.d.ts +37 -0
  96. package/lib/http/api.js +20 -0
  97. package/lib/http/api.js.map +1 -0
  98. package/lib/http/client.d.ts +4 -0
  99. package/lib/{get-seam.js → http/client.js} +16 -17
  100. package/lib/http/client.js.map +1 -0
  101. package/lib/http/follow-ups.d.ts +6 -0
  102. package/lib/http/follow-ups.js +30 -0
  103. package/lib/http/follow-ups.js.map +1 -0
  104. package/lib/http/memory-seam-api.d.ts +22 -0
  105. package/lib/http/memory-seam-api.js +41 -0
  106. package/lib/http/memory-seam-api.js.map +1 -0
  107. package/lib/http/request.d.ts +19 -0
  108. package/lib/http/request.js +39 -0
  109. package/lib/http/request.js.map +1 -0
  110. package/lib/{interact-for-access-code.js → interactions/access-code.js} +4 -4
  111. package/lib/interactions/access-code.js.map +1 -0
  112. package/lib/{interact-for-acs-entrance.js → interactions/acs-entrance.js} +3 -3
  113. package/lib/interactions/acs-entrance.js.map +1 -0
  114. package/lib/{interact-for-acs-system.js → interactions/acs-system.js} +3 -3
  115. package/lib/interactions/acs-system.js.map +1 -0
  116. package/lib/{interact-for-acs-user.js → interactions/acs-user.js} +4 -4
  117. package/lib/interactions/acs-user.js.map +1 -0
  118. package/lib/{interact-for-action-attempt-poll.js → interactions/action-attempt-poll.js} +5 -5
  119. package/lib/interactions/action-attempt-poll.js.map +1 -0
  120. package/lib/{interact-for-array.js → interactions/array.js} +4 -3
  121. package/lib/interactions/array.js.map +1 -0
  122. package/lib/{interact-for-blueprint-object.d.ts → interactions/blueprint-object.d.ts} +3 -2
  123. package/lib/{interact-for-blueprint-object.js → interactions/blueprint-object.js} +49 -20
  124. package/lib/interactions/blueprint-object.js.map +1 -0
  125. package/lib/{interact-for-command-params.d.ts → interactions/command-params.d.ts} +2 -2
  126. package/lib/{interact-for-command-params.js → interactions/command-params.js} +4 -3
  127. package/lib/interactions/command-params.js.map +1 -0
  128. package/lib/interactions/command-selection.d.ts +10 -0
  129. package/lib/{interact-for-command-selection.js → interactions/command-selection.js} +9 -15
  130. package/lib/interactions/command-selection.js.map +1 -0
  131. package/lib/{interact-for-connected-account.js → interactions/connected-account.js} +3 -3
  132. package/lib/interactions/connected-account.js.map +1 -0
  133. package/lib/{interact-for-custom-metadata.js → interactions/custom-metadata.js} +4 -3
  134. package/lib/interactions/custom-metadata.js.map +1 -0
  135. package/lib/{interact-for-device.js → interactions/device.js} +3 -3
  136. package/lib/interactions/device.js.map +1 -0
  137. package/lib/interactions/index.d.ts +19 -0
  138. package/lib/interactions/index.js +20 -0
  139. package/lib/interactions/index.js.map +1 -0
  140. package/lib/{interact-for-login.js → interactions/login.js} +16 -14
  141. package/lib/interactions/login.js.map +1 -0
  142. package/lib/{interact-for-resource.js → interactions/resource.js} +3 -3
  143. package/lib/interactions/resource.js.map +1 -0
  144. package/lib/{interact-for-server-selection.js → interactions/server-selection.js} +10 -13
  145. package/lib/interactions/server-selection.js.map +1 -0
  146. package/lib/{interact-for-timestamp.js → interactions/timestamp.js} +2 -2
  147. package/lib/interactions/timestamp.js.map +1 -0
  148. package/lib/{interact-for-use-remote-api-defs.js → interactions/use-remote-api-defs.js} +5 -6
  149. package/lib/interactions/use-remote-api-defs.js.map +1 -0
  150. package/lib/{interact-for-user-identity.js → interactions/user-identity.js} +3 -3
  151. package/lib/interactions/user-identity.js.map +1 -0
  152. package/lib/{interact-for-workspace-id.js → interactions/workspace-id.js} +11 -10
  153. package/lib/interactions/workspace-id.js.map +1 -0
  154. package/lib/memory-prompt.d.ts +32 -0
  155. package/lib/memory-prompt.js +41 -0
  156. package/lib/memory-prompt.js.map +1 -0
  157. package/lib/output/get-output.d.ts +1 -1
  158. package/lib/output/get-output.js +1 -1
  159. package/lib/output/get-output.js.map +1 -1
  160. package/lib/output/{create-memory-output.d.ts → memory-output.d.ts} +1 -1
  161. package/lib/output/{create-memory-output.js → memory-output.js} +2 -2
  162. package/lib/output/memory-output.js.map +1 -0
  163. package/lib/output/{create-output.d.ts → output.d.ts} +18 -1
  164. package/lib/output/output.js +46 -0
  165. package/lib/output/output.js.map +1 -0
  166. package/lib/output/read-stdin-json.js.map +1 -0
  167. package/lib/output/resolve-output-format.d.ts +1 -1
  168. package/lib/{util → output}/with-loading.js +1 -1
  169. package/lib/output/with-loading.js.map +1 -0
  170. package/lib/prompt.d.ts +101 -0
  171. package/lib/{util/prompt.js → prompt.js} +83 -56
  172. package/lib/prompt.js.map +1 -0
  173. package/lib/{completion → render/completion}/describe.js +1 -2
  174. package/lib/render/completion/describe.js.map +1 -0
  175. package/lib/{completion → render/completion}/index.d.ts +2 -2
  176. package/lib/{completion → render/completion}/index.js +1 -2
  177. package/lib/render/completion/index.js.map +1 -0
  178. package/lib/{completion → render/completion}/render-bash.d.ts +1 -1
  179. package/lib/{completion → render/completion}/render-bash.js +1 -1
  180. package/lib/render/completion/render-bash.js.map +1 -0
  181. package/lib/{completion → render/completion}/render-fish.d.ts +1 -1
  182. package/lib/render/completion/render-fish.js.map +1 -0
  183. package/lib/{completion → render/completion}/render-zsh.d.ts +1 -1
  184. package/lib/{completion → render/completion}/render-zsh.js +1 -1
  185. package/lib/render/completion/render-zsh.js.map +1 -0
  186. package/lib/{render-help.d.ts → render/help.d.ts} +1 -1
  187. package/lib/{render-help.js → render/help.js} +2 -2
  188. package/lib/render/help.js.map +1 -0
  189. package/lib/render/text.d.ts +4 -0
  190. package/lib/render/text.js +16 -0
  191. package/lib/render/text.js.map +1 -0
  192. package/lib/version.d.ts +2 -2
  193. package/lib/version.js +2 -2
  194. package/package.json +4 -3
  195. package/src/bin/cli.ts +91 -332
  196. package/src/lib/args/coerce.ts +164 -0
  197. package/src/lib/{util/cli-args.ts → args/parse.ts} +30 -25
  198. package/src/lib/args/validate.ts +73 -0
  199. package/src/lib/auth/operations.ts +169 -0
  200. package/src/lib/{validate-token.ts → auth/validate-token.ts} +2 -2
  201. package/src/lib/blueprint/cache.ts +97 -0
  202. package/src/lib/{get-response-key.ts → blueprint/endpoint.ts} +17 -3
  203. package/src/lib/blueprint/index.ts +27 -0
  204. package/src/lib/{blueprint.ts → blueprint/source-npm.ts} +27 -99
  205. package/src/lib/blueprint/source-remote.ts +17 -0
  206. package/src/lib/commands/api-command.ts +109 -0
  207. package/src/lib/commands/local/completion.ts +51 -0
  208. package/src/lib/commands/local/config-reveal-location.ts +16 -0
  209. package/src/lib/commands/local/config-set-fake-server.ts +21 -0
  210. package/src/lib/commands/local/config-use-remote-api-defs.ts +23 -0
  211. package/src/lib/commands/local/health.ts +22 -0
  212. package/src/lib/commands/local/login.ts +42 -0
  213. package/src/lib/commands/local/logout.ts +18 -0
  214. package/src/lib/commands/local/select-server.ts +30 -0
  215. package/src/lib/commands/local/select-workspace.ts +25 -0
  216. package/src/lib/commands/local/wizard.ts +31 -0
  217. package/src/lib/commands/registry.ts +127 -0
  218. package/src/lib/{command-spec.ts → commands/spec.ts} +30 -131
  219. package/src/lib/config/config-store.ts +39 -64
  220. package/src/lib/config/index.ts +8 -1
  221. package/src/lib/config/memory-config-store.ts +62 -0
  222. package/src/lib/config/migrate.ts +1 -1
  223. package/src/lib/config/values.ts +72 -0
  224. package/src/lib/context.ts +84 -0
  225. package/src/lib/env.ts +9 -2
  226. package/src/lib/errors.ts +67 -0
  227. package/src/lib/http/api.ts +61 -0
  228. package/src/lib/{get-seam.ts → http/client.ts} +19 -18
  229. package/src/lib/http/follow-ups.ts +42 -0
  230. package/src/lib/http/memory-seam-api.ts +57 -0
  231. package/src/lib/http/request.ts +69 -0
  232. package/src/lib/{interact-for-access-code.ts → interactions/access-code.ts} +4 -3
  233. package/src/lib/{interact-for-acs-entrance.ts → interactions/acs-entrance.ts} +3 -2
  234. package/src/lib/{interact-for-acs-system.ts → interactions/acs-system.ts} +3 -2
  235. package/src/lib/{interact-for-acs-user.ts → interactions/acs-user.ts} +4 -3
  236. package/src/lib/{interact-for-action-attempt-poll.ts → interactions/action-attempt-poll.ts} +4 -4
  237. package/src/lib/{interact-for-array.ts → interactions/array.ts} +3 -3
  238. package/src/lib/{interact-for-blueprint-object.ts → interactions/blueprint-object.ts} +57 -24
  239. package/src/lib/{interact-for-command-params.ts → interactions/command-params.ts} +6 -4
  240. package/src/lib/{interact-for-command-selection.ts → interactions/command-selection.ts} +11 -23
  241. package/src/lib/{interact-for-connected-account.ts → interactions/connected-account.ts} +3 -2
  242. package/src/lib/{interact-for-custom-metadata.ts → interactions/custom-metadata.ts} +3 -7
  243. package/src/lib/{interact-for-device.ts → interactions/device.ts} +3 -2
  244. package/src/lib/interactions/index.ts +19 -0
  245. package/src/lib/{interact-for-login.ts → interactions/login.ts} +16 -13
  246. package/src/lib/{interact-for-resource.ts → interactions/resource.ts} +2 -2
  247. package/src/lib/{interact-for-server-selection.ts → interactions/server-selection.ts} +12 -17
  248. package/src/lib/{interact-for-timestamp.ts → interactions/timestamp.ts} +1 -1
  249. package/src/lib/{interact-for-use-remote-api-defs.ts → interactions/use-remote-api-defs.ts} +4 -5
  250. package/src/lib/{interact-for-user-identity.ts → interactions/user-identity.ts} +3 -2
  251. package/src/lib/{interact-for-workspace-id.ts → interactions/workspace-id.ts} +10 -17
  252. package/src/lib/memory-prompt.ts +89 -0
  253. package/src/lib/output/get-output.ts +1 -1
  254. package/src/lib/output/{create-memory-output.ts → memory-output.ts} +1 -1
  255. package/src/lib/output/{create-output.ts → output.ts} +47 -32
  256. package/src/lib/output/resolve-output-format.ts +1 -1
  257. package/src/lib/{util → output}/with-loading.ts +1 -1
  258. package/src/lib/prompt.ts +306 -0
  259. package/src/lib/{completion → render/completion}/describe.ts +1 -2
  260. package/src/lib/{completion → render/completion}/index.ts +3 -4
  261. package/src/lib/{completion → render/completion}/render-bash.ts +1 -1
  262. package/src/lib/{completion → render/completion}/render-fish.ts +2 -1
  263. package/src/lib/{completion → render/completion}/render-zsh.ts +2 -1
  264. package/src/lib/{render-help.ts → render/help.ts} +1 -1
  265. package/src/lib/render/text.ts +17 -0
  266. package/src/lib/version.ts +2 -2
  267. package/lib/blueprint.d.ts +0 -7
  268. package/lib/blueprint.js.map +0 -1
  269. package/lib/command-spec.js.map +0 -1
  270. package/lib/completion/describe.js.map +0 -1
  271. package/lib/completion/index.js.map +0 -1
  272. package/lib/completion/render-bash.js.map +0 -1
  273. package/lib/completion/render-fish.js.map +0 -1
  274. package/lib/completion/render-zsh.js.map +0 -1
  275. package/lib/get-api-blueprint.d.ts +0 -6
  276. package/lib/get-api-blueprint.js +0 -18
  277. package/lib/get-api-blueprint.js.map +0 -1
  278. package/lib/get-command-blueprint-def.d.ts +0 -2
  279. package/lib/get-command-blueprint-def.js +0 -11
  280. package/lib/get-command-blueprint-def.js.map +0 -1
  281. package/lib/get-credentials.d.ts +0 -15
  282. package/lib/get-credentials.js +0 -35
  283. package/lib/get-credentials.js.map +0 -1
  284. package/lib/get-current-workspace-id.d.ts +0 -1
  285. package/lib/get-current-workspace-id.js +0 -9
  286. package/lib/get-current-workspace-id.js.map +0 -1
  287. package/lib/get-response-key.d.ts +0 -9
  288. package/lib/get-response-key.js.map +0 -1
  289. package/lib/get-seam.d.ts +0 -3
  290. package/lib/get-seam.js.map +0 -1
  291. package/lib/get-server.d.ts +0 -6
  292. package/lib/get-server.js +0 -17
  293. package/lib/get-server.js.map +0 -1
  294. package/lib/interact-for-access-code.js.map +0 -1
  295. package/lib/interact-for-acs-entrance.js.map +0 -1
  296. package/lib/interact-for-acs-system.js.map +0 -1
  297. package/lib/interact-for-acs-user.js.map +0 -1
  298. package/lib/interact-for-action-attempt-poll.js.map +0 -1
  299. package/lib/interact-for-array.js.map +0 -1
  300. package/lib/interact-for-blueprint-object.js.map +0 -1
  301. package/lib/interact-for-command-params.js.map +0 -1
  302. package/lib/interact-for-command-selection.d.ts +0 -2
  303. package/lib/interact-for-command-selection.js.map +0 -1
  304. package/lib/interact-for-connected-account.js.map +0 -1
  305. package/lib/interact-for-custom-metadata.js.map +0 -1
  306. package/lib/interact-for-device.js.map +0 -1
  307. package/lib/interact-for-login.js.map +0 -1
  308. package/lib/interact-for-resource.js.map +0 -1
  309. package/lib/interact-for-server-selection.js.map +0 -1
  310. package/lib/interact-for-timestamp.js.map +0 -1
  311. package/lib/interact-for-use-remote-api-defs.js.map +0 -1
  312. package/lib/interact-for-user-identity.js.map +0 -1
  313. package/lib/interact-for-workspace-id.js.map +0 -1
  314. package/lib/output/create-memory-output.js.map +0 -1
  315. package/lib/output/create-output.js +0 -34
  316. package/lib/output/create-output.js.map +0 -1
  317. package/lib/render-help.js.map +0 -1
  318. package/lib/types.d.ts +0 -6
  319. package/lib/types.js +0 -2
  320. package/lib/types.js.map +0 -1
  321. package/lib/util/cli-args.js.map +0 -1
  322. package/lib/util/ellipsis.d.ts +0 -1
  323. package/lib/util/ellipsis.js +0 -6
  324. package/lib/util/ellipsis.js.map +0 -1
  325. package/lib/util/prompt.d.ts +0 -80
  326. package/lib/util/prompt.js.map +0 -1
  327. package/lib/util/read-stdin-json.js.map +0 -1
  328. package/lib/util/request-seam-api.d.ts +0 -7
  329. package/lib/util/request-seam-api.js +0 -26
  330. package/lib/util/request-seam-api.js.map +0 -1
  331. package/lib/util/with-loading.js.map +0 -1
  332. package/lib/validate-token.js.map +0 -1
  333. package/src/lib/get-api-blueprint.ts +0 -31
  334. package/src/lib/get-command-blueprint-def.ts +0 -15
  335. package/src/lib/get-credentials.ts +0 -38
  336. package/src/lib/get-current-workspace-id.ts +0 -9
  337. package/src/lib/get-server.ts +0 -20
  338. package/src/lib/types.ts +0 -7
  339. package/src/lib/util/ellipsis.ts +0 -4
  340. package/src/lib/util/prompt.ts +0 -229
  341. package/src/lib/util/request-seam-api.ts +0 -47
  342. /package/lib/{validate-token.d.ts → auth/validate-token.d.ts} +0 -0
  343. /package/lib/{interact-for-access-code.d.ts → interactions/access-code.d.ts} +0 -0
  344. /package/lib/{interact-for-acs-entrance.d.ts → interactions/acs-entrance.d.ts} +0 -0
  345. /package/lib/{interact-for-acs-system.d.ts → interactions/acs-system.d.ts} +0 -0
  346. /package/lib/{interact-for-acs-user.d.ts → interactions/acs-user.d.ts} +0 -0
  347. /package/lib/{interact-for-action-attempt-poll.d.ts → interactions/action-attempt-poll.d.ts} +0 -0
  348. /package/lib/{interact-for-array.d.ts → interactions/array.d.ts} +0 -0
  349. /package/lib/{interact-for-connected-account.d.ts → interactions/connected-account.d.ts} +0 -0
  350. /package/lib/{interact-for-custom-metadata.d.ts → interactions/custom-metadata.d.ts} +0 -0
  351. /package/lib/{interact-for-device.d.ts → interactions/device.d.ts} +0 -0
  352. /package/lib/{interact-for-login.d.ts → interactions/login.d.ts} +0 -0
  353. /package/lib/{interact-for-resource.d.ts → interactions/resource.d.ts} +0 -0
  354. /package/lib/{interact-for-server-selection.d.ts → interactions/server-selection.d.ts} +0 -0
  355. /package/lib/{interact-for-timestamp.d.ts → interactions/timestamp.d.ts} +0 -0
  356. /package/lib/{interact-for-use-remote-api-defs.d.ts → interactions/use-remote-api-defs.d.ts} +0 -0
  357. /package/lib/{interact-for-user-identity.d.ts → interactions/user-identity.d.ts} +0 -0
  358. /package/lib/{interact-for-workspace-id.d.ts → interactions/workspace-id.d.ts} +0 -0
  359. /package/lib/{util → output}/read-stdin-json.d.ts +0 -0
  360. /package/lib/{util → output}/read-stdin-json.js +0 -0
  361. /package/lib/{util → output}/with-loading.d.ts +0 -0
  362. /package/lib/{completion → render/completion}/describe.d.ts +0 -0
  363. /package/lib/{completion → render/completion}/render-fish.js +0 -0
  364. /package/src/lib/{util → output}/read-stdin-json.ts +0 -0
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Config values as whole trees: merging two trees into one view, and
3
+ * splitting one tree into the settings file and the state file by key.
4
+ * Pure transforms shared by the persistent store and the legacy migration.
5
+ */
6
+ const currentWorkspaceIdKey = 'current_workspace_id';
7
+ const patKey = 'pat';
8
+ /** Whether a key holds auth state rather than a setting. */
9
+ export const isStateKey = (key) => {
10
+ return (key === currentWorkspaceIdKey ||
11
+ key === patKey ||
12
+ key.endsWith(`.${patKey}`));
13
+ };
14
+ export const mergeConfig = (baseConfig, overrideConfig) => {
15
+ const mergedConfig = { ...baseConfig };
16
+ for (const [key, value] of Object.entries(overrideConfig)) {
17
+ const baseValue = mergedConfig[key];
18
+ mergedConfig[key] =
19
+ isRecord(baseValue) && isRecord(value)
20
+ ? mergeConfig(baseValue, value)
21
+ : value;
22
+ }
23
+ return mergedConfig;
24
+ };
25
+ export const splitConfig = (config) => {
26
+ const settings = {};
27
+ const state = {};
28
+ for (const [key, value] of Object.entries(config)) {
29
+ if (isStateKey(key)) {
30
+ state[key] = value;
31
+ continue;
32
+ }
33
+ if (isRecord(value)) {
34
+ const splitValue = splitConfig(value);
35
+ if (Object.keys(splitValue.settings).length > 0) {
36
+ settings[key] = splitValue.settings;
37
+ }
38
+ if (Object.keys(splitValue.state).length > 0) {
39
+ state[key] = splitValue.state;
40
+ }
41
+ continue;
42
+ }
43
+ settings[key] = value;
44
+ }
45
+ return { settings, state };
46
+ };
47
+ const isRecord = (value) => {
48
+ return value != null && typeof value === 'object' && !Array.isArray(value);
49
+ };
50
+ //# sourceMappingURL=values.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"values.js","sourceRoot":"","sources":["../../src/lib/config/values.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,qBAAqB,GAAG,sBAAsB,CAAA;AACpD,MAAM,MAAM,GAAG,K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,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAChD,QAAQ,CAAC,GAAG,CAAC,GAAG,UAAU,CAAC,QAAQ,CAAA;YACrC,CAAC;YAED,IAAI,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC7C,KAAK,CAAC,GAAG,CAAC,GAAG,UAAU,CAAC,KAAK,CAAA;YAC/B,CAAC;YAED,SAAQ;QACV,CAAC;QAED,QAAQ,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;IACvB,CAAC;IAED,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAA;AAC5B,CAAC,CAAA;AAED,MAAM,QAAQ,GAAG,CAAC,KAAc,EAAoC,EAAE;IACpE,OAAO,KAAK,IAAI,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;AAC5E,CAAC,CAAA"}
@@ -0,0 +1,37 @@
1
+ import type { Interactivity } from './args/parse.js';
2
+ import type { ApiBlueprint } from './blueprint/index.js';
3
+ import { type ConfigStore } from './config/index.js';
4
+ import type { SeamApi } from './http/api.js';
5
+ import type { Output } from './output/output.js';
6
+ export declare const defaultServer = "https://connect.getseam.com";
7
+ /** Where a resolved value came from, e.g., to refuse writes the env shadows. */
8
+ export type ValueSource = 'env' | 'config' | 'default';
9
+ /**
10
+ * The server, token, and workspace requests are made with.
11
+ *
12
+ * Resolved in one place so the precedence rule exists once: an environment
13
+ * variable wins over the stored value, and the server falls back to Seam.
14
+ * The source tags say where each value came from.
15
+ */
16
+ export interface AuthContext {
17
+ server: string;
18
+ serverSource: ValueSource;
19
+ token: string | null;
20
+ tokenSource: Exclude<ValueSource, 'default'> | null;
21
+ workspaceId: string | null;
22
+ workspaceIdSource: Exclude<ValueSource, 'default'> | null;
23
+ }
24
+ export declare const resolveAuth: (config?: ConfigStore) => AuthContext;
25
+ /**
26
+ * Everything a command runs with: the stores and auth it reads, the API
27
+ * shape it acts on, and how it may interact with the user.
28
+ */
29
+ export interface CliContext {
30
+ config: ConfigStore;
31
+ auth: AuthContext;
32
+ output: Output;
33
+ blueprint: ApiBlueprint;
34
+ interactivity: Interactivity;
35
+ /** The Seam API, constructed on first use and shared for the run. */
36
+ api: () => Promise<SeamApi>;
37
+ }
package/lib/context.js ADDED
@@ -0,0 +1,31 @@
1
+ import { getConfigStore } from './config/index.js';
2
+ import { getEndpointFromEnv, getTokenFromEnv, getWorkspaceIdFromEnv, } from './env.js';
3
+ export const defaultServer = 'https://connect.getseam.com';
4
+ export const resolveAuth = (config = getConfigStore()) => {
5
+ const envServer = getEndpointFromEnv();
6
+ const storedServer = config.get('server');
7
+ const server = envServer ?? (typeof storedServer === 'string' ? storedServer : null);
8
+ const envToken = getTokenFromEnv();
9
+ const storedToken = readString(config.get(`${server ?? defaultServer}.pat`));
10
+ const envWorkspaceId = getWorkspaceIdFromEnv();
11
+ const storedWorkspaceId = readString(config.get('current_workspace_id'));
12
+ return {
13
+ server: server ?? defaultServer,
14
+ serverSource: envServer != null ? 'env' : server != null ? 'config' : 'default',
15
+ token: envToken ?? storedToken,
16
+ tokenSource: envToken != null ? 'env' : storedToken != null ? 'config' : null,
17
+ workspaceId: envWorkspaceId ?? storedWorkspaceId,
18
+ workspaceIdSource: envWorkspaceId != null
19
+ ? 'env'
20
+ : storedWorkspaceId != null
21
+ ? 'config'
22
+ : null,
23
+ };
24
+ };
25
+ const readString = (value) => {
26
+ if (typeof value !== 'string')
27
+ return null;
28
+ const trimmedValue = value.trim();
29
+ return trimmedValue === '' ? null : trimmedValue;
30
+ };
31
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../src/lib/context.ts"],"names":[],"mappings":"AAEA,OAAO,EAAoB,cAAc,EAAE,MAAM,mBAAmB,CAAA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AAI,IAAI;gBACzB,CAAC,CAAC,QAAQ;gBACV,CAAC,CAAC,IAAI;KACb,CAAA;AACH,CAAC,CAAA;AAgBD,MAAM,UAAU,GAAG,CAAC,KAAc,EAAiB,EAAE;IACnD,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAA;IAE1C,MAAM,YAAY,GAAG,KAAK,CAAC,IAAI,EAAE,CAAA;IAEjC,OAAO,YAAY,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,YAAY,CAAA;AAClD,CAAC,CAAA"}
package/lib/env.d.ts CHANGED
@@ -27,3 +27,8 @@ export declare class EnvVarOverrideError extends Error {
27
27
  * @param action What the command does, e.g., `log in`.
28
28
  */
29
29
  export declare const assertEnvVarUnset: (envVar: string, envValue: string | null, action: string) => void;
30
+ /**
31
+ * Whether the CLI runs inside a hosted web terminal, where it cannot open
32
+ * anything in a browser of its own.
33
+ */
34
+ export declare const isInsideWebBrowser: () => boolean;
package/lib/env.js CHANGED
@@ -31,6 +31,11 @@ export const assertEnvVarUnset = (envVar, envValue, action) => {
31
31
  return;
32
32
  throw new EnvVarOverrideError(`Cannot ${action} while ${envVar} is set: it overrides what would be stored. Unset ${envVar} to ${action}.`);
33
33
  };
34
+ /**
35
+ * Whether the CLI runs inside a hosted web terminal, where it cannot open
36
+ * anything in a browser of its own.
37
+ */
38
+ export const isInsideWebBrowser = () => process.env['INSIDE_WEB_BROWSER'] === '1';
34
39
  const readEnvVar = (envVar) => {
35
40
  const value = process.env[envVar];
36
41
  if (value == null)
package/lib/env.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"env.js","sourceRoot":"","sources":["../src/lib/env.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,kDAAkD;AAClD,MAAM,CAAC,MAAM,WAAW,GAAG,gBAAgB,CAAA;AAE3C,iEAAiE;AACjE,MAAM,CAAC,MAAM,iBAAiB,GAAG,uBAAuB,CAAA;AAExD,2DA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ot prompt for.
4
+ */
5
+ export declare class NonInteractiveError extends Error {
6
+ name: string;
7
+ }
8
+ /**
9
+ * Thrown when the user dismisses a prompt with ctrl-c or escape instead of
10
+ * answering it.
11
+ */
12
+ export declare class PromptCancelledError extends Error {
13
+ constructor();
14
+ }
15
+ /**
16
+ * Thrown when the arguments do not name something the CLI can run.
17
+ */
18
+ export declare class UsageError extends Error {
19
+ name: string;
20
+ /** What to run instead, reported after the message. */
21
+ readonly hint: string;
22
+ constructor(message: string, { hint }?: {
23
+ hint?: string;
24
+ });
25
+ }
26
+ /**
27
+ * Report a failure and set the exit code: usage mistakes read as one line
28
+ * with a hint, environment overrides without a stack trace, and anything
29
+ * else as an unexpected CLI error.
30
+ */
31
+ export declare const reportErrorAndExit: (e: unknown, output: Output) => void;
package/lib/errors.js ADDED
@@ -0,0 +1,58 @@
1
+ import chalk from 'chalk';
2
+ import { EnvVarOverrideError } from './env.js';
3
+ /**
4
+ * Thrown when the CLI needs input it cannot prompt for.
5
+ */
6
+ export class NonInteractiveError extends Error {
7
+ name = 'NonInteractiveError';
8
+ }
9
+ /**
10
+ * Thrown when the user dismisses a prompt with ctrl-c or escape instead of
11
+ * answering it.
12
+ */
13
+ export class PromptCancelledError extends Error {
14
+ constructor() {
15
+ super('Cancelled');
16
+ }
17
+ }
18
+ /**
19
+ * Thrown when the arguments do not name something the CLI can run.
20
+ */
21
+ export class UsageError extends Error {
22
+ name = 'UsageError';
23
+ /** What to run instead, reported after the message. */
24
+ hint;
25
+ constructor(message, { hint = '' } = {}) {
26
+ super(message);
27
+ this.hint = hint;
28
+ }
29
+ }
30
+ /**
31
+ * Report a failure and set the exit code: usage mistakes read as one line
32
+ * with a hint, environment overrides without a stack trace, and anything
33
+ * else as an unexpected CLI error.
34
+ */
35
+ export const reportErrorAndExit = (e, output) => {
36
+ process.exitCode = 1;
37
+ if (e instanceof UsageError) {
38
+ output.error(chalk.red(e.message));
39
+ if (e.hint !== '')
40
+ output.error(e.hint);
41
+ return;
42
+ }
43
+ if (e instanceof NonInteractiveError || e instanceof EnvVarOverrideError) {
44
+ output.error(chalk.red(e.message));
45
+ return;
46
+ }
47
+ // Dismissing a prompt is the user stopping the CLI, not the CLI failing:
48
+ // note it quietly, without the alarm of an error.
49
+ if (e instanceof PromptCancelledError) {
50
+ output.error(chalk.gray(e.message));
51
+ return;
52
+ }
53
+ const error = e instanceof Error ? e : new Error(String(e));
54
+ output.error(chalk.red(`CLI Error: ${error.message}`));
55
+ if (error.stack != null)
56
+ output.error(chalk.gray(error.stack));
57
+ };
58
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/lib/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAA;AAG9C;;GAEG;AACH,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IACnC,IAAI,GAAG,qBAAqB,CAAA;CACtC;AAED;;;GAGG;AACH,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IAC7C;QACE,KAAK,CAAC,WAAW,CAAC,CAAA;IACpB,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,UAAW,SAAQ,KAAK;IAC1B,IAAI,GAAG,YAAY,CAAA;IAE5B,uDAAuD;IAC9C,IAAI,CAAQ;IAErB,YAAY,OAAe,EAAE,EAAE,IAAI,GAAG,EAAE,KAAwB,EAAE;QAChE,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IAClB,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAU,EAAE,MAAc,EAAQ,EAAE;IACrE,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAA;IAEpB,IAAI,CAAC,YAAY,UAAU,EAAE,CAAC;QAC5B,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAA;QAClC,IAAI,CAAC,CAAC,IAAI,KAAK,EAAE;YAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA;QACvC,OAAM;IACR,CAAC;IAED,IAAI,CAAC,YAAY,mBAAmB,IAAI,CAAC,YAAY,mBAAmB,EAAE,CAAC;QACzE,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAA;QAClC,OAAM;IACR,CAAC;IAED,yEAAyE;IACzE,kDAAkD;IAClD,IAAI,CAAC,YAAY,oBAAoB,EAAE,CAAC;QACtC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAA;QACnC,OAAM;IACR,CAAC;IAED,MAAM,KAAK,GAAG,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAA;IAC3D,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,cAAc,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAA;IACtD,IAAI,KAAK,CAAC,KAAK,IAAI,IAAI;QAAE,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAA;AAChE,CAAC,CAAA"}
@@ -0,0 +1,37 @@
1
+ import { type SeamHttp } from '@seamapi/http/connect';
2
+ import type { AuthContext } from '../context.js';
3
+ export interface ApiRequestOptions {
4
+ path: string;
5
+ params: Record<string, unknown>;
6
+ /** Response key documented for the endpoint, e.g., `devices`. */
7
+ responseKey?: string | null | undefined;
8
+ }
9
+ /**
10
+ * A prepared call to the Seam API: inspectable before it is sent, e.g., to
11
+ * report the URL, then sent with {@link SeamApiRequest.fetchResponse}.
12
+ *
13
+ * The real implementation is the SDK's own `SeamHttpRequest`; sending one
14
+ * rejects with a `SeamHttpApiError` when the API reports an error.
15
+ */
16
+ export interface SeamApiRequest {
17
+ readonly url: URL;
18
+ readonly method: string;
19
+ readonly body: unknown;
20
+ /** Send the request and return the full response body. */
21
+ fetchResponse: () => Promise<unknown>;
22
+ }
23
+ /**
24
+ * How the blueprint-driven CLI reaches the Seam API: prepare a request for
25
+ * an endpoint path. Tests fake at this port with `createMemorySeamApi()` —
26
+ * the in-process mirror of the e2e suite's HTTP server.
27
+ */
28
+ export interface SeamApi {
29
+ createRequest: (options: ApiRequestOptions) => SeamApiRequest;
30
+ }
31
+ /** The only place `SeamHttp` appears for raw requests. */
32
+ export declare class HttpSeamApi implements SeamApi {
33
+ private readonly seam;
34
+ constructor(seam: SeamHttp);
35
+ createRequest: ({ path, params, responseKey, }: ApiRequestOptions) => SeamApiRequest;
36
+ }
37
+ export declare const createSeamApi: (auth?: AuthContext) => Promise<SeamApi>;
@@ -0,0 +1,20 @@
1
+ import { SeamHttpRequest } from '@seamapi/http/connect';
2
+ import { getSeam } from './client.js';
3
+ /** The only place `SeamHttp` appears for raw requests. */
4
+ export class HttpSeamApi {
5
+ seam;
6
+ constructor(seam) {
7
+ this.seam = seam;
8
+ }
9
+ createRequest = ({ path, params, responseKey, }) => new SeamHttpRequest(this.seam, {
10
+ pathname: path,
11
+ method: 'POST',
12
+ body: params,
13
+ responseKey: responseKey ?? undefined,
14
+ });
15
+ }
16
+ export const createSeamApi = async (auth) => {
17
+ const seam = await getSeam(auth);
18
+ return new HttpSeamApi(seam);
19
+ };
20
+ //# sourceMappingURL=api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/lib/http/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAItE,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAiCrC,0DAA0D;AAC1D,MAAM,OAAO,WAAW;IACO;IAA7B,YAA6B,IAAc;QAAd,SAAI,GAAJ,IAAI,CAAU;IAAG,CAAC;IAE/C,aAAa,GAAG,CAAC,EACf,IAAI,EACJ,MAAM,EACN,WAAW,GACO,EAAkB,EAAE,CACtC,IAAI,eAAe,CACjB,IAAI,CAAC,IAAI,EACT;QACE,QAAQ,EAAE,IAAI;QACd,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,MAAM;QACZ,WAAW,EAAE,WAAW,IAAI,SAAS;KACtC,CACF,CAAA;CACJ;AAED,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,EAAE,IAAkB,EAAoB,EAAE;IAC1E,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;IAChC,OAAO,IAAI,WAAW,CAAC,IAAI,CAAC,CAAA;AAC9B,CAAC,CAAA"}
@@ -0,0 +1,4 @@
1
+ import { SeamHttp, SeamHttpWithoutWorkspace } from '@seamapi/http/connect';
2
+ import { type AuthContext } from '../context.js';
3
+ export declare const getSeam: (auth?: AuthContext) => Promise<SeamHttp>;
4
+ export declare const getSeamMultiWorkspace: (auth?: AuthContext) => Promise<SeamHttpWithoutWorkspace | SeamHttp>;
@@ -1,38 +1,37 @@
1
1
  import { isConsoleSessionToken, isPersonalAccessToken, SeamHttp, SeamHttpWithoutWorkspace, } from '@seamapi/http/connect';
2
- import { tokenEnvVar, workspaceIdEnvVar } from './env.js';
3
- import { getToken, getWorkspaceId } from './get-credentials.js';
4
- import { getServer } from './get-server.js';
5
- export const getSeam = async () => {
6
- const token = getRequiredToken();
7
- const options = { endpoint: getServer() };
2
+ import { resolveAuth } from '../context.js';
3
+ import { tokenEnvVar, workspaceIdEnvVar } from '../env.js';
4
+ export const getSeam = async (auth = resolveAuth()) => {
5
+ const token = getRequiredToken(auth);
6
+ const options = { endpoint: auth.server };
8
7
  if (isPersonalAccessToken(token)) {
9
- return SeamHttp.fromPersonalAccessToken(token, getRequiredWorkspaceId(), options);
8
+ return SeamHttp.fromPersonalAccessToken(token, getRequiredWorkspaceId(auth), options);
10
9
  }
11
10
  if (isConsoleSessionToken(token)) {
12
- return SeamHttp.fromConsoleSessionToken(token, getRequiredWorkspaceId(), options);
11
+ return SeamHttp.fromConsoleSessionToken(token, getRequiredWorkspaceId(auth), options);
13
12
  }
14
13
  return SeamHttp.fromApiKey(token, options);
15
14
  };
16
- export const getSeamMultiWorkspace = async () => {
17
- const token = getRequiredToken();
18
- const options = { endpoint: getServer() };
15
+ export const getSeamMultiWorkspace = async (auth = resolveAuth()) => {
16
+ const token = getRequiredToken(auth);
17
+ const options = { endpoint: auth.server };
19
18
  if (isPersonalAccessToken(token)) {
20
19
  return SeamHttpWithoutWorkspace.fromPersonalAccessToken(token, options);
21
20
  }
22
- return await getSeam();
21
+ return await getSeam(auth);
23
22
  };
24
- const getRequiredToken = () => {
25
- const token = getToken();
23
+ const getRequiredToken = (auth) => {
24
+ const { token } = auth;
26
25
  if (token == null) {
27
26
  throw new Error(`Not logged in: run "seam login" or set the ${tokenEnvVar} environment variable`);
28
27
  }
29
28
  return token;
30
29
  };
31
- const getRequiredWorkspaceId = () => {
32
- const workspaceId = getWorkspaceId();
30
+ const getRequiredWorkspaceId = (auth) => {
31
+ const { workspaceId } = auth;
33
32
  if (workspaceId == null) {
34
33
  throw new Error(`No workspace selected: run "seam select workspace" or set the ${workspaceIdEnvVar} environment variable`);
35
34
  }
36
35
  return workspaceId;
37
36
  };
38
- //# sourceMappingURL=get-seam.js.map
37
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/lib/http/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,QAAQ,EACR,wBAAwB,GACzB,MAAM,uBAAuB,CAAA;AAE9B,OAAO,EAAoB,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC9D,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,YAA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B,CACjF,CAAA;IACH,CAAC;IAED,OAAO,KAAK,CAAA;AACd,CAAC,CAAA;AAED,MAAM,sBAAsB,GAAG,CAAC,IAAiB,EAAU,EAAE;IAC3D,MAAM,EAAE,WAAW,EAAE,GAAG,IAAI,CAAA;IAE5B,IAAI,WAAW,IAAI,IAAI,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CACb,iEAAiE,iBAAiB,uBAAuB,CAC1G,CAAA;IACH,CAAC;IAED,OAAO,WAAW,CAAA;AACpB,CAAC,CAAA"}
@@ -0,0 +1,6 @@
1
+ import type { CliContext } from '../context.js';
2
+ /**
3
+ * Follow-ups a response may call for: opening a connect webview in the
4
+ * browser, and offering to poll a pending action attempt.
5
+ */
6
+ export declare const runResponseFollowUps: (data: any, ctx: CliContext) => Promise<void>;
@@ -0,0 +1,30 @@
1
+ import { isInsideWebBrowser } from '../env.js';
2
+ import { interactForActionAttemptPoll } from '../interactions/index.js';
3
+ import { promptConfirm } from '../prompt.js';
4
+ /**
5
+ * Follow-ups a response may call for: opening a connect webview in the
6
+ * browser, and offering to poll a pending action attempt.
7
+ */
8
+ export const runResponseFollowUps = async (data, ctx) => {
9
+ const isNonInteractive = ctx.interactivity === 'non-interactive';
10
+ if (data?.connect_webview) {
11
+ await handleConnectWebview(data.connect_webview, isNonInteractive);
12
+ }
13
+ if (data?.action_attempt && !isNonInteractive) {
14
+ await interactForActionAttemptPoll(data.action_attempt);
15
+ }
16
+ };
17
+ const handleConnectWebview = async (connectWebview, isNonInteractive) => {
18
+ const url = connectWebview.url;
19
+ if (!isNonInteractive && !isInsideWebBrowser()) {
20
+ const action = await promptConfirm({
21
+ message: 'Would you like to open the webview in your browser?',
22
+ initialValue: false,
23
+ });
24
+ if (action) {
25
+ const { default: open } = await import('open');
26
+ await open(url);
27
+ }
28
+ }
29
+ };
30
+ //# sourceMappingURL=follow-ups.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"follow-ups.js","sourceRoot":"","sources":["../../src/lib/http/follow-ups.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAC/C,OAAO,EAAE,4BAA4B,EAAE,MAAM,2BAA2B,CAAA;AACxE,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAE7C;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,EACvC,IAAS,EACT,GAAe,EACA,EAAE;IACjB,MAAM,gBAAgB,GAAG,GAAG,CAAC,aAAa,KAAK,iBAAiB,CAAA;IAEhE,IAAI,IAAI,EAAE,eAAe,EAAE,CAAC;QAC1B,MAAM,oBAAoB,CAAC,IAAI,CAAC,eAAe,EAAE,gBAAgB,CAAC,CAAA;IACpE,CAAC;IAED,IAAI,IAAI,EAAE,cAAc,IAAI,CAAC,gBAAgB,EAAE,CAAC;QAC9C,MAAM,4BAA4B,CAAC,IAAI,CAAC,cAAc,CAAC,CAAA;IACzD,CAAC;AACH,CAAC,CAAA;AAED,MAAM,oBAAoB,GAAG,KAAK,EAChC,cAAmB,EACnB,gBAAyB,EACV,EAAE;IACjB,MAAM,GAAG,GAAG,cAAc,CAAC,GAAG,CAAA;IAE9B,IAAI,CAAC,gBAAgB,IAAI,CAAC,kBAAkB,EAAE,EAAE,CAAC;QAC/C,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC;YACjC,OAAO,EAAE,qDAAqD;YAC9D,YAAY,EAAE,KAAK;SACpB,CAAC,CAAA;QAEF,IAAI,MAAM,EAAE,CAAC;YACX,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,CAAA;YAC9C,MAAM,IAAI,CAAC,GAAG,CAAC,CAAA;QACjB,CAAC;IACH,CAAC;AACH,CAAC,CAAA"}
@@ -0,0 +1,22 @@
1
+ import type { ApiRequestOptions, SeamApi, SeamApiRequest } from './api.js';
2
+ export interface MemorySeamApiResponse {
3
+ status: number;
4
+ data: unknown;
5
+ }
6
+ /**
7
+ * A real {@link SeamApi} answering from a routes table and recording every
8
+ * request, for tests: the in-process mirror of the e2e suite's HTTP server.
9
+ * Error statuses reject with the SDK's own error classes, exactly as the
10
+ * real transport does.
11
+ */
12
+ export declare class MemorySeamApi implements SeamApi {
13
+ private readonly routes;
14
+ /** Every request sent, in order — assert on the outbound messages. */
15
+ readonly requests: Array<{
16
+ path: string;
17
+ params: Record<string, unknown>;
18
+ }>;
19
+ constructor(routes: Record<string, MemorySeamApiResponse>);
20
+ createRequest: ({ path, params }: ApiRequestOptions) => SeamApiRequest;
21
+ }
22
+ export declare const createMemorySeamApi: (routes: Record<string, MemorySeamApiResponse>) => MemorySeamApi;
@@ -0,0 +1,41 @@
1
+ import { SeamHttpApiError, SeamHttpInvalidInputError, } from '@seamapi/http/connect';
2
+ /**
3
+ * A real {@link SeamApi} answering from a routes table and recording every
4
+ * request, for tests: the in-process mirror of the e2e suite's HTTP server.
5
+ * Error statuses reject with the SDK's own error classes, exactly as the
6
+ * real transport does.
7
+ */
8
+ export class MemorySeamApi {
9
+ routes;
10
+ /** Every request sent, in order — assert on the outbound messages. */
11
+ requests = [];
12
+ constructor(routes) {
13
+ this.routes = routes;
14
+ }
15
+ createRequest = ({ path, params }) => ({
16
+ url: new URL(`https://memory.seam.example${path}`),
17
+ method: 'POST',
18
+ body: params,
19
+ fetchResponse: async () => {
20
+ this.requests.push({ path, params });
21
+ const route = this.routes[path] ?? {
22
+ status: 404,
23
+ data: { error: { type: 'not_found', message: 'Not Found' } },
24
+ };
25
+ if (route.status >= 400) {
26
+ throw toSeamHttpError(route);
27
+ }
28
+ return route.data;
29
+ },
30
+ });
31
+ }
32
+ const toSeamHttpError = (route) => {
33
+ const error = route.data
34
+ .error;
35
+ if (error.type === 'invalid_input') {
36
+ return new SeamHttpInvalidInputError(error, route.status, 'request_memory');
37
+ }
38
+ return new SeamHttpApiError(error, route.status, 'request_memory');
39
+ };
40
+ export const createMemorySeamApi = (routes) => new MemorySeamApi(routes);
41
+ //# sourceMappingURL=memory-seam-api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory-seam-api.js","sourceRoot":"","sources":["../../src/lib/http/memory-seam-api.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,yBAAyB,GAC1B,MAAM,uBAAuB,CAAA;AAS9B;;;;;GAKG;AACH,MAAM,OAAO,aAAa;IAKK;IAJ7B,sEAAsE;IAC7D,QAAQ,GACf,EAAE,CAAA;IAEJ,YAA6B,MAA6C;QAA7C,WAAM,GAAN,MAAM,CAAuC;IAAG,CAAC;IAE9E,aAAa,GAAG,CAAC,EAAE,IAAI,EAAE,MAAM,EAAqB,EAAkB,EAAE,CAAC,CAAC;QACxE,GAAG,EAAE,IAAI,GAAG,CAAC,8BAA8B,IAAI,EAAE,CAAC;QAClD,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,MAAM;QACZ,aAAa,EAAE,KAAK,IAAI,EAAE;YACxB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAA;YAEpC,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI;gBACjC,MAAM,EAAE,GAAG;gBACX,IAAI,EAAE,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,WAAW,EAAE,EAAE;aAC7D,CAAA;YAED,IAAI,KAAK,CAAC,MAAM,IAAI,GAAG,EAAE,CAAC;gBACxB,MAAM,eAAe,CAAC,KAAK,CAAC,CAAA;YAC9B,CAAC;YACD,OAAO,KAAK,CAAC,IAAI,CAAA;QACnB,CAAC;KACF,CAAC,CAAA;CACH;AAED,MAAM,eAAe,GAAG,CAAC,KAA4B,EAAoB,EAAE;IACzE,MAAM,KAAK,GAAI,KAAK,CAAC,IAAqD;SACvE,KAAK,CAAA;IACR,IAAI,KAAK,CAAC,IAAI,KAAK,eAAe,EAAE,CAAC;QACnC,OAAO,IAAI,yBAAyB,CAAC,KAAK,EAAE,KAAK,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAA;IAC7E,CAAC;IACD,OAAO,IAAI,gBAAgB,CAAC,KAAK,EAAE,KAAK,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAA;AACpE,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,mBAAmB,GAAG,CACjC,MAA6C,EAC9B,EAAE,CAAC,IAAI,aAAa,CAAC,MAAM,CAAC,CAAA"}
@@ -0,0 +1,19 @@
1
+ import type { Output } from '../output/output.js';
2
+ import type { SeamApi } from './api.js';
3
+ export interface RequestSeamApiOptions {
4
+ path: string;
5
+ params: Record<string, any>;
6
+ /** Response key for the endpoint, used to trim the reported payload. */
7
+ responseKey?: string | null | undefined;
8
+ }
9
+ export interface RequestSeamApiDependencies {
10
+ api: SeamApi;
11
+ output: Output;
12
+ }
13
+ /**
14
+ * Make a request and report the result: the request URL and params go to
15
+ * stderr, the trimmed payload to stdout. An API error reports its status
16
+ * and payload and sets the exit code. Returns the response body, or `null`
17
+ * when the API reported an error.
18
+ */
19
+ export declare const requestSeamApi: (options: RequestSeamApiOptions, { api, output }: RequestSeamApiDependencies) => Promise<unknown>;
@@ -0,0 +1,39 @@
1
+ import { isSeamHttpApiError, } from '@seamapi/http/connect';
2
+ import chalk from 'chalk';
3
+ import { selectResponsePayload } from '../output/select-response-payload.js';
4
+ import { withLoading } from '../output/with-loading.js';
5
+ /**
6
+ * Make a request and report the result: the request URL and params go to
7
+ * stderr, the trimmed payload to stdout. An API error reports its status
8
+ * and payload and sets the exit code. Returns the response body, or `null`
9
+ * when the API reported an error.
10
+ */
11
+ export const requestSeamApi = async (options, { api, output }) => {
12
+ const request = api.createRequest(options);
13
+ output.info(`\n${chalk.green(request.url.toString())}`);
14
+ output.info(`Request Params:`);
15
+ output.info(formatParams(options.params));
16
+ let body;
17
+ try {
18
+ body = await withLoading('Making request...', async () => {
19
+ return await request.fetchResponse();
20
+ });
21
+ }
22
+ catch (error) {
23
+ if (!isSeamHttpApiError(error))
24
+ throw error;
25
+ output.warn(chalk.red(`[${error.statusCode}]`));
26
+ process.exitCode = 1;
27
+ output.data({ error: toErrorPayload(error) });
28
+ return null;
29
+ }
30
+ output.data(selectResponsePayload(body, { responseKey: options.responseKey }));
31
+ return body;
32
+ };
33
+ const toErrorPayload = (error) => ({
34
+ type: error.code,
35
+ message: error.message,
36
+ ...(error.data === undefined ? {} : { data: error.data }),
37
+ });
38
+ const formatParams = (params) => JSON.stringify(params, null, 2);
39
+ //# sourceMappingURL=request.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request.js","sourceRoot":"","sources":["../../src/lib/http/request.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,GAEnB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAA;AAC7E,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AAgBxD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,EACjC,OAA8B,EAC9B,EAAE,GAAG,EAAE,MAAM,EAA8B,EACzB,EAAE;IACpB,MAAM,OAAO,GAAG,GAAG,CAAC,aAAa,CAAC,OAAO,CAAC,CAAA;IAE1C,MAAM,CAAC,IAAI,CAAC,KAAK,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,EAAE,CAAC,CAAA;IACvD,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAA;IAC9B,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAA;IAEzC,IAAI,IAAa,CAAA;IACjB,IAAI,CAAC;QACH,IAAI,GAAG,MAAM,WAAW,CAAC,mBAAmB,EAAE,KAAK,IAAI,EAAE;YACvD,OAAO,MAAM,OAAO,CAAC,aAAa,EAAE,CAAA;QACtC,CAAC,CAAC,CAAA;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC;YAAE,MAAM,KAAK,CAAA;QAE3C,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,UAAU,GAAG,CAAC,CAAC,CAAA;QAC/C,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAA;QACpB,MAAM,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,cAAc,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;QAC7C,OAAO,IAAI,CAAA;IACb,CAAC;IAED,MAAM,CAAC,IAAI,CAAC,qBAAqB,CAAC,IAAI,EAAE,EAAE,WAAW,EAAE,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC,CAAA;IAE9E,OAAO,IAAI,CAAA;AACb,CAAC,CAAA;AAED,MAAM,cAAc,GAAG,CACrB,KAAuB,EAC4B,EAAE,CAAC,CAAC;IACvD,IAAI,EAAE,KAAK,CAAC,IAAI;IAChB,OAAO,EAAE,KAAK,CAAC,OAAO;IACtB,GAAG,CAAC,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC;CAC1D,CAAC,CAAA;AAEF,MAAM,YAAY,GAAG,CAAC,MAA2B,EAAU,EAAE,CAC3D,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA"}
@@ -1,6 +1,6 @@
1
- import { getSeam } from './get-seam.js';
2
- import { interactForDevice } from './interact-for-device.js';
3
- import { interactForResource } from './interact-for-resource.js';
1
+ import { getSeam } from '../http/client.js';
2
+ import { interactForDevice } from './device.js';
3
+ import { interactForResource } from './resource.js';
4
4
  export const interactForAccessCode = async ({
5
5
  // The key is a Seam API parameter name: callers pass the blueprint params
6
6
  // bag through as-is, so only the binding may be camelCase.
@@ -19,4 +19,4 @@ device_id: deviceId, }) => {
19
19
  }),
20
20
  });
21
21
  };
22
- //# sourceMappingURL=interact-for-access-code.js.map
22
+ //# sourceMappingURL=access-code.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"access-code.js","sourceRoot":"","sources":["../../src/lib/interactions/access-code.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAE5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AAEnD,MAAM,CAAC,MAAM,qBAAqB,GAAG,KAAK,EAAE;AAC1C,0EAA0E;AAC1E,2DAA2D;AAC3D,SAAS,EAAE,QAAQ,GAGpB,EAAE,EAAE;IACH,MAAM,IAAI,GAAG,MAAM,OAAO,EAAE,CAAA;IAE5B,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,QAAQ,GAAG,MAAM,iBAAiB,EAAE,CAAA;IACtC,CAAC;IAED,OAAO,mBAAmB,CAAC;QACzB,YAAY,EAAE,aAAa;QAC3B,cAAc,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC;QACpE,QAAQ,EAAE,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;YACzB,KAAK,EAAE,UAAU,CAAC,IAAI,IAAI,WAAW;YACrC,KAAK,EAAE,UAAU,CAAC,cAAc;YAChC,WAAW,EAAE,GAAG,UAAU,CAAC,IAAI,IAAI,UAAU,CAAC,cAAc,EAAE;SAC/D,CAAC;KACH,CAAC,CAAA;AACJ,CAAC,CAAA"}
@@ -1,5 +1,5 @@
1
- import { getSeam } from './get-seam.js';
2
- import { interactForResource } from './interact-for-resource.js';
1
+ import { getSeam } from '../http/client.js';
2
+ import { interactForResource } from './resource.js';
3
3
  export const interactForAcsEntrance = async () => {
4
4
  const seam = await getSeam();
5
5
  return interactForResource({
@@ -12,4 +12,4 @@ export const interactForAcsEntrance = async () => {
12
12
  }),
13
13
  });
14
14
  };
15
- //# sourceMappingURL=interact-for-acs-entrance.js.map
15
+ //# sourceMappingURL=acs-entrance.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"acs-entrance.js","sourceRoot":"","sources":["../../src/lib/interactions/acs-entrance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAE5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AAEnD,MAAM,CAAC,MAAM,sBAAsB,GAAG,KAAK,IAAI,EAAE;IAC/C,MAAM,IAAI,GAAG,MAAM,OAAO,EAAE,CAAA;IAE5B,OAAO,mBAAmB,CAAC;QACzB,YAAY,EAAE,cAAc;QAC5B,cAAc,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,EAAE;QAC/C,QAAQ,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;YACvB,KAAK,EAAE,QAAQ,CAAC,YAAY,IAAI,WAAW;YAC3C,KAAK,EAAE,QAAQ,CAAC,eAAe;YAC/B,WAAW,EAAE,QAAQ,CAAC,eAAe;SACtC,CAAC;KACH,CAAC,CAAA;AACJ,CAAC,CAAA"}
@@ -1,5 +1,5 @@
1
- import { getSeam } from './get-seam.js';
2
- import { interactForResource } from './interact-for-resource.js';
1
+ import { getSeam } from '../http/client.js';
2
+ import { interactForResource } from './resource.js';
3
3
  export const interactForAcsSystem = async (message) => {
4
4
  const seam = await getSeam();
5
5
  return interactForResource({
@@ -13,4 +13,4 @@ export const interactForAcsSystem = async (message) => {
13
13
  }),
14
14
  });
15
15
  };
16
- //# sourceMappingURL=interact-for-acs-system.js.map
16
+ //# sourceMappingURL=acs-system.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"acs-system.js","sourceRoot":"","sources":["../../src/lib/interactions/acs-system.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAE5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AAEnD,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,EAAE,OAAgB,EAAE,EAAE;IAC7D,MAAM,IAAI,GAAG,MAAM,OAAO,EAAE,CAAA;IAE5B,OAAO,mBAAmB,CAAC;QACzB,YAAY,EAAE,YAAY;QAC1B,cAAc,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE;QAC7C,OAAO;QACP,QAAQ,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;YACrB,KAAK,EAAE,GAAG,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,0BAA0B,EAAE;YAC5D,KAAK,EAAE,MAAM,CAAC,aAAa;YAC3B,WAAW,EAAE,MAAM,CAAC,aAAa;SAClC,CAAC;KACH,CAAC,CAAA;AACJ,CAAC,CAAA"}