@credibledata/cred-cli 0.0.103 → 0.0.105

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 (430) hide show
  1. package/README.md +106 -1
  2. package/dist/agent-contract.spec.js +548 -0
  3. package/dist/agent-contract.spec.js.map +1 -0
  4. package/dist/browser.js +72 -0
  5. package/dist/browser.js.map +1 -0
  6. package/dist/browser.spec.js +125 -0
  7. package/dist/browser.spec.js.map +1 -0
  8. package/dist/client/api.js +4137 -1159
  9. package/dist/client/api.js.map +1 -1
  10. package/dist/client-codeassist/api.js +476 -0
  11. package/dist/client-codeassist/api.js.map +1 -0
  12. package/dist/client-codeassist/base.js +69 -0
  13. package/dist/client-codeassist/base.js.map +1 -0
  14. package/dist/client-codeassist/common.js +162 -0
  15. package/dist/client-codeassist/common.js.map +1 -0
  16. package/dist/client-codeassist/configuration.js +44 -0
  17. package/dist/client-codeassist/configuration.js.map +1 -0
  18. package/dist/client-codeassist/index.js +32 -0
  19. package/dist/client-codeassist/index.js.map +1 -0
  20. package/dist/clientconfiguration.js +17 -289
  21. package/dist/clientconfiguration.js.map +1 -1
  22. package/dist/clientconfiguration.spec.js +35 -96
  23. package/dist/clientconfiguration.spec.js.map +1 -1
  24. package/dist/commands/add.js +103 -3
  25. package/dist/commands/add.js.map +1 -1
  26. package/dist/commands/add.spec.js +113 -0
  27. package/dist/commands/add.spec.js.map +1 -0
  28. package/dist/commands/connection/createconnections.js +104 -7
  29. package/dist/commands/connection/createconnections.js.map +1 -1
  30. package/dist/commands/connection/createconnections.spec.js +35 -1
  31. package/dist/commands/connection/createconnections.spec.js.map +1 -1
  32. package/dist/commands/connection/deleteconnection.js +4 -2
  33. package/dist/commands/connection/deleteconnection.js.map +1 -1
  34. package/dist/commands/connection/deleteconnection.spec.js +6 -1
  35. package/dist/commands/connection/deleteconnection.spec.js.map +1 -1
  36. package/dist/commands/connection/listconnections.js +2 -0
  37. package/dist/commands/connection/listconnections.js.map +1 -1
  38. package/dist/commands/connection/updateconnection.js +365 -0
  39. package/dist/commands/connection/updateconnection.js.map +1 -0
  40. package/dist/commands/connection/updateconnection.spec.js +625 -0
  41. package/dist/commands/connection/updateconnection.spec.js.map +1 -0
  42. package/dist/commands/database/createdatabase.js +52 -0
  43. package/dist/commands/database/createdatabase.js.map +1 -0
  44. package/dist/commands/database/database.spec.js +267 -0
  45. package/dist/commands/database/database.spec.js.map +1 -0
  46. package/dist/commands/database/deletedatabase.js +91 -0
  47. package/dist/commands/database/deletedatabase.js.map +1 -0
  48. package/dist/commands/database/getdatabase.js +97 -0
  49. package/dist/commands/database/getdatabase.js.map +1 -0
  50. package/dist/commands/database/listdatabases.js +36 -0
  51. package/dist/commands/database/listdatabases.js.map +1 -0
  52. package/dist/commands/database/shared.js +125 -0
  53. package/dist/commands/database/shared.js.map +1 -0
  54. package/dist/commands/database/shared.spec.js +109 -0
  55. package/dist/commands/database/shared.spec.js.map +1 -0
  56. package/dist/commands/database/updatedatabase.js +39 -0
  57. package/dist/commands/database/updatedatabase.js.map +1 -0
  58. package/dist/commands/environment/createenvironment.js +59 -28
  59. package/dist/commands/environment/createenvironment.js.map +1 -1
  60. package/dist/commands/environment/createenvironment.spec.js +29 -0
  61. package/dist/commands/environment/createenvironment.spec.js.map +1 -1
  62. package/dist/commands/environment/deleteenvironment.js +3 -2
  63. package/dist/commands/environment/deleteenvironment.js.map +1 -1
  64. package/dist/commands/environment/deleteenvironment.spec.js +5 -1
  65. package/dist/commands/environment/deleteenvironment.spec.js.map +1 -1
  66. package/dist/commands/environment/getenvironment.js +1 -0
  67. package/dist/commands/environment/getenvironment.js.map +1 -1
  68. package/dist/commands/environment/listenvironments.js +40 -8
  69. package/dist/commands/environment/listenvironments.js.map +1 -1
  70. package/dist/commands/environment/listenvironments.spec.js +41 -2
  71. package/dist/commands/environment/listenvironments.spec.js.map +1 -1
  72. package/dist/commands/environment/setenvironment.js +145 -6
  73. package/dist/commands/environment/setenvironment.js.map +1 -1
  74. package/dist/commands/environment/setenvironment.spec.js +256 -8
  75. package/dist/commands/environment/setenvironment.spec.js.map +1 -1
  76. package/dist/commands/environment/updateenvironment.js +12 -8
  77. package/dist/commands/environment/updateenvironment.js.map +1 -1
  78. package/dist/commands/environment/updateenvironment.spec.js +36 -2
  79. package/dist/commands/environment/updateenvironment.spec.js.map +1 -1
  80. package/dist/commands/get.js +64 -1
  81. package/dist/commands/get.js.map +1 -1
  82. package/dist/commands/group/addmember.js +3 -1
  83. package/dist/commands/group/addmember.js.map +1 -1
  84. package/dist/commands/group/addmember.spec.js +7 -2
  85. package/dist/commands/group/addmember.spec.js.map +1 -1
  86. package/dist/commands/group/creategroup.js +2 -0
  87. package/dist/commands/group/creategroup.js.map +1 -1
  88. package/dist/commands/group/deletegroup.js +3 -1
  89. package/dist/commands/group/deletegroup.js.map +1 -1
  90. package/dist/commands/group/deletegroup.spec.js +7 -1
  91. package/dist/commands/group/deletegroup.spec.js.map +1 -1
  92. package/dist/commands/group/getgroup.js +2 -0
  93. package/dist/commands/group/getgroup.js.map +1 -1
  94. package/dist/commands/group/listgroups.js +2 -0
  95. package/dist/commands/group/listgroups.js.map +1 -1
  96. package/dist/commands/group/removemember.js +3 -1
  97. package/dist/commands/group/removemember.js.map +1 -1
  98. package/dist/commands/group/removemember.spec.js +7 -2
  99. package/dist/commands/group/removemember.spec.js.map +1 -1
  100. package/dist/commands/groupaccesstoken/deleteToken.js +2 -1
  101. package/dist/commands/groupaccesstoken/deleteToken.js.map +1 -1
  102. package/dist/commands/groupaccesstoken/groupContainer.js +2 -0
  103. package/dist/commands/groupaccesstoken/groupContainer.js.map +1 -1
  104. package/dist/commands/list.js +24 -4
  105. package/dist/commands/list.js.map +1 -1
  106. package/dist/commands/materialization/cancelrun.js +3 -1
  107. package/dist/commands/materialization/cancelrun.js.map +1 -1
  108. package/dist/commands/materialization/getindex.js +2 -0
  109. package/dist/commands/materialization/getindex.js.map +1 -1
  110. package/dist/commands/materialization/getmaterialization.js +2 -0
  111. package/dist/commands/materialization/getmaterialization.js.map +1 -1
  112. package/dist/commands/materialization/getpreaggregate.js +2 -0
  113. package/dist/commands/materialization/getpreaggregate.js.map +1 -1
  114. package/dist/commands/materialization/getrun.js +2 -0
  115. package/dist/commands/materialization/getrun.js.map +1 -1
  116. package/dist/commands/materialization/listindexes.js +2 -0
  117. package/dist/commands/materialization/listindexes.js.map +1 -1
  118. package/dist/commands/materialization/listmaterializations.js +2 -0
  119. package/dist/commands/materialization/listmaterializations.js.map +1 -1
  120. package/dist/commands/materialization/listpreaggregates.js +2 -0
  121. package/dist/commands/materialization/listpreaggregates.js.map +1 -1
  122. package/dist/commands/materialization/listruns.js +3 -1
  123. package/dist/commands/materialization/listruns.js.map +1 -1
  124. package/dist/commands/materialization/rerun.js +3 -1
  125. package/dist/commands/materialization/rerun.js.map +1 -1
  126. package/dist/commands/misc/inquirerHost.js +87 -0
  127. package/dist/commands/misc/inquirerHost.js.map +1 -0
  128. package/dist/commands/misc/inquirerHost.spec.js +91 -0
  129. package/dist/commands/misc/inquirerHost.spec.js.map +1 -0
  130. package/dist/commands/misc/login.js +348 -58
  131. package/dist/commands/misc/login.js.map +1 -1
  132. package/dist/commands/misc/login.spec.js +525 -7
  133. package/dist/commands/misc/login.spec.js.map +1 -1
  134. package/dist/commands/misc/logout.js +26 -3
  135. package/dist/commands/misc/logout.js.map +1 -1
  136. package/dist/commands/misc/logout.spec.js +52 -12
  137. package/dist/commands/misc/logout.spec.js.map +1 -1
  138. package/dist/commands/misc/resolveLoginTarget.spec.js +90 -0
  139. package/dist/commands/misc/resolveLoginTarget.spec.js.map +1 -0
  140. package/dist/commands/misc/scope.spec.js +108 -0
  141. package/dist/commands/misc/scope.spec.js.map +1 -0
  142. package/dist/commands/misc/set-access-token.js +1 -1
  143. package/dist/commands/misc/set-access-token.js.map +1 -1
  144. package/dist/commands/misc/set-access-token.spec.js +13 -2
  145. package/dist/commands/misc/set-access-token.spec.js.map +1 -1
  146. package/dist/commands/misc/setup.js +819 -0
  147. package/dist/commands/misc/setup.js.map +1 -0
  148. package/dist/commands/misc/setup.spec.js +783 -0
  149. package/dist/commands/misc/setup.spec.js.map +1 -0
  150. package/dist/commands/misc/status.js +168 -0
  151. package/dist/commands/misc/status.js.map +1 -0
  152. package/dist/commands/misc/status.spec.js +301 -0
  153. package/dist/commands/misc/status.spec.js.map +1 -0
  154. package/dist/commands/misc/token.js +57 -0
  155. package/dist/commands/misc/token.js.map +1 -0
  156. package/dist/commands/misc/token.spec.js +92 -0
  157. package/dist/commands/misc/token.spec.js.map +1 -0
  158. package/dist/commands/package/deletepackage.js +4 -2
  159. package/dist/commands/package/deletepackage.js.map +1 -1
  160. package/dist/commands/package/deletepackage.spec.js +7 -1
  161. package/dist/commands/package/deletepackage.spec.js.map +1 -1
  162. package/dist/commands/package/getpackage.js +142 -0
  163. package/dist/commands/package/getpackage.js.map +1 -0
  164. package/dist/commands/package/getpackage.spec.js +246 -0
  165. package/dist/commands/package/getpackage.spec.js.map +1 -0
  166. package/dist/commands/package/listpackages.js +2 -0
  167. package/dist/commands/package/listpackages.js.map +1 -1
  168. package/dist/commands/package/publish.archive.spec.js +570 -0
  169. package/dist/commands/package/publish.archive.spec.js.map +1 -0
  170. package/dist/commands/package/publish.js +780 -49
  171. package/dist/commands/package/publish.js.map +1 -1
  172. package/dist/commands/package/publish.spec.js +451 -8
  173. package/dist/commands/package/publish.spec.js.map +1 -1
  174. package/dist/commands/package/updatepackage.js +22 -19
  175. package/dist/commands/package/updatepackage.js.map +1 -1
  176. package/dist/commands/package/updatepackage.spec.js +36 -1
  177. package/dist/commands/package/updatepackage.spec.js.map +1 -1
  178. package/dist/commands/permission/createpermission.js +3 -1
  179. package/dist/commands/permission/createpermission.js.map +1 -1
  180. package/dist/commands/permission/deletepermission.js +6 -3
  181. package/dist/commands/permission/deletepermission.js.map +1 -1
  182. package/dist/commands/permission/getpermission.js +2 -0
  183. package/dist/commands/permission/getpermission.js.map +1 -1
  184. package/dist/commands/permission/listpermissions.js +2 -0
  185. package/dist/commands/permission/listpermissions.js.map +1 -1
  186. package/dist/commands/rm.js +21 -0
  187. package/dist/commands/rm.js.map +1 -1
  188. package/dist/commands/set.js +40 -6
  189. package/dist/commands/set.js.map +1 -1
  190. package/dist/commands/set.spec.js +123 -0
  191. package/dist/commands/set.spec.js.map +1 -0
  192. package/dist/commands/table/addtable.js +155 -0
  193. package/dist/commands/table/addtable.js.map +1 -0
  194. package/dist/commands/table/deletetable.js +45 -0
  195. package/dist/commands/table/deletetable.js.map +1 -0
  196. package/dist/commands/table/gettable.js +32 -0
  197. package/dist/commands/table/gettable.js.map +1 -0
  198. package/dist/commands/table/listtables.js +36 -0
  199. package/dist/commands/table/listtables.js.map +1 -0
  200. package/dist/commands/table/table.spec.js +304 -0
  201. package/dist/commands/table/table.spec.js.map +1 -0
  202. package/dist/commands/table/tablefile.js +195 -0
  203. package/dist/commands/table/tablefile.js.map +1 -0
  204. package/dist/commands/table/tablefile.spec.js +158 -0
  205. package/dist/commands/table/tablefile.spec.js.map +1 -0
  206. package/dist/commands/update.js +21 -0
  207. package/dist/commands/update.js.map +1 -1
  208. package/dist/commands/version/archive-unarchive-version.js +4 -2
  209. package/dist/commands/version/archive-unarchive-version.js.map +1 -1
  210. package/dist/commands/version/archive-unarchive-version.spec.js +6 -1
  211. package/dist/commands/version/archive-unarchive-version.spec.js.map +1 -1
  212. package/dist/commands/version/listversions.js +2 -0
  213. package/dist/commands/version/listversions.js.map +1 -1
  214. package/dist/common/UserGroupId.js +9 -4
  215. package/dist/common/UserGroupId.js.map +1 -1
  216. package/dist/common/UserGroupId.spec.js +5 -0
  217. package/dist/common/UserGroupId.spec.js.map +1 -1
  218. package/dist/constants.js +37 -143
  219. package/dist/constants.js.map +1 -1
  220. package/dist/index.js +487 -90
  221. package/dist/index.js.map +1 -1
  222. package/dist/logger.js +42 -9
  223. package/dist/logger.js.map +1 -1
  224. package/dist/session.js +56 -0
  225. package/dist/session.js.map +1 -0
  226. package/dist/session.spec.js +103 -0
  227. package/dist/session.spec.js.map +1 -0
  228. package/dist/setup-core/briefing.js +176 -0
  229. package/dist/setup-core/briefing.js.map +1 -0
  230. package/dist/setup-core/credstore.js +415 -0
  231. package/dist/setup-core/credstore.js.map +1 -0
  232. package/dist/setup-core/credstore.spec.js +238 -0
  233. package/dist/setup-core/credstore.spec.js.map +1 -0
  234. package/dist/setup-core/environments.js +267 -0
  235. package/dist/setup-core/environments.js.map +1 -0
  236. package/dist/setup-core/flow.e2e.js +165 -0
  237. package/dist/setup-core/flow.e2e.js.map +1 -0
  238. package/dist/setup-core/flow.js +765 -0
  239. package/dist/setup-core/flow.js.map +1 -0
  240. package/dist/setup-core/flow.spec.js +1348 -0
  241. package/dist/setup-core/flow.spec.js.map +1 -0
  242. package/dist/setup-core/folderconfig.js +283 -0
  243. package/dist/setup-core/folderconfig.js.map +1 -0
  244. package/dist/setup-core/git.js +97 -0
  245. package/dist/setup-core/git.js.map +1 -0
  246. package/dist/setup-core/host.js +77 -0
  247. package/dist/setup-core/host.js.map +1 -0
  248. package/dist/setup-core/importconnections.js +470 -0
  249. package/dist/setup-core/importconnections.js.map +1 -0
  250. package/dist/setup-core/importconnections.spec.js +594 -0
  251. package/dist/setup-core/importconnections.spec.js.map +1 -0
  252. package/dist/setup-core/liveness.js +94 -0
  253. package/dist/setup-core/liveness.js.map +1 -0
  254. package/dist/setup-core/liveness.spec.js +59 -0
  255. package/dist/setup-core/liveness.spec.js.map +1 -0
  256. package/dist/setup-core/localpublisherconfig.js +26 -0
  257. package/dist/setup-core/localpublisherconfig.js.map +1 -0
  258. package/dist/setup-core/localpublisherconfig.spec.js +29 -0
  259. package/dist/setup-core/localpublisherconfig.spec.js.map +1 -0
  260. package/dist/setup-core/mcpconfig.js +198 -0
  261. package/dist/setup-core/mcpconfig.js.map +1 -0
  262. package/dist/setup-core/mcpconfig.spec.js +205 -0
  263. package/dist/setup-core/mcpconfig.spec.js.map +1 -0
  264. package/dist/setup-core/packagemanifest.js +55 -0
  265. package/dist/setup-core/packagemanifest.js.map +1 -0
  266. package/dist/setup-core/ports.js +182 -0
  267. package/dist/setup-core/ports.js.map +1 -0
  268. package/dist/setup-core/ports.spec.js +173 -0
  269. package/dist/setup-core/ports.spec.js.map +1 -0
  270. package/dist/setup-core/publisherconfig.js +268 -0
  271. package/dist/setup-core/publisherconfig.js.map +1 -0
  272. package/dist/setup-core/publisherconfig.oracle.js +166 -0
  273. package/dist/setup-core/publisherconfig.oracle.js.map +1 -0
  274. package/dist/setup-core/publisherconfig.spec.js +277 -0
  275. package/dist/setup-core/publisherconfig.spec.js.map +1 -0
  276. package/dist/setup-core/publisherversion.js +26 -0
  277. package/dist/setup-core/publisherversion.js.map +1 -0
  278. package/dist/setup-core/readiness.spec.js +161 -0
  279. package/dist/setup-core/readiness.spec.js.map +1 -0
  280. package/dist/setup-core/readylines.js +169 -0
  281. package/dist/setup-core/readylines.js.map +1 -0
  282. package/dist/setup-core/readylines.spec.js +70 -0
  283. package/dist/setup-core/readylines.spec.js.map +1 -0
  284. package/dist/setup-core/refresh.js +348 -0
  285. package/dist/setup-core/refresh.js.map +1 -0
  286. package/dist/setup-core/refresh.spec.js +501 -0
  287. package/dist/setup-core/refresh.spec.js.map +1 -0
  288. package/dist/setup-core/skills.js +279 -0
  289. package/dist/setup-core/skills.js.map +1 -0
  290. package/dist/setup-core/skills.spec.js +334 -0
  291. package/dist/setup-core/skills.spec.js.map +1 -0
  292. package/dist/setup-core/supervisor.js +879 -0
  293. package/dist/setup-core/supervisor.js.map +1 -0
  294. package/dist/setup-core/supervisor.spec.js +833 -0
  295. package/dist/setup-core/supervisor.spec.js.map +1 -0
  296. package/dist/setup-core/writefile.js +61 -0
  297. package/dist/setup-core/writefile.js.map +1 -0
  298. package/dist/setup-core/writefile.spec.js +68 -0
  299. package/dist/setup-core/writefile.spec.js.map +1 -0
  300. package/dist/utils.js +409 -3
  301. package/dist/utils.js.map +1 -1
  302. package/dist/utils.spec.js +373 -2
  303. package/dist/utils.spec.js.map +1 -1
  304. package/dist/versioncheck-refresh.js +18 -0
  305. package/dist/versioncheck-refresh.js.map +1 -0
  306. package/dist/versioncheck.js +324 -0
  307. package/dist/versioncheck.js.map +1 -0
  308. package/dist/versioncheck.spec.js +587 -0
  309. package/dist/versioncheck.spec.js.map +1 -0
  310. package/node_modules/@credibledata/cli-auth/dist/index.d.ts +86 -0
  311. package/node_modules/@credibledata/cli-auth/dist/index.js +102 -0
  312. package/node_modules/@credibledata/cli-auth/package.json +19 -0
  313. package/package.json +18 -6
  314. package/.github/workflows/build.yml +0 -23
  315. package/.mocharc.json +0 -10
  316. package/.prettierignore +0 -2
  317. package/.prettierrc +0 -4
  318. package/README-DEV.md +0 -40
  319. package/coverage/coverage-summary.json +0 -40
  320. package/coverage/tmp/coverage-2152-1789496974457-0.json +0 -1
  321. package/coverage/tmp/coverage-2153-1789496954404-0.json +0 -1
  322. package/docker/Dockerfile.ci +0 -18
  323. package/docker-compose.yml +0 -18
  324. package/eslint.config.mjs +0 -45
  325. package/generate-client.sh +0 -27
  326. package/mocha.setup.ts +0 -4
  327. package/openapitools.json +0 -10
  328. package/src/client/.openapi-generator/FILES +0 -9
  329. package/src/client/.openapi-generator/VERSION +0 -1
  330. package/src/client/.openapi-generator-ignore +0 -23
  331. package/src/client/api.ts +0 -15999
  332. package/src/client/base.ts +0 -86
  333. package/src/client/common.ts +0 -150
  334. package/src/client/configuration.ts +0 -110
  335. package/src/client/git_push.sh +0 -57
  336. package/src/client/index.ts +0 -18
  337. package/src/clientconfiguration.spec.ts +0 -615
  338. package/src/clientconfiguration.ts +0 -364
  339. package/src/commands/add.ts +0 -191
  340. package/src/commands/connection/createconnections.spec.ts +0 -413
  341. package/src/commands/connection/createconnections.ts +0 -109
  342. package/src/commands/connection/deleteconnection.spec.ts +0 -189
  343. package/src/commands/connection/deleteconnection.ts +0 -57
  344. package/src/commands/connection/listconnections.spec.ts +0 -132
  345. package/src/commands/connection/listconnections.ts +0 -58
  346. package/src/commands/environment/createenvironment.spec.ts +0 -249
  347. package/src/commands/environment/createenvironment.ts +0 -73
  348. package/src/commands/environment/deleteenvironment.spec.ts +0 -152
  349. package/src/commands/environment/deleteenvironment.ts +0 -48
  350. package/src/commands/environment/getenvironment.spec.ts +0 -110
  351. package/src/commands/environment/getenvironment.ts +0 -43
  352. package/src/commands/environment/listenvironments.spec.ts +0 -123
  353. package/src/commands/environment/listenvironments.ts +0 -67
  354. package/src/commands/environment/setenvironment.spec.ts +0 -63
  355. package/src/commands/environment/setenvironment.ts +0 -14
  356. package/src/commands/environment/updateenvironment.spec.ts +0 -386
  357. package/src/commands/environment/updateenvironment.ts +0 -168
  358. package/src/commands/get.ts +0 -153
  359. package/src/commands/group/addmember.spec.ts +0 -257
  360. package/src/commands/group/addmember.ts +0 -85
  361. package/src/commands/group/creategroup.spec.ts +0 -146
  362. package/src/commands/group/creategroup.ts +0 -54
  363. package/src/commands/group/deletegroup.spec.ts +0 -120
  364. package/src/commands/group/deletegroup.ts +0 -45
  365. package/src/commands/group/getgroup.spec.ts +0 -129
  366. package/src/commands/group/getgroup.ts +0 -47
  367. package/src/commands/group/listgroups.spec.ts +0 -137
  368. package/src/commands/group/listgroups.ts +0 -45
  369. package/src/commands/group/removemember.spec.ts +0 -224
  370. package/src/commands/group/removemember.ts +0 -75
  371. package/src/commands/groupaccesstoken/createToken.spec.ts +0 -211
  372. package/src/commands/groupaccesstoken/createToken.ts +0 -72
  373. package/src/commands/groupaccesstoken/deleteToken.spec.ts +0 -147
  374. package/src/commands/groupaccesstoken/deleteToken.ts +0 -29
  375. package/src/commands/groupaccesstoken/groupContainer.ts +0 -83
  376. package/src/commands/groupaccesstoken/listTokens.spec.ts +0 -147
  377. package/src/commands/groupaccesstoken/listTokens.ts +0 -29
  378. package/src/commands/legacy.ts +0 -5
  379. package/src/commands/list.ts +0 -326
  380. package/src/commands/materialization/cancelrun.ts +0 -70
  381. package/src/commands/materialization/getindex.ts +0 -55
  382. package/src/commands/materialization/getmaterialization.ts +0 -57
  383. package/src/commands/materialization/getpreaggregate.ts +0 -58
  384. package/src/commands/materialization/getrun.ts +0 -55
  385. package/src/commands/materialization/listindexes.ts +0 -69
  386. package/src/commands/materialization/listmaterializations.ts +0 -53
  387. package/src/commands/materialization/listpreaggregates.ts +0 -74
  388. package/src/commands/materialization/listruns.ts +0 -77
  389. package/src/commands/materialization/rerun.ts +0 -123
  390. package/src/commands/misc/login.spec.ts +0 -371
  391. package/src/commands/misc/login.ts +0 -343
  392. package/src/commands/misc/logout.spec.ts +0 -32
  393. package/src/commands/misc/logout.ts +0 -9
  394. package/src/commands/misc/loopbackOAuth.ts +0 -127
  395. package/src/commands/misc/set-access-token.spec.ts +0 -95
  396. package/src/commands/misc/set-access-token.ts +0 -32
  397. package/src/commands/package/deletepackage.spec.ts +0 -164
  398. package/src/commands/package/deletepackage.ts +0 -58
  399. package/src/commands/package/listpackages.spec.ts +0 -163
  400. package/src/commands/package/listpackages.ts +0 -74
  401. package/src/commands/package/publish.spec.ts +0 -642
  402. package/src/commands/package/publish.ts +0 -236
  403. package/src/commands/package/updatepackage.spec.ts +0 -319
  404. package/src/commands/package/updatepackage.ts +0 -95
  405. package/src/commands/permission/createpermission.spec.ts +0 -507
  406. package/src/commands/permission/createpermission.ts +0 -181
  407. package/src/commands/permission/deletepermission.ts +0 -117
  408. package/src/commands/permission/getpermission.ts +0 -115
  409. package/src/commands/permission/listpermissions.ts +0 -101
  410. package/src/commands/permission/scope.ts +0 -180
  411. package/src/commands/rm.ts +0 -146
  412. package/src/commands/set.ts +0 -25
  413. package/src/commands/update.ts +0 -107
  414. package/src/commands/version/archive-unarchive-version.spec.ts +0 -456
  415. package/src/commands/version/archive-unarchive-version.ts +0 -108
  416. package/src/commands/version/listversions.spec.ts +0 -138
  417. package/src/commands/version/listversions.ts +0 -45
  418. package/src/common/UserGroupId.spec.ts +0 -115
  419. package/src/common/UserGroupId.ts +0 -137
  420. package/src/constants.spec.ts +0 -111
  421. package/src/constants.ts +0 -228
  422. package/src/index.ts +0 -378
  423. package/src/logger.spec.ts +0 -158
  424. package/src/logger.ts +0 -90
  425. package/src/polyfills/file.polyfill.ts +0 -6
  426. package/src/utils.spec.ts +0 -135
  427. package/src/utils.ts +0 -115
  428. package/src/validator.spec.ts +0 -51
  429. package/src/validator.ts +0 -44
  430. package/tsconfig.json +0 -17
