@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/README.md CHANGED
@@ -8,4 +8,109 @@ This directory contains a simple CLI to create, update, delete, and list project
8
8
 
9
9
  For complete usage instructions and command reference, see the official documentation at [https://www.credibledata.com/docs/platform-admin/cli](https://www.credibledata.com/docs/platform-admin/cli).
10
10
 
11
- ```
11
+ ### Driving `cred` from an agent
12
+
13
+ `cred` is built to be run by a coding agent (Claude Code, Codex, Cursor) as well
14
+ as by a person. The contract:
15
+
16
+ - **Every question has a flag.** A picker is the human way to answer it; the
17
+ flag is the other way — `cred login <organization>` answers the organization
18
+ picker, `cred publish --yes` answers the publish confirmation, and
19
+ `cred init -o <org> -e <env> [--create-environment]
20
+ [--connections all|none|a,b] [--skills replace|keep|none] [--package <dir>]
21
+ --no-start --no-open` runs the whole setup with no prompt.
22
+ - **Without a terminal, nothing prompts.** When stdin is not a TTY, `CI` or
23
+ `CRED_NON_INTERACTIVE` is set (to anything but `0` or `false`), or
24
+ `--non-interactive` is passed, a command that needs an answer exits **2**
25
+ and prints the flag and the options on stderr, e.g.
26
+ `Cannot ask "Which environment?" without a terminal. Pass --environment <name>. Options: prod-bars, staging.`
27
+ Exit 0 is success, 1 is failure, 2 is "needs input".
28
+ - **The update notice can be turned off.** When a newer `cred` is on npm, commands
29
+ print one line on stderr saying so. `CI`, `CRED_NO_UPDATE_CHECK`, or
30
+ `NO_UPDATE_NOTIFIER` set (to anything but `0` or `false`) silences it and stops
31
+ the once-a-day registry check.
32
+ - **Logs go to stderr; data goes to stdout.** `cred status --json` and
33
+ `cred ls ...` print one JSON document you can parse. `cred status --json`
34
+ reports `organization` and `environment` (what `cred publish` here would act
35
+ on: `--cell`'s cell, else the directory's pin, else `~/.cred`), `deployment`,
36
+ `controlPlane`, `deploymentFrom` (`flag` when `--cell` chose the deployment,
37
+ `folder` when this directory's pin did, else `global`), `ignoredPin` (the pin's
38
+ cell, only when `--cell` names another), `token` (`valid`, `kind`,
39
+ `expiresInSeconds`), and in a directory `cred init` wired, `directory` (the
40
+ pin, with its `deployment`) and `publisher`
41
+ (`running`, `ready`, `packages`, `uiUrl`, `mcpUrl`) — or `{ "error": ... }`
42
+ with exit 1 when it cannot read your setup.
43
+ - **Every command says where it acts, and acts where the directory is pinned.**
44
+ In a directory `cred init` set up, org- and environment-scoped commands
45
+ (`ls`, `get`, `add`, `update`, `rm`, `publish`) use the directory's
46
+ deployment, organization and environment; elsewhere, `~/.cred`'s. Each prints
47
+ `Using <org>/<env> on <cell>, pinned in .credible/config.json.` (or
48
+ `set by --cell`, or `from your global settings`) on stderr, and every
49
+ confirmation repeats it. The cell is always named.
50
+ An agent should check that line before anything that changes state.
51
+ `cred set environment` and `cred set cell <cell>` always change the global
52
+ settings; `cred --cell <cell> init` re-pins a directory. `--cell` naming another cell than the pin makes reads act
53
+ on that cell, and makes writes (`publish`, `add connection`) and `cred dev`
54
+ refuse; `cred --cell <cell> init` is the explicit re-pin.
55
+ - **`cred publish` can be previewed and read back.** `--dry-run` lists the
56
+ files it would upload (stdout) and the ones it leaves out (stderr), uploads
57
+ nothing and needs no login. `--json` prints one document: `organization`,
58
+ `environment`, `package`, `version`, `url` (the version in the app),
59
+ `latest` (`now`, `when-built` or `no`), `latestVersion`, `excluded` and
60
+ `response` (the server's reply as sent). With `--dry-run`, `--json` prints
61
+ `dryRun` (`true`), `package`, `version`, `included` and `excluded` instead.
62
+ A `.credignore` beside `publisher.json` leaves more files out,
63
+ one path or glob per line (`notes.md`, `tests/`, `/docs`), matched regardless
64
+ of case (`secrets/` also leaves out `Secrets/`). A nested `.credignore` is not
65
+ read, and every file or folder named `.credignore`, at any depth, is always
66
+ left out of the upload. It can never put back a file the fixed list leaves
67
+ out, and a publish stops if it leaves out `publisher.json`. Warnings the
68
+ server raises on the publish print on stderr after the link; with `--json`
69
+ they are only in `response.warnings`. `cred get version <package> <version>`
70
+ shows whether a version has built (`buildStatus`: `BUILDING`, then `READY`,
71
+ `FAILED` or `UNSUPPORTED`) and is waiting to become latest
72
+ (`promoteWhenReady`). Add `--wait` to read again every 10 seconds until it
73
+ reaches one of those three and print that; it exits 1 on `FAILED` or when
74
+ `--timeout <minutes>` (default 30; it needs `--wait`) runs out. `cred get package <package>`
75
+ shows the latest.
76
+ - **`cred token` prints a usable access token and nothing else**, renewing it
77
+ first when it is within two minutes of expiring. It exits 1 rather than print
78
+ a token that has already expired.
79
+ - **`cred login` needs the human once.** It prints a URL and a code; relay them
80
+ and wait — it polls until they sign in. Credentials are kept per cell, and
81
+ `--cell` is never saved: after `cred --cell staging login`, pass `--cell
82
+ staging` on every command or run `cred set cell staging` (the login says so
83
+ when your global cell differs). Already signed in to the cell, `cred login
84
+ <org>` only switches organization and says which cell and whether anything
85
+ changed; `cred login --force` signs in again, as someone else, without a
86
+ logout. `cred logout` signs out of one cell, the way `login` resolves it
87
+ (`--cell`, then the directory's pin, then the global cell), names it, and
88
+ leaves the other cells signed in; given a cell with nothing to clear it lists
89
+ the cells that hold credentials and the `cred --cell <cell> logout` to run.
90
+ - **`cred dev` is a foreground process.** Start it in the background with
91
+ `--no-open`, then poll `cred status --json` until `publisher.ready` is true
92
+ (`running` alone can be a server whose only package failed to compile).
93
+ - **Ports.** A directory keeps the pair it used last, else 4000/4040, else a
94
+ free pair derived from its path. In a directory with its own
95
+ `publisher.config.json`, another Publisher on 4000/4040 is refused rather
96
+ than stepped around, and the error names a free port. Re-run with
97
+ `--port <that port>` (on `init` or `dev`): MCP takes the port 40 above it,
98
+ the pair is remembered, and `.mcp.json` follows.
99
+
100
+ The three journeys, as commands:
101
+
102
+ ```bash
103
+ # 1. I run a local Publisher against my own warehouse; move to Credible.
104
+ cred init -e my-env --create-environment --connections my_warehouse --no-start
105
+ cred dev --no-open & # then poll: cred status --json
106
+ cred publish -y # publisher.config.json is never uploaded
107
+
108
+ # 2. I run a local Publisher over CSV / DuckDB files; publish the package.
109
+ # (a create-malloy-package directory: setup serves the package it lists,
110
+ # and --skills says what to do with the scaffolder's skills)
111
+ cred init -e my-env --create-environment --connections none --skills replace --no-start
112
+ cd shop && cred publish -y # the data files travel inside the package
113
+
114
+ # 3. I use Credible and want to model locally with Claude Code.
115
+ cred init -e prod-bars --no-start # skills, .mcp.json, CLAUDE.md, publisher config
116
+ cred dev --no-open & # local publisher proxies to the real warehouse
@@ -0,0 +1,548 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const chai_1 = require("chai");
16
+ const child_process_1 = require("child_process");
17
+ const fs_1 = __importDefault(require("fs"));
18
+ const os_1 = __importDefault(require("os"));
19
+ const path_1 = __importDefault(require("path"));
20
+ const environments_1 = require("./setup-core/environments");
21
+ /**
22
+ * The agent contract, checked against the real CLI.
23
+ *
24
+ * Every other spec exercises the guard through stubs. This one spawns the CLI
25
+ * with a piped stdin — exactly what an agent's shell tool gives it — and asserts
26
+ * the three things an agent depends on: a question it cannot answer exits 2 and
27
+ * names the flag; stdout of a `--json` command is one JSON document and nothing
28
+ * else; and a plain failure is still exit 1. No network: the cases below stop
29
+ * before any request.
30
+ */
31
+ function jwt(claims) {
32
+ const part = (value) => Buffer.from(JSON.stringify(value)).toString("base64url");
33
+ return `${part({ alg: "HS256" })}.${part(claims)}.sig`;
34
+ }
35
+ describe("the agent contract, against the real CLI", function () {
36
+ // ts-node compiles the CLI on each spawn.
37
+ this.timeout(90000);
38
+ let home;
39
+ let workDir;
40
+ beforeEach(() => {
41
+ home = fs_1.default.mkdtempSync(path_1.default.join(os_1.default.tmpdir(), "cred-home-"));
42
+ workDir = fs_1.default.mkdtempSync(path_1.default.join(os_1.default.tmpdir(), "cred-work-"));
43
+ fs_1.default.writeFileSync(path_1.default.join(home, ".cred"), JSON.stringify({
44
+ configPerEnvironment: {
45
+ production: {
46
+ organization: "acme",
47
+ project: "prod-bars",
48
+ jwtAccessToken: jwt({
49
+ aud: "https://ms2data.us.auth0.com/api/v2/",
50
+ exp: Math.floor(Date.now() / 1000) + 3600,
51
+ }),
52
+ },
53
+ },
54
+ activeEnvironment: "production",
55
+ }));
56
+ });
57
+ afterEach(() => {
58
+ fs_1.default.rmSync(home, { recursive: true, force: true });
59
+ fs_1.default.rmSync(workDir, { recursive: true, force: true });
60
+ });
61
+ function cred(args, env = {}) {
62
+ const result = (0, child_process_1.spawnSync)(process.execPath, [
63
+ path_1.default.join(__dirname, "..", "node_modules", "ts-node", "dist", "bin.js"),
64
+ "--transpile-only",
65
+ path_1.default.join(__dirname, "index.ts"),
66
+ ...args,
67
+ ], {
68
+ cwd: workDir,
69
+ // A pipe, not a TTY: the shape an agent's shell tool provides.
70
+ stdio: ["pipe", "pipe", "pipe"],
71
+ env: Object.assign(Object.assign(Object.assign({}, process.env), { HOME: home, CI: undefined, NO_COLOR: "1",
72
+ // No registry call from a test.
73
+ CRED_NO_UPDATE_CHECK: "1" }), env),
74
+ encoding: "utf-8",
75
+ // The failure this spec exists to catch is a prompt waiting on a
76
+ // pipe forever. Without a deadline that is a hung test run, not a
77
+ // red one.
78
+ timeout: 30000,
79
+ });
80
+ if (result.signal) {
81
+ throw new Error(`cred ${args.join(" ")} did not exit within 30s (killed with ${result.signal}) — a prompt is waiting on a pipe. stderr so far:\n${result.stderr}`);
82
+ }
83
+ return {
84
+ status: result.status,
85
+ stdout: result.stdout,
86
+ stderr: result.stderr,
87
+ };
88
+ }
89
+ it("status --json puts one JSON document on stdout and nothing else", () => {
90
+ const run = cred(["status", "--json"]);
91
+ (0, chai_1.expect)(run.status, run.stderr).to.equal(0);
92
+ const report = JSON.parse(run.stdout);
93
+ (0, chai_1.expect)(report.organization).to.equal("acme");
94
+ (0, chai_1.expect)(report.environment).to.equal("prod-bars");
95
+ (0, chai_1.expect)(report.token.valid).to.equal(true);
96
+ (0, chai_1.expect)(report.directory).to.equal(null);
97
+ (0, chai_1.expect)(report.publisher).to.equal(null);
98
+ });
99
+ describe("--cell", () => {
100
+ // Each cell has its own Auth0 audience, and the `sub` tells the tokens apart.
101
+ const token = (cell) => jwt({
102
+ aud: environments_1.auth0ConfigsByEnv[cell].audience,
103
+ sub: cell,
104
+ exp: Math.floor(Date.now() / 1000) + 3600,
105
+ });
106
+ beforeEach(() => {
107
+ const config = JSON.parse(fs_1.default.readFileSync(path_1.default.join(home, ".cred"), "utf-8"));
108
+ config.configPerEnvironment.staging = {
109
+ organization: "acme",
110
+ project: "stage-bars",
111
+ jwtAccessToken: token("staging"),
112
+ };
113
+ config.configPerEnvironment["aws-dev"] = {
114
+ organization: "acme",
115
+ project: "aws-bars",
116
+ jwtAccessToken: token("aws-dev"),
117
+ };
118
+ fs_1.default.writeFileSync(path_1.default.join(home, ".cred"), JSON.stringify(config));
119
+ });
120
+ const activeEnvironment = () => JSON.parse(fs_1.default.readFileSync(path_1.default.join(home, ".cred"), "utf-8"))
121
+ .activeEnvironment;
122
+ it("names the cell before or after the subcommand, and leaves activeEnvironment alone", () => {
123
+ for (const args of [
124
+ ["--cell", "staging", "status", "--json"],
125
+ ["status", "--json", "--cell=staging"],
126
+ ]) {
127
+ const run = cred(args);
128
+ (0, chai_1.expect)(run.status, run.stderr).to.equal(0);
129
+ const report = JSON.parse(run.stdout);
130
+ (0, chai_1.expect)(report.deployment).to.equal("staging");
131
+ (0, chai_1.expect)(report.deploymentFrom).to.equal("flag");
132
+ (0, chai_1.expect)(report.environment).to.equal("stage-bars");
133
+ }
134
+ (0, chai_1.expect)(activeEnvironment()).to.equal("production");
135
+ });
136
+ it("prints the token of the cell it names", () => {
137
+ const run = cred(["--cell", "staging", "token"]);
138
+ (0, chai_1.expect)(run.status, run.stderr).to.equal(0);
139
+ const claims = JSON.parse(Buffer.from(run.stdout.trim().split(".")[1], "base64url").toString());
140
+ (0, chai_1.expect)(claims.sub).to.equal("staging");
141
+ (0, chai_1.expect)(activeEnvironment()).to.equal("production");
142
+ });
143
+ it("refuses a login that would land on another cell, and leaves activeEnvironment alone", () => {
144
+ const run = cred([
145
+ "--cell",
146
+ "staging",
147
+ "login",
148
+ "acme",
149
+ "-c",
150
+ "aws",
151
+ "--no-browser",
152
+ ]);
153
+ (0, chai_1.expect)(run.status, run.stdout).to.equal(1);
154
+ (0, chai_1.expect)(run.stderr).to.not.contain(" at ");
155
+ (0, chai_1.expect)(activeEnvironment()).to.equal("production");
156
+ });
157
+ it("refuses a write in a directory pinned to another cell, naming init", () => {
158
+ fs_1.default.mkdirSync(path_1.default.join(workDir, ".credible"));
159
+ fs_1.default.writeFileSync(path_1.default.join(workDir, ".credible", "config.json"), JSON.stringify({ deployment: "staging", organization: "acme" }));
160
+ const run = cred(["--cell", "aws-dev", "publish"]);
161
+ (0, chai_1.expect)(run.status).to.equal(1);
162
+ (0, chai_1.expect)(run.stderr).to.contain("--cell aws-dev init");
163
+ (0, chai_1.expect)(run.stderr).to.not.contain(" at ");
164
+ });
165
+ it("refuses a write whose option value hides it from the argv heuristic", () => {
166
+ fs_1.default.mkdirSync(path_1.default.join(workDir, ".credible"));
167
+ fs_1.default.writeFileSync(path_1.default.join(workDir, ".credible", "config.json"), JSON.stringify({ deployment: "staging", organization: "acme" }));
168
+ const run = cred([
169
+ "--cell",
170
+ "aws-dev",
171
+ "publish",
172
+ "--replication",
173
+ "2",
174
+ "--yes",
175
+ ]);
176
+ (0, chai_1.expect)(run.status).to.equal(1);
177
+ (0, chai_1.expect)(run.stderr).to.contain("--cell aws-dev init");
178
+ });
179
+ for (const flag of ["--help", "--dry-run"]) {
180
+ it(`does not refuse publish ${flag} in a directory pinned to another cell`, () => {
181
+ fs_1.default.mkdirSync(path_1.default.join(workDir, ".credible"));
182
+ fs_1.default.writeFileSync(path_1.default.join(workDir, ".credible", "config.json"), JSON.stringify({ deployment: "staging", organization: "acme" }));
183
+ const run = cred(["--cell", "aws-dev", "publish", flag]);
184
+ (0, chai_1.expect)(run.stderr).to.not.contain("--cell aws-dev init");
185
+ });
186
+ }
187
+ describe("logout", () => {
188
+ const signedIn = () => {
189
+ const config = JSON.parse(fs_1.default.readFileSync(path_1.default.join(home, ".cred"), "utf-8"));
190
+ return Object.entries(config.configPerEnvironment)
191
+ .filter(([, slot]) => slot.jwtAccessToken)
192
+ .map(([cell]) => cell);
193
+ };
194
+ it("signs out of the cell a directory pin names, and says so", () => {
195
+ fs_1.default.mkdirSync(path_1.default.join(workDir, ".credible"));
196
+ fs_1.default.writeFileSync(path_1.default.join(workDir, ".credible", "config.json"), JSON.stringify({ deployment: "aws-dev", organization: "acme" }));
197
+ const run = cred(["logout"]);
198
+ (0, chai_1.expect)(run.status, run.stderr).to.equal(0);
199
+ (0, chai_1.expect)(run.stderr).to.contain("Signed out of aws-dev (acme/aws-bars), pinned in .credible/config.json.");
200
+ (0, chai_1.expect)(signedIn()).to.have.members(["production", "staging"]);
201
+ (0, chai_1.expect)(activeEnvironment()).to.equal("production");
202
+ });
203
+ it("lets --cell win over the pin, and over the global cell", () => {
204
+ const run = cred(["--cell", "staging", "logout"]);
205
+ (0, chai_1.expect)(run.status, run.stderr).to.equal(0);
206
+ (0, chai_1.expect)(run.stderr).to.contain("Signed out of staging (acme/stage-bars), set by --cell.");
207
+ (0, chai_1.expect)(signedIn()).to.have.members(["production", "aws-dev"]);
208
+ });
209
+ it("lists the signed-in cells and the command when the resolved cell has nothing to clear", () => {
210
+ const run = cred(["--cell", "dev", "logout"]);
211
+ (0, chai_1.expect)(run.status, run.stderr).to.equal(0);
212
+ (0, chai_1.expect)(run.stderr).to.contain("Not signed in to dev");
213
+ (0, chai_1.expect)(run.stderr).to.contain("`cred --cell staging logout`");
214
+ (0, chai_1.expect)(signedIn()).to.have.members([
215
+ "production",
216
+ "staging",
217
+ "aws-dev",
218
+ ]);
219
+ });
220
+ });
221
+ it("rejects an unknown cell without a stack trace, as JSON under status --json", () => {
222
+ const plain = cred(["--cell", "bogus", "status"]);
223
+ (0, chai_1.expect)(plain.status).to.equal(1);
224
+ (0, chai_1.expect)(plain.stderr)
225
+ .to.contain("Unknown cell")
226
+ .and.to.contain("aws-dev");
227
+ (0, chai_1.expect)(plain.stderr).to.not.contain(" at ");
228
+ // Before the command too: the bad value must not be read as it.
229
+ const before = cred(["--cell", "bogus", "status", "--json"]);
230
+ (0, chai_1.expect)(JSON.parse(before.stdout).error).to.contain("Unknown cell");
231
+ const json = cred(["status", "--json", "--cell", "bogus"]);
232
+ (0, chai_1.expect)(json.status).to.equal(1);
233
+ (0, chai_1.expect)(JSON.parse(json.stdout).error).to.contain("Unknown cell");
234
+ });
235
+ it("lets two concurrent processes each report their own cell", () => __awaiter(this, void 0, void 0, function* () {
236
+ const run = (cell) => new Promise((resolve, reject) => {
237
+ const child = (0, child_process_1.spawn)(process.execPath, [
238
+ path_1.default.join(__dirname, "..", "node_modules", "ts-node", "dist", "bin.js"),
239
+ "--transpile-only",
240
+ path_1.default.join(__dirname, "index.ts"),
241
+ "status",
242
+ "--json",
243
+ "--cell",
244
+ cell,
245
+ ], {
246
+ cwd: workDir,
247
+ env: Object.assign(Object.assign({}, process.env), { HOME: home, CRED_NO_UPDATE_CHECK: "1" }),
248
+ });
249
+ let out = "";
250
+ child.stdout.on("data", (chunk) => (out += chunk));
251
+ child.on("error", reject);
252
+ child.on("close", () => resolve(JSON.parse(out).deployment));
253
+ });
254
+ (0, chai_1.expect)(yield Promise.all([run("staging"), run("aws-dev")])).to.eql([
255
+ "staging",
256
+ "aws-dev",
257
+ ]);
258
+ (0, chai_1.expect)(activeEnvironment()).to.equal("production");
259
+ }));
260
+ });
261
+ it("names a newer cred on stderr, leaving --json stdout alone", () => {
262
+ // A fresh cache, so no ask is started; under ts-node there is no compiled
263
+ // worker to start one anyway.
264
+ fs_1.default.mkdirSync(path_1.default.join(home, ".credible"));
265
+ fs_1.default.writeFileSync(path_1.default.join(home, ".credible", "version-check.json"), JSON.stringify({ checkedAt: Date.now(), latest: "999.0.0" }));
266
+ const run = cred(["status", "--json"], {
267
+ CRED_NO_UPDATE_CHECK: undefined,
268
+ NO_UPDATE_NOTIFIER: undefined,
269
+ });
270
+ (0, chai_1.expect)(run.status, run.stderr).to.equal(0);
271
+ (0, chai_1.expect)(run.stderr).to.contain("999.0.0 is available. Update: npm i -g @credibledata/cred-cli@latest");
272
+ (0, chai_1.expect)(JSON.parse(run.stdout).organization).to.equal("acme");
273
+ });
274
+ // A corrupt ~/.cred is what a caller runs `status` to find out about. The
275
+ // file is read at startup, before Commander parses anything, so without the
276
+ // startup guard this was a stack trace and an empty stdout.
277
+ it("status --json answers a corrupt ~/.cred with a JSON error", () => {
278
+ fs_1.default.writeFileSync(path_1.default.join(home, ".cred"), "{ not json");
279
+ const run = cred(["status", "--json"]);
280
+ (0, chai_1.expect)(run.status, run.stderr).to.equal(1);
281
+ const report = JSON.parse(run.stdout);
282
+ (0, chai_1.expect)(report.error).to.contain("cred login");
283
+ (0, chai_1.expect)(run.stderr).to.not.contain(" at ");
284
+ });
285
+ // The confirmation is the cheapest real prompt to reach: `cred publish`
286
+ // refuses it before any network call, so this exercises the whole path — a
287
+ // real spawn, a real pipe, `NeedsInputError`, exit 2, the flag on stderr —
288
+ // without a control plane.
289
+ it("a question it cannot ask exits 2 and names the flag", () => {
290
+ fs_1.default.writeFileSync(path_1.default.join(workDir, "publisher.json"), JSON.stringify({ name: "bars", version: "0.0.1" }));
291
+ const run = cred(["publish"]);
292
+ (0, chai_1.expect)(run.status, run.stderr).to.equal(2);
293
+ (0, chai_1.expect)(run.stderr).to.contain("--yes");
294
+ (0, chai_1.expect)(run.stderr).to.contain("without a terminal");
295
+ (0, chai_1.expect)(run.stdout).to.equal("");
296
+ });
297
+ // The preHook skips the session refresh for a dry run. Without that skip it
298
+ // demanded a login before the preview, which needs none.
299
+ it("publish --dry-run and add version --dry-run work with no login", () => {
300
+ fs_1.default.rmSync(path_1.default.join(home, ".cred"));
301
+ fs_1.default.writeFileSync(path_1.default.join(workDir, "publisher.json"), JSON.stringify({ name: "bars", version: "0.0.1" }));
302
+ for (const command of [["publish"], ["add", "version"]]) {
303
+ const run = cred([...command, "--dry-run"]);
304
+ (0, chai_1.expect)(run.status, `${command.join(" ")}: ${run.stderr}`).to.equal(0);
305
+ (0, chai_1.expect)(run.stdout.trim(), command.join(" ")).to.equal("publisher.json");
306
+ }
307
+ });
308
+ it("a picker it cannot show exits 2 and names the flag and the options", () => {
309
+ fs_1.default.writeFileSync(path_1.default.join(workDir, "publisher.config.json"), JSON.stringify({
310
+ connections: [
311
+ {
312
+ name: "warehouse",
313
+ type: "postgres",
314
+ postgresConnection: { host: "db", password: "hunter2" },
315
+ },
316
+ { name: "other", type: "postgres", postgresConnection: {} },
317
+ ],
318
+ }));
319
+ const run = cred(["add", "connection", "--from-publisher-config"]);
320
+ (0, chai_1.expect)(run.status, run.stderr).to.equal(2);
321
+ // This command's own flag. `--connections` is `cred init`'s, and
322
+ // following it here was an unknown-option error.
323
+ (0, chai_1.expect)(run.stderr).to.contain("Pass --name <connection> (once per connection).");
324
+ (0, chai_1.expect)(run.stderr).to.contain("Options: warehouse, other.");
325
+ (0, chai_1.expect)(run.stderr, "a credential never reaches the terminal").to.not.contain("hunter2");
326
+ (0, chai_1.expect)(run.stdout).to.equal("");
327
+ });
328
+ it("a plain failure is still exit 1, with the fix on stderr", () => {
329
+ const run = cred(["dev", "--no-open"]);
330
+ (0, chai_1.expect)(run.status).to.equal(1);
331
+ (0, chai_1.expect)(run.stderr).to.contain("Run `cred init` here first");
332
+ });
333
+ // These guards printed their error and exited 0, so a script read
334
+ // `get version --wait` with no environment set as a version that was READY.
335
+ it("a command that needs an environment exits 1 when none is set, with nothing on stdout", () => {
336
+ const config = JSON.parse(fs_1.default.readFileSync(path_1.default.join(home, ".cred"), "utf-8"));
337
+ delete config.configPerEnvironment.production.project;
338
+ fs_1.default.writeFileSync(path_1.default.join(home, ".cred"), JSON.stringify(config));
339
+ for (const args of [
340
+ ["get", "version", "bars", "0.0.1", "--wait"],
341
+ ["get", "run", "bars", "run-1"],
342
+ ["ls", "versions", "bars"],
343
+ ["ls", "connections"],
344
+ ]) {
345
+ const run = cred(args);
346
+ (0, chai_1.expect)(run.status, `cred ${args.join(" ")}: ${run.stderr}`).to.equal(1);
347
+ (0, chai_1.expect)(run.stderr).to.contain("Please, make sure to set an environment");
348
+ (0, chai_1.expect)(run.stdout).to.equal("");
349
+ }
350
+ });
351
+ // `debugRequested` reads argv directly, so a unit test cannot tell whether
352
+ // Commander accepts the flag the startup line tells the user to pass.
353
+ it("init and dev accept the --debug their startup line names", () => {
354
+ const dev = cred(["dev", "--no-open", "--debug"]);
355
+ (0, chai_1.expect)(dev.stderr).to.not.contain("unknown option");
356
+ (0, chai_1.expect)(dev.stderr).to.contain("Run `cred init` here first");
357
+ const init = cred(["init", "--no-start", "--no-open", "--debug"]);
358
+ (0, chai_1.expect)(init.stderr).to.not.contain("unknown option");
359
+ });
360
+ it("init refuses an unanswerable question before it writes anything", () => {
361
+ fs_1.default.writeFileSync(path_1.default.join(workDir, "publisher.config.json"), JSON.stringify({
362
+ connections: [
363
+ { name: "warehouse", type: "postgres", postgresConnection: {} },
364
+ ],
365
+ }));
366
+ const before = fs_1.default.readFileSync(path_1.default.join(home, ".cred"), "utf-8");
367
+ const run = cred(["init", "--no-start", "--no-open"]);
368
+ (0, chai_1.expect)(run.status, run.stderr).to.equal(2);
369
+ (0, chai_1.expect)(run.stderr).to.contain("Pass --connections <all|none|name,name>.");
370
+ (0, chai_1.expect)(fs_1.default.readdirSync(workDir)).to.eql(["publisher.config.json"]);
371
+ (0, chai_1.expect)(fs_1.default.readFileSync(path_1.default.join(home, ".cred"), "utf-8")).to.equal(before);
372
+ });
373
+ // A value the flag does not accept is a usage error, so it exits 2 like the
374
+ // prompts above, not 1 like a run that failed. The fix hint stays.
375
+ it("an invalid --skills or --timeout value exits 2 with the fix on stderr", () => {
376
+ const skills = cred([
377
+ "init",
378
+ "--no-start",
379
+ "--no-open",
380
+ "--skills",
381
+ "bogus",
382
+ ]);
383
+ (0, chai_1.expect)(skills.status, skills.stderr).to.equal(2);
384
+ (0, chai_1.expect)(skills.stderr).to.contain("--skills <replace|keep|none> was given 'bogus'.");
385
+ (0, chai_1.expect)(skills.stderr).to.contain("Fix: pass replace, keep, or none.");
386
+ (0, chai_1.expect)(skills.stdout).to.equal("");
387
+ const timeout = cred([
388
+ "get",
389
+ "version",
390
+ "bars",
391
+ "0.0.1",
392
+ "--wait",
393
+ "--timeout",
394
+ "abc",
395
+ ]);
396
+ (0, chai_1.expect)(timeout.status, timeout.stderr).to.equal(2);
397
+ (0, chai_1.expect)(timeout.stderr).to.contain("Invalid --timeout 'abc': expected a number of minutes above 0. Fix: --timeout 30");
398
+ // Without --wait, --timeout would be ignored, valid value or not.
399
+ const unwaited = cred([
400
+ "get",
401
+ "version",
402
+ "bars",
403
+ "0.0.1",
404
+ "--timeout",
405
+ "5",
406
+ ]);
407
+ (0, chai_1.expect)(unwaited.status, unwaited.stderr).to.equal(2);
408
+ (0, chai_1.expect)(unwaited.stderr).to.contain("--timeout only applies with --wait. Fix: add --wait, or drop --timeout.");
409
+ (0, chai_1.expect)(unwaited.stdout).to.equal("");
410
+ });
411
+ // The refresh before a command has to renew the login the command will
412
+ // send. `add version` runs publish's action, and checking the global login
413
+ // for it failed with "not logged in" in a directory whose own was fine.
414
+ it("refreshes the pinned deployment's login for publish and add version", () => {
415
+ fs_1.default.writeFileSync(path_1.default.join(home, ".cred"), JSON.stringify({
416
+ configPerEnvironment: {
417
+ staging: {
418
+ organization: "acme",
419
+ project: "prod-bars",
420
+ jwtAccessToken: jwt({
421
+ aud: "https://dev-ohaafogw5p8uyx1m.us.auth0.com/api/v2/",
422
+ exp: Math.floor(Date.now() / 1000) + 3600,
423
+ }),
424
+ },
425
+ },
426
+ activeEnvironment: "production",
427
+ }));
428
+ fs_1.default.mkdirSync(path_1.default.join(workDir, ".credible"));
429
+ fs_1.default.writeFileSync(path_1.default.join(workDir, ".credible", "config.json"), JSON.stringify({
430
+ deployment: "staging",
431
+ organization: "acme",
432
+ environment: "prod-bars",
433
+ }));
434
+ for (const command of [["publish"], ["add", "version"]]) {
435
+ const run = cred([...command, "--yes"]);
436
+ (0, chai_1.expect)(run.stderr, command.join(" ")).to.not.contain("not logged in");
437
+ (0, chai_1.expect)(run.stderr, command.join(" ")).to.contain("Publishing to acme/prod-bars on staging");
438
+ }
439
+ });
440
+ // Every org- and environment-scoped command acts on the pin, as publish
441
+ // does. They read only ~/.cred, so in a directory pinned to acme a
442
+ // `cred rm connection` would have deleted from the global organization.
443
+ it("acts on the pinned organization for every scoped command, and names it in the question", () => {
444
+ fs_1.default.writeFileSync(path_1.default.join(home, ".cred"), JSON.stringify({
445
+ configPerEnvironment: {
446
+ production: {
447
+ organization: "global-org",
448
+ project: "global-env",
449
+ jwtAccessToken: jwt({
450
+ aud: "https://ms2data.us.auth0.com/api/v2/",
451
+ exp: Math.floor(Date.now() / 1000) + 3600,
452
+ }),
453
+ },
454
+ staging: {
455
+ organization: "acme",
456
+ project: "prod-bars",
457
+ jwtAccessToken: jwt({
458
+ aud: "https://dev-ohaafogw5p8uyx1m.us.auth0.com/api/v2/",
459
+ exp: Math.floor(Date.now() / 1000) + 3600,
460
+ }),
461
+ },
462
+ },
463
+ activeEnvironment: "production",
464
+ }));
465
+ fs_1.default.mkdirSync(path_1.default.join(workDir, ".credible"));
466
+ fs_1.default.writeFileSync(path_1.default.join(workDir, ".credible", "config.json"), JSON.stringify({
467
+ deployment: "staging",
468
+ organization: "acme",
469
+ environment: "analytics",
470
+ }));
471
+ // No --yes and no terminal: it stops at the question, before any request.
472
+ const run = cred(["rm", "connection", "bq_demo"]);
473
+ (0, chai_1.expect)(run.status, run.stderr).to.equal(2);
474
+ (0, chai_1.expect)(run.stderr).to.contain("Using acme/analytics on staging, pinned in .credible/config.json.");
475
+ (0, chai_1.expect)(run.stderr).to.contain("(acme/analytics on staging)");
476
+ (0, chai_1.expect)(run.stderr).to.not.contain("global-org");
477
+ });
478
+ // The pin keeps naming its own deployment, so a login to another one would
479
+ // store tokens nothing in this directory reads.
480
+ it("refuses a login to another deployment inside a pinned directory", () => {
481
+ fs_1.default.mkdirSync(path_1.default.join(workDir, ".credible"));
482
+ fs_1.default.writeFileSync(path_1.default.join(workDir, ".credible", "config.json"), JSON.stringify({
483
+ deployment: "staging",
484
+ organization: "acme",
485
+ environment: "prod-bars",
486
+ }));
487
+ const before = fs_1.default.readFileSync(path_1.default.join(home, ".cred"), "utf-8");
488
+ const run = cred(["login", "videoamp", "-c", "aws", "--no-browser"]);
489
+ (0, chai_1.expect)(run.status, run.stderr).to.equal(1);
490
+ (0, chai_1.expect)(run.stderr).to.contain("This directory is pinned to the staging deployment, so a login to videoamp here would not be used by anything in it.");
491
+ (0, chai_1.expect)(run.stderr).to.contain(`set "deployment": "videoamp" in ${fs_1.default.realpathSync(workDir)}/.credible/config.json`);
492
+ (0, chai_1.expect)(fs_1.default.readFileSync(path_1.default.join(home, ".cred"), "utf-8")).to.equal(before);
493
+ });
494
+ // Every command against a resource is `cred <verb> <resource>`. The old
495
+ // top-level verbs stay, listed, so nothing that uses them breaks.
496
+ describe("command shapes", () => {
497
+ it("names itself cred in help, not the file it runs from", () => {
498
+ (0, chai_1.expect)(cred(["--help"]).stdout).to.match(/^Usage: cred /);
499
+ });
500
+ // An agent learns a command from --help alone: the README does not ship
501
+ // with the CLI.
502
+ it("documents what publish uploads and prints, in publish --help and add version --help", () => {
503
+ for (const command of [["publish"], ["add", "version"]]) {
504
+ const help = cred([...command, "--help"]).stdout;
505
+ (0, chai_1.expect)(help, command.join(" ")).to.contain(".credignore");
506
+ // Rendered from PUBLISH_EXCLUDES, so a credential file is named.
507
+ (0, chai_1.expect)(help, command.join(" ")).to.contain("publisher.config.json, .env");
508
+ (0, chai_1.expect)(help, command.join(" ")).to.contain('latest ("now", "when-built" or "no")');
509
+ }
510
+ });
511
+ // An agent that ran a plain `cred init` sat on a foreground publisher,
512
+ // with no `malloy` tools until it was restarted.
513
+ it("tells an agent, before it runs init, that init needs a session restart", () => {
514
+ const help = cred(["init", "--help"]).stdout;
515
+ (0, chai_1.expect)(help).to.contain("cred init --no-start");
516
+ (0, chai_1.expect)(help).to.contain("Ask the user to restart you");
517
+ (0, chai_1.expect)(cred(["--help"]).stdout).to.contain("read `cred init --help`");
518
+ });
519
+ it("accepts list for ls", () => {
520
+ const run = cred(["list", "environments", "--help"]);
521
+ (0, chai_1.expect)(run.status, run.stderr).to.equal(0);
522
+ (0, chai_1.expect)(run.stdout).to.contain("List all environments.");
523
+ });
524
+ it("offers add version / add run / update version / update run, and keeps the old verbs listed", () => {
525
+ const top = cred(["--help"]).stdout;
526
+ for (const old of [
527
+ "publish",
528
+ "archive",
529
+ "unarchive",
530
+ "rerun",
531
+ "cancel-run",
532
+ ]) {
533
+ (0, chai_1.expect)(top).to.match(new RegExp(`^ ${old}\\b`, "m"));
534
+ }
535
+ (0, chai_1.expect)(cred(["add", "--help"]).stdout).to.match(/version[\s\S]*run/);
536
+ (0, chai_1.expect)(cred(["update", "--help"]).stdout).to.match(/version[\s\S]*run/);
537
+ });
538
+ it("refuses an update that changes nothing, naming the flag", () => {
539
+ const version = cred(["update", "version", "orders", "1.0.0"]);
540
+ (0, chai_1.expect)(version.status).to.equal(1);
541
+ (0, chai_1.expect)(version.stderr).to.contain("Pass --archived");
542
+ const run = cred(["update", "run", "orders", "run-1"]);
543
+ (0, chai_1.expect)(run.status).to.equal(1);
544
+ (0, chai_1.expect)(run.stderr).to.contain("Pass --cancel");
545
+ });
546
+ });
547
+ });
548
+ //# sourceMappingURL=agent-contract.spec.js.map