@burdenoff/cli-sdk 2026.1201.1 → 2026.1202.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-BGNPGKJM.js +1 -0
- package/dist/{chunk-ASSY2L5R.js → chunk-E6F56R4K.js} +3 -3
- package/dist/chunk-N7EXKGE2.js +34 -0
- package/dist/core/index.cjs +9 -9
- package/dist/core/index.d.cts +2 -2
- package/dist/core/index.d.ts +2 -2
- package/dist/core/index.js +1 -1
- package/dist/index.cjs +9 -9
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/{module-BNVKV_pI.d.ts → module-DWSAfs3k.d.cts} +20 -19
- package/dist/{module-BNVKV_pI.d.cts → module-DWSAfs3k.d.ts} +20 -19
- package/dist/modules/adaptercloud/index.cjs +38 -38
- package/dist/modules/adaptercloud/index.d.cts +1 -1
- package/dist/modules/adaptercloud/index.d.ts +1 -1
- package/dist/modules/adaptercloud/index.js +2 -2
- package/dist/modules/artistrybase/index.cjs +50 -50
- package/dist/modules/artistrybase/index.d.cts +1 -1
- package/dist/modules/artistrybase/index.d.ts +1 -1
- package/dist/modules/artistrybase/index.js +2 -2
- package/dist/modules/assethandler/index.cjs +32 -32
- package/dist/modules/assethandler/index.d.cts +1 -1
- package/dist/modules/assethandler/index.d.ts +1 -1
- package/dist/modules/assethandler/index.js +2 -2
- package/dist/modules/atheletebridge/index.cjs +34 -34
- package/dist/modules/atheletebridge/index.d.cts +1 -1
- package/dist/modules/atheletebridge/index.d.ts +1 -1
- package/dist/modules/atheletebridge/index.js +2 -2
- package/dist/modules/auth/index.cjs +34 -34
- package/dist/modules/auth/index.d.cts +1 -1
- package/dist/modules/auth/index.d.ts +1 -1
- package/dist/modules/auth/index.js +4 -4
- package/dist/modules/billing/index.cjs +18 -18
- package/dist/modules/billing/index.d.cts +1 -1
- package/dist/modules/billing/index.d.ts +1 -1
- package/dist/modules/billing/index.js +2 -2
- package/dist/modules/brainyrich/index.cjs +45 -45
- package/dist/modules/brainyrich/index.d.cts +1 -1
- package/dist/modules/brainyrich/index.d.ts +1 -1
- package/dist/modules/brainyrich/index.js +2 -2
- package/dist/modules/buildmyiq/index.cjs +32 -32
- package/dist/modules/buildmyiq/index.d.cts +1 -1
- package/dist/modules/buildmyiq/index.d.ts +1 -1
- package/dist/modules/buildmyiq/index.js +2 -2
- package/dist/modules/channels/index.cjs +12 -12
- package/dist/modules/channels/index.d.cts +1 -1
- package/dist/modules/channels/index.d.ts +1 -1
- package/dist/modules/channels/index.js +2 -2
- package/dist/modules/collabkin/index.cjs +34 -34
- package/dist/modules/collabkin/index.d.cts +1 -1
- package/dist/modules/collabkin/index.d.ts +1 -1
- package/dist/modules/collabkin/index.js +2 -2
- package/dist/modules/comradecircle/index.cjs +41 -41
- package/dist/modules/comradecircle/index.d.cts +1 -1
- package/dist/modules/comradecircle/index.d.ts +1 -1
- package/dist/modules/comradecircle/index.js +2 -2
- package/dist/modules/conversations/index.cjs +32 -32
- package/dist/modules/conversations/index.d.cts +1 -1
- package/dist/modules/conversations/index.d.ts +1 -1
- package/dist/modules/conversations/index.js +2 -2
- package/dist/modules/coolandlovely/index.cjs +41 -41
- package/dist/modules/coolandlovely/index.d.cts +1 -1
- package/dist/modules/coolandlovely/index.d.ts +1 -1
- package/dist/modules/coolandlovely/index.js +2 -2
- package/dist/modules/cosmicintersection/index.cjs +43 -43
- package/dist/modules/cosmicintersection/index.d.cts +1 -1
- package/dist/modules/cosmicintersection/index.d.ts +1 -1
- package/dist/modules/cosmicintersection/index.js +2 -2
- package/dist/modules/crewfoundry/index.cjs +70 -70
- package/dist/modules/crewfoundry/index.d.cts +1 -1
- package/dist/modules/crewfoundry/index.d.ts +1 -1
- package/dist/modules/crewfoundry/index.js +2 -2
- package/dist/modules/devportal/index.cjs +23 -23
- package/dist/modules/devportal/index.d.cts +1 -1
- package/dist/modules/devportal/index.d.ts +1 -1
- package/dist/modules/devportal/index.js +2 -2
- package/dist/modules/ecoimpacthub/index.cjs +41 -41
- package/dist/modules/ecoimpacthub/index.d.cts +1 -1
- package/dist/modules/ecoimpacthub/index.d.ts +1 -1
- package/dist/modules/ecoimpacthub/index.js +2 -2
- package/dist/modules/eventfullymanaged/index.cjs +92 -92
- package/dist/modules/eventfullymanaged/index.d.cts +1 -1
- package/dist/modules/eventfullymanaged/index.d.ts +1 -1
- package/dist/modules/eventfullymanaged/index.js +2 -2
- package/dist/modules/export/index.cjs +14 -14
- package/dist/modules/export/index.d.cts +1 -1
- package/dist/modules/export/index.d.ts +1 -1
- package/dist/modules/export/index.js +2 -2
- package/dist/modules/files/index.cjs +11 -11
- package/dist/modules/files/index.d.cts +1 -1
- package/dist/modules/files/index.d.ts +1 -1
- package/dist/modules/files/index.js +2 -2
- package/dist/modules/fluidgrids/index.cjs +29 -29
- package/dist/modules/fluidgrids/index.d.cts +1 -1
- package/dist/modules/fluidgrids/index.d.ts +1 -1
- package/dist/modules/fluidgrids/index.js +3 -3
- package/dist/modules/ggnomad/index.cjs +21 -21
- package/dist/modules/ggnomad/index.d.cts +1 -1
- package/dist/modules/ggnomad/index.d.ts +1 -1
- package/dist/modules/ggnomad/index.js +2 -2
- package/dist/modules/govcitizenhub/index.cjs +35 -35
- package/dist/modules/govcitizenhub/index.d.cts +1 -1
- package/dist/modules/govcitizenhub/index.d.ts +1 -1
- package/dist/modules/govcitizenhub/index.js +2 -2
- package/dist/modules/groups/index.cjs +12 -12
- package/dist/modules/groups/index.d.cts +1 -1
- package/dist/modules/groups/index.d.ts +1 -1
- package/dist/modules/groups/index.js +2 -2
- package/dist/modules/headshotmarketing/index.cjs +165 -165
- package/dist/modules/headshotmarketing/index.d.cts +1 -1
- package/dist/modules/headshotmarketing/index.d.ts +1 -1
- package/dist/modules/headshotmarketing/index.js +2 -2
- package/dist/modules/health/index.d.cts +1 -1
- package/dist/modules/health/index.d.ts +1 -1
- package/dist/modules/hookmovies/index.cjs +43 -43
- package/dist/modules/hookmovies/index.d.cts +1 -1
- package/dist/modules/hookmovies/index.d.ts +1 -1
- package/dist/modules/hookmovies/index.js +2 -2
- package/dist/modules/housingvista/index.cjs +24 -24
- package/dist/modules/housingvista/index.d.cts +1 -1
- package/dist/modules/housingvista/index.d.ts +1 -1
- package/dist/modules/housingvista/index.js +2 -2
- package/dist/modules/integrations/index.cjs +27 -27
- package/dist/modules/integrations/index.d.cts +1 -1
- package/dist/modules/integrations/index.d.ts +1 -1
- package/dist/modules/integrations/index.js +2 -2
- package/dist/modules/intelwatchtower/index.cjs +37 -37
- package/dist/modules/intelwatchtower/index.d.cts +1 -1
- package/dist/modules/intelwatchtower/index.d.ts +1 -1
- package/dist/modules/intelwatchtower/index.js +2 -2
- package/dist/modules/kadaikodi/index.cjs +26 -26
- package/dist/modules/kadaikodi/index.d.cts +1 -1
- package/dist/modules/kadaikodi/index.d.ts +1 -1
- package/dist/modules/kadaikodi/index.js +2 -2
- package/dist/modules/labsofscience/index.cjs +44 -44
- package/dist/modules/labsofscience/index.d.cts +1 -1
- package/dist/modules/labsofscience/index.d.ts +1 -1
- package/dist/modules/labsofscience/index.js +2 -2
- package/dist/modules/manufacturedops/index.cjs +36 -36
- package/dist/modules/manufacturedops/index.d.cts +1 -1
- package/dist/modules/manufacturedops/index.d.ts +1 -1
- package/dist/modules/manufacturedops/index.js +2 -2
- package/dist/modules/movethewheels/index.cjs +78 -78
- package/dist/modules/movethewheels/index.d.cts +1 -1
- package/dist/modules/movethewheels/index.d.ts +1 -1
- package/dist/modules/movethewheels/index.js +2 -2
- package/dist/modules/mybodyshield/index.cjs +36 -36
- package/dist/modules/mybodyshield/index.d.cts +1 -1
- package/dist/modules/mybodyshield/index.d.ts +1 -1
- package/dist/modules/mybodyshield/index.js +2 -2
- package/dist/modules/notifications/index.cjs +5 -5
- package/dist/modules/notifications/index.d.cts +1 -1
- package/dist/modules/notifications/index.d.ts +1 -1
- package/dist/modules/notifications/index.js +1 -1
- package/dist/modules/organizations/index.cjs +5 -5
- package/dist/modules/organizations/index.d.cts +1 -1
- package/dist/modules/organizations/index.d.ts +1 -1
- package/dist/modules/organizations/index.js +1 -1
- package/dist/modules/planmagnet/index.cjs +272 -272
- package/dist/modules/planmagnet/index.d.cts +1 -1
- package/dist/modules/planmagnet/index.d.ts +1 -1
- package/dist/modules/planmagnet/index.js +2 -2
- package/dist/modules/products/index.cjs +19 -19
- package/dist/modules/products/index.d.cts +1 -1
- package/dist/modules/products/index.d.ts +1 -1
- package/dist/modules/products/index.js +2 -2
- package/dist/modules/proserviceworld/index.cjs +24 -24
- package/dist/modules/proserviceworld/index.d.cts +1 -1
- package/dist/modules/proserviceworld/index.d.ts +1 -1
- package/dist/modules/proserviceworld/index.js +2 -2
- package/dist/modules/rbac/index.cjs +8 -8
- package/dist/modules/rbac/index.d.cts +1 -1
- package/dist/modules/rbac/index.d.ts +1 -1
- package/dist/modules/rbac/index.js +2 -2
- package/dist/modules/sandbox/index.cjs +39 -39
- package/dist/modules/sandbox/index.d.cts +1 -1
- package/dist/modules/sandbox/index.d.ts +1 -1
- package/dist/modules/sandbox/index.js +1 -1
- package/dist/modules/scheduler/index.cjs +25 -25
- package/dist/modules/scheduler/index.d.cts +1 -1
- package/dist/modules/scheduler/index.d.ts +1 -1
- package/dist/modules/scheduler/index.js +2 -2
- package/dist/modules/security/index.cjs +14 -14
- package/dist/modules/security/index.d.cts +1 -1
- package/dist/modules/security/index.d.ts +1 -1
- package/dist/modules/security/index.js +2 -2
- package/dist/modules/semanticfed/index.cjs +44 -44
- package/dist/modules/semanticfed/index.d.cts +1 -1
- package/dist/modules/semanticfed/index.d.ts +1 -1
- package/dist/modules/semanticfed/index.js +1 -1
- package/dist/modules/semanticfed-sql/index.cjs +4 -4
- package/dist/modules/semanticfed-sql/index.d.cts +1 -1
- package/dist/modules/semanticfed-sql/index.d.ts +1 -1
- package/dist/modules/semanticfed-sql/index.js +1 -1
- package/dist/modules/store/index.cjs +21 -21
- package/dist/modules/store/index.d.cts +1 -1
- package/dist/modules/store/index.d.ts +1 -1
- package/dist/modules/store/index.js +2 -2
- package/dist/modules/subscriberbot/index.cjs +41 -41
- package/dist/modules/subscriberbot/index.d.cts +1 -1
- package/dist/modules/subscriberbot/index.d.ts +1 -1
- package/dist/modules/subscriberbot/index.js +2 -2
- package/dist/modules/support/index.cjs +8 -8
- package/dist/modules/support/index.d.cts +1 -1
- package/dist/modules/support/index.d.ts +1 -1
- package/dist/modules/support/index.js +2 -2
- package/dist/modules/tags/index.cjs +10 -10
- package/dist/modules/tags/index.d.cts +1 -1
- package/dist/modules/tags/index.d.ts +1 -1
- package/dist/modules/tags/index.js +2 -2
- package/dist/modules/technospam/index.cjs +44 -44
- package/dist/modules/technospam/index.d.cts +1 -1
- package/dist/modules/technospam/index.d.ts +1 -1
- package/dist/modules/technospam/index.js +2 -2
- package/dist/modules/theculturepost/index.cjs +32 -32
- package/dist/modules/theculturepost/index.d.cts +1 -1
- package/dist/modules/theculturepost/index.d.ts +1 -1
- package/dist/modules/theculturepost/index.js +2 -2
- package/dist/modules/theglobalfuel/index.cjs +30 -30
- package/dist/modules/theglobalfuel/index.d.cts +1 -1
- package/dist/modules/theglobalfuel/index.d.ts +1 -1
- package/dist/modules/theglobalfuel/index.js +2 -2
- package/dist/modules/timecampus/index.cjs +69 -69
- package/dist/modules/timecampus/index.d.cts +1 -1
- package/dist/modules/timecampus/index.d.ts +1 -1
- package/dist/modules/timecampus/index.js +4 -4
- package/dist/modules/tours/index.cjs +4 -4
- package/dist/modules/tours/index.d.cts +1 -1
- package/dist/modules/tours/index.d.ts +1 -1
- package/dist/modules/tours/index.js +2 -2
- package/dist/modules/vibecontrols/index.cjs +460 -460
- package/dist/modules/vibecontrols/index.d.cts +1 -1
- package/dist/modules/vibecontrols/index.d.ts +1 -1
- package/dist/modules/vibecontrols/index.js +5 -5
- package/dist/modules/workspaces/index.cjs +16 -16
- package/dist/modules/workspaces/index.d.cts +1 -1
- package/dist/modules/workspaces/index.d.ts +1 -1
- package/dist/modules/workspaces/index.js +2 -2
- package/package.json +6 -1
- package/dist/chunk-3ZVMC2AF.js +0 -1
- package/dist/chunk-ZT6KOG7N.js +0 -34
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {a,b as b$1,i,r,h,k as k$1,d}from'../../chunk-
|
|
1
|
+
import {a,b as b$1,i,r,h,k as k$1,d}from'../../chunk-BGNPGKJM.js';import {j as j$1}from'../../chunk-N7EXKGE2.js';var y=`
|
|
2
2
|
query AthListTeams(
|
|
3
3
|
$pagination: PaginationInput
|
|
4
4
|
$sport: AthSport
|
|
@@ -287,4 +287,4 @@ import {a,b as b$1,i,r,h,k as k$1,d}from'../../chunk-3ZVMC2AF.js';import {q as q
|
|
|
287
287
|
query AthHealth {
|
|
288
288
|
athHealth
|
|
289
289
|
}
|
|
290
|
-
`;function Z(d,r){try{return JSON.parse(r)}catch{throw new q$1(`--${d} must be valid JSON`)}}function m(d){let r=Number.parseInt(d,10);if(Number.isNaN(r))throw new q$1(`Expected an integer but got "${d}"`);return r}function l(d){let r=Number.parseFloat(d);if(Number.isNaN(r))throw new q$1(`Expected a number but got "${d}"`);return r}function I(d){return d.split(",").map(r=>r.trim()).filter(r=>r.length>0)}function tt(d){let r$1=d.command("teams").description("AtheleteBridge teams");r$1.command("list").description("List teams").option("--sport <s>","Filter by sport").option("--status <s>","Filter by team status").option("--limit <n>","Page size",m,50).option("--offset <n>","Offset",m,0).option("-f, --format <format>","Output format").action(async o=>{try{let t=await b$1(y,{pagination:{limit:o.limit,offset:o.offset},sport:o.sport?o.sport.toUpperCase():void 0,status:o.status?o.status.toUpperCase():void 0});i(o,t.athListTeams.items,{headers:["ID","Name","Sport","Status","Season"],rows:t.athListTeams.items.map(e=>[r(e.id,12),e.name,e.sport,e.status,e.season??"-"])});}catch(t){h(t);}}),r$1.command("get").description("Get a team by id").argument("<id>","Team ID").option("-f, --format <format>","Output format").action(async(o,t)=>{try{let e=await b$1(w,{id:o});if(!e.athTeam)throw new q$1(`Team ${o} not found`);i(t,e.athTeam);}catch(e){h(e);}}),r$1.command("create").description("Create a team").requiredOption("--name <name>","Team name").option("--description <s>","Description").option("--sport <s>","Sport","OTHER").option("--status <s>","Team status","FORMING").option("--season <s>","Season").option("--age-group <s>","Age group").option("--home-venue <s>","Home venue").option("--head-coach-id <id>","Head coach user ID").option("--tags <csv>","Comma-separated tags").option("-f, --format <format>","Output format").action(async o=>{try{let t={name:o.name,sport:(o.sport??"OTHER").toUpperCase(),status:(o.status??"FORMING").toUpperCase()};o.description&&(t.description=o.description),o.season&&(t.season=o.season),o.ageGroup&&(t.ageGroup=o.ageGroup),o.homeVenue&&(t.homeVenue=o.homeVenue),o.headCoachId&&(t.headCoachId=o.headCoachId),o.tags&&(t.tags=I(o.tags));let e=await b$1(b,{input:t});k$1(`Team created: ${e.athCreateTeam.name}`),i(o,e.athCreateTeam);}catch(t){h(t);}}),r$1.command("update").description("Update a team").argument("<id>","Team ID").option("--name <name>","Team name").option("--description <s>","Description").option("--sport <s>","Sport").option("--status <s>","Team status").option("--season <s>","Season").option("--age-group <s>","Age group").option("--home-venue <s>","Home venue").option("--head-coach-id <id>","Head coach user ID").option("--tags <csv>","Comma-separated tags").option("-f, --format <format>","Output format").action(async(o,t)=>{try{let e={};if(t.name&&(e.name=t.name),t.description!==void 0&&(e.description=t.description),t.sport&&(e.sport=t.sport.toUpperCase()),t.status&&(e.status=t.status.toUpperCase()),t.season&&(e.season=t.season),t.ageGroup&&(e.ageGroup=t.ageGroup),t.homeVenue&&(e.homeVenue=t.homeVenue),t.headCoachId&&(e.headCoachId=t.headCoachId),t.tags&&(e.tags=I(t.tags)),!Object.keys(e).length)throw new q$1("No updates specified");let i$1=await b$1(R,{id:o,input:e});k$1("Team updated"),i(t,i$1.athUpdateTeam);}catch(e){h(e);}}),r$1.command("archive").description("Archive a team").argument("<id>","Team ID").option("-f, --format <format>","Output format").action(async(o,t)=>{try{let e=await b$1(C,{id:o});k$1(e.athArchiveTeam?`Team ${o} archived`:`Team ${o} not archived`),i(t,{archived:e.athArchiveTeam});}catch(e){h(e);}});}function et(d){let r$1=d.command("members").description("AtheleteBridge team members");r$1.command("list").description("List members of a team").requiredOption("--team <id>","Team ID").option("--status <s>","Filter by member status").option("-f, --format <format>","Output format").action(async o=>{try{let t=await b$1(T,{teamId:o.team,status:o.status?o.status.toUpperCase():void 0});i(o,t.athListMembers.items,{headers:["ID","Name","Role","Status","Jersey","Position"],rows:t.athListMembers.items.map(e=>[r(e.id,12),e.displayName,e.role,e.status,e.jerseyNumber!==void 0&&e.jerseyNumber!==null?String(e.jerseyNumber):"-",e.position??"-"])});}catch(t){h(t);}}),r$1.command("add").description("Add a member to a team").requiredOption("--team <id>","Team ID").requiredOption("--user <id>","User ID").requiredOption("--display-name <name>","Display name").option("--role <r>","Member role","PLAYER").option("--status <s>","Member status","ACTIVE").option("--jersey-number <n>","Jersey number",m).option("--position <s>","Position").option("--dominant-side <s>","Dominant side").option("--height <n>","Height",l).option("--weight <n>","Weight",l).option("--joined-at <iso>","Joined at (ISO timestamp)").option("--notes <s>","Notes").option("-f, --format <format>","Output format").action(async o=>{try{let t={teamId:o.team,userId:o.user,displayName:o.displayName,role:(o.role??"PLAYER").toUpperCase(),status:(o.status??"ACTIVE").toUpperCase()};o.jerseyNumber!==void 0&&(t.jerseyNumber=o.jerseyNumber),o.position&&(t.position=o.position),o.dominantSide&&(t.dominantSide=o.dominantSide),o.height!==void 0&&(t.height=o.height),o.weight!==void 0&&(t.weight=o.weight),o.joinedAt&&(t.joinedAt=o.joinedAt),o.notes&&(t.notes=o.notes);let e=await b$1(k,{input:t});k$1(`Member added: ${e.athAddMember.displayName}`),i(o,e.athAddMember);}catch(t){h(t);}}),r$1.command("update").description("Update a team member").argument("<id>","Member ID").option("--display-name <name>","Display name").option("--role <r>","Member role").option("--status <s>","Member status").option("--jersey-number <n>","Jersey number",m).option("--position <s>","Position").option("--dominant-side <s>","Dominant side").option("--height <n>","Height",l).option("--weight <n>","Weight",l).option("--notes <s>","Notes").option("-f, --format <format>","Output format").action(async(o,t)=>{try{let e={};if(t.displayName&&(e.displayName=t.displayName),t.role&&(e.role=t.role.toUpperCase()),t.status&&(e.status=t.status.toUpperCase()),t.jerseyNumber!==void 0&&(e.jerseyNumber=t.jerseyNumber),t.position&&(e.position=t.position),t.dominantSide&&(e.dominantSide=t.dominantSide),t.height!==void 0&&(e.height=t.height),t.weight!==void 0&&(e.weight=t.weight),t.notes!==void 0&&(e.notes=t.notes),!Object.keys(e).length)throw new q$1("No updates specified");let i$1=await b$1(O,{id:o,input:e});k$1("Member updated"),i(t,i$1.athUpdateMember);}catch(e){h(e);}}),r$1.command("remove").description("Remove a team member").argument("<id>","Member ID").option("-f, --format <format>","Output format").action(async(o,t)=>{try{let e=await b$1(M,{id:o});k$1(e.athRemoveMember?`Member ${o} removed`:`Member ${o} not removed`),i(t,{removed:e.athRemoveMember});}catch(e){h(e);}});}function ot(d){let r$1=d.command("programs").description("AtheleteBridge training programs");r$1.command("list").description("List training programs").option("--level <l>","Filter by program level").option("--sport <s>","Filter by sport").option("--status <s>","Filter by program status").option("--limit <n>","Page size",m,50).option("--offset <n>","Offset",m,0).option("-f, --format <format>","Output format").action(async t=>{try{let e=await b$1(E,{pagination:{limit:t.limit,offset:t.offset},level:t.level?t.level.toUpperCase():void 0,sport:t.sport?t.sport.toUpperCase():void 0,status:t.status?t.status.toUpperCase():void 0});i(t,e.athListPrograms.items,{headers:["ID","Name","Sport","Level","Status","Weeks"],rows:e.athListPrograms.items.map(i=>[r(i.id,12),i.name,i.sport,i.level,i.status,i.weeks!==void 0&&i.weeks!==null?String(i.weeks):"-"])});}catch(e){h(e);}}),r$1.command("get").description("Get a training program by id").argument("<id>","Program ID").option("-f, --format <format>","Output format").action(async(t,e)=>{try{let i$1=await b$1($,{id:t});if(!i$1.athProgram)throw new q$1(`Program ${t} not found`);i(e,i$1.athProgram);}catch(i){h(i);}}),r$1.command("create").description("Create a training program").requiredOption("--name <name>","Program name").option("--summary <s>","Summary").option("--sport <s>","Sport","OTHER").option("--level <l>","Level","BEGINNER").option("--weeks <n>","Number of weeks",m).option("--template","Mark as a template").option("--tags <csv>","Comma-separated tags").option("-f, --format <format>","Output format").action(async t=>{try{let e={name:t.name,sport:(t.sport??"OTHER").toUpperCase(),level:(t.level??"BEGINNER").toUpperCase(),isTemplate:!!t.template};t.summary&&(e.summary=t.summary),t.weeks!==void 0&&(e.weeks=t.weeks),t.tags&&(e.tags=I(t.tags));let i$1=await b$1(D,{input:e});k$1(`Program created: ${i$1.athCreateProgram.name}`),i(t,i$1.athCreateProgram);}catch(e){h(e);}}),r$1.command("update").description("Update a training program").argument("<id>","Program ID").option("--name <name>","Program name").option("--summary <s>","Summary").option("--sport <s>","Sport").option("--level <l>","Level").option("--weeks <n>","Number of weeks",m).option("--template <bool>","Template flag (true|false)").option("--tags <csv>","Comma-separated tags").option("-f, --format <format>","Output format").action(async(t,e)=>{try{let i$1={};if(e.name&&(i$1.name=e.name),e.summary!==void 0&&(i$1.summary=e.summary),e.sport&&(i$1.sport=e.sport.toUpperCase()),e.level&&(i$1.level=e.level.toUpperCase()),e.weeks!==void 0&&(i$1.weeks=e.weeks),e.template!==void 0&&(i$1.isTemplate=e.template==="true"),e.tags&&(i$1.tags=I(e.tags)),!Object.keys(i$1).length)throw new q$1("No updates specified");let dt=await b$1(L,{id:t,input:i$1});k$1("Program updated"),i(e,dt.athUpdateProgram);}catch(i){h(i);}}),r$1.command("transition").description("Advance a program through its publish lifecycle (DRAFT -> PUBLISHED -> ARCHIVED)").argument("<id>","Program ID").requiredOption("--status <s>","Target status: DRAFT|PUBLISHED|ARCHIVED").option("-f, --format <format>","Output format").action(async(t,e)=>{try{let i$1=await b$1(v,{id:t,status:e.status.toUpperCase()});k$1(`Program transitioned to ${i$1.athTransitionProgram.status}`),i(e,i$1.athTransitionProgram);}catch(i){h(i);}}),r$1.command("archive").description("Archive a training program").argument("<id>","Program ID").option("-f, --format <format>","Output format").action(async(t,e)=>{try{let i$1=await b$1(P,{id:t});k$1(i$1.athArchiveProgram?`Program ${t} archived`:`Program ${t} not archived`),i(e,{archived:i$1.athArchiveProgram});}catch(i){h(i);}});let o=r$1.command("drills").description("AtheleteBridge program drills");o.command("add").description("Add a drill to a program").requiredOption("--program <id>","Program ID").requiredOption("--name <name>","Drill name").option("--description <s>","Description").option("--week-number <n>","Week number",m,1).option("--order-index <n>","Order index",m,0).option("--sets <n>","Sets",m).option("--reps <n>","Reps",m).option("--duration-sec <n>","Duration (seconds)",m).option("--rest-sec <n>","Rest (seconds)",m).option("--video-file-id <id>","Video file ID (wspace-files-svc)").option("-f, --format <format>","Output format").action(async t=>{try{let e={programId:t.program,name:t.name,weekNumber:t.weekNumber??1,orderIndex:t.orderIndex??0};t.description&&(e.description=t.description),t.sets!==void 0&&(e.sets=t.sets),t.reps!==void 0&&(e.reps=t.reps),t.durationSec!==void 0&&(e.durationSec=t.durationSec),t.restSec!==void 0&&(e.restSec=t.restSec),t.videoFileId&&(e.videoFileId=t.videoFileId);let i$1=await b$1(x,{input:e});k$1(`Drill added: ${i$1.athAddDrill.name}`),i(t,i$1.athAddDrill);}catch(e){h(e);}}),o.command("remove").description("Remove a drill").argument("<id>","Drill ID").option("-f, --format <format>","Output format").action(async(t,e)=>{try{let i$1=await b$1(N,{id:t});k$1(i$1.athRemoveDrill?`Drill ${t} removed`:`Drill ${t} not removed`),i(e,{removed:i$1.athRemoveDrill});}catch(i){h(i);}});}function rt(d){let r$1=d.command("sessions").description("AtheleteBridge coaching sessions");r$1.command("list").description("List sessions").option("--athlete <id>","Filter by athlete ID").option("--coach <id>","Filter by coach ID").option("--status <s>","Filter by session status").option("--limit <n>","Page size",m,50).option("--offset <n>","Offset",m,0).option("-f, --format <format>","Output format").action(async o=>{try{let t=await b$1(U,{pagination:{limit:o.limit,offset:o.offset},athleteId:o.athlete,coachId:o.coach,status:o.status?o.status.toUpperCase():void 0});i(o,t.athListSessions.items,{headers:["ID","Title","Type","Status","Scheduled"],rows:t.athListSessions.items.map(e=>[r(e.id,12),e.title,e.type,e.status,e.scheduledAt])});}catch(t){h(t);}}),r$1.command("get").description("Get a session by id").argument("<id>","Session ID").option("-f, --format <format>","Output format").action(async(o,t)=>{try{let e=await b$1(F,{id:o});if(!e.athSession)throw new q$1(`Session ${o} not found`);i(t,e.athSession);}catch(e){h(e);}}),r$1.command("book").description("Book a coaching session").requiredOption("--athlete <id>","Athlete ID").requiredOption("--coach <id>","Coach ID").requiredOption("--title <s>","Session title").requiredOption("--scheduled-at <iso>","Scheduled at (ISO timestamp)").option("--type <t>","Session type","IN_PERSON").option("--duration-min <n>","Duration (minutes)",m).option("--location <s>","Location").option("--meeting-url <url>","Meeting URL").option("--program <id>","Program ID").option("-f, --format <format>","Output format").action(async o=>{try{let t={athleteId:o.athlete,coachId:o.coach,title:o.title,scheduledAt:o.scheduledAt,type:(o.type??"IN_PERSON").toUpperCase()};o.durationMin!==void 0&&(t.durationMin=o.durationMin),o.location&&(t.location=o.location),o.meetingUrl&&(t.meetingUrl=o.meetingUrl),o.program&&(t.programId=o.program);let e=await b$1(_,{input:t});k$1(`Session booked: ${e.athBookSession.title}`),i(o,e.athBookSession);}catch(t){h(t);}}),r$1.command("confirm").description("Confirm a requested session").argument("<id>","Session ID").option("-f, --format <format>","Output format").action(async(o,t)=>{try{let e=await b$1(G,{id:o});k$1(`Session confirmed: ${e.athConfirmSession.status}`),i(t,e.athConfirmSession);}catch(e){h(e);}}),r$1.command("cancel").description("Cancel a session").argument("<id>","Session ID").option("-f, --format <format>","Output format").action(async(o,t)=>{try{let e=await b$1(W,{id:o});k$1(`Session cancelled: ${e.athCancelSession.status}`),i(t,e.athCancelSession);}catch(e){h(e);}}),r$1.command("complete").description("Complete a session (optionally with rating and feedback)").argument("<id>","Session ID").option("--rating <n>","Rating",m).option("--feedback <s>","Feedback").option("-f, --format <format>","Output format").action(async(o,t)=>{try{let e={};t.rating!==void 0&&(e.rating=t.rating),t.feedback&&(e.feedback=t.feedback);let i$1=await b$1(q,{id:o,input:Object.keys(e).length?e:void 0});k$1(`Session completed: ${i$1.athCompleteSession.status}`),i(t,i$1.athCompleteSession);}catch(e){h(e);}});}function it(d){let r$1=d.command("workouts").description("AtheleteBridge workout logs");r$1.command("list").description("List workout logs").option("--athlete <id>","Filter by athlete ID").option("--program <id>","Filter by program ID").option("--limit <n>","Page size",m,50).option("--offset <n>","Offset",m,0).option("-f, --format <format>","Output format").action(async o=>{try{let t=await b$1(B,{pagination:{limit:o.limit,offset:o.offset},athleteId:o.athlete,programId:o.program});i(o,t.athListWorkoutLogs.items,{headers:["ID","Title","Status","Performed","Load","RPE"],rows:t.athListWorkoutLogs.items.map(e=>[r(e.id,12),e.title,e.status,e.performedAt,e.totalLoad!==void 0&&e.totalLoad!==null?String(e.totalLoad):"-",e.rpe!==void 0&&e.rpe!==null?String(e.rpe):"-"])});}catch(t){h(t);}}),r$1.command("log").description("Log a workout").requiredOption("--title <s>","Workout title").requiredOption("--performed-at <iso>","Performed at (ISO timestamp)").option("--athlete <id>","Athlete ID").option("--program <id>","Program ID").option("--status <s>","Workout status","COMPLETED").option("--duration-min <n>","Duration (minutes)",m).option("--total-load <n>","Total load",l).option("--rpe <n>","Rate of perceived exertion",m).option("--notes <s>","Notes").option("--metrics <json>","Metrics JSON object").option("-f, --format <format>","Output format").action(async o=>{try{let t={title:o.title,performedAt:o.performedAt,status:(o.status??"COMPLETED").toUpperCase()};o.athlete&&(t.athleteId=o.athlete),o.program&&(t.programId=o.program),o.durationMin!==void 0&&(t.durationMin=o.durationMin),o.totalLoad!==void 0&&(t.totalLoad=o.totalLoad),o.rpe!==void 0&&(t.rpe=o.rpe),o.notes&&(t.notes=o.notes),o.metrics&&(t.metrics=Z("metrics",o.metrics));let e=await b$1(H,{input:t});k$1(`Workout logged: ${e.athLogWorkout.title}`),i(o,e.athLogWorkout);}catch(t){h(t);}});}function at(d){let r$1=d.command("metrics").description("AtheleteBridge performance metrics");r$1.command("list").description("List performance metrics for an athlete").requiredOption("--athlete <id>","Athlete ID").option("--type <t>","Filter by metric type").option("-f, --format <format>","Output format").action(async o=>{try{let t=await b$1(j,{athleteId:o.athlete,type:o.type?o.type.toUpperCase():void 0});i(o,t.athPerformanceMetrics.items,{headers:["ID","Label","Type","Value","Unit","Recorded"],rows:t.athPerformanceMetrics.items.map(e=>[r(e.id,12),e.label,e.type,String(e.value),e.unit??"-",e.recordedAt])});}catch(t){h(t);}}),r$1.command("record").description("Record a performance metric").requiredOption("--label <s>","Metric label").requiredOption("--value <n>","Metric value",l).requiredOption("--recorded-at <iso>","Recorded at (ISO timestamp)").option("--athlete <id>","Athlete ID").option("--type <t>","Metric type","CUSTOM").option("--unit <s>","Unit").option("--source <s>","Source").option("-f, --format <format>","Output format").action(async o=>{try{let t={label:o.label,value:o.value,recordedAt:o.recordedAt,type:(o.type??"CUSTOM").toUpperCase()};o.athlete&&(t.athleteId=o.athlete),o.unit&&(t.unit=o.unit),o.source&&(t.source=o.source);let e=await b$1(V,{input:t});k$1(`Metric recorded: ${e.athRecordMetric.label}`),i(o,e.athRecordMetric);}catch(t){h(t);}});}function nt(d){let r$1=d.command("fixtures").description("AtheleteBridge fixtures");r$1.command("list").description("List fixtures").option("--team <id>","Filter by team ID").option("--status <s>","Filter by fixture status").option("--limit <n>","Page size",m,50).option("--offset <n>","Offset",m,0).option("-f, --format <format>","Output format").action(async o=>{try{let t=await b$1(J,{pagination:{limit:o.limit,offset:o.offset},status:o.status?o.status.toUpperCase():void 0,teamId:o.team});i(o,t.athListFixtures.items,{headers:["ID","Type","Status","Competition","Scheduled","Score"],rows:t.athListFixtures.items.map(e=>[r(e.id,12),e.type,e.status,e.competition??"-",e.scheduledAt,e.homeScore!==void 0&&e.homeScore!==null&&e.awayScore!==void 0&&e.awayScore!==null?`${e.homeScore}-${e.awayScore}`:"-"])});}catch(t){h(t);}}),r$1.command("get").description("Get a fixture by id").argument("<id>","Fixture ID").option("-f, --format <format>","Output format").action(async(o,t)=>{try{let e=await b$1(X,{id:o});if(!e.athFixture)throw new q$1(`Fixture ${o} not found`);i(t,e.athFixture);}catch(e){h(e);}}),r$1.command("schedule").description("Schedule a fixture").requiredOption("--home-team <id>","Home team ID").requiredOption("--scheduled-at <iso>","Scheduled at (ISO timestamp)").option("--away-team <id>","Away team ID").option("--type <t>","Fixture type","FRIENDLY").option("--competition <s>","Competition").option("--round <s>","Round").option("--kickoff-at <iso>","Kickoff at (ISO timestamp)").option("--venue <s>","Venue").option("--notes <s>","Notes").option("-f, --format <format>","Output format").action(async o=>{try{let t={homeTeamId:o.homeTeam,scheduledAt:o.scheduledAt,type:(o.type??"FRIENDLY").toUpperCase()};o.awayTeam&&(t.awayTeamId=o.awayTeam),o.competition&&(t.competition=o.competition),o.round&&(t.round=o.round),o.kickoffAt&&(t.kickoffAt=o.kickoffAt),o.venue&&(t.venue=o.venue),o.notes&&(t.notes=o.notes);let e=await b$1(K,{input:t});k$1(`Fixture scheduled: ${e.athScheduleFixture.id}`),i(o,e.athScheduleFixture);}catch(t){h(t);}}),r$1.command("record-result").description("Record a final result for a fixture and recompute standings").argument("<id>","Fixture ID").requiredOption("--home-score <n>","Home score",m).requiredOption("--away-score <n>","Away score",m).option("-f, --format <format>","Output format").action(async(o,t)=>{try{let e=await b$1(z,{id:o,input:{homeScore:t.homeScore,awayScore:t.awayScore}});k$1(`Result recorded: ${e.athRecordFixtureResult.homeScore??0}-${e.athRecordFixtureResult.awayScore??0}`),i(t,e.athRecordFixtureResult);}catch(e){h(e);}});}function st(d){d.command("standings").description("AtheleteBridge standings").command("list").description("List standings for a competition").requiredOption("--competition <s>","Competition name").option("-f, --format <format>","Output format").action(async o=>{try{let t=await b$1(Y,{competition:o.competition});i(o,t.athStandings.items,{headers:["Rank","Team","P","W","D","L","Pts"],rows:t.athStandings.items.map(e=>[e.rank!==void 0&&e.rank!==null?String(e.rank):"-",r(e.teamId,12),String(e.played),String(e.won),String(e.drawn),String(e.lost),String(e.points)])});}catch(t){h(t);}});}function mt(d$1){d$1.command("health").description("AtheleteBridge service health check (public)").option("-f, --format <format>","Output format").action(async r=>{try{let o=await d(Q);k$1(o.athHealth),i(r,{health:o.athHealth});}catch(o){h(o);}});}var pt={id:"atheletebridge",version:"1.0.0",displayName:"AtheleteBridge",dependsOn:["auth","workspaces"],register(d,r){a(r);let o=d.command("atheletebridge").description("AtheleteBridge sports team & athlete management");tt(o),et(o),ot(o),rt(o),it(o),at(o),nt(o),st(o),mt(o);}},Vt=pt;export{Vt as default};
|
|
290
|
+
`;function Z(d,r){try{return JSON.parse(r)}catch{throw new j$1(`--${d} must be valid JSON`)}}function m(d){let r=Number.parseInt(d,10);if(Number.isNaN(r))throw new j$1(`Expected an integer but got "${d}"`);return r}function l(d){let r=Number.parseFloat(d);if(Number.isNaN(r))throw new j$1(`Expected a number but got "${d}"`);return r}function I(d){return d.split(",").map(r=>r.trim()).filter(r=>r.length>0)}function tt(d){let r$1=d.command("teams").description("AtheleteBridge teams");r$1.command("list").description("List teams").option("--sport <s>","Filter by sport").option("--status <s>","Filter by team status").option("--limit <n>","Page size",m,50).option("--offset <n>","Offset",m,0).option("-f, --format <format>","Output format").action(async o=>{try{let t=await b$1(y,{pagination:{limit:o.limit,offset:o.offset},sport:o.sport?o.sport.toUpperCase():void 0,status:o.status?o.status.toUpperCase():void 0});i(o,t.athListTeams.items,{headers:["ID","Name","Sport","Status","Season"],rows:t.athListTeams.items.map(e=>[r(e.id,12),e.name,e.sport,e.status,e.season??"-"])});}catch(t){h(t);}}),r$1.command("get").description("Get a team by id").argument("<id>","Team ID").option("-f, --format <format>","Output format").action(async(o,t)=>{try{let e=await b$1(w,{id:o});if(!e.athTeam)throw new j$1(`Team ${o} not found`);i(t,e.athTeam);}catch(e){h(e);}}),r$1.command("create").description("Create a team").requiredOption("--name <name>","Team name").option("--description <s>","Description").option("--sport <s>","Sport","OTHER").option("--status <s>","Team status","FORMING").option("--season <s>","Season").option("--age-group <s>","Age group").option("--home-venue <s>","Home venue").option("--head-coach-id <id>","Head coach user ID").option("--tags <csv>","Comma-separated tags").option("-f, --format <format>","Output format").action(async o=>{try{let t={name:o.name,sport:(o.sport??"OTHER").toUpperCase(),status:(o.status??"FORMING").toUpperCase()};o.description&&(t.description=o.description),o.season&&(t.season=o.season),o.ageGroup&&(t.ageGroup=o.ageGroup),o.homeVenue&&(t.homeVenue=o.homeVenue),o.headCoachId&&(t.headCoachId=o.headCoachId),o.tags&&(t.tags=I(o.tags));let e=await b$1(b,{input:t});k$1(`Team created: ${e.athCreateTeam.name}`),i(o,e.athCreateTeam);}catch(t){h(t);}}),r$1.command("update").description("Update a team").argument("<id>","Team ID").option("--name <name>","Team name").option("--description <s>","Description").option("--sport <s>","Sport").option("--status <s>","Team status").option("--season <s>","Season").option("--age-group <s>","Age group").option("--home-venue <s>","Home venue").option("--head-coach-id <id>","Head coach user ID").option("--tags <csv>","Comma-separated tags").option("-f, --format <format>","Output format").action(async(o,t)=>{try{let e={};if(t.name&&(e.name=t.name),t.description!==void 0&&(e.description=t.description),t.sport&&(e.sport=t.sport.toUpperCase()),t.status&&(e.status=t.status.toUpperCase()),t.season&&(e.season=t.season),t.ageGroup&&(e.ageGroup=t.ageGroup),t.homeVenue&&(e.homeVenue=t.homeVenue),t.headCoachId&&(e.headCoachId=t.headCoachId),t.tags&&(e.tags=I(t.tags)),!Object.keys(e).length)throw new j$1("No updates specified");let i$1=await b$1(R,{id:o,input:e});k$1("Team updated"),i(t,i$1.athUpdateTeam);}catch(e){h(e);}}),r$1.command("archive").description("Archive a team").argument("<id>","Team ID").option("-f, --format <format>","Output format").action(async(o,t)=>{try{let e=await b$1(C,{id:o});k$1(e.athArchiveTeam?`Team ${o} archived`:`Team ${o} not archived`),i(t,{archived:e.athArchiveTeam});}catch(e){h(e);}});}function et(d){let r$1=d.command("members").description("AtheleteBridge team members");r$1.command("list").description("List members of a team").requiredOption("--team <id>","Team ID").option("--status <s>","Filter by member status").option("-f, --format <format>","Output format").action(async o=>{try{let t=await b$1(T,{teamId:o.team,status:o.status?o.status.toUpperCase():void 0});i(o,t.athListMembers.items,{headers:["ID","Name","Role","Status","Jersey","Position"],rows:t.athListMembers.items.map(e=>[r(e.id,12),e.displayName,e.role,e.status,e.jerseyNumber!==void 0&&e.jerseyNumber!==null?String(e.jerseyNumber):"-",e.position??"-"])});}catch(t){h(t);}}),r$1.command("add").description("Add a member to a team").requiredOption("--team <id>","Team ID").requiredOption("--user <id>","User ID").requiredOption("--display-name <name>","Display name").option("--role <r>","Member role","PLAYER").option("--status <s>","Member status","ACTIVE").option("--jersey-number <n>","Jersey number",m).option("--position <s>","Position").option("--dominant-side <s>","Dominant side").option("--height <n>","Height",l).option("--weight <n>","Weight",l).option("--joined-at <iso>","Joined at (ISO timestamp)").option("--notes <s>","Notes").option("-f, --format <format>","Output format").action(async o=>{try{let t={teamId:o.team,userId:o.user,displayName:o.displayName,role:(o.role??"PLAYER").toUpperCase(),status:(o.status??"ACTIVE").toUpperCase()};o.jerseyNumber!==void 0&&(t.jerseyNumber=o.jerseyNumber),o.position&&(t.position=o.position),o.dominantSide&&(t.dominantSide=o.dominantSide),o.height!==void 0&&(t.height=o.height),o.weight!==void 0&&(t.weight=o.weight),o.joinedAt&&(t.joinedAt=o.joinedAt),o.notes&&(t.notes=o.notes);let e=await b$1(k,{input:t});k$1(`Member added: ${e.athAddMember.displayName}`),i(o,e.athAddMember);}catch(t){h(t);}}),r$1.command("update").description("Update a team member").argument("<id>","Member ID").option("--display-name <name>","Display name").option("--role <r>","Member role").option("--status <s>","Member status").option("--jersey-number <n>","Jersey number",m).option("--position <s>","Position").option("--dominant-side <s>","Dominant side").option("--height <n>","Height",l).option("--weight <n>","Weight",l).option("--notes <s>","Notes").option("-f, --format <format>","Output format").action(async(o,t)=>{try{let e={};if(t.displayName&&(e.displayName=t.displayName),t.role&&(e.role=t.role.toUpperCase()),t.status&&(e.status=t.status.toUpperCase()),t.jerseyNumber!==void 0&&(e.jerseyNumber=t.jerseyNumber),t.position&&(e.position=t.position),t.dominantSide&&(e.dominantSide=t.dominantSide),t.height!==void 0&&(e.height=t.height),t.weight!==void 0&&(e.weight=t.weight),t.notes!==void 0&&(e.notes=t.notes),!Object.keys(e).length)throw new j$1("No updates specified");let i$1=await b$1(O,{id:o,input:e});k$1("Member updated"),i(t,i$1.athUpdateMember);}catch(e){h(e);}}),r$1.command("remove").description("Remove a team member").argument("<id>","Member ID").option("-f, --format <format>","Output format").action(async(o,t)=>{try{let e=await b$1(M,{id:o});k$1(e.athRemoveMember?`Member ${o} removed`:`Member ${o} not removed`),i(t,{removed:e.athRemoveMember});}catch(e){h(e);}});}function ot(d){let r$1=d.command("programs").description("AtheleteBridge training programs");r$1.command("list").description("List training programs").option("--level <l>","Filter by program level").option("--sport <s>","Filter by sport").option("--status <s>","Filter by program status").option("--limit <n>","Page size",m,50).option("--offset <n>","Offset",m,0).option("-f, --format <format>","Output format").action(async t=>{try{let e=await b$1(E,{pagination:{limit:t.limit,offset:t.offset},level:t.level?t.level.toUpperCase():void 0,sport:t.sport?t.sport.toUpperCase():void 0,status:t.status?t.status.toUpperCase():void 0});i(t,e.athListPrograms.items,{headers:["ID","Name","Sport","Level","Status","Weeks"],rows:e.athListPrograms.items.map(i=>[r(i.id,12),i.name,i.sport,i.level,i.status,i.weeks!==void 0&&i.weeks!==null?String(i.weeks):"-"])});}catch(e){h(e);}}),r$1.command("get").description("Get a training program by id").argument("<id>","Program ID").option("-f, --format <format>","Output format").action(async(t,e)=>{try{let i$1=await b$1($,{id:t});if(!i$1.athProgram)throw new j$1(`Program ${t} not found`);i(e,i$1.athProgram);}catch(i){h(i);}}),r$1.command("create").description("Create a training program").requiredOption("--name <name>","Program name").option("--summary <s>","Summary").option("--sport <s>","Sport","OTHER").option("--level <l>","Level","BEGINNER").option("--weeks <n>","Number of weeks",m).option("--template","Mark as a template").option("--tags <csv>","Comma-separated tags").option("-f, --format <format>","Output format").action(async t=>{try{let e={name:t.name,sport:(t.sport??"OTHER").toUpperCase(),level:(t.level??"BEGINNER").toUpperCase(),isTemplate:!!t.template};t.summary&&(e.summary=t.summary),t.weeks!==void 0&&(e.weeks=t.weeks),t.tags&&(e.tags=I(t.tags));let i$1=await b$1(D,{input:e});k$1(`Program created: ${i$1.athCreateProgram.name}`),i(t,i$1.athCreateProgram);}catch(e){h(e);}}),r$1.command("update").description("Update a training program").argument("<id>","Program ID").option("--name <name>","Program name").option("--summary <s>","Summary").option("--sport <s>","Sport").option("--level <l>","Level").option("--weeks <n>","Number of weeks",m).option("--template <bool>","Template flag (true|false)").option("--tags <csv>","Comma-separated tags").option("-f, --format <format>","Output format").action(async(t,e)=>{try{let i$1={};if(e.name&&(i$1.name=e.name),e.summary!==void 0&&(i$1.summary=e.summary),e.sport&&(i$1.sport=e.sport.toUpperCase()),e.level&&(i$1.level=e.level.toUpperCase()),e.weeks!==void 0&&(i$1.weeks=e.weeks),e.template!==void 0&&(i$1.isTemplate=e.template==="true"),e.tags&&(i$1.tags=I(e.tags)),!Object.keys(i$1).length)throw new j$1("No updates specified");let dt=await b$1(L,{id:t,input:i$1});k$1("Program updated"),i(e,dt.athUpdateProgram);}catch(i){h(i);}}),r$1.command("transition").description("Advance a program through its publish lifecycle (DRAFT -> PUBLISHED -> ARCHIVED)").argument("<id>","Program ID").requiredOption("--status <s>","Target status: DRAFT|PUBLISHED|ARCHIVED").option("-f, --format <format>","Output format").action(async(t,e)=>{try{let i$1=await b$1(v,{id:t,status:e.status.toUpperCase()});k$1(`Program transitioned to ${i$1.athTransitionProgram.status}`),i(e,i$1.athTransitionProgram);}catch(i){h(i);}}),r$1.command("archive").description("Archive a training program").argument("<id>","Program ID").option("-f, --format <format>","Output format").action(async(t,e)=>{try{let i$1=await b$1(P,{id:t});k$1(i$1.athArchiveProgram?`Program ${t} archived`:`Program ${t} not archived`),i(e,{archived:i$1.athArchiveProgram});}catch(i){h(i);}});let o=r$1.command("drills").description("AtheleteBridge program drills");o.command("add").description("Add a drill to a program").requiredOption("--program <id>","Program ID").requiredOption("--name <name>","Drill name").option("--description <s>","Description").option("--week-number <n>","Week number",m,1).option("--order-index <n>","Order index",m,0).option("--sets <n>","Sets",m).option("--reps <n>","Reps",m).option("--duration-sec <n>","Duration (seconds)",m).option("--rest-sec <n>","Rest (seconds)",m).option("--video-file-id <id>","Video file ID (wspace-files-svc)").option("-f, --format <format>","Output format").action(async t=>{try{let e={programId:t.program,name:t.name,weekNumber:t.weekNumber??1,orderIndex:t.orderIndex??0};t.description&&(e.description=t.description),t.sets!==void 0&&(e.sets=t.sets),t.reps!==void 0&&(e.reps=t.reps),t.durationSec!==void 0&&(e.durationSec=t.durationSec),t.restSec!==void 0&&(e.restSec=t.restSec),t.videoFileId&&(e.videoFileId=t.videoFileId);let i$1=await b$1(x,{input:e});k$1(`Drill added: ${i$1.athAddDrill.name}`),i(t,i$1.athAddDrill);}catch(e){h(e);}}),o.command("remove").description("Remove a drill").argument("<id>","Drill ID").option("-f, --format <format>","Output format").action(async(t,e)=>{try{let i$1=await b$1(N,{id:t});k$1(i$1.athRemoveDrill?`Drill ${t} removed`:`Drill ${t} not removed`),i(e,{removed:i$1.athRemoveDrill});}catch(i){h(i);}});}function rt(d){let r$1=d.command("sessions").description("AtheleteBridge coaching sessions");r$1.command("list").description("List sessions").option("--athlete <id>","Filter by athlete ID").option("--coach <id>","Filter by coach ID").option("--status <s>","Filter by session status").option("--limit <n>","Page size",m,50).option("--offset <n>","Offset",m,0).option("-f, --format <format>","Output format").action(async o=>{try{let t=await b$1(U,{pagination:{limit:o.limit,offset:o.offset},athleteId:o.athlete,coachId:o.coach,status:o.status?o.status.toUpperCase():void 0});i(o,t.athListSessions.items,{headers:["ID","Title","Type","Status","Scheduled"],rows:t.athListSessions.items.map(e=>[r(e.id,12),e.title,e.type,e.status,e.scheduledAt])});}catch(t){h(t);}}),r$1.command("get").description("Get a session by id").argument("<id>","Session ID").option("-f, --format <format>","Output format").action(async(o,t)=>{try{let e=await b$1(F,{id:o});if(!e.athSession)throw new j$1(`Session ${o} not found`);i(t,e.athSession);}catch(e){h(e);}}),r$1.command("book").description("Book a coaching session").requiredOption("--athlete <id>","Athlete ID").requiredOption("--coach <id>","Coach ID").requiredOption("--title <s>","Session title").requiredOption("--scheduled-at <iso>","Scheduled at (ISO timestamp)").option("--type <t>","Session type","IN_PERSON").option("--duration-min <n>","Duration (minutes)",m).option("--location <s>","Location").option("--meeting-url <url>","Meeting URL").option("--program <id>","Program ID").option("-f, --format <format>","Output format").action(async o=>{try{let t={athleteId:o.athlete,coachId:o.coach,title:o.title,scheduledAt:o.scheduledAt,type:(o.type??"IN_PERSON").toUpperCase()};o.durationMin!==void 0&&(t.durationMin=o.durationMin),o.location&&(t.location=o.location),o.meetingUrl&&(t.meetingUrl=o.meetingUrl),o.program&&(t.programId=o.program);let e=await b$1(_,{input:t});k$1(`Session booked: ${e.athBookSession.title}`),i(o,e.athBookSession);}catch(t){h(t);}}),r$1.command("confirm").description("Confirm a requested session").argument("<id>","Session ID").option("-f, --format <format>","Output format").action(async(o,t)=>{try{let e=await b$1(G,{id:o});k$1(`Session confirmed: ${e.athConfirmSession.status}`),i(t,e.athConfirmSession);}catch(e){h(e);}}),r$1.command("cancel").description("Cancel a session").argument("<id>","Session ID").option("-f, --format <format>","Output format").action(async(o,t)=>{try{let e=await b$1(W,{id:o});k$1(`Session cancelled: ${e.athCancelSession.status}`),i(t,e.athCancelSession);}catch(e){h(e);}}),r$1.command("complete").description("Complete a session (optionally with rating and feedback)").argument("<id>","Session ID").option("--rating <n>","Rating",m).option("--feedback <s>","Feedback").option("-f, --format <format>","Output format").action(async(o,t)=>{try{let e={};t.rating!==void 0&&(e.rating=t.rating),t.feedback&&(e.feedback=t.feedback);let i$1=await b$1(q,{id:o,input:Object.keys(e).length?e:void 0});k$1(`Session completed: ${i$1.athCompleteSession.status}`),i(t,i$1.athCompleteSession);}catch(e){h(e);}});}function it(d){let r$1=d.command("workouts").description("AtheleteBridge workout logs");r$1.command("list").description("List workout logs").option("--athlete <id>","Filter by athlete ID").option("--program <id>","Filter by program ID").option("--limit <n>","Page size",m,50).option("--offset <n>","Offset",m,0).option("-f, --format <format>","Output format").action(async o=>{try{let t=await b$1(B,{pagination:{limit:o.limit,offset:o.offset},athleteId:o.athlete,programId:o.program});i(o,t.athListWorkoutLogs.items,{headers:["ID","Title","Status","Performed","Load","RPE"],rows:t.athListWorkoutLogs.items.map(e=>[r(e.id,12),e.title,e.status,e.performedAt,e.totalLoad!==void 0&&e.totalLoad!==null?String(e.totalLoad):"-",e.rpe!==void 0&&e.rpe!==null?String(e.rpe):"-"])});}catch(t){h(t);}}),r$1.command("log").description("Log a workout").requiredOption("--title <s>","Workout title").requiredOption("--performed-at <iso>","Performed at (ISO timestamp)").option("--athlete <id>","Athlete ID").option("--program <id>","Program ID").option("--status <s>","Workout status","COMPLETED").option("--duration-min <n>","Duration (minutes)",m).option("--total-load <n>","Total load",l).option("--rpe <n>","Rate of perceived exertion",m).option("--notes <s>","Notes").option("--metrics <json>","Metrics JSON object").option("-f, --format <format>","Output format").action(async o=>{try{let t={title:o.title,performedAt:o.performedAt,status:(o.status??"COMPLETED").toUpperCase()};o.athlete&&(t.athleteId=o.athlete),o.program&&(t.programId=o.program),o.durationMin!==void 0&&(t.durationMin=o.durationMin),o.totalLoad!==void 0&&(t.totalLoad=o.totalLoad),o.rpe!==void 0&&(t.rpe=o.rpe),o.notes&&(t.notes=o.notes),o.metrics&&(t.metrics=Z("metrics",o.metrics));let e=await b$1(H,{input:t});k$1(`Workout logged: ${e.athLogWorkout.title}`),i(o,e.athLogWorkout);}catch(t){h(t);}});}function at(d){let r$1=d.command("metrics").description("AtheleteBridge performance metrics");r$1.command("list").description("List performance metrics for an athlete").requiredOption("--athlete <id>","Athlete ID").option("--type <t>","Filter by metric type").option("-f, --format <format>","Output format").action(async o=>{try{let t=await b$1(j,{athleteId:o.athlete,type:o.type?o.type.toUpperCase():void 0});i(o,t.athPerformanceMetrics.items,{headers:["ID","Label","Type","Value","Unit","Recorded"],rows:t.athPerformanceMetrics.items.map(e=>[r(e.id,12),e.label,e.type,String(e.value),e.unit??"-",e.recordedAt])});}catch(t){h(t);}}),r$1.command("record").description("Record a performance metric").requiredOption("--label <s>","Metric label").requiredOption("--value <n>","Metric value",l).requiredOption("--recorded-at <iso>","Recorded at (ISO timestamp)").option("--athlete <id>","Athlete ID").option("--type <t>","Metric type","CUSTOM").option("--unit <s>","Unit").option("--source <s>","Source").option("-f, --format <format>","Output format").action(async o=>{try{let t={label:o.label,value:o.value,recordedAt:o.recordedAt,type:(o.type??"CUSTOM").toUpperCase()};o.athlete&&(t.athleteId=o.athlete),o.unit&&(t.unit=o.unit),o.source&&(t.source=o.source);let e=await b$1(V,{input:t});k$1(`Metric recorded: ${e.athRecordMetric.label}`),i(o,e.athRecordMetric);}catch(t){h(t);}});}function nt(d){let r$1=d.command("fixtures").description("AtheleteBridge fixtures");r$1.command("list").description("List fixtures").option("--team <id>","Filter by team ID").option("--status <s>","Filter by fixture status").option("--limit <n>","Page size",m,50).option("--offset <n>","Offset",m,0).option("-f, --format <format>","Output format").action(async o=>{try{let t=await b$1(J,{pagination:{limit:o.limit,offset:o.offset},status:o.status?o.status.toUpperCase():void 0,teamId:o.team});i(o,t.athListFixtures.items,{headers:["ID","Type","Status","Competition","Scheduled","Score"],rows:t.athListFixtures.items.map(e=>[r(e.id,12),e.type,e.status,e.competition??"-",e.scheduledAt,e.homeScore!==void 0&&e.homeScore!==null&&e.awayScore!==void 0&&e.awayScore!==null?`${e.homeScore}-${e.awayScore}`:"-"])});}catch(t){h(t);}}),r$1.command("get").description("Get a fixture by id").argument("<id>","Fixture ID").option("-f, --format <format>","Output format").action(async(o,t)=>{try{let e=await b$1(X,{id:o});if(!e.athFixture)throw new j$1(`Fixture ${o} not found`);i(t,e.athFixture);}catch(e){h(e);}}),r$1.command("schedule").description("Schedule a fixture").requiredOption("--home-team <id>","Home team ID").requiredOption("--scheduled-at <iso>","Scheduled at (ISO timestamp)").option("--away-team <id>","Away team ID").option("--type <t>","Fixture type","FRIENDLY").option("--competition <s>","Competition").option("--round <s>","Round").option("--kickoff-at <iso>","Kickoff at (ISO timestamp)").option("--venue <s>","Venue").option("--notes <s>","Notes").option("-f, --format <format>","Output format").action(async o=>{try{let t={homeTeamId:o.homeTeam,scheduledAt:o.scheduledAt,type:(o.type??"FRIENDLY").toUpperCase()};o.awayTeam&&(t.awayTeamId=o.awayTeam),o.competition&&(t.competition=o.competition),o.round&&(t.round=o.round),o.kickoffAt&&(t.kickoffAt=o.kickoffAt),o.venue&&(t.venue=o.venue),o.notes&&(t.notes=o.notes);let e=await b$1(K,{input:t});k$1(`Fixture scheduled: ${e.athScheduleFixture.id}`),i(o,e.athScheduleFixture);}catch(t){h(t);}}),r$1.command("record-result").description("Record a final result for a fixture and recompute standings").argument("<id>","Fixture ID").requiredOption("--home-score <n>","Home score",m).requiredOption("--away-score <n>","Away score",m).option("-f, --format <format>","Output format").action(async(o,t)=>{try{let e=await b$1(z,{id:o,input:{homeScore:t.homeScore,awayScore:t.awayScore}});k$1(`Result recorded: ${e.athRecordFixtureResult.homeScore??0}-${e.athRecordFixtureResult.awayScore??0}`),i(t,e.athRecordFixtureResult);}catch(e){h(e);}});}function st(d){d.command("standings").description("AtheleteBridge standings").command("list").description("List standings for a competition").requiredOption("--competition <s>","Competition name").option("-f, --format <format>","Output format").action(async o=>{try{let t=await b$1(Y,{competition:o.competition});i(o,t.athStandings.items,{headers:["Rank","Team","P","W","D","L","Pts"],rows:t.athStandings.items.map(e=>[e.rank!==void 0&&e.rank!==null?String(e.rank):"-",r(e.teamId,12),String(e.played),String(e.won),String(e.drawn),String(e.lost),String(e.points)])});}catch(t){h(t);}});}function mt(d$1){d$1.command("health").description("AtheleteBridge service health check (public)").option("-f, --format <format>","Output format").action(async r=>{try{let o=await d(Q);k$1(o.athHealth),i(r,{health:o.athHealth});}catch(o){h(o);}});}var pt={id:"atheletebridge",version:"1.0.0",displayName:"AtheleteBridge",dependsOn:["auth","workspaces"],register(d,r){a(r);let o=d.command("atheletebridge").description("AtheleteBridge sports team & athlete management");tt(o),et(o),ot(o),rt(o),it(o),at(o),nt(o),st(o),mt(o);}},Vt=pt;export{Vt as default};
|
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
'use strict';require('graphql-request');var
|
|
1
|
+
'use strict';require('graphql-request');var N=require('cross-fetch');require('commander');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var N__default=/*#__PURE__*/_interopDefault(N);async function G(n){let s=`${n.oidcIssuer}/oidc/device/code`,o=new URLSearchParams({client_id:n.clientId,scope:"openid profile email offline_access"}),i=await N__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 W(n,s,o){let i=`${o.oidcIssuer}/oauth/device/token`,a=s;for(;;){await new Promise(k=>setTimeout(k,a*1e3));let c=await N__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 D(n,s,o,i){let c=await N__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: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
|
|
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 v(n,s,o,i){let c=await N__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:o,organizationId:i}}})});if(!c.ok){let
|
|
14
|
+
`,variables:{input:{workspaceId:o,organizationId:i}}})});if(!c.ok){let k=await c.text().catch(()=>"Unknown error");throw new Error(`Workspace token request failed (${c.status}): ${k}`)}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 k=d?.error?.message??"Unknown error";throw new Error(`Workspace token failed: ${k}`)}return {token:d.token,expiresAt:d.expiresAt??"",scopes:d.scopes??[]}}async function q(n,s){let i=await N__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(!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
|
|
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 De(n){try{let s=new URL(n);return s.protocol==="http:"||s.protocol==="https:"}catch{return false}}async function K(n){try{if(!De(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 g=class extends Error{exitCode;hint;constructor(s,o){super(s),this.name="CliUserError",this.exitCode=o?.exitCode??1,this.hint=o?.hint;}},E=class extends g{constructor(s,o){super(s,{exitCode:2,hint:o?.hint??"Run `<product> auth login` to authenticate."}),this.name="CliAuthError";}},C=class extends Error{cause;constructor(s,o){super(s),this.name="CliInternalError",this.cause=o;}};function V(n){if(n instanceof E||n instanceof g)return n;let s=j(n)&&j(n.response)?n.response:void 0,o=s?.errors,i=Array.isArray(o)?o[0]:void 0,c=(j(i)&&j(i.extensions)?i.extensions:void 0)?.code,p=s?.status;return c==="UNAUTHENTICATED"||p===401?new E("Authentication required."):c==="FORBIDDEN"||p===403?new g("Permission denied."):c==="BAD_USER_INPUT"||c==="GRAPHQL_VALIDATION_FAILED"||p===400?new g("Invalid request. Check the command arguments."):c==="NOT_FOUND"||p===404?new g("Requested resource was not found."):c==="RATE_LIMITED"||c==="TOO_MANY_REQUESTS"||p===429?new g("Request limit reached. Try again later."):new C("The request could not be completed. Try again later.")}var L=class extends Error{response;constructor(s,o){super(s),this.name="GqlRequestError",this.response=o;}};function j(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}var z=null;function Y(n){z=n;}function y(){if(!z)throw new C("vibecontrols module helpers used before setHelpersContext was called");return z}async function l(n,s){return y().gql.global.request(n,s)}async function B(n,s){return y().gql.global.request(n,s)}function T(){y().gql.reset();}function u(n){throw n instanceof E||n instanceof g||n instanceof C?n:n instanceof L||n!==null&&typeof n=="object"&&"response"in n?V(n):new C("The command could not be completed. Try again later.")}function h(n,s,o){y().output.formatAndOutput(n,s,o);}function f(n){y().output.printSuccess(n);}function x(n){y().output.printInfo(n);}function O(n){y().output.printWarning(n);}function M(n){y().output.printJson(n);}function F(n){return y().output.formatStatus(n)}function S(n){return y().output.formatDate(n)}function $(n,s){return y().output.truncate(n,s)}function R(){return y()}function U(){return y().auth.read()}function b(n){y().auth.write(n);}function J(){y().auth.clear();}function _(){return y().config.read()}function Q(){return y().config.resolveOIDC()}function X(n){return n?n.expiresAt?Date.now()>=n.expiresAt:false:y().auth.isTokenExpired()}var Z=`
|
|
21
21
|
query currentUser {
|
|
22
22
|
currentUser {
|
|
23
23
|
id email firstName lastName username phoneNumber name
|
|
24
24
|
emailVerified mfaEnabled isAdmin role status createdAt lastLoginAt
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
-
`,
|
|
27
|
+
`,ee=`
|
|
28
28
|
mutation updateCurrentUserProfile($input: UpdateUserInput!) {
|
|
29
29
|
updateCurrentUserProfile(input: $input) {
|
|
30
30
|
id name firstName lastName username phoneNumber
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
|
-
`,
|
|
33
|
+
`,H=`
|
|
34
34
|
query authAuditLogs($pagination: PaginationInput) {
|
|
35
35
|
authAuditLogs(pagination: $pagination) {
|
|
36
36
|
auditLogs {
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
hasMore
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
-
`,
|
|
44
|
+
`,te=`
|
|
45
45
|
query activeSessions($pagination: PaginationInput) {
|
|
46
46
|
activeSessions(pagination: $pagination) {
|
|
47
47
|
sessions {
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
hasMore
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
|
-
`,
|
|
54
|
+
`,ne=`
|
|
55
55
|
query currentUserMFAMethods($pagination: PaginationInput) {
|
|
56
56
|
currentUserMFAMethods(pagination: $pagination) {
|
|
57
57
|
methods { id method status createdAt updatedAt }
|
|
@@ -59,21 +59,21 @@
|
|
|
59
59
|
hasMore
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
|
-
`,
|
|
62
|
+
`,re=`
|
|
63
63
|
mutation setupMFA($method: MFAMethod!) {
|
|
64
64
|
setupMFA(method: $method) {
|
|
65
65
|
method backupCodes qrCode secret
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
|
-
`;var
|
|
68
|
+
`;var oe=`
|
|
69
69
|
mutation enableMFA($code: String!) {
|
|
70
70
|
enableMFA(code: $code)
|
|
71
71
|
}
|
|
72
|
-
`,
|
|
72
|
+
`,ie=`
|
|
73
73
|
mutation disableMFA {
|
|
74
74
|
disableMFA
|
|
75
75
|
}
|
|
76
|
-
`,
|
|
76
|
+
`,se=`
|
|
77
77
|
query myApiKeys($pagination: PaginationInput) {
|
|
78
78
|
myApiKeys(pagination: $pagination) {
|
|
79
79
|
apiKeys { id name prefix appId appName scopes expiresAt lastUsedAt createdAt }
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
hasMore
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
|
-
`,
|
|
84
|
+
`,ae=`
|
|
85
85
|
query appApiKeys($appId: ID!, $pagination: PaginationInput) {
|
|
86
86
|
appApiKeys(appId: $appId, pagination: $pagination) {
|
|
87
87
|
apiKeys { id name prefix appId appName scopes expiresAt lastUsedAt createdAt }
|
|
@@ -89,23 +89,23 @@
|
|
|
89
89
|
hasMore
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
|
-
`,
|
|
92
|
+
`,ce=`
|
|
93
93
|
mutation generateAPIKey($input: GenerateAPIKeyInput!) {
|
|
94
94
|
generateAPIKey(input: $input) {
|
|
95
95
|
keyId apiKey apiSecret
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
|
-
`;var
|
|
98
|
+
`;var pe=`
|
|
99
99
|
mutation revokeAPIKey($keyId: String!) {
|
|
100
100
|
revokeAPIKey(keyId: $keyId)
|
|
101
101
|
}
|
|
102
|
-
`,
|
|
102
|
+
`,ue=`
|
|
103
103
|
mutation rotateAPIKey($keyId: String!) {
|
|
104
104
|
rotateAPIKey(keyId: $keyId) {
|
|
105
105
|
apiSecret
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
|
-
`,
|
|
108
|
+
`,de=`
|
|
109
109
|
query currentUserDelegations($pagination: PaginationInput) {
|
|
110
110
|
currentUserDelegations(pagination: $pagination) {
|
|
111
111
|
delegations {
|
|
@@ -117,17 +117,17 @@
|
|
|
117
117
|
hasMore
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
|
-
`,
|
|
120
|
+
`,le=`
|
|
121
121
|
mutation grantDelegation($input: GrantDelegationInput!) {
|
|
122
122
|
grantDelegation(input: $input) {
|
|
123
123
|
id appId userId grantedBy grantedAt expiresAt scopes workspaceIds status
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
|
-
`,
|
|
126
|
+
`,ge=`
|
|
127
127
|
mutation revokeDelegation($id: ID!, $reason: String) {
|
|
128
128
|
revokeDelegation(id: $id, reason: $reason)
|
|
129
129
|
}
|
|
130
|
-
`,
|
|
130
|
+
`,fe=`
|
|
131
131
|
query currentUserApps($pagination: PaginationInput) {
|
|
132
132
|
currentUserApps(pagination: $pagination) {
|
|
133
133
|
apps {
|
|
@@ -138,68 +138,68 @@
|
|
|
138
138
|
hasMore
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
|
-
`,
|
|
141
|
+
`,me=`
|
|
142
142
|
query app($id: ID!) {
|
|
143
143
|
app(id: $id) {
|
|
144
144
|
id clientId name description type actorType status ownerUserId redirectUris scopes
|
|
145
145
|
}
|
|
146
146
|
}
|
|
147
|
-
`,
|
|
147
|
+
`,he=`
|
|
148
148
|
mutation createApp($input: CreateAppInput!) {
|
|
149
149
|
createApp(input: $input) {
|
|
150
150
|
app { id clientId name type status }
|
|
151
151
|
clientSecret
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
|
-
`,
|
|
154
|
+
`,ke=`
|
|
155
155
|
mutation updateApp($id: ID!, $input: UpdateAppInput!) {
|
|
156
156
|
updateApp(id: $id, input: $input) {
|
|
157
157
|
id name description redirectUris scopes status
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
|
-
`,
|
|
160
|
+
`,we=`
|
|
161
161
|
mutation deactivateApp($id: ID!) {
|
|
162
162
|
deactivateApp(id: $id)
|
|
163
163
|
}
|
|
164
|
-
`,
|
|
164
|
+
`,ye=`
|
|
165
165
|
query getSSOConfig($tenantId: String!) {
|
|
166
166
|
getSSOConfig(tenantId: $tenantId) {
|
|
167
167
|
id identifier tenantId entityId ssoUrl sloUrl certificate enabled metadata
|
|
168
168
|
}
|
|
169
169
|
}
|
|
170
|
-
`,
|
|
170
|
+
`,Ae=`
|
|
171
171
|
mutation saveSSOConfig($tenantId: String!, $input: SSOConfigInput!) {
|
|
172
172
|
saveSSOConfig(tenantId: $tenantId, input: $input) {
|
|
173
173
|
id identifier entityId ssoUrl sloUrl certificate enabled
|
|
174
174
|
}
|
|
175
175
|
}
|
|
176
|
-
`,
|
|
176
|
+
`,Ie=`
|
|
177
177
|
mutation deleteSSOConfig($tenantId: String!) {
|
|
178
178
|
deleteSSOConfig(tenantId: $tenantId)
|
|
179
179
|
}
|
|
180
|
-
`,
|
|
180
|
+
`,Ce=`
|
|
181
181
|
query users($filter: UserFilterInput, $pagination: PaginationInput) {
|
|
182
182
|
users(filter: $filter, pagination: $pagination) {
|
|
183
183
|
users { id email firstName lastName username role status createdAt }
|
|
184
184
|
totalCount hasMore
|
|
185
185
|
}
|
|
186
186
|
}
|
|
187
|
-
`,
|
|
187
|
+
`,xe=`
|
|
188
188
|
query user($id: ID!) {
|
|
189
189
|
user(id: $id) {
|
|
190
190
|
id email firstName lastName username role status emailVerified lastLoginAt
|
|
191
191
|
}
|
|
192
192
|
}
|
|
193
|
-
`,
|
|
193
|
+
`,Ee=`
|
|
194
194
|
mutation updateUser($id: ID!, $input: AdminUpdateUserInput!) {
|
|
195
195
|
updateUser(id: $id, input: $input) {
|
|
196
196
|
id email firstName lastName username role status
|
|
197
197
|
}
|
|
198
198
|
}
|
|
199
|
-
`,
|
|
199
|
+
`,Te="mutation SignOut { signOut }",Se=`
|
|
200
200
|
mutation RefreshToken($token: String!) {
|
|
201
201
|
refreshToken(token: $token) { accessToken refreshToken expiresIn }
|
|
202
202
|
}
|
|
203
|
-
`;async function
|
|
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
|
|
205
|
-
Available workspaces:`),t.forEach((w,R)=>console.log(` ${R+1}. ${w.name} (${w.slug})`)));let{workspace:f}=await Ee(t,{preferredId:n,interactive:r,ask:Te});t.length>1&&!r&&!n&&C(`${t.length} workspaces available; pass --workspace-id or run \`${O().productName} workspace set <id>\` to switch`),C(`Using workspace: ${f.name} (${f.id})`);let I=await b(s.workspaceEndpoint,h,f.id,f.organizationId);S({accessToken:h,refreshToken:d.refreshToken,expiresAt:e,workspaceToken:I.token,workspaceTokenExpiresAt:new Date(I.expiresAt).getTime(),workspaceId:f.id,organizationId:f.organizationId,authMethod:"device_code"}),E(),g("Authentication successful");}catch(t){S({accessToken:h,refreshToken:d.refreshToken,expiresAt:e,authMethod:"device_code"}),E(),g("Authentication successful"),v(`Workspace token not obtained: ${t instanceof Error?t.message:String(t)}`),C(`Set workspace manually: ${O().productName} workspace set <id>`);}}async function Me(n){let s=U(),i=(await import('readline')).createInterface({input:process.stdin,output:process.stdout}),a=await new Promise(I=>{i.question("Client ID: ",w=>I(w.trim()));}),c=await new Promise(I=>{i.question("Client Secret: ",w=>{i.close(),I(w.trim());});});if(!a||!c)throw new k("Client ID and secret cannot be empty");C("Authenticating app...");let p=await P(s.globalEndpoint,a,c),d=p.accessToken,h=Date.now()+p.expiresIn*1e3,e,t,r=n,f;if(r)try{let w=(await N(s.globalEndpoint,d)).find(R=>R.id===r);if(w){f=w.organizationId;let R=await b(s.workspaceEndpoint,d,r,f);e=R.token,t=new Date(R.expiresAt).getTime(),C(`Workspace token issued for: ${w.name}`);}else v(`Workspace ${r} not found \u2014 skipping workspace token`),r=void 0;}catch(I){v(`Workspace token failed: ${I instanceof Error?I.message:String(I)}`);}S({accessToken:d,refreshToken:"",expiresAt:h,workspaceToken:e,workspaceTokenExpiresAt:t,workspaceId:r,organizationId:f,authMethod:"client_credentials",clientId:a,clientSecret:c}),E(),g("App authentication successful");}function ve(n){let s=n.command("profile").description("Current user profile");s.command("show").description("Show current user").option("-f, --format <format>").action(async e=>{try{let t=await l(J);m(e,t.currentUser);}catch(t){u(t);}}),s.command("update").description("Update current user profile").option("--first-name <s>").option("--last-name <s>").option("--name <s>").option("--username <s>").option("--phone <s>").option("--timezone <s>").option("--language <s>").option("-f, --format <format>").action(async e=>{try{let t={};if(e.firstName&&(t.firstName=e.firstName),e.lastName&&(t.lastName=e.lastName),e.name&&(t.name=e.name),e.username&&(t.username=e.username),e.phone&&(t.phoneNumber=e.phone),e.timezone&&(t.timezone=e.timezone),e.language&&(t.language=e.language),!Object.keys(t).length)throw new k("No updates specified");let r=await l(Q,{input:t});g("Profile updated"),m(e,r.updateCurrentUserProfile);}catch(t){u(t);}});let o=n.command("security").description("Account security overview");o.command("audit-log").description("Recent auth audit events for the current user").option("--limit <n>","Page size",e=>parseInt(e,10),50).option("-f, --format <format>").action(async e=>{try{let t=await l(j,{pagination:{limit:e.limit,offset:0}});m(e,t.authAuditLogs.auditLogs,{headers:["When","Action","Resource","IP"],rows:t.authAuditLogs.auditLogs.map(r=>[T(r.createdAt),r.action,r.resource??"-",r.ipAddress??"-"])});}catch(t){u(t);}}),o.command("sessions").description("Active sessions for the current user").option("--limit <n>","Page size",e=>parseInt(e,10),50).option("-f, --format <format>").action(async e=>{try{let t=await l(X,{pagination:{limit:e.limit,offset:0}});m(e,t.activeSessions.sessions,{headers:["ID","Status","IP","LastActivity","Current"],rows:t.activeSessions.sessions.map(r=>[$(r.id,12),L(r.status),r.ipAddress??"-",T(r.lastActivityAt),String(!!r.isCurrent)])});}catch(t){u(t);}});let i=n.command("mfa").description("Multi-factor authentication");i.command("list").description("List MFA methods enrolled for the current user").option("--limit <n>","Page size",e=>parseInt(e,10),50).option("-f, --format <format>").action(async e=>{try{let t=await l(Z,{pagination:{limit:e.limit,offset:0}});m(e,t.currentUserMFAMethods.methods,{headers:["Method","Status","Created"],rows:t.currentUserMFAMethods.methods.map(r=>[r.method,L(r.status),T(r.createdAt)])});}catch(t){u(t);}}),i.command("enroll").description("Begin MFA enrollment (TOTP/SMS/EMAIL)").requiredOption("--method <m>","TOTP|SMS|EMAIL").option("-f, --format <format>").action(async e=>{try{let t=await l(ee,{method:e.method.toUpperCase()});e.format?m(e,t.setupMFA):(g("MFA enrollment started"),q(t.setupMFA),C("Save your backup codes; verify with `auth mfa verify --code <CODE>`."));}catch(t){u(t);}}),i.command("verify").description("Verify MFA enrollment code").requiredOption("--code <code>").action(async e=>{try{await l(te,{code:e.code}),g("MFA enabled");}catch(t){u(t);}}),i.command("disable").description("Disable MFA for the current user").action(async()=>{try{await l(ne),g("MFA disabled");}catch(e){u(e);}});let a=n.command("api-keys").description("API key management");a.command("list").description("List your API keys").option("--app <id>","Restrict to keys for an app id").option("--limit <n>","Page size",e=>parseInt(e,10),50).option("-f, --format <format>").action(async e=>{try{let t=e.app?oe:re,r=e.app?{appId:e.app,pagination:{limit:e.limit,offset:0}}:{pagination:{limit:e.limit,offset:0}},f=await l(t,r),I=(f.myApiKeys??f.appApiKeys)?.apiKeys??[];m(e,I,{headers:["ID","Name","Prefix","App","Scopes","LastUsed"],rows:I.map(w=>[$(w.id,12),w.name??"-",w.prefix??"-",w.appName??"-",Array.isArray(w.scopes)?w.scopes.join(","):"-",T(w.lastUsedAt)])});}catch(t){u(t);}}),a.command("create").description("Generate a new API key").requiredOption("--name <name>").requiredOption("--app <appId>","Owning app id").option("--scope <scope>","Comma-separated scopes").option("--expires <iso>","ISO expiry").option("-f, --format <format>").action(async e=>{try{let t={name:e.name,appId:e.app,scope:e.scope?e.scope.split(","):void 0,expiresAt:e.expires},r=await l(ie,{input:t});g("API key generated. Store the secret \u2014 it is only shown once."),q(r.generateAPIKey);}catch(t){u(t);}}),a.command("revoke").description("Revoke an API key").argument("<keyId>").action(async e=>{try{await l(se,{keyId:e}),g("API key revoked");}catch(t){u(t);}}),a.command("rotate").description("Rotate an API key (returns new secret)").argument("<keyId>").action(async e=>{try{let t=await l(ae,{keyId:e});g("API key rotated"),q(t.rotateAPIKey);}catch(t){u(t);}}),n.command("audit-log").description("Auth audit log").option("--limit <n>","Page size",e=>parseInt(e,10),50).option("-f, --format <format>").action(async e=>{try{let t=await l(j,{pagination:{limit:e.limit,offset:0}});m(e,t.authAuditLogs.auditLogs);}catch(t){u(t);}});let c=n.command("delegations").description("Delegation management");c.command("list").description("Delegations granted to the current user").option("--limit <n>","Page size",e=>parseInt(e,10),50).option("-f, --format <format>").action(async e=>{try{let t=await l(ce,{pagination:{limit:e.limit,offset:0}});m(e,t.currentUserDelegations.delegations);}catch(t){u(t);}}),c.command("grant").description("Grant a delegation to an app").requiredOption("--app <appId>").requiredOption("--user <userId>","User to delegate as").option("--scope <s>","Comma-separated scopes").option("--workspace <ids>","Comma-separated workspace ids").option("--expires <iso>").option("-f, --format <format>").action(async e=>{try{let t={appId:e.app,userId:e.user,scopes:e.scope?e.scope.split(","):void 0,workspaceIds:e.workspace?e.workspace.split(","):void 0,expiresAt:e.expires},r=await l(pe,{input:t});g("Delegation granted"),m(e,r.grantDelegation);}catch(t){u(t);}}),c.command("revoke").description("Revoke a delegation").argument("<id>").option("--reason <text>").action(async(e,t)=>{try{await l(ue,{id:e,reason:t.reason}),g("Delegation revoked");}catch(r){u(r);}});let p=n.command("apps").description("OAuth/system app management");p.command("list").description("Apps owned by the current user").option("--limit <n>","Page size",e=>parseInt(e,10),50).option("-f, --format <format>").action(async e=>{try{let t=await l(de,{pagination:{limit:e.limit,offset:0}});m(e,t.currentUserApps.apps,{headers:["ID","ClientID","Name","Type","Status"],rows:t.currentUserApps.apps.map(r=>[$(r.id,12),$(r.clientId,24),r.name??"-",r.type??"-",L(r.status)])});}catch(t){u(t);}}),p.command("get").description("Get an app by id").argument("<id>").option("-f, --format <format>").action(async(e,t)=>{try{let r=await l(le,{id:e});if(!r.app)throw new k(`App ${e} not found`);m(t,r.app);}catch(r){u(r);}}),p.command("create").description("Create an OAuth app").requiredOption("--name <s>").option("--description <s>").option("--type <t>","OAUTH|SYSTEM","OAUTH").option("--actor-type <t>","USER|APP|SERVICE","APP").option("--redirect <urls>","Comma-separated redirect URIs").option("--scopes <s>","Comma-separated scopes").option("-f, --format <format>").action(async e=>{try{let t={name:e.name,description:e.description,type:(e.type??"OAUTH").toUpperCase(),actorType:(e.actorType??"APP").toUpperCase(),redirectUris:e.redirect?e.redirect.split(","):void 0,scopes:e.scopes?e.scopes.split(","):void 0},r=await l(ge,{input:t});g("App created. Client secret only shown once."),q(r.createApp);}catch(t){u(t);}}),p.command("update").description("Update an app").argument("<id>").option("--name <s>").option("--description <s>").option("--redirect <urls>","Comma-separated redirect URIs").option("--scopes <s>","Comma-separated scopes").option("--status <s>").option("-f, --format <format>").action(async(e,t)=>{try{let r={};if(t.name&&(r.name=t.name),t.description!==void 0&&(r.description=t.description),t.redirect&&(r.redirectUris=t.redirect.split(",")),t.scopes&&(r.scopes=t.scopes.split(",")),t.status&&(r.status=t.status.toUpperCase()),!Object.keys(r).length)throw new k("No updates specified");let f=await l(fe,{id:e,input:r});g("App updated"),m(t,f.updateApp);}catch(r){u(r);}}),p.command("deactivate").description("Deactivate an app").argument("<id>").action(async e=>{try{await l(me,{id:e}),g("App deactivated");}catch(t){u(t);}});let d=n.command("sso").description("SSO (SAML/OIDC) configuration");d.command("get").description("Get SSO config for a tenant").requiredOption("--tenant <id>").option("-f, --format <format>").action(async e=>{try{let t=await l(he,{tenantId:e.tenant});m(e,t.getSSOConfig);}catch(t){u(t);}}),d.command("save").description("Save (upsert) SSO config for a tenant").requiredOption("--tenant <id>").requiredOption("--entity <s>","EntityID / Issuer").requiredOption("--sso-url <url>").option("--slo-url <url>").option("--certificate <pem>","X.509 certificate PEM").option("--enabled","Enable after save",false).option("-f, --format <format>").action(async e=>{try{let t={entityId:e.entity,ssoUrl:e.ssoUrl,sloUrl:e.sloUrl,certificate:e.certificate,enabled:!!e.enabled},r=await l(ke,{tenantId:e.tenant,input:t});g("SSO config saved"),m(e,r.saveSSOConfig);}catch(t){u(t);}}),d.command("delete").description("Delete SSO config for a tenant").requiredOption("--tenant <id>").action(async e=>{try{await l(we,{tenantId:e.tenant}),g("SSO config deleted");}catch(t){u(t);}});let h=n.command("users").description("User admin (requires admin permissions)");h.command("list").description("List users (admin)").option("--email <s>").option("--username <s>").option("--role <s>").option("--status <s>").option("--search <s>").option("--limit <n>","Page size",e=>parseInt(e,10),50).option("-f, --format <format>").action(async e=>{try{let t={};e.email&&(t.email=e.email),e.username&&(t.username=e.username),e.role&&(t.role=e.role.toUpperCase()),e.status&&(t.status=e.status.toUpperCase()),e.search&&(t.search=e.search);let r=await l(ye,{filter:Object.keys(t).length?t:void 0,pagination:{limit:e.limit,offset:0}});m(e,r.users.users,{headers:["ID","Email","Username","Role","Status","Created"],rows:r.users.users.map(f=>[$(f.id,12),f.email,f.username??"-",f.role??"-",L(f.status),T(f.createdAt)])});}catch(t){u(t);}}),h.command("get").description("Get user by id (admin)").argument("<id>").option("-f, --format <format>").action(async(e,t)=>{try{let r=await l(Ae,{id:e});if(!r.user)throw new k(`User ${e} not found`);m(t,r.user);}catch(r){u(r);}}),h.command("update").description("Update a user (admin)").argument("<id>").option("--first-name <s>").option("--last-name <s>").option("--username <s>").option("--phone <s>").option("--role <s>").option("--status <s>").option("--email-verified <bool>").option("-f, --format <format>").action(async(e,t)=>{try{let r={};if(t.firstName&&(r.firstName=t.firstName),t.lastName&&(r.lastName=t.lastName),t.username&&(r.username=t.username),t.phone&&(r.phoneNumber=t.phone),t.role&&(r.role=t.role.toUpperCase()),t.status&&(r.status=t.status.toUpperCase()),t.emailVerified!==void 0&&(r.emailVerified=t.emailVerified==="true"),!Object.keys(r).length)throw new k("No updates specified");let f=await l(Ie,{id:e,input:r});g("User updated"),m(t,f.updateUser);}catch(r){u(r);}});}var Fe={id:"auth",version:"1.0.0",displayName:"Authentication",register(n,s){V(s),be(n);let o=n.commands.find(i=>i.name()==="auth");if(!o)throw new x("auth command group missing after registerAuthCommands");ve(o);}},fn=Fe;module.exports=fn;
|
|
203
|
+
`;async function be(n,s){if(n.length===0)throw new g("No workspaces to choose from");if(s.preferredId){let p=n.find(d=>d.id===s.preferredId);if(!p)throw new g(`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 ve(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 Re(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 o=>{try{o.clientCredentials?await We(o.workspaceId):await Ge(o.workspaceId);}catch(i){u(i);}}),s.command("logout").description("Revoke tokens and clear stored auth").action(async()=>{try{if(U()?.accessToken)try{await B(Te);}catch{O("Server-side logout failed, clearing local tokens");}J(),T(),f("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=U(),a=_(),c=!!i?.accessToken,p=i?.accessToken?X(i):false,d=i?.expiresAt?S(new Date(i.expiresAt).toISOString()):"-",k=i?.authMethod==="client_credentials"?"Client Credentials":"OAuth2 Device Code",e=i?.workspaceTokenExpiresAt?S(new Date(i.workspaceTokenExpiresAt).toISOString()):"-";h(o,{authenticated:c,method:k,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",k],["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=U();if(o.workspace){if(!i?.workspaceToken)throw new g(`No workspace token. Set a workspace: ${R().productName} workspace set <id>`);process.stdout.write(i.workspaceToken);return}if(!i?.accessToken)throw new g(`Not authenticated. Run: ${R().productName} auth login`);process.stdout.write(i.accessToken);}),s.command("refresh").description("Force token refresh").action(async()=>{try{let o=U();if(!o?.refreshToken&&o?.authMethod!=="client_credentials")throw new g(`No refresh token available. Run: ${R().productName} auth login`);if(o?.authMethod==="client_credentials"&&o.clientId&&o.clientSecret){let c=_(),p=await D(c.globalEndpoint,o.clientId,o.clientSecret);b({...o,accessToken:p.accessToken,expiresAt:Date.now()+p.expiresIn*1e3}),T(),f("App token refreshed successfully"),o.workspaceId&&o.organizationId&&await Oe();return}let a=(await B(Se,{token:o.refreshToken})).refreshToken;b({...o,accessToken:a.accessToken,refreshToken:a.refreshToken,expiresAt:Date.now()+a.expiresIn*1e3}),T(),f("Token refreshed successfully"),o.workspaceId&&o.organizationId&&await Oe();}catch(o){u(o);}});}async function Oe(){let n=U();if(!n?.accessToken||!n.workspaceId||!n.organizationId)return;let s=_();try{let o=await v(s.workspaceEndpoint,n.accessToken,n.workspaceId,n.organizationId);b({...n,workspaceToken:o.token,workspaceTokenExpiresAt:new Date(o.expiresAt).getTime()}),T(),f("Workspace token refreshed");}catch{O("Workspace token refresh failed \u2014 workspace operations may require re-login");}}async function Ge(n){let s=_(),{oidcIssuer:o,clientId:i}=Q(),a={...s,oidcIssuer:o,clientId:i};x("Starting device code authentication...");let c=await G(a);console.log(""),console.log(` Open: ${c.verificationUri}`),console.log(` Code: ${c.userCode}`),console.log(""),await K(c.verificationUriComplete??c.verificationUri)?x("Browser opened"):O("Could not open browser \u2014 open the URL manually"),x("Waiting for authorization...");let d=await W(c.deviceCode,c.interval,a),k=d.accessToken,e=Date.now()+d.expiresIn*1e3;b({accessToken:k,refreshToken:d.refreshToken,expiresAt:e,authMethod:"device_code"}),T(),x("Fetching workspaces...");try{let t=await q(s.globalEndpoint,k);if(t.length===0){f("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:m}=await be(t,{preferredId:n,interactive:r,ask:ve});t.length>1&&!r&&!n&&x(`${t.length} workspaces available; pass --workspace-id or run \`${R().productName} workspace set <id>\` to switch`),x(`Using workspace: ${m.name} (${m.id})`);let I=await v(s.workspaceEndpoint,k,m.id,m.organizationId);b({accessToken:k,refreshToken:d.refreshToken,expiresAt:e,workspaceToken:I.token,workspaceTokenExpiresAt:new Date(I.expiresAt).getTime(),workspaceId:m.id,organizationId:m.organizationId,authMethod:"device_code"}),T(),f("Authentication successful");}catch(t){b({accessToken:k,refreshToken:d.refreshToken,expiresAt:e,authMethod:"device_code"}),T(),f("Authentication successful"),O(`Workspace token not obtained: ${t instanceof Error?t.message:String(t)}`),x(`Set workspace manually: ${R().productName} workspace set <id>`);}}async function We(n){let s=_(),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 g("Client ID and secret cannot be empty");x("Authenticating app...");let p=await D(s.globalEndpoint,a,c),d=p.accessToken,k=Date.now()+p.expiresIn*1e3,e,t,r=n,m;if(r)try{let w=(await q(s.globalEndpoint,d)).find(P=>P.id===r);if(w){m=w.organizationId;let P=await v(s.workspaceEndpoint,d,r,m);e=P.token,t=new Date(P.expiresAt).getTime(),x(`Workspace token issued for: ${w.name}`);}else O(`Workspace ${r} not found \u2014 skipping workspace token`),r=void 0;}catch(I){O(`Workspace token failed: ${I instanceof Error?I.message:String(I)}`);}b({accessToken:d,refreshToken:"",expiresAt:k,workspaceToken:e,workspaceTokenExpiresAt:t,workspaceId:r,organizationId:m,authMethod:"client_credentials",clientId:a,clientSecret:c}),T(),f("App authentication successful");}function Pe(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(Z);h(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 g("No updates specified");let r=await l(ee,{input:t});f("Profile updated"),h(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(H,{pagination:{limit:e.limit,offset:0}});h(e,t.authAuditLogs.auditLogs,{headers:["When","Action","Resource","IP"],rows:t.authAuditLogs.auditLogs.map(r=>[S(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(te,{pagination:{limit:e.limit,offset:0}});h(e,t.activeSessions.sessions,{headers:["ID","Status","IP","LastActivity","Current"],rows:t.activeSessions.sessions.map(r=>[$(r.id,12),F(r.status),r.ipAddress??"-",S(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(ne,{pagination:{limit:e.limit,offset:0}});h(e,t.currentUserMFAMethods.methods,{headers:["Method","Status","Created"],rows:t.currentUserMFAMethods.methods.map(r=>[r.method,F(r.status),S(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(re,{method:e.method.toUpperCase()});e.format?h(e,t.setupMFA):(f("MFA enrollment started"),M(t.setupMFA),x("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(oe,{code:e.code}),f("MFA enabled");}catch(t){u(t);}}),i.command("disable").description("Disable MFA for the current user").action(async()=>{try{await l(ie),f("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?ae:se,r=e.app?{appId:e.app,pagination:{limit:e.limit,offset:0}}:{pagination:{limit:e.limit,offset:0}},m=await l(t,r),I=(m.myApiKeys??m.appApiKeys)?.apiKeys??[];h(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(","):"-",S(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(ce,{input:t});f("API key generated. Store the secret \u2014 it is only shown once."),M(r.generateAPIKey);}catch(t){u(t);}}),a.command("revoke").description("Revoke an API key").argument("<keyId>").action(async e=>{try{await l(pe,{keyId:e}),f("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(ue,{keyId:e});f("API key rotated"),M(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(H,{pagination:{limit:e.limit,offset:0}});h(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(de,{pagination:{limit:e.limit,offset:0}});h(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(le,{input:t});f("Delegation granted"),h(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(ge,{id:e,reason:t.reason}),f("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(fe,{pagination:{limit:e.limit,offset:0}});h(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??"-",F(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(me,{id:e});if(!r.app)throw new g(`App ${e} not found`);h(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(he,{input:t});f("App created. Client secret only shown once."),M(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 g("No updates specified");let m=await l(ke,{id:e,input:r});f("App updated"),h(t,m.updateApp);}catch(r){u(r);}}),p.command("deactivate").description("Deactivate an app").argument("<id>").action(async e=>{try{await l(we,{id:e}),f("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(ye,{tenantId:e.tenant});h(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(Ae,{tenantId:e.tenant,input:t});f("SSO config saved"),h(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(Ie,{tenantId:e.tenant}),f("SSO config deleted");}catch(t){u(t);}});let k=n.command("users").description("User admin (requires admin permissions)");k.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(Ce,{filter:Object.keys(t).length?t:void 0,pagination:{limit:e.limit,offset:0}});h(e,r.users.users,{headers:["ID","Email","Username","Role","Status","Created"],rows:r.users.users.map(m=>[$(m.id,12),m.email,m.username??"-",m.role??"-",F(m.status),S(m.createdAt)])});}catch(t){u(t);}}),k.command("get").description("Get user by id (admin)").argument("<id>").option("-f, --format <format>").action(async(e,t)=>{try{let r=await l(xe,{id:e});if(!r.user)throw new g(`User ${e} not found`);h(t,r.user);}catch(r){u(r);}}),k.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 g("No updates specified");let m=await l(Ee,{id:e,input:r});f("User updated"),h(t,m.updateUser);}catch(r){u(r);}});}var Ke={id:"auth",version:"1.0.0",displayName:"Authentication",register(n,s){Y(s),Re(n);let o=n.commands.find(i=>i.name()==="auth");if(!o)throw new C("auth command group missing after registerAuthCommands");Pe(o);}},kn=Ke;module.exports=kn;
|