@burdenoff/cli-sdk 2026.1102.1 → 2026.1102.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-O6UCQ5IT.js +1 -0
- package/dist/{chunk-AYNNSLCL.js → chunk-ZGT7IIOP.js} +409 -418
- package/dist/modules/adaptercloud/index.cjs +4 -4
- package/dist/modules/adaptercloud/index.js +2 -2
- package/dist/modules/artistrybase/index.js +2 -2
- package/dist/modules/assethandler/index.cjs +2 -2
- package/dist/modules/assethandler/index.js +2 -2
- package/dist/modules/atheletebridge/index.cjs +8 -8
- package/dist/modules/atheletebridge/index.js +2 -2
- package/dist/modules/auth/index.cjs +37 -37
- package/dist/modules/auth/index.js +33 -29
- package/dist/modules/billing/index.cjs +1 -1
- package/dist/modules/billing/index.js +2 -2
- package/dist/modules/brainyrich/index.cjs +44 -28
- package/dist/modules/brainyrich/index.js +47 -31
- package/dist/modules/buildmyiq/index.js +2 -2
- package/dist/modules/channels/index.cjs +3 -3
- package/dist/modules/channels/index.js +2 -2
- package/dist/modules/collabkin/index.cjs +4 -4
- package/dist/modules/collabkin/index.js +2 -2
- package/dist/modules/comradecircle/index.cjs +6 -6
- package/dist/modules/comradecircle/index.js +2 -2
- package/dist/modules/conversations/index.cjs +7 -7
- package/dist/modules/conversations/index.js +2 -2
- package/dist/modules/coolandlovely/index.cjs +2 -2
- package/dist/modules/coolandlovely/index.js +2 -2
- package/dist/modules/cosmicintersection/index.cjs +6 -6
- package/dist/modules/cosmicintersection/index.js +2 -2
- package/dist/modules/crewfoundry/index.js +2 -2
- package/dist/modules/devportal/index.cjs +2 -2
- package/dist/modules/devportal/index.js +2 -2
- package/dist/modules/ecoimpacthub/index.cjs +5 -5
- package/dist/modules/ecoimpacthub/index.js +2 -2
- package/dist/modules/eventfullymanaged/index.cjs +12 -12
- package/dist/modules/eventfullymanaged/index.js +2 -2
- package/dist/modules/export/index.cjs +4 -4
- package/dist/modules/export/index.js +2 -2
- package/dist/modules/files/index.cjs +3 -3
- package/dist/modules/files/index.js +4 -4
- package/dist/modules/fluidgrids/index.cjs +16 -16
- package/dist/modules/fluidgrids/index.js +3 -3
- package/dist/modules/ggnomad/index.cjs +4 -4
- package/dist/modules/ggnomad/index.js +2 -2
- package/dist/modules/govcitizenhub/index.cjs +4 -4
- package/dist/modules/govcitizenhub/index.js +2 -2
- package/dist/modules/groups/index.cjs +4 -4
- package/dist/modules/groups/index.js +2 -2
- package/dist/modules/headshotmarketing/index.js +2 -2
- package/dist/modules/hookmovies/index.cjs +6 -6
- package/dist/modules/hookmovies/index.js +2 -2
- package/dist/modules/housingvista/index.cjs +3 -3
- package/dist/modules/housingvista/index.js +2 -2
- package/dist/modules/integrations/index.cjs +5 -5
- package/dist/modules/integrations/index.js +2 -2
- package/dist/modules/intelwatchtower/index.cjs +5 -5
- package/dist/modules/intelwatchtower/index.js +2 -2
- package/dist/modules/kadaikodi/index.cjs +2 -2
- package/dist/modules/kadaikodi/index.js +2 -2
- package/dist/modules/labsofscience/index.cjs +3 -3
- package/dist/modules/labsofscience/index.js +2 -2
- package/dist/modules/manufacturedops/index.cjs +2 -2
- package/dist/modules/manufacturedops/index.js +2 -2
- package/dist/modules/movethewheels/index.js +2 -2
- package/dist/modules/notifications/index.cjs +2 -2
- package/dist/modules/notifications/index.js +2 -2
- package/dist/modules/organizations/index.js +2 -2
- package/dist/modules/planmagnet/index.js +2 -2
- package/dist/modules/products/index.cjs +4 -4
- package/dist/modules/products/index.js +2 -2
- package/dist/modules/proserviceworld/index.cjs +2 -2
- package/dist/modules/proserviceworld/index.js +2 -2
- package/dist/modules/rbac/index.js +2 -2
- package/dist/modules/sandbox/index.cjs +17 -17
- package/dist/modules/sandbox/index.js +1 -1
- package/dist/modules/scheduler/index.cjs +2 -2
- package/dist/modules/scheduler/index.js +2 -2
- package/dist/modules/security/index.cjs +3 -3
- package/dist/modules/security/index.js +2 -2
- package/dist/modules/semanticfed/index.cjs +3 -3
- package/dist/modules/semanticfed/index.js +2 -2
- package/dist/modules/store/index.cjs +3 -3
- package/dist/modules/store/index.js +2 -2
- package/dist/modules/subscriberbot/index.cjs +1 -1
- package/dist/modules/subscriberbot/index.js +2 -2
- package/dist/modules/support/index.cjs +2 -2
- package/dist/modules/support/index.js +2 -2
- package/dist/modules/tags/index.js +2 -2
- package/dist/modules/technospam/index.cjs +2 -2
- package/dist/modules/technospam/index.js +2 -2
- package/dist/modules/theculturepost/index.js +2 -2
- package/dist/modules/theglobalfuel/index.cjs +2 -2
- package/dist/modules/theglobalfuel/index.js +2 -2
- package/dist/modules/timecampus/index.js +2 -2
- package/dist/modules/tours/index.cjs +2 -2
- package/dist/modules/tours/index.js +2 -2
- package/dist/modules/vibecontrols/index.cjs +563 -567
- package/dist/modules/vibecontrols/index.js +5 -4
- package/dist/modules/workspaces/index.cjs +4 -4
- package/dist/modules/workspaces/index.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-W4JZR7RJ.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {a,b as b$1,
|
|
1
|
+
import {a,b as b$1,i,r,h,k as k$1,d}from'../../chunk-O6UCQ5IT.js';import {o}from'../../chunk-YIY5IDXQ.js';var y=`
|
|
2
2
|
query AthListTeams(
|
|
3
3
|
$pagination: PaginationInput
|
|
4
4
|
$sport: AthSport
|
|
@@ -273,4 +273,4 @@ import {a,b as b$1,h,p,g,i,d}from'../../chunk-W4JZR7RJ.js';import {o}from'../../
|
|
|
273
273
|
query AthHealth {
|
|
274
274
|
athHealth
|
|
275
275
|
}
|
|
276
|
-
`;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=d.command("teams").description("AtheleteBridge teams");r.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});h(o,t.athListTeams.items,{headers:["ID","Name","Sport","Status","Season"],rows:t.athListTeams.items.map(e=>[p(e.id,12),e.name,e.sport,e.status,e.season??"-"])});}catch(t){g(t);}}),r.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`);h(t,e.athTeam);}catch(e){g(e);}}),r.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});i(`Team created: ${e.athCreateTeam.name}`),h(o,e.athCreateTeam);}catch(t){g(t);}}),r.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});i("Team updated"),h(t,i$1.athUpdateTeam);}catch(e){g(e);}}),r.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});i(e.athArchiveTeam?`Team ${o} archived`:`Team ${o} not archived`),h(t,{archived:e.athArchiveTeam});}catch(e){g(e);}});}function et(d){let r=d.command("members").description("AtheleteBridge team members");r.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});h(o,t.athListMembers,{headers:["ID","Name","Role","Status","Jersey","Position"],rows:t.athListMembers.map(e=>[p(e.id,12),e.displayName,e.role,e.status,e.jerseyNumber!==void 0&&e.jerseyNumber!==null?String(e.jerseyNumber):"-",e.position??"-"])});}catch(t){g(t);}}),r.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});i(`Member added: ${e.athAddMember.displayName}`),h(o,e.athAddMember);}catch(t){g(t);}}),r.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});i("Member updated"),h(t,i$1.athUpdateMember);}catch(e){g(e);}}),r.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(E,{id:o});i(e.athRemoveMember?`Member ${o} removed`:`Member ${o} not removed`),h(t,{removed:e.athRemoveMember});}catch(e){g(e);}});}function ot(d){let r=d.command("programs").description("AtheleteBridge training programs");r.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(M,{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});h(t,e.athListPrograms.items,{headers:["ID","Name","Sport","Level","Status","Weeks"],rows:e.athListPrograms.items.map(i=>[p(i.id,12),i.name,i.sport,i.level,i.status,i.weeks!==void 0&&i.weeks!==null?String(i.weeks):"-"])});}catch(e){g(e);}}),r.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=await b$1($,{id:t});if(!i.athProgram)throw new o(`Program ${t} not found`);h(e,i.athProgram);}catch(i){g(i);}}),r.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});i(`Program created: ${i$1.athCreateProgram.name}`),h(t,i$1.athCreateProgram);}catch(e){g(e);}}),r.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});i("Program updated"),h(e,dt.athUpdateProgram);}catch(i){g(i);}}),r.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()});i(`Program transitioned to ${i$1.athTransitionProgram.status}`),h(e,i$1.athTransitionProgram);}catch(i){g(i);}}),r.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});i(i$1.athArchiveProgram?`Program ${t} archived`:`Program ${t} not archived`),h(e,{archived:i$1.athArchiveProgram});}catch(i){g(i);}});let o$1=r.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});i(`Drill added: ${i$1.athAddDrill.name}`),h(t,i$1.athAddDrill);}catch(e){g(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});i(i$1.athRemoveDrill?`Drill ${t} removed`:`Drill ${t} not removed`),h(e,{removed:i$1.athRemoveDrill});}catch(i){g(i);}});}function rt(d){let r=d.command("sessions").description("AtheleteBridge coaching sessions");r.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});h(o,t.athListSessions.items,{headers:["ID","Title","Type","Status","Scheduled"],rows:t.athListSessions.items.map(e=>[p(e.id,12),e.title,e.type,e.status,e.scheduledAt])});}catch(t){g(t);}}),r.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`);h(t,e.athSession);}catch(e){g(e);}}),r.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});i(`Session booked: ${e.athBookSession.title}`),h(o,e.athBookSession);}catch(t){g(t);}}),r.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});i(`Session confirmed: ${e.athConfirmSession.status}`),h(t,e.athConfirmSession);}catch(e){g(e);}}),r.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});i(`Session cancelled: ${e.athCancelSession.status}`),h(t,e.athCancelSession);}catch(e){g(e);}}),r.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});i(`Session completed: ${i$1.athCompleteSession.status}`),h(t,i$1.athCompleteSession);}catch(e){g(e);}});}function it(d){let r=d.command("workouts").description("AtheleteBridge workout logs");r.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});h(o,t.athListWorkoutLogs.items,{headers:["ID","Title","Status","Performed","Load","RPE"],rows:t.athListWorkoutLogs.items.map(e=>[p(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){g(t);}}),r.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});i(`Workout logged: ${e.athLogWorkout.title}`),h(o,e.athLogWorkout);}catch(t){g(t);}});}function at(d){let r=d.command("metrics").description("AtheleteBridge performance metrics");r.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});h(o,t.athPerformanceMetrics,{headers:["ID","Label","Type","Value","Unit","Recorded"],rows:t.athPerformanceMetrics.map(e=>[p(e.id,12),e.label,e.type,String(e.value),e.unit??"-",e.recordedAt])});}catch(t){g(t);}}),r.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});i(`Metric recorded: ${e.athRecordMetric.label}`),h(o,e.athRecordMetric);}catch(t){g(t);}});}function nt(d){let r=d.command("fixtures").description("AtheleteBridge fixtures");r.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});h(o,t.athListFixtures.items,{headers:["ID","Type","Status","Competition","Scheduled","Score"],rows:t.athListFixtures.items.map(e=>[p(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){g(t);}}),r.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`);h(t,e.athFixture);}catch(e){g(e);}}),r.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});i(`Fixture scheduled: ${e.athScheduleFixture.id}`),h(o,e.athScheduleFixture);}catch(t){g(t);}}),r.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}});i(`Result recorded: ${e.athRecordFixtureResult.homeScore??0}-${e.athRecordFixtureResult.awayScore??0}`),h(t,e.athRecordFixtureResult);}catch(e){g(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});h(o,t.athStandings,{headers:["Rank","Team","P","W","D","L","Pts"],rows:t.athStandings.map(e=>[e.rank!==void 0&&e.rank!==null?String(e.rank):"-",p(e.teamId,12),String(e.played),String(e.won),String(e.drawn),String(e.lost),String(e.points)])});}catch(t){g(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);i(o.athHealth),h(r,{health:o.athHealth});}catch(o){g(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};
|
|
276
|
+
`;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,{headers:["ID","Name","Role","Status","Jersey","Position"],rows:t.athListMembers.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(E,{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(M,{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,{headers:["ID","Label","Type","Value","Unit","Recorded"],rows:t.athPerformanceMetrics.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,{headers:["Rank","Team","P","W","D","L","Pts"],rows:t.athStandings.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,42 +1,36 @@
|
|
|
1
|
-
'use strict';require('graphql-request');var
|
|
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:`
|
|
2
2
|
mutation AuthenticateApp($input: AuthenticateAppInput!) {
|
|
3
3
|
authenticateApp(input: $input) {
|
|
4
4
|
accessToken tokenType expiresIn scopes
|
|
5
5
|
}
|
|
6
6
|
}
|
|
7
|
-
`,variables:{input:{clientId:s,clientSecret:
|
|
7
|
+
`,variables:{input:{clientId:s,clientSecret:o,scopes:i}}})});if(!c.ok){let d=await c.text().catch(()=>"Unknown error");throw new Error(`App authentication failed (${c.status}): ${d}`)}let p=await c.json();if(p.errors?.length)throw new Error(`App authentication failed: ${p.errors[0]?.message??"unknown error"}`);if(!p.data?.authenticateApp?.accessToken)throw new Error("App authentication failed: no access token returned");return p.data.authenticateApp}async function b(n,s,o,i){let c=await ___default.default(n,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${s}`},body:JSON.stringify({query:`
|
|
8
8
|
mutation IssueWorkspaceToken($input: IssueWorkspaceTokenInput!) {
|
|
9
9
|
issueWorkspaceToken(input: $input) {
|
|
10
10
|
success token expiresAt scopes
|
|
11
11
|
error { code message }
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
|
-
`,variables:{input:{workspaceId:
|
|
14
|
+
`,variables:{input:{workspaceId:o,organizationId:i}}})});if(!c.ok){let h=await c.text().catch(()=>"Unknown error");throw new Error(`Workspace token request failed (${c.status}): ${h}`)}let p=await c.json();if(p.errors?.length)throw new Error(`Workspace token failed: ${p.errors[0]?.message??"unknown error"}`);let d=p.data?.issueWorkspaceToken;if(!d?.success||!d.token){let h=d?.error?.message??"Unknown error";throw new Error(`Workspace token failed: ${h}`)}return {token:d.token,expiresAt:d.expiresAt??"",scopes:d.scopes??[]}}async function N(n,s){let i=await ___default.default(n,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${s}`},body:JSON.stringify({query:`
|
|
15
15
|
query MyWorkspaces($limit: Int) {
|
|
16
16
|
myWorkspaces(limit: $limit) {
|
|
17
17
|
items { id name slug tenantId organizationId }
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
-
`,variables:{limit:50}})});if(!
|
|
21
|
-
mutation RefreshToken($token: String!) {
|
|
22
|
-
refreshToken(token: $token) { accessToken refreshToken expiresIn }
|
|
23
|
-
}
|
|
24
|
-
`;async function Bt(n,s){if(n.length===0)throw new S("No workspaces to choose from");if(s.preferredId){let p=n.find(u=>u.id===s.preferredId);if(!p)throw new S(`Workspace ${s.preferredId} is not one of your workspaces`);return {workspace:p,prompted:false}}let[i]=n;if(n.length===1||!s.interactive)return {workspace:i,prompted:false};let r=await s.ask(`
|
|
25
|
-
Select workspace [1-${n.length}]: `),a=r===null?-1:parseInt(r.trim(),10)-1;return {workspace:(a>=0&&a<n.length?n[a]:void 0)??i,prompted:true}}async function Kt(n){let i=(await import('readline')).createInterface({input:process.stdin,output:process.stdout});return new Promise(r=>{let a=false;i.on("close",()=>{a||r(null);}),i.question(n,c=>{a=true,i.close(),r(c);});})}function Wt(n){let s=n.command("auth").description("Authentication commands");s.command("login").description(`Authenticate with ${R().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 Oe(i.workspaceId):await he(i.workspaceId);}catch(r){d(r);}}),s.command("logout").description("Revoke tokens and clear stored auth").action(async()=>{try{if(F()?.accessToken)try{await St(wt);}catch{v("Server-side logout failed, clearing local tokens");}Dt(),b(),I("Logged out successfully");}catch(i){d(i);}}),s.command("status").description("Show current auth state").option("-f, --format <format>","Output format (json, table)").action(i=>{let r=F(),a=B(),c=!!r?.accessToken,p=r?.accessToken?_t(r):false,u=r?.expiresAt?h(new Date(r.expiresAt).toISOString()):"-",$=r?.authMethod==="client_credentials"?"Client Credentials":"OAuth2 Device Code",t=r?.workspaceTokenExpiresAt?h(new Date(r.workspaceTokenExpiresAt).toISOString()):"-";m(i,{authenticated:c,method:$,expired:p,expiresAt:u,workspaceId:r?.workspaceId??"-",organizationId:r?.organizationId??"-",workspaceTokenExpiresAt:t,workspaceEndpoint:a.workspaceEndpoint,globalEndpoint:a.globalEndpoint},{headers:["Key","Value"],rows:[["Authenticated",String(c)],["Method",$],["Expired",String(p)],["Expires At",u],["Workspace ID",r?.workspaceId??"-"],["Organization ID",r?.organizationId??"-"],["Workspace Token Expires",t],["Workspace Endpoint",a.workspaceEndpoint],["Global Endpoint",a.globalEndpoint]]});}),s.command("token").description("Print access token to stdout").option("--workspace","Print workspace token instead").action(i=>{let r=F();if(i.workspace){if(!r?.workspaceToken)throw new S(`No workspace token. Set a workspace: ${R().productName} workspace set <id>`);process.stdout.write(r.workspaceToken);return}if(!r?.accessToken)throw new S(`Not authenticated. Run: ${R().productName} auth login`);process.stdout.write(r.accessToken);}),s.command("refresh").description("Force token refresh").action(async()=>{try{let i=F();if(!i?.refreshToken&&i?.authMethod!=="client_credentials")throw new S(`No refresh token available. Run: ${R().productName} auth login`);if(i?.authMethod==="client_credentials"&&i.clientId&&i.clientSecret){let c=B(),p=await M(c.globalEndpoint,i.clientId,i.clientSecret);O({...i,accessToken:p.accessToken,expiresAt:Date.now()+p.expiresIn*1e3}),b(),I("App token refreshed successfully"),i.workspaceId&&i.organizationId&&await Ht();return}let a=(await St(vt,{token:i.refreshToken})).refreshToken;O({...i,accessToken:a.accessToken,refreshToken:a.refreshToken,expiresAt:Date.now()+a.expiresIn*1e3}),b(),I("Token refreshed successfully"),i.workspaceId&&i.organizationId&&await Ht();}catch(i){d(i);}});}async function Ht(){let n=F();if(!n?.accessToken||!n.workspaceId||!n.organizationId)return;let s=B();try{let i=await w(s.workspaceEndpoint,n.accessToken,n.workspaceId,n.organizationId);O({...n,workspaceToken:i.token,workspaceTokenExpiresAt:new Date(i.expiresAt).getTime()}),b(),I("Workspace token refreshed");}catch{v("Workspace token refresh failed \u2014 workspace operations may require re-login");}}async function he(n){let s=B(),{oidcIssuer:i,clientId:r}=Ct(),a={...s,oidcIssuer:i,clientId:r};x("Starting device code authentication...");let c=await ot(a);console.log(""),console.log(` Open: ${c.verificationUri}`),console.log(` Code: ${c.userCode}`),console.log(""),await rt(c.verificationUriComplete??c.verificationUri)?x("Browser opened"):v("Could not open browser \u2014 open the URL manually"),x("Waiting for authorization...");let u=await it(c.deviceCode,c.interval,a),$=u.accessToken,t=Date.now()+u.expiresIn*1e3;O({accessToken:$,refreshToken:u.refreshToken,expiresAt:t,authMethod:"device_code"}),b(),x("Fetching workspaces...");try{let e=await j(s.globalEndpoint,$);if(e.length===0){I("Authentication successful (no workspaces found)");return}let o=!!process.stdin.isTTY;e.length>1&&o&&!n&&(console.log(`
|
|
26
|
-
Available workspaces:`),e.forEach((E,G)=>console.log(` ${G+1}. ${E.name} (${E.slug})`)));let{workspace:g}=await Bt(e,{preferredId:n,interactive:o,ask:Kt});e.length>1&&!o&&!n&&x(`${e.length} workspaces available; pass --workspace-id or run \`${R().productName} workspace set <id>\` to switch`),x(`Using workspace: ${g.name} (${g.id})`);let A=await w(s.workspaceEndpoint,$,g.id,g.organizationId);O({accessToken:$,refreshToken:u.refreshToken,expiresAt:t,workspaceToken:A.token,workspaceTokenExpiresAt:new Date(A.expiresAt).getTime(),workspaceId:g.id,organizationId:g.organizationId,authMethod:"device_code"}),b(),I("Authentication successful");}catch(e){O({accessToken:$,refreshToken:u.refreshToken,expiresAt:t,authMethod:"device_code"}),b(),I("Authentication successful"),v(`Workspace token not obtained: ${e instanceof Error?e.message:String(e)}`),x(`Set workspace manually: ${R().productName} workspace set <id>`);}}async function Oe(n){let s=B(),r=(await import('readline')).createInterface({input:process.stdin,output:process.stdout}),a=await new Promise(A=>{r.question("Client ID: ",E=>A(E.trim()));}),c=await new Promise(A=>{r.question("Client Secret: ",E=>{r.close(),A(E.trim());});});if(!a||!c)throw new S("Client ID and secret cannot be empty");x("Authenticating app...");let p=await M(s.globalEndpoint,a,c),u=p.accessToken,$=Date.now()+p.expiresIn*1e3,t,e,o=n,g;if(o)try{let E=(await j(s.globalEndpoint,u)).find(G=>G.id===o);if(E){g=E.organizationId;let G=await w(s.workspaceEndpoint,u,o,g);t=G.token,e=new Date(G.expiresAt).getTime(),x(`Workspace token issued for: ${E.name}`);}else v(`Workspace ${o} not found \u2014 skipping workspace token`),o=void 0;}catch(A){v(`Workspace token failed: ${A instanceof Error?A.message:String(A)}`);}O({accessToken:u,refreshToken:"",expiresAt:$,workspaceToken:t,workspaceTokenExpiresAt:e,workspaceId:o,organizationId:g,authMethod:"client_credentials",clientId:a,clientSecret:c}),b(),I("App authentication successful");}var Yt=`
|
|
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=`
|
|
27
21
|
query currentUser {
|
|
28
22
|
currentUser {
|
|
29
23
|
id email firstName lastName username phoneNumber name
|
|
30
24
|
emailVerified mfaEnabled isAdmin role status createdAt lastLoginAt
|
|
31
25
|
}
|
|
32
26
|
}
|
|
33
|
-
`,
|
|
27
|
+
`,Q=`
|
|
34
28
|
mutation updateCurrentUserProfile($input: UpdateUserInput!) {
|
|
35
29
|
updateCurrentUserProfile(input: $input) {
|
|
36
30
|
id name firstName lastName username phoneNumber
|
|
37
31
|
}
|
|
38
32
|
}
|
|
39
|
-
`,
|
|
33
|
+
`,z=`
|
|
40
34
|
query authAuditLogs($pagination: PaginationInput) {
|
|
41
35
|
authAuditLogs(pagination: $pagination) {
|
|
42
36
|
auditLogs {
|
|
@@ -47,7 +41,7 @@ Available workspaces:`),e.forEach((E,G)=>console.log(` ${G+1}. ${E.name} (${E.s
|
|
|
47
41
|
hasMore
|
|
48
42
|
}
|
|
49
43
|
}
|
|
50
|
-
`,
|
|
44
|
+
`,X=`
|
|
51
45
|
query activeSessions($pagination: PaginationInput) {
|
|
52
46
|
activeSessions(pagination: $pagination) {
|
|
53
47
|
sessions {
|
|
@@ -57,7 +51,7 @@ Available workspaces:`),e.forEach((E,G)=>console.log(` ${G+1}. ${E.name} (${E.s
|
|
|
57
51
|
hasMore
|
|
58
52
|
}
|
|
59
53
|
}
|
|
60
|
-
`,
|
|
54
|
+
`,Z=`
|
|
61
55
|
query currentUserMFAMethods($pagination: PaginationInput) {
|
|
62
56
|
currentUserMFAMethods(pagination: $pagination) {
|
|
63
57
|
methods { id method status createdAt updatedAt }
|
|
@@ -65,21 +59,21 @@ Available workspaces:`),e.forEach((E,G)=>console.log(` ${G+1}. ${E.name} (${E.s
|
|
|
65
59
|
hasMore
|
|
66
60
|
}
|
|
67
61
|
}
|
|
68
|
-
`,
|
|
62
|
+
`,ee=`
|
|
69
63
|
mutation setupMFA($method: MFAMethod!) {
|
|
70
64
|
setupMFA(method: $method) {
|
|
71
65
|
method backupCodes qrCode secret
|
|
72
66
|
}
|
|
73
67
|
}
|
|
74
|
-
`;var
|
|
68
|
+
`;var te=`
|
|
75
69
|
mutation enableMFA($code: String!) {
|
|
76
70
|
enableMFA(code: $code)
|
|
77
71
|
}
|
|
78
|
-
`,
|
|
72
|
+
`,ne=`
|
|
79
73
|
mutation disableMFA {
|
|
80
74
|
disableMFA
|
|
81
75
|
}
|
|
82
|
-
`,
|
|
76
|
+
`,re=`
|
|
83
77
|
query myApiKeys($pagination: PaginationInput) {
|
|
84
78
|
myApiKeys(pagination: $pagination) {
|
|
85
79
|
apiKeys { id name prefix appId appName scopes expiresAt lastUsedAt createdAt }
|
|
@@ -87,7 +81,7 @@ Available workspaces:`),e.forEach((E,G)=>console.log(` ${G+1}. ${E.name} (${E.s
|
|
|
87
81
|
hasMore
|
|
88
82
|
}
|
|
89
83
|
}
|
|
90
|
-
`,
|
|
84
|
+
`,oe=`
|
|
91
85
|
query appApiKeys($appId: ID!, $pagination: PaginationInput) {
|
|
92
86
|
appApiKeys(appId: $appId, pagination: $pagination) {
|
|
93
87
|
apiKeys { id name prefix appId appName scopes expiresAt lastUsedAt createdAt }
|
|
@@ -95,23 +89,23 @@ Available workspaces:`),e.forEach((E,G)=>console.log(` ${G+1}. ${E.name} (${E.s
|
|
|
95
89
|
hasMore
|
|
96
90
|
}
|
|
97
91
|
}
|
|
98
|
-
`,
|
|
92
|
+
`,ie=`
|
|
99
93
|
mutation generateAPIKey($input: GenerateAPIKeyInput!) {
|
|
100
94
|
generateAPIKey(input: $input) {
|
|
101
95
|
keyId apiKey apiSecret
|
|
102
96
|
}
|
|
103
97
|
}
|
|
104
|
-
`;var
|
|
98
|
+
`;var se=`
|
|
105
99
|
mutation revokeAPIKey($keyId: String!) {
|
|
106
100
|
revokeAPIKey(keyId: $keyId)
|
|
107
101
|
}
|
|
108
|
-
`,
|
|
102
|
+
`,ae=`
|
|
109
103
|
mutation rotateAPIKey($keyId: String!) {
|
|
110
104
|
rotateAPIKey(keyId: $keyId) {
|
|
111
105
|
apiSecret
|
|
112
106
|
}
|
|
113
107
|
}
|
|
114
|
-
`,
|
|
108
|
+
`,ce=`
|
|
115
109
|
query currentUserDelegations($pagination: PaginationInput) {
|
|
116
110
|
currentUserDelegations(pagination: $pagination) {
|
|
117
111
|
delegations {
|
|
@@ -123,17 +117,17 @@ Available workspaces:`),e.forEach((E,G)=>console.log(` ${G+1}. ${E.name} (${E.s
|
|
|
123
117
|
hasMore
|
|
124
118
|
}
|
|
125
119
|
}
|
|
126
|
-
`,
|
|
120
|
+
`,pe=`
|
|
127
121
|
mutation grantDelegation($input: GrantDelegationInput!) {
|
|
128
122
|
grantDelegation(input: $input) {
|
|
129
123
|
id appId userId grantedBy grantedAt expiresAt scopes workspaceIds status
|
|
130
124
|
}
|
|
131
125
|
}
|
|
132
|
-
`,
|
|
126
|
+
`,ue=`
|
|
133
127
|
mutation revokeDelegation($id: ID!, $reason: String) {
|
|
134
128
|
revokeDelegation(id: $id, reason: $reason)
|
|
135
129
|
}
|
|
136
|
-
`,
|
|
130
|
+
`,de=`
|
|
137
131
|
query currentUserApps($pagination: PaginationInput) {
|
|
138
132
|
currentUserApps(pagination: $pagination) {
|
|
139
133
|
apps {
|
|
@@ -144,62 +138,68 @@ Available workspaces:`),e.forEach((E,G)=>console.log(` ${G+1}. ${E.name} (${E.s
|
|
|
144
138
|
hasMore
|
|
145
139
|
}
|
|
146
140
|
}
|
|
147
|
-
`,
|
|
141
|
+
`,le=`
|
|
148
142
|
query app($id: ID!) {
|
|
149
143
|
app(id: $id) {
|
|
150
144
|
id clientId name description type actorType status ownerUserId redirectUris scopes
|
|
151
145
|
}
|
|
152
146
|
}
|
|
153
|
-
`,
|
|
147
|
+
`,ge=`
|
|
154
148
|
mutation createApp($input: CreateAppInput!) {
|
|
155
149
|
createApp(input: $input) {
|
|
156
150
|
app { id clientId name type status }
|
|
157
151
|
clientSecret
|
|
158
152
|
}
|
|
159
153
|
}
|
|
160
|
-
`,
|
|
154
|
+
`,fe=`
|
|
161
155
|
mutation updateApp($id: ID!, $input: UpdateAppInput!) {
|
|
162
156
|
updateApp(id: $id, input: $input) {
|
|
163
157
|
id name description redirectUris scopes status
|
|
164
158
|
}
|
|
165
159
|
}
|
|
166
|
-
`,
|
|
160
|
+
`,me=`
|
|
167
161
|
mutation deactivateApp($id: ID!) {
|
|
168
162
|
deactivateApp(id: $id)
|
|
169
163
|
}
|
|
170
|
-
`,
|
|
164
|
+
`,he=`
|
|
171
165
|
query getSSOConfig($tenantId: String!) {
|
|
172
166
|
getSSOConfig(tenantId: $tenantId) {
|
|
173
167
|
id identifier tenantId entityId ssoUrl sloUrl certificate enabled metadata
|
|
174
168
|
}
|
|
175
169
|
}
|
|
176
|
-
`,
|
|
170
|
+
`,ke=`
|
|
177
171
|
mutation saveSSOConfig($tenantId: String!, $input: SSOConfigInput!) {
|
|
178
172
|
saveSSOConfig(tenantId: $tenantId, input: $input) {
|
|
179
173
|
id identifier entityId ssoUrl sloUrl certificate enabled
|
|
180
174
|
}
|
|
181
175
|
}
|
|
182
|
-
`,
|
|
176
|
+
`,we=`
|
|
183
177
|
mutation deleteSSOConfig($tenantId: String!) {
|
|
184
178
|
deleteSSOConfig(tenantId: $tenantId)
|
|
185
179
|
}
|
|
186
|
-
|
|
180
|
+
`,ye=`
|
|
187
181
|
query users($filter: UserFilterInput, $pagination: PaginationInput) {
|
|
188
182
|
users(filter: $filter, pagination: $pagination) {
|
|
189
183
|
users { id email firstName lastName username role status createdAt }
|
|
190
184
|
totalCount hasMore
|
|
191
185
|
}
|
|
192
186
|
}
|
|
193
|
-
`,
|
|
187
|
+
`,Ae=`
|
|
194
188
|
query user($id: ID!) {
|
|
195
189
|
user(id: $id) {
|
|
196
190
|
id email firstName lastName username role status emailVerified lastLoginAt
|
|
197
191
|
}
|
|
198
192
|
}
|
|
199
|
-
`,
|
|
193
|
+
`,Ie=`
|
|
200
194
|
mutation updateUser($id: ID!, $input: AdminUpdateUserInput!) {
|
|
201
195
|
updateUser(id: $id, input: $input) {
|
|
202
196
|
id email firstName lastName username role status
|
|
203
197
|
}
|
|
204
198
|
}
|
|
205
|
-
`;function fe(n){let s=n.command("profile").description("Current user profile");s.command("show").description("Show current user").option("-f, --format <format>").action(async t=>{try{let e=await l(Yt);m(t,e.currentUser);}catch(e){d(e);}}),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 t=>{try{let e={};if(t.firstName&&(e.firstName=t.firstName),t.lastName&&(e.lastName=t.lastName),t.name&&(e.name=t.name),t.username&&(e.username=t.username),t.phone&&(e.phoneNumber=t.phone),t.timezone&&(e.timezone=t.timezone),t.language&&(e.language=t.language),!Object.keys(e).length)throw new S("No updates specified");let o=await l(zt,{input:e});I("Profile updated"),m(t,o.updateCurrentUserProfile);}catch(e){d(e);}});let i=n.command("security").description("Account security overview");i.command("audit-log").description("Recent auth audit events for the current user").option("--limit <n>","Page size",t=>parseInt(t,10),50).option("-f, --format <format>").action(async t=>{try{let e=await l(At,{pagination:{limit:t.limit,offset:0}});m(t,e.authAuditLogs.auditLogs,{headers:["When","Action","Resource","IP"],rows:e.authAuditLogs.auditLogs.map(o=>[h(o.createdAt),o.action,o.resource??"-",o.ipAddress??"-"])});}catch(e){d(e);}}),i.command("sessions").description("Active sessions for the current user").option("--limit <n>","Page size",t=>parseInt(t,10),50).option("-f, --format <format>").action(async t=>{try{let e=await l(jt,{pagination:{limit:t.limit,offset:0}});m(t,e.activeSessions.sessions,{headers:["ID","Status","IP","LastActivity","Current"],rows:e.activeSessions.sessions.map(o=>[q(o.id,12),J(o.status),o.ipAddress??"-",h(o.lastActivityAt),String(!!o.isCurrent)])});}catch(e){d(e);}});let r=n.command("mfa").description("Multi-factor authentication");r.command("list").description("List MFA methods enrolled for the current user").option("--limit <n>","Page size",t=>parseInt(t,10),50).option("-f, --format <format>").action(async t=>{try{let e=await l(Xt,{pagination:{limit:t.limit,offset:0}});m(t,e.currentUserMFAMethods.methods,{headers:["Method","Status","Created"],rows:e.currentUserMFAMethods.methods.map(o=>[o.method,J(o.status),h(o.createdAt)])});}catch(e){d(e);}}),r.command("enroll").description("Begin MFA enrollment (TOTP/SMS/EMAIL)").requiredOption("--method <m>","TOTP|SMS|EMAIL").option("-f, --format <format>").action(async t=>{try{let e=await l(Jt,{method:t.method.toUpperCase()});t.format?m(t,e.setupMFA):(I("MFA enrollment started"),X(e.setupMFA),x("Save your backup codes; verify with `auth mfa verify --code <CODE>`."));}catch(e){d(e);}}),r.command("verify").description("Verify MFA enrollment code").requiredOption("--code <code>").action(async t=>{try{await l(Qt,{code:t.code}),I("MFA enabled");}catch(e){d(e);}}),r.command("disable").description("Disable MFA for the current user").action(async()=>{try{await l(Zt),I("MFA disabled");}catch(t){d(t);}});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",t=>parseInt(t,10),50).option("-f, --format <format>").action(async t=>{try{let e=t.app?ee:te,o=t.app?{appId:t.app,pagination:{limit:t.limit,offset:0}}:{pagination:{limit:t.limit,offset:0}},g=await l(e,o),A=(g.myApiKeys??g.appApiKeys)?.apiKeys??[];m(t,A,{headers:["ID","Name","Prefix","App","Scopes","LastUsed"],rows:A.map(E=>[q(E.id,12),E.name??"-",E.prefix??"-",E.appName??"-",Array.isArray(E.scopes)?E.scopes.join(","):"-",h(E.lastUsedAt)])});}catch(e){d(e);}}),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 t=>{try{let e={name:t.name,appId:t.app,scope:t.scope?t.scope.split(","):void 0,expiresAt:t.expires},o=await l(ne,{input:e});I("API key generated. Store the secret \u2014 it is only shown once."),X(o.generateAPIKey);}catch(e){d(e);}}),a.command("revoke").description("Revoke an API key").argument("<keyId>").action(async t=>{try{await l(oe,{keyId:t}),I("API key revoked");}catch(e){d(e);}}),a.command("rotate").description("Rotate an API key (returns new secret)").argument("<keyId>").action(async t=>{try{let e=await l(ie,{keyId:t});I("API key rotated"),X(e.rotateAPIKey);}catch(e){d(e);}}),n.command("audit-log").description("Auth audit log").option("--limit <n>","Page size",t=>parseInt(t,10),50).option("-f, --format <format>").action(async t=>{try{let e=await l(At,{pagination:{limit:t.limit,offset:0}});m(t,e.authAuditLogs.auditLogs);}catch(e){d(e);}});let c=n.command("delegations").description("Delegation management");c.command("list").description("Delegations granted to the current user").option("--limit <n>","Page size",t=>parseInt(t,10),50).option("-f, --format <format>").action(async t=>{try{let e=await l(re,{pagination:{limit:t.limit,offset:0}});m(t,e.currentUserDelegations.delegations);}catch(e){d(e);}}),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 t=>{try{let e={appId:t.app,userId:t.user,scopes:t.scope?t.scope.split(","):void 0,workspaceIds:t.workspace?t.workspace.split(","):void 0,expiresAt:t.expires},o=await l(se,{input:e});I("Delegation granted"),m(t,o.grantDelegation);}catch(e){d(e);}}),c.command("revoke").description("Revoke a delegation").argument("<id>").option("--reason <text>").action(async(t,e)=>{try{await l(ae,{id:t,reason:e.reason}),I("Delegation revoked");}catch(o){d(o);}});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",t=>parseInt(t,10),50).option("-f, --format <format>").action(async t=>{try{let e=await l(ce,{pagination:{limit:t.limit,offset:0}});m(t,e.currentUserApps.apps,{headers:["ID","ClientID","Name","Type","Status"],rows:e.currentUserApps.apps.map(o=>[q(o.id,12),q(o.clientId,24),o.name??"-",o.type??"-",J(o.status)])});}catch(e){d(e);}}),p.command("get").description("Get an app by id").argument("<id>").option("-f, --format <format>").action(async(t,e)=>{try{let o=await l(pe,{id:t});if(!o.app)throw new S(`App ${t} not found`);m(e,o.app);}catch(o){d(o);}}),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 t=>{try{let e={name:t.name,description:t.description,type:(t.type??"OAUTH").toUpperCase(),actorType:(t.actorType??"APP").toUpperCase(),redirectUris:t.redirect?t.redirect.split(","):void 0,scopes:t.scopes?t.scopes.split(","):void 0},o=await l(de,{input:e});I("App created. Client secret only shown once."),X(o.createApp);}catch(e){d(e);}}),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(t,e)=>{try{let o={};if(e.name&&(o.name=e.name),e.description!==void 0&&(o.description=e.description),e.redirect&&(o.redirectUris=e.redirect.split(",")),e.scopes&&(o.scopes=e.scopes.split(",")),e.status&&(o.status=e.status.toUpperCase()),!Object.keys(o).length)throw new S("No updates specified");let g=await l(ue,{id:t,input:o});I("App updated"),m(e,g.updateApp);}catch(o){d(o);}}),p.command("deactivate").description("Deactivate an app").argument("<id>").action(async t=>{try{await l(le,{id:t}),I("App deactivated");}catch(e){d(e);}});let u=n.command("sso").description("SSO (SAML/OIDC) configuration");u.command("get").description("Get SSO config for a tenant").requiredOption("--tenant <id>").option("-f, --format <format>").action(async t=>{try{let e=await l(Ie,{tenantId:t.tenant});m(t,e.getSSOConfig);}catch(e){d(e);}}),u.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 t=>{try{let e={entityId:t.entity,ssoUrl:t.ssoUrl,sloUrl:t.sloUrl,certificate:t.certificate,enabled:!!t.enabled},o=await l(ge,{tenantId:t.tenant,input:e});I("SSO config saved"),m(t,o.saveSSOConfig);}catch(e){d(e);}}),u.command("delete").description("Delete SSO config for a tenant").requiredOption("--tenant <id>").action(async t=>{try{await l(me,{tenantId:t.tenant}),I("SSO config deleted");}catch(e){d(e);}});let $=n.command("users").description("User admin (requires admin permissions)");$.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",t=>parseInt(t,10),50).option("-f, --format <format>").action(async t=>{try{let e={};t.email&&(e.email=t.email),t.username&&(e.username=t.username),t.role&&(e.role=t.role.toUpperCase()),t.status&&(e.status=t.status.toUpperCase()),t.search&&(e.search=t.search);let o=await l($e,{filter:Object.keys(e).length?e:void 0,pagination:{limit:t.limit,offset:0}});m(t,o.users.users,{headers:["ID","Email","Username","Role","Status","Created"],rows:o.users.users.map(g=>[q(g.id,12),g.email,g.username??"-",g.role??"-",J(g.status),h(g.createdAt)])});}catch(e){d(e);}}),$.command("get").description("Get user by id (admin)").argument("<id>").option("-f, --format <format>").action(async(t,e)=>{try{let o=await l(Se,{id:t});if(!o.user)throw new S(`User ${t} not found`);m(e,o.user);}catch(o){d(o);}}),$.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(t,e)=>{try{let o={};if(e.firstName&&(o.firstName=e.firstName),e.lastName&&(o.lastName=e.lastName),e.username&&(o.username=e.username),e.phone&&(o.phoneNumber=e.phone),e.role&&(o.role=e.role.toUpperCase()),e.status&&(o.status=e.status.toUpperCase()),e.emailVerified!==void 0&&(o.emailVerified=e.emailVerified==="true"),!Object.keys(o).length)throw new S("No updates specified");let g=await l(Ee,{id:t,input:o});I("User updated"),m(e,g.updateUser);}catch(o){d(o);}});}var we={id:"auth",version:"1.0.0",displayName:"Authentication",register(n,s){yt(s),Wt(n);let i=n.commands.find(r=>r.name()==="auth");if(!i)throw new k("auth command group missing after registerAuthCommands");fe(i);}},Bs=we;module.exports=Bs;
|
|
199
|
+
`,Ce="mutation SignOut { signOut }",xe=`
|
|
200
|
+
mutation RefreshToken($token: String!) {
|
|
201
|
+
refreshToken(token: $token) { accessToken refreshToken expiresIn }
|
|
202
|
+
}
|
|
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;
|