@nulab/bee 1.1.0 → 1.1.2

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 (253) hide show
  1. package/README.md +6 -3
  2. package/dist/activities-BPTHt_MD.mjs +69 -0
  3. package/dist/activities-CRiEq51-.mjs +72 -0
  4. package/dist/activities-DyOMqdsM.mjs +69 -0
  5. package/dist/activity-labels-CLFpxp8o.mjs +34 -0
  6. package/dist/add-Br-_TLRp.mjs +55 -0
  7. package/dist/add-CTmmy2t9.mjs +26 -0
  8. package/dist/add-user-BVWFcbH7.mjs +26 -0
  9. package/dist/api-kJR0fRPw.mjs +143 -0
  10. package/dist/attachments-CnL8t9tK.mjs +50 -0
  11. package/dist/attachments-D8IoJjYE.mjs +50 -0
  12. package/dist/attachments-DfgEkAY2.mjs +46 -0
  13. package/dist/auth-5TJGBPxi.mjs +13 -0
  14. package/dist/bee-command-v0qvZeth.mjs +57 -0
  15. package/dist/browse-vgF6nz7X.mjs +304 -0
  16. package/dist/category-BZ7XdVgx.mjs +11 -0
  17. package/dist/clone-DAWVtVbZ.mjs +43 -0
  18. package/dist/close-cTyZPv77.mjs +37 -0
  19. package/dist/comment-CkYJYFrF.mjs +115 -0
  20. package/dist/comment-DzRBQNv8.mjs +102 -0
  21. package/dist/comments-SnOZ-EUJ.mjs +47 -0
  22. package/dist/common-options-BuYWxYdO.mjs +45 -0
  23. package/dist/completion-yfcnEl7k.mjs +113 -0
  24. package/dist/count-BI7ld4k5.mjs +50 -0
  25. package/dist/count-Bw0mVlxC.mjs +40 -0
  26. package/dist/count-CH_LN4k6.mjs +51 -0
  27. package/dist/count-CHzDiMV3.mjs +25 -0
  28. package/dist/count-DvmYzPD_.mjs +46 -0
  29. package/dist/create-BHjwacOk.mjs +47 -0
  30. package/dist/create-BXWATibN.mjs +41 -0
  31. package/dist/create-BtLVFmbR.mjs +29 -0
  32. package/dist/create-CoF2bahH.mjs +29 -0
  33. package/dist/create-DhAOhro9.mjs +60 -0
  34. package/dist/create-DtMLv7Wq.mjs +26 -0
  35. package/dist/create-PtahSFdG.mjs +66 -0
  36. package/dist/create-Y4vo2zwX.mjs +44 -0
  37. package/dist/create-vwRKZ3Lm.mjs +31 -0
  38. package/dist/dashboard-CYYU5Yii.mjs +97 -0
  39. package/dist/delete-BCAPHs-g.mjs +25 -0
  40. package/dist/delete-BHNt5SWa.mjs +24 -0
  41. package/dist/delete-BlmanW0H.mjs +25 -0
  42. package/dist/delete-Bxk14ntp.mjs +24 -0
  43. package/dist/delete-C05oMZEW.mjs +24 -0
  44. package/dist/delete-CMwkcSiA.mjs +25 -0
  45. package/dist/delete-CTeH7nzL.mjs +29 -0
  46. package/dist/delete-D2yDBhZc.mjs +24 -0
  47. package/dist/delete-HMOfvtv3.mjs +25 -0
  48. package/dist/document-CiIzSyoS.mjs +13 -0
  49. package/dist/edit-BBvSbt0m.mjs +22 -0
  50. package/dist/edit-CN1gdpjd.mjs +37 -0
  51. package/dist/edit-C_KbKopB.mjs +36 -0
  52. package/dist/edit-D5Z45NVj.mjs +27 -0
  53. package/dist/edit-DKQw-XXP.mjs +27 -0
  54. package/dist/edit-DRxr4r-r.mjs +60 -0
  55. package/dist/edit-DxsP-aPX.mjs +43 -0
  56. package/dist/edit-Otc7XHU7.mjs +52 -0
  57. package/dist/format-DHAR0n3J.mjs +9 -0
  58. package/dist/history-DpjqxFkX.mjs +55 -0
  59. package/dist/index.mjs +35 -207
  60. package/dist/issue-BRzJy3k1.mjs +18 -0
  61. package/dist/issue-type-Byzh4yLx.mjs +11 -0
  62. package/dist/list-B3A5SDEm.mjs +35 -0
  63. package/dist/list-BMKaJoe_.mjs +64 -0
  64. package/dist/list-BOMbpS4m.mjs +46 -0
  65. package/dist/list-BmZ_JbLB.mjs +104 -0
  66. package/dist/list-BpUUxxwQ.mjs +46 -0
  67. package/dist/list-CgIebllW.mjs +94 -0
  68. package/dist/list-D0Z__0nw.mjs +42 -0
  69. package/dist/list-D3FkO9gb.mjs +56 -0
  70. package/dist/list-D7WLdHvX.mjs +42 -0
  71. package/dist/list-DAr3urtu.mjs +53 -0
  72. package/dist/list-DqpWd9aR.mjs +59 -0
  73. package/dist/list-VO_PbRjC.mjs +50 -0
  74. package/dist/list-b6ByzUFt.mjs +79 -0
  75. package/dist/list-jpQ28gU2.mjs +56 -0
  76. package/dist/list-y93EXyDj.mjs +42 -0
  77. package/dist/login-BnJYzdR3.mjs +228 -0
  78. package/dist/logout-YMnSRLLF.mjs +56 -0
  79. package/dist/me-CLPAe7X2.mjs +36 -0
  80. package/dist/milestone-Dc3alfp9.mjs +11 -0
  81. package/dist/notification-CsOuC8Uk.mjs +11 -0
  82. package/dist/output-DBvfyU1J.mjs +39 -0
  83. package/dist/pr-BBe07JUp.mjs +15 -0
  84. package/dist/project-Dilo1T5e.mjs +16 -0
  85. package/dist/read-BS2G4sNq.mjs +17 -0
  86. package/dist/read-CyCASx6U.mjs +17 -0
  87. package/dist/read-all-CjgMJ2to.mjs +16 -0
  88. package/dist/refresh-DDU2ZLnc.mjs +54 -0
  89. package/dist/registry-B0ZQfBD5.mjs +35 -0
  90. package/dist/registry-RATsKPUm.mjs +2 -0
  91. package/dist/remove-BSDJvkVJ.mjs +17 -0
  92. package/dist/remove-user-CShNCvf8.mjs +26 -0
  93. package/dist/reopen-BIRhcmsI.mjs +28 -0
  94. package/dist/repo-B2K8y0mD.mjs +10 -0
  95. package/dist/role-labels-CLA2wmjO.mjs +11 -0
  96. package/dist/space-BgZeUqoH.mjs +6 -0
  97. package/dist/{shared/bee.B3N0WBdU.mjs → src-BWaxjrq_.mjs} +143 -176
  98. package/dist/src-CP4YLIAh.mjs +1008 -0
  99. package/dist/src-CTD9-bSB.mjs +22760 -0
  100. package/dist/star-Sgb-e2CQ.mjs +11 -0
  101. package/dist/status-BkFMW8Jh.mjs +53 -0
  102. package/dist/status-CaGqMXh7.mjs +64 -0
  103. package/dist/status-DDFyQrRZ.mjs +11 -0
  104. package/dist/status-nI4Dpcoo.mjs +58 -0
  105. package/dist/stdin-C-vjNi9T.mjs +17 -0
  106. package/dist/switch-CMLfVGDN.mjs +34 -0
  107. package/dist/tags-DuMJZyBL.mjs +29 -0
  108. package/dist/team-DfQn8Tf5.mjs +6 -0
  109. package/dist/token-BmkUX9vc.mjs +28 -0
  110. package/dist/tree-CozBqPbN.mjs +46 -0
  111. package/dist/user-DMyFmoP3.mjs +11 -0
  112. package/dist/users-BSGqsGSy.mjs +51 -0
  113. package/dist/view-Bj99sk7O.mjs +48 -0
  114. package/dist/view-Bs8o0c7i.mjs +36 -0
  115. package/dist/view-C1ECwTMN.mjs +54 -0
  116. package/dist/view-COBYBfu7.mjs +38 -0
  117. package/dist/view-CZHT-HiE.mjs +36 -0
  118. package/dist/view-D1RuQJV6.mjs +76 -0
  119. package/dist/view-DBO75WzR.mjs +54 -0
  120. package/dist/view-DJHrnN8j.mjs +62 -0
  121. package/dist/view-DLx6qQt9.mjs +51 -0
  122. package/dist/watching-D22YYxOT.mjs +12 -0
  123. package/dist/wiki-B-DQUuIX.mjs +16 -0
  124. package/package.json +12 -7
  125. package/dist/chunks/activities.mjs +0 -77
  126. package/dist/chunks/activities2.mjs +0 -77
  127. package/dist/chunks/activities3.mjs +0 -77
  128. package/dist/chunks/add-user.mjs +0 -40
  129. package/dist/chunks/add.mjs +0 -65
  130. package/dist/chunks/add2.mjs +0 -41
  131. package/dist/chunks/api.mjs +0 -176
  132. package/dist/chunks/attachments.mjs +0 -49
  133. package/dist/chunks/attachments2.mjs +0 -49
  134. package/dist/chunks/attachments3.mjs +0 -50
  135. package/dist/chunks/browse.mjs +0 -271
  136. package/dist/chunks/clone.mjs +0 -62
  137. package/dist/chunks/close.mjs +0 -52
  138. package/dist/chunks/comment.mjs +0 -127
  139. package/dist/chunks/comment2.mjs +0 -113
  140. package/dist/chunks/comments.mjs +0 -59
  141. package/dist/chunks/completion.mjs +0 -118
  142. package/dist/chunks/count.mjs +0 -70
  143. package/dist/chunks/count2.mjs +0 -71
  144. package/dist/chunks/count3.mjs +0 -61
  145. package/dist/chunks/count4.mjs +0 -37
  146. package/dist/chunks/count5.mjs +0 -54
  147. package/dist/chunks/create.mjs +0 -62
  148. package/dist/chunks/create2.mjs +0 -90
  149. package/dist/chunks/create3.mjs +0 -66
  150. package/dist/chunks/create4.mjs +0 -76
  151. package/dist/chunks/create5.mjs +0 -58
  152. package/dist/chunks/create6.mjs +0 -39
  153. package/dist/chunks/create7.mjs +0 -47
  154. package/dist/chunks/create8.mjs +0 -51
  155. package/dist/chunks/create9.mjs +0 -51
  156. package/dist/chunks/dashboard.mjs +0 -86
  157. package/dist/chunks/delete.mjs +0 -50
  158. package/dist/chunks/delete2.mjs +0 -48
  159. package/dist/chunks/delete3.mjs +0 -48
  160. package/dist/chunks/delete4.mjs +0 -51
  161. package/dist/chunks/delete5.mjs +0 -52
  162. package/dist/chunks/delete6.mjs +0 -52
  163. package/dist/chunks/delete7.mjs +0 -64
  164. package/dist/chunks/delete8.mjs +0 -55
  165. package/dist/chunks/delete9.mjs +0 -50
  166. package/dist/chunks/edit.mjs +0 -58
  167. package/dist/chunks/edit2.mjs +0 -80
  168. package/dist/chunks/edit3.mjs +0 -67
  169. package/dist/chunks/edit4.mjs +0 -53
  170. package/dist/chunks/edit5.mjs +0 -45
  171. package/dist/chunks/edit6.mjs +0 -56
  172. package/dist/chunks/edit7.mjs +0 -52
  173. package/dist/chunks/edit8.mjs +0 -52
  174. package/dist/chunks/history.mjs +0 -58
  175. package/dist/chunks/index.mjs +0 -15
  176. package/dist/chunks/index10.mjs +0 -18
  177. package/dist/chunks/index11.mjs +0 -13
  178. package/dist/chunks/index12.mjs +0 -13
  179. package/dist/chunks/index13.mjs +0 -13
  180. package/dist/chunks/index14.mjs +0 -8
  181. package/dist/chunks/index15.mjs +0 -13
  182. package/dist/chunks/index16.mjs +0 -13
  183. package/dist/chunks/index17.mjs +0 -14
  184. package/dist/chunks/index2.mjs +0 -18
  185. package/dist/chunks/index3.mjs +0 -20
  186. package/dist/chunks/index4.mjs +0 -15
  187. package/dist/chunks/index5.mjs +0 -13
  188. package/dist/chunks/index6.mjs +0 -17
  189. package/dist/chunks/index7.mjs +0 -8
  190. package/dist/chunks/index8.mjs +0 -8
  191. package/dist/chunks/index9.mjs +0 -13
  192. package/dist/chunks/list.mjs +0 -54
  193. package/dist/chunks/list10.mjs +0 -46
  194. package/dist/chunks/list11.mjs +0 -51
  195. package/dist/chunks/list12.mjs +0 -47
  196. package/dist/chunks/list13.mjs +0 -47
  197. package/dist/chunks/list14.mjs +0 -56
  198. package/dist/chunks/list15.mjs +0 -48
  199. package/dist/chunks/list2.mjs +0 -105
  200. package/dist/chunks/list3.mjs +0 -87
  201. package/dist/chunks/list4.mjs +0 -81
  202. package/dist/chunks/list5.mjs +0 -79
  203. package/dist/chunks/list6.mjs +0 -47
  204. package/dist/chunks/list7.mjs +0 -50
  205. package/dist/chunks/list8.mjs +0 -48
  206. package/dist/chunks/list9.mjs +0 -55
  207. package/dist/chunks/login.mjs +0 -220
  208. package/dist/chunks/logout.mjs +0 -72
  209. package/dist/chunks/me.mjs +0 -50
  210. package/dist/chunks/read-all.mjs +0 -31
  211. package/dist/chunks/read.mjs +0 -31
  212. package/dist/chunks/read2.mjs +0 -29
  213. package/dist/chunks/refresh.mjs +0 -78
  214. package/dist/chunks/remove-user.mjs +0 -40
  215. package/dist/chunks/remove.mjs +0 -29
  216. package/dist/chunks/reopen.mjs +0 -44
  217. package/dist/chunks/status.mjs +0 -61
  218. package/dist/chunks/status2.mjs +0 -63
  219. package/dist/chunks/status3.mjs +0 -68
  220. package/dist/chunks/switch.mjs +0 -51
  221. package/dist/chunks/tags.mjs +0 -43
  222. package/dist/chunks/token.mjs +0 -38
  223. package/dist/chunks/tree.mjs +0 -63
  224. package/dist/chunks/users.mjs +0 -50
  225. package/dist/chunks/view.mjs +0 -60
  226. package/dist/chunks/view2.mjs +0 -96
  227. package/dist/chunks/view3.mjs +0 -70
  228. package/dist/chunks/view4.mjs +0 -72
  229. package/dist/chunks/view5.mjs +0 -63
  230. package/dist/chunks/view6.mjs +0 -54
  231. package/dist/chunks/view7.mjs +0 -50
  232. package/dist/chunks/view8.mjs +0 -63
  233. package/dist/chunks/view9.mjs +0 -50
  234. package/dist/shared/bee.BImw1HZl.mjs +0 -28
  235. package/dist/shared/bee.BTBGpv4K.mjs +0 -34
  236. package/dist/shared/bee.BXiuAfjJ.mjs +0 -10
  237. package/dist/shared/bee.BYqxm3yG.mjs +0 -24
  238. package/dist/shared/bee.Btmq3TXs.mjs +0 -19
  239. package/dist/shared/bee.C--ZWPxf.mjs +0 -14
  240. package/dist/shared/bee.C4p7W8_P.mjs +0 -18
  241. package/dist/shared/bee.CirccSk2.mjs +0 -51
  242. package/dist/shared/bee.CktwmH8R.mjs +0 -25
  243. package/dist/shared/bee.CzKcWSES.mjs +0 -42
  244. package/dist/shared/bee.DFnSWb6q.mjs +0 -396
  245. package/dist/shared/bee.DessOtkV.mjs +0 -132
  246. package/dist/shared/bee.DfqnFet4.mjs +0 -49
  247. package/dist/shared/bee.DoTvz3uW.mjs +0 -13
  248. package/dist/shared/bee.G4d7izLe.mjs +0 -14
  249. package/dist/shared/bee.KteAW2rM.mjs +0 -73
  250. package/dist/shared/bee.PF8hrVKn.mjs +0 -27
  251. package/dist/shared/bee.a05kNWpn.mjs +0 -32
  252. package/dist/shared/bee.n5MYN4a6.mjs +0 -12
  253. package/dist/shared/bee.x-FvgDW2.mjs +0 -37660
