@burdenoff/cli-sdk 2026.1108.1 → 2026.1109.1

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 (242) hide show
  1. package/dist/{chunk-N5KCAJXG.js → chunk-6HSWVWQW.js} +3 -3
  2. package/dist/chunk-MT2F54AC.js +34 -0
  3. package/dist/chunk-WTNQ5PEC.js +1 -0
  4. package/dist/core/index.cjs +8 -8
  5. package/dist/core/index.d.cts +2 -2
  6. package/dist/core/index.d.ts +2 -2
  7. package/dist/core/index.js +1 -1
  8. package/dist/index.cjs +8 -8
  9. package/dist/index.d.cts +1 -1
  10. package/dist/index.d.ts +1 -1
  11. package/dist/index.js +1 -1
  12. package/dist/{module-BwJmqefL.d.ts → module-CLaW1ycq.d.cts} +17 -1
  13. package/dist/{module-BwJmqefL.d.cts → module-CLaW1ycq.d.ts} +17 -1
  14. package/dist/modules/adaptercloud/index.cjs +8 -8
  15. package/dist/modules/adaptercloud/index.d.cts +1 -1
  16. package/dist/modules/adaptercloud/index.d.ts +1 -1
  17. package/dist/modules/adaptercloud/index.js +2 -2
  18. package/dist/modules/artistrybase/index.cjs +10 -10
  19. package/dist/modules/artistrybase/index.d.cts +1 -1
  20. package/dist/modules/artistrybase/index.d.ts +1 -1
  21. package/dist/modules/artistrybase/index.js +2 -2
  22. package/dist/modules/assethandler/index.cjs +6 -6
  23. package/dist/modules/assethandler/index.d.cts +1 -1
  24. package/dist/modules/assethandler/index.d.ts +1 -1
  25. package/dist/modules/assethandler/index.js +2 -2
  26. package/dist/modules/atheletebridge/index.cjs +8 -8
  27. package/dist/modules/atheletebridge/index.d.cts +1 -1
  28. package/dist/modules/atheletebridge/index.d.ts +1 -1
  29. package/dist/modules/atheletebridge/index.js +2 -2
  30. package/dist/modules/auth/index.cjs +5 -5
  31. package/dist/modules/auth/index.d.cts +1 -1
  32. package/dist/modules/auth/index.d.ts +1 -1
  33. package/dist/modules/auth/index.js +4 -4
  34. package/dist/modules/billing/index.cjs +5 -5
  35. package/dist/modules/billing/index.d.cts +1 -1
  36. package/dist/modules/billing/index.d.ts +1 -1
  37. package/dist/modules/billing/index.js +2 -2
  38. package/dist/modules/brainyrich/index.cjs +10 -10
  39. package/dist/modules/brainyrich/index.d.cts +1 -1
  40. package/dist/modules/brainyrich/index.d.ts +1 -1
  41. package/dist/modules/brainyrich/index.js +2 -2
  42. package/dist/modules/buildmyiq/index.cjs +6 -6
  43. package/dist/modules/buildmyiq/index.d.cts +1 -1
  44. package/dist/modules/buildmyiq/index.d.ts +1 -1
  45. package/dist/modules/buildmyiq/index.js +2 -2
  46. package/dist/modules/channels/index.cjs +11 -11
  47. package/dist/modules/channels/index.d.cts +1 -1
  48. package/dist/modules/channels/index.d.ts +1 -1
  49. package/dist/modules/channels/index.js +2 -2
  50. package/dist/modules/collabkin/index.cjs +7 -7
  51. package/dist/modules/collabkin/index.d.cts +1 -1
  52. package/dist/modules/collabkin/index.d.ts +1 -1
  53. package/dist/modules/collabkin/index.js +2 -2
  54. package/dist/modules/comradecircle/index.cjs +8 -8
  55. package/dist/modules/comradecircle/index.d.cts +1 -1
  56. package/dist/modules/comradecircle/index.d.ts +1 -1
  57. package/dist/modules/comradecircle/index.js +2 -2
  58. package/dist/modules/conversations/index.cjs +9 -9
  59. package/dist/modules/conversations/index.d.cts +1 -1
  60. package/dist/modules/conversations/index.d.ts +1 -1
  61. package/dist/modules/conversations/index.js +2 -2
  62. package/dist/modules/coolandlovely/index.cjs +7 -7
  63. package/dist/modules/coolandlovely/index.d.cts +1 -1
  64. package/dist/modules/coolandlovely/index.d.ts +1 -1
  65. package/dist/modules/coolandlovely/index.js +2 -2
  66. package/dist/modules/cosmicintersection/index.cjs +4 -4
  67. package/dist/modules/cosmicintersection/index.d.cts +1 -1
  68. package/dist/modules/cosmicintersection/index.d.ts +1 -1
  69. package/dist/modules/cosmicintersection/index.js +2 -2
  70. package/dist/modules/crewfoundry/index.cjs +19 -19
  71. package/dist/modules/crewfoundry/index.d.cts +1 -1
  72. package/dist/modules/crewfoundry/index.d.ts +1 -1
  73. package/dist/modules/crewfoundry/index.js +2 -2
  74. package/dist/modules/devportal/index.cjs +5 -5
  75. package/dist/modules/devportal/index.d.cts +1 -1
  76. package/dist/modules/devportal/index.d.ts +1 -1
  77. package/dist/modules/devportal/index.js +2 -2
  78. package/dist/modules/ecoimpacthub/index.cjs +7 -7
  79. package/dist/modules/ecoimpacthub/index.d.cts +1 -1
  80. package/dist/modules/ecoimpacthub/index.d.ts +1 -1
  81. package/dist/modules/ecoimpacthub/index.js +2 -2
  82. package/dist/modules/eventfullymanaged/index.cjs +24 -24
  83. package/dist/modules/eventfullymanaged/index.d.cts +1 -1
  84. package/dist/modules/eventfullymanaged/index.d.ts +1 -1
  85. package/dist/modules/eventfullymanaged/index.js +2 -2
  86. package/dist/modules/export/index.cjs +9 -9
  87. package/dist/modules/export/index.d.cts +1 -1
  88. package/dist/modules/export/index.d.ts +1 -1
  89. package/dist/modules/export/index.js +2 -2
  90. package/dist/modules/files/index.cjs +4 -4
  91. package/dist/modules/files/index.d.cts +1 -1
  92. package/dist/modules/files/index.d.ts +1 -1
  93. package/dist/modules/files/index.js +2 -2
  94. package/dist/modules/fluidgrids/index.cjs +8 -8
  95. package/dist/modules/fluidgrids/index.d.cts +1 -1
  96. package/dist/modules/fluidgrids/index.d.ts +1 -1
  97. package/dist/modules/fluidgrids/index.js +3 -3
  98. package/dist/modules/ggnomad/index.cjs +7 -7
  99. package/dist/modules/ggnomad/index.d.cts +1 -1
  100. package/dist/modules/ggnomad/index.d.ts +1 -1
  101. package/dist/modules/ggnomad/index.js +2 -2
  102. package/dist/modules/govcitizenhub/index.cjs +4 -4
  103. package/dist/modules/govcitizenhub/index.d.cts +1 -1
  104. package/dist/modules/govcitizenhub/index.d.ts +1 -1
  105. package/dist/modules/govcitizenhub/index.js +2 -2
  106. package/dist/modules/groups/index.cjs +8 -8
  107. package/dist/modules/groups/index.d.cts +1 -1
  108. package/dist/modules/groups/index.d.ts +1 -1
  109. package/dist/modules/groups/index.js +2 -2
  110. package/dist/modules/headshotmarketing/index.cjs +1 -1
  111. package/dist/modules/headshotmarketing/index.d.cts +1 -1
  112. package/dist/modules/headshotmarketing/index.d.ts +1 -1
  113. package/dist/modules/headshotmarketing/index.js +2 -2
  114. package/dist/modules/health/index.d.cts +1 -1
  115. package/dist/modules/health/index.d.ts +1 -1
  116. package/dist/modules/hookmovies/index.cjs +10 -10
  117. package/dist/modules/hookmovies/index.d.cts +1 -1
  118. package/dist/modules/hookmovies/index.d.ts +1 -1
  119. package/dist/modules/hookmovies/index.js +2 -2
  120. package/dist/modules/housingvista/index.cjs +8 -8
  121. package/dist/modules/housingvista/index.d.cts +1 -1
  122. package/dist/modules/housingvista/index.d.ts +1 -1
  123. package/dist/modules/housingvista/index.js +2 -2
  124. package/dist/modules/integrations/index.cjs +7 -7
  125. package/dist/modules/integrations/index.d.cts +1 -1
  126. package/dist/modules/integrations/index.d.ts +1 -1
  127. package/dist/modules/integrations/index.js +2 -2
  128. package/dist/modules/intelwatchtower/index.cjs +7 -7
  129. package/dist/modules/intelwatchtower/index.d.cts +1 -1
  130. package/dist/modules/intelwatchtower/index.d.ts +1 -1
  131. package/dist/modules/intelwatchtower/index.js +2 -2
  132. package/dist/modules/kadaikodi/index.cjs +6 -6
  133. package/dist/modules/kadaikodi/index.d.cts +1 -1
  134. package/dist/modules/kadaikodi/index.d.ts +1 -1
  135. package/dist/modules/kadaikodi/index.js +2 -2
  136. package/dist/modules/labsofscience/index.cjs +4 -4
  137. package/dist/modules/labsofscience/index.d.cts +1 -1
  138. package/dist/modules/labsofscience/index.d.ts +1 -1
  139. package/dist/modules/labsofscience/index.js +2 -2
  140. package/dist/modules/manufacturedops/index.cjs +3 -3
  141. package/dist/modules/manufacturedops/index.d.cts +1 -1
  142. package/dist/modules/manufacturedops/index.d.ts +1 -1
  143. package/dist/modules/manufacturedops/index.js +2 -2
  144. package/dist/modules/movethewheels/index.cjs +8 -8
  145. package/dist/modules/movethewheels/index.d.cts +1 -1
  146. package/dist/modules/movethewheels/index.d.ts +1 -1
  147. package/dist/modules/movethewheels/index.js +2 -2
  148. package/dist/modules/mybodyshield/index.cjs +5 -5
  149. package/dist/modules/mybodyshield/index.d.cts +1 -1
  150. package/dist/modules/mybodyshield/index.d.ts +1 -1
  151. package/dist/modules/mybodyshield/index.js +2 -2
  152. package/dist/modules/notifications/index.cjs +2 -2
  153. package/dist/modules/notifications/index.d.cts +1 -1
  154. package/dist/modules/notifications/index.d.ts +1 -1
  155. package/dist/modules/notifications/index.js +1 -1
  156. package/dist/modules/organizations/index.cjs +5 -5
  157. package/dist/modules/organizations/index.d.cts +1 -1
  158. package/dist/modules/organizations/index.d.ts +1 -1
  159. package/dist/modules/organizations/index.js +1 -1
  160. package/dist/modules/planmagnet/index.cjs +17 -17
  161. package/dist/modules/planmagnet/index.d.cts +1 -1
  162. package/dist/modules/planmagnet/index.d.ts +1 -1
  163. package/dist/modules/planmagnet/index.js +2 -2
  164. package/dist/modules/products/index.cjs +5 -5
  165. package/dist/modules/products/index.d.cts +1 -1
  166. package/dist/modules/products/index.d.ts +1 -1
  167. package/dist/modules/products/index.js +2 -2
  168. package/dist/modules/proserviceworld/index.cjs +6 -6
  169. package/dist/modules/proserviceworld/index.d.cts +1 -1
  170. package/dist/modules/proserviceworld/index.d.ts +1 -1
  171. package/dist/modules/proserviceworld/index.js +2 -2
  172. package/dist/modules/rbac/index.cjs +4 -4
  173. package/dist/modules/rbac/index.d.cts +1 -1
  174. package/dist/modules/rbac/index.d.ts +1 -1
  175. package/dist/modules/rbac/index.js +2 -2
  176. package/dist/modules/sandbox/index.cjs +11 -11
  177. package/dist/modules/sandbox/index.d.cts +1 -1
  178. package/dist/modules/sandbox/index.d.ts +1 -1
  179. package/dist/modules/sandbox/index.js +1 -1
  180. package/dist/modules/scheduler/index.cjs +14 -14
  181. package/dist/modules/scheduler/index.d.cts +1 -1
  182. package/dist/modules/scheduler/index.d.ts +1 -1
  183. package/dist/modules/scheduler/index.js +2 -2
  184. package/dist/modules/security/index.cjs +9 -9
  185. package/dist/modules/security/index.d.cts +1 -1
  186. package/dist/modules/security/index.d.ts +1 -1
  187. package/dist/modules/security/index.js +2 -2
  188. package/dist/modules/semanticfed/index.cjs +8 -8
  189. package/dist/modules/semanticfed/index.d.cts +1 -1
  190. package/dist/modules/semanticfed/index.d.ts +1 -1
  191. package/dist/modules/semanticfed/index.js +1 -1
  192. package/dist/modules/semanticfed-sql/index.cjs +4 -4
  193. package/dist/modules/semanticfed-sql/index.d.cts +1 -1
  194. package/dist/modules/semanticfed-sql/index.d.ts +1 -1
  195. package/dist/modules/semanticfed-sql/index.js +1 -1
  196. package/dist/modules/store/index.cjs +7 -7
  197. package/dist/modules/store/index.d.cts +1 -1
  198. package/dist/modules/store/index.d.ts +1 -1
  199. package/dist/modules/store/index.js +2 -2
  200. package/dist/modules/subscriberbot/index.cjs +1 -1
  201. package/dist/modules/subscriberbot/index.d.cts +1 -1
  202. package/dist/modules/subscriberbot/index.d.ts +1 -1
  203. package/dist/modules/subscriberbot/index.js +2 -2
  204. package/dist/modules/support/index.cjs +2 -2
  205. package/dist/modules/support/index.d.cts +1 -1
  206. package/dist/modules/support/index.d.ts +1 -1
  207. package/dist/modules/support/index.js +2 -2
  208. package/dist/modules/tags/index.cjs +7 -7
  209. package/dist/modules/tags/index.d.cts +1 -1
  210. package/dist/modules/tags/index.d.ts +1 -1
  211. package/dist/modules/tags/index.js +2 -2
  212. package/dist/modules/technospam/index.cjs +4 -4
  213. package/dist/modules/technospam/index.d.cts +1 -1
  214. package/dist/modules/technospam/index.d.ts +1 -1
  215. package/dist/modules/technospam/index.js +2 -2
  216. package/dist/modules/theculturepost/index.cjs +10 -10
  217. package/dist/modules/theculturepost/index.d.cts +1 -1
  218. package/dist/modules/theculturepost/index.d.ts +1 -1
  219. package/dist/modules/theculturepost/index.js +2 -2
  220. package/dist/modules/theglobalfuel/index.cjs +7 -7
  221. package/dist/modules/theglobalfuel/index.d.cts +1 -1
  222. package/dist/modules/theglobalfuel/index.d.ts +1 -1
  223. package/dist/modules/theglobalfuel/index.js +2 -2
  224. package/dist/modules/timecampus/index.cjs +8 -8
  225. package/dist/modules/timecampus/index.d.cts +1 -1
  226. package/dist/modules/timecampus/index.d.ts +1 -1
  227. package/dist/modules/timecampus/index.js +2 -2
  228. package/dist/modules/tours/index.cjs +3 -3
  229. package/dist/modules/tours/index.d.cts +1 -1
  230. package/dist/modules/tours/index.d.ts +1 -1
  231. package/dist/modules/tours/index.js +2 -2
  232. package/dist/modules/vibecontrols/index.cjs +27 -27
  233. package/dist/modules/vibecontrols/index.d.cts +1 -1
  234. package/dist/modules/vibecontrols/index.d.ts +1 -1
  235. package/dist/modules/vibecontrols/index.js +5 -5
  236. package/dist/modules/workspaces/index.cjs +6 -6
  237. package/dist/modules/workspaces/index.d.cts +1 -1
  238. package/dist/modules/workspaces/index.d.ts +1 -1
  239. package/dist/modules/workspaces/index.js +2 -2
  240. package/package.json +1 -1
  241. package/dist/chunk-2OISIPE6.js +0 -34
  242. package/dist/chunk-VL67DTWH.js +0 -1
