monday-cli 0.2.0 → 0.4.0

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 (479) hide show
  1. package/CHANGELOG.md +675 -2
  2. package/README.md +223 -31
  3. package/dist/api/assets.d.ts +326 -0
  4. package/dist/api/assets.d.ts.map +1 -0
  5. package/dist/api/assets.js +519 -0
  6. package/dist/api/assets.js.map +1 -0
  7. package/dist/api/board-favorites.d.ts +329 -0
  8. package/dist/api/board-favorites.d.ts.map +1 -0
  9. package/dist/api/board-favorites.js +353 -0
  10. package/dist/api/board-favorites.js.map +1 -0
  11. package/dist/api/board-mutation-result.d.ts +9 -5
  12. package/dist/api/board-mutation-result.d.ts.map +1 -1
  13. package/dist/api/board-mutation-result.js +9 -5
  14. package/dist/api/board-mutation-result.js.map +1 -1
  15. package/dist/api/board-relation-validation.d.ts +161 -0
  16. package/dist/api/board-relation-validation.d.ts.map +1 -0
  17. package/dist/api/board-relation-validation.js +317 -0
  18. package/dist/api/board-relation-validation.js.map +1 -0
  19. package/dist/api/cache.d.ts +14 -5
  20. package/dist/api/cache.d.ts.map +1 -1
  21. package/dist/api/cache.js +8 -10
  22. package/dist/api/cache.js.map +1 -1
  23. package/dist/api/column-mapping.js +2 -2
  24. package/dist/api/column-mapping.js.map +1 -1
  25. package/dist/api/column-mutation-result.d.ts +9 -5
  26. package/dist/api/column-mutation-result.d.ts.map +1 -1
  27. package/dist/api/column-mutation-result.js +9 -5
  28. package/dist/api/column-mutation-result.js.map +1 -1
  29. package/dist/api/column-types.d.ts +37 -14
  30. package/dist/api/column-types.d.ts.map +1 -1
  31. package/dist/api/column-types.js +47 -6
  32. package/dist/api/column-types.js.map +1 -1
  33. package/dist/api/column-values.d.ts +234 -31
  34. package/dist/api/column-values.d.ts.map +1 -1
  35. package/dist/api/column-values.js +560 -124
  36. package/dist/api/column-values.js.map +1 -1
  37. package/dist/api/cross-board-search.d.ts +501 -0
  38. package/dist/api/cross-board-search.d.ts.map +1 -0
  39. package/dist/api/cross-board-search.js +547 -0
  40. package/dist/api/cross-board-search.js.map +1 -0
  41. package/dist/api/dev-conventions.d.ts +1038 -0
  42. package/dist/api/dev-conventions.d.ts.map +1 -0
  43. package/dist/api/dev-conventions.js +1556 -0
  44. package/dist/api/dev-conventions.js.map +1 -0
  45. package/dist/api/documents.d.ts +519 -0
  46. package/dist/api/documents.d.ts.map +1 -0
  47. package/dist/api/documents.js +586 -0
  48. package/dist/api/documents.js.map +1 -0
  49. package/dist/api/dry-run.d.ts +32 -5
  50. package/dist/api/dry-run.d.ts.map +1 -1
  51. package/dist/api/dry-run.js +149 -32
  52. package/dist/api/dry-run.js.map +1 -1
  53. package/dist/api/errors.d.ts.map +1 -1
  54. package/dist/api/errors.js +28 -7
  55. package/dist/api/errors.js.map +1 -1
  56. package/dist/api/group-mutation-result.d.ts +9 -5
  57. package/dist/api/group-mutation-result.d.ts.map +1 -1
  58. package/dist/api/group-mutation-result.js +9 -5
  59. package/dist/api/group-mutation-result.js.map +1 -1
  60. package/dist/api/item-history-projection.d.ts +919 -0
  61. package/dist/api/item-history-projection.d.ts.map +1 -0
  62. package/dist/api/item-history-projection.js +1104 -0
  63. package/dist/api/item-history-projection.js.map +1 -0
  64. package/dist/api/item-mutation-execute.d.ts +82 -0
  65. package/dist/api/item-mutation-execute.d.ts.map +1 -0
  66. package/dist/api/item-mutation-execute.js +199 -0
  67. package/dist/api/item-mutation-execute.js.map +1 -0
  68. package/dist/api/item-watch.d.ts +263 -0
  69. package/dist/api/item-watch.d.ts.map +1 -0
  70. package/dist/api/item-watch.js +709 -0
  71. package/dist/api/item-watch.js.map +1 -0
  72. package/dist/api/multipart-transport.d.ts +223 -0
  73. package/dist/api/multipart-transport.d.ts.map +1 -0
  74. package/dist/api/multipart-transport.js +274 -0
  75. package/dist/api/multipart-transport.js.map +1 -0
  76. package/dist/api/notifications.d.ts +156 -0
  77. package/dist/api/notifications.d.ts.map +1 -0
  78. package/dist/api/notifications.js +215 -0
  79. package/dist/api/notifications.js.map +1 -0
  80. package/dist/api/oauth-test-helper.d.ts +64 -0
  81. package/dist/api/oauth-test-helper.d.ts.map +1 -0
  82. package/dist/api/oauth-test-helper.js +179 -0
  83. package/dist/api/oauth-test-helper.js.map +1 -0
  84. package/dist/api/oauth.d.ts +198 -0
  85. package/dist/api/oauth.d.ts.map +1 -0
  86. package/dist/api/oauth.js +471 -0
  87. package/dist/api/oauth.js.map +1 -0
  88. package/dist/api/parallel-dispatch.d.ts +155 -0
  89. package/dist/api/parallel-dispatch.d.ts.map +1 -0
  90. package/dist/api/parallel-dispatch.js +243 -0
  91. package/dist/api/parallel-dispatch.js.map +1 -0
  92. package/dist/api/partial-success-bulk.d.ts +480 -0
  93. package/dist/api/partial-success-bulk.d.ts.map +1 -0
  94. package/dist/api/partial-success-bulk.js +436 -0
  95. package/dist/api/partial-success-bulk.js.map +1 -0
  96. package/dist/api/partial-success-mutation.d.ts +13 -1
  97. package/dist/api/partial-success-mutation.d.ts.map +1 -1
  98. package/dist/api/partial-success-mutation.js +5 -1
  99. package/dist/api/partial-success-mutation.js.map +1 -1
  100. package/dist/api/people.d.ts +54 -1
  101. package/dist/api/people.d.ts.map +1 -1
  102. package/dist/api/people.js +27 -3
  103. package/dist/api/people.js.map +1 -1
  104. package/dist/api/probes.d.ts +487 -0
  105. package/dist/api/probes.d.ts.map +1 -0
  106. package/dist/api/probes.js +881 -0
  107. package/dist/api/probes.js.map +1 -0
  108. package/dist/api/raw-document.d.ts.map +1 -1
  109. package/dist/api/raw-document.js +2 -2
  110. package/dist/api/raw-document.js.map +1 -1
  111. package/dist/api/raw-write.d.ts +12 -4
  112. package/dist/api/raw-write.d.ts.map +1 -1
  113. package/dist/api/raw-write.js +32 -14
  114. package/dist/api/raw-write.js.map +1 -1
  115. package/dist/api/resolution-context.d.ts +23 -11
  116. package/dist/api/resolution-context.d.ts.map +1 -1
  117. package/dist/api/resolution-context.js +53 -12
  118. package/dist/api/resolution-context.js.map +1 -1
  119. package/dist/api/resolution-pass.d.ts +30 -1
  120. package/dist/api/resolution-pass.d.ts.map +1 -1
  121. package/dist/api/resolution-pass.js +36 -1
  122. package/dist/api/resolution-pass.js.map +1 -1
  123. package/dist/api/resolve-client.d.ts +22 -0
  124. package/dist/api/resolve-client.d.ts.map +1 -1
  125. package/dist/api/resolve-client.js +9 -1
  126. package/dist/api/resolve-client.js.map +1 -1
  127. package/dist/api/response-root.d.ts +92 -46
  128. package/dist/api/response-root.d.ts.map +1 -1
  129. package/dist/api/response-root.js +93 -41
  130. package/dist/api/response-root.js.map +1 -1
  131. package/dist/api/tag-directory.d.ts +154 -0
  132. package/dist/api/tag-directory.d.ts.map +1 -0
  133. package/dist/api/tag-directory.js +325 -0
  134. package/dist/api/tag-directory.js.map +1 -0
  135. package/dist/api/time-tracking.d.ts +165 -0
  136. package/dist/api/time-tracking.d.ts.map +1 -0
  137. package/dist/api/time-tracking.js +135 -0
  138. package/dist/api/time-tracking.js.map +1 -0
  139. package/dist/api/transport.js +3 -3
  140. package/dist/api/transport.js.map +1 -1
  141. package/dist/api/usage.d.ts +190 -0
  142. package/dist/api/usage.d.ts.map +1 -0
  143. package/dist/api/usage.js +194 -0
  144. package/dist/api/usage.js.map +1 -0
  145. package/dist/api/users-fan-out-mutation.d.ts.map +1 -1
  146. package/dist/api/users-fan-out-mutation.js +10 -5
  147. package/dist/api/users-fan-out-mutation.js.map +1 -1
  148. package/dist/api/webhooks.d.ts +357 -0
  149. package/dist/api/webhooks.d.ts.map +1 -0
  150. package/dist/api/webhooks.js +333 -0
  151. package/dist/api/webhooks.js.map +1 -0
  152. package/dist/cli/envelope-out.d.ts +18 -1
  153. package/dist/cli/envelope-out.d.ts.map +1 -1
  154. package/dist/cli/envelope-out.js +16 -2
  155. package/dist/cli/envelope-out.js.map +1 -1
  156. package/dist/cli/program.d.ts.map +1 -1
  157. package/dist/cli/program.js +120 -1
  158. package/dist/cli/program.js.map +1 -1
  159. package/dist/cli/run.d.ts +32 -0
  160. package/dist/cli/run.d.ts.map +1 -1
  161. package/dist/cli/run.js +3 -0
  162. package/dist/cli/run.js.map +1 -1
  163. package/dist/commands/account/tags.d.ts +37 -0
  164. package/dist/commands/account/tags.d.ts.map +1 -0
  165. package/dist/commands/account/tags.js +84 -0
  166. package/dist/commands/account/tags.js.map +1 -0
  167. package/dist/commands/auth/login.d.ts +14 -0
  168. package/dist/commands/auth/login.d.ts.map +1 -0
  169. package/dist/commands/auth/login.js +314 -0
  170. package/dist/commands/auth/login.js.map +1 -0
  171. package/dist/commands/auth/logout.d.ts +28 -0
  172. package/dist/commands/auth/logout.d.ts.map +1 -0
  173. package/dist/commands/auth/logout.js +94 -0
  174. package/dist/commands/auth/logout.js.map +1 -0
  175. package/dist/commands/board/archive.d.ts.map +1 -1
  176. package/dist/commands/board/archive.js +14 -14
  177. package/dist/commands/board/archive.js.map +1 -1
  178. package/dist/commands/board/column-create.d.ts +9 -8
  179. package/dist/commands/board/column-create.d.ts.map +1 -1
  180. package/dist/commands/board/column-create.js +61 -51
  181. package/dist/commands/board/column-create.js.map +1 -1
  182. package/dist/commands/board/column-delete.d.ts.map +1 -1
  183. package/dist/commands/board/column-delete.js +15 -16
  184. package/dist/commands/board/column-delete.js.map +1 -1
  185. package/dist/commands/board/column-update.d.ts.map +1 -1
  186. package/dist/commands/board/column-update.js +23 -22
  187. package/dist/commands/board/column-update.js.map +1 -1
  188. package/dist/commands/board/create.d.ts.map +1 -1
  189. package/dist/commands/board/create.js +14 -17
  190. package/dist/commands/board/create.js.map +1 -1
  191. package/dist/commands/board/delete.d.ts.map +1 -1
  192. package/dist/commands/board/delete.js +12 -15
  193. package/dist/commands/board/delete.js.map +1 -1
  194. package/dist/commands/board/describe.d.ts.map +1 -1
  195. package/dist/commands/board/describe.js +30 -0
  196. package/dist/commands/board/describe.js.map +1 -1
  197. package/dist/commands/board/duplicate.d.ts.map +1 -1
  198. package/dist/commands/board/duplicate.js +12 -13
  199. package/dist/commands/board/duplicate.js.map +1 -1
  200. package/dist/commands/board/favorites.d.ts +33 -0
  201. package/dist/commands/board/favorites.d.ts.map +1 -0
  202. package/dist/commands/board/favorites.js +74 -0
  203. package/dist/commands/board/favorites.js.map +1 -0
  204. package/dist/commands/board/find.d.ts +1 -1
  205. package/dist/commands/board/group-archive.d.ts.map +1 -1
  206. package/dist/commands/board/group-archive.js +12 -16
  207. package/dist/commands/board/group-archive.js.map +1 -1
  208. package/dist/commands/board/group-create.d.ts.map +1 -1
  209. package/dist/commands/board/group-create.js +9 -19
  210. package/dist/commands/board/group-create.js.map +1 -1
  211. package/dist/commands/board/group-delete.d.ts.map +1 -1
  212. package/dist/commands/board/group-delete.js +12 -16
  213. package/dist/commands/board/group-delete.js.map +1 -1
  214. package/dist/commands/board/group-duplicate.d.ts.map +1 -1
  215. package/dist/commands/board/group-duplicate.js +12 -16
  216. package/dist/commands/board/group-duplicate.js.map +1 -1
  217. package/dist/commands/board/group-update.d.ts.map +1 -1
  218. package/dist/commands/board/group-update.js +12 -11
  219. package/dist/commands/board/group-update.js.map +1 -1
  220. package/dist/commands/board/list.d.ts +1 -1
  221. package/dist/commands/board/update.d.ts.map +1 -1
  222. package/dist/commands/board/update.js +16 -11
  223. package/dist/commands/board/update.js.map +1 -1
  224. package/dist/commands/cache/list.d.ts +2 -0
  225. package/dist/commands/cache/list.d.ts.map +1 -1
  226. package/dist/commands/cache/list.js +2 -2
  227. package/dist/commands/cache/list.js.map +1 -1
  228. package/dist/commands/completion.d.ts +188 -0
  229. package/dist/commands/completion.d.ts.map +1 -0
  230. package/dist/commands/completion.js +418 -0
  231. package/dist/commands/completion.js.map +1 -0
  232. package/dist/commands/dev/_shared.d.ts +40 -0
  233. package/dist/commands/dev/_shared.d.ts.map +1 -0
  234. package/dist/commands/dev/_shared.js +104 -0
  235. package/dist/commands/dev/_shared.js.map +1 -0
  236. package/dist/commands/dev/configure.d.ts +36 -0
  237. package/dist/commands/dev/configure.d.ts.map +1 -0
  238. package/dist/commands/dev/configure.js +145 -0
  239. package/dist/commands/dev/configure.js.map +1 -0
  240. package/dist/commands/dev/discover.d.ts +34 -0
  241. package/dist/commands/dev/discover.d.ts.map +1 -0
  242. package/dist/commands/dev/discover.js +117 -0
  243. package/dist/commands/dev/discover.js.map +1 -0
  244. package/dist/commands/dev/doctor.d.ts +39 -0
  245. package/dist/commands/dev/doctor.d.ts.map +1 -0
  246. package/dist/commands/dev/doctor.js +91 -0
  247. package/dist/commands/dev/doctor.js.map +1 -0
  248. package/dist/commands/dev/epic/items.d.ts +24 -0
  249. package/dist/commands/dev/epic/items.d.ts.map +1 -0
  250. package/dist/commands/dev/epic/items.js +103 -0
  251. package/dist/commands/dev/epic/items.js.map +1 -0
  252. package/dist/commands/dev/epic/list.d.ts +36 -0
  253. package/dist/commands/dev/epic/list.d.ts.map +1 -0
  254. package/dist/commands/dev/epic/list.js +120 -0
  255. package/dist/commands/dev/epic/list.js.map +1 -0
  256. package/dist/commands/dev/release/list.d.ts +21 -0
  257. package/dist/commands/dev/release/list.d.ts.map +1 -0
  258. package/dist/commands/dev/release/list.js +73 -0
  259. package/dist/commands/dev/release/list.js.map +1 -0
  260. package/dist/commands/dev/sprint/current.d.ts +24 -0
  261. package/dist/commands/dev/sprint/current.d.ts.map +1 -0
  262. package/dist/commands/dev/sprint/current.js +90 -0
  263. package/dist/commands/dev/sprint/current.js.map +1 -0
  264. package/dist/commands/dev/sprint/items.d.ts +34 -0
  265. package/dist/commands/dev/sprint/items.d.ts.map +1 -0
  266. package/dist/commands/dev/sprint/items.js +118 -0
  267. package/dist/commands/dev/sprint/items.js.map +1 -0
  268. package/dist/commands/dev/sprint/list.d.ts +41 -0
  269. package/dist/commands/dev/sprint/list.d.ts.map +1 -0
  270. package/dist/commands/dev/sprint/list.js +104 -0
  271. package/dist/commands/dev/sprint/list.js.map +1 -0
  272. package/dist/commands/dev/task/block.d.ts +29 -0
  273. package/dist/commands/dev/task/block.d.ts.map +1 -0
  274. package/dist/commands/dev/task/block.js +106 -0
  275. package/dist/commands/dev/task/block.js.map +1 -0
  276. package/dist/commands/dev/task/done.d.ts +30 -0
  277. package/dist/commands/dev/task/done.d.ts.map +1 -0
  278. package/dist/commands/dev/task/done.js +113 -0
  279. package/dist/commands/dev/task/done.js.map +1 -0
  280. package/dist/commands/dev/task/list.d.ts +42 -0
  281. package/dist/commands/dev/task/list.d.ts.map +1 -0
  282. package/dist/commands/dev/task/list.js +227 -0
  283. package/dist/commands/dev/task/list.js.map +1 -0
  284. package/dist/commands/dev/task/start.d.ts +29 -0
  285. package/dist/commands/dev/task/start.d.ts.map +1 -0
  286. package/dist/commands/dev/task/start.js +90 -0
  287. package/dist/commands/dev/task/start.js.map +1 -0
  288. package/dist/commands/doc/get.d.ts +46 -0
  289. package/dist/commands/doc/get.d.ts.map +1 -0
  290. package/dist/commands/doc/get.js +95 -0
  291. package/dist/commands/doc/get.js.map +1 -0
  292. package/dist/commands/doc/list.d.ts +83 -0
  293. package/dist/commands/doc/list.d.ts.map +1 -0
  294. package/dist/commands/doc/list.js +248 -0
  295. package/dist/commands/doc/list.js.map +1 -0
  296. package/dist/commands/emit.d.ts.map +1 -1
  297. package/dist/commands/emit.js +5 -3
  298. package/dist/commands/emit.js.map +1 -1
  299. package/dist/commands/index.d.ts.map +1 -1
  300. package/dist/commands/index.js +141 -0
  301. package/dist/commands/index.js.map +1 -1
  302. package/dist/commands/item/archive.d.ts.map +1 -1
  303. package/dist/commands/item/archive.js +11 -0
  304. package/dist/commands/item/archive.js.map +1 -1
  305. package/dist/commands/item/clear.d.ts.map +1 -1
  306. package/dist/commands/item/clear.js +15 -0
  307. package/dist/commands/item/clear.js.map +1 -1
  308. package/dist/commands/item/create.d.ts.map +1 -1
  309. package/dist/commands/item/create.js +41 -8
  310. package/dist/commands/item/create.js.map +1 -1
  311. package/dist/commands/item/delete.d.ts.map +1 -1
  312. package/dist/commands/item/delete.js +11 -0
  313. package/dist/commands/item/delete.js.map +1 -1
  314. package/dist/commands/item/duplicate.d.ts.map +1 -1
  315. package/dist/commands/item/duplicate.js +12 -0
  316. package/dist/commands/item/duplicate.js.map +1 -1
  317. package/dist/commands/item/history.d.ts +60 -0
  318. package/dist/commands/item/history.d.ts.map +1 -0
  319. package/dist/commands/item/history.js +309 -0
  320. package/dist/commands/item/history.js.map +1 -0
  321. package/dist/commands/item/list.d.ts.map +1 -1
  322. package/dist/commands/item/list.js +16 -13
  323. package/dist/commands/item/list.js.map +1 -1
  324. package/dist/commands/item/move.d.ts.map +1 -1
  325. package/dist/commands/item/move.js +41 -7
  326. package/dist/commands/item/move.js.map +1 -1
  327. package/dist/commands/item/search.d.ts +99 -15
  328. package/dist/commands/item/search.d.ts.map +1 -1
  329. package/dist/commands/item/search.js +480 -36
  330. package/dist/commands/item/search.js.map +1 -1
  331. package/dist/commands/item/set.d.ts.map +1 -1
  332. package/dist/commands/item/set.js +52 -8
  333. package/dist/commands/item/set.js.map +1 -1
  334. package/dist/commands/item/time-track/start.d.ts +61 -0
  335. package/dist/commands/item/time-track/start.d.ts.map +1 -0
  336. package/dist/commands/item/time-track/start.js +138 -0
  337. package/dist/commands/item/time-track/start.js.map +1 -0
  338. package/dist/commands/item/time-track/stop.d.ts +32 -0
  339. package/dist/commands/item/time-track/stop.d.ts.map +1 -0
  340. package/dist/commands/item/time-track/stop.js +97 -0
  341. package/dist/commands/item/time-track/stop.js.map +1 -0
  342. package/dist/commands/item/update.d.ts +2 -0
  343. package/dist/commands/item/update.d.ts.map +1 -1
  344. package/dist/commands/item/update.js +164 -113
  345. package/dist/commands/item/update.js.map +1 -1
  346. package/dist/commands/item/upload.d.ts +108 -0
  347. package/dist/commands/item/upload.d.ts.map +1 -0
  348. package/dist/commands/item/upload.js +370 -0
  349. package/dist/commands/item/upload.js.map +1 -0
  350. package/dist/commands/item/upsert.d.ts.map +1 -1
  351. package/dist/commands/item/upsert.js +48 -1
  352. package/dist/commands/item/upsert.js.map +1 -1
  353. package/dist/commands/item/watch.d.ts +90 -0
  354. package/dist/commands/item/watch.d.ts.map +1 -0
  355. package/dist/commands/item/watch.js +342 -0
  356. package/dist/commands/item/watch.js.map +1 -0
  357. package/dist/commands/notification/send.d.ts +60 -0
  358. package/dist/commands/notification/send.d.ts.map +1 -0
  359. package/dist/commands/notification/send.js +147 -0
  360. package/dist/commands/notification/send.js.map +1 -0
  361. package/dist/commands/parse-argv.d.ts.map +1 -1
  362. package/dist/commands/parse-argv.js +14 -4
  363. package/dist/commands/parse-argv.js.map +1 -1
  364. package/dist/commands/raw/index.d.ts.map +1 -1
  365. package/dist/commands/raw/index.js +13 -15
  366. package/dist/commands/raw/index.js.map +1 -1
  367. package/dist/commands/run-by-id-lookup.d.ts.map +1 -1
  368. package/dist/commands/run-by-id-lookup.js +2 -2
  369. package/dist/commands/run-by-id-lookup.js.map +1 -1
  370. package/dist/commands/schema/index.d.ts +2 -0
  371. package/dist/commands/schema/index.d.ts.map +1 -1
  372. package/dist/commands/status.d.ts +120 -0
  373. package/dist/commands/status.d.ts.map +1 -0
  374. package/dist/commands/status.js +365 -0
  375. package/dist/commands/status.js.map +1 -0
  376. package/dist/commands/update/body-source.d.ts.map +1 -1
  377. package/dist/commands/update/body-source.js +2 -2
  378. package/dist/commands/update/body-source.js.map +1 -1
  379. package/dist/commands/update/create.d.ts +2 -3
  380. package/dist/commands/update/create.d.ts.map +1 -1
  381. package/dist/commands/update/create.js +15 -3
  382. package/dist/commands/update/create.js.map +1 -1
  383. package/dist/commands/update/delete.d.ts.map +1 -1
  384. package/dist/commands/update/delete.js +11 -0
  385. package/dist/commands/update/delete.js.map +1 -1
  386. package/dist/commands/update/edit.d.ts.map +1 -1
  387. package/dist/commands/update/edit.js +11 -0
  388. package/dist/commands/update/edit.js.map +1 -1
  389. package/dist/commands/update/list.d.ts.map +1 -1
  390. package/dist/commands/update/list.js +15 -12
  391. package/dist/commands/update/list.js.map +1 -1
  392. package/dist/commands/update/reply.d.ts.map +1 -1
  393. package/dist/commands/update/reply.js +11 -0
  394. package/dist/commands/update/reply.js.map +1 -1
  395. package/dist/commands/update/toggle.d.ts.map +1 -1
  396. package/dist/commands/update/toggle.js +13 -0
  397. package/dist/commands/update/toggle.js.map +1 -1
  398. package/dist/commands/update/upload.d.ts +69 -0
  399. package/dist/commands/update/upload.d.ts.map +1 -0
  400. package/dist/commands/update/upload.js +235 -0
  401. package/dist/commands/update/upload.js.map +1 -0
  402. package/dist/commands/usage.d.ts +58 -0
  403. package/dist/commands/usage.d.ts.map +1 -0
  404. package/dist/commands/usage.js +94 -0
  405. package/dist/commands/usage.js.map +1 -0
  406. package/dist/commands/webhook/create.d.ts +74 -0
  407. package/dist/commands/webhook/create.d.ts.map +1 -0
  408. package/dist/commands/webhook/create.js +150 -0
  409. package/dist/commands/webhook/create.js.map +1 -0
  410. package/dist/commands/webhook/delete.d.ts +46 -0
  411. package/dist/commands/webhook/delete.d.ts.map +1 -0
  412. package/dist/commands/webhook/delete.js +141 -0
  413. package/dist/commands/webhook/delete.js.map +1 -0
  414. package/dist/commands/webhook/list.d.ts +23 -0
  415. package/dist/commands/webhook/list.d.ts.map +1 -0
  416. package/dist/commands/webhook/list.js +68 -0
  417. package/dist/commands/webhook/list.js.map +1 -0
  418. package/dist/commands/workspace/create.d.ts.map +1 -1
  419. package/dist/commands/workspace/create.js +16 -0
  420. package/dist/commands/workspace/create.js.map +1 -1
  421. package/dist/commands/workspace/delete.d.ts.map +1 -1
  422. package/dist/commands/workspace/delete.js +13 -13
  423. package/dist/commands/workspace/delete.js.map +1 -1
  424. package/dist/commands/workspace/list.d.ts +1 -1
  425. package/dist/commands/workspace/update.d.ts.map +1 -1
  426. package/dist/commands/workspace/update.js +15 -15
  427. package/dist/commands/workspace/update.js.map +1 -1
  428. package/dist/config/credentials.d.ts +189 -0
  429. package/dist/config/credentials.d.ts.map +1 -0
  430. package/dist/config/credentials.js +300 -0
  431. package/dist/config/credentials.js.map +1 -0
  432. package/dist/config/profiles.d.ts +125 -0
  433. package/dist/config/profiles.d.ts.map +1 -0
  434. package/dist/config/profiles.js +227 -0
  435. package/dist/config/profiles.js.map +1 -0
  436. package/dist/types/global-flags.d.ts +1 -1
  437. package/dist/types/global-flags.d.ts.map +1 -1
  438. package/dist/types/global-flags.js +28 -16
  439. package/dist/types/global-flags.js.map +1 -1
  440. package/dist/types/ids.d.ts +4 -0
  441. package/dist/types/ids.d.ts.map +1 -1
  442. package/dist/types/ids.js +12 -3
  443. package/dist/types/ids.js.map +1 -1
  444. package/dist/utils/errors.d.ts +57 -3
  445. package/dist/utils/errors.d.ts.map +1 -1
  446. package/dist/utils/errors.js +69 -2
  447. package/dist/utils/errors.js.map +1 -1
  448. package/dist/utils/fs.d.ts +35 -0
  449. package/dist/utils/fs.d.ts.map +1 -0
  450. package/dist/utils/fs.js +36 -0
  451. package/dist/utils/fs.js.map +1 -0
  452. package/dist/utils/json.d.ts +60 -0
  453. package/dist/utils/json.d.ts.map +1 -0
  454. package/dist/utils/json.js +86 -0
  455. package/dist/utils/json.js.map +1 -0
  456. package/dist/utils/mime.d.ts +24 -0
  457. package/dist/utils/mime.d.ts.map +1 -0
  458. package/dist/utils/mime.js +64 -0
  459. package/dist/utils/mime.js.map +1 -0
  460. package/dist/utils/output/envelope.d.ts +30 -0
  461. package/dist/utils/output/envelope.d.ts.map +1 -1
  462. package/dist/utils/output/envelope.js +26 -0
  463. package/dist/utils/output/envelope.js.map +1 -1
  464. package/dist/utils/output/ndjson.d.ts +90 -3
  465. package/dist/utils/output/ndjson.d.ts.map +1 -1
  466. package/dist/utils/output/ndjson.js +33 -0
  467. package/dist/utils/output/ndjson.js.map +1 -1
  468. package/dist/utils/redact.d.ts.map +1 -1
  469. package/dist/utils/redact.js +31 -0
  470. package/dist/utils/redact.js.map +1 -1
  471. package/dist/utils/signal.d.ts +42 -0
  472. package/dist/utils/signal.d.ts.map +1 -0
  473. package/dist/utils/signal.js +45 -0
  474. package/dist/utils/signal.js.map +1 -0
  475. package/package.json +2 -1
  476. package/dist/commands/account/client-helper.d.ts +0 -37
  477. package/dist/commands/account/client-helper.d.ts.map +0 -1
  478. package/dist/commands/account/client-helper.js +0 -55
  479. package/dist/commands/account/client-helper.js.map +0 -1