@@ -0,0 +1,17 @@
1
+ import { y as getClient } from "./src-CTD9-bSB.mjs";
2
+ import { a as parseArg, s as vInteger } from "./src-CP4YLIAh.mjs";
3
+ import { n as ENV_AUTH, t as BeeCommand } from "./bee-command-v0qvZeth.mjs";
4
+ import { S as space } from "./common-options-BuYWxYdO.mjs";
5
+ import consola from "consola";
6
+ import { removeStar } from "backlog-js";
7
+ //#region src/commands/star/remove.ts
8
+ const remove = new BeeCommand("remove").summary("Remove a star").description(`Use \`bee star list\` to find star IDs.`).argument("<star>", "Star ID").addOption(space()).envVars([...ENV_AUTH]).examples([{
9
+ description: "Remove a star",
10
+ command: "bee star remove 12345"
11
+ }]).action(async (star, opts) => {
12
+ const { client } = await getClient(opts.space);
13
+ await removeStar(client, parseArg(vInteger, star, "star"));
14
+ consola.success(`Removed star ${star}.`);
15
+ });
16
+ //#endregion
17
+ export { remove as default };
@@ -0,0 +1,26 @@
1
+ import { y as getClient } from "./src-CTD9-bSB.mjs";
2
+ import { t as outputResult } from "./output-DBvfyU1J.mjs";
3
+ import { a as parseArg, s as vInteger } from "./src-CP4YLIAh.mjs";
4
+ import { n as ENV_AUTH, r as ENV_PROJECT, t as BeeCommand } from "./bee-command-v0qvZeth.mjs";
5
+ import { E as resolveOptions, S as space, T as RequiredOption, u as json, y as project } from "./common-options-BuYWxYdO.mjs";
6
+ import consola from "consola";
7
+ import { deleteProjectUsers } from "backlog-js";
8
+ //#region src/commands/project/remove-user.ts
9
+ const removeUser = new BeeCommand("remove-user").summary("Remove a user from a project").description(`Use \`bee project users\` to look up user IDs.`).addOption(project()).addOption(new RequiredOption("--user-id <id>", "User ID")).addOption(json()).addOption(space()).envVars([...ENV_AUTH, ENV_PROJECT]).examples([{
10
+ description: "Remove a user from a project",
11
+ command: "bee project remove-user -p PROJECT_KEY --user-id 12345"
12
+ }]).action(async (opts, cmd) => {
13
+ await resolveOptions(cmd);
14
+ const userId = parseArg(vInteger, opts.userId, "--user-id");
15
+ const { client } = await getClient(opts.space);
16
+ const user = await deleteProjectUsers(client, opts.project, { userId });
17
+ const jsonArg = opts.json === true ? "" : opts.json;
18
+ outputResult(user, {
19
+ ...opts,
20
+ json: jsonArg
21
+ }, (data) => {
22
+ consola.success(`Removed user ${data.name} from project ${opts.project}.`);
23
+ });
24
+ });
25
+ //#endregion
26
+ export { removeUser as default };
@@ -0,0 +1,28 @@
1
+ import { D as IssueStatusId, y as getClient } from "./src-CTD9-bSB.mjs";
2
+ import { t as outputResult } from "./output-DBvfyU1J.mjs";
3
+ import "./src-CP4YLIAh.mjs";
4
+ import { n as ENV_AUTH, t as BeeCommand } from "./bee-command-v0qvZeth.mjs";
5
+ import { S as space, g as notify, u as json } from "./common-options-BuYWxYdO.mjs";
6
+ import consola from "consola";
7
+ import { patchIssue } from "backlog-js";
8
+ //#region src/commands/issue/reopen.ts
9
+ const reopen = new BeeCommand("reopen").summary("Reopen an issue").description(`Sets the status back to Open.`).argument("<issue>", "Issue ID or issue key").option("-c, --comment <text>", "Comment to add when reopening").addOption(notify()).addOption(json()).addOption(space()).envVars([...ENV_AUTH]).examples([{
10
+ description: "Reopen an issue",
11
+ command: "bee issue reopen PROJECT-123"
12
+ }, {
13
+ description: "Reopen with a comment",
14
+ command: "bee issue reopen PROJECT-123 -c \"Reopening due to regression\""
15
+ }]).action(async (issue, opts) => {
16
+ const { client } = await getClient(opts.space);
17
+ const notifiedUserId = opts.notify ?? [];
18
+ const issueData = await patchIssue(client, issue, {
19
+ statusId: IssueStatusId.Open,
20
+ comment: opts.comment,
21
+ notifiedUserId
22
+ });
23
+ outputResult(issueData, opts, (data) => {
24
+ consola.success(`Reopened issue ${data.issueKey}: ${data.summary}`);
25
+ });
26
+ });
27
+ //#endregion
28
+ export { reopen as default };
@@ -0,0 +1,10 @@
1
+ import { t as BeeCommand } from "./bee-command-v0qvZeth.mjs";
2
+ //#region src/commands/repo/index.ts
3
+ const repo = new BeeCommand("repo").summary("Manage Backlog Git repositories");
4
+ await repo.addCommands([
5
+ import("./list-D7WLdHvX.mjs"),
6
+ import("./view-Bj99sk7O.mjs"),
7
+ import("./clone-DAWVtVbZ.mjs")
8
+ ]);
9
+ //#endregion
10
+ export { repo as default };
@@ -0,0 +1,11 @@
1
+ //#region ../../packages/backlog-utils/src/role-labels.ts
2
+ const ROLE_LABELS = {
3
+ 1: "Administrator",
4
+ 2: "Normal User",
5
+ 3: "Reporter",
6
+ 4: "Viewer",
7
+ 5: "Guest Reporter",
8
+ 6: "Guest Viewer"
9
+ };
10
+ //#endregion
11
+ export { ROLE_LABELS as t };
@@ -0,0 +1,6 @@
1
+ import { t as BeeCommand } from "./bee-command-v0qvZeth.mjs";
2
+ //#region src/commands/space/index.ts
3
+ const space = new BeeCommand("space").summary("Manage space information");
4
+ await space.addCommands([import("./activities-DyOMqdsM.mjs")]);
5
+ //#endregion
6
+ export { space as default };
@@ -1,56 +1,16 @@
1
- import { existsSync, readFileSync, writeFileSync, chmodSync } from 'node:fs';
2
- import { resolve } from 'node:path';
3
- import { homedir } from 'node:os';
4
- import consola from 'consola';
5
- import { U as UserError, p as parseArg, v as vInteger } from './bee.BYqxm3yG.mjs';
6
- import 'node:stream/consumers';
7
- import * as v from 'valibot';
8
- import { a as RcSchema } from './bee.BImw1HZl.mjs';
9
- import { Option } from 'commander';
10
-
11
- const promptRequired = async (label, existing, options) => {
12
- if (existing !== void 0) {
13
- if (existing) {
14
- return existing;
15
- }
16
- throw new UserError(`${label.replace(/:$/, "")} is required.`);
17
- }
18
- if (!process.stdin.isTTY) {
19
- throw new UserError(
20
- `${label.replace(/:$/, "")} is required. Use arguments to provide it in non-interactive mode.`
21
- );
22
- }
23
- const displayLabel = options?.valueHint ? label.replace(/:$/, ` ${options.valueHint}:`) : label;
24
- const { valueHint: _, ...promptOptions } = options ?? {};
25
- const value = await consola.prompt(displayLabel, { type: "text", ...promptOptions });
26
- if (typeof value !== "string" || !value) {
27
- throw new UserError(`${label.replace(/:$/, "")} is required.`);
28
- }
29
- return value;
30
- };
31
- const confirmOrExit = async (message, skipConfirm) => {
32
- if (skipConfirm) {
33
- return true;
34
- }
35
- if (!process.stdin.isTTY) {
36
- throw new UserError("Confirmation required. Use --yes to skip in non-interactive mode.");
37
- }
38
- const confirmed = await consola.prompt(message, { type: "confirm" });
39
- if (!confirmed) {
40
- consola.info("Cancelled.");
41
- return false;
42
- }
43
- return true;
44
- };
45
-
46
- //#region node_modules/.pnpm/flat@6.0.1/node_modules/flat/index.js
1
+ import { u as UserError } from "./src-CP4YLIAh.mjs";
2
+ import * as v from "valibot";
3
+ import { chmodSync, existsSync, readFileSync, writeFileSync } from "node:fs";
4
+ import { resolve } from "node:path";
5
+ import { homedir } from "node:os";
6
+ //#region ../../node_modules/.pnpm/rc9@3.0.1/node_modules/rc9/dist/_chunks/libs/flat.mjs
47
7
  function isBuffer(obj) {
48
8
  return obj && obj.constructor && typeof obj.constructor.isBuffer === "function" && obj.constructor.isBuffer(obj);
49
9
  }