@@ -1,4 +1,4 @@
1
- import {a,b as b$1,i,r,h,k as k$1,d}from'../../chunk-VL67DTWH.js';import {o}from'../../chunk-2OISIPE6.js';var y=`
1
+ import {a,b as b$1,i,r,h,k as k$1,d}from'../../chunk-WTNQ5PEC.js';import {q as q$1}from'../../chunk-MT2F54AC.js';var y=`
2
2
  query AthListTeams(
3
3
  $pagination: PaginationInput
4
4
  $sport: AthSport
@@ -287,4 +287,4 @@ import {a,b as b$1,i,r,h,k as k$1,d}from'../../chunk-VL67DTWH.js';import {o}from
287
287
  query AthHealth {
288
288
  athHealth
289
289
  }
290
- `;function Z(d,r){try{return JSON.parse(r)}catch{throw new o(`--${d} must be valid JSON`)}}function m(d){let r=Number.parseInt(d,10);if(Number.isNaN(r))throw new o(`Expected an integer but got "${d}"`);return r}function l(d){let r=Number.parseFloat(d);if(Number.isNaN(r))throw new o(`Expected a number but got "${d}"`);return r}function I(d){return d.split(",").map(r=>r.trim()).filter(r=>r.length>0)}function tt(d){let r$1=d.command("teams").description("AtheleteBridge teams");r$1.command("list").description("List teams").option("--sport <s>","Filter by sport").option("--status <s>","Filter by team status").option("--limit <n>","Page size",m,50).option("--offset <n>","Offset",m,0).option("-f, --format <format>","Output format").action(async o=>{try{let t=await b$1(y,{pagination:{limit:o.limit,offset:o.offset},sport:o.sport?o.sport.toUpperCase():void 0,status:o.status?o.status.toUpperCase():void 0});i(o,t.athListTeams.items,{headers:["ID","Name","Sport","Status","Season"],rows:t.athListTeams.items.map(e=>[r(e.id,12),e.name,e.sport,e.status,e.season??"-"])});}catch(t){h(t);}}),r$1.command("get").description("Get a team by id").argument("<id>","Team ID").option("-f, --format <format>","Output format").action(async(o$1,t)=>{try{let e=await b$1(w,{id:o$1});if(!e.athTeam)throw new o(`Team ${o$1} not found`);i(t,e.athTeam);}catch(e){h(e);}}),r$1.command("create").description("Create a team").requiredOption("--name <name>","Team name").option("--description <s>","Description").option("--sport <s>","Sport","OTHER").option("--status <s>","Team status","FORMING").option("--season <s>","Season").option("--age-group <s>","Age group").option("--home-venue <s>","Home venue").option("--head-coach-id <id>","Head coach user ID").option("--tags <csv>","Comma-separated tags").option("-f, --format <format>","Output format").action(async o=>{try{let t={name:o.name,sport:(o.sport??"OTHER").toUpperCase(),status:(o.status??"FORMING").toUpperCase()};o.description&&(t.description=o.description),o.season&&(t.season=o.season),o.ageGroup&&(t.ageGroup=o.ageGroup),o.homeVenue&&(t.homeVenue=o.homeVenue),o.headCoachId&&(t.headCoachId=o.headCoachId),o.tags&&(t.tags=I(o.tags));let e=await b$1(b,{input:t});k$1(`Team created: ${e.athCreateTeam.name}`),i(o,e.athCreateTeam);}catch(t){h(t);}}),r$1.command("update").description("Update a team").argument("<id>","Team ID").option("--name <name>","Team name").option("--description <s>","Description").option("--sport <s>","Sport").option("--status <s>","Team status").option("--season <s>","Season").option("--age-group <s>","Age group").option("--home-venue <s>","Home venue").option("--head-coach-id <id>","Head coach user ID").option("--tags <csv>","Comma-separated tags").option("-f, --format <format>","Output format").action(async(o$1,t)=>{try{let e={};if(t.name&&(e.name=t.name),t.description!==void 0&&(e.description=t.description),t.sport&&(e.sport=t.sport.toUpperCase()),t.status&&(e.status=t.status.toUpperCase()),t.season&&(e.season=t.season),t.ageGroup&&(e.ageGroup=t.ageGroup),t.homeVenue&&(e.homeVenue=t.homeVenue),t.headCoachId&&(e.headCoachId=t.headCoachId),t.tags&&(e.tags=I(t.tags)),!Object.keys(e).length)throw new o("No updates specified");let i$1=await b$1(R,{id:o$1,input:e});k$1("Team updated"),i(t,i$1.athUpdateTeam);}catch(e){h(e);}}),r$1.command("archive").description("Archive a team").argument("<id>","Team ID").option("-f, --format <format>","Output format").action(async(o,t)=>{try{let e=await b$1(C,{id:o});k$1(e.athArchiveTeam?`Team ${o} archived`:`Team ${o} not archived`),i(t,{archived:e.athArchiveTeam});}catch(e){h(e);}});}function et(d){let r$1=d.command("members").description("AtheleteBridge team members");r$1.command("list").description("List members of a team").requiredOption("--team <id>","Team ID").option("--status <s>","Filter by member status").option("-f, --format <format>","Output format").action(async o=>{try{let t=await b$1(T,{teamId:o.team,status:o.status?o.status.toUpperCase():void 0});i(o,t.athListMembers.items,{headers:["ID","Name","Role","Status","Jersey","Position"],rows:t.athListMembers.items.map(e=>[r(e.id,12),e.displayName,e.role,e.status,e.jerseyNumber!==void 0&&e.jerseyNumber!==null?String(e.jerseyNumber):"-",e.position??"-"])});}catch(t){h(t);}}),r$1.command("add").description("Add a member to a team").requiredOption("--team <id>","Team ID").requiredOption("--user <id>","User ID").requiredOption("--display-name <name>","Display name").option("--role <r>","Member role","PLAYER").option("--status <s>","Member status","ACTIVE").option("--jersey-number <n>","Jersey number",m).option("--position <s>","Position").option("--dominant-side <s>","Dominant side").option("--height <n>","Height",l).option("--weight <n>","Weight",l).option("--joined-at <iso>","Joined at (ISO timestamp)").option("--notes <s>","Notes").option("-f, --format <format>","Output format").action(async o=>{try{let t={teamId:o.team,userId:o.user,displayName:o.displayName,role:(o.role??"PLAYER").toUpperCase(),status:(o.status??"ACTIVE").toUpperCase()};o.jerseyNumber!==void 0&&(t.jerseyNumber=o.jerseyNumber),o.position&&(t.position=o.position),o.dominantSide&&(t.dominantSide=o.dominantSide),o.height!==void 0&&(t.height=o.height),o.weight!==void 0&&(t.weight=o.weight),o.joinedAt&&(t.joinedAt=o.joinedAt),o.notes&&(t.notes=o.notes);let e=await b$1(k,{input:t});k$1(`Member added: ${e.athAddMember.displayName}`),i(o,e.athAddMember);}catch(t){h(t);}}),r$1.command("update").description("Update a team member").argument("<id>","Member ID").option("--display-name <name>","Display name").option("--role <r>","Member role").option("--status <s>","Member status").option("--jersey-number <n>","Jersey number",m).option("--position <s>","Position").option("--dominant-side <s>","Dominant side").option("--height <n>","Height",l).option("--weight <n>","Weight",l).option("--notes <s>","Notes").option("-f, --format <format>","Output format").action(async(o$1,t)=>{try{let e={};if(t.displayName&&(e.displayName=t.displayName),t.role&&(e.role=t.role.toUpperCase()),t.status&&(e.status=t.status.toUpperCase()),t.jerseyNumber!==void 0&&(e.jerseyNumber=t.jerseyNumber),t.position&&(e.position=t.position),t.dominantSide&&(e.dominantSide=t.dominantSide),t.height!==void 0&&(e.height=t.height),t.weight!==void 0&&(e.weight=t.weight),t.notes!==void 0&&(e.notes=t.notes),!Object.keys(e).length)throw new o("No updates specified");let i$1=await b$1(O,{id:o$1,input:e});k$1("Member updated"),i(t,i$1.athUpdateMember);}catch(e){h(e);}}),r$1.command("remove").description("Remove a team member").argument("<id>","Member ID").option("-f, --format <format>","Output format").action(async(o,t)=>{try{let e=await b$1(M,{id:o});k$1(e.athRemoveMember?`Member ${o} removed`:`Member ${o} not removed`),i(t,{removed:e.athRemoveMember});}catch(e){h(e);}});}function ot(d){let r$1=d.command("programs").description("AtheleteBridge training programs");r$1.command("list").description("List training programs").option("--level <l>","Filter by program level").option("--sport <s>","Filter by sport").option("--status <s>","Filter by program status").option("--limit <n>","Page size",m,50).option("--offset <n>","Offset",m,0).option("-f, --format <format>","Output format").action(async t=>{try{let e=await b$1(E,{pagination:{limit:t.limit,offset:t.offset},level:t.level?t.level.toUpperCase():void 0,sport:t.sport?t.sport.toUpperCase():void 0,status:t.status?t.status.toUpperCase():void 0});i(t,e.athListPrograms.items,{headers:["ID","Name","Sport","Level","Status","Weeks"],rows:e.athListPrograms.items.map(i=>[r(i.id,12),i.name,i.sport,i.level,i.status,i.weeks!==void 0&&i.weeks!==null?String(i.weeks):"-"])});}catch(e){h(e);}}),r$1.command("get").description("Get a training program by id").argument("<id>","Program ID").option("-f, --format <format>","Output format").action(async(t,e)=>{try{let i$1=await b$1($,{id:t});if(!i$1.athProgram)throw new o(`Program ${t} not found`);i(e,i$1.athProgram);}catch(i){h(i);}}),r$1.command("create").description("Create a training program").requiredOption("--name <name>","Program name").option("--summary <s>","Summary").option("--sport <s>","Sport","OTHER").option("--level <l>","Level","BEGINNER").option("--weeks <n>","Number of weeks",m).option("--template","Mark as a template").option("--tags <csv>","Comma-separated tags").option("-f, --format <format>","Output format").action(async t=>{try{let e={name:t.name,sport:(t.sport??"OTHER").toUpperCase(),level:(t.level??"BEGINNER").toUpperCase(),isTemplate:!!t.template};t.summary&&(e.summary=t.summary),t.weeks!==void 0&&(e.weeks=t.weeks),t.tags&&(e.tags=I(t.tags));let i$1=await b$1(D,{input:e});k$1(`Program created: ${i$1.athCreateProgram.name}`),i(t,i$1.athCreateProgram);}catch(e){h(e);}}),r$1.command("update").description("Update a training program").argument("<id>","Program ID").option("--name <name>","Program name").option("--summary <s>","Summary").option("--sport <s>","Sport").option("--level <l>","Level").option("--weeks <n>","Number of weeks",m).option("--template <bool>","Template flag (true|false)").option("--tags <csv>","Comma-separated tags").option("-f, --format <format>","Output format").action(async(t,e)=>{try{let i$1={};if(e.name&&(i$1.name=e.name),e.summary!==void 0&&(i$1.summary=e.summary),e.sport&&(i$1.sport=e.sport.toUpperCase()),e.level&&(i$1.level=e.level.toUpperCase()),e.weeks!==void 0&&(i$1.weeks=e.weeks),e.template!==void 0&&(i$1.isTemplate=e.template==="true"),e.tags&&(i$1.tags=I(e.tags)),!Object.keys(i$1).length)throw new o("No updates specified");let dt=await b$1(L,{id:t,input:i$1});k$1("Program updated"),i(e,dt.athUpdateProgram);}catch(i){h(i);}}),r$1.command("transition").description("Advance a program through its publish lifecycle (DRAFT -> PUBLISHED -> ARCHIVED)").argument("<id>","Program ID").requiredOption("--status <s>","Target status: DRAFT|PUBLISHED|ARCHIVED").option("-f, --format <format>","Output format").action(async(t,e)=>{try{let i$1=await b$1(v,{id:t,status:e.status.toUpperCase()});k$1(`Program transitioned to ${i$1.athTransitionProgram.status}`),i(e,i$1.athTransitionProgram);}catch(i){h(i);}}),r$1.command("archive").description("Archive a training program").argument("<id>","Program ID").option("-f, --format <format>","Output format").action(async(t,e)=>{try{let i$1=await b$1(P,{id:t});k$1(i$1.athArchiveProgram?`Program ${t} archived`:`Program ${t} not archived`),i(e,{archived:i$1.athArchiveProgram});}catch(i){h(i);}});let o$1=r$1.command("drills").description("AtheleteBridge program drills");o$1.command("add").description("Add a drill to a program").requiredOption("--program <id>","Program ID").requiredOption("--name <name>","Drill name").option("--description <s>","Description").option("--week-number <n>","Week number",m,1).option("--order-index <n>","Order index",m,0).option("--sets <n>","Sets",m).option("--reps <n>","Reps",m).option("--duration-sec <n>","Duration (seconds)",m).option("--rest-sec <n>","Rest (seconds)",m).option("--video-file-id <id>","Video file ID (wspace-files-svc)").option("-f, --format <format>","Output format").action(async t=>{try{let e={programId:t.program,name:t.name,weekNumber:t.weekNumber??1,orderIndex:t.orderIndex??0};t.description&&(e.description=t.description),t.sets!==void 0&&(e.sets=t.sets),t.reps!==void 0&&(e.reps=t.reps),t.durationSec!==void 0&&(e.durationSec=t.durationSec),t.restSec!==void 0&&(e.restSec=t.restSec),t.videoFileId&&(e.videoFileId=t.videoFileId);let i$1=await b$1(x,{input:e});k$1(`Drill added: ${i$1.athAddDrill.name}`),i(t,i$1.athAddDrill);}catch(e){h(e);}}),o$1.command("remove").description("Remove a drill").argument("<id>","Drill ID").option("-f, --format <format>","Output format").action(async(t,e)=>{try{let i$1=await b$1(N,{id:t});k$1(i$1.athRemoveDrill?`Drill ${t} removed`:`Drill ${t} not removed`),i(e,{removed:i$1.athRemoveDrill});}catch(i){h(i);}});}function rt(d){let r$1=d.command("sessions").description("AtheleteBridge coaching sessions");r$1.command("list").description("List sessions").option("--athlete <id>","Filter by athlete ID").option("--coach <id>","Filter by coach ID").option("--status <s>","Filter by session status").option("--limit <n>","Page size",m,50).option("--offset <n>","Offset",m,0).option("-f, --format <format>","Output format").action(async o=>{try{let t=await b$1(U,{pagination:{limit:o.limit,offset:o.offset},athleteId:o.athlete,coachId:o.coach,status:o.status?o.status.toUpperCase():void 0});i(o,t.athListSessions.items,{headers:["ID","Title","Type","Status","Scheduled"],rows:t.athListSessions.items.map(e=>[r(e.id,12),e.title,e.type,e.status,e.scheduledAt])});}catch(t){h(t);}}),r$1.command("get").description("Get a session by id").argument("<id>","Session ID").option("-f, --format <format>","Output format").action(async(o$1,t)=>{try{let e=await b$1(F,{id:o$1});if(!e.athSession)throw new o(`Session ${o$1} not found`);i(t,e.athSession);}catch(e){h(e);}}),r$1.command("book").description("Book a coaching session").requiredOption("--athlete <id>","Athlete ID").requiredOption("--coach <id>","Coach ID").requiredOption("--title <s>","Session title").requiredOption("--scheduled-at <iso>","Scheduled at (ISO timestamp)").option("--type <t>","Session type","IN_PERSON").option("--duration-min <n>","Duration (minutes)",m).option("--location <s>","Location").option("--meeting-url <url>","Meeting URL").option("--program <id>","Program ID").option("-f, --format <format>","Output format").action(async o=>{try{let t={athleteId:o.athlete,coachId:o.coach,title:o.title,scheduledAt:o.scheduledAt,type:(o.type??"IN_PERSON").toUpperCase()};o.durationMin!==void 0&&(t.durationMin=o.durationMin),o.location&&(t.location=o.location),o.meetingUrl&&(t.meetingUrl=o.meetingUrl),o.program&&(t.programId=o.program);let e=await b$1(_,{input:t});k$1(`Session booked: ${e.athBookSession.title}`),i(o,e.athBookSession);}catch(t){h(t);}}),r$1.command("confirm").description("Confirm a requested session").argument("<id>","Session ID").option("-f, --format <format>","Output format").action(async(o,t)=>{try{let e=await b$1(G,{id:o});k$1(`Session confirmed: ${e.athConfirmSession.status}`),i(t,e.athConfirmSession);}catch(e){h(e);}}),r$1.command("cancel").description("Cancel a session").argument("<id>","Session ID").option("-f, --format <format>","Output format").action(async(o,t)=>{try{let e=await b$1(W,{id:o});k$1(`Session cancelled: ${e.athCancelSession.status}`),i(t,e.athCancelSession);}catch(e){h(e);}}),r$1.command("complete").description("Complete a session (optionally with rating and feedback)").argument("<id>","Session ID").option("--rating <n>","Rating",m).option("--feedback <s>","Feedback").option("-f, --format <format>","Output format").action(async(o,t)=>{try{let e={};t.rating!==void 0&&(e.rating=t.rating),t.feedback&&(e.feedback=t.feedback);let i$1=await b$1(q,{id:o,input:Object.keys(e).length?e:void 0});k$1(`Session completed: ${i$1.athCompleteSession.status}`),i(t,i$1.athCompleteSession);}catch(e){h(e);}});}function it(d){let r$1=d.command("workouts").description("AtheleteBridge workout logs");r$1.command("list").description("List workout logs").option("--athlete <id>","Filter by athlete ID").option("--program <id>","Filter by program ID").option("--limit <n>","Page size",m,50).option("--offset <n>","Offset",m,0).option("-f, --format <format>","Output format").action(async o=>{try{let t=await b$1(B,{pagination:{limit:o.limit,offset:o.offset},athleteId:o.athlete,programId:o.program});i(o,t.athListWorkoutLogs.items,{headers:["ID","Title","Status","Performed","Load","RPE"],rows:t.athListWorkoutLogs.items.map(e=>[r(e.id,12),e.title,e.status,e.performedAt,e.totalLoad!==void 0&&e.totalLoad!==null?String(e.totalLoad):"-",e.rpe!==void 0&&e.rpe!==null?String(e.rpe):"-"])});}catch(t){h(t);}}),r$1.command("log").description("Log a workout").requiredOption("--title <s>","Workout title").requiredOption("--performed-at <iso>","Performed at (ISO timestamp)").option("--athlete <id>","Athlete ID").option("--program <id>","Program ID").option("--status <s>","Workout status","COMPLETED").option("--duration-min <n>","Duration (minutes)",m).option("--total-load <n>","Total load",l).option("--rpe <n>","Rate of perceived exertion",m).option("--notes <s>","Notes").option("--metrics <json>","Metrics JSON object").option("-f, --format <format>","Output format").action(async o=>{try{let t={title:o.title,performedAt:o.performedAt,status:(o.status??"COMPLETED").toUpperCase()};o.athlete&&(t.athleteId=o.athlete),o.program&&(t.programId=o.program),o.durationMin!==void 0&&(t.durationMin=o.durationMin),o.totalLoad!==void 0&&(t.totalLoad=o.totalLoad),o.rpe!==void 0&&(t.rpe=o.rpe),o.notes&&(t.notes=o.notes),o.metrics&&(t.metrics=Z("metrics",o.metrics));let e=await b$1(H,{input:t});k$1(`Workout logged: ${e.athLogWorkout.title}`),i(o,e.athLogWorkout);}catch(t){h(t);}});}function at(d){let r$1=d.command("metrics").description("AtheleteBridge performance metrics");r$1.command("list").description("List performance metrics for an athlete").requiredOption("--athlete <id>","Athlete ID").option("--type <t>","Filter by metric type").option("-f, --format <format>","Output format").action(async o=>{try{let t=await b$1(j,{athleteId:o.athlete,type:o.type?o.type.toUpperCase():void 0});i(o,t.athPerformanceMetrics.items,{headers:["ID","Label","Type","Value","Unit","Recorded"],rows:t.athPerformanceMetrics.items.map(e=>[r(e.id,12),e.label,e.type,String(e.value),e.unit??"-",e.recordedAt])});}catch(t){h(t);}}),r$1.command("record").description("Record a performance metric").requiredOption("--label <s>","Metric label").requiredOption("--value <n>","Metric value",l).requiredOption("--recorded-at <iso>","Recorded at (ISO timestamp)").option("--athlete <id>","Athlete ID").option("--type <t>","Metric type","CUSTOM").option("--unit <s>","Unit").option("--source <s>","Source").option("-f, --format <format>","Output format").action(async o=>{try{let t={label:o.label,value:o.value,recordedAt:o.recordedAt,type:(o.type??"CUSTOM").toUpperCase()};o.athlete&&(t.athleteId=o.athlete),o.unit&&(t.unit=o.unit),o.source&&(t.source=o.source);let e=await b$1(V,{input:t});k$1(`Metric recorded: ${e.athRecordMetric.label}`),i(o,e.athRecordMetric);}catch(t){h(t);}});}function nt(d){let r$1=d.command("fixtures").description("AtheleteBridge fixtures");r$1.command("list").description("List fixtures").option("--team <id>","Filter by team ID").option("--status <s>","Filter by fixture status").option("--limit <n>","Page size",m,50).option("--offset <n>","Offset",m,0).option("-f, --format <format>","Output format").action(async o=>{try{let t=await b$1(J,{pagination:{limit:o.limit,offset:o.offset},status:o.status?o.status.toUpperCase():void 0,teamId:o.team});i(o,t.athListFixtures.items,{headers:["ID","Type","Status","Competition","Scheduled","Score"],rows:t.athListFixtures.items.map(e=>[r(e.id,12),e.type,e.status,e.competition??"-",e.scheduledAt,e.homeScore!==void 0&&e.homeScore!==null&&e.awayScore!==void 0&&e.awayScore!==null?`${e.homeScore}-${e.awayScore}`:"-"])});}catch(t){h(t);}}),r$1.command("get").description("Get a fixture by id").argument("<id>","Fixture ID").option("-f, --format <format>","Output format").action(async(o$1,t)=>{try{let e=await b$1(X,{id:o$1});if(!e.athFixture)throw new o(`Fixture ${o$1} not found`);i(t,e.athFixture);}catch(e){h(e);}}),r$1.command("schedule").description("Schedule a fixture").requiredOption("--home-team <id>","Home team ID").requiredOption("--scheduled-at <iso>","Scheduled at (ISO timestamp)").option("--away-team <id>","Away team ID").option("--type <t>","Fixture type","FRIENDLY").option("--competition <s>","Competition").option("--round <s>","Round").option("--kickoff-at <iso>","Kickoff at (ISO timestamp)").option("--venue <s>","Venue").option("--notes <s>","Notes").option("-f, --format <format>","Output format").action(async o=>{try{let t={homeTeamId:o.homeTeam,scheduledAt:o.scheduledAt,type:(o.type??"FRIENDLY").toUpperCase()};o.awayTeam&&(t.awayTeamId=o.awayTeam),o.competition&&(t.competition=o.competition),o.round&&(t.round=o.round),o.kickoffAt&&(t.kickoffAt=o.kickoffAt),o.venue&&(t.venue=o.venue),o.notes&&(t.notes=o.notes);let e=await b$1(K,{input:t});k$1(`Fixture scheduled: ${e.athScheduleFixture.id}`),i(o,e.athScheduleFixture);}catch(t){h(t);}}),r$1.command("record-result").description("Record a final result for a fixture and recompute standings").argument("<id>","Fixture ID").requiredOption("--home-score <n>","Home score",m).requiredOption("--away-score <n>","Away score",m).option("-f, --format <format>","Output format").action(async(o,t)=>{try{let e=await b$1(z,{id:o,input:{homeScore:t.homeScore,awayScore:t.awayScore}});k$1(`Result recorded: ${e.athRecordFixtureResult.homeScore??0}-${e.athRecordFixtureResult.awayScore??0}`),i(t,e.athRecordFixtureResult);}catch(e){h(e);}});}function st(d){d.command("standings").description("AtheleteBridge standings").command("list").description("List standings for a competition").requiredOption("--competition <s>","Competition name").option("-f, --format <format>","Output format").action(async o=>{try{let t=await b$1(Y,{competition:o.competition});i(o,t.athStandings.items,{headers:["Rank","Team","P","W","D","L","Pts"],rows:t.athStandings.items.map(e=>[e.rank!==void 0&&e.rank!==null?String(e.rank):"-",r(e.teamId,12),String(e.played),String(e.won),String(e.drawn),String(e.lost),String(e.points)])});}catch(t){h(t);}});}function mt(d$1){d$1.command("health").description("AtheleteBridge service health check (public)").option("-f, --format <format>","Output format").action(async r=>{try{let o=await d(Q);k$1(o.athHealth),i(r,{health:o.athHealth});}catch(o){h(o);}});}var pt={id:"atheletebridge",version:"1.0.0",displayName:"AtheleteBridge",dependsOn:["auth","workspaces"],register(d,r){a(r);let o=d.command("atheletebridge").description("AtheleteBridge sports team & athlete management");tt(o),et(o),ot(o),rt(o),it(o),at(o),nt(o),st(o),mt(o);}},Vt=pt;export{Vt as default};
290
+ `;function Z(d,r){try{return JSON.parse(r)}catch{throw new q$1(`--${d} must be valid JSON`)}}function m(d){let r=Number.parseInt(d,10);if(Number.isNaN(r))throw new q$1(`Expected an integer but got "${d}"`);return r}function l(d){let r=Number.parseFloat(d);if(Number.isNaN(r))throw new q$1(`Expected a number but got "${d}"`);return r}function I(d){return d.split(",").map(r=>r.trim()).filter(r=>r.length>0)}function tt(d){let r$1=d.command("teams").description("AtheleteBridge teams");r$1.command("list").description("List teams").option("--sport <s>","Filter by sport").option("--status <s>","Filter by team status").option("--limit <n>","Page size",m,50).option("--offset <n>","Offset",m,0).option("-f, --format <format>","Output format").action(async o=>{try{let t=await b$1(y,{pagination:{limit:o.limit,offset:o.offset},sport:o.sport?o.sport.toUpperCase():void 0,status:o.status?o.status.toUpperCase():void 0});i(o,t.athListTeams.items,{headers:["ID","Name","Sport","Status","Season"],rows:t.athListTeams.items.map(e=>[r(e.id,12),e.name,e.sport,e.status,e.season??"-"])});}catch(t){h(t);}}),r$1.command("get").description("Get a team by id").argument("<id>","Team ID").option("-f, --format <format>","Output format").action(async(o,t)=>{try{let e=await b$1(w,{id:o});if(!e.athTeam)throw new q$1(`Team ${o} not found`);i(t,e.athTeam);}catch(e){h(e);}}),r$1.command("create").description("Create a team").requiredOption("--name <name>","Team name").option("--description <s>","Description").option("--sport <s>","Sport","OTHER").option("--status <s>","Team status","FORMING").option("--season <s>","Season").option("--age-group <s>","Age group").option("--home-venue <s>","Home venue").option("--head-coach-id <id>","Head coach user ID").option("--tags <csv>","Comma-separated tags").option("-f, --format <format>","Output format").action(async o=>{try{let t={name:o.name,sport:(o.sport??"OTHER").toUpperCase(),status:(o.status??"FORMING").toUpperCase()};o.description&&(t.description=o.description),o.season&&(t.season=o.season),o.ageGroup&&(t.ageGroup=o.ageGroup),o.homeVenue&&(t.homeVenue=o.homeVenue),o.headCoachId&&(t.headCoachId=o.headCoachId),o.tags&&(t.tags=I(o.tags));let e=await b$1(b,{input:t});k$1(`Team created: ${e.athCreateTeam.name}`),i(o,e.athCreateTeam);}catch(t){h(t);}}),r$1.command("update").description("Update a team").argument("<id>","Team ID").option("--name <name>","Team name").option("--description <s>","Description").option("--sport <s>","Sport").option("--status <s>","Team status").option("--season <s>","Season").option("--age-group <s>","Age group").option("--home-venue <s>","Home venue").option("--head-coach-id <id>","Head coach user ID").option("--tags <csv>","Comma-separated tags").option("-f, --format <format>","Output format").action(async(o,t)=>{try{let e={};if(t.name&&(e.name=t.name),t.description!==void 0&&(e.description=t.description),t.sport&&(e.sport=t.sport.toUpperCase()),t.status&&(e.status=t.status.toUpperCase()),t.season&&(e.season=t.season),t.ageGroup&&(e.ageGroup=t.ageGroup),t.homeVenue&&(e.homeVenue=t.homeVenue),t.headCoachId&&(e.headCoachId=t.headCoachId),t.tags&&(e.tags=I(t.tags)),!Object.keys(e).length)throw new q$1("No updates specified");let i$1=await b$1(R,{id:o,input:e});k$1("Team updated"),i(t,i$1.athUpdateTeam);}catch(e){h(e);}}),r$1.command("archive").description("Archive a team").argument("<id>","Team ID").option("-f, --format <format>","Output format").action(async(o,t)=>{try{let e=await b$1(C,{id:o});k$1(e.athArchiveTeam?`Team ${o} archived`:`Team ${o} not archived`),i(t,{archived:e.athArchiveTeam});}catch(e){h(e);}});}function et(d){let r$1=d.command("members").description("AtheleteBridge team members");r$1.command("list").description("List members of a team").requiredOption("--team <id>","Team ID").option("--status <s>","Filter by member status").option("-f, --format <format>","Output format").action(async o=>{try{let t=await b$1(T,{teamId:o.team,status:o.status?o.status.toUpperCase():void 0});i(o,t.athListMembers.items,{headers:["ID","Name","Role","Status","Jersey","Position"],rows:t.athListMembers.items.map(e=>[r(e.id,12),e.displayName,e.role,e.status,e.jerseyNumber!==void 0&&e.jerseyNumber!==null?String(e.jerseyNumber):"-",e.position??"-"])});}catch(t){h(t);}}),r$1.command("add").description("Add a member to a team").requiredOption("--team <id>","Team ID").requiredOption("--user <id>","User ID").requiredOption("--display-name <name>","Display name").option("--role <r>","Member role","PLAYER").option("--status <s>","Member status","ACTIVE").option("--jersey-number <n>","Jersey number",m).option("--position <s>","Position").option("--dominant-side <s>","Dominant side").option("--height <n>","Height",l).option("--weight <n>","Weight",l).option("--joined-at <iso>","Joined at (ISO timestamp)").option("--notes <s>","Notes").option("-f, --format <format>","Output format").action(async o=>{try{let t={teamId:o.team,userId:o.user,displayName:o.displayName,role:(o.role??"PLAYER").toUpperCase(),status:(o.status??"ACTIVE").toUpperCase()};o.jerseyNumber!==void 0&&(t.jerseyNumber=o.jerseyNumber),o.position&&(t.position=o.position),o.dominantSide&&(t.dominantSide=o.dominantSide),o.height!==void 0&&(t.height=o.height),o.weight!==void 0&&(t.weight=o.weight),o.joinedAt&&(t.joinedAt=o.joinedAt),o.notes&&(t.notes=o.notes);let e=await b$1(k,{input:t});k$1(`Member added: ${e.athAddMember.displayName}`),i(o,e.athAddMember);}catch(t){h(t);}}),r$1.command("update").description("Update a team member").argument("<id>","Member ID").option("--display-name <name>","Display name").option("--role <r>","Member role").option("--status <s>","Member status").option("--jersey-number <n>","Jersey number",m).option("--position <s>","Position").option("--dominant-side <s>","Dominant side").option("--height <n>","Height",l).option("--weight <n>","Weight",l).option("--notes <s>","Notes").option("-f, --format <format>","Output format").action(async(o,t)=>{try{let e={};if(t.displayName&&(e.displayName=t.displayName),t.role&&(e.role=t.role.toUpperCase()),t.status&&(e.status=t.status.toUpperCase()),t.jerseyNumber!==void 0&&(e.jerseyNumber=t.jerseyNumber),t.position&&(e.position=t.position),t.dominantSide&&(e.dominantSide=t.dominantSide),t.height!==void 0&&(e.height=t.height),t.weight!==void 0&&(e.weight=t.weight),t.notes!==void 0&&(e.notes=t.notes),!Object.keys(e).length)throw new q$1("No updates specified");let i$1=await b$1(O,{id:o,input:e});k$1("Member updated"),i(t,i$1.athUpdateMember);}catch(e){h(e);}}),r$1.command("remove").description("Remove a team member").argument("<id>","Member ID").option("-f, --format <format>","Output format").action(async(o,t)=>{try{let e=await b$1(M,{id:o});k$1(e.athRemoveMember?`Member ${o} removed`:`Member ${o} not removed`),i(t,{removed:e.athRemoveMember});}catch(e){h(e);}});}function ot(d){let r$1=d.command("programs").description("AtheleteBridge training programs");r$1.command("list").description("List training programs").option("--level <l>","Filter by program level").option("--sport <s>","Filter by sport").option("--status <s>","Filter by program status").option("--limit <n>","Page size",m,50).option("--offset <n>","Offset",m,0).option("-f, --format <format>","Output format").action(async t=>{try{let e=await b$1(E,{pagination:{limit:t.limit,offset:t.offset},level:t.level?t.level.toUpperCase():void 0,sport:t.sport?t.sport.toUpperCase():void 0,status:t.status?t.status.toUpperCase():void 0});i(t,e.athListPrograms.items,{headers:["ID","Name","Sport","Level","Status","Weeks"],rows:e.athListPrograms.items.map(i=>[r(i.id,12),i.name,i.sport,i.level,i.status,i.weeks!==void 0&&i.weeks!==null?String(i.weeks):"-"])});}catch(e){h(e);}}),r$1.command("get").description("Get a training program by id").argument("<id>","Program ID").option("-f, --format <format>","Output format").action(async(t,e)=>{try{let i$1=await b$1($,{id:t});if(!i$1.athProgram)throw new q$1(`Program ${t} not found`);i(e,i$1.athProgram);}catch(i){h(i);}}),r$1.command("create").description("Create a training program").requiredOption("--name <name>","Program name").option("--summary <s>","Summary").option("--sport <s>","Sport","OTHER").option("--level <l>","Level","BEGINNER").option("--weeks <n>","Number of weeks",m).option("--template","Mark as a template").option("--tags <csv>","Comma-separated tags").option("-f, --format <format>","Output format").action(async t=>{try{let e={name:t.name,sport:(t.sport??"OTHER").toUpperCase(),level:(t.level??"BEGINNER").toUpperCase(),isTemplate:!!t.template};t.summary&&(e.summary=t.summary),t.weeks!==void 0&&(e.weeks=t.weeks),t.tags&&(e.tags=I(t.tags));let i$1=await b$1(D,{input:e});k$1(`Program created: ${i$1.athCreateProgram.name}`),i(t,i$1.athCreateProgram);}catch(e){h(e);}}),r$1.command("update").description("Update a training program").argument("<id>","Program ID").option("--name <name>","Program name").option("--summary <s>","Summary").option("--sport <s>","Sport").option("--level <l>","Level").option("--weeks <n>","Number of weeks",m).option("--template <bool>","Template flag (true|false)").option("--tags <csv>","Comma-separated tags").option("-f, --format <format>","Output format").action(async(t,e)=>{try{let i$1={};if(e.name&&(i$1.name=e.name),e.summary!==void 0&&(i$1.summary=e.summary),e.sport&&(i$1.sport=e.sport.toUpperCase()),e.level&&(i$1.level=e.level.toUpperCase()),e.weeks!==void 0&&(i$1.weeks=e.weeks),e.template!==void 0&&(i$1.isTemplate=e.template==="true"),e.tags&&(i$1.tags=I(e.tags)),!Object.keys(i$1).length)throw new q$1("No updates specified");let dt=await b$1(L,{id:t,input:i$1});k$1("Program updated"),i(e,dt.athUpdateProgram);}catch(i){h(i);}}),r$1.command("transition").description("Advance a program through its publish lifecycle (DRAFT -> PUBLISHED -> ARCHIVED)").argument("<id>","Program ID").requiredOption("--status <s>","Target status: DRAFT|PUBLISHED|ARCHIVED").option("-f, --format <format>","Output format").action(async(t,e)=>{try{let i$1=await b$1(v,{id:t,status:e.status.toUpperCase()});k$1(`Program transitioned to ${i$1.athTransitionProgram.status}`),i(e,i$1.athTransitionProgram);}catch(i){h(i);}}),r$1.command("archive").description("Archive a training program").argument("<id>","Program ID").option("-f, --format <format>","Output format").action(async(t,e)=>{try{let i$1=await b$1(P,{id:t});k$1(i$1.athArchiveProgram?`Program ${t} archived`:`Program ${t} not archived`),i(e,{archived:i$1.athArchiveProgram});}catch(i){h(i);}});let o=r$1.command("drills").description("AtheleteBridge program drills");o.command("add").description("Add a drill to a program").requiredOption("--program <id>","Program ID").requiredOption("--name <name>","Drill name").option("--description <s>","Description").option("--week-number <n>","Week number",m,1).option("--order-index <n>","Order index",m,0).option("--sets <n>","Sets",m).option("--reps <n>","Reps",m).option("--duration-sec <n>","Duration (seconds)",m).option("--rest-sec <n>","Rest (seconds)",m).option("--video-file-id <id>","Video file ID (wspace-files-svc)").option("-f, --format <format>","Output format").action(async t=>{try{let e={programId:t.program,name:t.name,weekNumber:t.weekNumber??1,orderIndex:t.orderIndex??0};t.description&&(e.description=t.description),t.sets!==void 0&&(e.sets=t.sets),t.reps!==void 0&&(e.reps=t.reps),t.durationSec!==void 0&&(e.durationSec=t.durationSec),t.restSec!==void 0&&(e.restSec=t.restSec),t.videoFileId&&(e.videoFileId=t.videoFileId);let i$1=await b$1(x,{input:e});k$1(`Drill added: ${i$1.athAddDrill.name}`),i(t,i$1.athAddDrill);}catch(e){h(e);}}),o.command("remove").description("Remove a drill").argument("<id>","Drill ID").option("-f, --format <format>","Output format").action(async(t,e)=>{try{let i$1=await b$1(N,{id:t});k$1(i$1.athRemoveDrill?`Drill ${t} removed`:`Drill ${t} not removed`),i(e,{removed:i$1.athRemoveDrill});}catch(i){h(i);}});}function rt(d){let r$1=d.command("sessions").description("AtheleteBridge coaching sessions");r$1.command("list").description("List sessions").option("--athlete <id>","Filter by athlete ID").option("--coach <id>","Filter by coach ID").option("--status <s>","Filter by session status").option("--limit <n>","Page size",m,50).option("--offset <n>","Offset",m,0).option("-f, --format <format>","Output format").action(async o=>{try{let t=await b$1(U,{pagination:{limit:o.limit,offset:o.offset},athleteId:o.athlete,coachId:o.coach,status:o.status?o.status.toUpperCase():void 0});i(o,t.athListSessions.items,{headers:["ID","Title","Type","Status","Scheduled"],rows:t.athListSessions.items.map(e=>[r(e.id,12),e.title,e.type,e.status,e.scheduledAt])});}catch(t){h(t);}}),r$1.command("get").description("Get a session by id").argument("<id>","Session ID").option("-f, --format <format>","Output format").action(async(o,t)=>{try{let e=await b$1(F,{id:o});if(!e.athSession)throw new q$1(`Session ${o} not found`);i(t,e.athSession);}catch(e){h(e);}}),r$1.command("book").description("Book a coaching session").requiredOption("--athlete <id>","Athlete ID").requiredOption("--coach <id>","Coach ID").requiredOption("--title <s>","Session title").requiredOption("--scheduled-at <iso>","Scheduled at (ISO timestamp)").option("--type <t>","Session type","IN_PERSON").option("--duration-min <n>","Duration (minutes)",m).option("--location <s>","Location").option("--meeting-url <url>","Meeting URL").option("--program <id>","Program ID").option("-f, --format <format>","Output format").action(async o=>{try{let t={athleteId:o.athlete,coachId:o.coach,title:o.title,scheduledAt:o.scheduledAt,type:(o.type??"IN_PERSON").toUpperCase()};o.durationMin!==void 0&&(t.durationMin=o.durationMin),o.location&&(t.location=o.location),o.meetingUrl&&(t.meetingUrl=o.meetingUrl),o.program&&(t.programId=o.program);let e=await b$1(_,{input:t});k$1(`Session booked: ${e.athBookSession.title}`),i(o,e.athBookSession);}catch(t){h(t);}}),r$1.command("confirm").description("Confirm a requested session").argument("<id>","Session ID").option("-f, --format <format>","Output format").action(async(o,t)=>{try{let e=await b$1(G,{id:o});k$1(`Session confirmed: ${e.athConfirmSession.status}`),i(t,e.athConfirmSession);}catch(e){h(e);}}),r$1.command("cancel").description("Cancel a session").argument("<id>","Session ID").option("-f, --format <format>","Output format").action(async(o,t)=>{try{let e=await b$1(W,{id:o});k$1(`Session cancelled: ${e.athCancelSession.status}`),i(t,e.athCancelSession);}catch(e){h(e);}}),r$1.command("complete").description("Complete a session (optionally with rating and feedback)").argument("<id>","Session ID").option("--rating <n>","Rating",m).option("--feedback <s>","Feedback").option("-f, --format <format>","Output format").action(async(o,t)=>{try{let e={};t.rating!==void 0&&(e.rating=t.rating),t.feedback&&(e.feedback=t.feedback);let i$1=await b$1(q,{id:o,input:Object.keys(e).length?e:void 0});k$1(`Session completed: ${i$1.athCompleteSession.status}`),i(t,i$1.athCompleteSession);}catch(e){h(e);}});}function it(d){let r$1=d.command("workouts").description("AtheleteBridge workout logs");r$1.command("list").description("List workout logs").option("--athlete <id>","Filter by athlete ID").option("--program <id>","Filter by program ID").option("--limit <n>","Page size",m,50).option("--offset <n>","Offset",m,0).option("-f, --format <format>","Output format").action(async o=>{try{let t=await b$1(B,{pagination:{limit:o.limit,offset:o.offset},athleteId:o.athlete,programId:o.program});i(o,t.athListWorkoutLogs.items,{headers:["ID","Title","Status","Performed","Load","RPE"],rows:t.athListWorkoutLogs.items.map(e=>[r(e.id,12),e.title,e.status,e.performedAt,e.totalLoad!==void 0&&e.totalLoad!==null?String(e.totalLoad):"-",e.rpe!==void 0&&e.rpe!==null?String(e.rpe):"-"])});}catch(t){h(t);}}),r$1.command("log").description("Log a workout").requiredOption("--title <s>","Workout title").requiredOption("--performed-at <iso>","Performed at (ISO timestamp)").option("--athlete <id>","Athlete ID").option("--program <id>","Program ID").option("--status <s>","Workout status","COMPLETED").option("--duration-min <n>","Duration (minutes)",m).option("--total-load <n>","Total load",l).option("--rpe <n>","Rate of perceived exertion",m).option("--notes <s>","Notes").option("--metrics <json>","Metrics JSON object").option("-f, --format <format>","Output format").action(async o=>{try{let t={title:o.title,performedAt:o.performedAt,status:(o.status??"COMPLETED").toUpperCase()};o.athlete&&(t.athleteId=o.athlete),o.program&&(t.programId=o.program),o.durationMin!==void 0&&(t.durationMin=o.durationMin),o.totalLoad!==void 0&&(t.totalLoad=o.totalLoad),o.rpe!==void 0&&(t.rpe=o.rpe),o.notes&&(t.notes=o.notes),o.metrics&&(t.metrics=Z("metrics",o.metrics));let e=await b$1(H,{input:t});k$1(`Workout logged: ${e.athLogWorkout.title}`),i(o,e.athLogWorkout);}catch(t){h(t);}});}function at(d){let r$1=d.command("metrics").description("AtheleteBridge performance metrics");r$1.command("list").description("List performance metrics for an athlete").requiredOption("--athlete <id>","Athlete ID").option("--type <t>","Filter by metric type").option("-f, --format <format>","Output format").action(async o=>{try{let t=await b$1(j,{athleteId:o.athlete,type:o.type?o.type.toUpperCase():void 0});i(o,t.athPerformanceMetrics.items,{headers:["ID","Label","Type","Value","Unit","Recorded"],rows:t.athPerformanceMetrics.items.map(e=>[r(e.id,12),e.label,e.type,String(e.value),e.unit??"-",e.recordedAt])});}catch(t){h(t);}}),r$1.command("record").description("Record a performance metric").requiredOption("--label <s>","Metric label").requiredOption("--value <n>","Metric value",l).requiredOption("--recorded-at <iso>","Recorded at (ISO timestamp)").option("--athlete <id>","Athlete ID").option("--type <t>","Metric type","CUSTOM").option("--unit <s>","Unit").option("--source <s>","Source").option("-f, --format <format>","Output format").action(async o=>{try{let t={label:o.label,value:o.value,recordedAt:o.recordedAt,type:(o.type??"CUSTOM").toUpperCase()};o.athlete&&(t.athleteId=o.athlete),o.unit&&(t.unit=o.unit),o.source&&(t.source=o.source);let e=await b$1(V,{input:t});k$1(`Metric recorded: ${e.athRecordMetric.label}`),i(o,e.athRecordMetric);}catch(t){h(t);}});}function nt(d){let r$1=d.command("fixtures").description("AtheleteBridge fixtures");r$1.command("list").description("List fixtures").option("--team <id>","Filter by team ID").option("--status <s>","Filter by fixture status").option("--limit <n>","Page size",m,50).option("--offset <n>","Offset",m,0).option("-f, --format <format>","Output format").action(async o=>{try{let t=await b$1(J,{pagination:{limit:o.limit,offset:o.offset},status:o.status?o.status.toUpperCase():void 0,teamId:o.team});i(o,t.athListFixtures.items,{headers:["ID","Type","Status","Competition","Scheduled","Score"],rows:t.athListFixtures.items.map(e=>[r(e.id,12),e.type,e.status,e.competition??"-",e.scheduledAt,e.homeScore!==void 0&&e.homeScore!==null&&e.awayScore!==void 0&&e.awayScore!==null?`${e.homeScore}-${e.awayScore}`:"-"])});}catch(t){h(t);}}),r$1.command("get").description("Get a fixture by id").argument("<id>","Fixture ID").option("-f, --format <format>","Output format").action(async(o,t)=>{try{let e=await b$1(X,{id:o});if(!e.athFixture)throw new q$1(`Fixture ${o} not found`);i(t,e.athFixture);}catch(e){h(e);}}),r$1.command("schedule").description("Schedule a fixture").requiredOption("--home-team <id>","Home team ID").requiredOption("--scheduled-at <iso>","Scheduled at (ISO timestamp)").option("--away-team <id>","Away team ID").option("--type <t>","Fixture type","FRIENDLY").option("--competition <s>","Competition").option("--round <s>","Round").option("--kickoff-at <iso>","Kickoff at (ISO timestamp)").option("--venue <s>","Venue").option("--notes <s>","Notes").option("-f, --format <format>","Output format").action(async o=>{try{let t={homeTeamId:o.homeTeam,scheduledAt:o.scheduledAt,type:(o.type??"FRIENDLY").toUpperCase()};o.awayTeam&&(t.awayTeamId=o.awayTeam),o.competition&&(t.competition=o.competition),o.round&&(t.round=o.round),o.kickoffAt&&(t.kickoffAt=o.kickoffAt),o.venue&&(t.venue=o.venue),o.notes&&(t.notes=o.notes);let e=await b$1(K,{input:t});k$1(`Fixture scheduled: ${e.athScheduleFixture.id}`),i(o,e.athScheduleFixture);}catch(t){h(t);}}),r$1.command("record-result").description("Record a final result for a fixture and recompute standings").argument("<id>","Fixture ID").requiredOption("--home-score <n>","Home score",m).requiredOption("--away-score <n>","Away score",m).option("-f, --format <format>","Output format").action(async(o,t)=>{try{let e=await b$1(z,{id:o,input:{homeScore:t.homeScore,awayScore:t.awayScore}});k$1(`Result recorded: ${e.athRecordFixtureResult.homeScore??0}-${e.athRecordFixtureResult.awayScore??0}`),i(t,e.athRecordFixtureResult);}catch(e){h(e);}});}function st(d){d.command("standings").description("AtheleteBridge standings").command("list").description("List standings for a competition").requiredOption("--competition <s>","Competition name").option("-f, --format <format>","Output format").action(async o=>{try{let t=await b$1(Y,{competition:o.competition});i(o,t.athStandings.items,{headers:["Rank","Team","P","W","D","L","Pts"],rows:t.athStandings.items.map(e=>[e.rank!==void 0&&e.rank!==null?String(e.rank):"-",r(e.teamId,12),String(e.played),String(e.won),String(e.drawn),String(e.lost),String(e.points)])});}catch(t){h(t);}});}function mt(d$1){d$1.command("health").description("AtheleteBridge service health check (public)").option("-f, --format <format>","Output format").action(async r=>{try{let o=await d(Q);k$1(o.athHealth),i(r,{health:o.athHealth});}catch(o){h(o);}});}var pt={id:"atheletebridge",version:"1.0.0",displayName:"AtheleteBridge",dependsOn:["auth","workspaces"],register(d,r){a(r);let o=d.command("atheletebridge").description("AtheleteBridge sports team & athlete management");tt(o),et(o),ot(o),rt(o),it(o),at(o),nt(o),st(o),mt(o);}},Vt=pt;export{Vt as default};
@@ -1,4 +1,4 @@
1
- 'use strict';require('graphql-request');var _=require('cross-fetch');require('commander');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var ___default=/*#__PURE__*/_interopDefault(_);async function M(n){let s=`${n.oidcIssuer}/oidc/device/code`,o=new URLSearchParams({client_id:n.clientId,scope:"openid profile email offline_access"}),i=await ___default.default(s,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:o.toString()});if(!i.ok){let c=await i.text().catch(()=>"Unknown error");throw new Error(`Device code request failed (${i.status}): ${c}`)}let a=await i.json();return {deviceCode:a.device_code,userCode:a.user_code,verificationUri:a.verification_uri,verificationUriComplete:a.verification_uri_complete??null,expiresIn:a.expires_in,interval:a.interval??5}}async function F(n,s,o){let i=`${o.oidcIssuer}/oauth/device/token`,a=s;for(;;){await new Promise(h=>setTimeout(h,a*1e3));let c=await ___default.default(i,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"urn:ietf:params:oauth:grant-type:device_code",device_code:n,client_id:o.clientId}).toString()}),p=await c.json();if(c.ok&&p.access_token)return {accessToken:p.access_token,refreshToken:p.refresh_token??"",expiresIn:p.expires_in??3600};let d=p.error;switch(d){case "authorization_pending":continue;case "slow_down":a+=5;continue;case "expired_token":throw new Error("Device code has expired. Please try again.");case "access_denied":throw new Error("Authorization was denied by the user.");default:throw new Error(`Device code polling failed: ${p.error_description??d??"Unknown error"}`)}}}async function R(n,s,o,i){let c=await ___default.default(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:`
1
+ 'use strict';require('graphql-request');var _=require('cross-fetch');require('commander');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var ___default=/*#__PURE__*/_interopDefault(_);async function M(n){let s=`${n.oidcIssuer}/oidc/device/code`,o=new URLSearchParams({client_id:n.clientId,scope:"openid profile email offline_access"}),i=await ___default.default(s,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:o.toString()});if(!i.ok){let c=await i.text().catch(()=>"Unknown error");throw new Error(`Device code request failed (${i.status}): ${c}`)}let a=await i.json();return {deviceCode:a.device_code,userCode:a.user_code,verificationUri:a.verification_uri,verificationUriComplete:a.verification_uri_complete??null,expiresIn:a.expires_in,interval:a.interval??5}}async function F(n,s,o){let i=`${o.oidcIssuer}/oauth/device/token`,a=s;for(;;){await new Promise(h=>setTimeout(h,a*1e3));let c=await ___default.default(i,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"urn:ietf:params:oauth:grant-type:device_code",device_code:n,client_id:o.clientId}).toString()}),p=await c.json();if(c.ok&&p.access_token)return {accessToken:p.access_token,refreshToken:p.refresh_token??"",expiresIn:p.expires_in??3600};let d=p.error;switch(d){case "authorization_pending":continue;case "slow_down":a+=5;continue;case "expired_token":throw new Error("Device code has expired. Please try again.");case "access_denied":throw new Error("Authorization was denied by the user.");default:throw new Error(`Device code polling failed: ${p.error_description??d??"Unknown error"}`)}}}async function P(n,s,o,i){let c=await ___default.default(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:`
2
2
  mutation AuthenticateApp($input: AuthenticateAppInput!) {
3
3
  authenticateApp(input: $input) {
4
4
  accessToken tokenType expiresIn scopes
@@ -17,7 +17,7 @@
17
17
  items { id name slug tenantId organizationId }
18
18
  }
19
19
  }
20
- `,variables:{limit:50}})});if(!i.ok){let c=await i.text().catch(()=>"Unknown error");throw new Error(`Failed to fetch workspaces (${i.status}): ${c}`)}let a=await i.json();if(a.errors?.length)throw new Error(`Failed to fetch workspaces: ${a.errors[0]?.message??"unknown error"}`);return a.data?.myWorkspaces?.items??[]}function Oe(n){try{let s=new URL(n);return s.protocol==="http:"||s.protocol==="https:"}catch{return false}}async function G(n){try{if(!Oe(n))return !1;let{execFile:s}=await import('child_process'),o=process.platform,i,a;return o==="darwin"?(i="open",a=[n]):o==="win32"?(i="cmd",a=["/c","start","",n]):(i="xdg-open",a=[n]),new Promise(c=>{s(i,a,p=>{c(!p);});})}catch{return false}}var k=class extends Error{exitCode;hint;constructor(s,o){super(s),this.name="CliUserError",this.exitCode=o?.exitCode??1,this.hint=o?.hint;}};var x=class extends Error{cause;constructor(s,o){super(s),this.name="CliInternalError",this.cause=o;}};var W=null;function V(n){W=n;}function y(){if(!W)throw new x("vibecontrols module helpers used before setHelpersContext was called");return W}async function l(n,s){return y().gql.global.request(n,s)}async function K(n,s){return y().gql.global.request(n,s)}function E(){y().gql.reset();}function u(n){let s=n instanceof Error?n.message:String(n);throw new k(s)}function m(n,s,o){y().output.formatAndOutput(n,s,o);}function g(n){y().output.printSuccess(n);}function C(n){y().output.printInfo(n);}function v(n){y().output.printWarning(n);}function L(n){y().output.printJson(n);}function q(n){return y().output.formatStatus(n)}function T(n){return y().output.formatDate(n)}function $(n,s){return y().output.truncate(n,s)}function O(){return y()}function D(){return y().auth.read()}function S(n){y().auth.write(n);}function B(){y().auth.clear();}function U(){return y().config.read()}function H(){return y().config.resolveOIDC()}function Y(n){return n?n.expiresAt?Date.now()>=n.expiresAt:false:y().auth.isTokenExpired()}var J=`
20
+ `,variables:{limit:50}})});if(!i.ok){let c=await i.text().catch(()=>"Unknown error");throw new Error(`Failed to fetch workspaces (${i.status}): ${c}`)}let a=await i.json();if(a.errors?.length)throw new Error(`Failed to fetch workspaces: ${a.errors[0]?.message??"unknown error"}`);return a.data?.myWorkspaces?.items??[]}function Oe(n){try{let s=new URL(n);return s.protocol==="http:"||s.protocol==="https:"}catch{return false}}async function G(n){try{if(!Oe(n))return !1;let{execFile:s}=await import('child_process'),o=process.platform,i,a;return o==="darwin"?(i="open",a=[n]):o==="win32"?(i="cmd",a=["/c","start","",n]):(i="xdg-open",a=[n]),new Promise(c=>{s(i,a,p=>{c(!p);});})}catch{return false}}var k=class extends Error{exitCode;hint;constructor(s,o){super(s),this.name="CliUserError",this.exitCode=o?.exitCode??1,this.hint=o?.hint;}};var x=class extends Error{cause;constructor(s,o){super(s),this.name="CliInternalError",this.cause=o;}};var W=null;function V(n){W=n;}function y(){if(!W)throw new x("vibecontrols module helpers used before setHelpersContext was called");return W}async function l(n,s){return y().gql.global.request(n,s)}async function K(n,s){return y().gql.global.request(n,s)}function E(){y().gql.reset();}function u(n){let s=n instanceof Error?n.message:String(n);throw new k(s)}function m(n,s,o){y().output.formatAndOutput(n,s,o);}function g(n){y().output.printSuccess(n);}function C(n){y().output.printInfo(n);}function v(n){y().output.printWarning(n);}function q(n){y().output.printJson(n);}function L(n){return y().output.formatStatus(n)}function T(n){return y().output.formatDate(n)}function $(n,s){return y().output.truncate(n,s)}function O(){return y()}function D(){return y().auth.read()}function S(n){y().auth.write(n);}function B(){y().auth.clear();}function U(){return y().config.read()}function H(){return y().config.resolveOIDC()}function Y(n){return n?n.expiresAt?Date.now()>=n.expiresAt:false:y().auth.isTokenExpired()}var J=`
21
21
  query currentUser {
22
22
  currentUser {
23
23
  id email firstName lastName username phoneNumber name
@@ -30,7 +30,7 @@
30
30
  id name firstName lastName username phoneNumber
31
31
  }
32
32
  }
33
- `,z=`
33
+ `,j=`
34
34
  query authAuditLogs($pagination: PaginationInput) {
35
35
  authAuditLogs(pagination: $pagination) {
36
36
  auditLogs {
@@ -201,5 +201,5 @@
201
201
  refreshToken(token: $token) { accessToken refreshToken expiresIn }
202
202
  }
203
203
  `;async function Ee(n,s){if(n.length===0)throw new k("No workspaces to choose from");if(s.preferredId){let p=n.find(d=>d.id===s.preferredId);if(!p)throw new k(`Workspace ${s.preferredId} is not one of your workspaces`);return {workspace:p,prompted:false}}let[o]=n;if(n.length===1||!s.interactive)return {workspace:o,prompted:false};let i=await s.ask(`
204
- Select workspace [1-${n.length}]: `),a=i===null?-1:parseInt(i.trim(),10)-1;return {workspace:(a>=0&&a<n.length?n[a]:void 0)??o,prompted:true}}async function Te(n){let o=(await import('readline')).createInterface({input:process.stdin,output:process.stdout});return new Promise(i=>{let a=false;o.on("close",()=>{a||i(null);}),o.question(n,c=>{a=true,o.close(),i(c);});})}function be(n){let s=n.command("auth").description("Authentication commands");s.command("login").description(`Authenticate with ${O().productName}`).option("--client-credentials","Authenticate as an app with client ID and secret").option("--workspace-id <id>","Workspace to bind the session to").action(async o=>{try{o.clientCredentials?await Me(o.workspaceId):await qe(o.workspaceId);}catch(i){u(i);}}),s.command("logout").description("Revoke tokens and clear stored auth").action(async()=>{try{if(D()?.accessToken)try{await K(Ce);}catch{v("Server-side logout failed, clearing local tokens");}B(),E(),g("Logged out successfully");}catch(o){u(o);}}),s.command("status").description("Show current auth state").option("-f, --format <format>","Output format (json, table)").action(o=>{let i=D(),a=U(),c=!!i?.accessToken,p=i?.accessToken?Y(i):false,d=i?.expiresAt?T(new Date(i.expiresAt).toISOString()):"-",h=i?.authMethod==="client_credentials"?"Client Credentials":"OAuth2 Device Code",e=i?.workspaceTokenExpiresAt?T(new Date(i.workspaceTokenExpiresAt).toISOString()):"-";m(o,{authenticated:c,method:h,expired:p,expiresAt:d,workspaceId:i?.workspaceId??"-",organizationId:i?.organizationId??"-",workspaceTokenExpiresAt:e,workspaceEndpoint:a.workspaceEndpoint,globalEndpoint:a.globalEndpoint},{headers:["Key","Value"],rows:[["Authenticated",String(c)],["Method",h],["Expired",String(p)],["Expires At",d],["Workspace ID",i?.workspaceId??"-"],["Organization ID",i?.organizationId??"-"],["Workspace Token Expires",e],["Workspace Endpoint",a.workspaceEndpoint],["Global Endpoint",a.globalEndpoint]]});}),s.command("token").description("Print access token to stdout").option("--workspace","Print workspace token instead").action(o=>{let i=D();if(o.workspace){if(!i?.workspaceToken)throw new k(`No workspace token. Set a workspace: ${O().productName} workspace set <id>`);process.stdout.write(i.workspaceToken);return}if(!i?.accessToken)throw new k(`Not authenticated. Run: ${O().productName} auth login`);process.stdout.write(i.accessToken);}),s.command("refresh").description("Force token refresh").action(async()=>{try{let o=D();if(!o?.refreshToken&&o?.authMethod!=="client_credentials")throw new k(`No refresh token available. Run: ${O().productName} auth login`);if(o?.authMethod==="client_credentials"&&o.clientId&&o.clientSecret){let c=U(),p=await R(c.globalEndpoint,o.clientId,o.clientSecret);S({...o,accessToken:p.accessToken,expiresAt:Date.now()+p.expiresIn*1e3}),E(),g("App token refreshed successfully"),o.workspaceId&&o.organizationId&&await Se();return}let a=(await K(xe,{token:o.refreshToken})).refreshToken;S({...o,accessToken:a.accessToken,refreshToken:a.refreshToken,expiresAt:Date.now()+a.expiresIn*1e3}),E(),g("Token refreshed successfully"),o.workspaceId&&o.organizationId&&await Se();}catch(o){u(o);}});}async function Se(){let n=D();if(!n?.accessToken||!n.workspaceId||!n.organizationId)return;let s=U();try{let o=await b(s.workspaceEndpoint,n.accessToken,n.workspaceId,n.organizationId);S({...n,workspaceToken:o.token,workspaceTokenExpiresAt:new Date(o.expiresAt).getTime()}),E(),g("Workspace token refreshed");}catch{v("Workspace token refresh failed \u2014 workspace operations may require re-login");}}async function qe(n){let s=U(),{oidcIssuer:o,clientId:i}=H(),a={...s,oidcIssuer:o,clientId:i};C("Starting device code authentication...");let c=await M(a);console.log(""),console.log(` Open: ${c.verificationUri}`),console.log(` Code: ${c.userCode}`),console.log(""),await G(c.verificationUriComplete??c.verificationUri)?C("Browser opened"):v("Could not open browser \u2014 open the URL manually"),C("Waiting for authorization...");let d=await F(c.deviceCode,c.interval,a),h=d.accessToken,e=Date.now()+d.expiresIn*1e3;S({accessToken:h,refreshToken:d.refreshToken,expiresAt:e,authMethod:"device_code"}),E(),C("Fetching workspaces...");try{let t=await N(s.globalEndpoint,h);if(t.length===0){g("Authentication successful (no workspaces found)");return}let r=!!process.stdin.isTTY;t.length>1&&r&&!n&&(console.log(`
205
- Available workspaces:`),t.forEach((w,P)=>console.log(` ${P+1}. ${w.name} (${w.slug})`)));let{workspace:f}=await Ee(t,{preferredId:n,interactive:r,ask:Te});t.length>1&&!r&&!n&&C(`${t.length} workspaces available; pass --workspace-id or run \`${O().productName} workspace set <id>\` to switch`),C(`Using workspace: ${f.name} (${f.id})`);let I=await b(s.workspaceEndpoint,h,f.id,f.organizationId);S({accessToken:h,refreshToken:d.refreshToken,expiresAt:e,workspaceToken:I.token,workspaceTokenExpiresAt:new Date(I.expiresAt).getTime(),workspaceId:f.id,organizationId:f.organizationId,authMethod:"device_code"}),E(),g("Authentication successful");}catch(t){S({accessToken:h,refreshToken:d.refreshToken,expiresAt:e,authMethod:"device_code"}),E(),g("Authentication successful"),v(`Workspace token not obtained: ${t instanceof Error?t.message:String(t)}`),C(`Set workspace manually: ${O().productName} workspace set <id>`);}}async function Me(n){let s=U(),i=(await import('readline')).createInterface({input:process.stdin,output:process.stdout}),a=await new Promise(I=>{i.question("Client ID: ",w=>I(w.trim()));}),c=await new Promise(I=>{i.question("Client Secret: ",w=>{i.close(),I(w.trim());});});if(!a||!c)throw new k("Client ID and secret cannot be empty");C("Authenticating app...");let p=await R(s.globalEndpoint,a,c),d=p.accessToken,h=Date.now()+p.expiresIn*1e3,e,t,r=n,f;if(r)try{let w=(await N(s.globalEndpoint,d)).find(P=>P.id===r);if(w){f=w.organizationId;let P=await b(s.workspaceEndpoint,d,r,f);e=P.token,t=new Date(P.expiresAt).getTime(),C(`Workspace token issued for: ${w.name}`);}else v(`Workspace ${r} not found \u2014 skipping workspace token`),r=void 0;}catch(I){v(`Workspace token failed: ${I instanceof Error?I.message:String(I)}`);}S({accessToken:d,refreshToken:"",expiresAt:h,workspaceToken:e,workspaceTokenExpiresAt:t,workspaceId:r,organizationId:f,authMethod:"client_credentials",clientId:a,clientSecret:c}),E(),g("App authentication successful");}function ve(n){let s=n.command("profile").description("Current user profile");s.command("show").description("Show current user").option("-f, --format <format>").action(async e=>{try{let t=await l(J);m(e,t.currentUser);}catch(t){u(t);}}),s.command("update").description("Update current user profile").option("--first-name <s>").option("--last-name <s>").option("--name <s>").option("--username <s>").option("--phone <s>").option("--timezone <s>").option("--language <s>").option("-f, --format <format>").action(async e=>{try{let t={};if(e.firstName&&(t.firstName=e.firstName),e.lastName&&(t.lastName=e.lastName),e.name&&(t.name=e.name),e.username&&(t.username=e.username),e.phone&&(t.phoneNumber=e.phone),e.timezone&&(t.timezone=e.timezone),e.language&&(t.language=e.language),!Object.keys(t).length)throw new k("No updates specified");let r=await l(Q,{input:t});g("Profile updated"),m(e,r.updateCurrentUserProfile);}catch(t){u(t);}});let o=n.command("security").description("Account security overview");o.command("audit-log").description("Recent auth audit events for the current user").option("--limit <n>","Page size",e=>parseInt(e,10),50).option("-f, --format <format>").action(async e=>{try{let t=await l(z,{pagination:{limit:e.limit,offset:0}});m(e,t.authAuditLogs.auditLogs,{headers:["When","Action","Resource","IP"],rows:t.authAuditLogs.auditLogs.map(r=>[T(r.createdAt),r.action,r.resource??"-",r.ipAddress??"-"])});}catch(t){u(t);}}),o.command("sessions").description("Active sessions for the current user").option("--limit <n>","Page size",e=>parseInt(e,10),50).option("-f, --format <format>").action(async e=>{try{let t=await l(X,{pagination:{limit:e.limit,offset:0}});m(e,t.activeSessions.sessions,{headers:["ID","Status","IP","LastActivity","Current"],rows:t.activeSessions.sessions.map(r=>[$(r.id,12),q(r.status),r.ipAddress??"-",T(r.lastActivityAt),String(!!r.isCurrent)])});}catch(t){u(t);}});let i=n.command("mfa").description("Multi-factor authentication");i.command("list").description("List MFA methods enrolled for the current user").option("--limit <n>","Page size",e=>parseInt(e,10),50).option("-f, --format <format>").action(async e=>{try{let t=await l(Z,{pagination:{limit:e.limit,offset:0}});m(e,t.currentUserMFAMethods.methods,{headers:["Method","Status","Created"],rows:t.currentUserMFAMethods.methods.map(r=>[r.method,q(r.status),T(r.createdAt)])});}catch(t){u(t);}}),i.command("enroll").description("Begin MFA enrollment (TOTP/SMS/EMAIL)").requiredOption("--method <m>","TOTP|SMS|EMAIL").option("-f, --format <format>").action(async e=>{try{let t=await l(ee,{method:e.method.toUpperCase()});e.format?m(e,t.setupMFA):(g("MFA enrollment started"),L(t.setupMFA),C("Save your backup codes; verify with `auth mfa verify --code <CODE>`."));}catch(t){u(t);}}),i.command("verify").description("Verify MFA enrollment code").requiredOption("--code <code>").action(async e=>{try{await l(te,{code:e.code}),g("MFA enabled");}catch(t){u(t);}}),i.command("disable").description("Disable MFA for the current user").action(async()=>{try{await l(ne),g("MFA disabled");}catch(e){u(e);}});let a=n.command("api-keys").description("API key management");a.command("list").description("List your API keys").option("--app <id>","Restrict to keys for an app id").option("--limit <n>","Page size",e=>parseInt(e,10),50).option("-f, --format <format>").action(async e=>{try{let t=e.app?oe:re,r=e.app?{appId:e.app,pagination:{limit:e.limit,offset:0}}:{pagination:{limit:e.limit,offset:0}},f=await l(t,r),I=(f.myApiKeys??f.appApiKeys)?.apiKeys??[];m(e,I,{headers:["ID","Name","Prefix","App","Scopes","LastUsed"],rows:I.map(w=>[$(w.id,12),w.name??"-",w.prefix??"-",w.appName??"-",Array.isArray(w.scopes)?w.scopes.join(","):"-",T(w.lastUsedAt)])});}catch(t){u(t);}}),a.command("create").description("Generate a new API key").requiredOption("--name <name>").requiredOption("--app <appId>","Owning app id").option("--scope <scope>","Comma-separated scopes").option("--expires <iso>","ISO expiry").option("-f, --format <format>").action(async e=>{try{let t={name:e.name,appId:e.app,scope:e.scope?e.scope.split(","):void 0,expiresAt:e.expires},r=await l(ie,{input:t});g("API key generated. Store the secret \u2014 it is only shown once."),L(r.generateAPIKey);}catch(t){u(t);}}),a.command("revoke").description("Revoke an API key").argument("<keyId>").action(async e=>{try{await l(se,{keyId:e}),g("API key revoked");}catch(t){u(t);}}),a.command("rotate").description("Rotate an API key (returns new secret)").argument("<keyId>").action(async e=>{try{let t=await l(ae,{keyId:e});g("API key rotated"),L(t.rotateAPIKey);}catch(t){u(t);}}),n.command("audit-log").description("Auth audit log").option("--limit <n>","Page size",e=>parseInt(e,10),50).option("-f, --format <format>").action(async e=>{try{let t=await l(z,{pagination:{limit:e.limit,offset:0}});m(e,t.authAuditLogs.auditLogs);}catch(t){u(t);}});let c=n.command("delegations").description("Delegation management");c.command("list").description("Delegations granted to the current user").option("--limit <n>","Page size",e=>parseInt(e,10),50).option("-f, --format <format>").action(async e=>{try{let t=await l(ce,{pagination:{limit:e.limit,offset:0}});m(e,t.currentUserDelegations.delegations);}catch(t){u(t);}}),c.command("grant").description("Grant a delegation to an app").requiredOption("--app <appId>").requiredOption("--user <userId>","User to delegate as").option("--scope <s>","Comma-separated scopes").option("--workspace <ids>","Comma-separated workspace ids").option("--expires <iso>").option("-f, --format <format>").action(async e=>{try{let t={appId:e.app,userId:e.user,scopes:e.scope?e.scope.split(","):void 0,workspaceIds:e.workspace?e.workspace.split(","):void 0,expiresAt:e.expires},r=await l(pe,{input:t});g("Delegation granted"),m(e,r.grantDelegation);}catch(t){u(t);}}),c.command("revoke").description("Revoke a delegation").argument("<id>").option("--reason <text>").action(async(e,t)=>{try{await l(ue,{id:e,reason:t.reason}),g("Delegation revoked");}catch(r){u(r);}});let p=n.command("apps").description("OAuth/system app management");p.command("list").description("Apps owned by the current user").option("--limit <n>","Page size",e=>parseInt(e,10),50).option("-f, --format <format>").action(async e=>{try{let t=await l(de,{pagination:{limit:e.limit,offset:0}});m(e,t.currentUserApps.apps,{headers:["ID","ClientID","Name","Type","Status"],rows:t.currentUserApps.apps.map(r=>[$(r.id,12),$(r.clientId,24),r.name??"-",r.type??"-",q(r.status)])});}catch(t){u(t);}}),p.command("get").description("Get an app by id").argument("<id>").option("-f, --format <format>").action(async(e,t)=>{try{let r=await l(le,{id:e});if(!r.app)throw new k(`App ${e} not found`);m(t,r.app);}catch(r){u(r);}}),p.command("create").description("Create an OAuth app").requiredOption("--name <s>").option("--description <s>").option("--type <t>","OAUTH|SYSTEM","OAUTH").option("--actor-type <t>","USER|APP|SERVICE","APP").option("--redirect <urls>","Comma-separated redirect URIs").option("--scopes <s>","Comma-separated scopes").option("-f, --format <format>").action(async e=>{try{let t={name:e.name,description:e.description,type:(e.type??"OAUTH").toUpperCase(),actorType:(e.actorType??"APP").toUpperCase(),redirectUris:e.redirect?e.redirect.split(","):void 0,scopes:e.scopes?e.scopes.split(","):void 0},r=await l(ge,{input:t});g("App created. Client secret only shown once."),L(r.createApp);}catch(t){u(t);}}),p.command("update").description("Update an app").argument("<id>").option("--name <s>").option("--description <s>").option("--redirect <urls>","Comma-separated redirect URIs").option("--scopes <s>","Comma-separated scopes").option("--status <s>").option("-f, --format <format>").action(async(e,t)=>{try{let r={};if(t.name&&(r.name=t.name),t.description!==void 0&&(r.description=t.description),t.redirect&&(r.redirectUris=t.redirect.split(",")),t.scopes&&(r.scopes=t.scopes.split(",")),t.status&&(r.status=t.status.toUpperCase()),!Object.keys(r).length)throw new k("No updates specified");let f=await l(fe,{id:e,input:r});g("App updated"),m(t,f.updateApp);}catch(r){u(r);}}),p.command("deactivate").description("Deactivate an app").argument("<id>").action(async e=>{try{await l(me,{id:e}),g("App deactivated");}catch(t){u(t);}});let d=n.command("sso").description("SSO (SAML/OIDC) configuration");d.command("get").description("Get SSO config for a tenant").requiredOption("--tenant <id>").option("-f, --format <format>").action(async e=>{try{let t=await l(he,{tenantId:e.tenant});m(e,t.getSSOConfig);}catch(t){u(t);}}),d.command("save").description("Save (upsert) SSO config for a tenant").requiredOption("--tenant <id>").requiredOption("--entity <s>","EntityID / Issuer").requiredOption("--sso-url <url>").option("--slo-url <url>").option("--certificate <pem>","X.509 certificate PEM").option("--enabled","Enable after save",false).option("-f, --format <format>").action(async e=>{try{let t={entityId:e.entity,ssoUrl:e.ssoUrl,sloUrl:e.sloUrl,certificate:e.certificate,enabled:!!e.enabled},r=await l(ke,{tenantId:e.tenant,input:t});g("SSO config saved"),m(e,r.saveSSOConfig);}catch(t){u(t);}}),d.command("delete").description("Delete SSO config for a tenant").requiredOption("--tenant <id>").action(async e=>{try{await l(we,{tenantId:e.tenant}),g("SSO config deleted");}catch(t){u(t);}});let h=n.command("users").description("User admin (requires admin permissions)");h.command("list").description("List users (admin)").option("--email <s>").option("--username <s>").option("--role <s>").option("--status <s>").option("--search <s>").option("--limit <n>","Page size",e=>parseInt(e,10),50).option("-f, --format <format>").action(async e=>{try{let t={};e.email&&(t.email=e.email),e.username&&(t.username=e.username),e.role&&(t.role=e.role.toUpperCase()),e.status&&(t.status=e.status.toUpperCase()),e.search&&(t.search=e.search);let r=await l(ye,{filter:Object.keys(t).length?t:void 0,pagination:{limit:e.limit,offset:0}});m(e,r.users.users,{headers:["ID","Email","Username","Role","Status","Created"],rows:r.users.users.map(f=>[$(f.id,12),f.email,f.username??"-",f.role??"-",q(f.status),T(f.createdAt)])});}catch(t){u(t);}}),h.command("get").description("Get user by id (admin)").argument("<id>").option("-f, --format <format>").action(async(e,t)=>{try{let r=await l(Ae,{id:e});if(!r.user)throw new k(`User ${e} not found`);m(t,r.user);}catch(r){u(r);}}),h.command("update").description("Update a user (admin)").argument("<id>").option("--first-name <s>").option("--last-name <s>").option("--username <s>").option("--phone <s>").option("--role <s>").option("--status <s>").option("--email-verified <bool>").option("-f, --format <format>").action(async(e,t)=>{try{let r={};if(t.firstName&&(r.firstName=t.firstName),t.lastName&&(r.lastName=t.lastName),t.username&&(r.username=t.username),t.phone&&(r.phoneNumber=t.phone),t.role&&(r.role=t.role.toUpperCase()),t.status&&(r.status=t.status.toUpperCase()),t.emailVerified!==void 0&&(r.emailVerified=t.emailVerified==="true"),!Object.keys(r).length)throw new k("No updates specified");let f=await l(Ie,{id:e,input:r});g("User updated"),m(t,f.updateUser);}catch(r){u(r);}});}var Fe={id:"auth",version:"1.0.0",displayName:"Authentication",register(n,s){V(s),be(n);let o=n.commands.find(i=>i.name()==="auth");if(!o)throw new x("auth command group missing after registerAuthCommands");ve(o);}},ln=Fe;module.exports=ln;
204
+ Select workspace [1-${n.length}]: `),a=i===null?-1:parseInt(i.trim(),10)-1;return {workspace:(a>=0&&a<n.length?n[a]:void 0)??o,prompted:true}}async function Te(n){let o=(await import('readline')).createInterface({input:process.stdin,output:process.stdout});return new Promise(i=>{let a=false;o.on("close",()=>{a||i(null);}),o.question(n,c=>{a=true,o.close(),i(c);});})}function be(n){let s=n.command("auth").description("Authentication commands");s.command("login").description(`Authenticate with ${O().productName}`).option("--client-credentials","Authenticate as an app with client ID and secret").option("--workspace-id <id>","Workspace to bind the session to").action(async o=>{try{o.clientCredentials?await Me(o.workspaceId):await Le(o.workspaceId);}catch(i){u(i);}}),s.command("logout").description("Revoke tokens and clear stored auth").action(async()=>{try{if(D()?.accessToken)try{await K(Ce);}catch{v("Server-side logout failed, clearing local tokens");}B(),E(),g("Logged out successfully");}catch(o){u(o);}}),s.command("status").description("Show current auth state").option("-f, --format <format>","Output format (json, table)").action(o=>{let i=D(),a=U(),c=!!i?.accessToken,p=i?.accessToken?Y(i):false,d=i?.expiresAt?T(new Date(i.expiresAt).toISOString()):"-",h=i?.authMethod==="client_credentials"?"Client Credentials":"OAuth2 Device Code",e=i?.workspaceTokenExpiresAt?T(new Date(i.workspaceTokenExpiresAt).toISOString()):"-";m(o,{authenticated:c,method:h,expired:p,expiresAt:d,workspaceId:i?.workspaceId??"-",organizationId:i?.organizationId??"-",workspaceTokenExpiresAt:e,workspaceEndpoint:a.workspaceEndpoint,globalEndpoint:a.globalEndpoint},{headers:["Key","Value"],rows:[["Authenticated",String(c)],["Method",h],["Expired",String(p)],["Expires At",d],["Workspace ID",i?.workspaceId??"-"],["Organization ID",i?.organizationId??"-"],["Workspace Token Expires",e],["Workspace Endpoint",a.workspaceEndpoint],["Global Endpoint",a.globalEndpoint]]});}),s.command("token").description("Print access token to stdout").option("--workspace","Print workspace token instead").action(o=>{let i=D();if(o.workspace){if(!i?.workspaceToken)throw new k(`No workspace token. Set a workspace: ${O().productName} workspace set <id>`);process.stdout.write(i.workspaceToken);return}if(!i?.accessToken)throw new k(`Not authenticated. Run: ${O().productName} auth login`);process.stdout.write(i.accessToken);}),s.command("refresh").description("Force token refresh").action(async()=>{try{let o=D();if(!o?.refreshToken&&o?.authMethod!=="client_credentials")throw new k(`No refresh token available. Run: ${O().productName} auth login`);if(o?.authMethod==="client_credentials"&&o.clientId&&o.clientSecret){let c=U(),p=await P(c.globalEndpoint,o.clientId,o.clientSecret);S({...o,accessToken:p.accessToken,expiresAt:Date.now()+p.expiresIn*1e3}),E(),g("App token refreshed successfully"),o.workspaceId&&o.organizationId&&await Se();return}let a=(await K(xe,{token:o.refreshToken})).refreshToken;S({...o,accessToken:a.accessToken,refreshToken:a.refreshToken,expiresAt:Date.now()+a.expiresIn*1e3}),E(),g("Token refreshed successfully"),o.workspaceId&&o.organizationId&&await Se();}catch(o){u(o);}});}async function Se(){let n=D();if(!n?.accessToken||!n.workspaceId||!n.organizationId)return;let s=U();try{let o=await b(s.workspaceEndpoint,n.accessToken,n.workspaceId,n.organizationId);S({...n,workspaceToken:o.token,workspaceTokenExpiresAt:new Date(o.expiresAt).getTime()}),E(),g("Workspace token refreshed");}catch{v("Workspace token refresh failed \u2014 workspace operations may require re-login");}}async function Le(n){let s=U(),{oidcIssuer:o,clientId:i}=H(),a={...s,oidcIssuer:o,clientId:i};C("Starting device code authentication...");let c=await M(a);console.log(""),console.log(` Open: ${c.verificationUri}`),console.log(` Code: ${c.userCode}`),console.log(""),await G(c.verificationUriComplete??c.verificationUri)?C("Browser opened"):v("Could not open browser \u2014 open the URL manually"),C("Waiting for authorization...");let d=await F(c.deviceCode,c.interval,a),h=d.accessToken,e=Date.now()+d.expiresIn*1e3;S({accessToken:h,refreshToken:d.refreshToken,expiresAt:e,authMethod:"device_code"}),E(),C("Fetching workspaces...");try{let t=await N(s.globalEndpoint,h);if(t.length===0){g("Authentication successful (no workspaces found)");return}let r=!!process.stdin.isTTY;t.length>1&&r&&!n&&(console.log(`
205
+ Available workspaces:`),t.forEach((w,R)=>console.log(` ${R+1}. ${w.name} (${w.slug})`)));let{workspace:f}=await Ee(t,{preferredId:n,interactive:r,ask:Te});t.length>1&&!r&&!n&&C(`${t.length} workspaces available; pass --workspace-id or run \`${O().productName} workspace set <id>\` to switch`),C(`Using workspace: ${f.name} (${f.id})`);let I=await b(s.workspaceEndpoint,h,f.id,f.organizationId);S({accessToken:h,refreshToken:d.refreshToken,expiresAt:e,workspaceToken:I.token,workspaceTokenExpiresAt:new Date(I.expiresAt).getTime(),workspaceId:f.id,organizationId:f.organizationId,authMethod:"device_code"}),E(),g("Authentication successful");}catch(t){S({accessToken:h,refreshToken:d.refreshToken,expiresAt:e,authMethod:"device_code"}),E(),g("Authentication successful"),v(`Workspace token not obtained: ${t instanceof Error?t.message:String(t)}`),C(`Set workspace manually: ${O().productName} workspace set <id>`);}}async function Me(n){let s=U(),i=(await import('readline')).createInterface({input:process.stdin,output:process.stdout}),a=await new Promise(I=>{i.question("Client ID: ",w=>I(w.trim()));}),c=await new Promise(I=>{i.question("Client Secret: ",w=>{i.close(),I(w.trim());});});if(!a||!c)throw new k("Client ID and secret cannot be empty");C("Authenticating app...");let p=await P(s.globalEndpoint,a,c),d=p.accessToken,h=Date.now()+p.expiresIn*1e3,e,t,r=n,f;if(r)try{let w=(await N(s.globalEndpoint,d)).find(R=>R.id===r);if(w){f=w.organizationId;let R=await b(s.workspaceEndpoint,d,r,f);e=R.token,t=new Date(R.expiresAt).getTime(),C(`Workspace token issued for: ${w.name}`);}else v(`Workspace ${r} not found \u2014 skipping workspace token`),r=void 0;}catch(I){v(`Workspace token failed: ${I instanceof Error?I.message:String(I)}`);}S({accessToken:d,refreshToken:"",expiresAt:h,workspaceToken:e,workspaceTokenExpiresAt:t,workspaceId:r,organizationId:f,authMethod:"client_credentials",clientId:a,clientSecret:c}),E(),g("App authentication successful");}function ve(n){let s=n.command("profile").description("Current user profile");s.command("show").description("Show current user").option("-f, --format <format>").action(async e=>{try{let t=await l(J);m(e,t.currentUser);}catch(t){u(t);}}),s.command("update").description("Update current user profile").option("--first-name <s>").option("--last-name <s>").option("--name <s>").option("--username <s>").option("--phone <s>").option("--timezone <s>").option("--language <s>").option("-f, --format <format>").action(async e=>{try{let t={};if(e.firstName&&(t.firstName=e.firstName),e.lastName&&(t.lastName=e.lastName),e.name&&(t.name=e.name),e.username&&(t.username=e.username),e.phone&&(t.phoneNumber=e.phone),e.timezone&&(t.timezone=e.timezone),e.language&&(t.language=e.language),!Object.keys(t).length)throw new k("No updates specified");let r=await l(Q,{input:t});g("Profile updated"),m(e,r.updateCurrentUserProfile);}catch(t){u(t);}});let o=n.command("security").description("Account security overview");o.command("audit-log").description("Recent auth audit events for the current user").option("--limit <n>","Page size",e=>parseInt(e,10),50).option("-f, --format <format>").action(async e=>{try{let t=await l(j,{pagination:{limit:e.limit,offset:0}});m(e,t.authAuditLogs.auditLogs,{headers:["When","Action","Resource","IP"],rows:t.authAuditLogs.auditLogs.map(r=>[T(r.createdAt),r.action,r.resource??"-",r.ipAddress??"-"])});}catch(t){u(t);}}),o.command("sessions").description("Active sessions for the current user").option("--limit <n>","Page size",e=>parseInt(e,10),50).option("-f, --format <format>").action(async e=>{try{let t=await l(X,{pagination:{limit:e.limit,offset:0}});m(e,t.activeSessions.sessions,{headers:["ID","Status","IP","LastActivity","Current"],rows:t.activeSessions.sessions.map(r=>[$(r.id,12),L(r.status),r.ipAddress??"-",T(r.lastActivityAt),String(!!r.isCurrent)])});}catch(t){u(t);}});let i=n.command("mfa").description("Multi-factor authentication");i.command("list").description("List MFA methods enrolled for the current user").option("--limit <n>","Page size",e=>parseInt(e,10),50).option("-f, --format <format>").action(async e=>{try{let t=await l(Z,{pagination:{limit:e.limit,offset:0}});m(e,t.currentUserMFAMethods.methods,{headers:["Method","Status","Created"],rows:t.currentUserMFAMethods.methods.map(r=>[r.method,L(r.status),T(r.createdAt)])});}catch(t){u(t);}}),i.command("enroll").description("Begin MFA enrollment (TOTP/SMS/EMAIL)").requiredOption("--method <m>","TOTP|SMS|EMAIL").option("-f, --format <format>").action(async e=>{try{let t=await l(ee,{method:e.method.toUpperCase()});e.format?m(e,t.setupMFA):(g("MFA enrollment started"),q(t.setupMFA),C("Save your backup codes; verify with `auth mfa verify --code <CODE>`."));}catch(t){u(t);}}),i.command("verify").description("Verify MFA enrollment code").requiredOption("--code <code>").action(async e=>{try{await l(te,{code:e.code}),g("MFA enabled");}catch(t){u(t);}}),i.command("disable").description("Disable MFA for the current user").action(async()=>{try{await l(ne),g("MFA disabled");}catch(e){u(e);}});let a=n.command("api-keys").description("API key management");a.command("list").description("List your API keys").option("--app <id>","Restrict to keys for an app id").option("--limit <n>","Page size",e=>parseInt(e,10),50).option("-f, --format <format>").action(async e=>{try{let t=e.app?oe:re,r=e.app?{appId:e.app,pagination:{limit:e.limit,offset:0}}:{pagination:{limit:e.limit,offset:0}},f=await l(t,r),I=(f.myApiKeys??f.appApiKeys)?.apiKeys??[];m(e,I,{headers:["ID","Name","Prefix","App","Scopes","LastUsed"],rows:I.map(w=>[$(w.id,12),w.name??"-",w.prefix??"-",w.appName??"-",Array.isArray(w.scopes)?w.scopes.join(","):"-",T(w.lastUsedAt)])});}catch(t){u(t);}}),a.command("create").description("Generate a new API key").requiredOption("--name <name>").requiredOption("--app <appId>","Owning app id").option("--scope <scope>","Comma-separated scopes").option("--expires <iso>","ISO expiry").option("-f, --format <format>").action(async e=>{try{let t={name:e.name,appId:e.app,scope:e.scope?e.scope.split(","):void 0,expiresAt:e.expires},r=await l(ie,{input:t});g("API key generated. Store the secret \u2014 it is only shown once."),q(r.generateAPIKey);}catch(t){u(t);}}),a.command("revoke").description("Revoke an API key").argument("<keyId>").action(async e=>{try{await l(se,{keyId:e}),g("API key revoked");}catch(t){u(t);}}),a.command("rotate").description("Rotate an API key (returns new secret)").argument("<keyId>").action(async e=>{try{let t=await l(ae,{keyId:e});g("API key rotated"),q(t.rotateAPIKey);}catch(t){u(t);}}),n.command("audit-log").description("Auth audit log").option("--limit <n>","Page size",e=>parseInt(e,10),50).option("-f, --format <format>").action(async e=>{try{let t=await l(j,{pagination:{limit:e.limit,offset:0}});m(e,t.authAuditLogs.auditLogs);}catch(t){u(t);}});let c=n.command("delegations").description("Delegation management");c.command("list").description("Delegations granted to the current user").option("--limit <n>","Page size",e=>parseInt(e,10),50).option("-f, --format <format>").action(async e=>{try{let t=await l(ce,{pagination:{limit:e.limit,offset:0}});m(e,t.currentUserDelegations.delegations);}catch(t){u(t);}}),c.command("grant").description("Grant a delegation to an app").requiredOption("--app <appId>").requiredOption("--user <userId>","User to delegate as").option("--scope <s>","Comma-separated scopes").option("--workspace <ids>","Comma-separated workspace ids").option("--expires <iso>").option("-f, --format <format>").action(async e=>{try{let t={appId:e.app,userId:e.user,scopes:e.scope?e.scope.split(","):void 0,workspaceIds:e.workspace?e.workspace.split(","):void 0,expiresAt:e.expires},r=await l(pe,{input:t});g("Delegation granted"),m(e,r.grantDelegation);}catch(t){u(t);}}),c.command("revoke").description("Revoke a delegation").argument("<id>").option("--reason <text>").action(async(e,t)=>{try{await l(ue,{id:e,reason:t.reason}),g("Delegation revoked");}catch(r){u(r);}});let p=n.command("apps").description("OAuth/system app management");p.command("list").description("Apps owned by the current user").option("--limit <n>","Page size",e=>parseInt(e,10),50).option("-f, --format <format>").action(async e=>{try{let t=await l(de,{pagination:{limit:e.limit,offset:0}});m(e,t.currentUserApps.apps,{headers:["ID","ClientID","Name","Type","Status"],rows:t.currentUserApps.apps.map(r=>[$(r.id,12),$(r.clientId,24),r.name??"-",r.type??"-",L(r.status)])});}catch(t){u(t);}}),p.command("get").description("Get an app by id").argument("<id>").option("-f, --format <format>").action(async(e,t)=>{try{let r=await l(le,{id:e});if(!r.app)throw new k(`App ${e} not found`);m(t,r.app);}catch(r){u(r);}}),p.command("create").description("Create an OAuth app").requiredOption("--name <s>").option("--description <s>").option("--type <t>","OAUTH|SYSTEM","OAUTH").option("--actor-type <t>","USER|APP|SERVICE","APP").option("--redirect <urls>","Comma-separated redirect URIs").option("--scopes <s>","Comma-separated scopes").option("-f, --format <format>").action(async e=>{try{let t={name:e.name,description:e.description,type:(e.type??"OAUTH").toUpperCase(),actorType:(e.actorType??"APP").toUpperCase(),redirectUris:e.redirect?e.redirect.split(","):void 0,scopes:e.scopes?e.scopes.split(","):void 0},r=await l(ge,{input:t});g("App created. Client secret only shown once."),q(r.createApp);}catch(t){u(t);}}),p.command("update").description("Update an app").argument("<id>").option("--name <s>").option("--description <s>").option("--redirect <urls>","Comma-separated redirect URIs").option("--scopes <s>","Comma-separated scopes").option("--status <s>").option("-f, --format <format>").action(async(e,t)=>{try{let r={};if(t.name&&(r.name=t.name),t.description!==void 0&&(r.description=t.description),t.redirect&&(r.redirectUris=t.redirect.split(",")),t.scopes&&(r.scopes=t.scopes.split(",")),t.status&&(r.status=t.status.toUpperCase()),!Object.keys(r).length)throw new k("No updates specified");let f=await l(fe,{id:e,input:r});g("App updated"),m(t,f.updateApp);}catch(r){u(r);}}),p.command("deactivate").description("Deactivate an app").argument("<id>").action(async e=>{try{await l(me,{id:e}),g("App deactivated");}catch(t){u(t);}});let d=n.command("sso").description("SSO (SAML/OIDC) configuration");d.command("get").description("Get SSO config for a tenant").requiredOption("--tenant <id>").option("-f, --format <format>").action(async e=>{try{let t=await l(he,{tenantId:e.tenant});m(e,t.getSSOConfig);}catch(t){u(t);}}),d.command("save").description("Save (upsert) SSO config for a tenant").requiredOption("--tenant <id>").requiredOption("--entity <s>","EntityID / Issuer").requiredOption("--sso-url <url>").option("--slo-url <url>").option("--certificate <pem>","X.509 certificate PEM").option("--enabled","Enable after save",false).option("-f, --format <format>").action(async e=>{try{let t={entityId:e.entity,ssoUrl:e.ssoUrl,sloUrl:e.sloUrl,certificate:e.certificate,enabled:!!e.enabled},r=await l(ke,{tenantId:e.tenant,input:t});g("SSO config saved"),m(e,r.saveSSOConfig);}catch(t){u(t);}}),d.command("delete").description("Delete SSO config for a tenant").requiredOption("--tenant <id>").action(async e=>{try{await l(we,{tenantId:e.tenant}),g("SSO config deleted");}catch(t){u(t);}});let h=n.command("users").description("User admin (requires admin permissions)");h.command("list").description("List users (admin)").option("--email <s>").option("--username <s>").option("--role <s>").option("--status <s>").option("--search <s>").option("--limit <n>","Page size",e=>parseInt(e,10),50).option("-f, --format <format>").action(async e=>{try{let t={};e.email&&(t.email=e.email),e.username&&(t.username=e.username),e.role&&(t.role=e.role.toUpperCase()),e.status&&(t.status=e.status.toUpperCase()),e.search&&(t.search=e.search);let r=await l(ye,{filter:Object.keys(t).length?t:void 0,pagination:{limit:e.limit,offset:0}});m(e,r.users.users,{headers:["ID","Email","Username","Role","Status","Created"],rows:r.users.users.map(f=>[$(f.id,12),f.email,f.username??"-",f.role??"-",L(f.status),T(f.createdAt)])});}catch(t){u(t);}}),h.command("get").description("Get user by id (admin)").argument("<id>").option("-f, --format <format>").action(async(e,t)=>{try{let r=await l(Ae,{id:e});if(!r.user)throw new k(`User ${e} not found`);m(t,r.user);}catch(r){u(r);}}),h.command("update").description("Update a user (admin)").argument("<id>").option("--first-name <s>").option("--last-name <s>").option("--username <s>").option("--phone <s>").option("--role <s>").option("--status <s>").option("--email-verified <bool>").option("-f, --format <format>").action(async(e,t)=>{try{let r={};if(t.firstName&&(r.firstName=t.firstName),t.lastName&&(r.lastName=t.lastName),t.username&&(r.username=t.username),t.phone&&(r.phoneNumber=t.phone),t.role&&(r.role=t.role.toUpperCase()),t.status&&(r.status=t.status.toUpperCase()),t.emailVerified!==void 0&&(r.emailVerified=t.emailVerified==="true"),!Object.keys(r).length)throw new k("No updates specified");let f=await l(Ie,{id:e,input:r});g("User updated"),m(t,f.updateUser);}catch(r){u(r);}});}var Fe={id:"auth",version:"1.0.0",displayName:"Authentication",register(n,s){V(s),be(n);let o=n.commands.find(i=>i.name()==="auth");if(!o)throw new x("auth command group missing after registerAuthCommands");ve(o);}},fn=Fe;module.exports=fn;
@@ -1,4 +1,4 @@
1
- import { C as CliModule } from '../../module-BwJmqefL.cjs';
1
+ import { C as CliModule } from '../../module-CLaW1ycq.cjs';
2
2
  import 'commander';