package/dist/index.js CHANGED
@@ -13,8 +13,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  return (mod && mod.__esModule) ? mod : { "default": mod };
14
14
  };
15
15
  Object.defineProperty(exports, "__esModule", { value: true });
16
+ /* eslint-disable @typescript-eslint/no-explicit-any */
16
17
  const axios_1 = __importDefault(require("axios"));
17
18
  const commander_1 = require("commander");
19
+ const logger_1 = require("./logger");
18
20
  const kleur_1 = __importDefault(require("kleur"));
19
21
  const omelette_1 = __importDefault(require("omelette"));
20
22
  const package_json_1 = __importDefault(require("../package.json"));
@@ -25,6 +27,9 @@ const list_1 = require("./commands/list");
25
27
  const login_1 = require("./commands/misc/login");
26
28
  const logout_1 = require("./commands/misc/logout");
27
29
  const set_access_token_1 = require("./commands/misc/set-access-token");
30
+ const setup_1 = require("./commands/misc/setup");
31
+ const status_1 = require("./commands/misc/status");
32
+ const token_1 = require("./commands/misc/token");
28
33
  const listpackages_1 = require("./commands/package/listpackages");
29
34
  const publish_1 = require("./commands/package/publish");
30
35
  const listenvironments_1 = require("./commands/environment/listenvironments");