50
10
  function keyIdentity(key) {
51
11
  return key;
52
12
  }
53
- function flatten(target, opts) {
13
+ function flatten$1(target, opts) {
54
14
  opts = opts || {};
55
15
  const delimiter = opts.delimiter || ".";
56
16
  const maxDepth = opts.maxDepth;
@@ -102,7 +62,7 @@ function unflatten(target, opts) {
102
62
  if (!(type === "[object Object]" || type === "[object Array]") || isEmpty(target[key])) {
103
63
  result[key] = target[key];
104
64
  return result;
105
- } else return addKeys(key, result, flatten(target[key], opts));
65
+ } else return addKeys(key, result, flatten$1(target[key], opts));
106
66
  }, {});
107
67
  Object.keys(target).forEach(function(key) {
108
68
  const split = key.split(delimiter).map(transformKey);
@@ -125,76 +85,51 @@ function unflatten(target, opts) {
125
85
  });
126
86
  return result;
127
87
  }
128
-
88
+ //#endregion
89
+ //#region ../../node_modules/.pnpm/destr@2.0.5/node_modules/destr/dist/index.mjs
129
90
  const suspectProtoRx = /"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/;
130
91
  const suspectConstructorRx = /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;
131
92
  const JsonSigRx = /^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;
132
93
  function jsonParseTransform(key, value) {
133
- if (key === "__proto__" || key === "constructor" && value && typeof value === "object" && "prototype" in value) {
134
- warnKeyDropped(key);
135
- return;
136
- }
137
- return value;
94
+ if (key === "__proto__" || key === "constructor" && value && typeof value === "object" && "prototype" in value) {
95
+ warnKeyDropped(key);
96
+ return;
97
+ }
98
+ return value;
138
99
  }