3
3
  import 'graphql-request';
4
4
 
@@ -1,4 +1,4 @@
1
- import { C as CliModule } from '../../module-BwJmqefL.js';
1
+ import { C as CliModule } from '../../module-CLaW1ycq.js';
2
2
  import 'commander';
3
3
  import 'graphql-request';
4
4
 
@@ -1,4 +1,4 @@
1
- import {a,u,h,v,e,n,x,f,k,y,E,q as q$1,i,w,c,r,p,o as o$1,m,D}from'../../chunk-VL67DTWH.js';import {q,o,f as f$1,h as h$1,g,d,i as i$1,e as e$1}from'../../chunk-2OISIPE6.js';var B=`
1
+ import {a,u,h,v,e,n,x,f,k,y,E,q,i,w,c,r,p,o,m,D}from'../../chunk-WTNQ5PEC.js';import {s,q as q$1,f as f$1,h as h$1,g,d,i as i$1,e as e$1}from'../../chunk-MT2F54AC.js';var B=`
2
2
  query currentUser {
3
3
  currentUser {
4
4
  id email firstName lastName username phoneNumber name
@@ -181,6 +181,6 @@ import {a,u,h,v,e,n,x,f,k,y,E,q as q$1,i,w,c,r,p,o as o$1,m,D}from'../../chunk-V
181
181
  mutation RefreshToken($token: String!) {
182
182
  refreshToken(token: $token) { accessToken refreshToken expiresIn }
183
183
  }
184
- `;async function ye(s,p){if(s.length===0)throw new o("No workspaces to choose from");if(p.preferredId){let g=s.find(f=>f.id===p.preferredId);if(!g)throw new o(`Workspace ${p.preferredId} is not one of your workspaces`);return {workspace:g,prompted:false}}let[i]=s;if(s.length===1||!p.interactive)return {workspace:i,prompted:false};let o$1=await p.ask(`
185
- Select workspace [1-${s.length}]: `),c=o$1===null?-1:parseInt(o$1.trim(),10)-1;return {workspace:(c>=0&&c<s.length?s[c]:void 0)??i,prompted:true}}async function Ee(s){let i=(await import('readline')).createInterface({input:process.stdin,output:process.stdout});return new Promise(o=>{let c=false;i.on("close",()=>{c||o(null);}),i.question(s,u=>{c=true,i.close(),o(u);});})}function Te(s){let p=s.command("auth").description("Authentication commands");p.command("login").description(`Authenticate with ${u().productName}`).option("--client-credentials","Authenticate as an app with client ID and secret").option("--workspace-id <id>","Workspace to bind the session to").action(async i=>{try{i.clientCredentials?await Re(i.workspaceId):await Pe(i.workspaceId);}catch(o){h(o);}}),p.command("logout").description("Revoke tokens and clear stored auth").action(async()=>{try{if(v()?.accessToken)try{await e(Ie);}catch{n("Server-side logout failed, clearing local tokens");}x(),f(),k("Logged out successfully");}catch(i){h(i);}}),p.command("status").description("Show current auth state").option("-f, --format <format>","Output format (json, table)").action(i$1=>{let o=v(),c=y(),u=!!o?.accessToken,g=o?.accessToken?E(o):false,f=o?.expiresAt?q$1(new Date(o.expiresAt).toISOString()):"-",h=o?.authMethod==="client_credentials"?"Client Credentials":"OAuth2 Device Code",e=o?.workspaceTokenExpiresAt?q$1(new Date(o.workspaceTokenExpiresAt).toISOString()):"-";i(i$1,{authenticated:u,method:h,expired:g,expiresAt:f,workspaceId:o?.workspaceId??"-",organizationId:o?.organizationId??"-",workspaceTokenExpiresAt:e,workspaceEndpoint:c.workspaceEndpoint,globalEndpoint:c.globalEndpoint},{headers:["Key","Value"],rows:[["Authenticated",String(u)],["Method",h],["Expired",String(g)],["Expires At",f],["Workspace ID",o?.workspaceId??"-"],["Organization ID",o?.organizationId??"-"],["Workspace Token Expires",e],["Workspace Endpoint",c.workspaceEndpoint],["Global Endpoint",c.globalEndpoint]]});}),p.command("token").description("Print access token to stdout").option("--workspace","Print workspace token instead").action(i=>{let o$1=v();if(i.workspace){if(!o$1?.workspaceToken)throw new o(`No workspace token. Set a workspace: ${u().productName} workspace set <id>`);process.stdout.write(o$1.workspaceToken);return}if(!o$1?.accessToken)throw new o(`Not authenticated. Run: ${u().productName} auth login`);process.stdout.write(o$1.accessToken);}),p.command("refresh").description("Force token refresh").action(async()=>{try{let i=v();if(!i?.refreshToken&&i?.authMethod!=="client_credentials")throw new o(`No refresh token available. Run: ${u().productName} auth login`);if(i?.authMethod==="client_credentials"&&i.clientId&&i.clientSecret){let u=y(),g=await f$1(u.globalEndpoint,i.clientId,i.clientSecret);w({...i,accessToken:g.accessToken,expiresAt:Date.now()+g.expiresIn*1e3}),f(),k("App token refreshed successfully"),i.workspaceId&&i.organizationId&&await Se();return}let c=(await e(we,{token:i.refreshToken})).refreshToken;w({...i,accessToken:c.accessToken,refreshToken:c.refreshToken,expiresAt:Date.now()+c.expiresIn*1e3}),f(),k("Token refreshed successfully"),i.workspaceId&&i.organizationId&&await Se();}catch(i){h(i);}});}async function Se(){let s=v();if(!s?.accessToken||!s.workspaceId||!s.organizationId)return;let p=y();try{let i=await g(p.workspaceEndpoint,s.accessToken,s.workspaceId,s.organizationId);w({...s,workspaceToken:i.token,workspaceTokenExpiresAt:new Date(i.expiresAt).getTime()}),f(),k("Workspace token refreshed");}catch{n("Workspace token refresh failed \u2014 workspace operations may require re-login");}}async function Pe(s){let p=y(),{oidcIssuer:i,clientId:o}=D(),c={...p,oidcIssuer:i,clientId:o};m("Starting device code authentication...");let u$1=await d(c);console.log(""),console.log(` Open: ${u$1.verificationUri}`),console.log(` Code: ${u$1.userCode}`),console.log(""),await i$1(u$1.verificationUriComplete??u$1.verificationUri)?m("Browser opened"):n("Could not open browser \u2014 open the URL manually"),m("Waiting for authorization...");let f$1=await e$1(u$1.deviceCode,u$1.interval,c),h=f$1.accessToken,e=Date.now()+f$1.expiresIn*1e3;w({accessToken:h,refreshToken:f$1.refreshToken,expiresAt:e,authMethod:"device_code"}),f(),m("Fetching workspaces...");try{let t=await h$1(p.globalEndpoint,h);if(t.length===0){k("Authentication successful (no workspaces found)");return}let n=!!process.stdin.isTTY;t.length>1&&n&&!s&&(console.log(`
186
- Available workspaces:`),t.forEach((A,C)=>console.log(` ${C+1}. ${A.name} (${A.slug})`)));let{workspace:m$1}=await ye(t,{preferredId:s,interactive:n,ask:Ee});t.length>1&&!n&&!s&&m(`${t.length} workspaces available; pass --workspace-id or run \`${u().productName} workspace set <id>\` to switch`),m(`Using workspace: ${m$1.name} (${m$1.id})`);let k$1=await g(p.workspaceEndpoint,h,m$1.id,m$1.organizationId);w({accessToken:h,refreshToken:f$1.refreshToken,expiresAt:e,workspaceToken:k$1.token,workspaceTokenExpiresAt:new Date(k$1.expiresAt).getTime(),workspaceId:m$1.id,organizationId:m$1.organizationId,authMethod:"device_code"}),f(),k("Authentication successful");}catch(t){w({accessToken:h,refreshToken:f$1.refreshToken,expiresAt:e,authMethod:"device_code"}),f(),k("Authentication successful"),n(`Workspace token not obtained: ${t instanceof Error?t.message:String(t)}`),m(`Set workspace manually: ${u().productName} workspace set <id>`);}}async function Re(s){let p=y(),o$1=(await import('readline')).createInterface({input:process.stdin,output:process.stdout}),c=await new Promise(k=>{o$1.question("Client ID: ",A=>k(A.trim()));}),u=await new Promise(k=>{o$1.question("Client Secret: ",A=>{o$1.close(),k(A.trim());});});if(!c||!u)throw new o("Client ID and secret cannot be empty");m("Authenticating app...");let g$1=await f$1(p.globalEndpoint,c,u),f$2=g$1.accessToken,h=Date.now()+g$1.expiresIn*1e3,e,t,n$1=s,m$1;if(n$1)try{let A=(await h$1(p.globalEndpoint,f$2)).find(C=>C.id===n$1);if(A){m$1=A.organizationId;let C=await g(p.workspaceEndpoint,f$2,n$1,m$1);e=C.token,t=new Date(C.expiresAt).getTime(),m(`Workspace token issued for: ${A.name}`);}else n(`Workspace ${n$1} not found \u2014 skipping workspace token`),n$1=void 0;}catch(k){n(`Workspace token failed: ${k instanceof Error?k.message:String(k)}`);}w({accessToken:f$2,refreshToken:"",expiresAt:h,workspaceToken:e,workspaceTokenExpiresAt:t,workspaceId:n$1,organizationId:m$1,authMethod:"client_credentials",clientId:c,clientSecret:u}),f(),k("App authentication successful");}function Ue(s){let p$1=s.command("profile").description("Current user profile");p$1.command("show").description("Show current user").option("-f, --format <format>").action(async e=>{try{let t=await c(B);i(e,t.currentUser);}catch(t){h(t);}}),p$1.command("update").description("Update current user profile").option("--first-name <s>").option("--last-name <s>").option("--name <s>").option("--username <s>").option("--phone <s>").option("--timezone <s>").option("--language <s>").option("-f, --format <format>").action(async e=>{try{let t={};if(e.firstName&&(t.firstName=e.firstName),e.lastName&&(t.lastName=e.lastName),e.name&&(t.name=e.name),e.username&&(t.username=e.username),e.phone&&(t.phoneNumber=e.phone),e.timezone&&(t.timezone=e.timezone),e.language&&(t.language=e.language),!Object.keys(t).length)throw new o("No updates specified");let n=await c(H,{input:t});k("Profile updated"),i(e,n.updateCurrentUserProfile);}catch(t){h(t);}});let i$1=s.command("security").description("Account security overview");i$1.command("audit-log").description("Recent auth audit events for the current user").option("--limit <n>","Page size",e=>parseInt(e,10),50).option("-f, --format <format>").action(async e=>{try{let t=await c(F,{pagination:{limit:e.limit,offset:0}});i(e,t.authAuditLogs.auditLogs,{headers:["When","Action","Resource","IP"],rows:t.authAuditLogs.auditLogs.map(n=>[q$1(n.createdAt),n.action,n.resource??"-",n.ipAddress??"-"])});}catch(t){h(t);}}),i$1.command("sessions").description("Active sessions for the current user").option("--limit <n>","Page size",e=>parseInt(e,10),50).option("-f, --format <format>").action(async e=>{try{let t=await c(j,{pagination:{limit:e.limit,offset:0}});i(e,t.activeSessions.sessions,{headers:["ID","Status","IP","LastActivity","Current"],rows:t.activeSessions.sessions.map(n=>[r(n.id,12),p(n.status),n.ipAddress??"-",q$1(n.lastActivityAt),String(!!n.isCurrent)])});}catch(t){h(t);}});let o$2=s.command("mfa").description("Multi-factor authentication");o$2.command("list").description("List MFA methods enrolled for the current user").option("--limit <n>","Page size",e=>parseInt(e,10),50).option("-f, --format <format>").action(async e=>{try{let t=await c(J,{pagination:{limit:e.limit,offset:0}});i(e,t.currentUserMFAMethods.methods,{headers:["Method","Status","Created"],rows:t.currentUserMFAMethods.methods.map(n=>[n.method,p(n.status),q$1(n.createdAt)])});}catch(t){h(t);}}),o$2.command("enroll").description("Begin MFA enrollment (TOTP/SMS/EMAIL)").requiredOption("--method <m>","TOTP|SMS|EMAIL").option("-f, --format <format>").action(async e=>{try{let t=await c(X,{method:e.method.toUpperCase()});e.format?i(e,t.setupMFA):(k("MFA enrollment started"),o$1(t.setupMFA),m("Save your backup codes; verify with `auth mfa verify --code <CODE>`."));}catch(t){h(t);}}),o$2.command("verify").description("Verify MFA enrollment code").requiredOption("--code <code>").action(async e=>{try{await c(Q,{code:e.code}),k("MFA enabled");}catch(t){h(t);}}),o$2.command("disable").description("Disable MFA for the current user").action(async()=>{try{await c(Z),k("MFA disabled");}catch(e){h(e);}});let c$1=s.command("api-keys").description("API key management");c$1.command("list").description("List your API keys").option("--app <id>","Restrict to keys for an app id").option("--limit <n>","Page size",e=>parseInt(e,10),50).option("-f, --format <format>").action(async e=>{try{let t=e.app?te:ee,n=e.app?{appId:e.app,pagination:{limit:e.limit,offset:0}}:{pagination:{limit:e.limit,offset:0}},m=await c(t,n),k=(m.myApiKeys??m.appApiKeys)?.apiKeys??[];i(e,k,{headers:["ID","Name","Prefix","App","Scopes","LastUsed"],rows:k.map(A=>[r(A.id,12),A.name??"-",A.prefix??"-",A.appName??"-",Array.isArray(A.scopes)?A.scopes.join(","):"-",q$1(A.lastUsedAt)])});}catch(t){h(t);}}),c$1.command("create").description("Generate a new API key").requiredOption("--name <name>").requiredOption("--app <appId>","Owning app id").option("--scope <scope>","Comma-separated scopes").option("--expires <iso>","ISO expiry").option("-f, --format <format>").action(async e=>{try{let t={name:e.name,appId:e.app,scope:e.scope?e.scope.split(","):void 0,expiresAt:e.expires},n=await c(ne,{input:t});k("API key generated. Store the secret \u2014 it is only shown once."),o$1(n.generateAPIKey);}catch(t){h(t);}}),c$1.command("revoke").description("Revoke an API key").argument("<keyId>").action(async e=>{try{await c(ie,{keyId:e}),k("API key revoked");}catch(t){h(t);}}),c$1.command("rotate").description("Rotate an API key (returns new secret)").argument("<keyId>").action(async e=>{try{let t=await c(oe,{keyId:e});k("API key rotated"),o$1(t.rotateAPIKey);}catch(t){h(t);}}),s.command("audit-log").description("Auth audit log").option("--limit <n>","Page size",e=>parseInt(e,10),50).option("-f, --format <format>").action(async e=>{try{let t=await c(F,{pagination:{limit:e.limit,offset:0}});i(e,t.authAuditLogs.auditLogs);}catch(t){h(t);}});let u=s.command("delegations").description("Delegation management");u.command("list").description("Delegations granted to the current user").option("--limit <n>","Page size",e=>parseInt(e,10),50).option("-f, --format <format>").action(async e=>{try{let t=await c(se,{pagination:{limit:e.limit,offset:0}});i(e,t.currentUserDelegations.delegations);}catch(t){h(t);}}),u.command("grant").description("Grant a delegation to an app").requiredOption("--app <appId>").requiredOption("--user <userId>","User to delegate as").option("--scope <s>","Comma-separated scopes").option("--workspace <ids>","Comma-separated workspace ids").option("--expires <iso>").option("-f, --format <format>").action(async e=>{try{let t={appId:e.app,userId:e.user,scopes:e.scope?e.scope.split(","):void 0,workspaceIds:e.workspace?e.workspace.split(","):void 0,expiresAt:e.expires},n=await c(re,{input:t});k("Delegation granted"),i(e,n.grantDelegation);}catch(t){h(t);}}),u.command("revoke").description("Revoke a delegation").argument("<id>").option("--reason <text>").action(async(e,t)=>{try{await c(ae,{id:e,reason:t.reason}),k("Delegation revoked");}catch(n){h(n);}});let g=s.command("apps").description("OAuth/system app management");g.command("list").description("Apps owned by the current user").option("--limit <n>","Page size",e=>parseInt(e,10),50).option("-f, --format <format>").action(async e=>{try{let t=await c(pe,{pagination:{limit:e.limit,offset:0}});i(e,t.currentUserApps.apps,{headers:["ID","ClientID","Name","Type","Status"],rows:t.currentUserApps.apps.map(n=>[r(n.id,12),r(n.clientId,24),n.name??"-",n.type??"-",p(n.status)])});}catch(t){h(t);}}),g.command("get").description("Get an app by id").argument("<id>").option("-f, --format <format>").action(async(e,t)=>{try{let n=await c(ce,{id:e});if(!n.app)throw new o(`App ${e} not found`);i(t,n.app);}catch(n){h(n);}}),g.command("create").description("Create an OAuth app").requiredOption("--name <s>").option("--description <s>").option("--type <t>","OAUTH|SYSTEM","OAUTH").option("--actor-type <t>","USER|APP|SERVICE","APP").option("--redirect <urls>","Comma-separated redirect URIs").option("--scopes <s>","Comma-separated scopes").option("-f, --format <format>").action(async e=>{try{let t={name:e.name,description:e.description,type:(e.type??"OAUTH").toUpperCase(),actorType:(e.actorType??"APP").toUpperCase(),redirectUris:e.redirect?e.redirect.split(","):void 0,scopes:e.scopes?e.scopes.split(","):void 0},n=await c(de,{input:t});k("App created. Client secret only shown once."),o$1(n.createApp);}catch(t){h(t);}}),g.command("update").description("Update an app").argument("<id>").option("--name <s>").option("--description <s>").option("--redirect <urls>","Comma-separated redirect URIs").option("--scopes <s>","Comma-separated scopes").option("--status <s>").option("-f, --format <format>").action(async(e,t)=>{try{let n={};if(t.name&&(n.name=t.name),t.description!==void 0&&(n.description=t.description),t.redirect&&(n.redirectUris=t.redirect.split(",")),t.scopes&&(n.scopes=t.scopes.split(",")),t.status&&(n.status=t.status.toUpperCase()),!Object.keys(n).length)throw new o("No updates specified");let m=await c(me,{id:e,input:n});k("App updated"),i(t,m.updateApp);}catch(n){h(n);}}),g.command("deactivate").description("Deactivate an app").argument("<id>").action(async e=>{try{await c(ue,{id:e}),k("App deactivated");}catch(t){h(t);}});let f=s.command("sso").description("SSO (SAML/OIDC) configuration");f.command("get").description("Get SSO config for a tenant").requiredOption("--tenant <id>").option("-f, --format <format>").action(async e=>{try{let t=await c(le,{tenantId:e.tenant});i(e,t.getSSOConfig);}catch(t){h(t);}}),f.command("save").description("Save (upsert) SSO config for a tenant").requiredOption("--tenant <id>").requiredOption("--entity <s>","EntityID / Issuer").requiredOption("--sso-url <url>").option("--slo-url <url>").option("--certificate <pem>","X.509 certificate PEM").option("--enabled","Enable after save",false).option("-f, --format <format>").action(async e=>{try{let t={entityId:e.entity,ssoUrl:e.ssoUrl,sloUrl:e.sloUrl,certificate:e.certificate,enabled:!!e.enabled},n=await c(ge,{tenantId:e.tenant,input:t});k("SSO config saved"),i(e,n.saveSSOConfig);}catch(t){h(t);}}),f.command("delete").description("Delete SSO config for a tenant").requiredOption("--tenant <id>").action(async e=>{try{await c(fe,{tenantId:e.tenant}),k("SSO config deleted");}catch(t){h(t);}});let h$1=s.command("users").description("User admin (requires admin permissions)");h$1.command("list").description("List users (admin)").option("--email <s>").option("--username <s>").option("--role <s>").option("--status <s>").option("--search <s>").option("--limit <n>","Page size",e=>parseInt(e,10),50).option("-f, --format <format>").action(async e=>{try{let t={};e.email&&(t.email=e.email),e.username&&(t.username=e.username),e.role&&(t.role=e.role.toUpperCase()),e.status&&(t.status=e.status.toUpperCase()),e.search&&(t.search=e.search);let n=await c(Ae,{filter:Object.keys(t).length?t:void 0,pagination:{limit:e.limit,offset:0}});i(e,n.users.users,{headers:["ID","Email","Username","Role","Status","Created"],rows:n.users.users.map(m=>[r(m.id,12),m.email,m.username??"-",m.role??"-",p(m.status),q$1(m.createdAt)])});}catch(t){h(t);}}),h$1.command("get").description("Get user by id (admin)").argument("<id>").option("-f, --format <format>").action(async(e,t)=>{try{let n=await c(he,{id:e});if(!n.user)throw new o(`User ${e} not found`);i(t,n.user);}catch(n){h(n);}}),h$1.command("update").description("Update a user (admin)").argument("<id>").option("--first-name <s>").option("--last-name <s>").option("--username <s>").option("--phone <s>").option("--role <s>").option("--status <s>").option("--email-verified <bool>").option("-f, --format <format>").action(async(e,t)=>{try{let n={};if(t.firstName&&(n.firstName=t.firstName),t.lastName&&(n.lastName=t.lastName),t.username&&(n.username=t.username),t.phone&&(n.phoneNumber=t.phone),t.role&&(n.role=t.role.toUpperCase()),t.status&&(n.status=t.status.toUpperCase()),t.emailVerified!==void 0&&(n.emailVerified=t.emailVerified==="true"),!Object.keys(n).length)throw new o("No updates specified");let m=await c(ke,{id:e,input:n});k("User updated"),i(t,m.updateUser);}catch(n){h(n);}});}var _e={id:"auth",version:"1.0.0",displayName:"Authentication",register(s,p){a(p),Te(s);let i=s.commands.find(o=>o.name()==="auth");if(!i)throw new q("auth command group missing after registerAuthCommands");Ue(i);}},Qe=_e;export{Qe as default};
184
+ `;async function ye(s,p){if(s.length===0)throw new q$1("No workspaces to choose from");if(p.preferredId){let g=s.find(f=>f.id===p.preferredId);if(!g)throw new q$1(`Workspace ${p.preferredId} is not one of your workspaces`);return {workspace:g,prompted:false}}let[i]=s;if(s.length===1||!p.interactive)return {workspace:i,prompted:false};let o=await p.ask(`
185
+ Select workspace [1-${s.length}]: `),c=o===null?-1:parseInt(o.trim(),10)-1;return {workspace:(c>=0&&c<s.length?s[c]:void 0)??i,prompted:true}}async function Ee(s){let i=(await import('readline')).createInterface({input:process.stdin,output:process.stdout});return new Promise(o=>{let c=false;i.on("close",()=>{c||o(null);}),i.question(s,u=>{c=true,i.close(),o(u);});})}function Te(s){let p=s.command("auth").description("Authentication commands");p.command("login").description(`Authenticate with ${u().productName}`).option("--client-credentials","Authenticate as an app with client ID and secret").option("--workspace-id <id>","Workspace to bind the session to").action(async i=>{try{i.clientCredentials?await Re(i.workspaceId):await Pe(i.workspaceId);}catch(o){h(o);}}),p.command("logout").description("Revoke tokens and clear stored auth").action(async()=>{try{if(v()?.accessToken)try{await e(Ie);}catch{n("Server-side logout failed, clearing local tokens");}x(),f(),k("Logged out successfully");}catch(i){h(i);}}),p.command("status").description("Show current auth state").option("-f, --format <format>","Output format (json, table)").action(i$1=>{let o=v(),c=y(),u=!!o?.accessToken,g=o?.accessToken?E(o):false,f=o?.expiresAt?q(new Date(o.expiresAt).toISOString()):"-",h=o?.authMethod==="client_credentials"?"Client Credentials":"OAuth2 Device Code",e=o?.workspaceTokenExpiresAt?q(new Date(o.workspaceTokenExpiresAt).toISOString()):"-";i(i$1,{authenticated:u,method:h,expired:g,expiresAt:f,workspaceId:o?.workspaceId??"-",organizationId:o?.organizationId??"-",workspaceTokenExpiresAt:e,workspaceEndpoint:c.workspaceEndpoint,globalEndpoint:c.globalEndpoint},{headers:["Key","Value"],rows:[["Authenticated",String(u)],["Method",h],["Expired",String(g)],["Expires At",f],["Workspace ID",o?.workspaceId??"-"],["Organization ID",o?.organizationId??"-"],["Workspace Token Expires",e],["Workspace Endpoint",c.workspaceEndpoint],["Global Endpoint",c.globalEndpoint]]});}),p.command("token").description("Print access token to stdout").option("--workspace","Print workspace token instead").action(i=>{let o=v();if(i.workspace){if(!o?.workspaceToken)throw new q$1(`No workspace token. Set a workspace: ${u().productName} workspace set <id>`);process.stdout.write(o.workspaceToken);return}if(!o?.accessToken)throw new q$1(`Not authenticated. Run: ${u().productName} auth login`);process.stdout.write(o.accessToken);}),p.command("refresh").description("Force token refresh").action(async()=>{try{let i=v();if(!i?.refreshToken&&i?.authMethod!=="client_credentials")throw new q$1(`No refresh token available. Run: ${u().productName} auth login`);if(i?.authMethod==="client_credentials"&&i.clientId&&i.clientSecret){let u=y(),g=await f$1(u.globalEndpoint,i.clientId,i.clientSecret);w({...i,accessToken:g.accessToken,expiresAt:Date.now()+g.expiresIn*1e3}),f(),k("App token refreshed successfully"),i.workspaceId&&i.organizationId&&await Se();return}let c=(await e(we,{token:i.refreshToken})).refreshToken;w({...i,accessToken:c.accessToken,refreshToken:c.refreshToken,expiresAt:Date.now()+c.expiresIn*1e3}),f(),k("Token refreshed successfully"),i.workspaceId&&i.organizationId&&await Se();}catch(i){h(i);}});}async function Se(){let s=v();if(!s?.accessToken||!s.workspaceId||!s.organizationId)return;let p=y();try{let i=await g(p.workspaceEndpoint,s.accessToken,s.workspaceId,s.organizationId);w({...s,workspaceToken:i.token,workspaceTokenExpiresAt:new Date(i.expiresAt).getTime()}),f(),k("Workspace token refreshed");}catch{n("Workspace token refresh failed \u2014 workspace operations may require re-login");}}async function Pe(s){let p=y(),{oidcIssuer:i,clientId:o}=D(),c={...p,oidcIssuer:i,clientId:o};m("Starting device code authentication...");let u$1=await d(c);console.log(""),console.log(` Open: ${u$1.verificationUri}`),console.log(` Code: ${u$1.userCode}`),console.log(""),await i$1(u$1.verificationUriComplete??u$1.verificationUri)?m("Browser opened"):n("Could not open browser \u2014 open the URL manually"),m("Waiting for authorization...");let f$1=await e$1(u$1.deviceCode,u$1.interval,c),h=f$1.accessToken,e=Date.now()+f$1.expiresIn*1e3;w({accessToken:h,refreshToken:f$1.refreshToken,expiresAt:e,authMethod:"device_code"}),f(),m("Fetching workspaces...");try{let t=await h$1(p.globalEndpoint,h);if(t.length===0){k("Authentication successful (no workspaces found)");return}let n=!!process.stdin.isTTY;t.length>1&&n&&!s&&(console.log(`
186
+ Available workspaces:`),t.forEach((A,C)=>console.log(` ${C+1}. ${A.name} (${A.slug})`)));let{workspace:m$1}=await ye(t,{preferredId:s,interactive:n,ask:Ee});t.length>1&&!n&&!s&&m(`${t.length} workspaces available; pass --workspace-id or run \`${u().productName} workspace set <id>\` to switch`),m(`Using workspace: ${m$1.name} (${m$1.id})`);let k$1=await g(p.workspaceEndpoint,h,m$1.id,m$1.organizationId);w({accessToken:h,refreshToken:f$1.refreshToken,expiresAt:e,workspaceToken:k$1.token,workspaceTokenExpiresAt:new Date(k$1.expiresAt).getTime(),workspaceId:m$1.id,organizationId:m$1.organizationId,authMethod:"device_code"}),f(),k("Authentication successful");}catch(t){w({accessToken:h,refreshToken:f$1.refreshToken,expiresAt:e,authMethod:"device_code"}),f(),k("Authentication successful"),n(`Workspace token not obtained: ${t instanceof Error?t.message:String(t)}`),m(`Set workspace manually: ${u().productName} workspace set <id>`);}}async function Re(s){let p=y(),o=(await import('readline')).createInterface({input:process.stdin,output:process.stdout}),c=await new Promise(k=>{o.question("Client ID: ",A=>k(A.trim()));}),u=await new Promise(k=>{o.question("Client Secret: ",A=>{o.close(),k(A.trim());});});if(!c||!u)throw new q$1("Client ID and secret cannot be empty");m("Authenticating app...");let g$1=await f$1(p.globalEndpoint,c,u),f$2=g$1.accessToken,h=Date.now()+g$1.expiresIn*1e3,e,t,n$1=s,m$1;if(n$1)try{let A=(await h$1(p.globalEndpoint,f$2)).find(C=>C.id===n$1);if(A){m$1=A.organizationId;let C=await g(p.workspaceEndpoint,f$2,n$1,m$1);e=C.token,t=new Date(C.expiresAt).getTime(),m(`Workspace token issued for: ${A.name}`);}else n(`Workspace ${n$1} not found \u2014 skipping workspace token`),n$1=void 0;}catch(k){n(`Workspace token failed: ${k instanceof Error?k.message:String(k)}`);}w({accessToken:f$2,refreshToken:"",expiresAt:h,workspaceToken:e,workspaceTokenExpiresAt:t,workspaceId:n$1,organizationId:m$1,authMethod:"client_credentials",clientId:c,clientSecret:u}),f(),k("App authentication successful");}function Ue(s){let p$1=s.command("profile").description("Current user profile");p$1.command("show").description("Show current user").option("-f, --format <format>").action(async e=>{try{let t=await c(B);i(e,t.currentUser);}catch(t){h(t);}}),p$1.command("update").description("Update current user profile").option("--first-name <s>").option("--last-name <s>").option("--name <s>").option("--username <s>").option("--phone <s>").option("--timezone <s>").option("--language <s>").option("-f, --format <format>").action(async e=>{try{let t={};if(e.firstName&&(t.firstName=e.firstName),e.lastName&&(t.lastName=e.lastName),e.name&&(t.name=e.name),e.username&&(t.username=e.username),e.phone&&(t.phoneNumber=e.phone),e.timezone&&(t.timezone=e.timezone),e.language&&(t.language=e.language),!Object.keys(t).length)throw new q$1("No updates specified");let n=await c(H,{input:t});k("Profile updated"),i(e,n.updateCurrentUserProfile);}catch(t){h(t);}});let i$1=s.command("security").description("Account security overview");i$1.command("audit-log").description("Recent auth audit events for the current user").option("--limit <n>","Page size",e=>parseInt(e,10),50).option("-f, --format <format>").action(async e=>{try{let t=await c(F,{pagination:{limit:e.limit,offset:0}});i(e,t.authAuditLogs.auditLogs,{headers:["When","Action","Resource","IP"],rows:t.authAuditLogs.auditLogs.map(n=>[q(n.createdAt),n.action,n.resource??"-",n.ipAddress??"-"])});}catch(t){h(t);}}),i$1.command("sessions").description("Active sessions for the current user").option("--limit <n>","Page size",e=>parseInt(e,10),50).option("-f, --format <format>").action(async e=>{try{let t=await c(j,{pagination:{limit:e.limit,offset:0}});i(e,t.activeSessions.sessions,{headers:["ID","Status","IP","LastActivity","Current"],rows:t.activeSessions.sessions.map(n=>[r(n.id,12),p(n.status),n.ipAddress??"-",q(n.lastActivityAt),String(!!n.isCurrent)])});}catch(t){h(t);}});let o$1=s.command("mfa").description("Multi-factor authentication");o$1.command("list").description("List MFA methods enrolled for the current user").option("--limit <n>","Page size",e=>parseInt(e,10),50).option("-f, --format <format>").action(async e=>{try{let t=await c(J,{pagination:{limit:e.limit,offset:0}});i(e,t.currentUserMFAMethods.methods,{headers:["Method","Status","Created"],rows:t.currentUserMFAMethods.methods.map(n=>[n.method,p(n.status),q(n.createdAt)])});}catch(t){h(t);}}),o$1.command("enroll").description("Begin MFA enrollment (TOTP/SMS/EMAIL)").requiredOption("--method <m>","TOTP|SMS|EMAIL").option("-f, --format <format>").action(async e=>{try{let t=await c(X,{method:e.method.toUpperCase()});e.format?i(e,t.setupMFA):(k("MFA enrollment started"),o(t.setupMFA),m("Save your backup codes; verify with `auth mfa verify --code <CODE>`."));}catch(t){h(t);}}),o$1.command("verify").description("Verify MFA enrollment code").requiredOption("--code <code>").action(async e=>{try{await c(Q,{code:e.code}),k("MFA enabled");}catch(t){h(t);}}),o$1.command("disable").description("Disable MFA for the current user").action(async()=>{try{await c(Z),k("MFA disabled");}catch(e){h(e);}});let c$1=s.command("api-keys").description("API key management");c$1.command("list").description("List your API keys").option("--app <id>","Restrict to keys for an app id").option("--limit <n>","Page size",e=>parseInt(e,10),50).option("-f, --format <format>").action(async e=>{try{let t=e.app?te:ee,n=e.app?{appId:e.app,pagination:{limit:e.limit,offset:0}}:{pagination:{limit:e.limit,offset:0}},m=await c(t,n),k=(m.myApiKeys??m.appApiKeys)?.apiKeys??[];i(e,k,{headers:["ID","Name","Prefix","App","Scopes","LastUsed"],rows:k.map(A=>[r(A.id,12),A.name??"-",A.prefix??"-",A.appName??"-",Array.isArray(A.scopes)?A.scopes.join(","):"-",q(A.lastUsedAt)])});}catch(t){h(t);}}),c$1.command("create").description("Generate a new API key").requiredOption("--name <name>").requiredOption("--app <appId>","Owning app id").option("--scope <scope>","Comma-separated scopes").option("--expires <iso>","ISO expiry").option("-f, --format <format>").action(async e=>{try{let t={name:e.name,appId:e.app,scope:e.scope?e.scope.split(","):void 0,expiresAt:e.expires},n=await c(ne,{input:t});k("API key generated. Store the secret \u2014 it is only shown once."),o(n.generateAPIKey);}catch(t){h(t);}}),c$1.command("revoke").description("Revoke an API key").argument("<keyId>").action(async e=>{try{await c(ie,{keyId:e}),k("API key revoked");}catch(t){h(t);}}),c$1.command("rotate").description("Rotate an API key (returns new secret)").argument("<keyId>").action(async e=>{try{let t=await c(oe,{keyId:e});k("API key rotated"),o(t.rotateAPIKey);}catch(t){h(t);}}),s.command("audit-log").description("Auth audit log").option("--limit <n>","Page size",e=>parseInt(e,10),50).option("-f, --format <format>").action(async e=>{try{let t=await c(F,{pagination:{limit:e.limit,offset:0}});i(e,t.authAuditLogs.auditLogs);}catch(t){h(t);}});let u=s.command("delegations").description("Delegation management");u.command("list").description("Delegations granted to the current user").option("--limit <n>","Page size",e=>parseInt(e,10),50).option("-f, --format <format>").action(async e=>{try{let t=await c(se,{pagination:{limit:e.limit,offset:0}});i(e,t.currentUserDelegations.delegations);}catch(t){h(t);}}),u.command("grant").description("Grant a delegation to an app").requiredOption("--app <appId>").requiredOption("--user <userId>","User to delegate as").option("--scope <s>","Comma-separated scopes").option("--workspace <ids>","Comma-separated workspace ids").option("--expires <iso>").option("-f, --format <format>").action(async e=>{try{let t={appId:e.app,userId:e.user,scopes:e.scope?e.scope.split(","):void 0,workspaceIds:e.workspace?e.workspace.split(","):void 0,expiresAt:e.expires},n=await c(re,{input:t});k("Delegation granted"),i(e,n.grantDelegation);}catch(t){h(t);}}),u.command("revoke").description("Revoke a delegation").argument("<id>").option("--reason <text>").action(async(e,t)=>{try{await c(ae,{id:e,reason:t.reason}),k("Delegation revoked");}catch(n){h(n);}});let g=s.command("apps").description("OAuth/system app management");g.command("list").description("Apps owned by the current user").option("--limit <n>","Page size",e=>parseInt(e,10),50).option("-f, --format <format>").action(async e=>{try{let t=await c(pe,{pagination:{limit:e.limit,offset:0}});i(e,t.currentUserApps.apps,{headers:["ID","ClientID","Name","Type","Status"],rows:t.currentUserApps.apps.map(n=>[r(n.id,12),r(n.clientId,24),n.name??"-",n.type??"-",p(n.status)])});}catch(t){h(t);}}),g.command("get").description("Get an app by id").argument("<id>").option("-f, --format <format>").action(async(e,t)=>{try{let n=await c(ce,{id:e});if(!n.app)throw new q$1(`App ${e} not found`);i(t,n.app);}catch(n){h(n);}}),g.command("create").description("Create an OAuth app").requiredOption("--name <s>").option("--description <s>").option("--type <t>","OAUTH|SYSTEM","OAUTH").option("--actor-type <t>","USER|APP|SERVICE","APP").option("--redirect <urls>","Comma-separated redirect URIs").option("--scopes <s>","Comma-separated scopes").option("-f, --format <format>").action(async e=>{try{let t={name:e.name,description:e.description,type:(e.type??"OAUTH").toUpperCase(),actorType:(e.actorType??"APP").toUpperCase(),redirectUris:e.redirect?e.redirect.split(","):void 0,scopes:e.scopes?e.scopes.split(","):void 0},n=await c(de,{input:t});k("App created. Client secret only shown once."),o(n.createApp);}catch(t){h(t);}}),g.command("update").description("Update an app").argument("<id>").option("--name <s>").option("--description <s>").option("--redirect <urls>","Comma-separated redirect URIs").option("--scopes <s>","Comma-separated scopes").option("--status <s>").option("-f, --format <format>").action(async(e,t)=>{try{let n={};if(t.name&&(n.name=t.name),t.description!==void 0&&(n.description=t.description),t.redirect&&(n.redirectUris=t.redirect.split(",")),t.scopes&&(n.scopes=t.scopes.split(",")),t.status&&(n.status=t.status.toUpperCase()),!Object.keys(n).length)throw new q$1("No updates specified");let m=await c(me,{id:e,input:n});k("App updated"),i(t,m.updateApp);}catch(n){h(n);}}),g.command("deactivate").description("Deactivate an app").argument("<id>").action(async e=>{try{await c(ue,{id:e}),k("App deactivated");}catch(t){h(t);}});let f=s.command("sso").description("SSO (SAML/OIDC) configuration");f.command("get").description("Get SSO config for a tenant").requiredOption("--tenant <id>").option("-f, --format <format>").action(async e=>{try{let t=await c(le,{tenantId:e.tenant});i(e,t.getSSOConfig);}catch(t){h(t);}}),f.command("save").description("Save (upsert) SSO config for a tenant").requiredOption("--tenant <id>").requiredOption("--entity <s>","EntityID / Issuer").requiredOption("--sso-url <url>").option("--slo-url <url>").option("--certificate <pem>","X.509 certificate PEM").option("--enabled","Enable after save",false).option("-f, --format <format>").action(async e=>{try{let t={entityId:e.entity,ssoUrl:e.ssoUrl,sloUrl:e.sloUrl,certificate:e.certificate,enabled:!!e.enabled},n=await c(ge,{tenantId:e.tenant,input:t});k("SSO config saved"),i(e,n.saveSSOConfig);}catch(t){h(t);}}),f.command("delete").description("Delete SSO config for a tenant").requiredOption("--tenant <id>").action(async e=>{try{await c(fe,{tenantId:e.tenant}),k("SSO config deleted");}catch(t){h(t);}});let h$1=s.command("users").description("User admin (requires admin permissions)");h$1.command("list").description("List users (admin)").option("--email <s>").option("--username <s>").option("--role <s>").option("--status <s>").option("--search <s>").option("--limit <n>","Page size",e=>parseInt(e,10),50).option("-f, --format <format>").action(async e=>{try{let t={};e.email&&(t.email=e.email),e.username&&(t.username=e.username),e.role&&(t.role=e.role.toUpperCase()),e.status&&(t.status=e.status.toUpperCase()),e.search&&(t.search=e.search);let n=await c(Ae,{filter:Object.keys(t).length?t:void 0,pagination:{limit:e.limit,offset:0}});i(e,n.users.users,{headers:["ID","Email","Username","Role","Status","Created"],rows:n.users.users.map(m=>[r(m.id,12),m.email,m.username??"-",m.role??"-",p(m.status),q(m.createdAt)])});}catch(t){h(t);}}),h$1.command("get").description("Get user by id (admin)").argument("<id>").option("-f, --format <format>").action(async(e,t)=>{try{let n=await c(he,{id:e});if(!n.user)throw new q$1(`User ${e} not found`);i(t,n.user);}catch(n){h(n);}}),h$1.command("update").description("Update a user (admin)").argument("<id>").option("--first-name <s>").option("--last-name <s>").option("--username <s>").option("--phone <s>").option("--role <s>").option("--status <s>").option("--email-verified <bool>").option("-f, --format <format>").action(async(e,t)=>{try{let n={};if(t.firstName&&(n.firstName=t.firstName),t.lastName&&(n.lastName=t.lastName),t.username&&(n.username=t.username),t.phone&&(n.phoneNumber=t.phone),t.role&&(n.role=t.role.toUpperCase()),t.status&&(n.status=t.status.toUpperCase()),t.emailVerified!==void 0&&(n.emailVerified=t.emailVerified==="true"),!Object.keys(n).length)throw new q$1("No updates specified");let m=await c(ke,{id:e,input:n});k("User updated"),i(t,m.updateUser);}catch(n){h(n);}});}var _e={id:"auth",version:"1.0.0",displayName:"Authentication",register(s$1,p){a(p),Te(s$1);let i=s$1.commands.find(o=>o.name()==="auth");if(!i)throw new s("auth command group missing after registerAuthCommands");Ue(i);}},Qe=_e;export{Qe as default};
@@ -1,4 +1,4 @@
1
- 'use strict';require('graphql-request'),require('cross-fetch'),require('commander');var d=class extends Error{exitCode;hint;constructor(i,l){super(i),this.name="CliUserError",this.exitCode=l?.exitCode??1,this.hint=l?.hint;}};var g=class extends Error{cause;constructor(i,l){super(i),this.name="CliInternalError",this.cause=l;}};var C=null;function P(r){C=r;}function f(){if(!C)throw new g("vibecontrols module helpers used before setHelpersContext was called");return C}async function s(r,i){return f().gql.global.request(r,i)}function a(r){let i=r instanceof Error?r.message:String(r);throw new d(i)}function c(r,i,l){f().output.formatAndOutput(r,i,l);}function m(r){f().output.printSuccess(r);}function O(r){f().output.printInfo(r);}function I(r){return f().output.formatStatus(r)}function x(r){return f().output.formatDate(r)}function w(r,i){return f().output.truncate(r,i)}var A=`
1
+ 'use strict';require('graphql-request'),require('cross-fetch'),require('commander');var d=class extends Error{exitCode;hint;constructor(i,l){super(i),this.name="CliUserError",this.exitCode=l?.exitCode??1,this.hint=l?.hint;}};var g=class extends Error{cause;constructor(i,l){super(i),this.name="CliInternalError",this.cause=l;}};var C=null;function P(o){C=o;}function f(){if(!C)throw new g("vibecontrols module helpers used before setHelpersContext was called");return C}async function s(o,i){return f().gql.global.request(o,i)}function a(o){let i=o instanceof Error?o.message:String(o);throw new d(i)}function c(o,i,l){f().output.formatAndOutput(o,i,l);}function m(o){f().output.printSuccess(o);}function O(o){f().output.printInfo(o);}function I(o){return f().output.formatStatus(o)}function x(o){return f().output.formatDate(o)}function y(o,i){return f().output.truncate(o,i)}var A=`
2
2
  query GetDefaultBillingAccount {
3
3
  getDefaultBillingAccount {
4
4
  id creditAmount currency
@@ -29,19 +29,19 @@
29
29
  id status canceledAt cancellationReason
30
30
  }
31
31
  }
