@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,819 @@
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
+ exports.resolveTarget = resolveTarget;
16
+ exports.scopeCommandToDirectory = scopeCommandToDirectory;
17
+ exports.refuseWriteUnderIgnoredPin = refuseWriteUnderIgnoredPin;
18
+ exports.credStoreToRefresh = credStoreToRefresh;
19
+ exports.needsNoSession = needsNoSession;
20
+ exports.describeIdentity = describeIdentity;
21
+ exports.pinnedIdentity = pinnedIdentity;
22
+ exports.listProxiedConnections = listProxiedConnections;
23
+ exports.parseConnectionsFlag = parseConnectionsFlag;
24
+ exports.parseSkillsFlag = parseSkillsFlag;
25
+ exports.parsePortFlag = parsePortFlag;
26
+ exports.setup = setup;
27
+ exports.dev = dev;
28
+ const path_1 = __importDefault(require("path"));
29
+ const kleur_1 = __importDefault(require("kleur"));
30
+ const axios_1 = require("axios");
31
+ const api_1 = require("../../client/api");
32
+ const shared_1 = require("../database/shared");
33
+ const configuration_1 = require("../../client/configuration");
34
+ const api_2 = require("../../client-codeassist/api");
35
+ const configuration_2 = require("../../client-codeassist/configuration");
36
+ const clientconfiguration_1 = require("../../clientconfiguration");
37
+ const createconnections_1 = require("../connection/createconnections");
38
+ const constants_1 = require("../../constants");
39
+ const logger_1 = require("../../logger");
40
+ const setenvironment_1 = require("../environment/setenvironment");
41
+ const login_1 = require("./login");
42
+ const utils_1 = require("../../utils");
43
+ const folderconfig_1 = require("../../setup-core/folderconfig");
44
+ const flow_1 = require("../../setup-core/flow");
45
+ const briefing_1 = require("../../setup-core/briefing");
46
+ const host_1 = require("../../setup-core/host");
47
+ const ports_1 = require("../../setup-core/ports");
48
+ const publisherversion_1 = require("../../setup-core/publisherversion");
49
+ const importconnections_1 = require("../../setup-core/importconnections");
50
+ const refresh_1 = require("../../setup-core/refresh");
51
+ const skills_1 = require("../../setup-core/skills");
52
+ const inquirerHost_1 = require("./inquirerHost");
53
+ /**
54
+ * `cred init` and `cred dev` — the terminal front door.
55
+ *
56
+ * Both are thin: they build a Host, resolve where the control plane is, and hand
57
+ * off to `setup-core`. Everything worth reviewing is in the library, because the
58
+ * VS Code extension will run exactly the same steps.
59
+ */
60
+ const connectionsApi = new api_1.ConnectionsApi(new configuration_1.Configuration());
61
+ const codeAssistApi = new api_2.CodeAssistApi(new configuration_2.Configuration());
62
+ /**
63
+ * Which deployment these commands act against, and with whose credentials.
64
+ *
65
+ * `~/.cred` stores tokens, organization and Credible environment *per
66
+ * deployment*, so the deployment has to be resolved before the credential store
67
+ * is read — not after. The store takes the resolved value as an override so
68
+ * every read (token, org, environment) comes from the same deployment the
69
+ * control-plane calls go to; resolving one without the other is how you end up
70
+ * presenting a staging token to production.
71
+ *
72
+ * Precedence lives in {@link resolveDeployment}: `--cell`, the directory's
73
+ * `.credible/config.json` pin, then the global `~/.cred` value.
74
+ */
75
+ function resolveTarget(cwd,
76
+ /** The global store; `~/.cred` unless a caller (a spec) supplies another. */
77
+ globalStore = new clientconfiguration_1.ClientConfiguration(), flag = (0, utils_1.cellFlag)()) {
78
+ const { deployment, from } = (0, folderconfig_1.resolveDeployment)({
79
+ cwd,
80
+ globalDefault: globalStore.getEnvironment(),
81
+ flag,
82
+ });
83
+ // Always pinned, even when the resolved deployment is the global one: the
84
+ // override then reads the same value the file would have given, so there is
85
+ // no second code path to reason about.
86
+ return {
87
+ deployment,
88
+ from,
89
+ credStore: globalStore.pinnedTo(deployment),
90
+ };
91
+ }
92
+ /**
93
+ * The command paths that run the publish action. `add version` is `publish`
94
+ * under its resource-shaped name.
95
+ */
96
+ const PUBLISH_COMMANDS = new Set(["publish", "add version"]);
97
+ /**
98
+ * The commands that act on the deployment this directory is pinned to, by
99
+ * command path. Each one's action calls {@link resolveTarget}.
100
+ */
101
+ const PINNED_COMMANDS = new Set([...PUBLISH_COMMANDS, "add connection"]);
102
+ /**
103
+ * The commands that do not take the directory's pin: they set or report the
104
+ * global identity, or resolve the pin themselves (`init`, `dev`, `status`,
105
+ * and the {@link PINNED_COMMANDS}, which print their own target line).
106
+ */
107
+ const UNSCOPED_COMMANDS = new Set([
108
+ "login",
109
+ "logout",
110
+ "set-access-token",
111
+ "set",
112
+ "init",
113
+ "dev",
114
+ "status",
115
+ "help",
116
+ ]);
117
+ /** Resources that belong to an organization and not to an environment. */
118
+ const ORG_ONLY_RESOURCES = new Set([
119
+ "group",
120
+ "groups",
121
+ "group-access-token",
122
+ "member",
123
+ ]);
124
+ /**
125
+ * Scope every org- and environment-scoped command run in `cwd` to the
126
+ * directory's pin, and say so, the way `cred publish` already did. Returns the
127
+ * line printed, or undefined when there is no pin or the command is exempt.
128
+ *
129
+ * `cred set ...` stays global on purpose: it is how a user changes their
130
+ * default, and re-pinning a directory is `cred --cell <cell> init`. In a pinned
131
+ * directory it says so rather than appearing to do nothing.
132
+ */
133
+ function scopeCommandToDirectory(commandPath, cwd, log) {
134
+ var _a, _b, _c, _d;
135
+ if (!commandPath)
136
+ return undefined;
137
+ const command = commandPath.split(" ")[0];
138
+ if (UNSCOPED_COMMANDS.has(command) && command !== "set")
139
+ return undefined;
140
+ const target = resolveTarget(cwd);
141
+ const identity = pinnedIdentity(cwd, target.credStore);
142
+ const pinned = identity.from === "folder" || target.from === "folder";
143
+ // Groups, their members and tokens belong to the organization alone, so
144
+ // naming an environment there would describe something the command ignores.
145
+ const orgOnly = ORG_ONLY_RESOURCES.has((_a = commandPath.split(" ")[1]) !== null && _a !== void 0 ? _a : "");
146
+ const where = describeIdentity(target.deployment, identity, identity.from, target.from, orgOnly ? "organization" : "environment");
147
+ if (command === "set") {
148
+ if (pinned) {
149
+ log(`This directory stays on ${where} \`cred set\` changes your global settings; \`cred --cell <cell> init\` re-pins this directory.`);
150
+ }
151
+ return undefined;
152
+ }
153
+ // Named in every confirmation, pinned or not: the global case is the one
154
+ // most likely to be wrong, as `describeIdentity` explains.
155
+ (0, utils_1.setCommandTarget)(orgOnly
156
+ ? `organization ${(_b = identity.organization) !== null && _b !== void 0 ? _b : "?"} on ${target.deployment}`
157
+ : `${(_c = identity.organization) !== null && _c !== void 0 ? _c : "?"}/${(_d = identity.environment) !== null && _d !== void 0 ? _d : "?"} on ${target.deployment}`);
158
+ // These print their own "Publishing to …" line and resolve the pin
159
+ // themselves.
160
+ if (PINNED_COMMANDS.has(commandPath))
161
+ return undefined;
162
+ if (pinned) {
163
+ clientconfiguration_1.ClientConfiguration.scopeCommand({
164
+ deployment: target.deployment,
165
+ organization: identity.organization,
166
+ environment: identity.environment,
167
+ });
168
+ }
169
+ // Every time, pinned or global, so an agent always has the line to check
170
+ // against the organization and environment it means.
171
+ const line = `Using ${where}`;
172
+ log(line);
173
+ return line;
174
+ }
175
+ /**
176
+ * Refuse a write whose `--cell` makes the directory's pin inert. Takes
177
+ * Commander's resolved command path: the argv heuristic that scopes reads
178
+ * reads `publish --replication 2` as `publish 2`.
179
+ */
180
+ function refuseWriteUnderIgnoredPin(commandPath, cwd) {
181
+ if (!PINNED_COMMANDS.has(commandPath))
182
+ return;
183
+ const target = resolveTarget(cwd);
184
+ refuseIgnoredPin(commandPath, pinnedIdentity(cwd, target.credStore).ignoredPin, target.deployment);
185
+ }
186
+ /**
187
+ * The credential store the `preAction` refresh has to renew for a command.
188
+ *
189
+ * A pinned command sends the pinned deployment's token, so that is the one to
190
+ * check. Checking the global one instead failed `cred publish` with "not logged
191
+ * in" in a directory pinned to a deployment whose login was fine, whenever the
192
+ * global deployment's login had lapsed.
193
+ */
194
+ function credStoreToRefresh(commandPath, cwd, globalStore) {
195
+ return PINNED_COMMANDS.has(commandPath)
196
+ ? resolveTarget(cwd).credStore
197
+ : globalStore;
198
+ }
199
+ /**
200
+ * Whether the `preAction` refresh must skip this command: `publish --dry-run`
201
+ * (and `add version --dry-run`) uploads nothing and needs no login. Without
202
+ * this, a logged-out user's preview exited 1 before `publish` was reached.
203
+ */
204
+ function needsNoSession(commandPath, options) {
205
+ return PUBLISH_COMMANDS.has(commandPath) && Boolean(options.dryRun);
206
+ }
207
+ /**
208
+ * Say where a command is about to act, and on whose say-so.
209
+ *
210
+ * Always, not only when a pin was involved. The silent case used to be the
211
+ * global fallback, which is exactly the one most likely to be wrong: `cred
212
+ * init` writes the settled organization and environment back to `~/.cred` as
213
+ * well as to the pin, so running init in `repo/pkg-a` moves the global too —
214
+ * and a later `cred publish` from an unpinned `repo/` picks those up and
215
+ * publishes to pkg-a's environment without a word. Naming the source is what
216
+ * makes that visible before the upload rather than after it.
217
+ */
218
+ function describeIdentity(deployment, identity, from, deploymentFrom,
219
+ /** `organization` for a command that has no environment, such as groups. */
220
+ scope = "environment") {
221
+ var _a, _b, _c;
222
+ const where = from === "folder"
223
+ ? "pinned in .credible/config.json"
224
+ : deploymentFrom === "flag"
225
+ ? `set by --cell${identity.ignoredPin ? ` (this directory's pin to ${identity.ignoredPin} is ignored)` : ""}`
226
+ : // Names `cred init` and no flags: the callers, `publish` and
227
+ // `add connection`, have no --organization/--environment.
228
+ "from your global settings (~/.cred) — run `cred init` here to pin this directory";
229
+ const target = scope === "organization"
230
+ ? `organization ${(_a = identity.organization) !== null && _a !== void 0 ? _a : "?"}`
231
+ : `${(_b = identity.organization) !== null && _b !== void 0 ? _b : "?"}/${(_c = identity.environment) !== null && _c !== void 0 ? _c : "?"}`;
232
+ return `${target} on ${deployment}, ${where}.`;
233
+ }
234
+ /**
235
+ * The directory's pin, unless it is for another cell than `deployment`: its
236
+ * organization and environment name things in that cell, so `--cell` ignores
237
+ * them (and `ignoredPin` says which cell they were for).
238
+ */
239
+ function pinFor(cwd, deployment) {
240
+ var _a;
241
+ const pinCell = (0, folderconfig_1.resolveDeployment)({ cwd, globalDefault: deployment });
242
+ if (pinCell.from === "folder" && pinCell.deployment !== deployment) {
243
+ return { ignoredPin: pinCell.deployment };
244
+ }
245
+ return { pin: (_a = (0, folderconfig_1.findFolderConfig)(cwd)) === null || _a === void 0 ? void 0 : _a.config };
246
+ }
247
+ /**
248
+ * `--cell` ignores a pin for another cell, so a write that followed it would
249
+ * act on an organization and environment the directory never named. `cred init`
250
+ * is the one explicit re-pin.
251
+ */
252
+ function refuseIgnoredPin(command, ignoredPin, deployment) {
253
+ if (!ignoredPin)
254
+ return;
255
+ throw new host_1.SetupError(`\`cred ${command}\` writes, and this directory is pinned to ${ignoredPin}, not ${deployment}.`, `run \`cred --cell ${deployment} init\` to re-pin it on purpose, or drop --cell.`);
256
+ }
257
+ /**
258
+ * The organization and environment a command in `cwd` acts on: the directory's
259
+ * pin when there is one, else the global `~/.cred` value — the same precedence
260
+ * `init` and `dev` apply, minus flags. `cred publish` and the standalone
261
+ * connection import read this rather than the global value alone: a
262
+ * `cred add environment` in another tab moves the global, and a publish that
263
+ * followed it went to that environment while the pin named another.
264
+ */
265
+ function pinnedIdentity(cwd, credStore) {
266
+ const { pin, ignoredPin } = pinFor(cwd, credStore.getEnvironment());
267
+ const resolved = (0, folderconfig_1.resolveIdentity)({
268
+ flag: {},
269
+ folder: {
270
+ organization: pin === null || pin === void 0 ? void 0 : pin.organization,
271
+ environment: pin === null || pin === void 0 ? void 0 : pin.environment,
272
+ },
273
+ global: {
274
+ organization: credStore.getOrganization(),
275
+ environment: credStore.getProject(),
276
+ },
277
+ });
278
+ return {
279
+ organization: resolved.organization.value,
280
+ environment: resolved.environment.value,
281
+ from: resolved.environment.from === "folder" ||
282
+ resolved.organization.from === "folder"
283
+ ? "folder"
284
+ : "global",
285
+ ignoredPin,
286
+ };
287
+ }
288
+ function hasConnections(wired) {
289
+ return wired.config.environments[0].connections.length > 0;
290
+ }
291
+ /**
292
+ * The last line for an environment with no connections. Not "now open
293
+ * claude": the server is up, but every query an agent tries will fail.
294
+ */
295
+ function servingWithoutConnections(uiUrl) {
296
+ return `Publisher is serving ${kleur_1.default.cyan(uiUrl)}, but the environment has no connections, so there is nothing to query yet. To fix it, ${briefing_1.NO_CONNECTIONS_NEXT_STEP}.`;
297
+ }
298
+ /**
299
+ * What the local Publisher proxies: the environment's connections, then each
300
+ * `READY` database under its own name (database-design.md §12.5). A database
301
+ * is not on the connections list, but it is addressed through the same
302
+ * router route, so `buildPublisherConfig` gives it the same `connectionUriFor`
303
+ * and `@malloydata/db-publisher` needs no change.
304
+ *
305
+ * A 404 from `listDatabases` is a deployment without databases, so it adds
306
+ * none. Any other failure is a warning, not a failed `cred dev`: the
307
+ * connections alone still serve every model that does not read a database.
308
+ */
309
+ function listProxiedConnections(controlPlane, credStore, organization, credibleEnvironment) {
310
+ return __awaiter(this, void 0, void 0, function* () {
311
+ var _a, _b, _c;
312
+ const options = { baseURL: controlPlane, headers: credStore.getHeaders() };
313
+ const connections = (_a = (yield connectionsApi.listConnections(organization, credibleEnvironment, -1, 0, options)).data) !== null && _a !== void 0 ? _a : [];
314
+ let databases = [];
315
+ try {
316
+ const listed = (_b = (yield shared_1.databasesApi.listDatabases(organization, credibleEnvironment, -1, 0, options)).data) !== null && _b !== void 0 ? _b : [];
317
+ databases = listed
318
+ .filter((database) => database.status === "READY")
319
+ .map((database) => ({ name: database.name }));
320
+ }
321
+ catch (error) {
322
+ if (!((0, axios_1.isAxiosError)(error) && ((_c = error.response) === null || _c === void 0 ? void 0 : _c.status) === 404)) {
323
+ logger_1.logger.warn(`Could not list the databases of '${credibleEnvironment}' (${(0, utils_1.describeApiError)(error)}), so the local Publisher has its connections only.`);
324
+ }
325
+ }
326
+ const named = new Set(connections.map((c) => c.name));
327
+ return [
328
+ ...connections,
329
+ ...databases.filter((database) => !named.has(database.name)),
330
+ ];
331
+ });
332
+ }
333
+ function buildContext(deployment, credStore, canOpenBrowser, identity) {
334
+ const controlPlane = constants_1.controlPlanesByEnv[deployment];
335
+ return {
336
+ host: (0, inquirerHost_1.createInquirerHost)({ canOpenBrowser, session: credStore }),
337
+ credStore,
338
+ deployment,
339
+ publisherVersion: publisherversion_1.PUBLISHER_VERSION,
340
+ cwd: process.cwd(),
341
+ showAllPublisherOutput: logger_1.debugRequested,
342
+ listConnections: (organization, credibleEnvironment) => listProxiedConnections(controlPlane, credStore, organization, credibleEnvironment),
343
+ // Bound to the pair `chooseTarget` settled, not read from the store at
344
+ // call time: another terminal's `cred set environment` while the
345
+ // credential question is open must not redirect the create.
346
+ createConnection: (0, createconnections_1.makeConnectionCreator)(controlPlane, credStore, {
347
+ organization: identity.organization,
348
+ environment: identity.credibleEnvironment,
349
+ }),
350
+ fetchSkills: (manifest) => __awaiter(this, void 0, void 0, function* () {
351
+ var _a;
352
+ try {
353
+ const response = yield codeAssistApi.getAgentSkills(manifest, undefined, undefined, {
354
+ baseURL: constants_1.codeAssistByEnv[deployment],
355
+ headers: credStore.getHeaders(),
356
+ });
357
+ return response.data;
358
+ }
359
+ catch (error) {
360
+ // A deployment without the endpoint has no skills to offer; that
361
+ // is a skip, not a failure. Anything else is reported by the flow.
362
+ if ((0, axios_1.isAxiosError)(error) && ((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === 404) {
363
+ return undefined;
364
+ }
365
+ throw new Error((0, utils_1.describeApiError)(error));
366
+ }
367
+ }),
368
+ };
369
+ }
370
+ /**
371
+ * Parse `--connections`. Anything but the two keywords is a name list.
372
+ *
373
+ * Empty names (`a,,b`, a trailing comma) are dropped rather than passed on as
374
+ * a lookup for `''` that fails with a confusing "no connection named ''".
375
+ */
376
+ function parseConnectionsFlag(value) {
377
+ if (value === undefined)
378
+ return undefined;
379
+ const trimmed = value.trim();
380
+ if (trimmed === "all" || trimmed === "none")
381
+ return trimmed;
382
+ const names = trimmed
383
+ .split(",")
384
+ .map((name) => name.trim())
385
+ .filter(Boolean);
386
+ if (names.length === 0) {
387
+ throw new host_1.UsageError(`${importconnections_1.CONNECTIONS_FLAG} was given '${value}', which names nothing.`, "pass all, none, or a comma-separated list of connection names.");
388
+ }
389
+ return names;
390
+ }
391
+ /**
392
+ * Report a SetupError as its message, and anything else as itself.
393
+ *
394
+ * A question that could not be asked exits 2, not 1: it is the one failure a
395
+ * caller can fix by re-running with the flag the message names, and a script
396
+ * needs to tell that apart from "setup broke".
397
+ */
398
+ function reportAndExit(error) {
399
+ if (error instanceof host_1.NeedsInputError) {
400
+ logger_1.logger.error(error.message);
401
+ process.exit(error.exitCode);
402
+ }
403
+ if (error instanceof host_1.ReportedSetupError) {
404
+ process.exit(1);
405
+ }
406
+ if (error instanceof host_1.UsageError) {
407
+ logger_1.logger.error(error.message);
408
+ process.exit(error.exitCode);
409
+ }
410
+ if (error instanceof host_1.SetupError) {
411
+ logger_1.logger.error(error.message);
412
+ }
413
+ else {
414
+ logger_1.logger.error(error instanceof Error ? error.message : String(error));
415
+ }
416
+ process.exit(1);
417
+ }
418
+ /**
419
+ * Make sure we are logged in with an organization and an environment, prompting
420
+ * for whatever is missing.
421
+ *
422
+ * This is what makes `cred init` the single command a new user is told to type.
423
+ * `cred login` and `cred set environment` still exist — they are what you run
424
+ * *again* — but a first-time user should not have to know they come first, and
425
+ * should certainly not learn it from an error message.
426
+ *
427
+ * This is also why `init` and `dev` are exempt from the global token-refresh
428
+ * hook in `index.ts`: that hook exits the process when it finds no credentials,
429
+ * which for these two commands is the state they exist to resolve. They do their
430
+ * own refresh here instead — a spent-but-refreshable token has to renew silently
431
+ * rather than trigger a browser round-trip, since the `listConnections` call in
432
+ * `wireDirectory` needs a live token either way.
433
+ *
434
+ * `organization` is the one already known — `--organization`, else the pin's.
435
+ * Dropping it failed every AWS login (its tenant needs the organization up
436
+ * front) and, on GCP, opened the organization picker, which exits 2 without a
437
+ * terminal even when `-o` named it.
438
+ */
439
+ function ensureLoggedIn(credStore, organization) {
440
+ return __awaiter(this, void 0, void 0, function* () {
441
+ const refreshed = yield (0, refresh_1.ensureFreshTokens)(credStore);
442
+ if (refreshed.status === "offline" || refreshed.status === "not-renewable") {
443
+ logger_1.logger.warn(refreshed.reason);
444
+ }
445
+ const needsLogin = refreshed.status === "logged-out" || !credStore.isTokenValid().valid;
446
+ if (needsLogin) {
447
+ logger_1.logger.info("You are not logged in yet — starting that now.");
448
+ const currentEnv = credStore.getEnvironment();
449
+ // The cluster is this deployment's, asked for explicitly: named alone,
450
+ // an organization picks its own default cluster, which can be another
451
+ // deployment's (videoamp defaults to gcp), and the tokens would land in
452
+ // a slot nothing here reads.
453
+ let target;
454
+ try {
455
+ target = (0, login_1.resolveLoginTarget)(currentEnv, organization, constants_1.CLUSTER_BY_ENVIRONMENT[currentEnv]);
456
+ }
457
+ catch (error) {
458
+ throw new host_1.SetupError(error instanceof Error ? error.message : String(error));
459
+ }
460
+ yield (0, login_1.login)(organization, constants_1.controlPlanesByEnv[target.targetEnv], undefined, target.cluster,
461
+ // The deployment `credStore` is scoped to. Without it login writes the
462
+ // tokens and organization under the file's global `activeEnvironment`,
463
+ // and the `getOrganization()` check below then reads a slot login
464
+ // never touched — so a directory pinned to a non-global deployment,
465
+ // the case the pin exists for, failed its own first run.
466
+ target.targetEnv);
467
+ }
468
+ if (!credStore.getOrganization()) {
469
+ // login() persists the organization it resolved, so reaching here means
470
+ // login did not complete. Its own output already said why.
471
+ throw new host_1.SetupError("Setup needs an organization and login did not finish.", "run `cred login` and try again.");
472
+ }
473
+ });
474
+ }
475
+ /**
476
+ * Establish which organization and Credible environment this directory is for.
477
+ *
478
+ * These two values are baked into `.mcp.json`, the agent briefing and the
479
+ * publisher config, and they are the expensive ones to get wrong: a directory
480
+ * wired against the wrong environment looks completely normal until someone
481
+ * queries it.
482
+ *
483
+ * Resolution order is {@link resolveIdentity}'s: a flag, then this directory's
484
+ * pin, then the global `~/.cred` value. What each mode does with the result:
485
+ *
486
+ * - `always-ask` (`init`) asks unless a flag settled it. It is the
487
+ * once-per-directory command, and `selectFromList` skips a prompt with one
488
+ * option, so a single-organization user sees no extra step anyway.
489
+ * - `confirm` (`dev`) states what the pin says and takes a yes, opening the
490
+ * pickers on a no. A flag skips the question and re-pins, which is how
491
+ * `cred dev --environment staging` switches a directory over.
492
+ *
493
+ * Whatever is settled is written back to the directory's pin by
494
+ * {@link wireDirectory}, and to `~/.cred` here so unrelated commands
495
+ * (`cred publish`) act on the same pair.
496
+ */
497
+ function chooseTarget(credStore, deployment, mode, flags, cwd) {
498
+ return __awaiter(this, void 0, void 0, function* () {
499
+ const controlPlane = constants_1.controlPlanesByEnv[deployment];
500
+ const { pin } = pinFor(cwd, deployment);
501
+ const resolved = (0, folderconfig_1.resolveIdentity)({
502
+ flag: flags,
503
+ folder: {
504
+ organization: pin === null || pin === void 0 ? void 0 : pin.organization,
505
+ environment: pin === null || pin === void 0 ? void 0 : pin.environment,
506
+ },
507
+ global: {
508
+ organization: credStore.getOrganization(),
509
+ environment: credStore.getProject(),
510
+ },
511
+ });
512
+ // A flag is an instruction, not a suggestion, so it is never confirmed. It is
513
+ // also the only path a script can take, and a script cannot answer a prompt.
514
+ //
515
+ // Either flag suppresses the confirmation, not both together. The shortcut
516
+ // below persists what it confirms *without validating it*, so with one flag
517
+ // set it read the flag's value back out of `resolveIdentity`, put it in the
518
+ // prompt, and wrote a yes straight to disk — which is how `cred dev
519
+ // --environment stagng` re-pinned a directory to a typo and then failed
520
+ // somewhere far from the cause. A named value goes through `setEnvironment`.
521
+ const flagged = resolved.organization.from === "flag" ||
522
+ resolved.environment.from === "flag";
523
+ // A "no" to the confirmation below. `settleTarget` in `confirm` mode keeps
524
+ // the resolved pair, so without this a decline re-wired the very pair the
525
+ // user had just turned down.
526
+ let declined = false;
527
+ if (!flagged && mode === "confirm") {
528
+ const { value: organization } = resolved.organization;
529
+ const { value: environment } = resolved.environment;
530
+ if (organization && environment) {
531
+ // The confirm re-states recorded state, so without a terminal it is
532
+ // taken as a yes rather than refused: `cred dev` in an agent's shell
533
+ // must start the publisher, not exit asking for a flag that would
534
+ // only repeat what the pin already says. `--yes` is the same answer
535
+ // given on purpose.
536
+ // Taken as a yes silently: `dev` has already printed the target line
537
+ // every scoped command prints, so saying it again here repeated it.
538
+ const keep = flags.yes || !(0, utils_1.isInteractive)()
539
+ ? true
540
+ : yield (0, utils_1.getConfirmation)(`Use organization ${kleur_1.default.cyan(organization)} and environment ${kleur_1.default.cyan(environment)}?`, credStore, { flag: "--yes" });
541
+ if (keep)
542
+ return persist(credStore, organization, environment);
543
+ declined = true;
544
+ }
545
+ }
546
+ // `~/.cred` gets the settled pair or nothing. The organization has to be in
547
+ // the store before `setEnvironment` can list its environments, so a refused
548
+ // environment would otherwise leave the new organization beside the old
549
+ // environment — a pair nobody chose, which the next unpinned `cred publish`
550
+ // targets.
551
+ const before = {
552
+ organization: credStore.getOrganization(),
553
+ environment: credStore.getProject(),
554
+ };
555
+ const restore = () => {
556
+ credStore.setOrganization(before.organization);
557
+ credStore.setProject(before.environment);
558
+ };
559
+ // Ctrl-C at a picker does not throw. Inquirer closes the prompt and re-raises
560
+ // SIGINT at the process, and nothing else is listening yet (the supervisor
561
+ // subscribes once it spawns), so Node exited with the new organization and
562
+ // no environment on disk. Listening here is also what keeps Node from
563
+ // exiting on its own, so this handler has to exit.
564
+ const onSignal = (signal) => {
565
+ restore();
566
+ process.exit(signal === "SIGINT" ? 130 : 1);
567
+ };
568
+ for (const signal of inquirerHost_1.INTERRUPTS)
569
+ process.once(signal, onSignal);
570
+ try {
571
+ return yield settleTarget(credStore, controlPlane, declined ? "always-ask" : mode, flags, resolved);
572
+ }
573
+ catch (error) {
574
+ restore();
575
+ throw error;
576
+ }
577
+ finally {
578
+ for (const signal of inquirerHost_1.INTERRUPTS)
579
+ process.off(signal, onSignal);
580
+ }
581
+ });
582
+ }
583
+ /** The part of {@link chooseTarget} that writes to the store as it goes. */
584
+ function settleTarget(credStore, controlPlane, mode, flags, resolved) {
585
+ return __awaiter(this, void 0, void 0, function* () {
586
+ var _a, _b;
587
+ // `confirm` mode keeps the organization it already resolved rather than
588
+ // re-asking: `cred dev --environment other-bars` is a request to change the
589
+ // environment, and answering an organization picker to do it would be a
590
+ // question the user has already answered once for this directory.
591
+ const organization = (_b = (_a = flags.organization) !== null && _a !== void 0 ? _a : (mode === "confirm" ? resolved.organization.value : undefined)) !== null && _b !== void 0 ? _b :
592
+ // `cred init` and `cred dev` both take `--organization`; the default
593
+ // hint names `cred login <organization>`, a different command.
594
+ (yield (0, login_1.resolveOrganization)(undefined, controlPlane, credStore, "--organization <name>"));
595
+ credStore.setOrganization(organization);
596
+ // Both front doors take `--create-environment`. `dev` once pointed at
597
+ // `cred add environment` instead, which creates on the pin's organization:
598
+ // wrong after `cred dev -o other-org`, where this is the one that is meant.
599
+ const hints = setenvironment_1.INIT_ENVIRONMENT_HINTS;
600
+ // The name we asked for, when we named one, for the message below. Left
601
+ // undefined for the picker, whose answer we do not know in advance.
602
+ let requested;
603
+ let accepted;
604
+ if (flags.environment) {
605
+ // Validated rather than trusted: `setEnvironment` refuses a name the
606
+ // organization does not have, and a typo caught here is one that does not
607
+ // reach the publisher config as a dead connectionUri.
608
+ requested = flags.environment;
609
+ accepted = yield (0, setenvironment_1.setEnvironment)(flags.environment, credStore, {
610
+ createIfMissing: flags.createEnvironment,
611
+ hints,
612
+ });
613
+ }
614
+ else if (mode === "always-ask" || !resolved.environment.value) {
615
+ // Cleared first so the picker is a real choice rather than a confirmation
616
+ // of a stale value. `undefined`, not `""`: an empty string survives
617
+ // `getProject() ?? "Not set"` in `cred status` and prints a blank line,
618
+ // so an interrupted setup would report differently from every other
619
+ // unset-environment path.
620
+ const current = credStore.getProject();
621
+ credStore.setProject(undefined);
622
+ accepted = yield (0, setenvironment_1.setEnvironment)(undefined, credStore, {
623
+ current,
624
+ hints,
625
+ });
626
+ }
627
+ else {
628
+ requested = resolved.environment.value;
629
+ accepted = yield (0, setenvironment_1.setEnvironment)(requested, credStore, {
630
+ hints,
631
+ });
632
+ }
633
+ // Asked, not inferred from the store. `setEnvironment` refuses a name by
634
+ // returning without writing, and the store can still hold that same name
635
+ // from before: `cred dev --organization other-org` keeps the pin's
636
+ // environment name, and when other-org lacks it the old value matched and
637
+ // the directory was re-pinned to an environment its organization does not
638
+ // have.
639
+ const chosen = credStore.getProject();
640
+ if (!accepted) {
641
+ // `setEnvironment` has already logged what went wrong and how to fix it,
642
+ // in this front door's own hints; saying it again printed two errors.
643
+ throw new host_1.ReportedSetupError("Setup needs a Credible environment.");
644
+ }
645
+ if (!chosen) {
646
+ throw new host_1.SetupError("Setup needs a Credible environment.", requested
647
+ ? `check the name '${requested}', or pass --create-environment to create it.`
648
+ : `re-run \`cred ${mode === "confirm" ? "dev" : "init"}\` and pick or create one, or pass --environment <name> [--create-environment].`);
649
+ }
650
+ return { organization, credibleEnvironment: chosen };
651
+ });
652
+ }
653
+ /** Record the settled pair globally, and hand it back for the flow to pin. */
654
+ function persist(credStore, organization, credibleEnvironment) {
655
+ credStore.setOrganization(organization);
656
+ credStore.setProject(credibleEnvironment);
657
+ return { organization, credibleEnvironment };
658
+ }
659
+ /** Parse `--skills`. A value outside the three is refused, never guessed at. */
660
+ function parseSkillsFlag(value) {
661
+ if (value === undefined)
662
+ return undefined;
663
+ if (value === "replace" || value === "keep" || value === "none")
664
+ return value;
665
+ throw new host_1.UsageError(`${skills_1.SKILLS_FLAG} was given '${value}'.`, "pass replace, keep, or none.");
666
+ }
667
+ /**
668
+ * Parse `--port`. Refused unless it is a whole number whose MCP partner, 40
669
+ * above it, is a valid port too; never rounded or clamped into one.
670
+ */
671
+ function parsePortFlag(value) {
672
+ if (value === undefined)
673
+ return undefined;
674
+ const port = Number(value);
675
+ if (!/^\d+$/.test(value) || port < ports_1.MIN_UI_PORT || port > ports_1.MAX_UI_PORT) {
676
+ throw new host_1.UsageError(`${flow_1.PORT_FLAG} was given '${value}'.`, `pass a whole number from ${ports_1.MIN_UI_PORT} to ${ports_1.MAX_UI_PORT}; the MCP server takes the port ${ports_1.MCP_OFFSET} above it. Example: ${flow_1.PORT_FLAG} 4100.`);
677
+ }
678
+ return port;
679
+ }
680
+ function setup(options) {
681
+ return __awaiter(this, void 0, void 0, function* () {
682
+ var _a, _b, _c, _d, _e, _f;
683
+ let target;
684
+ try {
685
+ target = resolveTarget((_a = options.directory) !== null && _a !== void 0 ? _a : process.cwd());
686
+ }
687
+ catch (error) {
688
+ reportAndExit(error);
689
+ }
690
+ const { deployment, credStore } = target;
691
+ try {
692
+ // Before logging in or choosing an environment, both of which write.
693
+ (0, flow_1.refuseUnanswerable)(path_1.default.resolve((_b = options.directory) !== null && _b !== void 0 ? _b : process.cwd()), {
694
+ connections: parseConnectionsFlag(options.connections),
695
+ skills: parseSkillsFlag(options.skills),
696
+ package: options.package,
697
+ }, (0, utils_1.isInteractive)());
698
+ const port = parsePortFlag(options.port);
699
+ // A chosen --port is checked even with --no-start: it rewrites the pin
700
+ // and .mcp.json, so a busy or conflicting pair is refused up front.
701
+ if (options.start || port !== undefined) {
702
+ yield (0, flow_1.refuseBesideOtherPublisher)(path_1.default.resolve((_c = options.directory) !== null && _c !== void 0 ? _c : process.cwd()), port);
703
+ }
704
+ const { pin, ignoredPin } = pinFor((_d = options.directory) !== null && _d !== void 0 ? _d : process.cwd(), deployment);
705
+ if (ignoredPin) {
706
+ logger_1.logger.info(`re-pinning this directory from ${ignoredPin} to ${deployment}`);
707
+ }
708
+ yield ensureLoggedIn(credStore, (_e = options.organization) !== null && _e !== void 0 ? _e : pin === null || pin === void 0 ? void 0 : pin.organization);
709
+ const identity = yield chooseTarget(credStore, deployment, "always-ask", {
710
+ organization: options.organization,
711
+ environment: options.environment,
712
+ createEnvironment: options.createEnvironment,
713
+ }, (_f = options.directory) !== null && _f !== void 0 ? _f : process.cwd());
714
+ const context = buildContext(deployment, credStore, options.open, identity);
715
+ const { wired, running } = yield (0, flow_1.runSetup)(context, Object.assign(Object.assign(Object.assign({}, options), identity), { connections: parseConnectionsFlag(options.connections), skills: parseSkillsFlag(options.skills), port }));
716
+ if (!running)
717
+ return;
718
+ // The one next step, printed once, immediately before the server's own
719
+ // output takes over the tab.
720
+ logger_1.logger.info(hasConnections(wired)
721
+ ? `Publisher is serving ${kleur_1.default.cyan(running.uiUrl)} — now open ${kleur_1.default.bold("claude")} in another tab.`
722
+ : servingWithoutConnections(running.uiUrl));
723
+ yield waitUntilStopped(running);
724
+ }
725
+ catch (error) {
726
+ reportAndExit(error);
727
+ }
728
+ });
729
+ }
730
+ function dev(options) {
731
+ return __awaiter(this, void 0, void 0, function* () {
732
+ var _a, _b;
733
+ const cwd = process.cwd();
734
+ const found = (0, folderconfig_1.findFolderConfig)(cwd);
735
+ if (!found) {
736
+ logger_1.logger.error("This directory is not set up for Credible yet. Run `cred init` here first.");
737
+ process.exit(1);
738
+ }
739
+ let target;
740
+ try {
741
+ target = resolveTarget(cwd);
742
+ }
743
+ catch (error) {
744
+ reportAndExit(error);
745
+ }
746
+ const { deployment, credStore, from } = target;
747
+ // The same line every scoped command prints, so `cred dev` is checked the
748
+ // same way. The pin's organization and environment, before any `-o`/`-e`.
749
+ const pinned = pinnedIdentity(cwd, credStore);
750
+ try {
751
+ // Before login: wiring would rewrite .mcp.json and the briefing too.
752
+ refuseIgnoredPin("dev", pinned.ignoredPin, deployment);
753
+ }
754
+ catch (error) {
755
+ reportAndExit(error);
756
+ }
757
+ logger_1.logger.info(`Using ${describeIdentity(deployment, pinned, pinned.from, from)}`);
758
+ try {
759
+ // The same gate as init's, before login and the environment write. `dev`
760
+ // never imports connections, so there is no connections question to ask.
761
+ (0, flow_1.refuseUnanswerable)(found.root, {
762
+ connections: "none",
763
+ skills: parseSkillsFlag(options.skills),
764
+ package: options.package,
765
+ }, (0, utils_1.isInteractive)());
766
+ const port = parsePortFlag(options.port);
767
+ yield (0, flow_1.refuseBesideOtherPublisher)(found.root, port);
768
+ yield ensureLoggedIn(credStore, (_a = options.organization) !== null && _a !== void 0 ? _a : (_b = pinFor(cwd, deployment).pin) === null || _b === void 0 ? void 0 : _b.organization);
769
+ const identity = yield chooseTarget(credStore, deployment, "confirm", {
770
+ organization: options.organization,
771
+ environment: options.environment,
772
+ createEnvironment: options.createEnvironment,
773
+ yes: options.yes,
774
+ }, found.root);
775
+ const context = buildContext(deployment, credStore, options.open, identity);
776
+ // Re-wire rather than replay: connections may have changed in Credible
777
+ // since setup ran, and picking that up is cheaper than making the user
778
+ // notice a missing connection and re-run setup.
779
+ const wired = yield (0, flow_1.wireDirectory)(context, Object.assign(Object.assign({ directory: found.root }, identity), { skipConnectionImport: true, package: options.package, skills: parseSkillsFlag(options.skills), port, start: true, open: options.open }));
780
+ const running = yield (0, flow_1.startSession)(context, wired, {
781
+ open: options.open,
782
+ });
783
+ logger_1.logger.info(hasConnections(wired)
784
+ ? `Publisher is serving ${kleur_1.default.cyan(running.uiUrl)}.`
785
+ : servingWithoutConnections(running.uiUrl));
786
+ yield waitUntilStopped(running);
787
+ }
788
+ catch (error) {
789
+ reportAndExit(error);
790
+ }
791
+ });
792
+ }
793
+ /**
794
+ * Hold the terminal until the server exits.
795
+ *
796
+ * Foreground is the v1 lifecycle on purpose: it is also the only channel where a
797
+ * human sees watch mode's deliberately-swallowed compile failures. Ctrl-C is the
798
+ * supervisor's to handle — it subscribed through the host when it spawned the
799
+ * server, so the same handler covers the boot wait and the session.
800
+ */
801
+ function waitUntilStopped(running) {
802
+ return __awaiter(this, void 0, void 0, function* () {
803
+ var _a;
804
+ const code = yield running.waitForExit();
805
+ // A requested stop is not a failure, but it is not a clean finish either:
806
+ // 130 is the shell's code for Ctrl-C, which a waiting script can tell from
807
+ // the 1 a dead server gives. Said aloud so the cleanup is visible.
808
+ if ((_a = running.interrupted) === null || _a === void 0 ? void 0 : _a.call(running)) {
809
+ logger_1.logger.info("Stopped the local Publisher and removed this session's token file.");
810
+ process.exitCode = 130;
811
+ return;
812
+ }
813
+ if (code && code !== 0) {
814
+ logger_1.logger.error(`The publisher exited with code ${code}.`);
815
+ process.exitCode = code;
816
+ }
817
+ });
818
+ }
819
+ //# sourceMappingURL=setup.js.map