@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
@@ -0,0 +1,783 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
36
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
37
+ return new (P || (P = Promise))(function (resolve, reject) {
38
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
39
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
40
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
41
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
42
+ });
43
+ };
44
+ var __importDefault = (this && this.__importDefault) || function (mod) {
45
+ return (mod && mod.__esModule) ? mod : { "default": mod };
46
+ };
47
+ Object.defineProperty(exports, "__esModule", { value: true });
48
+ const chai_1 = require("chai");
49
+ const fs_1 = __importDefault(require("fs"));
50
+ const os_1 = __importDefault(require("os"));
51
+ const path_1 = __importDefault(require("path"));
52
+ const sinon_1 = __importDefault(require("sinon"));
53
+ const api_1 = require("../../client/api");
54
+ const clientconfiguration_1 = require("../../clientconfiguration");
55
+ const constants_1 = require("../../constants");
56
+ const logger_1 = require("../../logger");
57
+ const flow = __importStar(require("../../setup-core/flow"));
58
+ const host_1 = require("../../setup-core/host");
59
+ const refresh = __importStar(require("../../setup-core/refresh"));
60
+ const folderconfig_1 = require("../../setup-core/folderconfig");
61
+ const setEnvironmentModule = __importStar(require("../environment/setenvironment"));
62
+ const utils = __importStar(require("../../utils"));
63
+ const inquirerHost = __importStar(require("./inquirerHost"));
64
+ const loginModule = __importStar(require("./login"));
65
+ const setup_1 = require("./setup");
66
+ /**
67
+ * `cred init` / `cred dev` orchestration.
68
+ *
69
+ * These two decide which deployment, organization and Credible environment a
70
+ * directory is wired to, and those answers are baked into `.mcp.json`, the agent
71
+ * briefing and the publisher config — where getting one wrong looks entirely
72
+ * normal until someone queries the wrong warehouse. So the assertions here are
73
+ * about *which* values reach `runSetup`/`wireDirectory` and whether a refusal
74
+ * stops the flow, not about what those write.
75
+ *
76
+ * The credential store is stubbed at the prototype rather than given a temp
77
+ * file, because `resolveTarget` constructs its own `ClientConfiguration` with no
78
+ * injection point: an unstubbed run would read — and `loadConfig` would create —
79
+ * the developer's real `~/.cred`.
80
+ */
81
+ describe("init and dev", () => {
82
+ let sandbox;
83
+ let workDir;
84
+ let previousCwd;
85
+ /** The store's per-deployment state, so setProject/getProject behave. */
86
+ let stored;
87
+ let runSetupStub;
88
+ let wireDirectoryStub;
89
+ let startSessionStub;
90
+ let loginStub;
91
+ let setEnvironmentStub;
92
+ let ensureFreshTokensStub;
93
+ let exitStub;
94
+ /** Thrown in place of `process.exit`, so a test can assert the flow stopped. */
95
+ class Exited extends Error {
96
+ }
97
+ beforeEach(() => {
98
+ sandbox = sinon_1.default.createSandbox();
99
+ workDir = fs_1.default.mkdtempSync(path_1.default.join(os_1.default.tmpdir(), "setup-cmd-"));
100
+ previousCwd = process.cwd();
101
+ process.chdir(workDir);
102
+ stored = { organization: "acme", project: "prod-bars" };
103
+ sandbox.stub(logger_1.logger);
104
+ exitStub = sandbox.stub(process, "exit").callsFake(() => {
105
+ throw new Exited("exited");
106
+ });
107
+ // No prompts, no browser, no terminal colours.
108
+ sandbox.stub(inquirerHost, "createInquirerHost").returns({
109
+ log: () => undefined,
110
+ write: () => undefined,
111
+ confirm: () => __awaiter(void 0, void 0, void 0, function* () { return true; }),
112
+ select: () => __awaiter(void 0, void 0, void 0, function* () { return ""; }),
113
+ selectMany: () => __awaiter(void 0, void 0, void 0, function* () { return []; }),
114
+ openUrl: () => __awaiter(void 0, void 0, void 0, function* () { return undefined; }),
115
+ });
116
+ sandbox.stub(utils, "getConfirmation").resolves(true);
117
+ // Every read the flow makes of the store, backed by `stored` so a refusal
118
+ // to write is visible as an unchanged value.
119
+ // Honours the instance's `environmentOverride`, because that is the whole
120
+ // mechanism under test: `resolveTarget` builds the store with the resolved
121
+ // deployment pinned, and a flat stub would hide whether the scoping works.
122
+ sandbox
123
+ .stub(clientconfiguration_1.ClientConfiguration.prototype, "getEnvironment")
124
+ .callsFake(function () {
125
+ var _a;
126
+ return ((_a = this.environmentOverride) !== null && _a !== void 0 ? _a : "production");
127
+ });
128
+ sandbox
129
+ .stub(clientconfiguration_1.ClientConfiguration.prototype, "getOrganization")
130
+ .callsFake(() => stored.organization);
131
+ sandbox
132
+ .stub(clientconfiguration_1.ClientConfiguration.prototype, "getProject")
133
+ .callsFake(() => stored.project);
134
+ sandbox
135
+ .stub(clientconfiguration_1.ClientConfiguration.prototype, "setOrganization")
136
+ .callsFake((value) => {
137
+ stored.organization = value;
138
+ });
139
+ sandbox
140
+ .stub(clientconfiguration_1.ClientConfiguration.prototype, "setProject")
141
+ .callsFake((value) => {
142
+ stored.project = value;
143
+ });
144
+ sandbox
145
+ .stub(clientconfiguration_1.ClientConfiguration.prototype, "isTokenValid")
146
+ .returns({ valid: true });
147
+ sandbox
148
+ .stub(clientconfiguration_1.ClientConfiguration.prototype, "getHeaders")
149
+ .returns({ Authorization: "Bearer t" });
150
+ ensureFreshTokensStub = sandbox
151
+ .stub(refresh, "ensureFreshTokens")
152
+ .resolves({ status: "fresh" });
153
+ loginStub = sandbox.stub(loginModule, "login").resolves(undefined);
154
+ sandbox.stub(loginModule, "resolveOrganization").resolves("acme");
155
+ // Accepts by default; the interesting cases make it refuse.
156
+ setEnvironmentStub = sandbox
157
+ .stub(setEnvironmentModule, "setEnvironment")
158
+ .callsFake((name) => __awaiter(void 0, void 0, void 0, function* () {
159
+ if (name !== undefined)
160
+ stored.project = name;
161
+ return name !== undefined;
162
+ }));
163
+ // The real one probes 127.0.0.1:4000, so a publisher a developer has
164
+ // running there would make every start in this file refuse.
165
+ sandbox.stub(flow, "refuseBesideOtherPublisher").resolves();
166
+ // Only the field the last line reads: whether there is a connection.
167
+ const wired = {
168
+ config: { environments: [{ connections: [{ name: "warehouse" }] }] },
169
+ };
170
+ runSetupStub = sandbox.stub(flow, "runSetup").resolves({ wired });
171
+ wireDirectoryStub = sandbox.stub(flow, "wireDirectory").resolves(wired);
172
+ startSessionStub = sandbox.stub(flow, "startSession").resolves({
173
+ uiUrl: "http://localhost:4000",
174
+ waitForExit: () => __awaiter(void 0, void 0, void 0, function* () { return 0; }),
175
+ stop: () => undefined,
176
+ });
177
+ });
178
+ afterEach(() => {
179
+ process.chdir(previousCwd);
180
+ sandbox.restore();
181
+ fs_1.default.rmSync(workDir, { recursive: true, force: true });
182
+ });
183
+ describe("an --environment the organization does not have", () => {
184
+ it("stops setup rather than wiring the previous answer", () => __awaiter(void 0, void 0, void 0, function* () {
185
+ // `setEnvironment` reports a refused name and returns WITHOUT writing,
186
+ // so the store still holds the last run's answer. Checking only for an
187
+ // empty store passed on that value: setup printed success and wired the
188
+ // directory to the OLD environment, contradicting the flag just passed.
189
+ // The refusal is setEnvironment's to print, as the real one does.
190
+ setEnvironmentStub.callsFake(() => __awaiter(void 0, void 0, void 0, function* () {
191
+ logger_1.logger.error("No environment named 'prod-barz'.");
192
+ return false;
193
+ }));
194
+ yield (0, setup_1.setup)({
195
+ start: false,
196
+ open: false,
197
+ environment: "prod-barz",
198
+ }).catch((error) => {
199
+ (0, chai_1.expect)(error).to.be.instanceOf(Exited);
200
+ });
201
+ (0, chai_1.expect)(runSetupStub.called, "wired anyway").to.equal(false);
202
+ (0, chai_1.expect)(exitStub.calledWith(1)).to.equal(true);
203
+ const reported = logger_1.logger.error
204
+ .getCalls()
205
+ .map((call) => String(call.args[0]));
206
+ (0, chai_1.expect)(reported).to.eql(["No environment named 'prod-barz'."]);
207
+ }));
208
+ // The organization has to be in the store before `setEnvironment` can
209
+ // list its environments. Written and left there, a refused environment
210
+ // paired the new organization with the old environment in ~/.cred — a
211
+ // pair nobody chose, which the next unpinned `cred publish` targets.
212
+ it("leaves ~/.cred as it was, organization included", () => __awaiter(void 0, void 0, void 0, function* () {
213
+ setEnvironmentStub.callsFake(() => __awaiter(void 0, void 0, void 0, function* () { return false; }));
214
+ yield (0, setup_1.setup)({
215
+ start: false,
216
+ open: false,
217
+ organization: "other-org",
218
+ environment: "typo",
219
+ }).catch((error) => {
220
+ (0, chai_1.expect)(error).to.be.instanceOf(Exited);
221
+ });
222
+ (0, chai_1.expect)(stored).to.eql({ organization: "acme", project: "prod-bars" });
223
+ }));
224
+ // Inquirer 8 does not throw on Ctrl-C: it closes the prompt and re-raises
225
+ // SIGINT at the process, and the prompt's promise never settles. Without
226
+ // a listener Node then exited with the new organization and no
227
+ // environment in ~/.cred.
228
+ it("puts ~/.cred back before exiting when Ctrl-C closes the picker", () => __awaiter(void 0, void 0, void 0, function* () {
229
+ const once = sandbox.spy(process, "once");
230
+ let atExit;
231
+ exitStub.callsFake((code) => {
232
+ if (code === 130)
233
+ atExit = Object.assign({}, stored);
234
+ throw new Exited("exited");
235
+ });
236
+ loginModule.resolveOrganization.resolves("other-org");
237
+ setEnvironmentStub.callsFake(() => __awaiter(void 0, void 0, void 0, function* () {
238
+ var _a;
239
+ (0, chai_1.expect)(stored.organization, "written before the picker").to.equal("other-org");
240
+ // What inquirer does: re-raise SIGINT at the process.
241
+ const listener = (_a = once
242
+ .getCalls()
243
+ .find((call) => call.args[0] === "SIGINT")) === null || _a === void 0 ? void 0 : _a.args[1];
244
+ (0, chai_1.expect)(listener, "nothing listens for SIGINT").to.not.equal(undefined);
245
+ listener("SIGINT");
246
+ return true;
247
+ }));
248
+ yield (0, setup_1.setup)({ start: false, open: false }).catch((error) => {
249
+ (0, chai_1.expect)(error).to.be.instanceOf(Exited);
250
+ });
251
+ (0, chai_1.expect)(atExit).to.eql({ organization: "acme", project: "prod-bars" });
252
+ }));
253
+ it("stops dev too, which is the command that re-points a directory", () => __awaiter(void 0, void 0, void 0, function* () {
254
+ (0, folderconfig_1.writeFolderConfig)(workDir, {
255
+ organization: "acme",
256
+ environment: "prod-bars",
257
+ });
258
+ setEnvironmentStub.callsFake(() => __awaiter(void 0, void 0, void 0, function* () { return false; }));
259
+ yield (0, setup_1.dev)({ open: false, environment: "prod-barz" }).catch((error) => {
260
+ (0, chai_1.expect)(error).to.be.instanceOf(Exited);
261
+ });
262
+ (0, chai_1.expect)(wireDirectoryStub.called, "re-wired anyway").to.equal(false);
263
+ (0, chai_1.expect)(startSessionStub.called).to.equal(false);
264
+ }));
265
+ // `cred dev` has no --create-environment, so naming it sent an agent to
266
+ // Commander's unknown-option error.
267
+ // dev takes --create-environment like init. Pointing it at
268
+ // `cred add environment` created on the pin's organization, which is
269
+ // the wrong one after `cred dev -o other-org`.
270
+ it("gives dev init's hints, and passes --create-environment through", () => __awaiter(void 0, void 0, void 0, function* () {
271
+ (0, folderconfig_1.writeFolderConfig)(workDir, {
272
+ organization: "acme",
273
+ environment: "prod-bars",
274
+ });
275
+ // As the real one does: it logs the refusal itself, then says false.
276
+ setEnvironmentStub.callsFake(() => __awaiter(void 0, void 0, void 0, function* () {
277
+ logger_1.logger.error("No environment named 'typo'.");
278
+ return false;
279
+ }));
280
+ yield (0, setup_1.dev)({ open: false, environment: "typo" }).catch((error) => {
281
+ (0, chai_1.expect)(error).to.be.instanceOf(Exited);
282
+ });
283
+ (0, chai_1.expect)(setEnvironmentStub.firstCall.args[2].hints).to.equal(setEnvironmentModule.INIT_ENVIRONMENT_HINTS);
284
+ (0, chai_1.expect)(exitStub.firstCall.args[0]).to.equal(1);
285
+ // One error, the refusal; setup used to add a second saying the same.
286
+ const reported = logger_1.logger.error
287
+ .getCalls()
288
+ .map((call) => String(call.args[0]));
289
+ (0, chai_1.expect)(reported).to.eql(["No environment named 'typo'."]);
290
+ }));
291
+ it("creates a missing environment from dev when --create-environment is passed", () => __awaiter(void 0, void 0, void 0, function* () {
292
+ (0, folderconfig_1.writeFolderConfig)(workDir, {
293
+ organization: "acme",
294
+ environment: "prod-bars",
295
+ });
296
+ yield (0, setup_1.dev)({
297
+ open: false,
298
+ environment: "fresh",
299
+ createEnvironment: true,
300
+ }).catch(() => undefined);
301
+ (0, chai_1.expect)(setEnvironmentStub.firstCall.args[0]).to.equal("fresh");
302
+ (0, chai_1.expect)(setEnvironmentStub.firstCall.args[2].createIfMissing).to.equal(true);
303
+ }));
304
+ it("names --organization, not cred login, when init cannot ask for one", () => __awaiter(void 0, void 0, void 0, function* () {
305
+ yield (0, setup_1.setup)({ start: false, open: false, environment: "prod-bars" });
306
+ (0, chai_1.expect)(loginModule.resolveOrganization
307
+ .firstCall.args[3]).to.equal("--organization <name>");
308
+ }));
309
+ });
310
+ // `cred dev --organization other-org` keeps the pin's environment name. When
311
+ // other-org lacks it, `setEnvironment` refuses without writing, and the store
312
+ // still held that same name from before, so a check on the store passed.
313
+ it("stops dev when the new organization lacks the pinned environment", () => __awaiter(void 0, void 0, void 0, function* () {
314
+ (0, folderconfig_1.writeFolderConfig)(workDir, {
315
+ organization: "acme",
316
+ environment: "prod-bars",
317
+ });
318
+ setEnvironmentStub.callsFake(() => __awaiter(void 0, void 0, void 0, function* () { return false; }));
319
+ yield (0, setup_1.dev)({ open: false, organization: "other-org" }).catch((error) => {
320
+ (0, chai_1.expect)(error).to.be.instanceOf(Exited);
321
+ });
322
+ (0, chai_1.expect)(wireDirectoryStub.called, "re-pinned anyway").to.equal(false);
323
+ (0, chai_1.expect)(stored).to.eql({ organization: "acme", project: "prod-bars" });
324
+ }));
325
+ // Bound to the settled pair, so another terminal moving ~/.cred while the
326
+ // credential question is open cannot redirect the create.
327
+ it("creates imported connections in the pair it settled, not the store's current one", () => __awaiter(void 0, void 0, void 0, function* () {
328
+ const create = sandbox
329
+ .stub(api_1.ConnectionsApi.prototype, "createConnection")
330
+ .resolves({});
331
+ yield (0, setup_1.setup)({ start: false, open: false, environment: "staging-bars" });
332
+ stored.organization = "moved-org";
333
+ stored.project = "moved-env";
334
+ yield runSetupStub.firstCall.args[0].createConnection({ name: "warehouse", type: "postgres" }, { dryRun: false });
335
+ (0, chai_1.expect)(create.firstCall.args.slice(0, 2)).to.eql([
336
+ "acme",
337
+ "staging-bars",
338
+ ]);
339
+ }));
340
+ // A pinned package that no longer exists surfaced its question only after
341
+ // login and the environment write.
342
+ it("asks dev's unanswerable questions before logging in", () => __awaiter(void 0, void 0, void 0, function* () {
343
+ (0, folderconfig_1.writeFolderConfig)(workDir, {
344
+ organization: "acme",
345
+ environment: "prod-bars",
346
+ });
347
+ const gate = sandbox
348
+ .stub(flow, "refuseUnanswerable")
349
+ .throws(new host_1.NeedsInputError("Which package?", { flag: "--package <dir>" }));
350
+ yield (0, setup_1.dev)({ open: false, package: "gone" }).catch((error) => {
351
+ (0, chai_1.expect)(error).to.be.instanceOf(Exited);
352
+ });
353
+ (0, chai_1.expect)(gate.firstCall.args[1]).to.eql({
354
+ connections: "none",
355
+ skills: undefined,
356
+ package: "gone",
357
+ });
358
+ (0, chai_1.expect)(ensureFreshTokensStub.called, "logged in first").to.equal(false);
359
+ (0, chai_1.expect)(setEnvironmentStub.called).to.equal(false);
360
+ (0, chai_1.expect)(exitStub.calledWith(2)).to.equal(true);
361
+ }));
362
+ // `dev` can hit the skills question too (a pin with no skills record), and
363
+ // without a terminal that exit 2 named a flag `dev` did not take.
364
+ // A Ctrl-C is a requested stop: 130, the shell's code for it, and a line
365
+ // saying the cleanup ran. It exited 1, which a waiting script reads as a
366
+ // dead server, and said nothing.
367
+ it("exits 130 and says so when dev is stopped with Ctrl-C", () => __awaiter(void 0, void 0, void 0, function* () {
368
+ (0, folderconfig_1.writeFolderConfig)(workDir, {
369
+ organization: "acme",
370
+ environment: "prod-bars",
371
+ });
372
+ startSessionStub.resolves({
373
+ uiUrl: "http://localhost:4000",
374
+ waitForExit: () => __awaiter(void 0, void 0, void 0, function* () { return 1; }),
375
+ stop: () => undefined,
376
+ interrupted: () => true,
377
+ });
378
+ const saved = process.exitCode;
379
+ try {
380
+ yield (0, setup_1.dev)({ open: false, yes: true });
381
+ (0, chai_1.expect)(process.exitCode).to.equal(130);
382
+ }
383
+ finally {
384
+ process.exitCode = saved;
385
+ }
386
+ (0, chai_1.expect)(logger_1.logger.info.calledWith("Stopped the local Publisher and removed this session's token file.")).to.equal(true);
387
+ (0, chai_1.expect)(logger_1.logger.error.called).to.equal(false);
388
+ }));
389
+ it("hands dev's --skills to the wiring", () => __awaiter(void 0, void 0, void 0, function* () {
390
+ (0, folderconfig_1.writeFolderConfig)(workDir, {
391
+ organization: "acme",
392
+ environment: "prod-bars",
393
+ });
394
+ yield (0, setup_1.dev)({ open: false, yes: true, skills: "none" });
395
+ (0, chai_1.expect)(wireDirectoryStub.firstCall.args[1].skills).to.equal("none");
396
+ }));
397
+ it("does not end dev on a plain success line when there are no connections", () => __awaiter(void 0, void 0, void 0, function* () {
398
+ (0, folderconfig_1.writeFolderConfig)(workDir, {
399
+ organization: "acme",
400
+ environment: "prod-bars",
401
+ });
402
+ wireDirectoryStub.resolves({
403
+ config: { environments: [{ connections: [] }] },
404
+ });
405
+ yield (0, setup_1.dev)({ open: false, yes: true });
406
+ const infos = logger_1.logger.info.args.map((args) => String(args[0]));
407
+ (0, chai_1.expect)(infos.some((line) => line.includes("but the environment has no connections, so there is nothing to query yet. To fix it, add one with `cred add connection`, then restart `cred dev`.")), infos.join("\n")).to.equal(true);
408
+ }));
409
+ it("wires the environment a flag names when it is accepted", () => __awaiter(void 0, void 0, void 0, function* () {
410
+ yield (0, setup_1.setup)({ start: false, open: false, environment: "staging-bars" });
411
+ (0, chai_1.expect)(runSetupStub.calledOnce).to.equal(true);
412
+ (0, chai_1.expect)(runSetupStub.firstCall.args[1]).to.include({
413
+ organization: "acme",
414
+ credibleEnvironment: "staging-bars",
415
+ });
416
+ }));
417
+ it("clears the stored environment with undefined before opening the picker", () => __awaiter(void 0, void 0, void 0, function* () {
418
+ // `""` would survive `cred status`'s `getProject() ?? "Not set"` and print
419
+ // a blank line, so an interrupted setup would report differently from
420
+ // every other unset-environment path.
421
+ let clearedTo = "not called";
422
+ setEnvironmentStub.callsFake((name) => __awaiter(void 0, void 0, void 0, function* () {
423
+ if (name === undefined) {
424
+ clearedTo = stored.project;
425
+ stored.project = "picked-bars";
426
+ }
427
+ return true;
428
+ }));
429
+ yield (0, setup_1.setup)({ start: false, open: false });
430
+ (0, chai_1.expect)(clearedTo).to.equal(undefined);
431
+ (0, chai_1.expect)(runSetupStub.firstCall.args[1]).to.include({
432
+ credibleEnvironment: "picked-bars",
433
+ });
434
+ }));
435
+ describe("login", () => {
436
+ it("is given the deployment the store is scoped to", () => __awaiter(void 0, void 0, void 0, function* () {
437
+ // Without it, login writes the tokens and organization under the file's
438
+ // global `activeEnvironment`, and setup's own `getOrganization()` check
439
+ // then reads a slot login never touched — so a directory pinned to a
440
+ // non-global deployment failed its first run with "Setup needs an
441
+ // organization", the case the pin exists for.
442
+ (0, folderconfig_1.writeFolderConfig)(workDir, { deployment: "staging" });
443
+ ensureFreshTokensStub.resolves({
444
+ status: "logged-out",
445
+ reason: "not logged in",
446
+ });
447
+ clientconfiguration_1.ClientConfiguration.prototype
448
+ .isTokenValid.returns({ valid: false });
449
+ yield (0, setup_1.setup)({
450
+ start: false,
451
+ open: false,
452
+ environment: "staging-bars",
453
+ });
454
+ (0, chai_1.expect)(loginStub.calledOnce).to.equal(true);
455
+ const [organization, controlPlane, configPath, cluster, deployment] = loginStub.firstCall.args;
456
+ (0, chai_1.expect)(organization).to.equal(undefined);
457
+ (0, chai_1.expect)(controlPlane).to.equal(constants_1.controlPlanesByEnv["staging"]);
458
+ (0, chai_1.expect)(configPath).to.equal(undefined);
459
+ (0, chai_1.expect)(cluster).to.equal("gcp");
460
+ (0, chai_1.expect)(deployment).to.equal("staging");
461
+ }));
462
+ // An AWS login needs the organization up front, and a GCP login without
463
+ // one opens a picker that exits 2 without a terminal.
464
+ it("is given the organization the pin names", () => __awaiter(void 0, void 0, void 0, function* () {
465
+ (0, folderconfig_1.writeFolderConfig)(workDir, {
466
+ deployment: "videoamp",
467
+ organization: "videoamp",
468
+ environment: "reports",
469
+ });
470
+ ensureFreshTokensStub.resolves({
471
+ status: "logged-out",
472
+ reason: "not logged in",
473
+ });
474
+ clientconfiguration_1.ClientConfiguration.prototype
475
+ .isTokenValid.returns({ valid: false });
476
+ yield (0, setup_1.dev)({ open: false, yes: true });
477
+ (0, chai_1.expect)(loginStub.calledOnce, "login attempted").to.equal(true);
478
+ const [organization, , , cluster, deployment] = loginStub.firstCall.args;
479
+ (0, chai_1.expect)(organization).to.equal("videoamp");
480
+ (0, chai_1.expect)(cluster).to.equal("aws");
481
+ (0, chai_1.expect)(deployment).to.equal("videoamp");
482
+ }));
483
+ it("is given the organization --organization names, over the pin's", () => __awaiter(void 0, void 0, void 0, function* () {
484
+ (0, folderconfig_1.writeFolderConfig)(workDir, { organization: "acme" });
485
+ ensureFreshTokensStub.resolves({
486
+ status: "logged-out",
487
+ reason: "not logged in",
488
+ });
489
+ clientconfiguration_1.ClientConfiguration.prototype
490
+ .isTokenValid.returns({ valid: false });
491
+ yield (0, setup_1.setup)({
492
+ start: false,
493
+ open: false,
494
+ organization: "globex",
495
+ environment: "prod-bars",
496
+ });
497
+ (0, chai_1.expect)(loginStub.firstCall.args[0]).to.equal("globex");
498
+ }));
499
+ it("is not attempted when the token on disk is live", () => __awaiter(void 0, void 0, void 0, function* () {
500
+ yield (0, setup_1.setup)({
501
+ start: false,
502
+ open: false,
503
+ environment: "staging-bars",
504
+ });
505
+ (0, chai_1.expect)(loginStub.called).to.equal(false);
506
+ }));
507
+ });
508
+ describe("deployment resolution", () => {
509
+ it("acts against the deployment a directory is pinned to", () => __awaiter(void 0, void 0, void 0, function* () {
510
+ (0, folderconfig_1.writeFolderConfig)(workDir, {
511
+ deployment: "staging",
512
+ organization: "acme",
513
+ environment: "prod-bars",
514
+ });
515
+ yield (0, setup_1.dev)({ open: false, environment: "prod-bars" });
516
+ (0, chai_1.expect)(wireDirectoryStub.calledOnce).to.equal(true);
517
+ (0, chai_1.expect)(wireDirectoryStub.firstCall.args[0].deployment).to.equal("staging");
518
+ }));
519
+ });
520
+ // `settleTarget` in confirm mode keeps the resolved pair, so a "no" used to
521
+ // re-wire exactly the pair the user had just declined.
522
+ it("opens the pickers when dev's confirmation is answered no", () => __awaiter(void 0, void 0, void 0, function* () {
523
+ (0, folderconfig_1.writeFolderConfig)(workDir, {
524
+ organization: "acme",
525
+ environment: "prod-bars",
526
+ });
527
+ sandbox.stub(utils, "isInteractive").returns(true);
528
+ utils.getConfirmation.resolves(false);
529
+ loginModule.resolveOrganization.resolves("globex");
530
+ setEnvironmentStub.callsFake((name) => __awaiter(void 0, void 0, void 0, function* () {
531
+ stored.project = name !== null && name !== void 0 ? name : "picked-bars";
532
+ return true;
533
+ }));
534
+ yield (0, setup_1.dev)({ open: false });
535
+ (0, chai_1.expect)(setEnvironmentStub.calledWith(undefined)).to.equal(true);
536
+ (0, chai_1.expect)(wireDirectoryStub.firstCall.args[1]).to.include({
537
+ organization: "globex",
538
+ credibleEnvironment: "picked-bars",
539
+ });
540
+ }));
541
+ describe("--cell", () => {
542
+ afterEach(() => {
543
+ utils.takeCellFlag(["node", "cred"]);
544
+ });
545
+ function slots() {
546
+ const credPath = path_1.default.join(workDir, "slots.cred");
547
+ fs_1.default.writeFileSync(credPath, JSON.stringify({
548
+ configPerEnvironment: {
549
+ dev: { organization: "pin-org", project: "pin-env" },
550
+ staging: { organization: "demo", project: "malloy-samples" },
551
+ },
552
+ activeEnvironment: "production",
553
+ }));
554
+ return new clientconfiguration_1.ClientConfiguration(credPath);
555
+ }
556
+ it("overrides the pin and the global default, taking organization and environment from the flagged cell's slot", () => {
557
+ (0, folderconfig_1.writeFolderConfig)(workDir, {
558
+ deployment: "dev",
559
+ organization: "pin-org",
560
+ environment: "pin-env",
561
+ });
562
+ const target = (0, setup_1.resolveTarget)(workDir, slots(), "staging");
563
+ (0, chai_1.expect)(target.deployment).to.equal("staging");
564
+ (0, chai_1.expect)(target.from).to.equal("flag");
565
+ // The store's own getters are stubbed in this spec; what matters is
566
+ // that they, and not the pin, supply the pair.
567
+ (0, chai_1.expect)((0, setup_1.pinnedIdentity)(workDir, target.credStore)).to.eql({
568
+ organization: target.credStore.getOrganization(),
569
+ environment: target.credStore.getProject(),
570
+ from: "global",
571
+ ignoredPin: "dev",
572
+ });
573
+ (0, chai_1.expect)(target.credStore.getOrganization()).to.not.equal("pin-org");
574
+ });
575
+ it("keeps the pin's organization and environment when the flag names the pin's own cell", () => {
576
+ (0, folderconfig_1.writeFolderConfig)(workDir, {
577
+ deployment: "dev",
578
+ organization: "pin-org",
579
+ environment: "pin-env",
580
+ });
581
+ const target = (0, setup_1.resolveTarget)(workDir, slots(), "dev");
582
+ (0, chai_1.expect)((0, setup_1.pinnedIdentity)(workDir, target.credStore)).to.include({
583
+ organization: "pin-org",
584
+ from: "folder",
585
+ });
586
+ });
587
+ it("refuses dev when --cell names another cell than the pin, and names init", () => __awaiter(void 0, void 0, void 0, function* () {
588
+ (0, folderconfig_1.writeFolderConfig)(workDir, {
589
+ deployment: "dev",
590
+ organization: "acme",
591
+ environment: "prod-bars",
592
+ });
593
+ utils.takeCellFlag(["node", "cred", "--cell", "staging"]);
594
+ const errors = logger_1.logger.error;
595
+ yield (0, setup_1.dev)({ open: false, environment: "prod-bars" }).catch((error) => {
596
+ (0, chai_1.expect)(error).to.be.instanceOf(Exited);
597
+ });
598
+ (0, chai_1.expect)(wireDirectoryStub.called, "re-pinned anyway").to.equal(false);
599
+ (0, chai_1.expect)(errors.firstCall.args[0]).to.contain("--cell staging init");
600
+ }));
601
+ it("still re-pins on dev -e when --cell names the pin's own cell", () => __awaiter(void 0, void 0, void 0, function* () {
602
+ (0, folderconfig_1.writeFolderConfig)(workDir, {
603
+ deployment: "dev",
604
+ organization: "acme",
605
+ environment: "prod-bars",
606
+ });
607
+ utils.takeCellFlag(["node", "cred", "--cell", "dev"]);
608
+ setEnvironmentStub.callsFake((name) => __awaiter(void 0, void 0, void 0, function* () {
609
+ stored.project = name !== null && name !== void 0 ? name : "picked-bars";
610
+ return true;
611
+ }));
612
+ yield (0, setup_1.dev)({ open: false, environment: "other" });
613
+ (0, chai_1.expect)(wireDirectoryStub.firstCall.args[1].credibleEnvironment).to.equal("other");
614
+ }));
615
+ it("says init is re-pinning a directory pinned to another cell", () => __awaiter(void 0, void 0, void 0, function* () {
616
+ (0, folderconfig_1.writeFolderConfig)(workDir, {
617
+ deployment: "dev",
618
+ organization: "acme",
619
+ environment: "prod-bars",
620
+ });
621
+ utils.takeCellFlag(["node", "cred", "--cell", "staging"]);
622
+ const infos = logger_1.logger.info;
623
+ yield (0, setup_1.setup)({
624
+ start: false,
625
+ open: false,
626
+ environment: "staging-bars",
627
+ });
628
+ (0, chai_1.expect)(infos.args.map((a) => a[0])).to.include("re-pinning this directory from dev to staging");
629
+ }));
630
+ });
631
+ describe("credStoreToRefresh", () => {
632
+ const global = {};
633
+ it("checks the pinned deployment's login for the commands that act on it", () => {
634
+ (0, folderconfig_1.writeFolderConfig)(workDir, { deployment: "staging" });
635
+ for (const command of ["publish", "add connection"]) {
636
+ const store = (0, setup_1.credStoreToRefresh)(command, workDir, global);
637
+ (0, chai_1.expect)(store, command).to.not.equal(global);
638
+ (0, chai_1.expect)(store.getEnvironment(), command).to.equal("staging");
639
+ }
640
+ });
641
+ it("checks the global login for every other command", () => {
642
+ (0, folderconfig_1.writeFolderConfig)(workDir, { deployment: "staging" });
643
+ for (const command of ["ls environment", "rm connection", "archive"]) {
644
+ (0, chai_1.expect)((0, setup_1.credStoreToRefresh)(command, workDir, global), command).to.equal(global);
645
+ }
646
+ });
647
+ });
648
+ describe("needsNoSession", () => {
649
+ it("lets a publish dry run through without a login, under either name", () => {
650
+ (0, chai_1.expect)((0, setup_1.needsNoSession)("publish", { dryRun: true })).to.equal(true);
651
+ (0, chai_1.expect)((0, setup_1.needsNoSession)("add version", { dryRun: true })).to.equal(true);
652
+ });
653
+ it("still refreshes a real publish, and every other command", () => {
654
+ (0, chai_1.expect)((0, setup_1.needsNoSession)("publish", {})).to.equal(false);
655
+ (0, chai_1.expect)((0, setup_1.needsNoSession)("add version", { dryRun: false })).to.equal(false);
656
+ (0, chai_1.expect)((0, setup_1.needsNoSession)("add connection", { dryRun: true })).to.equal(false);
657
+ });
658
+ });
659
+ it("tells someone to run setup first when dev finds no pin", () => __awaiter(void 0, void 0, void 0, function* () {
660
+ yield (0, setup_1.dev)({ open: false }).catch((error) => {
661
+ (0, chai_1.expect)(error).to.be.instanceOf(Exited);
662
+ });
663
+ (0, chai_1.expect)(wireDirectoryStub.called).to.equal(false);
664
+ (0, chai_1.expect)(String(logger_1.logger.error.firstCall.args[0])).to.contain("cred init");
665
+ }));
666
+ });
667
+ describe("parsePortFlag", () => {
668
+ it("takes a whole port whose MCP partner, 40 above, is valid too", () => {
669
+ (0, chai_1.expect)((0, setup_1.parsePortFlag)(undefined)).to.equal(undefined);
670
+ (0, chai_1.expect)((0, setup_1.parsePortFlag)("4100")).to.equal(4100);
671
+ (0, chai_1.expect)((0, setup_1.parsePortFlag)("65495")).to.equal(65495);
672
+ });
673
+ it("refuses anything else, naming the range and an example", () => {
674
+ for (const value of ["abc", "4100.5", "-4100", "80", "65496", ""]) {
675
+ (0, chai_1.expect)(() => (0, setup_1.parsePortFlag)(value), value).to.throw(`--port was given '${value}'. Fix: pass a whole number from 1024 to 65495; the MCP server takes the port 40 above it. Example: --port 4100.`);
676
+ }
677
+ });
678
+ });
679
+ /**
680
+ * The line `cred publish` and `cred add connection` print before they act.
681
+ *
682
+ * It exists because the *silent* case was the wrong one. `chooseTarget`
683
+ * persists the settled organization and environment to `~/.cred` as well as to
684
+ * the directory's pin, so `cred init` in `repo/pkg-a` moves the global too —
685
+ * and a later publish from an unpinned `repo/` inherits pkg-a's environment and
686
+ * used to say nothing at all, because the old line only printed when a pin was
687
+ * involved.
688
+ */
689
+ describe("describeIdentity", () => {
690
+ it("names the pin as the source when the directory has one", () => {
691
+ (0, chai_1.expect)((0, setup_1.describeIdentity)("production", { organization: "acme", environment: "prod-bars" }, "folder", "folder")).to.equal("acme/prod-bars on production, pinned in .credible/config.json.");
692
+ });
693
+ it("says the global fallback is a fallback, and how to stop it being one", () => {
694
+ const line = (0, setup_1.describeIdentity)("production", { organization: "acme", environment: "pkg-a-env" }, "global", "global");
695
+ (0, chai_1.expect)(line).to.contain("acme/pkg-a-env");
696
+ (0, chai_1.expect)(line).to.contain("on production, from your global settings");
697
+ (0, chai_1.expect)(line).to.contain("~/.cred");
698
+ (0, chai_1.expect)(line, "the way out has to be in the line").to.contain("cred init");
699
+ // Its callers, `publish` and `add connection`, have no such flags: a
700
+ // caller following the line got "unknown option '--organization'".
701
+ (0, chai_1.expect)(line).to.not.contain("--organization");
702
+ (0, chai_1.expect)(line).to.not.contain("--environment");
703
+ });
704
+ it("names the cell even when it is the ordinary one", () => {
705
+ // Credentials are per cell: a line that left production out let a
706
+ // `--cell staging` login read as if it had changed what this one acts on.
707
+ (0, chai_1.expect)((0, setup_1.describeIdentity)("production", { organization: "acme", environment: "e" }, "folder", "global")).to.contain("on production");
708
+ });
709
+ it("names the deployment when it is not the ordinary one", () => {
710
+ (0, chai_1.expect)((0, setup_1.describeIdentity)("staging", { organization: "acme", environment: "e" }, "folder", "folder")).to.contain("on staging");
711
+ });
712
+ it("says --cell set the cell, and names the pin it overrode", () => {
713
+ (0, chai_1.expect)((0, setup_1.describeIdentity)("staging", {
714
+ organization: "demo",
715
+ environment: "malloy-samples",
716
+ ignoredPin: "dev",
717
+ }, "global", "flag")).to.equal("demo/malloy-samples on staging, set by --cell (this directory's pin to dev is ignored).");
718
+ });
719
+ it("shows a missing value rather than printing undefined", () => {
720
+ (0, chai_1.expect)((0, setup_1.describeIdentity)("production", { organization: "acme" }, "global", "global")).to.contain("acme/?");
721
+ });
722
+ });
723
+ // database-design.md §12.5: `cred dev` proxies each READY database under its
724
+ // own name, beside the connections, through the same connection route.
725
+ describe("listProxiedConnections", () => {
726
+ let sandbox;
727
+ const store = {
728
+ getHeaders: () => ({ Authorization: "Bearer t" }),
729
+ };
730
+ const httpError = (status) => Object.assign(new Error(`HTTP ${status}`), {
731
+ isAxiosError: true,
732
+ response: { status, data: { message: "boom" } },
733
+ });
734
+ beforeEach(() => {
735
+ sandbox = sinon_1.default.createSandbox();
736
+ sandbox.stub(logger_1.logger);
737
+ sandbox
738
+ .stub(api_1.ConnectionsApi.prototype, "listConnections")
739
+ .resolves({ data: [{ name: "warehouse" }] });
740
+ });
741
+ afterEach(() => sandbox.restore());
742
+ it("appends each READY database under its own name", () => __awaiter(void 0, void 0, void 0, function* () {
743
+ const list = sandbox
744
+ .stub(api_1.DatabasesApi.prototype, "listDatabases")
745
+ .resolves({
746
+ data: [
747
+ { name: "credible", status: "READY" },
748
+ { name: "staging_db", status: "PROVISIONING" },
749
+ { name: "sales", status: "READY" },
750
+ { name: "gone", status: "DELETING" },
751
+ ],
752
+ });
753
+ const proxied = yield (0, setup_1.listProxiedConnections)("http://cp", store, "acme", "analytics");
754
+ (0, chai_1.expect)(proxied.map((c) => c.name)).to.eql([
755
+ "warehouse",
756
+ "credible",
757
+ "sales",
758
+ ]);
759
+ (0, chai_1.expect)(list.firstCall.args.slice(0, 4)).to.eql([
760
+ "acme",
761
+ "analytics",
762
+ -1,
763
+ 0,
764
+ ]);
765
+ }));
766
+ it("adds none, quietly, when the deployment has no databases (404)", () => __awaiter(void 0, void 0, void 0, function* () {
767
+ sandbox
768
+ .stub(api_1.DatabasesApi.prototype, "listDatabases")
769
+ .rejects(httpError(404));
770
+ const proxied = yield (0, setup_1.listProxiedConnections)("http://cp", store, "acme", "analytics");
771
+ (0, chai_1.expect)(proxied.map((c) => c.name)).to.eql(["warehouse"]);
772
+ (0, chai_1.expect)(logger_1.logger.warn.called).to.equal(false);
773
+ }));
774
+ it("warns and keeps the connections on any other failure", () => __awaiter(void 0, void 0, void 0, function* () {
775
+ sandbox
776
+ .stub(api_1.DatabasesApi.prototype, "listDatabases")
777
+ .rejects(httpError(503));
778
+ const proxied = yield (0, setup_1.listProxiedConnections)("http://cp", store, "acme", "analytics");
779
+ (0, chai_1.expect)(proxied.map((c) => c.name)).to.eql(["warehouse"]);
780
+ (0, chai_1.expect)(String(logger_1.logger.warn.firstCall.args[0])).to.match(/Could not list the databases of 'analytics' \(boom\)/);
781
+ }));
782
+ });
783
+ //# sourceMappingURL=setup.spec.js.map