@seamapi/cli 0.18.2 → 0.20.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 (363) hide show
  1. package/README.md +4 -4
  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 +122 -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-use-remote-api-defs.d.ts +2 -0
  43. package/lib/commands/local/config-use-remote-api-defs.js +20 -0
  44. package/lib/commands/local/config-use-remote-api-defs.js.map +1 -0
  45. package/lib/commands/local/health.d.ts +2 -0
  46. package/lib/commands/local/health.js +18 -0
  47. package/lib/commands/local/health.js.map +1 -0
  48. package/lib/commands/local/login.d.ts +2 -0
  49. package/lib/commands/local/login.js +35 -0
  50. package/lib/commands/local/login.js.map +1 -0
  51. package/lib/commands/local/logout.d.ts +2 -0
  52. package/lib/commands/local/logout.js +17 -0
  53. package/lib/commands/local/logout.js.map +1 -0
  54. package/lib/commands/local/select-endpoint.d.ts +2 -0
  55. package/lib/commands/local/select-endpoint.js +27 -0
  56. package/lib/commands/local/select-endpoint.js.map +1 -0
  57. package/lib/commands/local/select-workspace.d.ts +2 -0
  58. package/lib/commands/local/select-workspace.js +22 -0
  59. package/lib/commands/local/select-workspace.js.map +1 -0
  60. package/lib/commands/local/wizard.d.ts +9 -0
  61. package/lib/commands/local/wizard.js +28 -0
  62. package/lib/commands/local/wizard.js.map +1 -0
  63. package/lib/commands/registry.d.ts +54 -0
  64. package/lib/commands/registry.js +62 -0
  65. package/lib/commands/registry.js.map +1 -0
  66. package/lib/{command-spec.d.ts → commands/spec.d.ts} +8 -12
  67. package/lib/{command-spec.js → commands/spec.js} +27 -120
  68. package/lib/commands/spec.js.map +1 -0
  69. package/lib/config/config-store.d.ts +23 -8
  70. package/lib/config/config-store.js +16 -42
  71. package/lib/config/config-store.js.map +1 -1
  72. package/lib/config/index.d.ts +2 -1
  73. package/lib/config/index.js +2 -1
  74. package/lib/config/index.js.map +1 -1
  75. package/lib/config/memory-config-store.d.ts +21 -0
  76. package/lib/config/memory-config-store.js +48 -0
  77. package/lib/config/memory-config-store.js.map +1 -0
  78. package/lib/config/migrate.js +1 -1
  79. package/lib/config/migrate.js.map +1 -1
  80. package/lib/config/values.d.ts +12 -0
  81. package/lib/config/values.js +50 -0
  82. package/lib/config/values.js.map +1 -0
  83. package/lib/context.d.ts +37 -0
  84. package/lib/context.js +33 -0
  85. package/lib/context.js.map +1 -0
  86. package/lib/env.d.ts +7 -2
  87. package/lib/env.js +7 -2
  88. package/lib/env.js.map +1 -1
  89. package/lib/errors.d.ts +31 -0
  90. package/lib/errors.js +58 -0
  91. package/lib/errors.js.map +1 -0
  92. package/lib/http/api.d.ts +37 -0
  93. package/lib/http/api.js +20 -0
  94. package/lib/http/api.js.map +1 -0
  95. package/lib/http/client.d.ts +4 -0
  96. package/lib/{get-seam.js → http/client.js} +16 -17
  97. package/lib/http/client.js.map +1 -0
  98. package/lib/http/follow-ups.d.ts +6 -0
  99. package/lib/http/follow-ups.js +30 -0
  100. package/lib/http/follow-ups.js.map +1 -0
  101. package/lib/http/memory-seam-api.d.ts +22 -0
  102. package/lib/http/memory-seam-api.js +41 -0
  103. package/lib/http/memory-seam-api.js.map +1 -0
  104. package/lib/http/request.d.ts +19 -0
  105. package/lib/http/request.js +39 -0
  106. package/lib/http/request.js.map +1 -0
  107. package/lib/{interact-for-access-code.js → interactions/access-code.js} +4 -4
  108. package/lib/interactions/access-code.js.map +1 -0
  109. package/lib/{interact-for-acs-entrance.js → interactions/acs-entrance.js} +3 -3
  110. package/lib/interactions/acs-entrance.js.map +1 -0
  111. package/lib/{interact-for-acs-system.js → interactions/acs-system.js} +3 -3
  112. package/lib/interactions/acs-system.js.map +1 -0
  113. package/lib/{interact-for-acs-user.js → interactions/acs-user.js} +4 -4
  114. package/lib/interactions/acs-user.js.map +1 -0
  115. package/lib/{interact-for-action-attempt-poll.js → interactions/action-attempt-poll.js} +5 -5
  116. package/lib/interactions/action-attempt-poll.js.map +1 -0
  117. package/lib/{interact-for-array.js → interactions/array.js} +4 -3
  118. package/lib/interactions/array.js.map +1 -0
  119. package/lib/{interact-for-blueprint-object.d.ts → interactions/blueprint-object.d.ts} +3 -2
  120. package/lib/{interact-for-blueprint-object.js → interactions/blueprint-object.js} +49 -20
  121. package/lib/interactions/blueprint-object.js.map +1 -0
  122. package/lib/{interact-for-command-params.d.ts → interactions/command-params.d.ts} +2 -2
  123. package/lib/{interact-for-command-params.js → interactions/command-params.js} +4 -3
  124. package/lib/interactions/command-params.js.map +1 -0
  125. package/lib/interactions/command-selection.d.ts +10 -0
  126. package/lib/{interact-for-command-selection.js → interactions/command-selection.js} +9 -15
  127. package/lib/interactions/command-selection.js.map +1 -0
  128. package/lib/{interact-for-connected-account.js → interactions/connected-account.js} +3 -3
  129. package/lib/interactions/connected-account.js.map +1 -0
  130. package/lib/{interact-for-custom-metadata.js → interactions/custom-metadata.js} +4 -3
  131. package/lib/interactions/custom-metadata.js.map +1 -0
  132. package/lib/{interact-for-device.js → interactions/device.js} +3 -3
  133. package/lib/interactions/device.js.map +1 -0
  134. package/lib/interactions/endpoint-selection.d.ts +1 -0
  135. package/lib/interactions/endpoint-selection.js +39 -0
  136. package/lib/interactions/endpoint-selection.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-timestamp.js → interactions/timestamp.js} +2 -2
  145. package/lib/interactions/timestamp.js.map +1 -0
  146. package/lib/{interact-for-use-remote-api-defs.js → interactions/use-remote-api-defs.js} +5 -6
  147. package/lib/interactions/use-remote-api-defs.js.map +1 -0
  148. package/lib/{interact-for-user-identity.js → interactions/user-identity.js} +3 -3
  149. package/lib/interactions/user-identity.js.map +1 -0
  150. package/lib/{interact-for-workspace-id.js → interactions/workspace-id.js} +11 -10
  151. package/lib/interactions/workspace-id.js.map +1 -0
  152. package/lib/memory-prompt.d.ts +32 -0
  153. package/lib/memory-prompt.js +41 -0
  154. package/lib/memory-prompt.js.map +1 -0
  155. package/lib/output/get-output.d.ts +1 -1
  156. package/lib/output/get-output.js +1 -1
  157. package/lib/output/get-output.js.map +1 -1
  158. package/lib/output/{create-memory-output.d.ts → memory-output.d.ts} +1 -1
  159. package/lib/output/{create-memory-output.js → memory-output.js} +2 -2
  160. package/lib/output/memory-output.js.map +1 -0
  161. package/lib/output/{create-output.d.ts → output.d.ts} +18 -1
  162. package/lib/output/output.js +46 -0
  163. package/lib/output/output.js.map +1 -0
  164. package/lib/output/read-stdin-json.js.map +1 -0
  165. package/lib/output/resolve-output-format.d.ts +1 -1
  166. package/lib/{util → output}/with-loading.js +1 -1
  167. package/lib/output/with-loading.js.map +1 -0
  168. package/lib/prompt.d.ts +101 -0
  169. package/lib/{util/prompt.js → prompt.js} +83 -56
  170. package/lib/prompt.js.map +1 -0
  171. package/lib/{completion → render/completion}/describe.js +1 -2
  172. package/lib/render/completion/describe.js.map +1 -0
  173. package/lib/{completion → render/completion}/index.d.ts +2 -2
  174. package/lib/{completion → render/completion}/index.js +1 -2
  175. package/lib/render/completion/index.js.map +1 -0
  176. package/lib/{completion → render/completion}/render-bash.d.ts +1 -1
  177. package/lib/{completion → render/completion}/render-bash.js +1 -1
  178. package/lib/render/completion/render-bash.js.map +1 -0
  179. package/lib/{completion → render/completion}/render-fish.d.ts +1 -1
  180. package/lib/render/completion/render-fish.js.map +1 -0
  181. package/lib/{completion → render/completion}/render-zsh.d.ts +1 -1
  182. package/lib/{completion → render/completion}/render-zsh.js +1 -1
  183. package/lib/render/completion/render-zsh.js.map +1 -0
  184. package/lib/{render-help.d.ts → render/help.d.ts} +1 -1
  185. package/lib/{render-help.js → render/help.js} +2 -2
  186. package/lib/render/help.js.map +1 -0
  187. package/lib/render/text.d.ts +4 -0
  188. package/lib/render/text.js +16 -0
  189. package/lib/render/text.js.map +1 -0
  190. package/lib/version.d.ts +2 -2
  191. package/lib/version.js +2 -2
  192. package/package.json +4 -3
  193. package/src/bin/cli.ts +91 -332
  194. package/src/lib/args/coerce.ts +164 -0
  195. package/src/lib/{util/cli-args.ts → args/parse.ts} +30 -25
  196. package/src/lib/args/validate.ts +73 -0
  197. package/src/lib/auth/operations.ts +177 -0
  198. package/src/lib/{validate-token.ts → auth/validate-token.ts} +2 -2
  199. package/src/lib/blueprint/cache.ts +97 -0
  200. package/src/lib/{get-response-key.ts → blueprint/endpoint.ts} +17 -3
  201. package/src/lib/blueprint/index.ts +27 -0
  202. package/src/lib/{blueprint.ts → blueprint/source-npm.ts} +27 -99
  203. package/src/lib/blueprint/source-remote.ts +17 -0
  204. package/src/lib/commands/api-command.ts +109 -0
  205. package/src/lib/commands/local/completion.ts +51 -0
  206. package/src/lib/commands/local/config-reveal-location.ts +16 -0
  207. package/src/lib/commands/local/config-use-remote-api-defs.ts +23 -0
  208. package/src/lib/commands/local/health.ts +22 -0
  209. package/src/lib/commands/local/login.ts +42 -0
  210. package/src/lib/commands/local/logout.ts +18 -0
  211. package/src/lib/commands/local/select-endpoint.ts +30 -0
  212. package/src/lib/commands/local/select-workspace.ts +25 -0
  213. package/src/lib/commands/local/wizard.ts +31 -0
  214. package/src/lib/commands/registry.ts +125 -0
  215. package/src/lib/{command-spec.ts → commands/spec.ts} +30 -131
  216. package/src/lib/config/config-store.ts +39 -64
  217. package/src/lib/config/index.ts +8 -1
  218. package/src/lib/config/memory-config-store.ts +62 -0
  219. package/src/lib/config/migrate.ts +1 -1
  220. package/src/lib/config/values.ts +72 -0
  221. package/src/lib/context.ts +88 -0
  222. package/src/lib/env.ts +11 -4
  223. package/src/lib/errors.ts +67 -0
  224. package/src/lib/http/api.ts +61 -0
  225. package/src/lib/{get-seam.ts → http/client.ts} +19 -18
  226. package/src/lib/http/follow-ups.ts +42 -0
  227. package/src/lib/http/memory-seam-api.ts +57 -0
  228. package/src/lib/http/request.ts +69 -0
  229. package/src/lib/{interact-for-access-code.ts → interactions/access-code.ts} +4 -3
  230. package/src/lib/{interact-for-acs-entrance.ts → interactions/acs-entrance.ts} +3 -2
  231. package/src/lib/{interact-for-acs-system.ts → interactions/acs-system.ts} +3 -2
  232. package/src/lib/{interact-for-acs-user.ts → interactions/acs-user.ts} +4 -3
  233. package/src/lib/{interact-for-action-attempt-poll.ts → interactions/action-attempt-poll.ts} +4 -4
  234. package/src/lib/{interact-for-array.ts → interactions/array.ts} +3 -3
  235. package/src/lib/{interact-for-blueprint-object.ts → interactions/blueprint-object.ts} +57 -24
  236. package/src/lib/{interact-for-command-params.ts → interactions/command-params.ts} +6 -4
  237. package/src/lib/{interact-for-command-selection.ts → interactions/command-selection.ts} +11 -23
  238. package/src/lib/{interact-for-connected-account.ts → interactions/connected-account.ts} +3 -2
  239. package/src/lib/{interact-for-custom-metadata.ts → interactions/custom-metadata.ts} +3 -7
  240. package/src/lib/{interact-for-device.ts → interactions/device.ts} +3 -2
  241. package/src/lib/interactions/endpoint-selection.ts +48 -0
  242. package/src/lib/interactions/index.ts +19 -0
  243. package/src/lib/{interact-for-login.ts → interactions/login.ts} +16 -13
  244. package/src/lib/{interact-for-resource.ts → interactions/resource.ts} +2 -2
  245. package/src/lib/{interact-for-timestamp.ts → interactions/timestamp.ts} +1 -1
  246. package/src/lib/{interact-for-use-remote-api-defs.ts → interactions/use-remote-api-defs.ts} +4 -5
  247. package/src/lib/{interact-for-user-identity.ts → interactions/user-identity.ts} +3 -2
  248. package/src/lib/{interact-for-workspace-id.ts → interactions/workspace-id.ts} +10 -17
  249. package/src/lib/memory-prompt.ts +89 -0
  250. package/src/lib/output/get-output.ts +1 -1
  251. package/src/lib/output/{create-memory-output.ts → memory-output.ts} +1 -1
  252. package/src/lib/output/{create-output.ts → output.ts} +47 -32
  253. package/src/lib/output/resolve-output-format.ts +1 -1
  254. package/src/lib/{util → output}/with-loading.ts +1 -1
  255. package/src/lib/prompt.ts +306 -0
  256. package/src/lib/{completion → render/completion}/describe.ts +1 -2
  257. package/src/lib/{completion → render/completion}/index.ts +3 -4
  258. package/src/lib/{completion → render/completion}/render-bash.ts +1 -1
  259. package/src/lib/{completion → render/completion}/render-fish.ts +2 -1
  260. package/src/lib/{completion → render/completion}/render-zsh.ts +2 -1
  261. package/src/lib/{render-help.ts → render/help.ts} +1 -1
  262. package/src/lib/render/text.ts +17 -0
  263. package/src/lib/version.ts +2 -2
  264. package/lib/blueprint.d.ts +0 -7
  265. package/lib/blueprint.js.map +0 -1
  266. package/lib/command-spec.js.map +0 -1
  267. package/lib/completion/describe.js.map +0 -1
  268. package/lib/completion/index.js.map +0 -1
  269. package/lib/completion/render-bash.js.map +0 -1
  270. package/lib/completion/render-fish.js.map +0 -1
  271. package/lib/completion/render-zsh.js.map +0 -1
  272. package/lib/get-api-blueprint.d.ts +0 -6
  273. package/lib/get-api-blueprint.js +0 -18
  274. package/lib/get-api-blueprint.js.map +0 -1
  275. package/lib/get-command-blueprint-def.d.ts +0 -2
  276. package/lib/get-command-blueprint-def.js +0 -11
  277. package/lib/get-command-blueprint-def.js.map +0 -1
  278. package/lib/get-credentials.d.ts +0 -15
  279. package/lib/get-credentials.js +0 -35
  280. package/lib/get-credentials.js.map +0 -1
  281. package/lib/get-current-workspace-id.d.ts +0 -1
  282. package/lib/get-current-workspace-id.js +0 -9
  283. package/lib/get-current-workspace-id.js.map +0 -1
  284. package/lib/get-response-key.d.ts +0 -9
  285. package/lib/get-response-key.js.map +0 -1
  286. package/lib/get-seam.d.ts +0 -3
  287. package/lib/get-seam.js.map +0 -1
  288. package/lib/get-server.d.ts +0 -6
  289. package/lib/get-server.js +0 -17
  290. package/lib/get-server.js.map +0 -1
  291. package/lib/interact-for-access-code.js.map +0 -1
  292. package/lib/interact-for-acs-entrance.js.map +0 -1
  293. package/lib/interact-for-acs-system.js.map +0 -1
  294. package/lib/interact-for-acs-user.js.map +0 -1
  295. package/lib/interact-for-action-attempt-poll.js.map +0 -1
  296. package/lib/interact-for-array.js.map +0 -1
  297. package/lib/interact-for-blueprint-object.js.map +0 -1
  298. package/lib/interact-for-command-params.js.map +0 -1
  299. package/lib/interact-for-command-selection.d.ts +0 -2
  300. package/lib/interact-for-command-selection.js.map +0 -1
  301. package/lib/interact-for-connected-account.js.map +0 -1
  302. package/lib/interact-for-custom-metadata.js.map +0 -1
  303. package/lib/interact-for-device.js.map +0 -1
  304. package/lib/interact-for-login.js.map +0 -1
  305. package/lib/interact-for-resource.js.map +0 -1
  306. package/lib/interact-for-server-selection.d.ts +0 -1
  307. package/lib/interact-for-server-selection.js +0 -39
  308. package/lib/interact-for-server-selection.js.map +0 -1
  309. package/lib/interact-for-timestamp.js.map +0 -1
  310. package/lib/interact-for-use-remote-api-defs.js.map +0 -1
  311. package/lib/interact-for-user-identity.js.map +0 -1
  312. package/lib/interact-for-workspace-id.js.map +0 -1
  313. package/lib/output/create-memory-output.js.map +0 -1
  314. package/lib/output/create-output.js +0 -34
  315. package/lib/output/create-output.js.map +0 -1
  316. package/lib/render-help.js.map +0 -1
  317. package/lib/types.d.ts +0 -6
  318. package/lib/types.js +0 -2
  319. package/lib/types.js.map +0 -1
  320. package/lib/util/cli-args.js.map +0 -1
  321. package/lib/util/ellipsis.d.ts +0 -1
  322. package/lib/util/ellipsis.js +0 -6
  323. package/lib/util/ellipsis.js.map +0 -1
  324. package/lib/util/prompt.d.ts +0 -80
  325. package/lib/util/prompt.js.map +0 -1
  326. package/lib/util/read-stdin-json.js.map +0 -1
  327. package/lib/util/request-seam-api.d.ts +0 -7
  328. package/lib/util/request-seam-api.js +0 -26
  329. package/lib/util/request-seam-api.js.map +0 -1
  330. package/lib/util/with-loading.js.map +0 -1
  331. package/lib/validate-token.js.map +0 -1
  332. package/src/lib/get-api-blueprint.ts +0 -31
  333. package/src/lib/get-command-blueprint-def.ts +0 -15
  334. package/src/lib/get-credentials.ts +0 -38
  335. package/src/lib/get-current-workspace-id.ts +0 -9
  336. package/src/lib/get-server.ts +0 -20
  337. package/src/lib/interact-for-server-selection.ts +0 -50
  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-timestamp.d.ts → interactions/timestamp.d.ts} +0 -0
  355. /package/lib/{interact-for-use-remote-api-defs.d.ts → interactions/use-remote-api-defs.d.ts} +0 -0
  356. /package/lib/{interact-for-user-identity.d.ts → interactions/user-identity.d.ts} +0 -0
  357. /package/lib/{interact-for-workspace-id.d.ts → interactions/workspace-id.d.ts} +0 -0
  358. /package/lib/{util → output}/read-stdin-json.d.ts +0 -0
  359. /package/lib/{util → output}/read-stdin-json.js +0 -0
  360. /package/lib/{util → output}/with-loading.d.ts +0 -0
  361. /package/lib/{completion → render/completion}/describe.d.ts +0 -0
  362. /package/lib/{completion → render/completion}/render-fish.js +0 -0
  363. /package/src/lib/{util → output}/read-stdin-json.ts +0 -0
