@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,625 @@
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 logger_1 = require("../../logger");
56
+ const host_1 = require("../../setup-core/host");
57
+ const utils = __importStar(require("../../utils"));
58
+ const updateconnection_1 = require("./updateconnection");
59
+ // The stored connection as a read returns it: no secrets.
60
+ const stored = {
61
+ name: "bq_demo",
62
+ type: "bigquery",
63
+ bigqueryConnection: {
64
+ defaultProjectId: "vscode-demo",
65
+ location: "US",
66
+ serviceAccountKeyJson: undefined,
67
+ },
68
+ includeTables: ["sales.*"],
69
+ };
70
+ describe("mergeConnectionUpdate", () => {
71
+ // The use case: the service-account key is old. A file with only the new
72
+ // key, sent as it is, would clear the project id, because the update
73
+ // replaces the whole connection.
74
+ it("rotates a key and keeps everything else", () => {
75
+ const { connection, changed } = (0, updateconnection_1.mergeConnectionUpdate)(stored, {
76
+ name: "bq_demo",
77
+ bigqueryConnection: { serviceAccountKeyJson: '{"new":"key"}' },
78
+ });
79
+ (0, chai_1.expect)(connection).to.deep.equal({
80
+ name: "bq_demo",
81
+ type: "bigquery",
82
+ bigqueryConnection: {
83
+ defaultProjectId: "vscode-demo",
84
+ location: "US",
85
+ serviceAccountKeyJson: '{"new":"key"}',
86
+ },
87
+ includeTables: ["sales.*"],
88
+ });
89
+ (0, chai_1.expect)(changed).to.eql(["bigqueryConnection.serviceAccountKeyJson"]);
90
+ });
91
+ // Every update sent re-indexes the connection, so re-applying the same
92
+ // file must list nothing and send nothing.
93
+ it("lists nothing as changed when the file repeats the stored values", () => {
94
+ const { changed } = (0, updateconnection_1.mergeConnectionUpdate)(stored, {
95
+ name: "bq_demo",
96
+ type: "bigquery",
97
+ bigqueryConnection: {
98
+ defaultProjectId: "vscode-demo",
99
+ location: "US",
100
+ },
101
+ includeTables: ["sales.*"],
102
+ });
103
+ (0, chai_1.expect)(changed).to.eql([]);
104
+ (0, chai_1.expect)((0, updateconnection_1.mergeConnectionUpdate)(stored, {
105
+ name: "bq_demo",
106
+ bigqueryConnection: { location: "EU" },
107
+ includeTables: ["sales.*", "ops.*"],
108
+ }).changed).to.eql(["bigqueryConnection.location", "includeTables"]);
109
+ });
110
+ // A read never returns secrets, so echoing a blank one back must omit it:
111
+ // the server keeps a stored secret only when its field is left out.
112
+ it("leaves out blank stored values instead of sending them empty", () => {
113
+ const withBlank = Object.assign(Object.assign({}, stored), { bigqueryConnection: {
114
+ defaultProjectId: "p",
115
+ serviceAccountKeyJson: "",
116
+ } });
117
+ const { connection } = (0, updateconnection_1.mergeConnectionUpdate)(withBlank, {
118
+ name: "bq_demo",
119
+ bigqueryConnection: { location: "EU" },
120
+ });
121
+ (0, chai_1.expect)(connection
122
+ .bigqueryConnection).to.deep.equal({ defaultProjectId: "p", location: "EU" });
123
+ });
124
+ it("carries a postgres proxy over, since the update would remove it", () => {
125
+ const pg = {
126
+ name: "pg",
127
+ type: "postgres",
128
+ postgresConnection: { host: "db" },
129
+ proxy: { type: "ssh", host: "bastion" },
130
+ includeTables: ["public.*"],
131
+ };
132
+ const { connection } = (0, updateconnection_1.mergeConnectionUpdate)(pg, {
133
+ name: "pg",
134
+ postgresConnection: { password: "new" },
135
+ });
136
+ (0, chai_1.expect)(connection.proxy).to.deep.equal({ type: "ssh", host: "bastion" });
137
+ });
138
+ // A read returns every attached database; a file naming one of them must
139
+ // not drop the others, and the server merges stored secrets by position,
140
+ // so the stored order has to survive.
141
+ it("merges attached databases by name and keeps the ones the file leaves out", () => {
142
+ var _a;
143
+ const duck = {
144
+ name: "lake",
145
+ type: "duckdb",
146
+ duckdbConnection: {
147
+ attachedDatabases: [
148
+ {
149
+ name: "a",
150
+ type: "bigquery",
151
+ bigqueryConnection: { defaultProjectId: "pa" },
152
+ },
153
+ {
154
+ name: "b",
155
+ type: "postgres",
156
+ postgresConnection: { host: "hb" },
157
+ },
158
+ ],
159
+ },
160
+ includeTables: ["a.*"],
161
+ };
162
+ const { connection, changed } = (0, updateconnection_1.mergeConnectionUpdate)(duck, {
163
+ name: "lake",
164
+ duckdbConnection: {
165
+ attachedDatabases: [
166
+ {
167
+ name: "a",
168
+ bigqueryConnection: { serviceAccountKeyJson: "k" },
169
+ },
170
+ ],
171
+ },
172
+ });
173
+ (0, chai_1.expect)((_a = connection.duckdbConnection) === null || _a === void 0 ? void 0 : _a.attachedDatabases).to.deep.equal([
174
+ {
175
+ name: "a",
176
+ type: "bigquery",
177
+ bigqueryConnection: {
178
+ defaultProjectId: "pa",
179
+ serviceAccountKeyJson: "k",
180
+ },
181
+ },
182
+ { name: "b", type: "postgres", postgresConnection: { host: "hb" } },
183
+ ]);
184
+ (0, chai_1.expect)(changed).to.eql([
185
+ "duckdbConnection.attachedDatabases[a].bigqueryConnection.serviceAccountKeyJson",
186
+ ]);
187
+ });
188
+ it("keeps the rest of a nested block, like a DuckLake catalog", () => {
189
+ const lake = {
190
+ name: "dl",
191
+ type: "ducklake",
192
+ ducklakeConnection: {
193
+ catalog: {
194
+ metadataSchema: "meta",
195
+ postgresConnection: { host: "h", userName: "u", password: "" },
196
+ },
197
+ storage: { gcsConnection: { keyId: "id" } },
198
+ },
199
+ includeTables: ["main.*"],
200
+ };
201
+ const { connection, changed } = (0, updateconnection_1.mergeConnectionUpdate)(lake, {
202
+ name: "dl",
203
+ ducklakeConnection: {
204
+ catalog: { postgresConnection: { password: "new" } },
205
+ },
206
+ });
207
+ (0, chai_1.expect)(connection.ducklakeConnection).to.deep.equal({
208
+ catalog: {
209
+ metadataSchema: "meta",
210
+ postgresConnection: { host: "h", userName: "u", password: "new" },
211
+ },
212
+ storage: { gcsConnection: { keyId: "id" } },
213
+ });
214
+ (0, chai_1.expect)(changed).to.eql([
215
+ "ducklakeConnection.catalog.postgresConnection.password",
216
+ ]);
217
+ });
218
+ // Sent whole, a proxy holding only the new key loses its host, and the
219
+ // server refuses the update for want of a bastion host.
220
+ it("rotates an SSH proxy key and keeps the proxy's host", () => {
221
+ const pg = {
222
+ name: "pg",
223
+ type: "postgres",
224
+ postgresConnection: { host: "db" },
225
+ proxy: {
226
+ type: "ssh",
227
+ ssh: { host: "bastion", username: "u", port: 22 },
228
+ },
229
+ includeTables: ["public.*"],
230
+ };
231
+ const { connection, changed } = (0, updateconnection_1.mergeConnectionUpdate)(pg, {
232
+ name: "pg",
233
+ proxy: { ssh: { privateKey: "new" } },
234
+ });
235
+ (0, chai_1.expect)(connection.proxy).to.deep.equal({
236
+ type: "ssh",
237
+ ssh: { host: "bastion", username: "u", port: 22, privateKey: "new" },
238
+ });
239
+ (0, chai_1.expect)(changed).to.eql(["proxy.ssh.privateKey"]);
240
+ });
241
+ it("keeps a connection's query metadata", () => {
242
+ const tagged = Object.assign(Object.assign({}, stored), { queryMetadata: { team: "growth" } });
243
+ const { connection } = (0, updateconnection_1.mergeConnectionUpdate)(tagged, {
244
+ name: "bq_demo",
245
+ bigqueryConnection: { location: "EU" },
246
+ });
247
+ (0, chai_1.expect)(connection.queryMetadata).to.deep.equal({ team: "growth" });
248
+ });
249
+ // The server clears a list the update leaves out, so null clears it.
250
+ it("clears a table list the file sets to null", () => {
251
+ const { connection, changed } = (0, updateconnection_1.mergeConnectionUpdate)(stored, {
252
+ name: "bq_demo",
253
+ includeTables: null,
254
+ excludeAllTables: true,
255
+ });
256
+ (0, chai_1.expect)(connection.includeTables).to.equal(undefined);
257
+ (0, chai_1.expect)(connection.excludeAllTables).to.equal(true);
258
+ (0, chai_1.expect)(changed).to.eql(["includeTables", "excludeAllTables"]);
259
+ });
260
+ // Without includeTables the server stops indexing the connection, so a
261
+ // password change on one stored with none (an older connection) did that.
262
+ it("refuses an update that would stop indexing the connection", () => {
263
+ const noTables = Object.assign(Object.assign({}, stored), { includeTables: undefined, excludeAllTables: false });
264
+ (0, chai_1.expect)(() => (0, updateconnection_1.mergeConnectionUpdate)(noTables, {
265
+ name: "bq_demo",
266
+ bigqueryConnection: { serviceAccountKeyJson: "k" },
267
+ })).to.throw("'bq_demo' would have no includeTables after this update, and the server stops indexing a connection without them.");
268
+ (0, chai_1.expect)(() => (0, updateconnection_1.mergeConnectionUpdate)(stored, { name: "bq_demo", includeTables: [] })).to.throw("would have no includeTables");
269
+ });
270
+ // A read reports a connection that is not indexed as excludeAllTables:
271
+ // true; sent back, it kept the file's includeTables from being indexed.
272
+ it("refuses includeTables on a connection that is not indexed, unless the file turns indexing on", () => {
273
+ const unindexed = Object.assign(Object.assign({}, stored), { excludeAllTables: true });
274
+ (0, chai_1.expect)(() => (0, updateconnection_1.mergeConnectionUpdate)(unindexed, {
275
+ name: "bq_demo",
276
+ includeTables: ["orders.*"],
277
+ })).to.throw('Fix: add "excludeAllTables": false to the file.');
278
+ const { connection } = (0, updateconnection_1.mergeConnectionUpdate)(unindexed, {
279
+ name: "bq_demo",
280
+ includeTables: ["orders.*"],
281
+ excludeAllTables: false,
282
+ });
283
+ (0, chai_1.expect)(connection.includeTables).to.eql(["orders.*"]);
284
+ (0, chai_1.expect)(connection.excludeAllTables).to.equal(false);
285
+ });
286
+ // `type` is an ordinary key in query metadata; only the connection and an
287
+ // attached database are typed.
288
+ it("changes a query-metadata tag named type", () => {
289
+ const tagged = Object.assign(Object.assign({}, stored), { queryMetadata: { type: "internal", team: "growth" } });
290
+ const { connection, changed } = (0, updateconnection_1.mergeConnectionUpdate)(tagged, {
291
+ name: "bq_demo",
292
+ queryMetadata: { type: "external" },
293
+ });
294
+ (0, chai_1.expect)(connection.queryMetadata).to.deep.equal({
295
+ type: "external",
296
+ team: "growth",
297
+ });
298
+ (0, chai_1.expect)(changed).to.eql(["queryMetadata.type"]);
299
+ });
300
+ // A read never returns a secret, and the server keeps one that is left
301
+ // out, so the prompt listed a change that never happened.
302
+ it("refuses null on a secret, which the server would keep", () => {
303
+ const pg = {
304
+ name: "pg",
305
+ type: "postgres",
306
+ postgresConnection: { host: "db" },
307
+ includeTables: ["public.*"],
308
+ };
309
+ (0, chai_1.expect)(() => (0, updateconnection_1.mergeConnectionUpdate)(pg, {
310
+ name: "pg",
311
+ postgresConnection: { password: null },
312
+ })).to.throw("The file sets 'pg' postgresConnection.password to null, and the stored connection has no value there to clear");
313
+ });
314
+ it("refuses null on a whole block", () => {
315
+ (0, chai_1.expect)(() => (0, updateconnection_1.mergeConnectionUpdate)(stored, {
316
+ name: "bq_demo",
317
+ bigqueryConnection: null,
318
+ })).to.throw("The file sets 'bq_demo' bigqueryConnection to null, which would remove the whole block.");
319
+ });
320
+ it("refuses a proxy on a connection that is not postgres", () => {
321
+ (0, chai_1.expect)(() => (0, updateconnection_1.mergeConnectionUpdate)(stored, {
322
+ name: "bq_demo",
323
+ proxy: { ssh: { privateKey: "k" } },
324
+ })).to.throw("only postgres connections take a proxy");
325
+ });
326
+ it("refuses to change a connection's type", () => {
327
+ (0, chai_1.expect)(() => (0, updateconnection_1.mergeConnectionUpdate)(stored, { name: "bq_demo", type: "postgres" })).to.throw("is a bigquery connection, and the file says postgres");
328
+ });
329
+ // A DuckDB connection with two attached databases, as a read returns it.
330
+ const duck = {
331
+ name: "lake",
332
+ type: "duckdb",
333
+ duckdbConnection: {
334
+ attachedDatabases: [
335
+ {
336
+ name: "a",
337
+ type: "bigquery",
338
+ bigqueryConnection: { defaultProjectId: "pa" },
339
+ },
340
+ { name: "b", type: "postgres", postgresConnection: { host: "hb" } },
341
+ ],
342
+ },
343
+ includeTables: ["a.*"],
344
+ };
345
+ // Sent as it was, [] cleared every attached database; a list matched by
346
+ // name that names nothing changes nothing.
347
+ it("keeps every attached database when the file gives an empty list", () => {
348
+ const { connection, changed } = (0, updateconnection_1.mergeConnectionUpdate)(duck, {
349
+ name: "lake",
350
+ duckdbConnection: { attachedDatabases: [] },
351
+ });
352
+ (0, chai_1.expect)(connection.duckdbConnection).to.deep.equal(duck.duckdbConnection);
353
+ (0, chai_1.expect)(changed).to.eql([]);
354
+ });
355
+ it("refuses null for attached databases, which would remove them all", () => {
356
+ (0, chai_1.expect)(() => (0, updateconnection_1.mergeConnectionUpdate)(duck, {
357
+ name: "lake",
358
+ duckdbConnection: { attachedDatabases: null },
359
+ })).to.throw("The file sets 'lake' duckdbConnection.attachedDatabases to null, which would remove every entry.");
360
+ });
361
+ // Without a name it cannot be matched, and replacing the list with the
362
+ // file's would drop the others.
363
+ it("refuses an attached database without a name", () => {
364
+ (0, chai_1.expect)(() => (0, updateconnection_1.mergeConnectionUpdate)(duck, {
365
+ name: "lake",
366
+ duckdbConnection: {
367
+ attachedDatabases: [
368
+ { bigqueryConnection: { serviceAccountKeyJson: "k" } },
369
+ ],
370
+ },
371
+ })).to.throw("Every entry of 'lake' duckdbConnection.attachedDatabases in the file needs the \"name\" of the entry it changes or adds, and 1 has none.");
372
+ });
373
+ it("refuses an attached database named twice", () => {
374
+ (0, chai_1.expect)(() => (0, updateconnection_1.mergeConnectionUpdate)(duck, {
375
+ name: "lake",
376
+ duckdbConnection: {
377
+ attachedDatabases: [
378
+ { name: "a", bigqueryConnection: { location: "EU" } },
379
+ { name: "a", bigqueryConnection: { location: "US" } },
380
+ ],
381
+ },
382
+ })).to.throw("The file names a more than once");
383
+ });
384
+ // Merged, the new type kept the old one's settings and secrets beside it.
385
+ it("refuses to change an attached database's type", () => {
386
+ (0, chai_1.expect)(() => (0, updateconnection_1.mergeConnectionUpdate)(duck, {
387
+ name: "lake",
388
+ duckdbConnection: {
389
+ attachedDatabases: [
390
+ { name: "a", type: "s3", s3Connection: { accessKeyId: "x" } },
391
+ ],
392
+ },
393
+ })).to.throw("'lake' duckdbConnection.attachedDatabases[a] is a bigquery entry, and the file says s3. Fix: a different type is a different database");
394
+ });
395
+ it("refuses another type's block on an attached database", () => {
396
+ (0, chai_1.expect)(() => (0, updateconnection_1.mergeConnectionUpdate)(duck, {
397
+ name: "lake",
398
+ duckdbConnection: {
399
+ attachedDatabases: [
400
+ { name: "b", bigqueryConnection: { location: "EU" } },
401
+ ],
402
+ },
403
+ })).to.throw("Fix: put the changes under duckdbConnection.attachedDatabases[b].postgresConnection.");
404
+ // The block's name has a digit.
405
+ (0, chai_1.expect)(() => (0, updateconnection_1.mergeConnectionUpdate)(duck, {
406
+ name: "lake",
407
+ duckdbConnection: {
408
+ attachedDatabases: [
409
+ { name: "b", s3Connection: { accessKeyId: "AKIA" } },
410
+ ],
411
+ },
412
+ })).to.throw("so the file's s3Connection does not apply to it");
413
+ });
414
+ // It was never read, so the rest of the file was sent without it.
415
+ it("refuses another type's block on the connection", () => {
416
+ (0, chai_1.expect)(() => (0, updateconnection_1.mergeConnectionUpdate)(stored, {
417
+ name: "bq_demo",
418
+ postgresConnection: { password: "p" },
419
+ includeTables: ["sales.*"],
420
+ })).to.throw("'bq_demo' is a bigquery connection, so the file's postgresConnection does not apply to it. Fix: put the changes under bigqueryConnection.");
421
+ });
422
+ it("refuses a field the command does not change, blank or not", () => {
423
+ (0, chai_1.expect)(() => (0, updateconnection_1.mergeConnectionUpdate)(stored, {
424
+ name: "bq_demo",
425
+ includeTable: ["sales.*"],
426
+ })).to.throw("The file sets includeTable on 'bq_demo', which this command does not change.");
427
+ (0, chai_1.expect)(() => (0, updateconnection_1.mergeConnectionUpdate)(stored, { name: "bq_demo", includeTable: "" })).to.throw("The file sets includeTable on 'bq_demo'");
428
+ });
429
+ // Replacing the object with the value would drop the fields beside it.
430
+ it("refuses a value where the stored connection has an object", () => {
431
+ (0, chai_1.expect)(() => (0, updateconnection_1.mergeConnectionUpdate)(stored, {
432
+ name: "bq_demo",
433
+ bigqueryConnection: "key",
434
+ })).to.throw("'bq_demo' bigqueryConnection is an object in the stored connection, and the file gives a value.");
435
+ });
436
+ });
437
+ describe("cred update connection", () => {
438
+ let sandbox;
439
+ let workDir;
440
+ let savedExitCode;
441
+ beforeEach(() => {
442
+ sandbox = sinon_1.default.createSandbox();
443
+ sandbox.stub(logger_1.logger);
444
+ sandbox.stub(console, "log");
445
+ workDir = fs_1.default.mkdtempSync(path_1.default.join(os_1.default.tmpdir(), "update-connection-"));
446
+ savedExitCode = process.exitCode;
447
+ process.exitCode = 0;
448
+ sandbox
449
+ .stub(clientconfiguration_1.ClientConfiguration.prototype, "doesConfigExists")
450
+ .returns(true);
451
+ sandbox
452
+ .stub(clientconfiguration_1.ClientConfiguration.prototype, "getOrganization")
453
+ .returns("acme");
454
+ sandbox
455
+ .stub(clientconfiguration_1.ClientConfiguration.prototype, "getProject")
456
+ .returns("analytics");
457
+ sandbox
458
+ .stub(clientconfiguration_1.ClientConfiguration.prototype, "getHeaders")
459
+ .returns({ Authorization: "Bearer t" });
460
+ });
461
+ afterEach(() => {
462
+ sandbox.restore();
463
+ process.exitCode = savedExitCode;
464
+ fs_1.default.rmSync(workDir, { recursive: true, force: true });
465
+ });
466
+ function file(contents) {
467
+ const filePath = path_1.default.join(workDir, "changes.json");
468
+ fs_1.default.writeFileSync(filePath, JSON.stringify(contents));
469
+ return filePath;
470
+ }
471
+ it("reads the stored connection, then sends the merged one", () => __awaiter(void 0, void 0, void 0, function* () {
472
+ sandbox
473
+ .stub(api_1.ConnectionsApi.prototype, "getConnection")
474
+ .resolves({ data: stored });
475
+ const update = sandbox
476
+ .stub(api_1.ConnectionsApi.prototype, "updateConnection")
477
+ .resolves({ data: {} });
478
+ yield (0, updateconnection_1.updateConnections)("http://cp", file([
479
+ {
480
+ name: "bq_demo",
481
+ bigqueryConnection: { serviceAccountKeyJson: "k" },
482
+ },
483
+ ]), false, true);
484
+ (0, chai_1.expect)(update.firstCall.args.slice(0, 3)).to.eql([
485
+ "acme",
486
+ "analytics",
487
+ "bq_demo",
488
+ ]);
489
+ (0, chai_1.expect)(update.firstCall.args[3]).to.deep.include({
490
+ bigqueryConnection: {
491
+ defaultProjectId: "vscode-demo",
492
+ location: "US",
493
+ serviceAccountKeyJson: "k",
494
+ },
495
+ });
496
+ (0, chai_1.expect)(process.exitCode).to.equal(0);
497
+ }));
498
+ it("sends nothing when the file repeats the stored connection", () => __awaiter(void 0, void 0, void 0, function* () {
499
+ sandbox
500
+ .stub(api_1.ConnectionsApi.prototype, "getConnection")
501
+ .resolves({ data: stored });
502
+ const update = sandbox.stub(api_1.ConnectionsApi.prototype, "updateConnection");
503
+ yield (0, updateconnection_1.updateConnections)("http://cp", file({
504
+ name: "bq_demo",
505
+ bigqueryConnection: { location: "US" },
506
+ includeTables: ["sales.*"],
507
+ }), false, true);
508
+ (0, chai_1.expect)(update.called).to.equal(false);
509
+ (0, chai_1.expect)(logger_1.logger.info.firstCall.args[0]).to.equal("Nothing to change in bq_demo: the file changes no stored value.");
510
+ (0, chai_1.expect)(process.exitCode).to.equal(0);
511
+ }));
512
+ // The agent contract: a question that cannot be asked exits 2 naming
513
+ // --yes. Asked inside the update's try, it was reported as a failed update.
514
+ it("refuses without a terminal by asking for --yes, and sends nothing", () => __awaiter(void 0, void 0, void 0, function* () {
515
+ sandbox
516
+ .stub(api_1.ConnectionsApi.prototype, "getConnection")
517
+ .resolves({ data: stored });
518
+ const update = sandbox.stub(api_1.ConnectionsApi.prototype, "updateConnection");
519
+ // CI runs with a TTY attached, so "no terminal" has to be asked for.
520
+ const saved = process.env.CRED_NON_INTERACTIVE;
521
+ process.env.CRED_NON_INTERACTIVE = "1";
522
+ const error = yield (0, updateconnection_1.updateConnections)("http://cp", file({ name: "bq_demo", bigqueryConnection: { location: "EU" } }), false, false).catch((e) => e);
523
+ if (saved === undefined)
524
+ delete process.env.CRED_NON_INTERACTIVE;
525
+ else
526
+ process.env.CRED_NON_INTERACTIVE = saved;
527
+ (0, chai_1.expect)(error).to.be.instanceOf(host_1.NeedsInputError);
528
+ (0, chai_1.expect)(String(error.message)).to.contain("Pass --yes");
529
+ (0, chai_1.expect)(update.called).to.equal(false);
530
+ }));
531
+ // Confirming can refresh the session; the update after it has to carry the
532
+ // refreshed token, not the one read before the question.
533
+ it("reads the headers again for each call", () => __awaiter(void 0, void 0, void 0, function* () {
534
+ sandbox
535
+ .stub(api_1.ConnectionsApi.prototype, "getConnection")
536
+ .resolves({ data: stored });
537
+ const update = sandbox
538
+ .stub(api_1.ConnectionsApi.prototype, "updateConnection")
539
+ .resolves({ data: {} });
540
+ clientconfiguration_1.ClientConfiguration.prototype.getHeaders
541
+ .onFirstCall()
542
+ .returns({ Authorization: "Bearer old" })
543
+ .returns({ Authorization: "Bearer new" });
544
+ yield (0, updateconnection_1.updateConnections)("http://cp", file({ name: "bq_demo", bigqueryConnection: { location: "EU" } }), false, true);
545
+ (0, chai_1.expect)(update.firstCall.args[4]).to.deep.include({
546
+ headers: { Authorization: "Bearer new" },
547
+ });
548
+ }));
549
+ // The server tests the merged connection and refuses a bad one; that has to
550
+ // reach the exit code, and later entries still run.
551
+ it("exits 1 when the server refuses the update, and goes on to the next entry", () => __awaiter(void 0, void 0, void 0, function* () {
552
+ sandbox
553
+ .stub(api_1.ConnectionsApi.prototype, "getConnection")
554
+ .resolves({ data: stored });
555
+ const update = sandbox.stub(api_1.ConnectionsApi.prototype, "updateConnection");
556
+ update.onFirstCall().rejects(Object.assign(new Error("Request failed with status code 400"), {
557
+ isAxiosError: true,
558
+ response: { status: 400, data: { message: "bad key" } },
559
+ }));
560
+ update.onSecondCall().resolves({ data: {} });
561
+ yield (0, updateconnection_1.updateConnections)("http://cp", file([
562
+ { name: "bq_demo", bigqueryConnection: { location: "EU" } },
563
+ { name: "bq_demo", bigqueryConnection: { location: "ASIA" } },
564
+ ]), false, true);
565
+ (0, chai_1.expect)(update.callCount).to.equal(2);
566
+ (0, chai_1.expect)(logger_1.logger.error.calledWith("Failed to update connection bq_demo")).to.equal(true);
567
+ (0, chai_1.expect)(process.exitCode).to.equal(1);
568
+ }));
569
+ it("exits 1 and sends nothing for a connection that does not exist", () => __awaiter(void 0, void 0, void 0, function* () {
570
+ sandbox.stub(api_1.ConnectionsApi.prototype, "getConnection").rejects(Object.assign(new Error("Request failed with status code 404"), {
571
+ isAxiosError: true,
572
+ response: { status: 404, data: {} },
573
+ }));
574
+ const update = sandbox.stub(api_1.ConnectionsApi.prototype, "updateConnection");
575
+ yield (0, updateconnection_1.updateConnections)("http://cp", file({ name: "nope" }), false, true);
576
+ (0, chai_1.expect)(update.called).to.equal(false);
577
+ (0, chai_1.expect)(process.exitCode).to.equal(1);
578
+ }));
579
+ // Declining one entry used to end the run, so the entries after it were
580
+ // never sent.
581
+ it("skips only the entry the user declines, and goes on to the next", () => __awaiter(void 0, void 0, void 0, function* () {
582
+ sandbox
583
+ .stub(api_1.ConnectionsApi.prototype, "getConnection")
584
+ .resolves({ data: stored });
585
+ const update = sandbox
586
+ .stub(api_1.ConnectionsApi.prototype, "updateConnection")
587
+ .resolves({ data: {} });
588
+ sandbox
589
+ .stub(utils, "getConfirmation")
590
+ .onFirstCall()
591
+ .resolves(false)
592
+ .onSecondCall()
593
+ .resolves(true);
594
+ yield (0, updateconnection_1.updateConnections)("http://cp", file([
595
+ { name: "bq_demo", bigqueryConnection: { location: "EU" } },
596
+ { name: "bq_demo", bigqueryConnection: { location: "ASIA" } },
597
+ ]), false, false);
598
+ (0, chai_1.expect)(update.callCount).to.equal(1);
599
+ (0, chai_1.expect)(update.firstCall.args[3].bigqueryConnection).to.deep.include({ location: "ASIA" });
600
+ (0, chai_1.expect)(logger_1.logger.info.calledWith("Skipped bq_demo: not confirmed, nothing sent.")).to.equal(true);
601
+ (0, chai_1.expect)(process.exitCode).to.equal(0);
602
+ }));
603
+ it("says when the connection will not be indexed", () => __awaiter(void 0, void 0, void 0, function* () {
604
+ sandbox
605
+ .stub(api_1.ConnectionsApi.prototype, "getConnection")
606
+ .resolves({ data: Object.assign(Object.assign({}, stored), { excludeAllTables: true }) });
607
+ sandbox
608
+ .stub(api_1.ConnectionsApi.prototype, "updateConnection")
609
+ .resolves({ data: {} });
610
+ const confirm = sandbox.stub(utils, "getConfirmation").resolves(true);
611
+ yield (0, updateconnection_1.updateConnections)("http://cp", file({ name: "bq_demo", bigqueryConnection: { location: "EU" } }), false, false);
612
+ (0, chai_1.expect)(confirm.firstCall.args[0]).to.equal("Update bigqueryConnection.location on connection bq_demo in acme/analytics? It will not be indexed (excludeAllTables is true).");
613
+ }));
614
+ it("prints the fix for a file it refuses, and sends nothing", () => __awaiter(void 0, void 0, void 0, function* () {
615
+ sandbox
616
+ .stub(api_1.ConnectionsApi.prototype, "getConnection")
617
+ .resolves({ data: stored });
618
+ const update = sandbox.stub(api_1.ConnectionsApi.prototype, "updateConnection");
619
+ yield (0, updateconnection_1.updateConnections)("http://cp", file({ name: "bq_demo", postgresConnection: { password: "p" } }), false, true);
620
+ (0, chai_1.expect)(update.called).to.equal(false);
621
+ (0, chai_1.expect)(logger_1.logger.error.calledWith("'bq_demo' is a bigquery connection, so the file's postgresConnection does not apply to it. Fix: put the changes under bigqueryConnection.")).to.equal(true);
622
+ (0, chai_1.expect)(process.exitCode).to.equal(1);
623
+ }));
624
+ });
625
+ //# sourceMappingURL=updateconnection.spec.js.map