32
- `,L=`
32
+ `,q=`
33
33
  query GetAllPlans($filter: PlansFilter) {
34
34
  getAllPlans(filter: $filter) {
35
35
  id name price currency duration pricingModel
36
36
  }
37
37
  }
38
- `,N=`
38
+ `,L=`
39
39
  query GetPlan($id: ID!) {
40
40
  getPlan(id: $id) {
41
41
  id name price pricePerSeat minSeats maxSeats isActive
42
42
  }
43
43
  }
44
- `,q=`
44
+ `,N=`
45
45
  query GetAllAddOns($filter: AddonsFilter, $limit: Int) {
46
46
  getAllAddOns(filter: $filter, limit: $limit) {
47
47
  id name price currency duration isActive
@@ -102,4 +102,4 @@
102
102
  id name limits currentUsageSum reusable
103
103
  }
104
104
  }
105
- `;async function p(){let r=await s(A);if(!r.getDefaultBillingAccount?.id)throw new d("No default billing account on file. Pass --account <id> explicitly.");return r.getDefaultBillingAccount.id}function z(r){let i=r.command("billing").description("Billing: subscriptions, invoices, credits"),l=i.command("subscriptions").description("Subscriptions");l.command("list").description("List active subscriptions").option("--account <id>","Billing account id (defaults to current)").option("-f, --format <format>").action(async t=>{try{let e=t.account??await p(),n=await s(D,{billingAccountId:e});c(t,n.getActiveSubscriptions,{headers:["ID","Status","Plan","Seats","NextBilling"],rows:n.getActiveSubscriptions.map(o=>[w(o.id,12),I(o.status),o.plan?.name??"-",String(o.seatCount??"-"),x(o.nextBillingDate)])});}catch(e){a(e);}}),l.command("get").description("Get a subscription").argument("<id>").option("--account <id>","Billing account id (default: your default account)").option("-f, --format <format>").action(async(t,e)=>{try{let n=e.account??await p(),o=await s(R,{id:t,billingAccountId:n});if(!o.getSubscription)throw new d(`Subscription ${t} not found`);c(e,o.getSubscription);}catch(n){a(n);}}),l.command("upgrade").description("Change subscription seat count").argument("<id>").requiredOption("--seats <n>","Target seat count",t=>parseInt(t,10)).option("-f, --format <format>").action(async(t,e)=>{try{let n={subscriptionId:t,seatCount:e.seats},o=await s($,{input:n});m(`Seat count updated to ${o.updateSubscriptionSeats.seatCount}`),c(e,o.updateSubscriptionSeats);}catch(n){a(n);}}),l.command("cancel").description("Cancel a subscription").argument("<id>").option("--reason <s>").action(async(t,e)=>{try{let n={subscriptionId:t,reason:e.reason},o=await s(_,{input:n});m("Subscription canceled"),c({},o.cancelSubscription);}catch(n){a(n);}});let T=i.command("plans").description("Plans");T.command("list").description("List available plans").option("--product <id>").option("-f, --format <format>").action(async t=>{try{let e={};t.product&&(e.productId=t.product);let n=await s(L,{filter:Object.keys(e).length?e:void 0});c(t,n.getAllPlans,{headers:["ID","Name","Price","Currency","Duration"],rows:n.getAllPlans.map(o=>[w(o.id,12),o.name,String(o.price??"-"),o.currency??"-",o.duration??"-"])});}catch(e){a(e);}}),T.command("get").description("Get a plan").argument("<id>").option("-f, --format <format>").action(async(t,e)=>{try{let n=await s(N,{id:t});if(!n.getPlan)throw new d(`Plan ${t} not found`);c(e,n.getPlan);}catch(n){a(n);}}),i.command("addons").description("Addons").command("list").description("List addons").option("--product <id>").option("--limit <n>","Page size",t=>parseInt(t,10),50).option("-f, --format <format>").action(async t=>{try{let e={};t.product&&(e.productId=t.product);let n=await s(q,{filter:Object.keys(e).length?e:void 0,limit:t.limit});c(t,n.getAllAddOns);}catch(e){a(e);}});let h=i.command("invoices").description("Invoices");h.command("list").description("List invoices").option("--account <id>").option("--page <n>","",t=>parseInt(t,10),1).option("--page-size <n>","",t=>parseInt(t,10),20).option("-f, --format <format>").action(async t=>{try{let e=t.account??await p(),n=await s(G,{billingAccountId:e,page:t.page,pageSize:t.pageSize});c(t,n.getPaginatedInvoices.invoices,{headers:["ID","#","Status","Total","Currency","Paid"],rows:n.getPaginatedInvoices.invoices.map(o=>[w(o.id,12),o.invoiceNumber??"-",I(o.status),String(o.total??"-"),o.currency??"-",x(o.paidAt)])});}catch(e){a(e);}}),h.command("get").description("Get an invoice").argument("<id>").option("--account <id>","Billing account id (default: your default account)").option("-f, --format <format>").action(async(t,e)=>{try{let n=e.account??await p(),o=await s(k,{id:t,billingAccountId:n});if(!o.getInvoice)throw new d(`Invoice ${t} not found`);c(e,o.getInvoice);}catch(n){a(n);}}),h.command("download").description("Print invoice PDF URL (browser-only download)").argument("<id>").option("--account <id>","Billing account id (default: your default account)").action(async(t,e)=>{try{let n=e.account??await p(),o=await s(k,{id:t,billingAccountId:n});if(!o.getInvoice?.pdfUrl)throw new d(`Invoice ${t} has no pdfUrl`);O("PDF URL:"),console.log(o.getInvoice.pdfUrl);}catch(n){a(n);}});let y=i.command("payment-methods").description("Payment methods");y.command("list").description("List payment methods").option("--account <id>").option("-f, --format <format>").action(async t=>{try{let e=t.account??await p(),n=await s(M,{billingAccountId:e});c(t,n.getPaymentMethods,{headers:["ID","Type","Brand","Last4","Default","Verified"],rows:n.getPaymentMethods.map(o=>[w(o.id,12),o.type,o.brand??"-",o.last4??"-",String(!!o.isDefault),String(!!o.isVerified)])});}catch(e){a(e);}}),y.command("add").description("Add a payment method (card metadata only \u2014 providers handle secrets)").requiredOption("--type <t>","CREDIT_CARD|BANK|UPI","CREDIT_CARD").requiredOption("--last4 <s>").option("--brand <s>","Visa|MasterCard|...").option("--expiry-month <n>","",t=>parseInt(t,10)).option("--expiry-year <n>","",t=>parseInt(t,10)).option("--account <id>").option("--default","Make it the default").option("-f, --format <format>").action(async t=>{try{let n={billingAccountId:t.account??await p(),type:t.type.toUpperCase(),last4:t.last4,brand:t.brand,expiryMonth:t.expiryMonth,expiryYear:t.expiryYear,isDefault:!!t.default},o=await s(U,{input:n});m("Payment method added"),c(t,o.addPaymentMethod);}catch(e){a(e);}}),y.command("remove").description("Remove a payment method").argument("<id>").option("--account <id>","Billing account id (default: your default account)").action(async(t,e)=>{try{let n=e.account??await p();await s(B,{id:t,billingAccountId:n}),m("Payment method removed");}catch(n){a(n);}});let b=i.command("credits").description("Credits & withdrawal");b.command("balance").description("Show current credit balance").option("-f, --format <format>").action(async t=>{try{let e=await s(A);c(t,e.getDefaultBillingAccount);}catch(e){a(e);}}),b.command("grant").description("Grant credits to a billing account (admin)").requiredOption("--account <id>").requiredOption("--amount <n>","Amount",t=>parseFloat(t)).option("--reason <s>").action(async t=>{try{let e={billingAccountId:t.account,amount:t.amount,reason:t.reason??"cli-grant"};await s(F,{input:e}),m("Credits granted");}catch(e){a(e);}}),b.command("withdraw").description("Request a credit withdrawal").requiredOption("--account <id>").requiredOption("--amount <n>","Amount",t=>parseFloat(t)).requiredOption("--payout <id>","Payout account id").action(async t=>{try{let e={billingAccountId:t.account,creditAmount:t.amount,payoutAccountId:t.payout};await s(W,{input:e}),m("Withdrawal requested");}catch(e){a(e);}}),i.command("refunds").description("Pending refunds").option("--page <n>","",t=>parseInt(t,10),0).option("--page-size <n>","",t=>parseInt(t,10),20).option("-f, --format <format>").action(async t=>{try{let e=await s(j,{page:t.page,pageSize:t.pageSize});c(t,e.getPendingRefunds.records);}catch(e){a(e);}}),i.command("quota").description("Quotas for a subscription").argument("<subscriptionId>").option("--account <id>","Billing account id (default: your default account)").option("-f, --format <format>").action(async(t,e)=>{try{let n=e.account??await p(),o=await s(V,{subscriptionId:t,billingAccountId:n});c(e,o.getAllQuotasOfSub);}catch(n){a(n);}});}var it={id:"billing",version:"1.0.0",displayName:"Billing",dependsOn:["auth"],register(r,i){P(i),z(r);}},we=it;module.exports=we;
105
+ `;async function p(){let o=await s(A);if(!o.getDefaultBillingAccount?.id)throw new d("No default billing account on file. Pass --account <id> explicitly.");return o.getDefaultBillingAccount.id}function z(o){let i=o.command("billing").description("Billing: subscriptions, invoices, credits"),l=i.command("subscriptions").description("Subscriptions");l.command("list").description("List active subscriptions").option("--account <id>","Billing account id (defaults to current)").option("-f, --format <format>").action(async t=>{try{let e=t.account??await p(),n=await s(D,{billingAccountId:e});c(t,n.getActiveSubscriptions,{headers:["ID","Status","Plan","Seats","NextBilling"],rows:n.getActiveSubscriptions.map(r=>[y(r.id,12),I(r.status),r.plan?.name??"-",String(r.seatCount??"-"),x(r.nextBillingDate)])});}catch(e){a(e);}}),l.command("get").description("Get a subscription").argument("<id>").option("--account <id>","Billing account id (default: your default account)").option("-f, --format <format>").action(async(t,e)=>{try{let n=e.account??await p(),r=await s(R,{id:t,billingAccountId:n});if(!r.getSubscription)throw new d(`Subscription ${t} not found`);c(e,r.getSubscription);}catch(n){a(n);}}),l.command("upgrade").description("Change subscription seat count").argument("<id>").requiredOption("--seats <n>","Target seat count",t=>parseInt(t,10)).option("-f, --format <format>").action(async(t,e)=>{try{let n={subscriptionId:t,seatCount:e.seats},r=await s($,{input:n});m(`Seat count updated to ${r.updateSubscriptionSeats.seatCount}`),c(e,r.updateSubscriptionSeats);}catch(n){a(n);}}),l.command("cancel").description("Cancel a subscription").argument("<id>").option("--reason <s>").action(async(t,e)=>{try{let n={subscriptionId:t,reason:e.reason},r=await s(_,{input:n});m("Subscription canceled"),c({},r.cancelSubscription);}catch(n){a(n);}});let T=i.command("plans").description("Plans");T.command("list").description("List available plans").option("--product <id>").option("-f, --format <format>").action(async t=>{try{let e={};t.product&&(e.productId=t.product);let n=await s(q,{filter:Object.keys(e).length?e:void 0});c(t,n.getAllPlans,{headers:["ID","Name","Price","Currency","Duration"],rows:n.getAllPlans.map(r=>[y(r.id,12),r.name,String(r.price??"-"),r.currency??"-",r.duration??"-"])});}catch(e){a(e);}}),T.command("get").description("Get a plan").argument("<id>").option("-f, --format <format>").action(async(t,e)=>{try{let n=await s(L,{id:t});if(!n.getPlan)throw new d(`Plan ${t} not found`);c(e,n.getPlan);}catch(n){a(n);}}),i.command("addons").description("Addons").command("list").description("List addons").option("--product <id>").option("--limit <n>","Page size",t=>parseInt(t,10),50).option("-f, --format <format>").action(async t=>{try{let e={};t.product&&(e.productId=t.product);let n=await s(N,{filter:Object.keys(e).length?e:void 0,limit:t.limit});c(t,n.getAllAddOns);}catch(e){a(e);}});let w=i.command("invoices").description("Invoices");w.command("list").description("List invoices").option("--account <id>").option("--page <n>","",t=>parseInt(t,10),1).option("--page-size <n>","",t=>parseInt(t,10),20).option("-f, --format <format>").action(async t=>{try{let e=t.account??await p(),n=await s(G,{billingAccountId:e,page:t.page,pageSize:t.pageSize});c(t,n.getPaginatedInvoices.invoices,{headers:["ID","#","Status","Total","Currency","Paid"],rows:n.getPaginatedInvoices.invoices.map(r=>[y(r.id,12),r.invoiceNumber??"-",I(r.status),String(r.total??"-"),r.currency??"-",x(r.paidAt)])});}catch(e){a(e);}}),w.command("get").description("Get an invoice").argument("<id>").option("--account <id>","Billing account id (default: your default account)").option("-f, --format <format>").action(async(t,e)=>{try{let n=e.account??await p(),r=await s(k,{id:t,billingAccountId:n});if(!r.getInvoice)throw new d(`Invoice ${t} not found`);c(e,r.getInvoice);}catch(n){a(n);}}),w.command("download").description("Print invoice PDF URL (browser-only download)").argument("<id>").option("--account <id>","Billing account id (default: your default account)").action(async(t,e)=>{try{let n=e.account??await p(),r=await s(k,{id:t,billingAccountId:n});if(!r.getInvoice?.pdfUrl)throw new d(`Invoice ${t} has no pdfUrl`);O("PDF URL:"),console.log(r.getInvoice.pdfUrl);}catch(n){a(n);}});let b=i.command("payment-methods").description("Payment methods");b.command("list").description("List payment methods").option("--account <id>").option("-f, --format <format>").action(async t=>{try{let e=t.account??await p(),n=await s(M,{billingAccountId:e});c(t,n.getPaymentMethods,{headers:["ID","Type","Brand","Last4","Default","Verified"],rows:n.getPaymentMethods.map(r=>[y(r.id,12),r.type,r.brand??"-",r.last4??"-",String(!!r.isDefault),String(!!r.isVerified)])});}catch(e){a(e);}}),b.command("add").description("Add a payment method (card metadata only \u2014 providers handle secrets)").requiredOption("--type <t>","CREDIT_CARD|BANK|UPI","CREDIT_CARD").requiredOption("--last4 <s>").option("--brand <s>","Visa|MasterCard|...").option("--expiry-month <n>","",t=>parseInt(t,10)).option("--expiry-year <n>","",t=>parseInt(t,10)).option("--account <id>").option("--default","Make it the default").option("-f, --format <format>").action(async t=>{try{let n={billingAccountId:t.account??await p(),type:t.type.toUpperCase(),last4:t.last4,brand:t.brand,expiryMonth:t.expiryMonth,expiryYear:t.expiryYear,isDefault:!!t.default},r=await s(U,{input:n});m("Payment method added"),c(t,r.addPaymentMethod);}catch(e){a(e);}}),b.command("remove").description("Remove a payment method").argument("<id>").option("--account <id>","Billing account id (default: your default account)").action(async(t,e)=>{try{let n=e.account??await p();await s(B,{id:t,billingAccountId:n}),m("Payment method removed");}catch(n){a(n);}});let h=i.command("credits").description("Credits & withdrawal");h.command("balance").description("Show current credit balance").option("-f, --format <format>").action(async t=>{try{let e=await s(A);c(t,e.getDefaultBillingAccount);}catch(e){a(e);}}),h.command("grant").description("Grant credits to a billing account (admin)").requiredOption("--account <id>").requiredOption("--amount <n>","Amount",t=>parseFloat(t)).option("--reason <s>").action(async t=>{try{let e={billingAccountId:t.account,amount:t.amount,reason:t.reason??"cli-grant"};await s(F,{input:e}),m("Credits granted");}catch(e){a(e);}}),h.command("withdraw").description("Request a credit withdrawal").requiredOption("--account <id>").requiredOption("--amount <n>","Amount",t=>parseFloat(t)).requiredOption("--payout <id>","Payout account id").action(async t=>{try{let e={billingAccountId:t.account,creditAmount:t.amount,payoutAccountId:t.payout};await s(W,{input:e}),m("Withdrawal requested");}catch(e){a(e);}}),i.command("refunds").description("Pending refunds").option("--page <n>","",t=>parseInt(t,10),0).option("--page-size <n>","",t=>parseInt(t,10),20).option("-f, --format <format>").action(async t=>{try{let e=await s(j,{page:t.page,pageSize:t.pageSize});c(t,e.getPendingRefunds.records);}catch(e){a(e);}}),i.command("quota").description("Quotas for a subscription").argument("<subscriptionId>").option("--account <id>","Billing account id (default: your default account)").option("-f, --format <format>").action(async(t,e)=>{try{let n=e.account??await p(),r=await s(V,{subscriptionId:t,billingAccountId:n});c(e,r.getAllQuotasOfSub);}catch(n){a(n);}});}var it={id:"billing",version:"1.0.0",displayName:"Billing",dependsOn:["auth"],register(o,i){P(i),z(o);}},be=it;module.exports=be;
@@ -1,4 +1,4 @@
1
- import { C as CliModule } from '../../module-BwJmqefL.cjs';
1
+ import { C as CliModule } from '../../module-CLaW1ycq.cjs';
2
2
  import 'commander';