@@ -20,24 +20,21 @@ export declare const interactivityFlags: string[];
20
20
  * and are therefore never sent as command parameters.
21
21
  */
22
22
  export declare const cliFlags: string[];
23
- /**
24
- * Thrown when the CLI needs input it cannot prompt for.
25
- */
26
- export declare class NonInteractiveError extends Error {
27
- name: string;
23
+ export interface ParseCliArgsOptions {
24
+ /**
25
+ * Argument keys read exactly as given rather than by guessing at a type,
26
+ * e.g., every parameter of an endpoint that does not take a number or a
27
+ * boolean. Read as a number, an opaque value like an access code would
28
+ * lose leading zeroes or turn exponent notation into a digit string.
29
+ */
30
+ stringKeys?: string[];
28
31
  }
32
+ export declare const parseCliArgs: (argv: string[], { stringKeys }?: ParseCliArgsOptions) => ParsedArgs;
29
33
  /**
30
- * Thrown when the arguments do not name something the CLI can run.
34
+ * The request params among the parsed arguments: every key normalized to
35
+ * the parameter it names, minus the flags that configure the CLI itself.
31
36
  */
32
- export declare class UsageError extends Error {
33
- name: string;
34
- /** What to run instead, reported after the message. */
35
- readonly hint: string;
36
- constructor(message: string, { hint }?: {
37
- hint?: string;
38
- });
39
- }
40
- export declare const parseCliArgs: (argv: string[]) => ParsedArgs;
37
+ export declare const toArgParams: (args: ParsedArgs) => Record<string, unknown>;
41
38
  export interface GetInteractivityOptions {
42
39
  /**
43
40
  * Whether there is a terminal to prompt on.
@@ -22,34 +22,31 @@ export const cliFlags = [
22
22
  'update',
23
23
  'version',
24
24
  ];
25
- /**
26
- * Thrown when the CLI needs input it cannot prompt for.
27
- */
28
- export class NonInteractiveError extends Error {
29
- name = 'NonInteractiveError';
30
- }
31
- /**
32
- * Thrown when the arguments do not name something the CLI can run.
33
- */
34
- export class UsageError extends Error {
35
- name = 'UsageError';
36
- /** What to run instead, reported after the message. */
37
- hint;
38
- constructor(message, { hint = '' } = {}) {
39
- super(message);
40
- this.hint = hint;
41
- }
42
- }
43
- export const parseCliArgs = (argv) => parseArgs(argv, {
44
- // A page cursor is opaque, so keep it exactly as given: read as a number
45
- // it would lose leading zeroes and turn exponent notation into a digit
46
- // string, naming a page the API never issued.
47
- string: ['code', 'page-cursor', 'page_cursor'],
25
+ export const parseCliArgs = (argv, { stringKeys = [] } = {}) => parseArgs(argv, {
26
+ // A page cursor and a code are opaque even before the endpoint's own
27
+ // parameter types are known, so always keep them exactly as given.
28
+ string: ['code', 'page-cursor', 'page_cursor', ...stringKeys],
48
29
  boolean: ['non-interactive', 'interactive', 'json'],
49
30
  // Deliberately not aliased to -n, which is reserved for a future
50
31
  // --dry-run flag.
51
32
  alias: { 'non-interactive': 'y', interactive: 'i' },
52
33
  });
34
+ /**
35
+ * The request params among the parsed arguments: every key normalized to
36
+ * the parameter it names, minus the flags that configure the CLI itself.
37
+ */
38
+ export const toArgParams = (args) => {
39
+ const argParams = {};
40
+ for (const [key, value] of Object.entries(args)) {
41
+ if (key === '_')
42
+ continue;
43
+ const name = toParameterName(key);
44
+ if (cliFlags.includes(name))
45
+ continue;
46
+ argParams[name] = value;
47
+ }
48
+ return argParams;
49
+ };
53
50
  export const getInteractivity = (args, { canPrompt = true } = {}) => {
54
51
  const isNonInteractive = args['non_interactive'] === true || args['y'] === true;
55
52
  const isInteractive = args['interactive'] === true || args['i'] === true;
@@ -80,4 +77,4 @@ export const toParameterName = (argKey) => argKey.toLowerCase().replace(/-/g, '_
80
77
  * key as the short form it can only have been written as, e.g., `-n`.
81
78
  */
82
79
  export const toGivenArgName = (argKey) => argKey.length === 1 ? `-${argKey}` : toArgName(argKey);
83
- //# sourceMappingURL=cli-args.js.map
80
+ //# sourceMappingURL=parse.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse.js","sourceRoot":"","sources":["../../src/lib/args/parse.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,EAAE,EAAmB,MAAM,UAAU,CAAA;AAcrD;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAa;IAC1C,iBAAiB;IACjB,GAAG;IACH,aAAa;IACb,GAAG;CACJ,CAAA;AAED;;;GAGG;AACH,MAAM,CA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KAAK,IAAI,CAAA;IACxD,MAAM,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC,KAAK,IAAI,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,IAAI,CAAA;IAExE,IAAI,gBAAgB,IAAI,aAAa,EAAE,CAAC;QACtC,MAAM,IAAI,KAAK,CACb,uEAAuE,CACxE,CAAA;IACH,CAAC;IACD,IAAI,gBAAgB;QAAE,OAAO,iBAAiB,CAAA;IAC9C,uEAAuE;IACvE,IAAI,aAAa;QAAE,OAAO,aAAa,CAAA;IACvC,IAAI,CAAC,SAAS;QAAE,OAAO,iBAAiB,CAAA;IACxC,OAAO,MAAM,CAAA;AACf,CAAC,CAAA;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,aAAqB,EAAU,EAAE,CACzD,KAAK,aAAa,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE,CAAA;AAEzC;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,MAAc,EAAU,EAAE,CACxD,MAAM,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;AAEzC;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,MAAc,EAAU,EAAE,CACvD,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,MAAM,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA"}
@@ -0,0 +1,23 @@
1
+ import type { Parameter } from '@seamapi/blueprint';
2
+ /**
3
+ * Report every required parameter still missing from the params, rather
4
+ * than prompting for it.
5
+ *
6
+ * @param target What the params are for, e.g., `/devices/list`.
7
+ */
8
+ export declare const assertRequiredParams: (parameters: Parameter[], params: Record<string, unknown>, target: string) => void;
9
+ /**
10
+ * Report any argument the command does not accept, rather than acting on it.
11
+ * An unrecognized argument is a mistake: forwarded to the API it would fail
12
+ * somewhere less obvious or be quietly ignored, and on a command the CLI
13
+ * handles itself it would go nowhere at all.
14
+ *
15
+ * Only arguments are checked. Params read from stdin are passed through as
16
+ * given, so a caller may send whatever the API itself accepts.
17
+ */
18
+ export declare const assertKnownArgs: (argParams: Record<string, unknown>, command: string[], { accepted, isLocal, }: {
19
+ /** Parameter names the command accepts. */
20
+ accepted: Set<string>;
21
+ /** Whether the CLI handles the command itself. */
22
+ isLocal: boolean;
23
+ }) => void;
@@ -0,0 +1,42 @@
1
+ import { NonInteractiveError, UsageError } from '../errors.js';
2
+ import { toArgName, toGivenArgName } from './parse.js';
3
+ /**
4
+ * Report every required parameter still missing from the params, rather
5
+ * than prompting for it.
6
+ *
7
+ * @param target What the params are for, e.g., `/devices/list`.
8
+ */
9
+ export const assertRequiredParams = (parameters, params, target) => {
10
+ // A required parameter is satisfied by being present, not by being
11
+ // truthy: `false`, `0` and `''` are values a caller can supply.
12
+ const missing = parameters
13
+ .filter((parameter) => parameter.isRequired)
14
+ .map((parameter) => parameter.name)
15
+ .filter((name) => params[name] === undefined);
16
+ if (missing.length === 0)
17
+ return;
18
+ throw new NonInteractiveError(`Missing required ${missing.length === 1 ? 'parameter' : 'parameters'} for ${target}: ${missing.map(toArgName).join(' ')}`);
19
+ };
20
+ /**
21
+ * Report any argument the command does not accept, rather than acting on it.
22
+ * An unrecognized argument is a mistake: forwarded to the API it would fail
23
+ * somewhere less obvious or be quietly ignored, and on a command the CLI
24
+ * handles itself it would go nowhere at all.
25
+ *
26
+ * Only arguments are checked. Params read from stdin are passed through as
27
+ * given, so a caller may send whatever the API itself accepts.
28
+ */
29
+ export const assertKnownArgs = (argParams, command, { accepted, isLocal, }) => {
30
+ const unknown = Object.keys(argParams).filter((key) => !accepted.has(key));
31
+ if (unknown.length === 0)
32
+ return;
33
+ // Name an endpoint command by its path, as missing params are named, and a
34
+ // command the CLI handles itself by the words that run it.
35
+ const target = isLocal
36
+ ? command.join(' ')
37
+ : `/${command.join('/').replace(/-/g, '_')}`;
38
+ throw new UsageError(`Unknown ${unknown.length === 1 ? 'parameter' : 'parameters'} for ${target}: ${unknown.map(toGivenArgName).join(' ')}`, {
39
+ hint: `Run 'seam ${command.join(' ')} --help' to see what it accepts.`,
40
+ });
41
+ };
42
+ //# sourceMappingURL=validate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate.js","sourceRoot":"","sources":["../../src/lib/args/validate.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAE/D,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAEtD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAClC,UAAuB,EACvB,MAA+B,EAC/B,MAAc,EACR,EAAE;IACR,mEAAmE;IACnE,gEAAgE;IAChE,MAAM,OAAO,GAAG,UAAU;SACvB,MAAM,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,UAAU,CAAC;SAC3C,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC;SAClC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,SAAS,CAAC,CAAA;IAE/C,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAM;IAEhC,MAAM,IAAI,mBAAmB,CAC3B,oBACE,OAAO,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,YACvC,QAAQ,MAAM,KAAK,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CACtD,CAAA;AACH,CAAC,CAAA;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAC7B,SAAkC,EAClC,OAAiB,EACjB,EACE,QAAQ,EACR,OAAO,GAMR,EACK,EAAE;IACR,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAA;IAC1E,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAM;IAEhC,2EAA2E;IAC3E,2DAA2D;IAC3D,MAAM,MAAM,GAAG,OAAO;QACpB,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC;QACnB,CAAC,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE,CAAA;IAE9C,MAAM,IAAI,UAAU,CAClB,WACE,OAAO,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,YACvC,QAAQ,MAAM,KAAK,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,EAC1D;QACE,IAAI,EAAE,aAAa,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,kCAAkC;KACvE,CACF,CAAA;AACH,CAAC,CAAA"}
@@ -0,0 +1,54 @@
1
+ import { type ConfigStore } from '../config/index.js';
2
+ import { type AuthContext } from '../context.js';
3
+ import { validateToken } from './validate-token.js';
4
+ /** A stored auth setting an environment variable may override. */
5
+ export type AuthSetting = 'endpoint' | 'token' | 'workspaceId';
6
+ /**
7
+ * Refuse to store a setting the environment overrides.
8
+ *
9
+ * The env-override policy lives here alone: every auth mutation asserts
10
+ * through this before writing, so a command that appears to succeed cannot
11
+ * leave the CLI using something else.
12
+ *
13
+ * @param action What the command does, e.g., `log in`.
14
+ */
15
+ export declare const assertMutable: (auth: AuthContext, setting: AuthSetting, action: string) => void;
16
+ export interface LoginOptions {
17
+ endpoint?: string | undefined;
18
+ token?: string | undefined;
19
+ workspaceId?: string | undefined;
20
+ }
21
+ /**
22
+ * Store the given credentials, validating the token first.
23
+ *
24
+ * The token is stored under the endpoint it will be used with, so a given
25
+ * endpoint is stored and re-resolved before the token key is derived.
26
+ *
27
+ * Validation reaches the network, so a test may inject its own `validate`.
28
+ */
29
+ export declare const login: ({ endpoint, token, workspaceId }: LoginOptions, config?: ConfigStore, validate?: typeof validateToken) => Promise<void>;
30
+ /** Store the token for the current endpoint, e.g., one just prompted for. */
31
+ export declare const storeToken: (token: string, config?: ConfigStore) => void;
32
+ /** Remove the stored token and workspace selection. */
33
+ export declare const logout: (config?: ConfigStore) => void;
34
+ /**
35
+ * Store the endpoint to make requests against.
36
+ *
37
+ * The workspace selection belongs to the previous endpoint, so it is cleared.
38
+ */
39
+ export declare const selectEndpoint: (endpoint: string, config?: ConfigStore) => void;
40
+ /** Store the workspace requests are made against. */
41
+ export declare const selectWorkspace: (workspaceId: string, config?: ConfigStore) => void;
42
+ /**
43
+ * Point the CLI at a fake Seam Connect endpoint and store the well-known
44
+ * token it accepts. Returns the generated endpoint URL for reporting.
45
+ */
46
+ export declare const selectFakeEndpoint: ({ urlSeed, config, }?: {
47
+ urlSeed?: string;
48
+ config?: ConfigStore;
49
+ }) => {
50
+ endpoint: string;
51
+ token: string;
52
+ };
53
+ /** Store whether API definitions come from the endpoint instead of npm. */
54
+ export declare const setUseRemoteApiDefs: (useRemoteApiDefs: boolean, config?: ConfigStore) => void;
@@ -0,0 +1,122 @@
1
+ import { randomBytes } from 'node:crypto';
2
+ import { getConfigStore } from '../config/index.js';
3
+ import { resolveAuth } from '../context.js';
4
+ import { assertEnvVarUnset, endpointEnvVar, tokenEnvVar, workspaceIdEnvVar, } from '../env.js';
5
+ import { validateToken } from './validate-token.js';
6
+ /**
7
+ * Refuse to store a setting the environment overrides.
8
+ *
9
+ * The env-override policy lives here alone: every auth mutation asserts
10
+ * through this before writing, so a command that appears to succeed cannot
11
+ * leave the CLI using something else.
12
+ *
13
+ * @param action What the command does, e.g., `log in`.
14
+ */
15
+ export const assertMutable = (auth, setting, action) => {
16
+ const { envVar, source, value } = {
17
+ endpoint: {
18
+ envVar: endpointEnvVar,
19
+ source: auth.endpointSource,
20
+ value: auth.endpoint,
21
+ },
22
+ token: { envVar: tokenEnvVar, source: auth.tokenSource, value: auth.token },
23
+ workspaceId: {
24
+ envVar: workspaceIdEnvVar,
25
+ source: auth.workspaceIdSource,
26
+ value: auth.workspaceId,
27
+ },
28
+ }[setting];
29
+ if (source !== 'env')
30
+ return;
31
+ assertEnvVarUnset(envVar, value, action);
32
+ };
33
+ /**
34
+ * Store the given credentials, validating the token first.
35
+ *
36
+ * The token is stored under the endpoint it will be used with, so a given
37
+ * endpoint is stored and re-resolved before the token key is derived.
38
+ *
39
+ * Validation reaches the network, so a test may inject its own `validate`.
40
+ */
41
+ export const login = async ({ endpoint, token, workspaceId }, config = getConfigStore(), validate = validateToken) => {
42
+ let auth = resolveAuth(config);
43
+ // Nothing is stored while the environment overrides it, so refuse before
44
+ // storing anything rather than part way through.
45
+ assertMutable(auth, 'token', 'log in');
46
+ if (endpoint != null)
47
+ assertMutable(auth, 'endpoint', 'select an endpoint');
48
+ if (workspaceId != null) {
49
+ assertMutable(auth, 'workspaceId', 'select a workspace');
50
+ }
51
+ if (endpoint != null) {
52
+ storeEndpoint(endpoint, config);
53
+ auth = resolveAuth(config);
54
+ }
55
+ if (token != null) {
56
+ await validate(token, workspaceId);
57
+ config.set(`${auth.endpoint}.pat`, token);
58
+ config.delete('current_workspace_id');
59
+ }
60
+ if (workspaceId != null) {
61
+ config.set('current_workspace_id', workspaceId);
62
+ }
63
+ };
64
+ /** Store the token for the current endpoint, e.g., one just prompted for. */
65
+ export const storeToken = (token, config = getConfigStore()) => {
66
+ const auth = resolveAuth(config);
67
+ assertMutable(auth, 'token', 'log in');
68
+ config.set(`${auth.endpoint}.pat`, token);
69
+ };
70
+ /** Remove the stored token and workspace selection. */
71
+ export const logout = (config = getConfigStore()) => {
72
+ const auth = resolveAuth(config);
73
+ assertMutable(auth, 'token', 'log out');
74
+ config.delete(`${auth.endpoint}.pat`);
75
+ // Configs written before tokens were stored per endpoint may still hold an
76
+ // un-namespaced token, so drop that too.
77
+ config.delete('pat');
78
+ config.delete('current_workspace_id');
79
+ };
80
+ /**
81
+ * Store the endpoint to make requests against.
82
+ *
83
+ * The workspace selection belongs to the previous endpoint, so it is cleared.
84
+ */
85
+ export const selectEndpoint = (endpoint, config = getConfigStore()) => {
86
+ assertMutable(resolveAuth(config), 'endpoint', 'select an endpoint');
87
+ storeEndpoint(endpoint, config);
88
+ };
89
+ /** Store the workspace requests are made against. */
90
+ export const selectWorkspace = (workspaceId, config = getConfigStore()) => {
91
+ assertMutable(resolveAuth(config), 'workspaceId', 'select a workspace');
92
+ config.set('current_workspace_id', workspaceId);
93
+ };
94
+ /**
95
+ * Point the CLI at a fake Seam Connect endpoint and store the well-known
96
+ * token it accepts. Returns the generated endpoint URL for reporting.
97
+ */
98
+ export const selectFakeEndpoint = ({ urlSeed = randomBytes(5).toString('hex'), config = getConfigStore(), } = {}) => {
99
+ const auth = resolveAuth(config);
100
+ assertMutable(auth, 'endpoint', 'select an endpoint');
101
+ assertMutable(auth, 'token', 'log in');
102
+ const endpoint = `https://${urlSeed}.fakeseamconnect.seam.vc`;
103
+ const token = 'seam_apikey1_token';
104
+ storeEndpoint(endpoint, config);
105
+ config.set(`${endpoint}.pat`, token);
106
+ return { endpoint, token };
107
+ };
108
+ /** Store whether API definitions come from the endpoint instead of npm. */
109
+ export const setUseRemoteApiDefs = (useRemoteApiDefs, config = getConfigStore()) => {
110
+ config.set('use_remote_api_defs', useRemoteApiDefs);
111
+ };
112
+ /**
113
+ * Write the endpoint, dropping what belonged to the previous one: the
114
+ * workspace selection, and any value left under the legacy `server` key that
115
+ * {@link resolveAuth} would otherwise still fall back to.
116
+ */
117
+ const storeEndpoint = (endpoint, config) => {
118
+ config.set('endpoint', endpoint);
119
+ config.delete('server');
120
+ config.delete('current_workspace_id');
121
+ };
122
+ //# sourceMappingURL=operations.js.map
@@ -0,0 +1 @@
1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O,EAAE,QAAQ,CAAC,CAAA;IAEtC,MAAM,QAAQ,GAAG,WAAW,OAAO,0BAA0B,CAAA;IAC7D,MAAM,KAAK,GAAG,oBAAoB,CAAA;IAClC,aAAa,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;IAC/B,MAAM,CAAC,GAAG,CAAC,GAAG,QAAQ,MAAM,EAAE,KAAK,CAAC,CAAA;IAEpC,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAA;AAC5B,CAAC,CAAA;AAED,2EAA2E;AAC3E,MAAM,CAAC,MAAM,mBAAmB,GAAG,CACjC,gBAAyB,EACzB,SAAsB,cAAc,EAAE,EAChC,EAAE;IACR,MAAM,CAAC,GAAG,CAAC,qBAAqB,EAAE,gBAAgB,CAAC,CAAA;AACrD,CAAC,CAAA;AAED;;;;GAIG;AACH,MAAM,aAAa,GAAG,CAAC,QAAgB,EAAE,MAAmB,EAAQ,EAAE;IACpE,MAAM,CAAC,GAAG,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAA;IAChC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;IACvB,MAAM,CAAC,MAAM,CAAC,sBAAsB,CAAC,CAAA;AACvC,CAAC,CAAA"}
@@ -1,7 +1,7 @@
1
1
  import { isApiKey, isPersonalAccessToken, SeamHttp, SeamHttpWithoutWorkspace, } from '@seamapi/http/connect';
2
- import { getServer } from './get-server.js';
2
+ import { resolveAuth } from '../context.js';
3
3
  export const validateToken = async (token, workspaceId) => {
4
- const options = { endpoint: getServer() };
4
+ const options = { endpoint: resolveAuth().endpoint };
5
5
  if (isPersonalAccessToken(token)) {
6
6
  const seam = workspaceId
7
7
  ? SeamHttp.fromPersonalAccessToken(token, workspaceId, options)
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate-token.js","sourceRoot":"","sources":["../../src/lib/auth/validate-token.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,qBAAqB,EACrB,QAAQ,EACR,wBAAwB,GACzB,MAAM,uBAAuB,CAAA;AAE9B,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAE5C,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,EAAE,KAAa,EAAE,WAAoB,EAAE,EAAE;IACzE,MAAM,OAAO,GAAG,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC,QAAQ,EAAE,CAAA;IAEpD,IAAI,qBAAqB,CAAC,KAAK,CAAC,EAAE,CAAC;QACjC,MAAM,IAAI,GAAG,WAAW;YACtB,CAAC,CAAC,QAAQ,CAAC,uBAAuB,CAAC,KAAK,EAAE,WAAW,EAAE,OAAO,CAAC;YAC/D,CAAC,CAAC,wBAAwB,CAAC,uBAAuB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;QACpE,MAAM,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,CAAA;QAC5B,OAAM;IACR,CAAC;IAED,IAAI,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QACpB,MAAM,IAAI,GAAG,QAAQ,CAAC,UAAU,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;QAChD,MAAM,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,CAAA;QAC5B,OAAM;IACR,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,4DAA4D,CAAC,CAAA;AAC/E,CAAC,CAAA"}
@@ -0,0 +1,16 @@
1
+ import type { Blueprint } from '@seamapi/blueprint';
2
+ export interface BlueprintCache {
3
+ blueprintVersion: string;
4
+ typesVersion: string;
5
+ checkedAt: string;
6
+ blueprint: Blueprint;
7
+ }
8
+ export declare const getCacheFile: (cacheDirectory: string) => string;
9
+ export declare const readCache: (file: string) => Promise<BlueprintCache | null>;
10
+ export declare const writeCache: (file: string, cache: BlueprintCache) => Promise<void>;
11
+ export declare const isUpdateCheckDue: (checkedAt: string) => boolean;
12
+ /**
13
+ * The blueprint version the cache is keyed on: a cached blueprint built by a
14
+ * different @seamapi/blueprint version is stale even for the same types.
15
+ */
16
+ export declare const getBlueprintVersion: () => Promise<string>;
@@ -0,0 +1,73 @@
1
+ import { mkdir, readFile, rename, writeFile } from 'node:fs/promises';
2
+ import { dirname, join } from 'node:path';
3
+ import { fileURLToPath } from 'node:url';
4
+ import { seamapiBlueprintVersion } from '../version.js';
5
+ const cacheFileName = 'blueprint.json';
6
+ const updateCheckInterval = 24 * 60 * 60 * 1000;
7
+ export const getCacheFile = (cacheDirectory) => join(cacheDirectory, cacheFileName);
8
+ export const readCache = async (file) => {
9
+ try {
10
+ const contents = await readFile(file, 'utf8');
11
+ const cache = JSON.parse(contents);
12
+ if (!isBlueprintCache(cache))
13
+ return null;
14
+ return cache;
15
+ }
16
+ catch {
17
+ return null;
18
+ }
19
+ };
20
+ export const writeCache = async (file, cache) => {
21
+ const temporaryFile = `${file}.tmp`;
22
+ await mkdir(dirname(file), { recursive: true });
23
+ await writeFile(temporaryFile, `${JSON.stringify(cache)}\n`, 'utf8');
24
+ await rename(temporaryFile, file);
25
+ };
26
+ export const isUpdateCheckDue = (checkedAt) => {
27
+ const checkedAtTime = Date.parse(checkedAt);
28
+ if (Number.isNaN(checkedAtTime))
29
+ return true;
30
+ return Date.now() - checkedAtTime > updateCheckInterval;
31
+ };
32
+ /**
33
+ * The blueprint version the cache is keyed on: a cached blueprint built by a
34
+ * different @seamapi/blueprint version is stale even for the same types.
35
+ */
36
+ export const getBlueprintVersion = async () => {
37
+ if (seamapiBlueprintVersion !== '0.0.0')
38
+ return seamapiBlueprintVersion;
39
+ // The version is only injected when the package is packed, so a
40
+ // development checkout reads the pinned version from package.json
41
+ // to keep invalidating the cache on version changes as expected.
42
+ const pkg = await findOwnPackageJson();
43
+ return pkg?.dependencies?.['@seamapi/blueprint'] ?? seamapiBlueprintVersion;
44
+ };
45
+ const findOwnPackageJson = async () => {
46
+ let directory = dirname(fileURLToPath(import.meta.url));
47
+ while (true) {
48
+ try {
49
+ const contents = await readFile(join(directory, 'package.json'), 'utf8');
50
+ const pkg = JSON.parse(contents);
51
+ if (pkg.name === '@seamapi/cli')
52
+ return pkg;
53
+ }
54
+ catch {
55
+ // Keep walking up until a package.json for this package is found.
56
+ }
57
+ const parent = dirname(directory);
58
+ if (parent === directory)
59
+ return null;
60
+ directory = parent;
61
+ }
62
+ };
63
+ const isBlueprintCache = (cache) => {
64
+ if (cache == null || typeof cache !== 'object')
65
+ return false;
66
+ const { blueprintVersion, typesVersion, checkedAt, blueprint } = cache;
67
+ return (typeof blueprintVersion === 'string' &&
68
+ typeof typesVersion === 'string' &&
69
+ typeof checkedAt === 'string' &&
70
+ blueprint != null &&
71
+ typeof blueprint === 'object');
72
+ };
73
+ //# sourceMappingURL=cache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cache.js","sourceRoot":"","sources":["../../src/lib/blueprint/cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACrE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAIxC,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAA;AAExD,MAAM,aAAa,GAAG,gBAAgB,CAAA;AACtC,MAAM,mBAAmB,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAA;AAS/C,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,cAAsB,EAAU,EAAE,CAC7D,IAAI,CAAC,cAAc,EAAE,aAAa,CAAC,CAAA;AAErC,MAAM,CAAC,MAAM,SAAS,GAAG,KAAK,EAC5B,IAAY,EACoB,EAAE;IAClC,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;QAC7C,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAY,CAAA;QAC7C,IAAI,CAAC,g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AAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAA;IACvD,OAAO,IAAI,EAAE,CAAC;QACZ,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,SAAS,EAAE,cAAc,CAAC,EAAE,MAAM,CAAC,CAAA;YACxE,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAG9B,CAAA;YACD,IAAI,GAAG,CAAC,IAAI,KAAK,cAAc;gBAAE,OAAO,GAAG,CAAA;QAC7C,CAAC;QAAC,MAAM,CAAC;YACP,kEAAkE;QACpE,CAAC;QACD,MAAM,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,CAAA;QACjC,IAAI,MAAM,KAAK,SAAS;YAAE,OAAO,IAAI,CAAA;QACrC,SAAS,GAAG,MAAM,CAAA;IACpB,CAAC;AACH,CAAC,CAAA;AAED,MAAM,gBAAgB,GAAG,CAAC,KAAc,EAA2B,EAAE;IACnE,IAAI,KAAK,IAAI,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAA;IAC5D,MAAM,EAAE,gBAAgB,EAAE,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,GAC5D,KAAgC,CAAA;IAClC,OAAO,CACL,OAAO,gBAAgB,KAAK,QAAQ;QACpC,OAAO,YAAY,KAAK,QAAQ;QAChC,OAAO,SAAS,KAAK,QAAQ;QAC7B,SAAS,IAAI,IAAI;QACjB,OAAO,SAAS,KAAK,QAAQ,CAC9B,CAAA;AACH,CAAC,CAAA"}
@@ -0,0 +1,14 @@
1
+ import type { ApiBlueprint } from './index.js';
2
+ export declare const getCommandBlueprintDef: (cmd: string[], helpers: {
3
+ blueprint: ApiBlueprint;
4
+ }) => import("@seamapi/blueprint").Endpoint;
5
+ /**
6
+ * The top level response key documented for a command,
7
+ * e.g., `devices` for `seam devices list`.
8
+ *
9
+ * Returns null when the command is not in the blueprint,
10
+ * or when it does not respond with a resource.
11
+ */
12
+ export declare const getResponseKey: (command: string[], ctx: {
13
+ blueprint: ApiBlueprint;
14
+ }) => string | null;
@@ -1,4 +1,13 @@
1
- import { getCommandBlueprintDef } from './get-command-blueprint-def.js';
1
+ export const getCommandBlueprintDef = (cmd, helpers) => {
2
+ const path = `/${cmd.join('/').replace(/-/g, '_')}`;
3
+ const def = helpers.blueprint.routes
4
+ .flatMap((route) => route.endpoints)
5
+ .find((endpoint) => endpoint.path === path);
6
+ if (!def) {
7
+ throw new Error(`No definition for path ${path}`);
8
+ }
9
+ return def;
10
+ };
2
11
  /**
3
12
  * The top level response key documented for a command,
4
13
  * e.g., `devices` for `seam devices list`.
@@ -18,4 +27,4 @@ export const getResponseKey = (command, ctx) => {
18
27
  return null;
19
28
  return endpoint.response.responseKey;
20
29
  };
21
- //# sourceMappingURL=get-response-key.js.map
30
+ //# sourceMappingURL=endpoint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"endpoint.js","sourceRoot":"","sources":["../../src/lib/blueprint/endpoint.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,sBAAsB,GAAG,CACpC,GAAa,EACb,OAAoC,EACpC,EAAE;IACF,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE,CAAA;IACnD,MAAM,GAAG,GAAG,OAAO,CAAC,SAAS,CAAC,MAAM;SACjC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC;SACnC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,KAAK,IAAI,CAAC,CAAA;IAC7C,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,MAAM,IAAI,KAAK,CAAC,0BAA0B,IAAI,EAAE,CAAC,CAAA;IACnD,CAAC;IAED,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA;AAED;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,OAAiB,EACjB,GAAgC,EACjB,EAAE;IACjB,IAAI,QAAQ,CAAA;IACZ,IAAI,CAAC;QACH,QAAQ,GAAG,sBAAsB,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;IACjD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAA;IACb,CAAC;IAED,IAAI,QAAQ,CAAC,QAAQ,CAAC,YAAY,KAAK,MAAM;QAAE,OAAO,IAAI,CAAA;IAE1D,OAAO,QAAQ,CAAC,QAAQ,CAAC,WAAW,CAAA;AACtC,CAAC,CAAA"}
@@ -0,0 +1,12 @@
1
+ import type { Blueprint } from '@seamapi/blueprint';
2
+ export type ApiBlueprint = Blueprint;
3
+ export interface GetApiBlueprintOptions {
4
+ /**
5
+ * Build from the OpenAPI document the configured endpoint is currently
6
+ * running, instead of the published npm types.
7
+ */
8
+ useRemoteDefinitions?: boolean;
9
+ /** Force an update of the cached Seam API definitions. */
10
+ update?: boolean;
11
+ }
12
+ export declare const getApiBlueprint: ({ useRemoteDefinitions, update, }?: GetApiBlueprintOptions) => Promise<ApiBlueprint>;
@@ -0,0 +1,10 @@
1
+ import { getBlueprint } from './source-npm.js';
2
+ import { createRemoteBlueprint } from './source-remote.js';
3
+ export const getApiBlueprint = async ({ useRemoteDefinitions = false, update = false, } = {}) => {
4
+ // Remote definitions describe whatever the endpoint is currently running, so
5
+ // build them directly from that endpoint's OpenAPI document.
6
+ if (useRemoteDefinitions)
7
+ return await createRemoteBlueprint();
8
+ return await getBlueprint({ update });
9
+ };
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/lib/blueprint/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAA;AAc1D,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,EAAE,EACpC,oBAAoB,GAAG,KAAK,EAC5B,MAAM,GAAG,KAAK,MACY,EAAE,EAAyB,EAAE;IACvD,6EAA6E;IAC7E,6DAA6D;IAC7D,IAAI,oBAAoB;QAAE,OAAO,MAAM,qBAAqB,EAAE,CAAA;IAE9D,OAAO,MAAM,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC,CAAA;AACvC,CAAC,CAAA"}
@@ -0,0 +1,10 @@
1
+ import type { Blueprint } from '@seamapi/blueprint';
2
+ export interface GetBlueprintOptions {
3
+ update?: boolean;
4
+ cacheDirectory?: string;
5
+ }
6
+ /**
7
+ * Build a blueprint from the latest published Seam API types on npm,
8
+ * using the on-disk cache unless it is stale or an update is forced.
9
+ */
10
+ export declare const getBlueprint: (options?: GetBlueprintOptions) => Promise<Blueprint>;