@@ -0,0 +1,300 @@
1
+ /**
2
+ * Credentials cache primitive for the v0.3-M21 `monday auth login` /
3
+ * `monday auth logout` verbs (cli-design §7.4 — closes Decision 3).
4
+ *
5
+ * **What this module owns.** The mode-`0600` per-profile credentials
6
+ * file at `~/.monday-cli/credentials`, read/write/delete primitives,
7
+ * and the per-profile token-source-order resolver
8
+ * (§7.4.1: credentials cache > `api_token_env` > `config_error`).
9
+ *
10
+ * **What this module does NOT own.** The credentials file shape is
11
+ * intentionally orthogonal to:
12
+ * - the OAuth wire flow (`src/api/oauth.ts`),
13
+ * - the TOML profile loader (`src/config/profiles.ts`),
14
+ * - the redaction layer (`src/utils/redact.ts`).
15
+ *
16
+ * **Mirrors `src/api/cache.ts writeJsonFile` verbatim** per cli-design
17
+ * §7.4.2. The R-candidate "secure-file primitive shared between cache
18
+ * + credentials" (v0.3-plan §22) flags consolidation when a third
19
+ * consumer lands; today's two-consumer state stays below threshold,
20
+ * so this module duplicates the disk-discipline shape rather than
21
+ * extracting it. The duplication is intentional and the §7.4.2
22
+ * "mirror verbatim" wording is the in-design backstop.
23
+ *
24
+ * **Disk discipline (§7.4.2):**
25
+ *
26
+ * 1. `mkdir({ recursive: true, mode: 0o700 })` + explicit `chmod
27
+ * 0o700` on the parent dir (advisory under umask on some
28
+ * platforms; mirrors `src/api/cache.ts`).
29
+ * 2. Atomic-replace via `writeFile(tmp, payload, { mode: 0o600 })`
30
+ * → `chmod(tmp, 0o600)` → `rename(tmp, final)`.
31
+ * 3. Read-time `fs.fstat`-against-open-descriptor permission check
32
+ * (`(stats.mode & 0o077) !== 0` → refuse, surface
33
+ * `config_error` with `details.path` + `details.hint`).
34
+ */
35
+ import { constants as fsConstants } from 'node:fs';
36
+ import { chmod, mkdir, open, rename, unlink, writeFile } from 'node:fs/promises';
37
+ import { homedir } from 'node:os';
38
+ import { join } from 'node:path';
39
+ import { randomUUID } from 'node:crypto';
40
+ import { z } from 'zod';
41
+ import { ConfigError, asError } from '../utils/errors.js';
42
+ import { formatMode, isENOENT } from '../utils/fs.js';
43
+ /**
44
+ * File-mode constant for the credentials file. Mirrors
45
+ * `src/api/cache.ts CACHE_FILE_MODE`. The R-candidate consolidation
46
+ * (v0.3-plan §22) would re-export this from a shared `secure-file`
47
+ * primitive; the constant lives here for pre-flight to keep the two
48
+ * surfaces independent.
49
+ */
50
+ export const CREDENTIALS_FILE_MODE = 0o600;
51
+ /**
52
+ * Bitmask used to detect group/world readable bits on read. A non-
53
+ * zero result means the file is loose; the read path refuses to
54
+ * open it.
55
+ */
56
+ export const CREDENTIALS_INSECURE_BITS = 0o077;
57
+ /**
58
+ * Pinned at `"1"` for v0.3; reserved for a future migration if the
59
+ * per-profile shape grows incompatibly. Mirrors the cache module's
60
+ * `CACHE_SCHEMA_VERSION`.
61
+ */
62
+ export const CREDENTIALS_SCHEMA_VERSION = '1';
63
+ /** Filename under `~/.monday-cli/`. Pinned for HOME-scoping. */
64
+ export const CREDENTIALS_FILE_NAME = 'credentials';
65
+ /** Parent directory under HOME. Pinned to match cli-design §7.4.2. */
66
+ export const CREDENTIALS_DIR_NAME = '.monday-cli';
67
+ /**
68
+ * Per-profile credentials entry per cli-design §7.4.1.
69
+ */
70
+ export const profileEntrySchema = z
71
+ .object({
72
+ access_token: z.string().min(1),
73
+ obtained_at: z.string().min(1),
74
+ expires_at: z.union([z.string(), z.null()]),
75
+ scopes: z.array(z.string()),
76
+ account_id: z.string().min(1),
77
+ })
78
+ .strict();
79
+ /**
80
+ * Top-level credentials file shape per cli-design §7.4.1.
81
+ *
82
+ * **`schema_version` pinned to literal `"1"`** so a future-version
83
+ * credentials file (e.g., `"2"` after a v0.4 schema change) fails
84
+ * parse-time at this security-bearing surface rather than passing
85
+ * through and getting reinterpreted under the v0.3 schema.
86
+ */
87
+ export const credentialsFileSchema = z
88
+ .object({
89
+ schema_version: z.literal(CREDENTIALS_SCHEMA_VERSION),
90
+ profiles: z.record(z.string().min(1), profileEntrySchema),
91
+ })
92
+ .strict();
93
+ const wrapAsConfigError = (err, message, details = {}) => {
94
+ return new ConfigError(message, { cause: asError(err), details });
95
+ };
96
+ /**
97
+ * Resolves the absolute credentials-file path. Pure helper — does
98
+ * not touch the filesystem.
99
+ */
100
+ export const resolveCredentialsPath = (options = {}) => {
101
+ const home = options.home ?? homedir();
102
+ return join(home, CREDENTIALS_DIR_NAME, CREDENTIALS_FILE_NAME);
103
+ };
104
+ const credentialsDirPath = (options) => join(options.home ?? homedir(), CREDENTIALS_DIR_NAME);
105
+ /**
106
+ * Reads the credentials file, parses it through
107
+ * {@link credentialsFileSchema}, and returns the parsed shape.
108
+ *
109
+ * Returns `undefined` when the file does not exist (typical first-
110
+ * run state). Throws `config_error` for every other failure mode
111
+ * (insecure mode, malformed JSON, schema mismatch).
112
+ */
113
+ export const readCredentials = async (options = {}) => {
114
+ const fullPath = resolveCredentialsPath(options);
115
+ let handle;
116
+ try {
117
+ handle = await open(fullPath, fsConstants.O_RDONLY);
118
+ }
119
+ catch (err) {
120
+ if (isENOENT(err)) {
121
+ return undefined;
122
+ }
123
+ throw wrapAsConfigError(err, `cannot read credentials file ${fullPath}`, {
124
+ path: fullPath,
125
+ });
126
+ }
127
+ try {
128
+ const stats = await handle.stat();
129
+ if ((stats.mode & CREDENTIALS_INSECURE_BITS) !== 0) {
130
+ throw new ConfigError(`refusing to read credentials file with insecure permissions ${formatMode(stats.mode)}`, {
131
+ details: {
132
+ path: fullPath,
133
+ mode: formatMode(stats.mode),
134
+ hint: `permissions must be 0600 — run \`chmod 600 ${fullPath}\``,
135
+ },
136
+ });
137
+ }
138
+ const raw = await handle.readFile('utf8');
139
+ let parsed;
140
+ try {
141
+ parsed = JSON.parse(raw);
142
+ }
143
+ catch (err) {
144
+ throw wrapAsConfigError(err, `malformed JSON in credentials file ${fullPath}`, {
145
+ path: fullPath,
146
+ hint: `delete the file and re-run \`monday auth login --profile <name>\``,
147
+ });
148
+ }
149
+ const result = credentialsFileSchema.safeParse(parsed);
150
+ if (!result.success) {
151
+ const issues = result.error.issues.map((i) => ({
152
+ path: i.path.join('.'),
153
+ message: i.message,
154
+ code: i.code,
155
+ }));
156
+ throw new ConfigError(`credentials file does not conform to v${CREDENTIALS_SCHEMA_VERSION} schema`, {
157
+ cause: result.error,
158
+ details: {
159
+ path: fullPath,
160
+ issues,
161
+ hint: `delete the file and re-run \`monday auth login --profile <name>\``,
162
+ },
163
+ });
164
+ }
165
+ return result.data;
166
+ }
167
+ finally {
168
+ await handle.close();
169
+ }
170
+ };
171
+ const ensureSecureDir = async (path) => {
172
+ // mkdir respects umask, so the explicit `mode` is advisory on some
173
+ // platforms. Re-apply via chmod so a tightened-after-creation
174
+ // directory doesn't betray credentials to another user.
175
+ try {
176
+ await mkdir(path, { recursive: true, mode: 0o700 });
177
+ await chmod(path, 0o700);
178
+ }
179
+ catch (err) {
180
+ // Disk-full / permissions-denied path; not reproducible from a
181
+ // unit test against a tmp dir.
182
+ /* c8 ignore start */
183
+ throw wrapAsConfigError(err, `cannot prepare credentials directory ${path}`, {
184
+ path,
185
+ });
186
+ /* c8 ignore stop */
187
+ }
188
+ };
189
+ /**
190
+ * Atomically writes the credentials file. Mirrors `src/api/cache.ts
191
+ * writeEntry` verbatim:
192
+ *
193
+ * 1. `mkdir({ recursive: true, mode: 0o700 })` + `chmod 0o700`.
194
+ * 2. `writeFile(tmpPath, payload, { mode: 0o600 })`.
195
+ * 3. `chmod(tmpPath, 0o600)` (re-applied because `writeFile`'s
196
+ * `mode` is advisory under umask).
197
+ * 4. `rename(tmpPath, finalPath)` (atomic on the same filesystem).
198
+ *
199
+ * Best-effort cleanup of `tmpPath` on any failure so a half-written
200
+ * `.tmp` doesn't accumulate.
201
+ */
202
+ export const writeCredentials = async (file, options = {}) => {
203
+ // Re-validate before write so a caller passing a malformed shape
204
+ // (e.g., a hand-built object that bypassed the schema) can't slip
205
+ // a bad file onto disk.
206
+ const validated = credentialsFileSchema.parse(file);
207
+ const fullPath = resolveCredentialsPath(options);
208
+ const dir = credentialsDirPath(options);
209
+ await ensureSecureDir(dir);
210
+ const payload = JSON.stringify(validated, null, 2);
211
+ const tmpPath = `${fullPath}.${randomUUID()}.tmp`;
212
+ try {
213
+ await writeFile(tmpPath, payload, { mode: CREDENTIALS_FILE_MODE });
214
+ await chmod(tmpPath, CREDENTIALS_FILE_MODE);
215
+ await rename(tmpPath, fullPath);
216
+ }
217
+ catch (err) {
218
+ // Disk-full / atomic-rename failure path; not reproducible from a
219
+ // unit test against a tmp dir.
220
+ /* c8 ignore start */
221
+ await unlink(tmpPath).catch(() => undefined);
222
+ throw wrapAsConfigError(err, `cannot write credentials file ${fullPath}`, {
223
+ path: fullPath,
224
+ });
225
+ /* c8 ignore stop */
226
+ }
227
+ };
228
+ /**
229
+ * Read-modify-write convenience for `monday auth login`'s success
230
+ * path. Loads the existing file (or starts a fresh `{schema_version,
231
+ * profiles: {}}` if absent), inserts/replaces the named profile's
232
+ * entry, and writes the result back via {@link writeCredentials}.
233
+ */
234
+ export const setProfileCredentials = async (inputs, options = {}) => {
235
+ const existing = await readCredentials(options);
236
+ const next = {
237
+ schema_version: CREDENTIALS_SCHEMA_VERSION,
238
+ profiles: {
239
+ ...(existing?.profiles ?? {}),
240
+ [inputs.profileName]: inputs.entry,
241
+ },
242
+ };
243
+ await writeCredentials(next, options);
244
+ };
245
+ /**
246
+ * Idempotent profile delete for `monday auth logout`. Loads the
247
+ * file (no-op if file is absent), removes the named profile from
248
+ * `profiles`, writes the result back. When the post-delete
249
+ * `profiles` map is empty, **still writes
250
+ * `{schema_version, profiles: {}}`** rather than deleting the file
251
+ * outright (per cli-design §7.3.2 — keeps the schema-version pin
252
+ * discoverable + avoids a fresh-install vs all-logged-out
253
+ * ambiguity).
254
+ *
255
+ * Returns whether the named profile was present pre-delete — the
256
+ * caller surfaces this in the success envelope's `was_present`
257
+ * slot.
258
+ */
259
+ export const deleteProfileCredentials = async (profileName, options = {}) => {
260
+ const existing = await readCredentials(options);
261
+ if (existing === undefined) {
262
+ return { wasPresent: false };
263
+ }
264
+ const wasPresent = Object.prototype.hasOwnProperty.call(existing.profiles, profileName);
265
+ if (!wasPresent) {
266
+ return { wasPresent: false };
267
+ }
268
+ const nextProfiles = Object.fromEntries(Object.entries(existing.profiles).filter(([key]) => key !== profileName));
269
+ const next = {
270
+ schema_version: CREDENTIALS_SCHEMA_VERSION,
271
+ profiles: nextProfiles,
272
+ };
273
+ await writeCredentials(next, options);
274
+ return { wasPresent: true };
275
+ };
276
+ export const resolveProfileToken = async (inputs, options = {}) => {
277
+ const credentials = await readCredentials(options);
278
+ const cached = credentials?.profiles[inputs.profileName];
279
+ if (cached !== undefined) {
280
+ return { token: cached.access_token, source: 'credentials_cache' };
281
+ }
282
+ if (inputs.apiTokenEnvName !== undefined) {
283
+ const env = options.env ?? process.env;
284
+ const fromEnv = env[inputs.apiTokenEnvName];
285
+ if (fromEnv !== undefined && fromEnv.length > 0) {
286
+ return { token: fromEnv, source: 'api_token_env' };
287
+ }
288
+ }
289
+ const hint = inputs.apiTokenEnvName !== undefined
290
+ ? `no token for profile \`${inputs.profileName}\` — run \`monday auth login --profile ${inputs.profileName}\` or set ${inputs.apiTokenEnvName}`
291
+ : `no token for profile \`${inputs.profileName}\` — run \`monday auth login --profile ${inputs.profileName}\``;
292
+ throw new ConfigError(`no credentials available for profile \`${inputs.profileName}\``, {
293
+ details: {
294
+ profile: inputs.profileName,
295
+ api_token_env: inputs.apiTokenEnvName ?? null,
296
+ hint,
297
+ },
298
+ });
299
+ };
300
+ //# sourceMappingURL=credentials.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"credentials.js","sourceRoot":"","sources":["../../src/config/credentials.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,OAAO,EAAE,SAAS,IAAI,WAAW,EAAE,MAAM,SAAS,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EAAE,CAAC;QACzB,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,YAAY,EAAE,MAAM,EAAE,mBAAmB,EAAE,CAAC;IACrE,CAAC;IACD,IAAI,MAAM,CAAC,eAAe,KAAK,SAAS,EAAE,CAAC;QACzC,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC;QACvC,MAAM,OAAO,GAAG,GAAG,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;QAC5C,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAChD,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,CAAC;QACrD,CAAC;IACH,CAAC;IACD,MAAM,IAAI,GACR,MAAM,CAAC,eAAe,KAAK,SAAS;QAClC,CAAC,CAAC,0BAA0B,MAAM,CAAC,WAAW,0CAA0C,MAAM,CAAC,WAAW,aAAa,MAAM,CAAC,eAAe,EAAE;QAC/I,CAAC,CAAC,0BAA0B,MAAM,CAAC,WAAW,0CAA0C,MAAM,CAAC,WAAW,IAAI,CAAC;IACnH,MAAM,IAAI,WAAW,CACnB,0CAA0C,MAAM,CAAC,WAAW,IAAI,EAChE;QACE,OAAO,EAAE;YACP,OAAO,EAAE,MAAM,CAAC,WAAW;YAC3B,aAAa,EAAE,MAAM,CAAC,eAAe,IAAI,IAAI;YAC7C,IAAI;SACL;KACF,CACF,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,125 @@
1
+ /**
2
+ * Profile-config loader for the v0.3-M21 multi-profile surface
3
+ * (cli-design §7.2 — `~/.monday-cli/config.toml`).
4
+ *
5
+ * **What this module owns.** Reading + parsing the TOML config file,
6
+ * the per-profile config schema (zod-validated at the parse boundary
7
+ * per `.claude/rules/validation.md`), and the profile-selection
8
+ * resolver per §7.2 source order:
9
+ *
10
+ * `--profile flag > MONDAY_PROFILE env > default_profile in
11
+ * config > implicit v1 mode (no config file present)`
12
+ *
13
+ * **What this module does NOT own.** The credentials cache (token
14
+ * source-order within a profile) lives in
15
+ * `src/config/credentials.ts`.
16
+ *
17
+ * **Token-storage rule (cli-design §7.2 + §7.4 + .claude/rules/
18
+ * security.md):** tokens are NEVER stored in `config.toml`. Profile
19
+ * entries reference an env-var name via `api_token_env =
20
+ * "MONDAY_API_TOKEN_<X>"` (the env var's *name*, never its value).
21
+ * Two layers of defense:
22
+ *
23
+ * 1. **Structural exclusion** — `.strict()` on the zod object
24
+ * rejects unknown keys (`api_token`, `access_token`, `secret`).
25
+ * 2. **Value-level shape check** — `api_token_env` is constrained
26
+ * to the env-var-identifier regex `/^[A-Z_][A-Z0-9_]*$/u`.
27
+ */
28
+ import { z } from 'zod';
29
+ /** Filename under `~/.monday-cli/`. Pinned for HOME-scoping. */
30
+ export declare const PROFILES_CONFIG_FILE_NAME = "config.toml";
31
+ /** Parent directory under HOME (shared with credentials cache). */
32
+ export declare const PROFILES_DIR_NAME = ".monday-cli";
33
+ /**
34
+ * Optional `[profiles.<name>.dev]` block per cli-design §11.3 (Monday
35
+ * Dev convenience). Pinned here so v0.3-M26 (`monday dev …`) can read
36
+ * the same shape without a fresh schema landing alongside that
37
+ * milestone.
38
+ */
39
+ export declare const profileDevBlockSchema: z.ZodObject<{
40
+ tasks_board: z.ZodOptional<z.ZodString>;
41
+ sprints_board: z.ZodOptional<z.ZodString>;
42
+ epics_board: z.ZodOptional<z.ZodString>;
43
+ bugs_board: z.ZodOptional<z.ZodString>;
44
+ releases_board: z.ZodOptional<z.ZodString>;
45
+ }, z.core.$strict>;
46
+ export type ProfileDevBlock = z.infer<typeof profileDevBlockSchema>;
47
+ export declare const profileEntrySchema: z.ZodObject<{
48
+ api_token_env: z.ZodOptional<z.ZodString>;
49
+ api_version: z.ZodOptional<z.ZodString>;
50
+ default_workspace: z.ZodOptional<z.ZodString>;
51
+ timezone: z.ZodOptional<z.ZodString>;
52
+ dev: z.ZodOptional<z.ZodObject<{
53
+ tasks_board: z.ZodOptional<z.ZodString>;
54
+ sprints_board: z.ZodOptional<z.ZodString>;
55
+ epics_board: z.ZodOptional<z.ZodString>;
56
+ bugs_board: z.ZodOptional<z.ZodString>;
57
+ releases_board: z.ZodOptional<z.ZodString>;
58
+ }, z.core.$strict>>;
59
+ }, z.core.$strict>;
60
+ export type ProfileEntry = z.infer<typeof profileEntrySchema>;
61
+ /**
62
+ * Top-level config-file shape per cli-design §7.2.
63
+ */
64
+ export declare const profilesConfigSchema: z.ZodObject<{
65
+ default_profile: z.ZodOptional<z.ZodString>;
66
+ profiles: z.ZodRecord<z.ZodString, z.ZodObject<{
67
+ api_token_env: z.ZodOptional<z.ZodString>;
68
+ api_version: z.ZodOptional<z.ZodString>;
69
+ default_workspace: z.ZodOptional<z.ZodString>;
70
+ timezone: z.ZodOptional<z.ZodString>;
71
+ dev: z.ZodOptional<z.ZodObject<{
72
+ tasks_board: z.ZodOptional<z.ZodString>;
73
+ sprints_board: z.ZodOptional<z.ZodString>;
74
+ epics_board: z.ZodOptional<z.ZodString>;
75
+ bugs_board: z.ZodOptional<z.ZodString>;
76
+ releases_board: z.ZodOptional<z.ZodString>;
77
+ }, z.core.$strict>>;
78
+ }, z.core.$strict>>;
79
+ }, z.core.$strict>;
80
+ export type ProfilesConfig = z.infer<typeof profilesConfigSchema>;
81
+ export interface ProfilesRootOptions {
82
+ readonly env?: NodeJS.ProcessEnv;
83
+ readonly home?: string;
84
+ }
85
+ /**
86
+ * Resolves the absolute config-file path. Pure helper.
87
+ */
88
+ export declare const resolveProfilesConfigPath: (options?: ProfilesRootOptions) => string;
89
+ /**
90
+ * Reads + parses `~/.monday-cli/config.toml`. Returns `undefined`
91
+ * when the file does not exist (typical first-run state — implicit
92
+ * v1 mode applies). Throws `config_error` for parse failures (TOML
93
+ * malformed) or schema-validation failures (unknown keys, type
94
+ * mismatch, token-smuggled-as-env-var-name).
95
+ */
96
+ export declare const loadProfilesConfig: (options?: ProfilesRootOptions) => Promise<ProfilesConfig | undefined>;
97
+ export interface SelectProfileInputs {
98
+ readonly flag: string | undefined;
99
+ readonly env: NodeJS.ProcessEnv;
100
+ readonly config: ProfilesConfig | undefined;
101
+ }
102
+ export type SelectProfileResult = {
103
+ readonly mode: 'named';
104
+ readonly name: string;
105
+ readonly entry: ProfileEntry;
106
+ } | {
107
+ readonly mode: 'implicit_v1';
108
+ };
109
+ /**
110
+ * Resolves the active profile per cli-design §7.2 source order:
111
+ *
112
+ * 1. `flag` (from `--profile <name>`).
113
+ * 2. `env.MONDAY_PROFILE`.
114
+ * 3. `config.default_profile`.
115
+ * 4. Implicit-v1 sentinel.
116
+ *
117
+ * Surfaces `config_error` when:
118
+ * - any of (1)/(2)/(3) names a profile not present in the config
119
+ * file, OR
120
+ * - `flag` / `MONDAY_PROFILE` is set but no config file exists
121
+ * (the flag/env imply per-profile resolution that the missing
122
+ * config can't fulfil).
123
+ */
124
+ export declare const selectProfile: (inputs: SelectProfileInputs) => SelectProfileResult;
125
+ //# sourceMappingURL=profiles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"profiles.d.ts","sourceRoot":"","sources":["../../src/config/profiles.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAMH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,gEAAgE;AAChE,eAAO,MAAM,yBAAyB,gBAAgB,CAAC;AAEvD,mEAAmE;AACnE,eAAO,MAAM,iBAAiB,gBAAgB,CAAC;AAE/C;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB;;;;;;kBAQvB,CAAC;AAEZ,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAUpE,eAAO,MAAM,kBAAkB;;;;;;;;;;;;kBAkBpB,CAAC;AAEZ,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAE9D;;GAEG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;kBAKtB,CAAC;AAEZ,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAElE,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACjC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;GAEG;AACH,eAAO,MAAM,yBAAyB,GACpC,UAAS,mBAAwB,KAChC,MAGF,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,GAC7B,UAAS,mBAAwB,KAChC,OAAO,CAAC,cAAc,GAAG,SAAS,CA6DpC,CAAC;AAEF,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,UAAU,CAAC;IAChC,QAAQ,CAAC,MAAM,EAAE,cAAc,GAAG,SAAS,CAAC;CAC7C;AAED,MAAM,MAAM,mBAAmB,GAC3B;IACE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;CAC9B,GACD;IAAE,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAA;CAAE,CAAC;AAErC;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,aAAa,GACxB,QAAQ,mBAAmB,KAC1B,mBAmEF,CAAC"}
@@ -0,0 +1,227 @@
1
+ /**
2
+ * Profile-config loader for the v0.3-M21 multi-profile surface
3
+ * (cli-design §7.2 — `~/.monday-cli/config.toml`).
4
+ *
5
+ * **What this module owns.** Reading + parsing the TOML config file,
6
+ * the per-profile config schema (zod-validated at the parse boundary
7
+ * per `.claude/rules/validation.md`), and the profile-selection
8
+ * resolver per §7.2 source order:
9
+ *
10
+ * `--profile flag > MONDAY_PROFILE env > default_profile in
11
+ * config > implicit v1 mode (no config file present)`
12
+ *
13
+ * **What this module does NOT own.** The credentials cache (token
14
+ * source-order within a profile) lives in
15
+ * `src/config/credentials.ts`.
16
+ *
17
+ * **Token-storage rule (cli-design §7.2 + §7.4 + .claude/rules/
18
+ * security.md):** tokens are NEVER stored in `config.toml`. Profile
19
+ * entries reference an env-var name via `api_token_env =
20
+ * "MONDAY_API_TOKEN_<X>"` (the env var's *name*, never its value).
21
+ * Two layers of defense:
22
+ *
23
+ * 1. **Structural exclusion** — `.strict()` on the zod object
24
+ * rejects unknown keys (`api_token`, `access_token`, `secret`).
25
+ * 2. **Value-level shape check** — `api_token_env` is constrained
26
+ * to the env-var-identifier regex `/^[A-Z_][A-Z0-9_]*$/u`.
27
+ */
28
+ import { readFile } from 'node:fs/promises';
29
+ import { homedir } from 'node:os';
30
+ import { join } from 'node:path';
31
+ import { parse as parseToml } from 'smol-toml';
32
+ import { z } from 'zod';
33
+ import { ConfigError, asError } from '../utils/errors.js';
34
+ import { isENOENT } from '../utils/fs.js';
35
+ /** Filename under `~/.monday-cli/`. Pinned for HOME-scoping. */
36
+ export const PROFILES_CONFIG_FILE_NAME = 'config.toml';
37
+ /** Parent directory under HOME (shared with credentials cache). */
38
+ export const PROFILES_DIR_NAME = '.monday-cli';
39
+ /**
40
+ * Optional `[profiles.<name>.dev]` block per cli-design §11.3 (Monday
41
+ * Dev convenience). Pinned here so v0.3-M26 (`monday dev …`) can read
42
+ * the same shape without a fresh schema landing alongside that
43
+ * milestone.
44
+ */
45
+ export const profileDevBlockSchema = z
46
+ .object({
47
+ tasks_board: z.string().min(1).optional(),
48
+ sprints_board: z.string().min(1).optional(),
49
+ epics_board: z.string().min(1).optional(),
50
+ bugs_board: z.string().min(1).optional(),
51
+ releases_board: z.string().min(1).optional(),
52
+ })
53
+ .strict();
54
+ /**
55
+ * Env-var identifier shape (POSIX-style). Rejects token-looking
56
+ * values like `tok-fixture-xxxx` or JWT-looking values like
57
+ * `eyJhbGciOi...` so a user pasting a token under the allowed
58
+ * `api_token_env` key fails at parse time.
59
+ */
60
+ const ENV_VAR_NAME_PATTERN = /^[A-Z_][A-Z0-9_]*$/u;
61
+ export const profileEntrySchema = z
62
+ .object({
63
+ api_token_env: z
64
+ .string()
65
+ .min(1)
66
+ .regex(ENV_VAR_NAME_PATTERN, {
67
+ message: '`api_token_env` must be an env-var name (e.g., `MONDAY_API_TOKEN_WORK`), NOT the token value itself. The CLI never reads tokens from `config.toml`; reference an env var or use `monday auth login` instead.',
68
+ })
69
+ .optional(),
70
+ api_version: z
71
+ .string()
72
+ .regex(/^\d{4}-\d{2}$/u, { message: 'expected YYYY-MM' })
73
+ .optional(),
74
+ default_workspace: z.string().min(1).optional(),
75
+ timezone: z.string().min(1).optional(),
76
+ dev: profileDevBlockSchema.optional(),
77
+ })
78
+ .strict();
79
+ /**
80
+ * Top-level config-file shape per cli-design §7.2.
81
+ */
82
+ export const profilesConfigSchema = z
83
+ .object({
84
+ default_profile: z.string().min(1).optional(),
85
+ profiles: z.record(z.string().min(1), profileEntrySchema),
86
+ })
87
+ .strict();
88
+ /**
89
+ * Resolves the absolute config-file path. Pure helper.
90
+ */
91
+ export const resolveProfilesConfigPath = (options = {}) => {
92
+ const home = options.home ?? homedir();
93
+ return join(home, PROFILES_DIR_NAME, PROFILES_CONFIG_FILE_NAME);
94
+ };
95
+ /**
96
+ * Reads + parses `~/.monday-cli/config.toml`. Returns `undefined`
97
+ * when the file does not exist (typical first-run state — implicit
98
+ * v1 mode applies). Throws `config_error` for parse failures (TOML
99
+ * malformed) or schema-validation failures (unknown keys, type
100
+ * mismatch, token-smuggled-as-env-var-name).
101
+ */
102
+ export const loadProfilesConfig = async (options = {}) => {
103
+ const fullPath = resolveProfilesConfigPath(options);
104
+ let raw;
105
+ try {
106
+ raw = await readFile(fullPath, 'utf8');
107
+ }
108
+ catch (err) {
109
+ if (isENOENT(err)) {
110
+ return undefined;
111
+ }
112
+ // Non-ENOENT readFile errors (EACCES, EISDIR) are platform-
113
+ // specific and not reproducible from a tmp-dir test.
114
+ /* c8 ignore start */
115
+ throw new ConfigError(`cannot read profiles config ${fullPath}`, {
116
+ cause: asError(err),
117
+ details: { path: fullPath },
118
+ });
119
+ /* c8 ignore stop */
120
+ }
121
+ let tomlParsed;
122
+ try {
123
+ tomlParsed = parseToml(raw);
124
+ }
125
+ catch (err) {
126
+ throw new ConfigError(`malformed TOML in profiles config ${fullPath}`, {
127
+ cause: asError(err),
128
+ details: {
129
+ path: fullPath,
130
+ hint: 'check the file for unmatched quotes, missing `=`, or invalid section headers',
131
+ },
132
+ });
133
+ }
134
+ const result = profilesConfigSchema.safeParse(tomlParsed);
135
+ if (!result.success) {
136
+ const issues = result.error.issues.map((i) => ({
137
+ path: i.path.join('.'),
138
+ message: i.message,
139
+ code: i.code,
140
+ }));
141
+ const summary = issues
142
+ .map((i) => (i.path !== '' ? `${i.path}: ${i.message}` : i.message))
143
+ .join('; ');
144
+ throw new ConfigError(`invalid profiles config: ${summary}`, {
145
+ cause: result.error,
146
+ details: {
147
+ path: fullPath,
148
+ issues,
149
+ hint: 'profile entries must reference an env-var NAME via `api_token_env`, never the token value itself; tokens belong in env vars or the credentials cache (run `monday auth login`).',
150
+ },
151
+ });
152
+ }
153
+ return result.data;
154
+ };
155
+ /**
156
+ * Resolves the active profile per cli-design §7.2 source order:
157
+ *
158
+ * 1. `flag` (from `--profile <name>`).
159
+ * 2. `env.MONDAY_PROFILE`.
160
+ * 3. `config.default_profile`.
161
+ * 4. Implicit-v1 sentinel.
162
+ *
163
+ * Surfaces `config_error` when:
164
+ * - any of (1)/(2)/(3) names a profile not present in the config
165
+ * file, OR
166
+ * - `flag` / `MONDAY_PROFILE` is set but no config file exists
167
+ * (the flag/env imply per-profile resolution that the missing
168
+ * config can't fulfil).
169
+ */
170
+ export const selectProfile = (inputs) => {
171
+ const flagName = inputs.flag !== undefined && inputs.flag.length > 0
172
+ ? inputs.flag
173
+ : undefined;
174
+ const envName = inputs.env.MONDAY_PROFILE !== undefined &&
175
+ inputs.env.MONDAY_PROFILE.length > 0
176
+ ? inputs.env.MONDAY_PROFILE
177
+ : undefined;
178
+ // (1)/(2): explicit selection. The credentials cache is the
179
+ // authoritative store for tokens (cli-design §7.4.1), and
180
+ // `monday auth login --profile <name>` populates it without
181
+ // requiring a `config.toml` edit. Two cases:
182
+ //
183
+ // - No config file: return a synthetic empty entry. The caller
184
+ // resolves the token via `resolveProfileToken`, which checks
185
+ // the credentials cache first and surfaces `config_error`
186
+ // only if neither cache nor `api_token_env` is populated.
187
+ // - Config file present but profile not in `profiles`: error
188
+ // loud — the user expressed an explicit `[profiles.<name>]`
189
+ // intent that the file doesn't satisfy.
190
+ const explicit = flagName ?? envName;
191
+ if (explicit !== undefined) {
192
+ if (inputs.config === undefined) {
193
+ return { mode: 'named', name: explicit, entry: {} };
194
+ }
195
+ const entry = inputs.config.profiles[explicit];
196
+ if (entry === undefined) {
197
+ throw new ConfigError(`profile \`${explicit}\` not found in ~/.monday-cli/config.toml`, {
198
+ details: {
199
+ profile: explicit,
200
+ available_profiles: Object.keys(inputs.config.profiles),
201
+ source: flagName !== undefined ? '--profile flag' : 'MONDAY_PROFILE env',
202
+ hint: `add a [profiles.${explicit}] section to ~/.monday-cli/config.toml, OR run \`monday auth login --profile ${explicit}\` to populate the credentials cache directly`,
203
+ },
204
+ });
205
+ }
206
+ return { mode: 'named', name: explicit, entry };
207
+ }
208
+ // (3): default_profile from config.
209
+ if (inputs.config?.default_profile !== undefined) {
210
+ const name = inputs.config.default_profile;
211
+ const entry = inputs.config.profiles[name];
212
+ if (entry === undefined) {
213
+ throw new ConfigError(`default_profile \`${name}\` not found in ~/.monday-cli/config.toml`, {
214
+ details: {
215
+ profile: name,
216
+ available_profiles: Object.keys(inputs.config.profiles),
217
+ source: 'default_profile in config.toml',
218
+ hint: 'set `default_profile` to one of the listed available_profiles, or remove the `default_profile` line to fall back to the first profile listed',
219
+ },
220
+ });
221
+ }
222
+ return { mode: 'named', name, entry };
223
+ }
224
+ // (4): implicit v1.
225
+ return { mode: 'implicit_v1' };
226
+ };
227
+ //# sourceMappingURL=profiles.js.map