3
3
  import 'graphql-request';
4
4
 
@@ -1,4 +1,4 @@
1
- import { C as CliModule } from '../../module-BwJmqefL.js';
1
+ import { C as CliModule } from '../../module-CLaW1ycq.js';
2
2
  import 'commander';
3
3
  import 'graphql-request';
4
4
 
@@ -1,4 +1,4 @@
1
- import {a,c,i,r,p,q as q$1,h as h$1,k,m}from'../../chunk-VL67DTWH.js';import {o}from'../../chunk-2OISIPE6.js';var y=`
1
+ import {a,c,i,r,p,q as q$1,h as h$1,k,m}from'../../chunk-WTNQ5PEC.js';import {q as q$2}from'../../chunk-MT2F54AC.js';var y=`
2
2
  query GetDefaultBillingAccount {
3
3
  getDefaultBillingAccount {
4
4
  id creditAmount currency
@@ -102,4 +102,4 @@ import {a,c,i,r,p,q as q$1,h as h$1,k,m}from'../../chunk-VL67DTWH.js';import {o}
102
102
  id name limits currentUsageSum reusable
103
103
  }
104
104
  }
105
- `;async function s(){let u=await c(y);if(!u.getDefaultBillingAccount?.id)throw new o("No default billing account on file. Pass --account <id> explicitly.");return u.getDefaultBillingAccount.id}function z(u){let r$1=u.command("billing").description("Billing: subscriptions, invoices, credits"),g=r$1.command("subscriptions").description("Subscriptions");g.command("list").description("List active subscriptions").option("--account <id>","Billing account id (defaults to current)").option("-f, --format <format>").action(async t=>{try{let n=t.account??await s(),i$1=await c(E,{billingAccountId:n});i(t,i$1.getActiveSubscriptions,{headers:["ID","Status","Plan","Seats","NextBilling"],rows:i$1.getActiveSubscriptions.map(e=>[r(e.id,12),p(e.status),e.plan?.name??"-",String(e.seatCount??"-"),q$1(e.nextBillingDate)])});}catch(n){h$1(n);}}),g.command("get").description("Get a subscription").argument("<id>").option("--account <id>","Billing account id (default: your default account)").option("-f, --format <format>").action(async(t,n)=>{try{let i$1=n.account??await s(),e=await c(h,{id:t,billingAccountId:i$1});if(!e.getSubscription)throw new o(`Subscription ${t} not found`);i(n,e.getSubscription);}catch(i){h$1(i);}}),g.command("upgrade").description("Change subscription seat count").argument("<id>").requiredOption("--seats <n>","Target seat count",t=>parseInt(t,10)).option("-f, --format <format>").action(async(t,n)=>{try{let i$1={subscriptionId:t,seatCount:n.seats},e=await c(_,{input:i$1});k(`Seat count updated to ${e.updateSubscriptionSeats.seatCount}`),i(n,e.updateSubscriptionSeats);}catch(i){h$1(i);}}),g.command("cancel").description("Cancel a subscription").argument("<id>").option("--reason <s>").action(async(t,n)=>{try{let i$1={subscriptionId:t,reason:n.reason},e=await c(R,{input:i$1});k("Subscription canceled"),i({},e.cancelSubscription);}catch(i){h$1(i);}});let P=r$1.command("plans").description("Plans");P.command("list").description("List available plans").option("--product <id>").option("-f, --format <format>").action(async t=>{try{let n={};t.product&&(n.productId=t.product);let i$1=await c($,{filter:Object.keys(n).length?n:void 0});i(t,i$1.getAllPlans,{headers:["ID","Name","Price","Currency","Duration"],rows:i$1.getAllPlans.map(e=>[r(e.id,12),e.name,String(e.price??"-"),e.currency??"-",e.duration??"-"])});}catch(n){h$1(n);}}),P.command("get").description("Get a plan").argument("<id>").option("-f, --format <format>").action(async(t,n)=>{try{let i$1=await c(N,{id:t});if(!i$1.getPlan)throw new o(`Plan ${t} not found`);i(n,i$1.getPlan);}catch(i){h$1(i);}}),r$1.command("addons").description("Addons").command("list").description("List addons").option("--product <id>").option("--limit <n>","Page size",t=>parseInt(t,10),50).option("-f, --format <format>").action(async t=>{try{let n={};t.product&&(n.productId=t.product);let i$1=await c(v,{filter:Object.keys(n).length?n:void 0,limit:t.limit});i(t,i$1.getAllAddOns);}catch(n){h$1(n);}});let m$1=r$1.command("invoices").description("Invoices");m$1.command("list").description("List invoices").option("--account <id>").option("--page <n>","",t=>parseInt(t,10),1).option("--page-size <n>","",t=>parseInt(t,10),20).option("-f, --format <format>").action(async t=>{try{let n=t.account??await s(),i$1=await c(G,{billingAccountId:n,page:t.page,pageSize:t.pageSize});i(t,i$1.getPaginatedInvoices.invoices,{headers:["ID","#","Status","Total","Currency","Paid"],rows:i$1.getPaginatedInvoices.invoices.map(e=>[r(e.id,12),e.invoiceNumber??"-",p(e.status),String(e.total??"-"),e.currency??"-",q$1(e.paidAt)])});}catch(n){h$1(n);}}),m$1.command("get").description("Get an invoice").argument("<id>").option("--account <id>","Billing account id (default: your default account)").option("-f, --format <format>").action(async(t,n)=>{try{let i$1=n.account??await s(),e=await c(S,{id:t,billingAccountId:i$1});if(!e.getInvoice)throw new o(`Invoice ${t} not found`);i(n,e.getInvoice);}catch(i){h$1(i);}}),m$1.command("download").description("Print invoice PDF URL (browser-only download)").argument("<id>").option("--account <id>","Billing account id (default: your default account)").action(async(t,n)=>{try{let i=n.account??await s(),e=await c(S,{id:t,billingAccountId:i});if(!e.getInvoice?.pdfUrl)throw new o(`Invoice ${t} has no pdfUrl`);m("PDF URL:"),console.log(e.getInvoice.pdfUrl);}catch(i){h$1(i);}});let I=r$1.command("payment-methods").description("Payment methods");I.command("list").description("List payment methods").option("--account <id>").option("-f, --format <format>").action(async t=>{try{let n=t.account??await s(),i$1=await c(O,{billingAccountId:n});i(t,i$1.getPaymentMethods,{headers:["ID","Type","Brand","Last4","Default","Verified"],rows:i$1.getPaymentMethods.map(e=>[r(e.id,12),e.type,e.brand??"-",e.last4??"-",String(!!e.isDefault),String(!!e.isVerified)])});}catch(n){h$1(n);}}),I.command("add").description("Add a payment method (card metadata only \u2014 providers handle secrets)").requiredOption("--type <t>","CREDIT_CARD|BANK|UPI","CREDIT_CARD").requiredOption("--last4 <s>").option("--brand <s>","Visa|MasterCard|...").option("--expiry-month <n>","",t=>parseInt(t,10)).option("--expiry-year <n>","",t=>parseInt(t,10)).option("--account <id>").option("--default","Make it the default").option("-f, --format <format>").action(async t=>{try{let i$1={billingAccountId:t.account??await s(),type:t.type.toUpperCase(),last4:t.last4,brand:t.brand,expiryMonth:t.expiryMonth,expiryYear:t.expiryYear,isDefault:!!t.default},e=await c(x,{input:i$1});k("Payment method added"),i(t,e.addPaymentMethod);}catch(n){h$1(n);}}),I.command("remove").description("Remove a payment method").argument("<id>").option("--account <id>","Billing account id (default: your default account)").action(async(t,n)=>{try{let i=n.account??await s();await c(B,{id:t,billingAccountId:i}),k("Payment method removed");}catch(i){h$1(i);}});let f=r$1.command("credits").description("Credits & withdrawal");f.command("balance").description("Show current credit balance").option("-f, --format <format>").action(async t=>{try{let n=await c(y);i(t,n.getDefaultBillingAccount);}catch(n){h$1(n);}}),f.command("grant").description("Grant credits to a billing account (admin)").requiredOption("--account <id>").requiredOption("--amount <n>","Amount",t=>parseFloat(t)).option("--reason <s>").action(async t=>{try{let n={billingAccountId:t.account,amount:t.amount,reason:t.reason??"cli-grant"};await c(M,{input:n}),k("Credits granted");}catch(n){h$1(n);}}),f.command("withdraw").description("Request a credit withdrawal").requiredOption("--account <id>").requiredOption("--amount <n>","Amount",t=>parseFloat(t)).requiredOption("--payout <id>","Payout account id").action(async t=>{try{let n={billingAccountId:t.account,creditAmount:t.amount,payoutAccountId:t.payout};await c(U,{input:n}),k("Withdrawal requested");}catch(n){h$1(n);}}),r$1.command("refunds").description("Pending refunds").option("--page <n>","",t=>parseInt(t,10),0).option("--page-size <n>","",t=>parseInt(t,10),20).option("-f, --format <format>").action(async t=>{try{let n=await c(L,{page:t.page,pageSize:t.pageSize});i(t,n.getPendingRefunds.records);}catch(n){h$1(n);}}),r$1.command("quota").description("Quotas for a subscription").argument("<subscriptionId>").option("--account <id>","Billing account id (default: your default account)").option("-f, --format <format>").action(async(t,n)=>{try{let i$1=n.account??await s(),e=await c(q,{subscriptionId:t,billingAccountId:i$1});i(n,e.getAllQuotasOfSub);}catch(i){h$1(i);}});}var V={id:"billing",version:"1.0.0",displayName:"Billing",dependsOn:["auth"],register(u,r){a(r),z(u);}},J=V;export{J as default};
105
+ `;async function s(){let u=await c(y);if(!u.getDefaultBillingAccount?.id)throw new q$2("No default billing account on file. Pass --account <id> explicitly.");return u.getDefaultBillingAccount.id}function z(u){let r$1=u.command("billing").description("Billing: subscriptions, invoices, credits"),g=r$1.command("subscriptions").description("Subscriptions");g.command("list").description("List active subscriptions").option("--account <id>","Billing account id (defaults to current)").option("-f, --format <format>").action(async t=>{try{let n=t.account??await s(),i$1=await c(E,{billingAccountId:n});i(t,i$1.getActiveSubscriptions,{headers:["ID","Status","Plan","Seats","NextBilling"],rows:i$1.getActiveSubscriptions.map(e=>[r(e.id,12),p(e.status),e.plan?.name??"-",String(e.seatCount??"-"),q$1(e.nextBillingDate)])});}catch(n){h$1(n);}}),g.command("get").description("Get a subscription").argument("<id>").option("--account <id>","Billing account id (default: your default account)").option("-f, --format <format>").action(async(t,n)=>{try{let i$1=n.account??await s(),e=await c(h,{id:t,billingAccountId:i$1});if(!e.getSubscription)throw new q$2(`Subscription ${t} not found`);i(n,e.getSubscription);}catch(i){h$1(i);}}),g.command("upgrade").description("Change subscription seat count").argument("<id>").requiredOption("--seats <n>","Target seat count",t=>parseInt(t,10)).option("-f, --format <format>").action(async(t,n)=>{try{let i$1={subscriptionId:t,seatCount:n.seats},e=await c(_,{input:i$1});k(`Seat count updated to ${e.updateSubscriptionSeats.seatCount}`),i(n,e.updateSubscriptionSeats);}catch(i){h$1(i);}}),g.command("cancel").description("Cancel a subscription").argument("<id>").option("--reason <s>").action(async(t,n)=>{try{let i$1={subscriptionId:t,reason:n.reason},e=await c(R,{input:i$1});k("Subscription canceled"),i({},e.cancelSubscription);}catch(i){h$1(i);}});let P=r$1.command("plans").description("Plans");P.command("list").description("List available plans").option("--product <id>").option("-f, --format <format>").action(async t=>{try{let n={};t.product&&(n.productId=t.product);let i$1=await c($,{filter:Object.keys(n).length?n:void 0});i(t,i$1.getAllPlans,{headers:["ID","Name","Price","Currency","Duration"],rows:i$1.getAllPlans.map(e=>[r(e.id,12),e.name,String(e.price??"-"),e.currency??"-",e.duration??"-"])});}catch(n){h$1(n);}}),P.command("get").description("Get a plan").argument("<id>").option("-f, --format <format>").action(async(t,n)=>{try{let i$1=await c(N,{id:t});if(!i$1.getPlan)throw new q$2(`Plan ${t} not found`);i(n,i$1.getPlan);}catch(i){h$1(i);}}),r$1.command("addons").description("Addons").command("list").description("List addons").option("--product <id>").option("--limit <n>","Page size",t=>parseInt(t,10),50).option("-f, --format <format>").action(async t=>{try{let n={};t.product&&(n.productId=t.product);let i$1=await c(v,{filter:Object.keys(n).length?n:void 0,limit:t.limit});i(t,i$1.getAllAddOns);}catch(n){h$1(n);}});let m$1=r$1.command("invoices").description("Invoices");m$1.command("list").description("List invoices").option("--account <id>").option("--page <n>","",t=>parseInt(t,10),1).option("--page-size <n>","",t=>parseInt(t,10),20).option("-f, --format <format>").action(async t=>{try{let n=t.account??await s(),i$1=await c(G,{billingAccountId:n,page:t.page,pageSize:t.pageSize});i(t,i$1.getPaginatedInvoices.invoices,{headers:["ID","#","Status","Total","Currency","Paid"],rows:i$1.getPaginatedInvoices.invoices.map(e=>[r(e.id,12),e.invoiceNumber??"-",p(e.status),String(e.total??"-"),e.currency??"-",q$1(e.paidAt)])});}catch(n){h$1(n);}}),m$1.command("get").description("Get an invoice").argument("<id>").option("--account <id>","Billing account id (default: your default account)").option("-f, --format <format>").action(async(t,n)=>{try{let i$1=n.account??await s(),e=await c(S,{id:t,billingAccountId:i$1});if(!e.getInvoice)throw new q$2(`Invoice ${t} not found`);i(n,e.getInvoice);}catch(i){h$1(i);}}),m$1.command("download").description("Print invoice PDF URL (browser-only download)").argument("<id>").option("--account <id>","Billing account id (default: your default account)").action(async(t,n)=>{try{let i=n.account??await s(),e=await c(S,{id:t,billingAccountId:i});if(!e.getInvoice?.pdfUrl)throw new q$2(`Invoice ${t} has no pdfUrl`);m("PDF URL:"),console.log(e.getInvoice.pdfUrl);}catch(i){h$1(i);}});let I=r$1.command("payment-methods").description("Payment methods");I.command("list").description("List payment methods").option("--account <id>").option("-f, --format <format>").action(async t=>{try{let n=t.account??await s(),i$1=await c(O,{billingAccountId:n});i(t,i$1.getPaymentMethods,{headers:["ID","Type","Brand","Last4","Default","Verified"],rows:i$1.getPaymentMethods.map(e=>[r(e.id,12),e.type,e.brand??"-",e.last4??"-",String(!!e.isDefault),String(!!e.isVerified)])});}catch(n){h$1(n);}}),I.command("add").description("Add a payment method (card metadata only \u2014 providers handle secrets)").requiredOption("--type <t>","CREDIT_CARD|BANK|UPI","CREDIT_CARD").requiredOption("--last4 <s>").option("--brand <s>","Visa|MasterCard|...").option("--expiry-month <n>","",t=>parseInt(t,10)).option("--expiry-year <n>","",t=>parseInt(t,10)).option("--account <id>").option("--default","Make it the default").option("-f, --format <format>").action(async t=>{try{let i$1={billingAccountId:t.account??await s(),type:t.type.toUpperCase(),last4:t.last4,brand:t.brand,expiryMonth:t.expiryMonth,expiryYear:t.expiryYear,isDefault:!!t.default},e=await c(x,{input:i$1});k("Payment method added"),i(t,e.addPaymentMethod);}catch(n){h$1(n);}}),I.command("remove").description("Remove a payment method").argument("<id>").option("--account <id>","Billing account id (default: your default account)").action(async(t,n)=>{try{let i=n.account??await s();await c(B,{id:t,billingAccountId:i}),k("Payment method removed");}catch(i){h$1(i);}});let f=r$1.command("credits").description("Credits & withdrawal");f.command("balance").description("Show current credit balance").option("-f, --format <format>").action(async t=>{try{let n=await c(y);i(t,n.getDefaultBillingAccount);}catch(n){h$1(n);}}),f.command("grant").description("Grant credits to a billing account (admin)").requiredOption("--account <id>").requiredOption("--amount <n>","Amount",t=>parseFloat(t)).option("--reason <s>").action(async t=>{try{let n={billingAccountId:t.account,amount:t.amount,reason:t.reason??"cli-grant"};await c(M,{input:n}),k("Credits granted");}catch(n){h$1(n);}}),f.command("withdraw").description("Request a credit withdrawal").requiredOption("--account <id>").requiredOption("--amount <n>","Amount",t=>parseFloat(t)).requiredOption("--payout <id>","Payout account id").action(async t=>{try{let n={billingAccountId:t.account,creditAmount:t.amount,payoutAccountId:t.payout};await c(U,{input:n}),k("Withdrawal requested");}catch(n){h$1(n);}}),r$1.command("refunds").description("Pending refunds").option("--page <n>","",t=>parseInt(t,10),0).option("--page-size <n>","",t=>parseInt(t,10),20).option("-f, --format <format>").action(async t=>{try{let n=await c(L,{page:t.page,pageSize:t.pageSize});i(t,n.getPendingRefunds.records);}catch(n){h$1(n);}}),r$1.command("quota").description("Quotas for a subscription").argument("<subscriptionId>").option("--account <id>","Billing account id (default: your default account)").option("-f, --format <format>").action(async(t,n)=>{try{let i$1=n.account??await s(),e=await c(q,{subscriptionId:t,billingAccountId:i$1});i(n,e.getAllQuotasOfSub);}catch(i){h$1(i);}});}var V={id:"billing",version:"1.0.0",displayName:"Billing",dependsOn:["auth"],register(u,r){a(r),z(u);}},J=V;export{J as default};