139
100
  function warnKeyDropped(key) {
140
- console.warn(`[destr] Dropping "${key}" key to prevent prototype pollution.`);
101
+ console.warn(`[destr] Dropping "${key}" key to prevent prototype pollution.`);
141
102
  }
142
103
  function destr(value, options = {}) {
143
- if (typeof value !== "string") {
144
- return value;
145
- }
146
- if (value[0] === '"' && value[value.length - 1] === '"' && value.indexOf("\\") === -1) {
147
- return value.slice(1, -1);
148
- }
149
- const _value = value.trim();
150
- if (_value.length <= 9) {
151
- switch (_value.toLowerCase()) {
152
- case "true": {
153
- return true;
154
- }
155
- case "false": {
156
- return false;
157
- }
158
- case "undefined": {
159
- return void 0;
160
- }
161
- case "null": {
162
- return null;
163
- }
164
- case "nan": {
165
- return Number.NaN;
166
- }
167
- case "infinity": {
168
- return Number.POSITIVE_INFINITY;
169
- }
170
- case "-infinity": {
171
- return Number.NEGATIVE_INFINITY;
172
- }
173
- }
174
- }
175
- if (!JsonSigRx.test(value)) {
176
- if (options.strict) {
177
- throw new SyntaxError("[destr] Invalid JSON");
178
- }
179
- return value;
180
- }
181
- try {
182
- if (suspectProtoRx.test(value) || suspectConstructorRx.test(value)) {
183
- if (options.strict) {
184
- throw new Error("[destr] Possible prototype pollution");
185
- }
186
- return JSON.parse(value, jsonParseTransform);
187
- }
188
- return JSON.parse(value);
189
- } catch (error) {
190
- if (options.strict) {
191
- throw error;
192
- }
193
- return value;
194
- }
104
+ if (typeof value !== "string") return value;
105
+ if (value[0] === "\"" && value[value.length - 1] === "\"" && value.indexOf("\\") === -1) return value.slice(1, -1);
106
+ const _value = value.trim();
107
+ if (_value.length <= 9) switch (_value.toLowerCase()) {
108
+ case "true": return true;
109
+ case "false": return false;
110
+ case "undefined": return;
111
+ case "null": return null;
112
+ case "nan": return NaN;
113
+ case "infinity": return Number.POSITIVE_INFINITY;
114
+ case "-infinity": return Number.NEGATIVE_INFINITY;
115
+ }
116
+ if (!JsonSigRx.test(value)) {
117
+ if (options.strict) throw new SyntaxError("[destr] Invalid JSON");
118
+ return value;
119
+ }
120
+ try {
121
+ if (suspectProtoRx.test(value) || suspectConstructorRx.test(value)) {
122
+ if (options.strict) throw new Error("[destr] Possible prototype pollution");
123
+ return JSON.parse(value, jsonParseTransform);
124
+ }
125
+ return JSON.parse(value);
126
+ } catch (error) {
127
+ if (options.strict) throw error;
128
+ return value;
129
+ }
195
130
  }