@@ -35,6 +40,30 @@ const archive_unarchive_version_1 = require("./commands/version/archive-unarchiv
35
40
  const rerun_1 = require("./commands/materialization/rerun");
36
41
  const cancelrun_1 = require("./commands/materialization/cancelrun");
37
42
  const constants_1 = require("./constants");
43
+ const folderconfig_1 = require("./setup-core/folderconfig");
44
+ const host_1 = require("./setup-core/host");
45
+ const credstore_1 = require("./setup-core/credstore");
46
+ const session_1 = require("./session");
47
+ const utils_1 = require("./utils");
48
+ const versioncheck_1 = require("./versioncheck");
49
+ // First, before anything reads argv or the store: the flag is spliced out so
50
+ // everything below sees the line without it. Under `status --json` the error
51
+ // keeps the JSON contract an agent parses.
52
+ try {
53
+ (0, utils_1.takeCellFlag)(process.argv);
54
+ }
55
+ catch (error) {
56
+ if ((0, utils_1.invokedCommand)(process.argv) === "status" &&
57
+ process.argv.includes("--json")) {
58
+ (0, status_1.printStatusError)(error);
59
+ }
60
+ else {
61
+ console.error(error instanceof Error ? error.message : String(error));
62
+ }
63
+ process.exit(1);
64
+ }
65
+ if ((0, utils_1.cellFlag)())
66
+ clientconfiguration_1.ClientConfiguration.scopeCommand({ deployment: (0, utils_1.cellFlag)() });
38
67
  const clientConfig = new clientconfiguration_1.ClientConfiguration();
39
68
  // `cred login` is the documented recovery path for a corrupt `~/.cred`, and the
40
69
  // one command whose job is to (re)establish config. The startup reads below —
@@ -45,15 +74,169 @@ const clientConfig = new clientconfiguration_1.ClientConfiguration();
45
74
  // command stays fail-loud (the thrown error still names `cred login` as the
46
75
  // fix) so a stray read never silently resets a user's tokens.
47
76
  if ((0, login_1.isLoginInvocation)(process.argv)) {
48
- clientConfig.recoverIfCorrupt();
77
+ // Report it. `recoverIfCorrupt` returns the backup path instead of logging,
78
+ // because setup-core owns no logger — which makes saying so the caller's job.
79
+ // Dropping it would reset a user's tokens and move their file with no output
80
+ // at all, which is the silent-loss-of-state that #5133 exists to prevent.
81
+ const backupPath = clientConfig.recoverIfCorrupt();
82
+ if (backupPath) {
83
+ console.error(`Your credential file was unreadable, so it has been reset to defaults. ` +
84
+ `The previous one is at ${backupPath}.`);
85
+ }
86
+ }
87
+ // Every other command reads ~/.cred at startup too (the axios baseURL and the
88
+ // command registration below), so a corrupt file throws here, before Commander
89
+ // has parsed anything. Read it once up front and answer then: `status --json`
90
+ // with the JSON error an agent parses, anything else with the message, which
91
+ // names `cred login` as the fix. Either beats a stack trace.
92
+ try {
93
+ clientConfig.loadConfig();
94
+ }
95
+ catch (error) {
96
+ if ((0, utils_1.invokedCommand)(process.argv) === "status" &&
97
+ process.argv.includes("--json")) {
98
+ (0, status_1.printStatusError)(error);
99
+ process.exit(1);
100
+ }
101
+ if (!(error instanceof credstore_1.InvalidConfigError))
102
+ throw error;
103
+ console.error(error.message);
104
+ process.exit(1);
105
+ }
106
+ const targetLines = [];
107
+ // Before anything below reads the store: in a directory `cred init` pinned,
108
+ // every org- and environment-scoped command acts on the pin, as publish does.
109
+ // Without this, `cred ls connections` there listed the global organization's
110
+ // connections under a `cred status` that named the pinned one.
111
+ try {
112
+ (0, setup_1.scopeCommandToDirectory)(process.argv
113
+ .slice(2)
114
+ .filter((arg) => !arg.startsWith("-"))
115
+ .slice(0, 2)
116
+ .join(" ") || undefined, process.cwd(),
117
+ // Held until the hook below: the scope has to be set before the commands
118
+ // register, but the line reads as "about to act", so it waits for a command
119
+ // that will actually run, not `--help` or one Commander rejects.
120
+ (line) => targetLines.push(line));
49
121
  }
122
+ catch (error) {
123
+ console.error(error instanceof Error ? error.message : String(error));
124
+ process.exit(1);
125
+ }
126
+ // A fresh store each time, so a scope set above is the one read.
50
127
  const getActiveEnvironment = () => {
51
- return clientConfig.getEnvironment();
128
+ return new clientconfiguration_1.ClientConfiguration().getEnvironment();
52
129
  };
53
130
  axios_1.default.defaults.baseURL = constants_1.controlPlanesByEnv[getActiveEnvironment()];
54
131
  const cli = commander_1.program
132
+ .name("cred")
55
133
  .version(package_json_1.default.version, "-V, --cli-version", "Output the CLI version number")
56
- .description(kleur_1.default.green(constants_1.ASCII_TITLE));
134
+ .option("--non-interactive", "Never prompt. A question that needs an answer exits 2 and names the flag that answers it on stderr. Implied when stdin is not a terminal or CI is set.")
135
+ .description(kleur_1.default.green(constants_1.ASCII_TITLE))
136
+ .addHelpText("after", `
137
+ Driving cred from a script or an agent: every question has a flag. Without a
138
+ terminal (piped stdin, CI, --non-interactive) nothing prompts — a command that
139
+ needs an answer exits 2 and names the flag and the options on stderr. Logs go
140
+ to stderr; only data (\`cred status --json\`, \`cred ls ...\`) goes to stdout.
141
+ \`cred init\` writes .mcp.json, which an agent reads only when its session
142
+ starts: read \`cred init --help\` before running it. Each command's --help
143
+ documents it in full (\`cred publish --help\`, \`cred get --help\`).
144
+
145
+ Cells: credentials are kept per cell (${constants_1.ALL_ENVIRONMENTS.join(", ")}). \`--cell
146
+ <cell>\`, before or after any command, picks the cell for that one command, over
147
+ this directory's pin and your global cell, and is never saved. \`cred set cell
148
+ <cell>\` saves the global cell. \`cred login --force\` signs in again as someone
149
+ else; \`cred logout\` signs out of one cell.`);
150
+ // The agent contract, in one place: a prompt that could not be asked exits 2 —
151
+ // distinct from 1, so a script can tell "needs input" from "failed" — with the
152
+ // flag and the options already on stderr (`NeedsInputError` writes them). This
153
+ // catches the rejections Commander's `parseAsync` does not: actions that fire a
154
+ // promise without awaiting it.
155
+ process.on("unhandledRejection", (reason) => {
156
+ exitOnFailure(reason);
157
+ });
158
+ // Any other failure prints just its message and exits 1. Under `--debug` (or
159
+ // CRED_LOG_LEVEL=debug) it prints the stack instead, so a TypeError in an
160
+ // action can still be traced.
161
+ function exitOnFailure(error) {
162
+ if (error instanceof host_1.NeedsInputError) {
163
+ console.error(error.message);
164
+ process.exit(error.exitCode);
165
+ }
166
+ if (error instanceof Error) {
167
+ console.error(logger_1.debugRequested && error.stack ? error.stack : error.message);
168
+ }
169
+ else {
170
+ console.error(String(error));
171
+ }
172
+ process.exit(1);
173
+ }
174
+ // Refresh the access token before any command runs, rather than at each of the
175
+ // ~25 call sites that read it. Until now the CLI persisted a refresh token and
176
+ // never exchanged it, so every session died at the access token's `exp` and the
177
+ // user saw it as an unexplained 401.
178
+ //
179
+ // These commands are exempt:
180
+ // - `login` / `set-access-token` establish credentials, and `logout` destroys
181
+ // them, so refreshing first is pointless or actively wrong;
182
+ // - `token` runs its own refresh so it can report the outcome on stderr while
183
+ // keeping stdout to just the token;
184
+ // - `status` exists to *report* that you are not logged in. Refusing to run it
185
+ // for the reason it was invoked to explain would be the worst possible
186
+ // answer to "why isn't this working?";
187
+ // - `init` / `dev` resolve credentials themselves, and must: this hook exits
188
+ // the process on `logged-out`, which on a brand-new machine is exactly the
189
+ // state `cred init` exists to fix. Exiting here would make the one command
190
+ // a new user is told to type fail with "Run `cred login`" — the error
191
+ // message `ensureLoggedIn` was written to avoid. They also resolve a
192
+ // per-directory deployment first, so they need a differently-scoped
193
+ // credential store than the module-level one this hook holds;
194
+ // - `set ...` only writes the local config and sends no request, so on dev it
195
+ // worked with an expired session. Refreshing first would make it exit 1.
196
+ // - `publish --dry-run` (and `add version --dry-run`) uploads nothing and is
197
+ // documented as needing no login; see `needsNoSession`.
198
+ const COMMANDS_WITHOUT_REFRESH = new Set([
199
+ "login",
200
+ "logout",
201
+ "token",
202
+ "set-access-token",
203
+ "status",
204
+ "init",
205
+ "dev",
206
+ ]);
207
+ cli.hook("preAction", (_thisCommand, actionCommand) => __awaiter(void 0, void 0, void 0, function* () {
208
+ var _a;
209
+ for (const line of targetLines.splice(0))
210
+ console.error(line);
211
+ // Before the exemptions below: `init`, `dev` and `status` are the commands
212
+ // most worth a notice. On stderr, so `cred token` and `--json` stay clean.
213
+ const { notice } = (0, versioncheck_1.checkForUpdate)({ current: package_json_1.default.version });
214
+ if (notice)
215
+ console.error(notice);
216
+ if (COMMANDS_WITHOUT_REFRESH.has(actionCommand.name()) ||
217
+ ((_a = actionCommand.parent) === null || _a === void 0 ? void 0 : _a.name()) === "set") {
218
+ return;
219
+ }
220
+ // `add connection`, not `connection`: the name alone is shared by `get`,
221
+ // `rm` and the other groups.
222
+ const parent = actionCommand.parent;
223
+ const commandPath = parent && parent !== cli
224
+ ? `${parent.name()} ${actionCommand.name()}`
225
+ : actionCommand.name();
226
+ if ((0, setup_1.needsNoSession)(commandPath, actionCommand.opts()))
227
+ return;
228
+ try {
229
+ (0, setup_1.refuseWriteUnderIgnoredPin)(commandPath, process.cwd());
230
+ }
231
+ catch (error) {
232
+ console.error(error instanceof Error ? error.message : String(error));
233
+ process.exit(1);
234
+ }
235
+ yield (0, session_1.refreshSessionOrExit)(
236
+ // A fresh store, not the module-level one built before the scope was
237
+ // set: a scoped command sends the pinned deployment's token.
238
+ (0, setup_1.credStoreToRefresh)(commandPath, process.cwd(), new clientconfiguration_1.ClientConfiguration()));
239
+ }));
57
240
  // Nested CRUD commands for resource management
58
241
  (0, get_1.registerGetCommands)(cli, getActiveEnvironment());
59
242
  (0, list_1.registerListCommands)(cli, getActiveEnvironment());
@@ -62,35 +245,85 @@ const cli = commander_1.program
62
245
  (0, add_1.registerAddCommands)(cli, getActiveEnvironment());
63
246
  (0, set_1.registerSetCommands)(cli);
64
247
  // Root commands
65
- cli.command("publish")
66
- .description("Publish a new version of the package.")
248
+ // Every command against a Credible resource reads `cred <verb> <resource>`, the
249
+ // way the API is `<method> /…/<resource>`: publish is `add version` (POST a
250
+ // package version), archive is `update version --archived` (PATCH its
251
+ // archiveStatus), rerun is `add run`, cancel is `update run --cancel`. The verb
252
+ // set is the one `get`/`ls`/`add`/`update`/`rm` already use, so a new resource
253
+ // needs no new verb. The old top-level verbs (publish, archive, unarchive,
254
+ // rerun, cancel-run) stay exactly as they were, listed and without a warning:
255
+ // scripts, skills and docs use them, and each new form runs the same code.
256
+ const findGroup = (name) => {
257
+ const group = cli.commands.find((command) => command.name() === name);
258
+ if (!group)
259
+ throw new Error(`no '${name}' command group registered`);
260
+ return group;
261
+ };
262
+ const addGroup = findGroup("add");
263
+ const updateGroup = findGroup("update");
264
+ const publishOptions = (command) => command
67
265
  .option("--debug")
68
266
  .option("-y, --yes", "Skip confirmation.")
69
267
  .option("--replication <replication_count>", "The number of replicas to create.", (v) => (v === undefined ? undefined : parseInt(v)), undefined)
70
- .option("--set-latest", "Set this version as the latest version of the package.", false)
71
- .action((options) => {
72
- (0, publish_1.publish)(constants_1.controlPlanesByEnv[getActiveEnvironment()], options.replicationCount, options.debug, options.yes, options.setLatest);
73
- });
74
- cli.command("archive")
75
- .description("Archive a version of a package.")
76
- .argument("<packageName>", "The name of the package to archive the version of.")
77
- .argument("<versionId>", "The id of the version to archive.")
78
- .option("--debug")
79
- .option("-y, --yes", "Skip confirmation.")
80
- .action((packageName, versionId, options) => {
81
- (0, archive_unarchive_version_1.archiveVersion)(constants_1.controlPlanesByEnv[getActiveEnvironment()], packageName, versionId, options.debug, options.yes);
82
- });
83
- cli.command("unarchive")
84
- .description("Unarchive a version of a package.")
85
- .argument("<packageName>", "The name of the package to unarchive the version of.")
86
- .argument("<versionId>", "The id of the version to unarchive.")
268
+ .option("--set-latest", "Make this version latest now, before its indexes and materialized tables are built. Without it, a package with auto-promote on (the default) makes it latest once they are built.", false)
269
+ .option("--dry-run", "List the files that would be uploaded and the ones left out, and upload nothing. Needs no login.", false)
270
+ .option("--json", "Machine-readable: one JSON document on stdout (the link, whether it became latest, what was left out).", false)
271
+ .addHelpText("after", (0, publish_1.publishHelpText)());
272
+ const publishAction = (options) => {
273
+ // Publish where this directory is pinned, not where the last unrelated
274
+ // command left the global deployment.
275
+ const target = (0, setup_1.resolveTarget)(process.cwd());
276
+ const identity = (0, setup_1.pinnedIdentity)(process.cwd(), target.credStore);
277
+ // Always, not only for a pin: see `describeIdentity`. An upload is not a
278
+ // step to take on an unstated assumption about which environment it is
279
+ // going to. stderr, because stdout is the command's data.
280
+ console.error(`Publishing to ${(0, setup_1.describeIdentity)(target.deployment, identity, identity.from, target.from)}`);
281
+ (0, publish_1.publish)(constants_1.controlPlanesByEnv[target.deployment],
282
+ // Known bug, kept as dev has it: `--replication` lands on
283
+ // `options.replication`, so this is always undefined and the flag is
284
+ // ignored. Honoring it made a local publish with `--replication 2` hang
285
+ // and roll back, so fixing it is its own change.
286
+ options.replicationCount, options.debug, options.yes, options.setLatest, target.credStore, identity, {
287
+ deployment: target.deployment,
288
+ dryRun: options.dryRun,
289
+ json: options.json,
290
+ });
291
+ };
292
+ publishOptions(addGroup
293
+ .command("version")
294
+ .description("Publish a new version of the package. Same as `cred publish`.")).action(publishAction);
295
+ publishOptions(cli.command("publish").description("Publish a new version of the package.")).action(publishAction);
296
+ const archiveAction = (archived) => (packageName, versionId, options) => (archived ? archive_unarchive_version_1.archiveVersion : archive_unarchive_version_1.unarchiveVersion)(constants_1.controlPlanesByEnv[getActiveEnvironment()], packageName, versionId, options.debug, options.yes);
297
+ updateGroup
298
+ .command("version")
299
+ .description("Update a version of a package: archive it, or bring it back.")
300
+ .argument("<packageName>", "The package the version belongs to.")
301
+ .argument("<versionId>", "The version to update (e.g. 0.1.21).")
302
+ .option("--archived", "Archive the version.")
303
+ .option("--no-archived", "Unarchive the version.")
87
304
  .option("--debug")
88
305
  .option("-y, --yes", "Skip confirmation.")
89
306
  .action((packageName, versionId, options) => {
90
- (0, archive_unarchive_version_1.unarchiveVersion)(constants_1.controlPlanesByEnv[getActiveEnvironment()], packageName, versionId, options.debug, options.yes);
307
+ if (options.archived === undefined) {
308
+ logger_1.logger.error("Nothing to update. Pass --archived to archive the version, or --no-archived to unarchive it.");
309
+ process.exitCode = 1;
310
+ return;
311
+ }
312
+ return archiveAction(options.archived)(packageName, versionId, options);
91
313
  });
92
- cli.command("rerun")
93
- .description("Trigger an on-demand run (rebuild/refresh) for a package version. Defaults to a full run (all sources, indexes and pre-aggregations); use --source/--dimension/--measure/--model-file to scope it to a single unit.")
314
+ for (const [verb, archived] of [
315
+ ["archive", true],
316
+ ["unarchive", false],
317
+ ]) {
318
+ cli.command(verb)
319
+ .description(`${verb === "archive" ? "Archive" : "Unarchive"} a version of a package.`)
320
+ .argument("<packageName>", `The name of the package to ${verb} the version of.`)
321
+ .argument("<versionId>", `The id of the version to ${verb}.`)
322
+ .option("--debug")
323
+ .option("-y, --yes", "Skip confirmation.")
324
+ .action(archiveAction(archived));
325
+ }
326
+ const runOptions = (command) => command
94
327
  .argument("<packageName>", "The name of the package to run.")
95
328
  .argument("<versionId>", "The version to (re)build (e.g. 0.1.21).")
96
329
  .option("--debug")
@@ -99,15 +332,36 @@ cli.command("rerun")
99
332
  .option("--dimension <dimension>", "Scope the run to a single indexed dimension.")
100
333
  .option("--measure <measure>", "Scope the run to a single pre-aggregated measure. Rebuilds the rollup serving it; add --source when the measure is declared at more than one grain.")
101
334
  .option("--model-file <modelFilePath>", "Disambiguate a dimension/source defined in more than one model file.")
102
- .option("--include-upstream", "Also force-rebuild the target's upstream persisted closure (only meaningful with --source/--dimension/--measure).", false)
103
- .action((packageName, versionId, options) => {
104
- (0, rerun_1.rerun)(constants_1.controlPlanesByEnv[getActiveEnvironment()], packageName, versionId, {
105
- source: options.source,
106
- dimension: options.dimension,
107
- measure: options.measure,
108
- modelFile: options.modelFile,
109
- includeUpstream: options.includeUpstream,
110
- }, options.debug, options.yes);
335
+ .option("--include-upstream", "Also force-rebuild the target's upstream persisted closure (only meaningful with --source/--dimension/--measure).", false);
336
+ const runAction = (packageName, versionId, options) => (0, rerun_1.rerun)(constants_1.controlPlanesByEnv[getActiveEnvironment()], packageName, versionId, {
337
+ source: options.source,
338
+ dimension: options.dimension,
339
+ measure: options.measure,
340
+ modelFile: options.modelFile,
341
+ includeUpstream: options.includeUpstream,
342
+ }, options.debug, options.yes);
343
+ runOptions(addGroup
344
+ .command("run")
345
+ .description("Start a run (rebuild/refresh) of a package version. Defaults to a full run (all sources, indexes and pre-aggregations); use --source/--dimension/--measure/--model-file to scope it to a single unit.")).action(runAction);
346
+ runOptions(cli
347
+ .command("rerun")
348
+ .description("Trigger an on-demand run (rebuild/refresh) for a package version. Defaults to a full run (all sources, indexes and pre-aggregations); use --source/--dimension/--measure/--model-file to scope it to a single unit.")).action(runAction);
349
+ const cancelAction = (packageName, runId, options) => (0, cancelrun_1.cancelRun)(constants_1.controlPlanesByEnv[getActiveEnvironment()], packageName, runId, options.debug, options.yes);
350
+ updateGroup
351
+ .command("run")
352
+ .description("Update a run: cancel it while it is in flight.")
353
+ .argument("<packageName>", "The name of the package that owns the run.")
354
+ .argument("<runId>", "The id of the run.")
355
+ .option("--cancel", "Cancel the run.")
356
+ .option("--debug")
357
+ .option("-y, --yes", "Skip confirmation.")
358
+ .action((packageName, runId, options) => {
359
+ if (!options.cancel) {
360
+ logger_1.logger.error("Nothing to update. Pass --cancel to cancel the run.");
361
+ process.exitCode = 1;
362
+ return;
363
+ }
364
+ return cancelAction(packageName, runId, options);
111
365
  });
112
366
  cli.command("cancel-run")
113
367
  .description("Cancel an in-flight (non-terminal) run.")
@@ -115,61 +369,161 @@ cli.command("cancel-run")
115
369
  .argument("<runId>", "The id of the run to cancel.")
116
370
  .option("--debug")
117
371
  .option("-y, --yes", "Skip confirmation.")
118
- .action((packageName, runId, options) => {
119
- (0, cancelrun_1.cancelRun)(constants_1.controlPlanesByEnv[getActiveEnvironment()], packageName, runId, options.debug, options.yes);
120
- });
372
+ .action(cancelAction);
121
373
  cli.command("login")
122
374
  .description("Login into Credible service.")
123
- .argument("<organizationName>", "The organization to login to.")
375
+ .argument("[organizationName]", "The organization to login to. Omit it to pick from the organizations you belong to after signing in.")
124
376
  .option("-c, --cluster <cluster>", "Target cluster: 'gcp' or 'aws'. Defaults to the org's default cluster (gcp for most orgs).")
125
- .action((organizationName, options) => {
126
- var _a;
127
- const orgConfig = (0, constants_1.getCliOrgConfig)(organizationName);
128
- const currentEnv = clientConfig.getEnvironment();
129
- // Determine the target cluster. Precedence:
130
- // 1. Explicit -c/--cluster flag.
131
- // 2. The org's defaultCluster (from CliOrgConfig), if registered.
132
- // 3. The cluster of the current activeEnvironment — i.e. don't touch
133
- // anything. Unregistered orgs with no flag stay wherever the user
134
- // already set themselves via ms2ad set-env.
135
- let cluster;
136
- if (options.cluster !== undefined) {
137
- const requested = String(options.cluster).toLowerCase();
138
- if (requested !== "gcp" && requested !== "aws") {
139
- console.error(`Invalid --cluster value '${options.cluster}'. Must be 'gcp' or 'aws'.`);
140
- process.exit(1);
141
- }
142
- cluster = requested;
377
+ .option("--no-browser", "Print the sign-in URL without opening a browser. Implied without a terminal.")
378
+ .option("--force", "Sign in again even if you are already signed in to this cell, to sign in as someone else.")
379
+ .action((organizationName, options) => __awaiter(void 0, void 0, void 0, function* () {
380
+ var _a, _b;
381
+ // `--cell`, then the directory's pin, then the global value. A login in a directory pinned to another deployment signs
382
+ // in to that deployment, so the tokens land where that directory reads.
383
+ const resolved = (0, folderconfig_1.resolveDeployment)({
384
+ cwd: process.cwd(),
385
+ globalDefault: clientConfig.getEnvironment(),
386
+ flag: (0, utils_1.cellFlag)(),
387
+ });
388
+ const currentEnv = resolved.deployment;
389
+ let target;
390
+ try {
391
+ target = (0, login_1.resolveLoginTarget)(currentEnv, organizationName, options.cluster === undefined ? undefined : String(options.cluster),
392
+ // The pin says which deployment is meant, so an org's own default
393
+ // cluster must not pick another one.
394
+ { pinned: resolved.from !== "global" });
143
395
  }
144
- else if (orgConfig) {
145
- cluster = orgConfig.defaultCluster;
396
+ catch (error) {
397
+ console.error(error instanceof Error ? error.message : String(error));
398
+ process.exit(1);
146
399
  }
147
- else {
148
- cluster = constants_1.CLUSTER_BY_ENVIRONMENT[currentEnv];
400
+ // A login to another deployment would store its tokens in a slot nothing
401
+ // in this directory reads, since the pin keeps naming its own. It looked
402
+ // like it worked, and every command here still said "not logged in".
403
+ if (resolved.from === "flag" && target.targetEnv !== currentEnv) {
404
+ console.error(`--cell ${currentEnv} names the cell, so a login to ${target.targetEnv} would not be used by it. Drop --cell, or drop -c / pass an organization that lives on ${currentEnv}.`);
405
+ process.exit(1);
149
406
  }
150
- // Unregistered orgs implicitly support only gcp; registered orgs declare
151
- // their cluster list. Reject anything else.
152
- const supportedClusters = (_a = orgConfig === null || orgConfig === void 0 ? void 0 : orgConfig.supportedClusters) !== null && _a !== void 0 ? _a : [
153
- "gcp",
154
- ];
155
- if (!supportedClusters.includes(cluster)) {
156
- console.error(`Organization '${organizationName}' is not available on the ${cluster} cluster.`);
407
+ if (resolved.from === "folder" && target.targetEnv !== currentEnv) {
408
+ const root = (_b = (_a = (0, folderconfig_1.findFolderConfig)(process.cwd())) === null || _a === void 0 ? void 0 : _a.root) !== null && _b !== void 0 ? _b : process.cwd();
409
+ console.error(`This directory is pinned to the ${currentEnv} deployment, so a login to ${target.targetEnv} here would not be used by anything in it. ` +
410
+ `Run the login from outside ${root}, or, to move this directory to ${target.targetEnv}, set "deployment": "${target.targetEnv}" in ${root}/.credible/config.json and run \`cred init\` there.`);
157
411
  process.exit(1);
158
412
  }
159
- // Respect a previously-set activeEnvironment if it's already on the chosen
160
- // cluster (e.g. `ms2ad set-env staging && cred login demo` stays on staging).
161
- // Only flip envs when the current one is on a different cluster.
162
- const targetEnv = constants_1.CLUSTER_BY_ENVIRONMENT[currentEnv] === cluster
163
- ? currentEnv
164
- : constants_1.DEFAULT_ENVIRONMENT_BY_CLUSTER[cluster];
165
- if (targetEnv !== currentEnv) {
166
- clientConfig.setEnvironment(targetEnv);
413
+ // `resolveLoginTarget` has already refused everything it can refuse, so
414
+ // this write only happens for a login that is going to be attempted — and
415
+ // only when the deployment came from the global value: a directory pin
416
+ // must not move every other terminal's default.
417
+ if (resolved.from === "global" && target.targetEnv !== currentEnv) {
418
+ clientConfig.setEnvironment(target.targetEnv);
167
419
  }
168
- (0, login_1.login)(organizationName, constants_1.controlPlanesByEnv[targetEnv], undefined, cluster);
169
- });
420
+ // Awaited, with its own catch. The `unhandledRejection` handler above
421
+ // would still report a rejection here with the right exit code, so this
422
+ // is not the difference between working and broken — it is the
423
+ // difference between a failure handled where it happened and one handled
424
+ // by a global net. Two things follow from awaiting. `parseAsync`
425
+ // otherwise returns while login is still running, because an action body
426
+ // that fires a promise without returning it resolves immediately; and
427
+ // login is the command with partial state to reason about (tokens are
428
+ // persisted before the organization is resolved), so its error path
429
+ // deserves to be visible next to that, not several files away.
430
+ try {
431
+ yield (0, login_1.login)(organizationName, constants_1.controlPlanesByEnv[target.targetEnv], undefined, target.cluster,
432
+ // Explicit rather than inherited from the write above, so where the
433
+ // tokens land does not depend on that statement having run.
434
+ target.targetEnv, { force: options.force });
435
+ }
436
+ catch (error) {
437
+ console.error(error instanceof Error ? error.message : String(error));
438
+ process.exit(error instanceof host_1.NeedsInputError ? 2 : 1);
439
+ }
440
+ if (resolved.from === "flag") {
441
+ const warning = (0, login_1.bareCellWarning)(currentEnv, (0, folderconfig_1.resolveDeployment)({
442
+ cwd: process.cwd(),
443
+ globalDefault: clientConfig.getGlobalEnvironment(),
444
+ }));
445
+ if (warning)
446
+ console.error(warning);
447
+ }
448
+ }));
449
+ cli.command("token")
450
+ .description("Print a fresh access token on stdout, refreshing it first if needed. Machine-facing: nothing else is written to stdout.")
451
+ .action(() => __awaiter(void 0, void 0, void 0, function* () {
452
+ yield (0, token_1.printToken)();
453
+ }));
454
+ cli.command("init")
455
+ .description("Set up this directory for local Malloy modeling: log in if needed, wire the directory to a Credible environment, and start a local Publisher serving it.")
456
+ .option("--no-start", "Write the configuration but do not start the publisher.")
457
+ .option("--no-open", "Start the publisher but do not open a browser.")
458
+ .option("-d, --directory <path>", "Set up this directory instead of the current one.")
459
+ .option("-o, --organization <name>", "Use this organization instead of asking. Also re-pins the directory.")
460
+ .option("-e, --environment <name>", "Use this Credible environment instead of asking. Also re-pins the directory.")
461
+ .option("--create-environment", "With --environment: create the environment if the organization does not have it yet.", false)
462
+ .option("--skills <replace|keep|none>", "What to do with skills already in .claude/skills/ that cred did not install (a create-malloy-package directory): replace them with Credible's set, keep both, or install none. Asked once when omitted.")
463
+ .option("--package <dir>", "In a directory whose publisher.config.json lists several packages (a create-malloy-package workspace), which one the local publisher serves. Remembered for cred dev.")
464
+ .option("--debug", "Show all of the local Publisher's output here, not only its errors.")
465
+ .option("--port <number>", "Serve on this port, and MCP on the port 40 above it, instead of the remembered pair or 4000/4040. Remembered, and .mcp.json follows. Use it when another Publisher holds the ports.")
466
+ .option("--connections <all|none|names>", "Which connections from a local publisher.config.json to copy into Credible: all, none, or a comma-separated list. Naming them is the consent to send their credentials, so no question is asked.")
467
+ .addHelpText("after", `
468
+ init writes .mcp.json, CLAUDE.md and AGENTS.md here. An agent reads those only
469
+ when its session starts, so one already running here gets no local \`malloy\`
470
+ tools from this run. Without --no-start, init then runs the publisher in the
471
+ foreground until Ctrl-C.
472
+
473
+ If you are an agent running init yourself:
474
+ 1. cred init --no-start -e <environment> --connections <all|none|names> --skills <replace|keep|none>
475
+ 2. Ask the user to restart you in this directory (for Claude Code: exit,
476
+ run \`claude\` here, and trust the project's MCP servers).
477
+ 3. In the new session: \`cred dev --no-open\` in the background, then poll
478
+ \`cred status --json\` until publisher.ready is true. If it exits saying
479
+ another Publisher holds the ports, re-run it with the --port it names.
480
+ Simplest of all: the user runs \`cred init\` before starting the agent.`)
481
+ .action((options) => __awaiter(void 0, void 0, void 0, function* () {
482
+ yield (0, setup_1.setup)({
483
+ start: options.start,
484
+ open: options.open,
485
+ directory: options.directory,
486
+ organization: options.organization,
487
+ environment: options.environment,
488
+ connections: options.connections,
489
+ createEnvironment: options.createEnvironment,
490
+ skills: options.skills,
491
+ package: options.package,
492
+ port: options.port,
493
+ });
494
+ }));
495
+ cli.command("dev")
496
+ .description("Re-enter the local Publisher session for this directory (foreground; Ctrl-C stops it).")
497
+ .option("--no-open", "Do not open a browser.")
498
+ .option("-o, --organization <name>", "Switch this directory to another organization, and remember it.")
499
+ .option("-e, --environment <name>", "Switch this directory to another Credible environment, and remember it.")
500
+ .option("--create-environment", "With --environment: create the environment if the organization does not have it yet.", false)
501
+ .option("--package <dir>", "Serve this listed package instead of the one this directory is pinned to, and remember it.")
502
+ .option("--skills <replace|keep|none>", "What to do with skills in .claude/skills/ that cred did not install, when it has to ask. none is remembered, and replace or keep undoes it.")
503
+ .option("--port <number>", "Serve on this port, and MCP on the port 40 above it, instead of the remembered pair or 4000/4040. Remembered, and .mcp.json follows. Use it when another Publisher holds the ports.")
504
+ .option("-y, --yes", "Use the organization and environment this directory is pinned to without asking. Implied without a terminal.", false)
505
+ .option("--debug", "Show all of the local Publisher's output here, not only its errors.")
506
+ .action((options) => __awaiter(void 0, void 0, void 0, function* () {
507
+ yield (0, setup_1.dev)({
508
+ open: options.open,
509
+ organization: options.organization,
510
+ environment: options.environment,
511
+ createEnvironment: options.createEnvironment,
512
+ package: options.package,
513
+ skills: options.skills,
514
+ yes: options.yes,
515
+ port: options.port,
516
+ });
517
+ }));
170
518
  cli.command("logout")
171
- .description("Resets Credible service credentials")
172
- .action(logout_1.logout);
519
+ .description("Sign out of one cell: the one --cell names, else this directory's pin, else your global cell. Other cells stay signed in.")
520
+ .action(() => {
521
+ (0, logout_1.logout)((0, folderconfig_1.resolveDeployment)({
522
+ cwd: process.cwd(),
523
+ globalDefault: clientConfig.getGlobalEnvironment(),
524
+ flag: (0, utils_1.cellFlag)(),
525
+ }));
526
+ });
173
527
  cli.command("set-access-token")
174
528
  .description("Set a service account JWT token for CLI authentication")
175
529
  .argument("<jwtToken>", "The JWT token to use for authentication")
@@ -178,22 +532,36 @@ cli.command("set-access-token")
178
532
  (0, set_access_token_1.setAccessToken)(jwtToken, options.organization);
179
533
  });
180
534
  cli.command("status")
181
- .description("Shows the cell this CLI targets, and the active organization and environment.")
182
- .action(() => {
183
- const config = new clientconfiguration_1.ClientConfiguration();
184
- config.printStatus();
185
- });
535
+ .description("Shows the active organization, Credible environment, and token freshness — and, in a directory cred init wired, whether its publisher is running.")
536
+ .option("--json", "Machine-readable: one JSON document on stdout, nothing else. Poll publisher.ready after starting `cred dev` in the background.", false)
537
+ .action((options) => __awaiter(void 0, void 0, void 0, function* () {
538
+ yield (0, status_1.printStatus)({ json: options.json });
539
+ }));
186
540
  const complete = (0, omelette_1.default)("credible").tree({
187
541
  // CRUD commands
188
542
  get: [
189
543
  "environment",
190
544
  "project",
545
+ "package",
546
+ "version",
191
547
  "group",
192
548
  "permission",
193
549
  "materialization",
194
550
  "index",
195
551
  "run",
196
552
  ],
553
+ list: [
554
+ "environment",
555
+ "connection",
556
+ "package",
557
+ "version",
558
+ "materialization",
559
+ "index",
560
+ "run",
561
+ "group",
562
+ "group-access-token",
563
+ "permission",
564
+ ],
197
565
  ls: [
198
566
  "environment",
199
567
  "project",
@@ -207,7 +575,7 @@ const complete = (0, omelette_1.default)("credible").tree({
207
575
  "group-access-token",
208
576
  "permission",
209
577
  ],
210
- update: ["environment", "project", "package"],
578
+ update: ["environment", "project", "package", "version", "run"],
211
579
  rm: [
212
580
  "environment",
213
581
  "project",
@@ -222,15 +590,20 @@ const complete = (0, omelette_1.default)("credible").tree({
222
590
  "environment",
223
591
  "project",
224
592
  "connection",
593
+ "version",
594
+ "run",
225
595
  "group",
226
596
  "member",
227
597
  "group-access-token",
228
598
  "permission",
229
599
  ],
230
600
  // Misc commands
231
- set: ["environment", "project"],
601
+ set: ["environment", "project", "cell"],
232
602
  login: [],
233
603
  logout: [],
604
+ token: [],
605
+ init: [],
606
+ dev: [],
234
607
  "set-access-token": [],
235
608
  status: [],
236
609
  publish: [],
@@ -249,7 +622,10 @@ complete.onAsync("$3", (_a) => __awaiter(void 0, [_a], void 0, function* ({ repl
249
622
  "rm project",
250
623
  ];
251
624
  if (environmentRelatedCommands.some((cmd) => line.includes(cmd))) {
252
- reply((0, listenvironments_1.listEnvironments)(constants_1.controlPlanesByEnv[getActiveEnvironment()], false).then((result) => result.projects.map((environment) => environment.name)));
625
+ reply((0, listenvironments_1.listEnvironments)(constants_1.controlPlanesByEnv[getActiveEnvironment()], false).then((result) => result.environments.map((environment) => environment.name)));
626
+ }
627
+ if (line.includes("set cell")) {
628
+ reply(Promise.resolve(constants_1.ALL_ENVIRONMENTS));
253
629
  }
254
630
  const packageRelatedCommands = ["rm package", "ls version"];
255
631
  if (packageRelatedCommands.some((cmd) => line.includes(cmd))) {
@@ -257,15 +633,36 @@ complete.onAsync("$3", (_a) => __awaiter(void 0, [_a], void 0, function* ({ repl
257
633
  }
258
634
  }));
259
635
  complete.next(() => {
260
- commander_1.program.parse(process.argv);
636
+ // `parseAsync`, not `parse`, now that a `preAction` hook is async. `parse`
637
+ // does work — Commander still chains the hook before the action — but it
638
+ // returns before either has finished and hands back nothing to attach a
639
+ // catch to, so a rejection anywhere in that chain surfaces as an unhandled
640
+ // promise rejection and a stack dump. `ensureFreshTokens` is written not to
641
+ // throw, but that is a contract a future edit can break quietly.
642
+ commander_1.program.parseAsync(process.argv).catch(exitOnFailure);
261
643
  });
644
+ // omelette finds the shell init file to edit from $SHELL, and throws when it is
645
+ // unset (a container started without a login shell: CI runner pods, `docker
646
+ // run`) or names a shell other than bash, zsh or fish. The CLI is installed by
647
+ // then and only completion needs the shell, so completion is skipped rather
648
+ // than failing the install.
649
+ function skipCompletionOnError(setup) {
650
+ try {
651
+ setup();
652
+ }
653
+ catch (error) {
654
+ console.log(`Skipping shell completion setup: ${error.message}`);
655
+ }
656
+ }
262
657
  if (~process.argv.indexOf("--cleanup")) {
263
- complete.cleanupShellInitFile();
658
+ skipCompletionOnError(() => complete.cleanupShellInitFile());
264
659
  process.exit(0);
265
660
  }
266
661
  if (~process.argv.indexOf("--install")) {
267
- complete.setupShellInitFile();
662
+ // Printed first: setupShellInitFile() exits the process itself once it has
663
+ // written the init file.
268
664
  console.log("CLI installed successfully!");
665
+ skipCompletionOnError(() => complete.setupShellInitFile());
269
666
  process.exit(0);
270
667
  }
271
668
  complete.init();