196
-
197
- //#region src/index.ts
131
+ //#endregion
132
+ //#region ../../node_modules/.pnpm/rc9@3.0.1/node_modules/rc9/dist/index.mjs
198
133
  const RE_KEY_VAL = /^\s*([^\s=]+)\s*=\s*(.*)?\s*$/;
199
134
  const RE_LINES = /\n|\r|\r\n/;
200
135
  /**
@@ -266,7 +201,7 @@ function readUser(options) {
266
201
  * @returns {string} - The serialised configuration string.
267
202
  */
268
203
  function serialize(config) {
269
- return Object.entries(flatten(config)).map(([key, value]) => `${key}=${JSON.stringify(value)}`).join("\n");
204
+ return Object.entries(flatten$1(config)).map(([key, value]) => `${key}=${JSON.stringify(value)}`).join("\n");
270
205
  }
271
206
  /**
272
207
  * Writes a configuration object to a file in a default or specified location.
@@ -288,79 +223,111 @@ function writeUser(config, options) {
288
223
  options.dir = process.env.XDG_CONFIG_HOME || homedir();
289
224
  write(config, options);
290
225
  }
291
-
226
+ //#endregion
227
+ //#region ../../packages/config/src/schema.ts
228
+ const ApiKeyAuthSchema = v.object({
229
+ method: v.literal("api-key"),
230
+ apiKey: v.string()
231
+ });
232
+ const OAuthAuthSchema = v.object({
233
+ method: v.literal("oauth"),
234
+ accessToken: v.string(),
235
+ refreshToken: v.string(),
236
+ clientId: v.optional(v.string()),
237
+ clientSecret: v.optional(v.string())
238
+ });
239
+ const RcAuthSchema = v.variant("method", [ApiKeyAuthSchema, OAuthAuthSchema]);
240
+ /**
241
+ * A Backlog space hostname.
242
+ *
243
+ * Any domain is accepted so that self-hosted spaces work, but the value must be
244
+ * a bare hostname: it is interpolated into `https://${host}` by both
245
+ * `buildBacklogUrl` and backlog-js, so a value carrying userinfo, a path, or a
246
+ * scheme (e.g. `example.backlog.com@evil.com`) would silently redirect requests
247
+ * — and the credentials in them — to another origin.
248
+ */
249
+ const RcHostSchema = v.pipe(v.string(), v.toLowerCase(), v.domain());
250
+ const RcSpaceSchema = v.object({
251
+ host: RcHostSchema,
252
+ auth: RcAuthSchema
253
+ });
254
+ const RcSchema = v.object({
255
+ defaultSpace: v.optional(v.pipe(v.string(), v.toLowerCase())),
256
+ spaces: v.optional(v.array(RcSpaceSchema), []),
257
+ aliases: v.optional(v.record(v.string(), v.string()), {})
258
+ });
259
+ //#endregion
260
+ //#region ../../packages/config/src/config.ts
292
261
  const CONFIG_FILE_NAME = ".beerc";
293
262
  const parseConfig = (raw) => {
294
- const result = v.safeParse(RcSchema, raw);
295
- if (!result.success) {
296
- const details = result.issues.map((issue) => issue.message).join("\n");
297
- throw new UserError(`Configuration Error:
298
- ${details}`);
299
- }
300
- return result.output;
263
+ const result = v.safeParse(RcSchema, raw);
264
+ if (!result.success) {
265
+ const details = result.issues.map((issue) => issue.message).join("\n");
266
+ throw new UserError(`Configuration Error:\n${details}`);
267
+ }
268
+ return result.output;
301
269
  };
302
270
  const loadConfig = () => parseConfig(readUser(CONFIG_FILE_NAME));
303
271
  const configFilePath = () => resolve(process.env.XDG_CONFIG_HOME || homedir(), CONFIG_FILE_NAME);
272
+ /**
273
+ * Validates before writing rather than trusting the caller, so an invalid host
274
+ * cannot be persisted by a command that writes the rc file directly (such as
275
+ * `bee auth login`) only to break every later read.
276
+ */
304
277
  const writeConfig = (config) => {
305
- writeUser(parseConfig(config), CONFIG_FILE_NAME);
306
- chmodSync(configFilePath(), 384);
278
+ writeUser(parseConfig(config), CONFIG_FILE_NAME);
279
+ chmodSync(configFilePath(), 384);
307
280
  };
308
281
  const updateConfig = (updater) => {
309
- const config = loadConfig();
310
- const updated = updater(config);
311
- writeConfig(updated);
312
- return updated;
282
+ const updated = updater(loadConfig());
283
+ writeConfig(updated);
284
+ return updated;
313
285
  };
314
-
315
- class RequiredOption extends Option {
316
- promptLabel;
317
- constructor(flags, description, promptLabel) {
318
- super(flags, `${description} (required)`);
319
- this.promptLabel = promptLabel ?? description;
320
- }
321
- }
322
- const resolveOptions = async (cmd) => {
323
- const opts = cmd.opts();
324
- for (const opt of cmd.options) {
325
- if (opt instanceof RequiredOption) {
326
- const key = opt.attributeName();
327
- opts[key] = await promptRequired(`${opt.promptLabel}:`, opts[key]);
328
- }
329
- }
286
+ //#endregion
287
+ //#region ../../packages/config/src/space.ts
288
+ const removeSpace = (host) => {
289
+ updateConfig((config) => {
290
+ if (!config.spaces.some((space) => space.host === host)) throw new Error(`Space with host "${host}" not found in configuration.`);
291
+ const spaces = config.spaces.filter((space) => space.host !== host);
292
+ const defaultSpace = config.defaultSpace === host ? void 0 : config.defaultSpace;
293
+ return {
294
+ ...config,
295
+ spaces,
296
+ defaultSpace
297
+ };
298
+ });
299
+ };
300
+ const removeAllSpaces = () => {
301
+ updateConfig((config) => ({
302
+ ...config,
303
+ spaces: [],
304
+ defaultSpace: void 0
305
+ }));
306
+ };
307
+ const updateSpaceAuth = (host, auth) => {
308
+ updateConfig((config) => {
309
+ const index = config.spaces.findIndex((space) => space.host === host);
310
+ if (index === -1) throw new Error(`Space with host "${host}" not found in configuration.`);
311
+ return {
312
+ ...config,
313
+ spaces: config.spaces.with(index, {
314
+ ...config.spaces[index],
315
+ auth
316
+ })
317
+ };
318
+ });
319
+ };
320
+ const findSpace = (spaces, host) => {
321
+ const exactMatch = spaces.find((s) => s.host === host);
322
+ if (exactMatch) return exactMatch;
323
+ const prefixMatches = spaces.filter((s) => s.host.startsWith(`${host}.`));
324
+ const [singleMatch] = prefixMatches;
325
+ if (prefixMatches.length === 1) return singleMatch;
326
+ if (prefixMatches.length > 1) {
327
+ const candidates = prefixMatches.map((s) => s.host).join(", ");
328
+ throw new Error(`Ambiguous space name "${host}". Matching spaces: ${candidates}`);
329
+ }
330
+ return null;
330
331
  };
331
-
332
- const collect = (val, prev) => [...prev, val];
333
- const collectNum = (val, prev) => [
334
- ...prev,
335
- parseArg(vInteger, val, "value")
336
- ];
337
- const project = () => new RequiredOption("-p, --project <id>", "Project ID or project key").env("BACKLOG_PROJECT");
338
- const projectOptional = (description = "Project ID or project key") => new Option("-p, --project <id>", description).env("BACKLOG_PROJECT");
339
- const repo = () => new RequiredOption("-R, --repo <name>", "Repository name or ID").env("BACKLOG_REPO");
340
- const count = () => new Option("-L, --count <n>", "Number of results (default: 20)");
341
- const offset = () => new Option("--offset <n>", "Offset for pagination");
342
- const order = () => new Option("--order <dir>", "Sort order").choices(["asc", "desc"]);
343
- const minId = () => new Option("--min-id <n>", "Minimum ID for cursor-based pagination");
344
- const maxId = () => new Option("--max-id <n>", "Maximum ID for cursor-based pagination");
345
- const keyword = () => new Option("-k, --keyword <text>", "Keyword search");
346
- const assignee = () => new Option("-a, --assignee <id>", "Assignee user ID. Use @me for yourself.");
347
- const assigneeList = () => new Option("-a, --assignee <id>", "Assignee user ID (repeatable). Use @me for yourself.").argParser(collect).default([]);
348
- const issue = () => new Option("--issue <key>", "Issue ID or issue key");
349
- const notify = () => new Option("--notify <id>", "User IDs to notify (repeatable)").argParser(collectNum).default([]);
350
- const attachment = () => new Option("--attachment <id>", "Attachment IDs (repeatable)").argParser(collectNum).default([]);
351
- const category = () => new Option("--category <id>", "Category IDs (repeatable)").argParser(collectNum).default([]);
352
- const version = () => new Option("--version <id>", "Version IDs (repeatable)").argParser(collectNum).default([]);
353
- const milestone = () => new Option("--milestone <id>", "Milestone IDs (repeatable)").argParser(collectNum).default([]);
354
- const comment = () => new Option("-c, --comment <text>", "Comment to add with the update");
355
- const web = (resource) => new Option("-w, --web", `Open the ${resource} in the browser`);
356
- const noBrowser = () => new Option("-n, --no-browser", "Print the URL instead of opening the browser");
357
- const space = () => new Option(
358
- "-s, --space <hostname>",
359
- "Space hostname (e.g. xxx.backlog.com, or your own domain)"
360
- ).env("BACKLOG_SPACE");
361
- const json = () => new Option(
362
- "--json [fields]",
363
- "Output as JSON (optionally filter by field names, comma-separated)"
364
- ).preset("");
365
-
366
- export { minId as A, maxId as B, repo as C, issue as D, RequiredOption as R, promptRequired as a, writeConfig as b, collect as c, project as d, confirmOrExit as e, collectNum as f, count as g, assigneeList as h, offset as i, json as j, keyword as k, loadConfig as l, assignee as m, noBrowser as n, order as o, projectOptional as p, category as q, resolveOptions as r, space as s, milestone as t, updateConfig as u, version as v, web as w, notify as x, attachment as y, comment as z };
332
+ //#endregion
333
+ export { loadConfig as a, RcHostSchema as c, updateSpaceAuth as i, removeAllSpaces as n, updateConfig as o, removeSpace as r, writeConfig as s, findSpace as t };