@burdenoff/cli-sdk 2026.928.1 → 2026.1021.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (236) hide show
  1. package/dist/chunk-IZXPWPKX.js +32 -0
  2. package/dist/chunk-NLEVVDXR.js +1 -0
  3. package/dist/core/index.cjs +7 -7
  4. package/dist/core/index.d.cts +2 -2
  5. package/dist/core/index.d.ts +2 -2
  6. package/dist/core/index.js +1 -1
  7. package/dist/index.cjs +7 -7
  8. package/dist/index.d.cts +1 -1
  9. package/dist/index.d.ts +1 -1
  10. package/dist/index.js +1 -1
  11. package/dist/{module-DxCuik6L.d.cts → module-DOIiVaXQ.d.cts} +4 -1
  12. package/dist/{module-DxCuik6L.d.ts → module-DOIiVaXQ.d.ts} +4 -1
  13. package/dist/modules/adaptercloud/index.cjs +2 -2
  14. package/dist/modules/adaptercloud/index.d.cts +1 -1
  15. package/dist/modules/adaptercloud/index.d.ts +1 -1
  16. package/dist/modules/adaptercloud/index.js +1 -1
  17. package/dist/modules/artistrybase/index.cjs +6 -6
  18. package/dist/modules/artistrybase/index.d.cts +1 -1
  19. package/dist/modules/artistrybase/index.d.ts +1 -1
  20. package/dist/modules/artistrybase/index.js +1 -1
  21. package/dist/modules/assethandler/index.cjs +2 -2
  22. package/dist/modules/assethandler/index.d.cts +1 -1
  23. package/dist/modules/assethandler/index.d.ts +1 -1
  24. package/dist/modules/assethandler/index.js +1 -1
  25. package/dist/modules/atheletebridge/index.cjs +4 -4
  26. package/dist/modules/atheletebridge/index.d.cts +1 -1
  27. package/dist/modules/atheletebridge/index.d.ts +1 -1
  28. package/dist/modules/atheletebridge/index.js +1 -1
  29. package/dist/modules/auth/index.cjs +34 -34
  30. package/dist/modules/auth/index.d.cts +1 -1
  31. package/dist/modules/auth/index.d.ts +1 -1
  32. package/dist/modules/auth/index.js +30 -30
  33. package/dist/modules/billing/index.cjs +3 -3
  34. package/dist/modules/billing/index.d.cts +1 -1
  35. package/dist/modules/billing/index.d.ts +1 -1
  36. package/dist/modules/billing/index.js +1 -1
  37. package/dist/modules/brainyrich/index.cjs +4 -4
  38. package/dist/modules/brainyrich/index.d.cts +1 -1
  39. package/dist/modules/brainyrich/index.d.ts +1 -1
  40. package/dist/modules/brainyrich/index.js +1 -1
  41. package/dist/modules/buildmyiq/index.cjs +3 -3
  42. package/dist/modules/buildmyiq/index.d.cts +1 -1
  43. package/dist/modules/buildmyiq/index.d.ts +1 -1
  44. package/dist/modules/buildmyiq/index.js +1 -1
  45. package/dist/modules/channels/index.cjs +7 -7
  46. package/dist/modules/channels/index.d.cts +1 -1
  47. package/dist/modules/channels/index.d.ts +1 -1
  48. package/dist/modules/channels/index.js +1 -1
  49. package/dist/modules/collabkin/index.cjs +11 -11
  50. package/dist/modules/collabkin/index.d.cts +1 -1
  51. package/dist/modules/collabkin/index.d.ts +1 -1
  52. package/dist/modules/collabkin/index.js +1 -1
  53. package/dist/modules/comradecircle/index.cjs +5 -5
  54. package/dist/modules/comradecircle/index.d.cts +1 -1
  55. package/dist/modules/comradecircle/index.d.ts +1 -1
  56. package/dist/modules/comradecircle/index.js +1 -1
  57. package/dist/modules/conversations/index.cjs +8 -8
  58. package/dist/modules/conversations/index.d.cts +1 -1
  59. package/dist/modules/conversations/index.d.ts +1 -1
  60. package/dist/modules/conversations/index.js +1 -1
  61. package/dist/modules/coolandlovely/index.cjs +4 -4
  62. package/dist/modules/coolandlovely/index.d.cts +1 -1
  63. package/dist/modules/coolandlovely/index.d.ts +1 -1
  64. package/dist/modules/coolandlovely/index.js +1 -1
  65. package/dist/modules/cosmicintersection/index.cjs +4 -4
  66. package/dist/modules/cosmicintersection/index.d.cts +1 -1
  67. package/dist/modules/cosmicintersection/index.d.ts +1 -1
  68. package/dist/modules/cosmicintersection/index.js +1 -1
  69. package/dist/modules/crewfoundry/index.cjs +4 -4
  70. package/dist/modules/crewfoundry/index.d.cts +1 -1
  71. package/dist/modules/crewfoundry/index.d.ts +1 -1
  72. package/dist/modules/crewfoundry/index.js +1 -1
  73. package/dist/modules/devportal/index.cjs +5 -5
  74. package/dist/modules/devportal/index.d.cts +1 -1
  75. package/dist/modules/devportal/index.d.ts +1 -1
  76. package/dist/modules/devportal/index.js +1 -1
  77. package/dist/modules/ecoimpacthub/index.cjs +2 -2
  78. package/dist/modules/ecoimpacthub/index.d.cts +1 -1
  79. package/dist/modules/ecoimpacthub/index.d.ts +1 -1
  80. package/dist/modules/ecoimpacthub/index.js +1 -1
  81. package/dist/modules/eventfullymanaged/index.cjs +21 -21
  82. package/dist/modules/eventfullymanaged/index.d.cts +1 -1
  83. package/dist/modules/eventfullymanaged/index.d.ts +1 -1
  84. package/dist/modules/eventfullymanaged/index.js +1 -1
  85. package/dist/modules/export/index.cjs +3 -3
  86. package/dist/modules/export/index.d.cts +1 -1
  87. package/dist/modules/export/index.d.ts +1 -1
  88. package/dist/modules/export/index.js +1 -1
  89. package/dist/modules/files/index.cjs +9 -9
  90. package/dist/modules/files/index.d.cts +1 -1
  91. package/dist/modules/files/index.d.ts +1 -1
  92. package/dist/modules/files/index.js +1 -1
  93. package/dist/modules/fluidgrids/index.cjs +401 -0
  94. package/dist/modules/fluidgrids/index.d.cts +7 -0
  95. package/dist/modules/fluidgrids/index.d.ts +7 -0
  96. package/dist/modules/fluidgrids/index.js +401 -0
  97. package/dist/modules/ggnomad/index.cjs +5 -5
  98. package/dist/modules/ggnomad/index.d.cts +1 -1
  99. package/dist/modules/ggnomad/index.d.ts +1 -1
  100. package/dist/modules/ggnomad/index.js +1 -1
  101. package/dist/modules/govcitizenhub/index.cjs +4 -4
  102. package/dist/modules/govcitizenhub/index.d.cts +1 -1
  103. package/dist/modules/govcitizenhub/index.d.ts +1 -1
  104. package/dist/modules/govcitizenhub/index.js +1 -1
  105. package/dist/modules/groups/index.cjs +4 -4
  106. package/dist/modules/groups/index.d.cts +1 -1
  107. package/dist/modules/groups/index.d.ts +1 -1
  108. package/dist/modules/groups/index.js +1 -1
  109. package/dist/modules/headshotmarketing/index.cjs +1 -1
  110. package/dist/modules/headshotmarketing/index.d.cts +1 -1
  111. package/dist/modules/headshotmarketing/index.d.ts +1 -1
  112. package/dist/modules/headshotmarketing/index.js +1 -1
  113. package/dist/modules/health/index.d.cts +1 -1
  114. package/dist/modules/health/index.d.ts +1 -1
  115. package/dist/modules/hookmovies/index.cjs +7 -7
  116. package/dist/modules/hookmovies/index.d.cts +1 -1
  117. package/dist/modules/hookmovies/index.d.ts +1 -1
  118. package/dist/modules/hookmovies/index.js +1 -1
  119. package/dist/modules/housingvista/index.cjs +7 -7
  120. package/dist/modules/housingvista/index.d.cts +1 -1
  121. package/dist/modules/housingvista/index.d.ts +1 -1
  122. package/dist/modules/housingvista/index.js +1 -1
  123. package/dist/modules/integrations/index.cjs +5 -5
  124. package/dist/modules/integrations/index.d.cts +1 -1
  125. package/dist/modules/integrations/index.d.ts +1 -1
  126. package/dist/modules/integrations/index.js +1 -1
  127. package/dist/modules/intelwatchtower/index.cjs +4 -4
  128. package/dist/modules/intelwatchtower/index.d.cts +1 -1
  129. package/dist/modules/intelwatchtower/index.d.ts +1 -1
  130. package/dist/modules/intelwatchtower/index.js +1 -1
  131. package/dist/modules/kadaikodi/index.cjs +2 -2
  132. package/dist/modules/kadaikodi/index.d.cts +1 -1
  133. package/dist/modules/kadaikodi/index.d.ts +1 -1
  134. package/dist/modules/kadaikodi/index.js +1 -1
  135. package/dist/modules/labsofscience/index.cjs +4 -4
  136. package/dist/modules/labsofscience/index.d.cts +1 -1
  137. package/dist/modules/labsofscience/index.d.ts +1 -1
  138. package/dist/modules/labsofscience/index.js +1 -1
  139. package/dist/modules/manufacturedops/index.cjs +6 -6
  140. package/dist/modules/manufacturedops/index.d.cts +1 -1
  141. package/dist/modules/manufacturedops/index.d.ts +1 -1
  142. package/dist/modules/manufacturedops/index.js +1 -1
  143. package/dist/modules/movethewheels/index.cjs +1 -1
  144. package/dist/modules/movethewheels/index.d.cts +1 -1
  145. package/dist/modules/movethewheels/index.d.ts +1 -1
  146. package/dist/modules/movethewheels/index.js +1 -1
  147. package/dist/modules/mybodyshield/index.cjs +6 -6
  148. package/dist/modules/mybodyshield/index.d.cts +1 -1
  149. package/dist/modules/mybodyshield/index.d.ts +1 -1
  150. package/dist/modules/mybodyshield/index.js +1 -1
  151. package/dist/modules/notifications/index.cjs +5 -5
  152. package/dist/modules/notifications/index.d.cts +1 -1
  153. package/dist/modules/notifications/index.d.ts +1 -1
  154. package/dist/modules/notifications/index.js +1 -1
  155. package/dist/modules/organizations/index.d.cts +1 -1
  156. package/dist/modules/organizations/index.d.ts +1 -1
  157. package/dist/modules/organizations/index.js +1 -1
  158. package/dist/modules/planmagnet/index.cjs +23 -23
  159. package/dist/modules/planmagnet/index.d.cts +1 -1
  160. package/dist/modules/planmagnet/index.d.ts +1 -1
  161. package/dist/modules/planmagnet/index.js +1 -1
  162. package/dist/modules/products/index.cjs +4 -4
  163. package/dist/modules/products/index.d.cts +1 -1
  164. package/dist/modules/products/index.d.ts +1 -1
  165. package/dist/modules/products/index.js +1 -1
  166. package/dist/modules/proserviceworld/index.cjs +2 -2
  167. package/dist/modules/proserviceworld/index.d.cts +1 -1
  168. package/dist/modules/proserviceworld/index.d.ts +1 -1
  169. package/dist/modules/proserviceworld/index.js +1 -1
  170. package/dist/modules/rbac/index.cjs +2 -2
  171. package/dist/modules/rbac/index.d.cts +1 -1
  172. package/dist/modules/rbac/index.d.ts +1 -1
  173. package/dist/modules/rbac/index.js +1 -1
  174. package/dist/modules/sandbox/index.cjs +4 -4
  175. package/dist/modules/sandbox/index.d.cts +1 -1
  176. package/dist/modules/sandbox/index.d.ts +1 -1
  177. package/dist/modules/sandbox/index.js +1 -1
  178. package/dist/modules/scheduler/index.cjs +5 -5
  179. package/dist/modules/scheduler/index.d.cts +1 -1
  180. package/dist/modules/scheduler/index.d.ts +1 -1
  181. package/dist/modules/scheduler/index.js +1 -1
  182. package/dist/modules/security/index.cjs +7 -7
  183. package/dist/modules/security/index.d.cts +1 -1
  184. package/dist/modules/security/index.d.ts +1 -1
  185. package/dist/modules/security/index.js +1 -1
  186. package/dist/modules/semanticfed/index.cjs +7 -7
  187. package/dist/modules/semanticfed/index.d.cts +1 -1
  188. package/dist/modules/semanticfed/index.d.ts +1 -1
  189. package/dist/modules/semanticfed/index.js +1 -1
  190. package/dist/modules/store/index.cjs +7 -7
  191. package/dist/modules/store/index.d.cts +1 -1
  192. package/dist/modules/store/index.d.ts +1 -1
  193. package/dist/modules/store/index.js +1 -1
  194. package/dist/modules/subscriberbot/index.cjs +2 -2
  195. package/dist/modules/subscriberbot/index.d.cts +1 -1
  196. package/dist/modules/subscriberbot/index.d.ts +1 -1
  197. package/dist/modules/subscriberbot/index.js +1 -1
  198. package/dist/modules/support/index.cjs +2 -2
  199. package/dist/modules/support/index.d.cts +1 -1
  200. package/dist/modules/support/index.d.ts +1 -1
  201. package/dist/modules/support/index.js +1 -1
  202. package/dist/modules/tags/index.cjs +2 -2
  203. package/dist/modules/tags/index.d.cts +1 -1
  204. package/dist/modules/tags/index.d.ts +1 -1
  205. package/dist/modules/tags/index.js +1 -1
  206. package/dist/modules/technospam/index.cjs +4 -4
  207. package/dist/modules/technospam/index.d.cts +1 -1
  208. package/dist/modules/technospam/index.d.ts +1 -1
  209. package/dist/modules/technospam/index.js +1 -1
  210. package/dist/modules/theculturepost/index.cjs +3 -3
  211. package/dist/modules/theculturepost/index.d.cts +1 -1
  212. package/dist/modules/theculturepost/index.d.ts +1 -1
  213. package/dist/modules/theculturepost/index.js +1 -1
  214. package/dist/modules/theglobalfuel/index.cjs +3 -3
  215. package/dist/modules/theglobalfuel/index.d.cts +1 -1
  216. package/dist/modules/theglobalfuel/index.d.ts +1 -1
  217. package/dist/modules/theglobalfuel/index.js +1 -1
  218. package/dist/modules/timecampus/index.cjs +7 -7
  219. package/dist/modules/timecampus/index.d.cts +1 -1
  220. package/dist/modules/timecampus/index.d.ts +1 -1
  221. package/dist/modules/timecampus/index.js +1 -1
  222. package/dist/modules/tours/index.cjs +2 -2
  223. package/dist/modules/tours/index.d.cts +1 -1
  224. package/dist/modules/tours/index.d.ts +1 -1
  225. package/dist/modules/tours/index.js +1 -1
  226. package/dist/modules/vibecontrols/index.cjs +1 -1
  227. package/dist/modules/vibecontrols/index.d.cts +1 -1
  228. package/dist/modules/vibecontrols/index.d.ts +1 -1
  229. package/dist/modules/vibecontrols/index.js +1 -1
  230. package/dist/modules/workspaces/index.cjs +15 -15
  231. package/dist/modules/workspaces/index.d.cts +1 -1
  232. package/dist/modules/workspaces/index.d.ts +1 -1
  233. package/dist/modules/workspaces/index.js +11 -11
  234. package/package.json +1 -1
  235. package/dist/chunk-TCBALVP4.js +0 -32
  236. package/dist/chunk-WXDQ3S5J.js +0 -1
@@ -0,0 +1,32 @@
1
+ import {existsSync,readFileSync,writeFileSync,chmodSync,unlinkSync,mkdirSync}from'fs';import {join}from'path';import {homedir}from'os';import {GraphQLClient}from'graphql-request';import C from'cross-fetch';import {Command}from'commander';var G=300*1e3;function O(e){let n=join(e,"auth.json");function r(){existsSync(e)||mkdirSync(e,{recursive:true,mode:448});}function t(){try{if(!existsSync(n))return null;let a=readFileSync(n,"utf8");return JSON.parse(a)}catch{return null}}function s(a){r(),writeFileSync(n,JSON.stringify(a,null,2),{encoding:"utf8",mode:384});try{chmodSync(n,384);}catch{}}function i(){try{existsSync(n)&&unlinkSync(n);}catch{}}function o(){let a=t();return a?.expiresAt?Date.now()>=a.expiresAt:false}function u(){let a=t();return a?.expiresAt?Date.now()+G>=a.expiresAt:false}function d(){let a=t();return a?.workspaceTokenExpiresAt?Date.now()>=a.workspaceTokenExpiresAt:false}function m(){let a=t();return a?.workspaceTokenExpiresAt?Date.now()+G>=a.workspaceTokenExpiresAt:false}function b(){return t()?.accessToken?!o():false}return {read:t,write:s,clear:i,isTokenExpired:o,isTokenExpiringSoon:u,isWorkspaceTokenExpired:d,isWorkspaceTokenExpiringSoon:m,isAuthenticated:b}}var ce=["workspaceEndpoint","globalEndpoint","oidcIssuer","clientId","defaultFormat","verbose","authServiceEndpoint","productOrigin"];function S(e){let n=join(homedir(),".config",e.configDirName),r=join(n,"config.json"),t={workspaceEndpoint:e.workspaceEndpointDefault,globalEndpoint:e.globalEndpointDefault};function s(){existsSync(n)||mkdirSync(n,{recursive:true,mode:448});}function i(c){if(e.envPrefix){let p=process.env[`${e.envPrefix}_${c}`];if(p)return p}let l=process.env[c];return l&&l.length>0?l:void 0}function o(c){if(!e.envPrefix)return;let l=process.env[`${e.envPrefix}_${c}`];return l&&l.length>0?l:void 0}function u(){let c={};try{existsSync(r)&&(c=JSON.parse(readFileSync(r,"utf8")));}catch{}return {...t,...c,workspaceEndpoint:i("WORKSPACE_ENDPOINT")??c.workspaceEndpoint??t.workspaceEndpoint,globalEndpoint:i("GLOBAL_ENDPOINT")??c.globalEndpoint??t.globalEndpoint,oidcIssuer:i("OIDC_ISSUER")??c.oidcIssuer,clientId:i("CLIENT_ID")??c.clientId,productOrigin:o("ORIGIN")??c.productOrigin}}function d(c){s(),writeFileSync(r,JSON.stringify(c,null,2),{encoding:"utf8"});try{chmodSync(r,384);}catch{}}function m(c){return u()[c]}function b(c,l){let p=u();p[c]=l,d(p);}function a(){let c=u(),l=c.clientId||e.oidcClientId,p=c.oidcIssuer;if(!p){let f=c.globalEndpoint;f.includes("localhost")||f.includes("127.0.0.1")?p=f.replace(/\/graphql$/,"").replace(/\/global\/graphql$/,"/global"):p=e.oidcIssuerProd??"https://graphql.burdenoff.com/global";}return {oidcIssuer:p,clientId:l}}function g(){let c=u();if(c.productOrigin)return c.productOrigin;if(e.productOrigins)try{let l=new URL(c.workspaceEndpoint).hostname.toLowerCase();return e.productOrigins[l]}catch{return}}return {read:u,write:d,get:m,set:b,path:()=>r,dir:()=>n,resolveOIDC:a,resolveProductOrigin:g}}async function ue(e){let n=`${e.oidcIssuer}/oidc/device/code`,r=new URLSearchParams({client_id:e.clientId,scope:"openid profile email offline_access"}),t=await C(n,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:r.toString()});if(!t.ok){let i=await t.text().catch(()=>"Unknown error");throw new Error(`Device code request failed (${t.status}): ${i}`)}let s=await t.json();return {deviceCode:s.device_code,userCode:s.user_code,verificationUri:s.verification_uri,verificationUriComplete:s.verification_uri_complete??null,expiresIn:s.expires_in,interval:s.interval??5}}async function le(e,n,r){let t=`${r.oidcIssuer}/oauth/device/token`,s=n;for(;;){await new Promise(d=>setTimeout(d,s*1e3));let i=await C(t,{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:e,client_id:r.clientId}).toString()}),o=await i.json();if(i.ok&&o.access_token)return {accessToken:o.access_token,refreshToken:o.refresh_token??"",expiresIn:o.expires_in??3600};let u=o.error;switch(u){case "authorization_pending":continue;case "slow_down":s+=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: ${o.error_description??u??"Unknown error"}`)}}}async function $(e,n,r,t){let i=await C(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:`
2
+ mutation AuthenticateApp($input: AuthenticateAppInput!) {
3
+ authenticateApp(input: $input) {
4
+ accessToken tokenType expiresIn scopes
5
+ }
6
+ }
7
+ `,variables:{input:{clientId:n,clientSecret:r,scopes:t}}})});if(!i.ok){let u=await i.text().catch(()=>"Unknown error");throw new Error(`App authentication failed (${i.status}): ${u}`)}let o=await i.json();if(o.errors?.length)throw new Error(`App authentication failed: ${o.errors[0]?.message??"unknown error"}`);if(!o.data?.authenticateApp?.accessToken)throw new Error("App authentication failed: no access token returned");return o.data.authenticateApp}async function P(e,n,r,t){let i=await C(e,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`},body:JSON.stringify({query:`
8
+ mutation IssueWorkspaceToken($input: IssueWorkspaceTokenInput!) {
9
+ issueWorkspaceToken(input: $input) {
10
+ success token expiresAt scopes
11
+ error { code message }
12
+ }
13
+ }
14
+ `,variables:{input:{workspaceId:r,organizationId:t}}})});if(!i.ok){let d=await i.text().catch(()=>"Unknown error");throw new Error(`Workspace token request failed (${i.status}): ${d}`)}let o=await i.json();if(o.errors?.length)throw new Error(`Workspace token failed: ${o.errors[0]?.message??"unknown error"}`);let u=o.data?.issueWorkspaceToken;if(!u?.success||!u.token){let d=u?.error?.message??"Unknown error";throw new Error(`Workspace token failed: ${d}`)}return {token:u.token,expiresAt:u.expiresAt??"",scopes:u.scopes??[]}}async function pe(e,n){let t=await C(e,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`},body:JSON.stringify({query:`
15
+ query MyWorkspaces($limit: Int) {
16
+ myWorkspaces(limit: $limit) {
17
+ items { id name slug tenantId organizationId }
18
+ }
19
+ }
20
+ `,variables:{limit:50}})});if(!t.ok){let i=await t.text().catch(()=>"Unknown error");throw new Error(`Failed to fetch workspaces (${t.status}): ${i}`)}let s=await t.json();if(s.errors?.length)throw new Error(`Failed to fetch workspaces: ${s.errors[0]?.message??"unknown error"}`);return s.data?.myWorkspaces?.items??[]}function de(e){try{let n=new URL(e);return n.protocol==="http:"||n.protocol==="https:"}catch{return false}}async function ge(e){try{if(!de(e))return !1;let{execFile:n}=await import('child_process'),r=process.platform,t,s;return r==="darwin"?(t="open",s=[e]):r==="win32"?(t="cmd",s=["/c","start","",e]):(t="xdg-open",s=[e]),new Promise(i=>{n(t,s,o=>{i(!o);});})}catch{return false}}var fe=3e4,z=3,me=1e3;function ke(e){return new Promise(n=>setTimeout(n,e))}function we(e){if(e instanceof TypeError)return true;if(e&&typeof e=="object"&&"response"in e){let n=e.response;if(n&&typeof n.status=="number"&&n.status>=500)return true}return false}function H(e){if(e&&typeof e=="object"&&"response"in e){let n=e,r=n.response?.errors?.[0],t=r?.extensions?.originalError?.message;if(t)return t;if(r?.message)return r.message;if(n.message)return n.message}return e instanceof Error?e.message:String(e)}function T(e){let n={};return e?.accessToken&&(n.Authorization=`Bearer ${e.accessToken}`),e?.organizationId&&(n["x-org-id"]=e.organizationId),n}function B(e,n){let r=T(e);return n&&(r.Origin=n),e?.workspaceToken&&(r["X-Workspace-Authorization"]=`Bearer ${e.workspaceToken}`),e?.organizationId&&(r["x-org-id"]=e.organizationId),r}async function R(e,n,r){let t;for(let s=0;s<z;s++)try{let i=new AbortController,o=setTimeout(()=>i.abort(),fe);try{return await e.request({document:n,variables:r,signal:i.signal})}finally{clearTimeout(o);}}catch(i){if(t=i,i&&typeof i=="object"&&"response"in i){let o=i.response;if(o&&typeof o.status=="number"&&o.status>=400&&o.status<500)break}if(we(i)&&s<z-1){let o=me*Math.pow(2,s);await ke(o);continue}break}throw new Error(H(t))}function D(e,n){let r=null,t=null;function s(){let a=e.read(),g=n.read();return r=new GraphQLClient(a.workspaceEndpoint),r.setHeaders(B(g,e.resolveProductOrigin())),t=new GraphQLClient(a.globalEndpoint),t.setHeaders(T(g)),{workspace:r,global:t}}async function i(){let a=n.read();if(!a)return;if(a.authMethod==="client_credentials"&&a.clientId&&a.clientSecret){let p=e.read();try{let f=await $(p.globalEndpoint,a.clientId,a.clientSecret);n.write({...a,accessToken:f.accessToken,expiresAt:Date.now()+f.expiresIn*1e3}),r=null,t=null;}catch{}return}if(!a.refreshToken)return;let g=e.read(),c=new GraphQLClient(g.globalEndpoint);c.setHeaders({Authorization:`Bearer ${a.accessToken}`});let l=`
21
+ mutation RefreshToken($token: String!) {
22
+ refreshToken(token: $token) {
23
+ accessToken
24
+ refreshToken
25
+ expiresIn
26
+ }
27
+ }
28
+ `;try{let f=(await c.request(l,{token:a.refreshToken})).refreshToken;n.write({...a,accessToken:f.accessToken,refreshToken:f.refreshToken,expiresAt:Date.now()+f.expiresIn*1e3}),r=null,t=null;}catch{}}async function o(){let a=n.read();if(!a?.accessToken||!a.workspaceId||!a.organizationId)return;let g=e.read();try{let c=await P(g.workspaceEndpoint,a.accessToken,a.workspaceId,a.organizationId);n.write({...a,workspaceToken:c.token,workspaceTokenExpiresAt:new Date(c.expiresAt).getTime()}),r=null;}catch{}}async function u(){n.isTokenExpiringSoon()&&await i(),n.read()?.workspaceToken&&n.isWorkspaceTokenExpiringSoon()&&await o();}return {workspace:{async request(a,g){await u();let{workspace:c}=r?{workspace:r}:s();return c.setHeaders(B(n.read(),e.resolveProductOrigin())),R(c,a,g)}},global:{async request(a,g){let{global:c}=t?{global:t}:s();return c.setHeaders(T(n.read())),R(c,a,g)}},workspaceAuthOnly:{async request(a,g){let c=e.read(),l=n.read(),p=new GraphQLClient(c.workspaceEndpoint),f=T(l),W=e.resolveProductOrigin();return W&&(f.Origin=W),p.setHeaders(f),R(p,a,g)}},reset(){r=null,t=null;}}}function _(){return !!(process.stdout.isTTY&&process.stdin.isTTY)}function V(e){if(e.format){let n=e.format.toLowerCase();if(n==="json"||n==="table"||n==="yaml")return n}return _()?"table":"json"}function L(e){console.log(JSON.stringify(e,null,2));}function J(e,n){if(e.length===0)return;let r=e.map((i,o)=>{let u=i.length;for(let d of n){let m=d[o]??"";m.length>u&&(u=m.length);}return Math.min(u,50)}),t=r.map(i=>"-".repeat(i+2)).join("+"),s=i=>i.map((o,u)=>` ${(o??"").padEnd(r[u]??0)} `).join("|");console.log(s(e)),console.log(t);for(let i of n)console.log(s(i));}function q(e,n){let r=" ".repeat(n),t=[];for(let[s,i]of Object.entries(e))if(i==null)t.push(`${r}${s}: null`);else if(Array.isArray(i)){t.push(`${r}${s}:`);for(let o of i)typeof o=="object"&&o!==null?(t.push(`${r} -`),t.push(q(o,n+2))):t.push(`${r} - ${String(o)}`);}else typeof i=="object"?(t.push(`${r}${s}:`),t.push(q(i,n+1))):t.push(`${r}${s}: ${String(i)}`);return t.join(`
29
+ `)}function Y(e){if(typeof e!="object"||e===null){console.log(String(e));return}console.log(q(e,0));}function he(e){console.log(`\u2713 ${e}`);}function K(e){console.error(`\u2717 ${e}`);}function ye(e){console.warn(`! ${e}`);}function Ce(e){console.log(`\u2139 ${e}`);}function xe(e){if(!e)return "-";try{return new Date(e).toLocaleString()}catch{return e}}function be(e){if(!e)return "-";switch(e.toUpperCase()){case "ACTIVE":case "RUNNING":case "HEALTHY":return `\u2713 ${e}`;case "INACTIVE":case "STOPPED":case "PENDING":return `\u25CB ${e}`;case "ERROR":return `\u2717 ${e}`;case "ARCHIVED":return `\u2192 ${e}`;case "STARTING":return `\u25B6 ${e}`;case "TERMINATED":return `\u25A0 ${e}`;default:return e}}function ve(e,n){return e?e.length<=n?e:e.substring(0,n-3)+"...":"-"}function Te(e,n,r){switch(V(e)){case "json":L(n);break;case "yaml":Y(n);break;case "table":r?J(r.headers,r.rows):L(n);break}}async function Ee(e,n){return n?true:_()?new Promise(r=>{process.stdout.write(`${e} [y/N] `),process.stdin.setEncoding("utf8"),process.stdin.once("data",t=>{let s=t.trim().toLowerCase();r(s==="y"||s==="yes");}),process.stdin.resume();}):(K(`${e} Use --force to skip confirmation.`),false)}var N={isInteractive:_,getFormat:V,formatAndOutput:Te,printJson:L,printTable:J,printYaml:Y,printSuccess:he,printError:K,printWarning:ye,printInfo:Ce,formatDate:xe,formatStatus:be,truncate:ve,confirm:Ee};function j(e={}){let{verbose:n=false,quiet:r=false}=e;return {debug(t,...s){n&&console.error(`[debug] ${t}`,...s);},info(t,...s){r||console.error(`[info] ${t}`,...s);},warn(t,...s){console.error(`[warn] ${t}`,...s);},error(t,...s){console.error(`[error] ${t}`,...s);}}}function Ie(e){return e.includes("localhost")||e.includes("127.0.0.1")?"local":e.includes("alpha")||e.includes("staging")?"staging":"prod"}function Ae(e){return !!e&&typeof e.debug=="function"&&typeof e.info=="function"}function Oe(e){let n=S(e.defaults),r=O(n.dir()),t=D(n,r),s=e.output??N,i=Ae(e.logger)?e.logger:j(e.logger),o=e.env??Ie(n.read().workspaceEndpoint);return {productName:e.productName,productVersion:e.productVersion,defaults:e.defaults,config:n,auth:r,gql:t,output:s,logger:i,env:o}}var y=class extends Error{exitCode;hint;constructor(n,r){super(n),this.name="CliUserError",this.exitCode=r?.exitCode??1,this.hint=r?.hint;}},x=class extends y{constructor(n,r){super(n,{exitCode:2,hint:r?.hint??"Run `<product> auth login` to authenticate."}),this.name="CliAuthError";}},h=class extends Error{cause;constructor(n,r){super(n),this.name="CliInternalError",this.cause=r;}};var E=class extends h{constructor(n,r){super(`Module '${n}' declares dependency on '${r}', but '${r}' is not in the module list.`),this.name="MissingDependencyError";}},I=class extends h{constructor(n){super(`Circular dependency detected among modules: ${n.join(" -> ")}`),this.name="CircularDependencyError";}};function F(e){let n=new Map;for(let o of e){if(n.has(o.id))throw new h(`Duplicate module id: '${o.id}'`);n.set(o.id,o);}for(let o of e)for(let u of o.dependsOn??[])if(!n.has(u))throw new E(o.id,u);let r=[],t=new Set,s=new Set;function i(o,u){if(!s.has(o.id)){if(t.has(o.id))throw new I([...u,o.id]);t.add(o.id);for(let d of o.dependsOn??[]){let m=n.get(d);m&&i(m,[...u,o.id]);}t.delete(o.id),s.add(o.id),r.push(o);}}for(let o of e)i(o,[]);return r}function $e(e,n,r){let t=new Command;t.name(r.name).description(r.description??"").version(r.version,"-v, --version").option("-f, --format <format>","Output format (json, table, yaml)").option("--verbose","Enable verbose logging").option("--no-color","Disable colored output");let s=F(n);for(let o of s)o.register(t,e);r.helpExamples?.length&&t.addHelpText("after",`
30
+ Examples:
31
+ `+r.helpExamples.map(o=>" "+o).join(`
32
+ `)),t.on("command:*",()=>{e.output.printError(`Invalid command: ${t.args.join(" ")}`),e.output.printInfo(`Run \`${r.name} --help\` for available commands.`),process.exit(1);});async function i(o=process.argv){try{await t.parseAsync(o),o.length<=2&&t.outputHelp();}catch(u){Pe(e,u);}}return {program:t,run:i}}function Pe(e,n){if(n instanceof x&&(e.output.printError(n.message),n.hint&&e.output.printInfo(n.hint),process.exit(n.exitCode)),n instanceof y&&(e.output.printError(n.message),n.hint&&e.output.printInfo(n.hint),process.exit(n.exitCode)),n instanceof h&&(e.output.printError(`Internal error: ${n.message}`),n.cause&&e.logger.debug("caused by:",n.cause),process.exit(70)),n&&typeof n=="object"&&"code"in n&&"exitCode"in n){let t=n.exitCode;process.exit(typeof t=="number"?t:0);}let r=n instanceof Error?n.message:String(n);e.output.printError(r),process.exit(1);}export{O as a,ce as b,S as c,ue as d,le as e,$ as f,P as g,pe as h,ge as i,H as j,D as k,N as l,j as m,Oe as n,y as o,x as p,h as q,E as r,I as s,F as t,$e as u};
@@ -0,0 +1 @@
1
+ import {b as b$1,o,p,q as q$1}from'./chunk-IZXPWPKX.js';var r=null;function T(t){r=t;}function e(){if(!r)throw new q$1("vibecontrols module helpers used before setHelpersContext was called");return r}function c(){let t=e();if(!t.auth.isAuthenticated())throw new p("Authentication required.",{hint:`Run \`${t.productName} auth login\` to authenticate.`})}async function q(t,n){return c(),e().gql.workspace.request(t,n)}async function w(t,n){return e().gql.global.request(t,n)}async function b(t,n){return e().gql.workspaceAuthOnly.request(t,n)}async function A(t,n){return e().gql.global.request(t,n)}function v(){e().gql.reset();}function I(t){let n=t instanceof Error?t.message:String(t);throw new o(n)}function k(t,n,p){e().output.formatAndOutput(t,n,p);}function E(t){e().output.printSuccess(t);}function O(t){e().output.printError(t);}function S(t){e().output.printInfo(t);}function D(t){e().output.printWarning(t);}function y(t){e().output.printJson(t);}function N(t){return e().output.formatStatus(t)}function R(t){return e().output.formatDate(t)}function W(t,n){return e().output.truncate(t,n)}function F(t,n){return e().output.confirm(t,n)}function L(t,n){e().output.printTable(t,n);}function V(){return e()}function P(){return e().auth.read()}function _(t){e().auth.write(t);}function K(){e().auth.clear();}function G(){return e().config.read()}function Y(t){return e().config.get(t)}function j(t,n){e().config.set(t,n);}function H(){return e().config.path()}var J=b$1;function B(){return e().config.resolveOIDC()}function U(t){return t?t.expiresAt?Date.now()>=t.expiresAt:false:e().auth.isTokenExpired()}export{J as A,B,U as C,T as a,q as b,w as c,b as d,A as e,v as f,I as g,k as h,E as i,O as j,S as k,D as l,y as m,N as n,R as o,W as p,F as q,L as r,V as s,P as t,_ as u,K as v,G as w,Y as x,j as y,H as z};
@@ -1,23 +1,23 @@
1
- 'use strict';var fs=require('fs'),path=require('path'),os=require('os'),graphqlRequest=require('graphql-request'),y=require('cross-fetch'),commander=require('commander');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var y__default=/*#__PURE__*/_interopDefault(y);var F=300*1e3;function A(e){let n=path.join(e,"auth.json");function r(){fs.existsSync(e)||fs.mkdirSync(e,{recursive:true,mode:448});}function t(){try{if(!fs.existsSync(n))return null;let s=fs.readFileSync(n,"utf8");return JSON.parse(s)}catch{return null}}function a(s){r(),fs.writeFileSync(n,JSON.stringify(s,null,2),{encoding:"utf8",mode:384});try{fs.chmodSync(n,384);}catch{}}function i(){try{fs.existsSync(n)&&fs.unlinkSync(n);}catch{}}function o(){let s=t();return s?.expiresAt?Date.now()>=s.expiresAt:false}function c(){let s=t();return s?.expiresAt?Date.now()+F>=s.expiresAt:false}function p(){let s=t();return s?.workspaceTokenExpiresAt?Date.now()>=s.workspaceTokenExpiresAt:false}function d(){let s=t();return s?.workspaceTokenExpiresAt?Date.now()+F>=s.workspaceTokenExpiresAt:false}function x(){return t()?.accessToken?!o():false}return {read:t,write:a,clear:i,isTokenExpired:o,isTokenExpiringSoon:c,isWorkspaceTokenExpired:p,isWorkspaceTokenExpiringSoon:d,isAuthenticated:x}}var ie=["workspaceEndpoint","globalEndpoint","oidcIssuer","clientId","defaultFormat","verbose","authServiceEndpoint"];function S(e){let n=path.join(os.homedir(),".config",e.configDirName),r=path.join(n,"config.json"),t={workspaceEndpoint:e.workspaceEndpointDefault,globalEndpoint:e.globalEndpointDefault};function a(){fs.existsSync(n)||fs.mkdirSync(n,{recursive:true,mode:448});}function i(s){if(e.envPrefix){let u=process.env[`${e.envPrefix}_${s}`];if(u)return u}let l=process.env[s];return l&&l.length>0?l:void 0}function o(){let s={};try{fs.existsSync(r)&&(s=JSON.parse(fs.readFileSync(r,"utf8")));}catch{}return {...t,...s,workspaceEndpoint:i("WORKSPACE_ENDPOINT")??s.workspaceEndpoint??t.workspaceEndpoint,globalEndpoint:i("GLOBAL_ENDPOINT")??s.globalEndpoint??t.globalEndpoint,oidcIssuer:i("OIDC_ISSUER")??s.oidcIssuer,clientId:i("CLIENT_ID")??s.clientId}}function c(s){a(),fs.writeFileSync(r,JSON.stringify(s,null,2),{encoding:"utf8"});try{fs.chmodSync(r,384);}catch{}}function p(s){return o()[s]}function d(s,l){let u=o();u[s]=l,c(u);}function x(){let s=o(),l=s.clientId||e.oidcClientId,u=s.oidcIssuer;if(!u){let m=s.globalEndpoint;m.includes("localhost")||m.includes("127.0.0.1")?u=m.replace(/\/graphql$/,"").replace(/\/global\/graphql$/,"/global"):u=e.oidcIssuerProd??"https://graphql.burdenoff.com/global";}return {oidcIssuer:u,clientId:l}}return {read:o,write:c,get:p,set:d,path:()=>r,dir:()=>n,resolveOIDC:x}}async function ae(e){let n=`${e.oidcIssuer}/oidc/device/code`,r=new URLSearchParams({client_id:e.clientId,scope:"openid profile email offline_access"}),t=await y__default.default(n,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:r.toString()});if(!t.ok){let i=await t.text().catch(()=>"Unknown error");throw new Error(`Device code request failed (${t.status}): ${i}`)}let a=await t.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 ce(e,n,r){let t=`${r.oidcIssuer}/oauth/device/token`,a=n;for(;;){await new Promise(p=>setTimeout(p,a*1e3));let i=await y__default.default(t,{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:e,client_id:r.clientId}).toString()}),o=await i.json();if(i.ok&&o.access_token)return {accessToken:o.access_token,refreshToken:o.refresh_token??"",expiresIn:o.expires_in??3600};let c=o.error;switch(c){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: ${o.error_description??c??"Unknown error"}`)}}}async function O(e,n,r,t){let i=await y__default.default(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:`
1
+ 'use strict';var fs=require('fs'),path=require('path'),os=require('os'),graphqlRequest=require('graphql-request'),y=require('cross-fetch'),commander=require('commander');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var y__default=/*#__PURE__*/_interopDefault(y);var W=300*1e3;function A(e){let n=path.join(e,"auth.json");function r(){fs.existsSync(e)||fs.mkdirSync(e,{recursive:true,mode:448});}function t(){try{if(!fs.existsSync(n))return null;let a=fs.readFileSync(n,"utf8");return JSON.parse(a)}catch{return null}}function s(a){r(),fs.writeFileSync(n,JSON.stringify(a,null,2),{encoding:"utf8",mode:384});try{fs.chmodSync(n,384);}catch{}}function i(){try{fs.existsSync(n)&&fs.unlinkSync(n);}catch{}}function o(){let a=t();return a?.expiresAt?Date.now()>=a.expiresAt:false}function u(){let a=t();return a?.expiresAt?Date.now()+W>=a.expiresAt:false}function d(){let a=t();return a?.workspaceTokenExpiresAt?Date.now()>=a.workspaceTokenExpiresAt:false}function m(){let a=t();return a?.workspaceTokenExpiresAt?Date.now()+W>=a.workspaceTokenExpiresAt:false}function x(){return t()?.accessToken?!o():false}return {read:t,write:s,clear:i,isTokenExpired:o,isTokenExpiringSoon:u,isWorkspaceTokenExpired:d,isWorkspaceTokenExpiringSoon:m,isAuthenticated:x}}var ae=["workspaceEndpoint","globalEndpoint","oidcIssuer","clientId","defaultFormat","verbose","authServiceEndpoint","productOrigin"];function O(e){let n=path.join(os.homedir(),".config",e.configDirName),r=path.join(n,"config.json"),t={workspaceEndpoint:e.workspaceEndpointDefault,globalEndpoint:e.globalEndpointDefault};function s(){fs.existsSync(n)||fs.mkdirSync(n,{recursive:true,mode:448});}function i(c){if(e.envPrefix){let p=process.env[`${e.envPrefix}_${c}`];if(p)return p}let l=process.env[c];return l&&l.length>0?l:void 0}function o(c){if(!e.envPrefix)return;let l=process.env[`${e.envPrefix}_${c}`];return l&&l.length>0?l:void 0}function u(){let c={};try{fs.existsSync(r)&&(c=JSON.parse(fs.readFileSync(r,"utf8")));}catch{}return {...t,...c,workspaceEndpoint:i("WORKSPACE_ENDPOINT")??c.workspaceEndpoint??t.workspaceEndpoint,globalEndpoint:i("GLOBAL_ENDPOINT")??c.globalEndpoint??t.globalEndpoint,oidcIssuer:i("OIDC_ISSUER")??c.oidcIssuer,clientId:i("CLIENT_ID")??c.clientId,productOrigin:o("ORIGIN")??c.productOrigin}}function d(c){s(),fs.writeFileSync(r,JSON.stringify(c,null,2),{encoding:"utf8"});try{fs.chmodSync(r,384);}catch{}}function m(c){return u()[c]}function x(c,l){let p=u();p[c]=l,d(p);}function a(){let c=u(),l=c.clientId||e.oidcClientId,p=c.oidcIssuer;if(!p){let f=c.globalEndpoint;f.includes("localhost")||f.includes("127.0.0.1")?p=f.replace(/\/graphql$/,"").replace(/\/global\/graphql$/,"/global"):p=e.oidcIssuerProd??"https://graphql.burdenoff.com/global";}return {oidcIssuer:p,clientId:l}}function g(){let c=u();if(c.productOrigin)return c.productOrigin;if(e.productOrigins)try{let l=new URL(c.workspaceEndpoint).hostname.toLowerCase();return e.productOrigins[l]}catch{return}}return {read:u,write:d,get:m,set:x,path:()=>r,dir:()=>n,resolveOIDC:a,resolveProductOrigin:g}}async function ce(e){let n=`${e.oidcIssuer}/oidc/device/code`,r=new URLSearchParams({client_id:e.clientId,scope:"openid profile email offline_access"}),t=await y__default.default(n,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:r.toString()});if(!t.ok){let i=await t.text().catch(()=>"Unknown error");throw new Error(`Device code request failed (${t.status}): ${i}`)}let s=await t.json();return {deviceCode:s.device_code,userCode:s.user_code,verificationUri:s.verification_uri,verificationUriComplete:s.verification_uri_complete??null,expiresIn:s.expires_in,interval:s.interval??5}}async function ue(e,n,r){let t=`${r.oidcIssuer}/oauth/device/token`,s=n;for(;;){await new Promise(d=>setTimeout(d,s*1e3));let i=await y__default.default(t,{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:e,client_id:r.clientId}).toString()}),o=await i.json();if(i.ok&&o.access_token)return {accessToken:o.access_token,refreshToken:o.refresh_token??"",expiresIn:o.expires_in??3600};let u=o.error;switch(u){case "authorization_pending":continue;case "slow_down":s+=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: ${o.error_description??u??"Unknown error"}`)}}}async function S(e,n,r,t){let i=await y__default.default(e,{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:n,clientSecret:r,scopes:t}}})});if(!i.ok){let c=await i.text().catch(()=>"Unknown error");throw new Error(`App authentication failed (${i.status}): ${c}`)}let o=await i.json();if(o.errors?.length)throw new Error(`App authentication failed: ${o.errors[0]?.message??"unknown error"}`);if(!o.data?.authenticateApp?.accessToken)throw new Error("App authentication failed: no access token returned");return o.data.authenticateApp}async function $(e,n,r,t){let i=await y__default.default(e,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`},body:JSON.stringify({query:`
7
+ `,variables:{input:{clientId:n,clientSecret:r,scopes:t}}})});if(!i.ok){let u=await i.text().catch(()=>"Unknown error");throw new Error(`App authentication failed (${i.status}): ${u}`)}let o=await i.json();if(o.errors?.length)throw new Error(`App authentication failed: ${o.errors[0]?.message??"unknown error"}`);if(!o.data?.authenticateApp?.accessToken)throw new Error("App authentication failed: no access token returned");return o.data.authenticateApp}async function $(e,n,r,t){let i=await y__default.default(e,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`},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:r,organizationId:t}}})});if(!i.ok){let p=await i.text().catch(()=>"Unknown error");throw new Error(`Workspace token request failed (${i.status}): ${p}`)}let o=await i.json();if(o.errors?.length)throw new Error(`Workspace token failed: ${o.errors[0]?.message??"unknown error"}`);let c=o.data?.issueWorkspaceToken;if(!c?.success||!c.token){let p=c?.error?.message??"Unknown error";throw new Error(`Workspace token failed: ${p}`)}return {token:c.token,expiresAt:c.expiresAt??"",scopes:c.scopes??[]}}async function ue(e,n){let t=await y__default.default(e,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`},body:JSON.stringify({query:`
14
+ `,variables:{input:{workspaceId:r,organizationId:t}}})});if(!i.ok){let d=await i.text().catch(()=>"Unknown error");throw new Error(`Workspace token request failed (${i.status}): ${d}`)}let o=await i.json();if(o.errors?.length)throw new Error(`Workspace token failed: ${o.errors[0]?.message??"unknown error"}`);let u=o.data?.issueWorkspaceToken;if(!u?.success||!u.token){let d=u?.error?.message??"Unknown error";throw new Error(`Workspace token failed: ${d}`)}return {token:u.token,expiresAt:u.expiresAt??"",scopes:u.scopes??[]}}async function le(e,n){let t=await y__default.default(e,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`},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(!t.ok){let i=await t.text().catch(()=>"Unknown error");throw new Error(`Failed to fetch workspaces (${t.status}): ${i}`)}let a=await t.json();if(a.errors?.length)throw new Error(`Failed to fetch workspaces: ${a.errors[0]?.message??"unknown error"}`);return a.data?.myWorkspaces?.items??[]}function le(e){try{let n=new URL(e);return n.protocol==="http:"||n.protocol==="https:"}catch{return false}}async function pe(e){try{if(!le(e))return !1;let{execFile:n}=await import('child_process'),r=process.platform,t,a;return r==="darwin"?(t="open",a=[e]):r==="win32"?(t="cmd",a=["/c","start","",e]):(t="xdg-open",a=[e]),new Promise(i=>{n(t,a,o=>{i(!o);});})}catch{return false}}var de=3e4,M=3,ge=1e3;function fe(e){return new Promise(n=>setTimeout(n,e))}function me(e){if(e instanceof TypeError)return true;if(e&&typeof e=="object"&&"response"in e){let n=e.response;if(n&&typeof n.status=="number"&&n.status>=500)return true}return false}function z(e){if(e&&typeof e=="object"&&"response"in e){let n=e,r=n.response?.errors?.[0],t=r?.extensions?.originalError?.message;if(t)return t;if(r?.message)return r.message;if(n.message)return n.message}return e instanceof Error?e.message:String(e)}function T(e){let n={};return e?.accessToken&&(n.Authorization=`Bearer ${e.accessToken}`),e?.organizationId&&(n["x-org-id"]=e.organizationId),n}function U(e){let n=T(e);return e?.workspaceToken&&(n["X-Workspace-Authorization"]=`Bearer ${e.workspaceToken}`),e?.organizationId&&(n["x-org-id"]=e.organizationId),n}async function D(e,n,r){let t;for(let a=0;a<M;a++)try{let i=new AbortController,o=setTimeout(()=>i.abort(),de);try{return await e.request({document:n,variables:r,signal:i.signal})}finally{clearTimeout(o);}}catch(i){if(t=i,i&&typeof i=="object"&&"response"in i){let o=i.response;if(o&&typeof o.status=="number"&&o.status>=400&&o.status<500)break}if(me(i)&&a<M-1){let o=ge*Math.pow(2,a);await fe(o);continue}break}throw new Error(z(t))}function P(e,n){let r=null,t=null;function a(){let s=e.read(),l=n.read();return r=new graphqlRequest.GraphQLClient(s.workspaceEndpoint),r.setHeaders(U(l)),t=new graphqlRequest.GraphQLClient(s.globalEndpoint),t.setHeaders(T(l)),{workspace:r,global:t}}async function i(){let s=n.read();if(!s)return;if(s.authMethod==="client_credentials"&&s.clientId&&s.clientSecret){let h=e.read();try{let k=await O(h.globalEndpoint,s.clientId,s.clientSecret);n.write({...s,accessToken:k.accessToken,expiresAt:Date.now()+k.expiresIn*1e3}),r=null,t=null;}catch{}return}if(!s.refreshToken)return;let l=e.read(),u=new graphqlRequest.GraphQLClient(l.globalEndpoint);u.setHeaders({Authorization:`Bearer ${s.accessToken}`});let m=`
20
+ `,variables:{limit:50}})});if(!t.ok){let i=await t.text().catch(()=>"Unknown error");throw new Error(`Failed to fetch workspaces (${t.status}): ${i}`)}let s=await t.json();if(s.errors?.length)throw new Error(`Failed to fetch workspaces: ${s.errors[0]?.message??"unknown error"}`);return s.data?.myWorkspaces?.items??[]}function pe(e){try{let n=new URL(e);return n.protocol==="http:"||n.protocol==="https:"}catch{return false}}async function de(e){try{if(!pe(e))return !1;let{execFile:n}=await import('child_process'),r=process.platform,t,s;return r==="darwin"?(t="open",s=[e]):r==="win32"?(t="cmd",s=["/c","start","",e]):(t="xdg-open",s=[e]),new Promise(i=>{n(t,s,o=>{i(!o);});})}catch{return false}}var ge=3e4,U=3,fe=1e3;function me(e){return new Promise(n=>setTimeout(n,e))}function ke(e){if(e instanceof TypeError)return true;if(e&&typeof e=="object"&&"response"in e){let n=e.response;if(n&&typeof n.status=="number"&&n.status>=500)return true}return false}function B(e){if(e&&typeof e=="object"&&"response"in e){let n=e,r=n.response?.errors?.[0],t=r?.extensions?.originalError?.message;if(t)return t;if(r?.message)return r.message;if(n.message)return n.message}return e instanceof Error?e.message:String(e)}function v(e){let n={};return e?.accessToken&&(n.Authorization=`Bearer ${e.accessToken}`),e?.organizationId&&(n["x-org-id"]=e.organizationId),n}function z(e,n){let r=v(e);return n&&(r.Origin=n),e?.workspaceToken&&(r["X-Workspace-Authorization"]=`Bearer ${e.workspaceToken}`),e?.organizationId&&(r["x-org-id"]=e.organizationId),r}async function P(e,n,r){let t;for(let s=0;s<U;s++)try{let i=new AbortController,o=setTimeout(()=>i.abort(),ge);try{return await e.request({document:n,variables:r,signal:i.signal})}finally{clearTimeout(o);}}catch(i){if(t=i,i&&typeof i=="object"&&"response"in i){let o=i.response;if(o&&typeof o.status=="number"&&o.status>=400&&o.status<500)break}if(ke(i)&&s<U-1){let o=fe*Math.pow(2,s);await me(o);continue}break}throw new Error(B(t))}function R(e,n){let r=null,t=null;function s(){let a=e.read(),g=n.read();return r=new graphqlRequest.GraphQLClient(a.workspaceEndpoint),r.setHeaders(z(g,e.resolveProductOrigin())),t=new graphqlRequest.GraphQLClient(a.globalEndpoint),t.setHeaders(v(g)),{workspace:r,global:t}}async function i(){let a=n.read();if(!a)return;if(a.authMethod==="client_credentials"&&a.clientId&&a.clientSecret){let p=e.read();try{let f=await S(p.globalEndpoint,a.clientId,a.clientSecret);n.write({...a,accessToken:f.accessToken,expiresAt:Date.now()+f.expiresIn*1e3}),r=null,t=null;}catch{}return}if(!a.refreshToken)return;let g=e.read(),c=new graphqlRequest.GraphQLClient(g.globalEndpoint);c.setHeaders({Authorization:`Bearer ${a.accessToken}`});let l=`
21
21
  mutation RefreshToken($token: String!) {
22
22
  refreshToken(token: $token) {
23
23
  accessToken
@@ -25,8 +25,8 @@
25
25
  expiresIn
26
26
  }
27
27
  }
28
- `;try{let k=(await u.request(m,{token:s.refreshToken})).refreshToken;n.write({...s,accessToken:k.accessToken,refreshToken:k.refreshToken,expiresAt:Date.now()+k.expiresIn*1e3}),r=null,t=null;}catch{}}async function o(){let s=n.read();if(!s?.accessToken||!s.workspaceId||!s.organizationId)return;let l=e.read();try{let u=await $(l.workspaceEndpoint,s.accessToken,s.workspaceId,s.organizationId);n.write({...s,workspaceToken:u.token,workspaceTokenExpiresAt:new Date(u.expiresAt).getTime()}),r=null;}catch{}}async function c(){n.isTokenExpiringSoon()&&await i(),n.read()?.workspaceToken&&n.isWorkspaceTokenExpiringSoon()&&await o();}return {workspace:{async request(s,l){await c();let{workspace:u}=r?{workspace:r}:a();return u.setHeaders(U(n.read())),D(u,s,l)}},global:{async request(s,l){let{global:u}=t?{global:t}:a();return u.setHeaders(T(n.read())),D(u,s,l)}},workspaceAuthOnly:{async request(s,l){let u=e.read(),m=n.read(),h=new graphqlRequest.GraphQLClient(u.workspaceEndpoint);return h.setHeaders(T(m)),D(h,s,l)}},reset(){r=null,t=null;}}}function q(){return !!(process.stdout.isTTY&&process.stdin.isTTY)}function B(e){if(e.format){let n=e.format.toLowerCase();if(n==="json"||n==="table"||n==="yaml")return n}return q()?"table":"json"}function L(e){console.log(JSON.stringify(e,null,2));}function H(e,n){if(e.length===0)return;let r=e.map((i,o)=>{let c=i.length;for(let p of n){let d=p[o]??"";d.length>c&&(c=d.length);}return Math.min(c,50)}),t=r.map(i=>"-".repeat(i+2)).join("+"),a=i=>i.map((o,c)=>` ${(o??"").padEnd(r[c]??0)} `).join("|");console.log(a(e)),console.log(t);for(let i of n)console.log(a(i));}function R(e,n){let r=" ".repeat(n),t=[];for(let[a,i]of Object.entries(e))if(i==null)t.push(`${r}${a}: null`);else if(Array.isArray(i)){t.push(`${r}${a}:`);for(let o of i)typeof o=="object"&&o!==null?(t.push(`${r} -`),t.push(R(o,n+2))):t.push(`${r} - ${String(o)}`);}else typeof i=="object"?(t.push(`${r}${a}:`),t.push(R(i,n+1))):t.push(`${r}${a}: ${String(i)}`);return t.join(`
29
- `)}function V(e){if(typeof e!="object"||e===null){console.log(String(e));return}console.log(R(e,0));}function ke(e){console.log(`\u2713 ${e}`);}function J(e){console.error(`\u2717 ${e}`);}function we(e){console.warn(`! ${e}`);}function he(e){console.log(`\u2139 ${e}`);}function ye(e){if(!e)return "-";try{return new Date(e).toLocaleString()}catch{return e}}function Ce(e){if(!e)return "-";switch(e.toUpperCase()){case "ACTIVE":case "RUNNING":case "HEALTHY":return `\u2713 ${e}`;case "INACTIVE":case "STOPPED":case "PENDING":return `\u25CB ${e}`;case "ERROR":return `\u2717 ${e}`;case "ARCHIVED":return `\u2192 ${e}`;case "STARTING":return `\u25B6 ${e}`;case "TERMINATED":return `\u25A0 ${e}`;default:return e}}function xe(e,n){return e?e.length<=n?e:e.substring(0,n-3)+"...":"-"}function be(e,n,r){switch(B(e)){case "json":L(n);break;case "yaml":V(n);break;case "table":r?H(r.headers,r.rows):L(n);break}}async function Te(e,n){return n?true:q()?new Promise(r=>{process.stdout.write(`${e} [y/N] `),process.stdin.setEncoding("utf8"),process.stdin.once("data",t=>{let a=t.trim().toLowerCase();r(a==="y"||a==="yes");}),process.stdin.resume();}):(J(`${e} Use --force to skip confirmation.`),false)}var _={isInteractive:q,getFormat:B,formatAndOutput:be,printJson:L,printTable:H,printYaml:V,printSuccess:ke,printError:J,printWarning:we,printInfo:he,formatDate:ye,formatStatus:Ce,truncate:xe,confirm:Te};function N(e={}){let{verbose:n=false,quiet:r=false}=e;return {debug(t,...a){n&&console.error(`[debug] ${t}`,...a);},info(t,...a){r||console.error(`[info] ${t}`,...a);},warn(t,...a){console.error(`[warn] ${t}`,...a);},error(t,...a){console.error(`[error] ${t}`,...a);}}}function ve(e){return e.includes("localhost")||e.includes("127.0.0.1")?"local":e.includes("alpha")||e.includes("staging")?"staging":"prod"}function Ee(e){return !!e&&typeof e.debug=="function"&&typeof e.info=="function"}function Ie(e){let n=S(e.defaults),r=A(n.dir()),t=P(n,r),a=e.output??_,i=Ee(e.logger)?e.logger:N(e.logger),o=e.env??ve(n.read().workspaceEndpoint);return {productName:e.productName,productVersion:e.productVersion,defaults:e.defaults,config:n,auth:r,gql:t,output:a,logger:i,env:o}}var w=class extends Error{exitCode;hint;constructor(n,r){super(n),this.name="CliUserError",this.exitCode=r?.exitCode??1,this.hint=r?.hint;}},C=class extends w{constructor(n,r){super(n,{exitCode:2,hint:r?.hint??"Run `<product> auth login` to authenticate."}),this.name="CliAuthError";}},f=class extends Error{cause;constructor(n,r){super(n),this.name="CliInternalError",this.cause=r;}};var v=class extends f{constructor(n,r){super(`Module '${n}' declares dependency on '${r}', but '${r}' is not in the module list.`),this.name="MissingDependencyError";}},E=class extends f{constructor(n){super(`Circular dependency detected among modules: ${n.join(" -> ")}`),this.name="CircularDependencyError";}};function j(e){let n=new Map;for(let o of e){if(n.has(o.id))throw new f(`Duplicate module id: '${o.id}'`);n.set(o.id,o);}for(let o of e)for(let c of o.dependsOn??[])if(!n.has(c))throw new v(o.id,c);let r=[],t=new Set,a=new Set;function i(o,c){if(!a.has(o.id)){if(t.has(o.id))throw new E([...c,o.id]);t.add(o.id);for(let p of o.dependsOn??[]){let d=n.get(p);d&&i(d,[...c,o.id]);}t.delete(o.id),a.add(o.id),r.push(o);}}for(let o of e)i(o,[]);return r}function Se(e,n,r){let t=new commander.Command;t.name(r.name).description(r.description??"").version(r.version,"-v, --version").option("-f, --format <format>","Output format (json, table, yaml)").option("--verbose","Enable verbose logging").option("--no-color","Disable colored output");let a=j(n);for(let o of a)o.register(t,e);r.helpExamples?.length&&t.addHelpText("after",`
28
+ `;try{let f=(await c.request(l,{token:a.refreshToken})).refreshToken;n.write({...a,accessToken:f.accessToken,refreshToken:f.refreshToken,expiresAt:Date.now()+f.expiresIn*1e3}),r=null,t=null;}catch{}}async function o(){let a=n.read();if(!a?.accessToken||!a.workspaceId||!a.organizationId)return;let g=e.read();try{let c=await $(g.workspaceEndpoint,a.accessToken,a.workspaceId,a.organizationId);n.write({...a,workspaceToken:c.token,workspaceTokenExpiresAt:new Date(c.expiresAt).getTime()}),r=null;}catch{}}async function u(){n.isTokenExpiringSoon()&&await i(),n.read()?.workspaceToken&&n.isWorkspaceTokenExpiringSoon()&&await o();}return {workspace:{async request(a,g){await u();let{workspace:c}=r?{workspace:r}:s();return c.setHeaders(z(n.read(),e.resolveProductOrigin())),P(c,a,g)}},global:{async request(a,g){let{global:c}=t?{global:t}:s();return c.setHeaders(v(n.read())),P(c,a,g)}},workspaceAuthOnly:{async request(a,g){let c=e.read(),l=n.read(),p=new graphqlRequest.GraphQLClient(c.workspaceEndpoint),f=v(l),F=e.resolveProductOrigin();return F&&(f.Origin=F),p.setHeaders(f),P(p,a,g)}},reset(){r=null,t=null;}}}function q(){return !!(process.stdout.isTTY&&process.stdin.isTTY)}function H(e){if(e.format){let n=e.format.toLowerCase();if(n==="json"||n==="table"||n==="yaml")return n}return q()?"table":"json"}function D(e){console.log(JSON.stringify(e,null,2));}function V(e,n){if(e.length===0)return;let r=e.map((i,o)=>{let u=i.length;for(let d of n){let m=d[o]??"";m.length>u&&(u=m.length);}return Math.min(u,50)}),t=r.map(i=>"-".repeat(i+2)).join("+"),s=i=>i.map((o,u)=>` ${(o??"").padEnd(r[u]??0)} `).join("|");console.log(s(e)),console.log(t);for(let i of n)console.log(s(i));}function L(e,n){let r=" ".repeat(n),t=[];for(let[s,i]of Object.entries(e))if(i==null)t.push(`${r}${s}: null`);else if(Array.isArray(i)){t.push(`${r}${s}:`);for(let o of i)typeof o=="object"&&o!==null?(t.push(`${r} -`),t.push(L(o,n+2))):t.push(`${r} - ${String(o)}`);}else typeof i=="object"?(t.push(`${r}${s}:`),t.push(L(i,n+1))):t.push(`${r}${s}: ${String(i)}`);return t.join(`
29
+ `)}function J(e){if(typeof e!="object"||e===null){console.log(String(e));return}console.log(L(e,0));}function we(e){console.log(`\u2713 ${e}`);}function Y(e){console.error(`\u2717 ${e}`);}function he(e){console.warn(`! ${e}`);}function ye(e){console.log(`\u2139 ${e}`);}function Ce(e){if(!e)return "-";try{return new Date(e).toLocaleString()}catch{return e}}function xe(e){if(!e)return "-";switch(e.toUpperCase()){case "ACTIVE":case "RUNNING":case "HEALTHY":return `\u2713 ${e}`;case "INACTIVE":case "STOPPED":case "PENDING":return `\u25CB ${e}`;case "ERROR":return `\u2717 ${e}`;case "ARCHIVED":return `\u2192 ${e}`;case "STARTING":return `\u25B6 ${e}`;case "TERMINATED":return `\u25A0 ${e}`;default:return e}}function be(e,n){return e?e.length<=n?e:e.substring(0,n-3)+"...":"-"}function ve(e,n,r){switch(H(e)){case "json":D(n);break;case "yaml":J(n);break;case "table":r?V(r.headers,r.rows):D(n);break}}async function Te(e,n){return n?true:q()?new Promise(r=>{process.stdout.write(`${e} [y/N] `),process.stdin.setEncoding("utf8"),process.stdin.once("data",t=>{let s=t.trim().toLowerCase();r(s==="y"||s==="yes");}),process.stdin.resume();}):(Y(`${e} Use --force to skip confirmation.`),false)}var _={isInteractive:q,getFormat:H,formatAndOutput:ve,printJson:D,printTable:V,printYaml:J,printSuccess:we,printError:Y,printWarning:he,printInfo:ye,formatDate:Ce,formatStatus:xe,truncate:be,confirm:Te};function N(e={}){let{verbose:n=false,quiet:r=false}=e;return {debug(t,...s){n&&console.error(`[debug] ${t}`,...s);},info(t,...s){r||console.error(`[info] ${t}`,...s);},warn(t,...s){console.error(`[warn] ${t}`,...s);},error(t,...s){console.error(`[error] ${t}`,...s);}}}function Ee(e){return e.includes("localhost")||e.includes("127.0.0.1")?"local":e.includes("alpha")||e.includes("staging")?"staging":"prod"}function Ie(e){return !!e&&typeof e.debug=="function"&&typeof e.info=="function"}function Ae(e){let n=O(e.defaults),r=A(n.dir()),t=R(n,r),s=e.output??_,i=Ie(e.logger)?e.logger:N(e.logger),o=e.env??Ee(n.read().workspaceEndpoint);return {productName:e.productName,productVersion:e.productVersion,defaults:e.defaults,config:n,auth:r,gql:t,output:s,logger:i,env:o}}var h=class extends Error{exitCode;hint;constructor(n,r){super(n),this.name="CliUserError",this.exitCode=r?.exitCode??1,this.hint=r?.hint;}},C=class extends h{constructor(n,r){super(n,{exitCode:2,hint:r?.hint??"Run `<product> auth login` to authenticate."}),this.name="CliAuthError";}},w=class extends Error{cause;constructor(n,r){super(n),this.name="CliInternalError",this.cause=r;}};var T=class extends w{constructor(n,r){super(`Module '${n}' declares dependency on '${r}', but '${r}' is not in the module list.`),this.name="MissingDependencyError";}},E=class extends w{constructor(n){super(`Circular dependency detected among modules: ${n.join(" -> ")}`),this.name="CircularDependencyError";}};function j(e){let n=new Map;for(let o of e){if(n.has(o.id))throw new w(`Duplicate module id: '${o.id}'`);n.set(o.id,o);}for(let o of e)for(let u of o.dependsOn??[])if(!n.has(u))throw new T(o.id,u);let r=[],t=new Set,s=new Set;function i(o,u){if(!s.has(o.id)){if(t.has(o.id))throw new E([...u,o.id]);t.add(o.id);for(let d of o.dependsOn??[]){let m=n.get(d);m&&i(m,[...u,o.id]);}t.delete(o.id),s.add(o.id),r.push(o);}}for(let o of e)i(o,[]);return r}function Se(e,n,r){let t=new commander.Command;t.name(r.name).description(r.description??"").version(r.version,"-v, --version").option("-f, --format <format>","Output format (json, table, yaml)").option("--verbose","Enable verbose logging").option("--no-color","Disable colored output");let s=j(n);for(let o of s)o.register(t,e);r.helpExamples?.length&&t.addHelpText("after",`
30
30
  Examples:
31
31
  `+r.helpExamples.map(o=>" "+o).join(`
32
- `)),t.on("command:*",()=>{e.output.printError(`Invalid command: ${t.args.join(" ")}`),e.output.printInfo(`Run \`${r.name} --help\` for available commands.`),process.exit(1);});async function i(o=process.argv){try{await t.parseAsync(o),o.length<=2&&t.outputHelp();}catch(c){Oe(e,c);}}return {program:t,run:i}}function Oe(e,n){if(n instanceof C&&(e.output.printError(n.message),n.hint&&e.output.printInfo(n.hint),process.exit(n.exitCode)),n instanceof w&&(e.output.printError(n.message),n.hint&&e.output.printInfo(n.hint),process.exit(n.exitCode)),n instanceof f&&(e.output.printError(`Internal error: ${n.message}`),n.cause&&e.logger.debug("caused by:",n.cause),process.exit(70)),n&&typeof n=="object"&&"code"in n&&"exitCode"in n){let t=n.exitCode;process.exit(typeof t=="number"?t:0);}let r=n instanceof Error?n.message:String(n);e.output.printError(r),process.exit(1);}exports.CircularDependencyError=E;exports.CliAuthError=C;exports.CliInternalError=f;exports.CliUserError=w;exports.KNOWN_CONFIG_KEYS=ie;exports.MissingDependencyError=v;exports.buildContext=Ie;exports.clientCredentialsFlow=O;exports.createAuthStore=A;exports.createConfigStore=S;exports.createGqlClients=P;exports.createLogger=N;exports.createProgram=Se;exports.defaultOutputAdapter=_;exports.extractGqlErrorMessage=z;exports.fetchWorkspaces=ue;exports.issueWorkspaceToken=$;exports.openBrowser=pe;exports.pollForToken=ce;exports.sortModules=j;exports.startDeviceCodeFlow=ae;
32
+ `)),t.on("command:*",()=>{e.output.printError(`Invalid command: ${t.args.join(" ")}`),e.output.printInfo(`Run \`${r.name} --help\` for available commands.`),process.exit(1);});async function i(o=process.argv){try{await t.parseAsync(o),o.length<=2&&t.outputHelp();}catch(u){$e(e,u);}}return {program:t,run:i}}function $e(e,n){if(n instanceof C&&(e.output.printError(n.message),n.hint&&e.output.printInfo(n.hint),process.exit(n.exitCode)),n instanceof h&&(e.output.printError(n.message),n.hint&&e.output.printInfo(n.hint),process.exit(n.exitCode)),n instanceof w&&(e.output.printError(`Internal error: ${n.message}`),n.cause&&e.logger.debug("caused by:",n.cause),process.exit(70)),n&&typeof n=="object"&&"code"in n&&"exitCode"in n){let t=n.exitCode;process.exit(typeof t=="number"?t:0);}let r=n instanceof Error?n.message:String(n);e.output.printError(r),process.exit(1);}exports.CircularDependencyError=E;exports.CliAuthError=C;exports.CliInternalError=w;exports.CliUserError=h;exports.KNOWN_CONFIG_KEYS=ae;exports.MissingDependencyError=T;exports.buildContext=Ae;exports.clientCredentialsFlow=S;exports.createAuthStore=A;exports.createConfigStore=O;exports.createGqlClients=R;exports.createLogger=N;exports.createProgram=Se;exports.defaultOutputAdapter=_;exports.extractGqlErrorMessage=B;exports.fetchWorkspaces=le;exports.issueWorkspaceToken=$;exports.openBrowser=de;exports.pollForToken=ue;exports.sortModules=j;exports.startDeviceCodeFlow=ce;
@@ -1,5 +1,5 @@
1
- import { a as CLIContext, C as CliModule } from '../module-DxCuik6L.cjs';
2
- export { A as AuthStore, B as BuildContextOptions, b as CLIConfig, c as CircularDependencyError, d as CliAuthError, e as CliInternalError, f as CliUserError, g as ConfigStore, E as Environment, G as GqlClient, h as GqlClients, K as KNOWN_CONFIG_KEYS, L as Logger, i as LoggerOptions, M as MissingDependencyError, O as OutputAdapter, j as OutputFormat, P as ProductDefaults, S as StoredAuth, T as TableConfig, k as buildContext, l as createAuthStore, m as createConfigStore, n as createGqlClients, o as createLogger, p as defaultOutputAdapter, q as extractGqlErrorMessage, s as sortModules } from '../module-DxCuik6L.cjs';
1
+ import { a as CLIContext, C as CliModule } from '../module-DOIiVaXQ.cjs';
2
+ export { A as AuthStore, B as BuildContextOptions, b as CLIConfig, c as CircularDependencyError, d as CliAuthError, e as CliInternalError, f as CliUserError, g as ConfigStore, E as Environment, G as GqlClient, h as GqlClients, K as KNOWN_CONFIG_KEYS, L as Logger, i as LoggerOptions, M as MissingDependencyError, O as OutputAdapter, j as OutputFormat, P as ProductDefaults, S as StoredAuth, T as TableConfig, k as buildContext, l as createAuthStore, m as createConfigStore, n as createGqlClients, o as createLogger, p as defaultOutputAdapter, q as extractGqlErrorMessage, s as sortModules } from '../module-DOIiVaXQ.cjs';
3
3
  import { Command } from 'commander';
4
4
  import 'graphql-request';
5
5
 
@@ -1,5 +1,5 @@
1
- import { a as CLIContext, C as CliModule } from '../module-DxCuik6L.js';
2
- export { A as AuthStore, B as BuildContextOptions, b as CLIConfig, c as CircularDependencyError, d as CliAuthError, e as CliInternalError, f as CliUserError, g as ConfigStore, E as Environment, G as GqlClient, h as GqlClients, K as KNOWN_CONFIG_KEYS, L as Logger, i as LoggerOptions, M as MissingDependencyError, O as OutputAdapter, j as OutputFormat, P as ProductDefaults, S as StoredAuth, T as TableConfig, k as buildContext, l as createAuthStore, m as createConfigStore, n as createGqlClients, o as createLogger, p as defaultOutputAdapter, q as extractGqlErrorMessage, s as sortModules } from '../module-DxCuik6L.js';
1
+ import { a as CLIContext, C as CliModule } from '../module-DOIiVaXQ.js';
2
+ export { A as AuthStore, B as BuildContextOptions, b as CLIConfig, c as CircularDependencyError, d as CliAuthError, e as CliInternalError, f as CliUserError, g as ConfigStore, E as Environment, G as GqlClient, h as GqlClients, K as KNOWN_CONFIG_KEYS, L as Logger, i as LoggerOptions, M as MissingDependencyError, O as OutputAdapter, j as OutputFormat, P as ProductDefaults, S as StoredAuth, T as TableConfig, k as buildContext, l as createAuthStore, m as createConfigStore, n as createGqlClients, o as createLogger, p as defaultOutputAdapter, q as extractGqlErrorMessage, s as sortModules } from '../module-DOIiVaXQ.js';
3
3
  import { Command } from 'commander';
4
4
  import 'graphql-request';
5
5
 
@@ -1 +1 @@
1
- export{s as CircularDependencyError,p as CliAuthError,q as CliInternalError,o as CliUserError,b as KNOWN_CONFIG_KEYS,r as MissingDependencyError,n as buildContext,f as clientCredentialsFlow,a as createAuthStore,c as createConfigStore,k as createGqlClients,m as createLogger,u as createProgram,l as defaultOutputAdapter,j as extractGqlErrorMessage,h as fetchWorkspaces,g as issueWorkspaceToken,i as openBrowser,e as pollForToken,t as sortModules,d as startDeviceCodeFlow}from'../chunk-TCBALVP4.js';
1
+ export{s as CircularDependencyError,p as CliAuthError,q as CliInternalError,o as CliUserError,b as KNOWN_CONFIG_KEYS,r as MissingDependencyError,n as buildContext,f as clientCredentialsFlow,a as createAuthStore,c as createConfigStore,k as createGqlClients,m as createLogger,u as createProgram,l as defaultOutputAdapter,j as extractGqlErrorMessage,h as fetchWorkspaces,g as issueWorkspaceToken,i as openBrowser,e as pollForToken,t as sortModules,d as startDeviceCodeFlow}from'../chunk-IZXPWPKX.js';
package/dist/index.cjs CHANGED
@@ -1,23 +1,23 @@
1
- 'use strict';var fs=require('fs'),path=require('path'),os=require('os'),graphqlRequest=require('graphql-request'),y=require('cross-fetch'),commander=require('commander');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var y__default=/*#__PURE__*/_interopDefault(y);var F=300*1e3;function A(e){let n=path.join(e,"auth.json");function r(){fs.existsSync(e)||fs.mkdirSync(e,{recursive:true,mode:448});}function t(){try{if(!fs.existsSync(n))return null;let s=fs.readFileSync(n,"utf8");return JSON.parse(s)}catch{return null}}function a(s){r(),fs.writeFileSync(n,JSON.stringify(s,null,2),{encoding:"utf8",mode:384});try{fs.chmodSync(n,384);}catch{}}function i(){try{fs.existsSync(n)&&fs.unlinkSync(n);}catch{}}function o(){let s=t();return s?.expiresAt?Date.now()>=s.expiresAt:false}function c(){let s=t();return s?.expiresAt?Date.now()+F>=s.expiresAt:false}function p(){let s=t();return s?.workspaceTokenExpiresAt?Date.now()>=s.workspaceTokenExpiresAt:false}function g(){let s=t();return s?.workspaceTokenExpiresAt?Date.now()+F>=s.workspaceTokenExpiresAt:false}function x(){return t()?.accessToken?!o():false}return {read:t,write:a,clear:i,isTokenExpired:o,isTokenExpiringSoon:c,isWorkspaceTokenExpired:p,isWorkspaceTokenExpiringSoon:g,isAuthenticated:x}}var ie=["workspaceEndpoint","globalEndpoint","oidcIssuer","clientId","defaultFormat","verbose","authServiceEndpoint"];function S(e){let n=path.join(os.homedir(),".config",e.configDirName),r=path.join(n,"config.json"),t={workspaceEndpoint:e.workspaceEndpointDefault,globalEndpoint:e.globalEndpointDefault};function a(){fs.existsSync(n)||fs.mkdirSync(n,{recursive:true,mode:448});}function i(s){if(e.envPrefix){let u=process.env[`${e.envPrefix}_${s}`];if(u)return u}let l=process.env[s];return l&&l.length>0?l:void 0}function o(){let s={};try{fs.existsSync(r)&&(s=JSON.parse(fs.readFileSync(r,"utf8")));}catch{}return {...t,...s,workspaceEndpoint:i("WORKSPACE_ENDPOINT")??s.workspaceEndpoint??t.workspaceEndpoint,globalEndpoint:i("GLOBAL_ENDPOINT")??s.globalEndpoint??t.globalEndpoint,oidcIssuer:i("OIDC_ISSUER")??s.oidcIssuer,clientId:i("CLIENT_ID")??s.clientId}}function c(s){a(),fs.writeFileSync(r,JSON.stringify(s,null,2),{encoding:"utf8"});try{fs.chmodSync(r,384);}catch{}}function p(s){return o()[s]}function g(s,l){let u=o();u[s]=l,c(u);}function x(){let s=o(),l=s.clientId||e.oidcClientId,u=s.oidcIssuer;if(!u){let m=s.globalEndpoint;m.includes("localhost")||m.includes("127.0.0.1")?u=m.replace(/\/graphql$/,"").replace(/\/global\/graphql$/,"/global"):u=e.oidcIssuerProd??"https://graphql.burdenoff.com/global";}return {oidcIssuer:u,clientId:l}}return {read:o,write:c,get:p,set:g,path:()=>r,dir:()=>n,resolveOIDC:x}}async function ae(e){let n=`${e.oidcIssuer}/oidc/device/code`,r=new URLSearchParams({client_id:e.clientId,scope:"openid profile email offline_access"}),t=await y__default.default(n,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:r.toString()});if(!t.ok){let i=await t.text().catch(()=>"Unknown error");throw new Error(`Device code request failed (${t.status}): ${i}`)}let a=await t.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 ce(e,n,r){let t=`${r.oidcIssuer}/oauth/device/token`,a=n;for(;;){await new Promise(p=>setTimeout(p,a*1e3));let i=await y__default.default(t,{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:e,client_id:r.clientId}).toString()}),o=await i.json();if(i.ok&&o.access_token)return {accessToken:o.access_token,refreshToken:o.refresh_token??"",expiresIn:o.expires_in??3600};let c=o.error;switch(c){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: ${o.error_description??c??"Unknown error"}`)}}}async function O(e,n,r,t){let i=await y__default.default(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:`
1
+ 'use strict';var fs=require('fs'),path=require('path'),os=require('os'),graphqlRequest=require('graphql-request'),y=require('cross-fetch'),commander=require('commander');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var y__default=/*#__PURE__*/_interopDefault(y);var W=300*1e3;function A(e){let n=path.join(e,"auth.json");function r(){fs.existsSync(e)||fs.mkdirSync(e,{recursive:true,mode:448});}function t(){try{if(!fs.existsSync(n))return null;let a=fs.readFileSync(n,"utf8");return JSON.parse(a)}catch{return null}}function s(a){r(),fs.writeFileSync(n,JSON.stringify(a,null,2),{encoding:"utf8",mode:384});try{fs.chmodSync(n,384);}catch{}}function i(){try{fs.existsSync(n)&&fs.unlinkSync(n);}catch{}}function o(){let a=t();return a?.expiresAt?Date.now()>=a.expiresAt:false}function u(){let a=t();return a?.expiresAt?Date.now()+W>=a.expiresAt:false}function d(){let a=t();return a?.workspaceTokenExpiresAt?Date.now()>=a.workspaceTokenExpiresAt:false}function k(){let a=t();return a?.workspaceTokenExpiresAt?Date.now()+W>=a.workspaceTokenExpiresAt:false}function x(){return t()?.accessToken?!o():false}return {read:t,write:s,clear:i,isTokenExpired:o,isTokenExpiringSoon:u,isWorkspaceTokenExpired:d,isWorkspaceTokenExpiringSoon:k,isAuthenticated:x}}var ae=["workspaceEndpoint","globalEndpoint","oidcIssuer","clientId","defaultFormat","verbose","authServiceEndpoint","productOrigin"];function O(e){let n=path.join(os.homedir(),".config",e.configDirName),r=path.join(n,"config.json"),t={workspaceEndpoint:e.workspaceEndpointDefault,globalEndpoint:e.globalEndpointDefault};function s(){fs.existsSync(n)||fs.mkdirSync(n,{recursive:true,mode:448});}function i(c){if(e.envPrefix){let p=process.env[`${e.envPrefix}_${c}`];if(p)return p}let l=process.env[c];return l&&l.length>0?l:void 0}function o(c){if(!e.envPrefix)return;let l=process.env[`${e.envPrefix}_${c}`];return l&&l.length>0?l:void 0}function u(){let c={};try{fs.existsSync(r)&&(c=JSON.parse(fs.readFileSync(r,"utf8")));}catch{}return {...t,...c,workspaceEndpoint:i("WORKSPACE_ENDPOINT")??c.workspaceEndpoint??t.workspaceEndpoint,globalEndpoint:i("GLOBAL_ENDPOINT")??c.globalEndpoint??t.globalEndpoint,oidcIssuer:i("OIDC_ISSUER")??c.oidcIssuer,clientId:i("CLIENT_ID")??c.clientId,productOrigin:o("ORIGIN")??c.productOrigin}}function d(c){s(),fs.writeFileSync(r,JSON.stringify(c,null,2),{encoding:"utf8"});try{fs.chmodSync(r,384);}catch{}}function k(c){return u()[c]}function x(c,l){let p=u();p[c]=l,d(p);}function a(){let c=u(),l=c.clientId||e.oidcClientId,p=c.oidcIssuer;if(!p){let f=c.globalEndpoint;f.includes("localhost")||f.includes("127.0.0.1")?p=f.replace(/\/graphql$/,"").replace(/\/global\/graphql$/,"/global"):p=e.oidcIssuerProd??"https://graphql.burdenoff.com/global";}return {oidcIssuer:p,clientId:l}}function g(){let c=u();if(c.productOrigin)return c.productOrigin;if(e.productOrigins)try{let l=new URL(c.workspaceEndpoint).hostname.toLowerCase();return e.productOrigins[l]}catch{return}}return {read:u,write:d,get:k,set:x,path:()=>r,dir:()=>n,resolveOIDC:a,resolveProductOrigin:g}}async function ce(e){let n=`${e.oidcIssuer}/oidc/device/code`,r=new URLSearchParams({client_id:e.clientId,scope:"openid profile email offline_access"}),t=await y__default.default(n,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:r.toString()});if(!t.ok){let i=await t.text().catch(()=>"Unknown error");throw new Error(`Device code request failed (${t.status}): ${i}`)}let s=await t.json();return {deviceCode:s.device_code,userCode:s.user_code,verificationUri:s.verification_uri,verificationUriComplete:s.verification_uri_complete??null,expiresIn:s.expires_in,interval:s.interval??5}}async function ue(e,n,r){let t=`${r.oidcIssuer}/oauth/device/token`,s=n;for(;;){await new Promise(d=>setTimeout(d,s*1e3));let i=await y__default.default(t,{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:e,client_id:r.clientId}).toString()}),o=await i.json();if(i.ok&&o.access_token)return {accessToken:o.access_token,refreshToken:o.refresh_token??"",expiresIn:o.expires_in??3600};let u=o.error;switch(u){case "authorization_pending":continue;case "slow_down":s+=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: ${o.error_description??u??"Unknown error"}`)}}}async function S(e,n,r,t){let i=await y__default.default(e,{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:n,clientSecret:r,scopes:t}}})});if(!i.ok){let c=await i.text().catch(()=>"Unknown error");throw new Error(`App authentication failed (${i.status}): ${c}`)}let o=await i.json();if(o.errors?.length)throw new Error(`App authentication failed: ${o.errors[0]?.message??"unknown error"}`);if(!o.data?.authenticateApp?.accessToken)throw new Error("App authentication failed: no access token returned");return o.data.authenticateApp}async function $(e,n,r,t){let i=await y__default.default(e,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`},body:JSON.stringify({query:`
7
+ `,variables:{input:{clientId:n,clientSecret:r,scopes:t}}})});if(!i.ok){let u=await i.text().catch(()=>"Unknown error");throw new Error(`App authentication failed (${i.status}): ${u}`)}let o=await i.json();if(o.errors?.length)throw new Error(`App authentication failed: ${o.errors[0]?.message??"unknown error"}`);if(!o.data?.authenticateApp?.accessToken)throw new Error("App authentication failed: no access token returned");return o.data.authenticateApp}async function $(e,n,r,t){let i=await y__default.default(e,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`},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:r,organizationId:t}}})});if(!i.ok){let p=await i.text().catch(()=>"Unknown error");throw new Error(`Workspace token request failed (${i.status}): ${p}`)}let o=await i.json();if(o.errors?.length)throw new Error(`Workspace token failed: ${o.errors[0]?.message??"unknown error"}`);let c=o.data?.issueWorkspaceToken;if(!c?.success||!c.token){let p=c?.error?.message??"Unknown error";throw new Error(`Workspace token failed: ${p}`)}return {token:c.token,expiresAt:c.expiresAt??"",scopes:c.scopes??[]}}async function ue(e,n){let t=await y__default.default(e,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`},body:JSON.stringify({query:`
14
+ `,variables:{input:{workspaceId:r,organizationId:t}}})});if(!i.ok){let d=await i.text().catch(()=>"Unknown error");throw new Error(`Workspace token request failed (${i.status}): ${d}`)}let o=await i.json();if(o.errors?.length)throw new Error(`Workspace token failed: ${o.errors[0]?.message??"unknown error"}`);let u=o.data?.issueWorkspaceToken;if(!u?.success||!u.token){let d=u?.error?.message??"Unknown error";throw new Error(`Workspace token failed: ${d}`)}return {token:u.token,expiresAt:u.expiresAt??"",scopes:u.scopes??[]}}async function le(e,n){let t=await y__default.default(e,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`},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(!t.ok){let i=await t.text().catch(()=>"Unknown error");throw new Error(`Failed to fetch workspaces (${t.status}): ${i}`)}let a=await t.json();if(a.errors?.length)throw new Error(`Failed to fetch workspaces: ${a.errors[0]?.message??"unknown error"}`);return a.data?.myWorkspaces?.items??[]}function le(e){try{let n=new URL(e);return n.protocol==="http:"||n.protocol==="https:"}catch{return false}}async function pe(e){try{if(!le(e))return !1;let{execFile:n}=await import('child_process'),r=process.platform,t,a;return r==="darwin"?(t="open",a=[e]):r==="win32"?(t="cmd",a=["/c","start","",e]):(t="xdg-open",a=[e]),new Promise(i=>{n(t,a,o=>{i(!o);});})}catch{return false}}var de=3e4,M=3,ge=1e3;function fe(e){return new Promise(n=>setTimeout(n,e))}function me(e){if(e instanceof TypeError)return true;if(e&&typeof e=="object"&&"response"in e){let n=e.response;if(n&&typeof n.status=="number"&&n.status>=500)return true}return false}function z(e){if(e&&typeof e=="object"&&"response"in e){let n=e,r=n.response?.errors?.[0],t=r?.extensions?.originalError?.message;if(t)return t;if(r?.message)return r.message;if(n.message)return n.message}return e instanceof Error?e.message:String(e)}function T(e){let n={};return e?.accessToken&&(n.Authorization=`Bearer ${e.accessToken}`),e?.organizationId&&(n["x-org-id"]=e.organizationId),n}function U(e){let n=T(e);return e?.workspaceToken&&(n["X-Workspace-Authorization"]=`Bearer ${e.workspaceToken}`),e?.organizationId&&(n["x-org-id"]=e.organizationId),n}async function D(e,n,r){let t;for(let a=0;a<M;a++)try{let i=new AbortController,o=setTimeout(()=>i.abort(),de);try{return await e.request({document:n,variables:r,signal:i.signal})}finally{clearTimeout(o);}}catch(i){if(t=i,i&&typeof i=="object"&&"response"in i){let o=i.response;if(o&&typeof o.status=="number"&&o.status>=400&&o.status<500)break}if(me(i)&&a<M-1){let o=ge*Math.pow(2,a);await fe(o);continue}break}throw new Error(z(t))}function P(e,n){let r=null,t=null;function a(){let s=e.read(),l=n.read();return r=new graphqlRequest.GraphQLClient(s.workspaceEndpoint),r.setHeaders(U(l)),t=new graphqlRequest.GraphQLClient(s.globalEndpoint),t.setHeaders(T(l)),{workspace:r,global:t}}async function i(){let s=n.read();if(!s)return;if(s.authMethod==="client_credentials"&&s.clientId&&s.clientSecret){let h=e.read();try{let k=await O(h.globalEndpoint,s.clientId,s.clientSecret);n.write({...s,accessToken:k.accessToken,expiresAt:Date.now()+k.expiresIn*1e3}),r=null,t=null;}catch{}return}if(!s.refreshToken)return;let l=e.read(),u=new graphqlRequest.GraphQLClient(l.globalEndpoint);u.setHeaders({Authorization:`Bearer ${s.accessToken}`});let m=`
20
+ `,variables:{limit:50}})});if(!t.ok){let i=await t.text().catch(()=>"Unknown error");throw new Error(`Failed to fetch workspaces (${t.status}): ${i}`)}let s=await t.json();if(s.errors?.length)throw new Error(`Failed to fetch workspaces: ${s.errors[0]?.message??"unknown error"}`);return s.data?.myWorkspaces?.items??[]}function pe(e){try{let n=new URL(e);return n.protocol==="http:"||n.protocol==="https:"}catch{return false}}async function de(e){try{if(!pe(e))return !1;let{execFile:n}=await import('child_process'),r=process.platform,t,s;return r==="darwin"?(t="open",s=[e]):r==="win32"?(t="cmd",s=["/c","start","",e]):(t="xdg-open",s=[e]),new Promise(i=>{n(t,s,o=>{i(!o);});})}catch{return false}}var ge=3e4,U=3,fe=1e3;function me(e){return new Promise(n=>setTimeout(n,e))}function ke(e){if(e instanceof TypeError)return true;if(e&&typeof e=="object"&&"response"in e){let n=e.response;if(n&&typeof n.status=="number"&&n.status>=500)return true}return false}function B(e){if(e&&typeof e=="object"&&"response"in e){let n=e,r=n.response?.errors?.[0],t=r?.extensions?.originalError?.message;if(t)return t;if(r?.message)return r.message;if(n.message)return n.message}return e instanceof Error?e.message:String(e)}function v(e){let n={};return e?.accessToken&&(n.Authorization=`Bearer ${e.accessToken}`),e?.organizationId&&(n["x-org-id"]=e.organizationId),n}function z(e,n){let r=v(e);return n&&(r.Origin=n),e?.workspaceToken&&(r["X-Workspace-Authorization"]=`Bearer ${e.workspaceToken}`),e?.organizationId&&(r["x-org-id"]=e.organizationId),r}async function P(e,n,r){let t;for(let s=0;s<U;s++)try{let i=new AbortController,o=setTimeout(()=>i.abort(),ge);try{return await e.request({document:n,variables:r,signal:i.signal})}finally{clearTimeout(o);}}catch(i){if(t=i,i&&typeof i=="object"&&"response"in i){let o=i.response;if(o&&typeof o.status=="number"&&o.status>=400&&o.status<500)break}if(ke(i)&&s<U-1){let o=fe*Math.pow(2,s);await me(o);continue}break}throw new Error(B(t))}function R(e,n){let r=null,t=null;function s(){let a=e.read(),g=n.read();return r=new graphqlRequest.GraphQLClient(a.workspaceEndpoint),r.setHeaders(z(g,e.resolveProductOrigin())),t=new graphqlRequest.GraphQLClient(a.globalEndpoint),t.setHeaders(v(g)),{workspace:r,global:t}}async function i(){let a=n.read();if(!a)return;if(a.authMethod==="client_credentials"&&a.clientId&&a.clientSecret){let p=e.read();try{let f=await S(p.globalEndpoint,a.clientId,a.clientSecret);n.write({...a,accessToken:f.accessToken,expiresAt:Date.now()+f.expiresIn*1e3}),r=null,t=null;}catch{}return}if(!a.refreshToken)return;let g=e.read(),c=new graphqlRequest.GraphQLClient(g.globalEndpoint);c.setHeaders({Authorization:`Bearer ${a.accessToken}`});let l=`
21
21
  mutation RefreshToken($token: String!) {
22
22
  refreshToken(token: $token) {
23
23
  accessToken
@@ -25,8 +25,8 @@
25
25
  expiresIn
26
26
  }
27
27
  }
28
- `;try{let k=(await u.request(m,{token:s.refreshToken})).refreshToken;n.write({...s,accessToken:k.accessToken,refreshToken:k.refreshToken,expiresAt:Date.now()+k.expiresIn*1e3}),r=null,t=null;}catch{}}async function o(){let s=n.read();if(!s?.accessToken||!s.workspaceId||!s.organizationId)return;let l=e.read();try{let u=await $(l.workspaceEndpoint,s.accessToken,s.workspaceId,s.organizationId);n.write({...s,workspaceToken:u.token,workspaceTokenExpiresAt:new Date(u.expiresAt).getTime()}),r=null;}catch{}}async function c(){n.isTokenExpiringSoon()&&await i(),n.read()?.workspaceToken&&n.isWorkspaceTokenExpiringSoon()&&await o();}return {workspace:{async request(s,l){await c();let{workspace:u}=r?{workspace:r}:a();return u.setHeaders(U(n.read())),D(u,s,l)}},global:{async request(s,l){let{global:u}=t?{global:t}:a();return u.setHeaders(T(n.read())),D(u,s,l)}},workspaceAuthOnly:{async request(s,l){let u=e.read(),m=n.read(),h=new graphqlRequest.GraphQLClient(u.workspaceEndpoint);return h.setHeaders(T(m)),D(h,s,l)}},reset(){r=null,t=null;}}}function q(){return !!(process.stdout.isTTY&&process.stdin.isTTY)}function B(e){if(e.format){let n=e.format.toLowerCase();if(n==="json"||n==="table"||n==="yaml")return n}return q()?"table":"json"}function L(e){console.log(JSON.stringify(e,null,2));}function H(e,n){if(e.length===0)return;let r=e.map((i,o)=>{let c=i.length;for(let p of n){let g=p[o]??"";g.length>c&&(c=g.length);}return Math.min(c,50)}),t=r.map(i=>"-".repeat(i+2)).join("+"),a=i=>i.map((o,c)=>` ${(o??"").padEnd(r[c]??0)} `).join("|");console.log(a(e)),console.log(t);for(let i of n)console.log(a(i));}function R(e,n){let r=" ".repeat(n),t=[];for(let[a,i]of Object.entries(e))if(i==null)t.push(`${r}${a}: null`);else if(Array.isArray(i)){t.push(`${r}${a}:`);for(let o of i)typeof o=="object"&&o!==null?(t.push(`${r} -`),t.push(R(o,n+2))):t.push(`${r} - ${String(o)}`);}else typeof i=="object"?(t.push(`${r}${a}:`),t.push(R(i,n+1))):t.push(`${r}${a}: ${String(i)}`);return t.join(`
29
- `)}function V(e){if(typeof e!="object"||e===null){console.log(String(e));return}console.log(R(e,0));}function ke(e){console.log(`\u2713 ${e}`);}function J(e){console.error(`\u2717 ${e}`);}function we(e){console.warn(`! ${e}`);}function he(e){console.log(`\u2139 ${e}`);}function ye(e){if(!e)return "-";try{return new Date(e).toLocaleString()}catch{return e}}function Ce(e){if(!e)return "-";switch(e.toUpperCase()){case "ACTIVE":case "RUNNING":case "HEALTHY":return `\u2713 ${e}`;case "INACTIVE":case "STOPPED":case "PENDING":return `\u25CB ${e}`;case "ERROR":return `\u2717 ${e}`;case "ARCHIVED":return `\u2192 ${e}`;case "STARTING":return `\u25B6 ${e}`;case "TERMINATED":return `\u25A0 ${e}`;default:return e}}function xe(e,n){return e?e.length<=n?e:e.substring(0,n-3)+"...":"-"}function be(e,n,r){switch(B(e)){case "json":L(n);break;case "yaml":V(n);break;case "table":r?H(r.headers,r.rows):L(n);break}}async function Te(e,n){return n?true:q()?new Promise(r=>{process.stdout.write(`${e} [y/N] `),process.stdin.setEncoding("utf8"),process.stdin.once("data",t=>{let a=t.trim().toLowerCase();r(a==="y"||a==="yes");}),process.stdin.resume();}):(J(`${e} Use --force to skip confirmation.`),false)}var _={isInteractive:q,getFormat:B,formatAndOutput:be,printJson:L,printTable:H,printYaml:V,printSuccess:ke,printError:J,printWarning:we,printInfo:he,formatDate:ye,formatStatus:Ce,truncate:xe,confirm:Te};function N(e={}){let{verbose:n=false,quiet:r=false}=e;return {debug(t,...a){n&&console.error(`[debug] ${t}`,...a);},info(t,...a){r||console.error(`[info] ${t}`,...a);},warn(t,...a){console.error(`[warn] ${t}`,...a);},error(t,...a){console.error(`[error] ${t}`,...a);}}}function ve(e){return e.includes("localhost")||e.includes("127.0.0.1")?"local":e.includes("alpha")||e.includes("staging")?"staging":"prod"}function Ee(e){return !!e&&typeof e.debug=="function"&&typeof e.info=="function"}function Ie(e){let n=S(e.defaults),r=A(n.dir()),t=P(n,r),a=e.output??_,i=Ee(e.logger)?e.logger:N(e.logger),o=e.env??ve(n.read().workspaceEndpoint);return {productName:e.productName,productVersion:e.productVersion,defaults:e.defaults,config:n,auth:r,gql:t,output:a,logger:i,env:o}}var w=class extends Error{exitCode;hint;constructor(n,r){super(n),this.name="CliUserError",this.exitCode=r?.exitCode??1,this.hint=r?.hint;}},C=class extends w{constructor(n,r){super(n,{exitCode:2,hint:r?.hint??"Run `<product> auth login` to authenticate."}),this.name="CliAuthError";}},f=class extends Error{cause;constructor(n,r){super(n),this.name="CliInternalError",this.cause=r;}};var v=class extends f{constructor(n,r){super(`Module '${n}' declares dependency on '${r}', but '${r}' is not in the module list.`),this.name="MissingDependencyError";}},E=class extends f{constructor(n){super(`Circular dependency detected among modules: ${n.join(" -> ")}`),this.name="CircularDependencyError";}};function j(e){let n=new Map;for(let o of e){if(n.has(o.id))throw new f(`Duplicate module id: '${o.id}'`);n.set(o.id,o);}for(let o of e)for(let c of o.dependsOn??[])if(!n.has(c))throw new v(o.id,c);let r=[],t=new Set,a=new Set;function i(o,c){if(!a.has(o.id)){if(t.has(o.id))throw new E([...c,o.id]);t.add(o.id);for(let p of o.dependsOn??[]){let g=n.get(p);g&&i(g,[...c,o.id]);}t.delete(o.id),a.add(o.id),r.push(o);}}for(let o of e)i(o,[]);return r}function Se(e,n,r){let t=new commander.Command;t.name(r.name).description(r.description??"").version(r.version,"-v, --version").option("-f, --format <format>","Output format (json, table, yaml)").option("--verbose","Enable verbose logging").option("--no-color","Disable colored output");let a=j(n);for(let o of a)o.register(t,e);r.helpExamples?.length&&t.addHelpText("after",`
28
+ `;try{let f=(await c.request(l,{token:a.refreshToken})).refreshToken;n.write({...a,accessToken:f.accessToken,refreshToken:f.refreshToken,expiresAt:Date.now()+f.expiresIn*1e3}),r=null,t=null;}catch{}}async function o(){let a=n.read();if(!a?.accessToken||!a.workspaceId||!a.organizationId)return;let g=e.read();try{let c=await $(g.workspaceEndpoint,a.accessToken,a.workspaceId,a.organizationId);n.write({...a,workspaceToken:c.token,workspaceTokenExpiresAt:new Date(c.expiresAt).getTime()}),r=null;}catch{}}async function u(){n.isTokenExpiringSoon()&&await i(),n.read()?.workspaceToken&&n.isWorkspaceTokenExpiringSoon()&&await o();}return {workspace:{async request(a,g){await u();let{workspace:c}=r?{workspace:r}:s();return c.setHeaders(z(n.read(),e.resolveProductOrigin())),P(c,a,g)}},global:{async request(a,g){let{global:c}=t?{global:t}:s();return c.setHeaders(v(n.read())),P(c,a,g)}},workspaceAuthOnly:{async request(a,g){let c=e.read(),l=n.read(),p=new graphqlRequest.GraphQLClient(c.workspaceEndpoint),f=v(l),F=e.resolveProductOrigin();return F&&(f.Origin=F),p.setHeaders(f),P(p,a,g)}},reset(){r=null,t=null;}}}function q(){return !!(process.stdout.isTTY&&process.stdin.isTTY)}function H(e){if(e.format){let n=e.format.toLowerCase();if(n==="json"||n==="table"||n==="yaml")return n}return q()?"table":"json"}function D(e){console.log(JSON.stringify(e,null,2));}function V(e,n){if(e.length===0)return;let r=e.map((i,o)=>{let u=i.length;for(let d of n){let k=d[o]??"";k.length>u&&(u=k.length);}return Math.min(u,50)}),t=r.map(i=>"-".repeat(i+2)).join("+"),s=i=>i.map((o,u)=>` ${(o??"").padEnd(r[u]??0)} `).join("|");console.log(s(e)),console.log(t);for(let i of n)console.log(s(i));}function L(e,n){let r=" ".repeat(n),t=[];for(let[s,i]of Object.entries(e))if(i==null)t.push(`${r}${s}: null`);else if(Array.isArray(i)){t.push(`${r}${s}:`);for(let o of i)typeof o=="object"&&o!==null?(t.push(`${r} -`),t.push(L(o,n+2))):t.push(`${r} - ${String(o)}`);}else typeof i=="object"?(t.push(`${r}${s}:`),t.push(L(i,n+1))):t.push(`${r}${s}: ${String(i)}`);return t.join(`
29
+ `)}function J(e){if(typeof e!="object"||e===null){console.log(String(e));return}console.log(L(e,0));}function we(e){console.log(`\u2713 ${e}`);}function Y(e){console.error(`\u2717 ${e}`);}function he(e){console.warn(`! ${e}`);}function ye(e){console.log(`\u2139 ${e}`);}function Ce(e){if(!e)return "-";try{return new Date(e).toLocaleString()}catch{return e}}function xe(e){if(!e)return "-";switch(e.toUpperCase()){case "ACTIVE":case "RUNNING":case "HEALTHY":return `\u2713 ${e}`;case "INACTIVE":case "STOPPED":case "PENDING":return `\u25CB ${e}`;case "ERROR":return `\u2717 ${e}`;case "ARCHIVED":return `\u2192 ${e}`;case "STARTING":return `\u25B6 ${e}`;case "TERMINATED":return `\u25A0 ${e}`;default:return e}}function be(e,n){return e?e.length<=n?e:e.substring(0,n-3)+"...":"-"}function ve(e,n,r){switch(H(e)){case "json":D(n);break;case "yaml":J(n);break;case "table":r?V(r.headers,r.rows):D(n);break}}async function Te(e,n){return n?true:q()?new Promise(r=>{process.stdout.write(`${e} [y/N] `),process.stdin.setEncoding("utf8"),process.stdin.once("data",t=>{let s=t.trim().toLowerCase();r(s==="y"||s==="yes");}),process.stdin.resume();}):(Y(`${e} Use --force to skip confirmation.`),false)}var _={isInteractive:q,getFormat:H,formatAndOutput:ve,printJson:D,printTable:V,printYaml:J,printSuccess:we,printError:Y,printWarning:he,printInfo:ye,formatDate:Ce,formatStatus:xe,truncate:be,confirm:Te};function N(e={}){let{verbose:n=false,quiet:r=false}=e;return {debug(t,...s){n&&console.error(`[debug] ${t}`,...s);},info(t,...s){r||console.error(`[info] ${t}`,...s);},warn(t,...s){console.error(`[warn] ${t}`,...s);},error(t,...s){console.error(`[error] ${t}`,...s);}}}function Ee(e){return e.includes("localhost")||e.includes("127.0.0.1")?"local":e.includes("alpha")||e.includes("staging")?"staging":"prod"}function Ie(e){return !!e&&typeof e.debug=="function"&&typeof e.info=="function"}function Ae(e){let n=O(e.defaults),r=A(n.dir()),t=R(n,r),s=e.output??_,i=Ie(e.logger)?e.logger:N(e.logger),o=e.env??Ee(n.read().workspaceEndpoint);return {productName:e.productName,productVersion:e.productVersion,defaults:e.defaults,config:n,auth:r,gql:t,output:s,logger:i,env:o}}var h=class extends Error{exitCode;hint;constructor(n,r){super(n),this.name="CliUserError",this.exitCode=r?.exitCode??1,this.hint=r?.hint;}},C=class extends h{constructor(n,r){super(n,{exitCode:2,hint:r?.hint??"Run `<product> auth login` to authenticate."}),this.name="CliAuthError";}},w=class extends Error{cause;constructor(n,r){super(n),this.name="CliInternalError",this.cause=r;}};var T=class extends w{constructor(n,r){super(`Module '${n}' declares dependency on '${r}', but '${r}' is not in the module list.`),this.name="MissingDependencyError";}},E=class extends w{constructor(n){super(`Circular dependency detected among modules: ${n.join(" -> ")}`),this.name="CircularDependencyError";}};function j(e){let n=new Map;for(let o of e){if(n.has(o.id))throw new w(`Duplicate module id: '${o.id}'`);n.set(o.id,o);}for(let o of e)for(let u of o.dependsOn??[])if(!n.has(u))throw new T(o.id,u);let r=[],t=new Set,s=new Set;function i(o,u){if(!s.has(o.id)){if(t.has(o.id))throw new E([...u,o.id]);t.add(o.id);for(let d of o.dependsOn??[]){let k=n.get(d);k&&i(k,[...u,o.id]);}t.delete(o.id),s.add(o.id),r.push(o);}}for(let o of e)i(o,[]);return r}function Se(e,n,r){let t=new commander.Command;t.name(r.name).description(r.description??"").version(r.version,"-v, --version").option("-f, --format <format>","Output format (json, table, yaml)").option("--verbose","Enable verbose logging").option("--no-color","Disable colored output");let s=j(n);for(let o of s)o.register(t,e);r.helpExamples?.length&&t.addHelpText("after",`
30
30
  Examples:
31
31
  `+r.helpExamples.map(o=>" "+o).join(`
32
- `)),t.on("command:*",()=>{e.output.printError(`Invalid command: ${t.args.join(" ")}`),e.output.printInfo(`Run \`${r.name} --help\` for available commands.`),process.exit(1);});async function i(o=process.argv){try{await t.parseAsync(o),o.length<=2&&t.outputHelp();}catch(c){Oe(e,c);}}return {program:t,run:i}}function Oe(e,n){if(n instanceof C&&(e.output.printError(n.message),n.hint&&e.output.printInfo(n.hint),process.exit(n.exitCode)),n instanceof w&&(e.output.printError(n.message),n.hint&&e.output.printInfo(n.hint),process.exit(n.exitCode)),n instanceof f&&(e.output.printError(`Internal error: ${n.message}`),n.cause&&e.logger.debug("caused by:",n.cause),process.exit(70)),n&&typeof n=="object"&&"code"in n&&"exitCode"in n){let t=n.exitCode;process.exit(typeof t=="number"?t:0);}let r=n instanceof Error?n.message:String(n);e.output.printError(r),process.exit(1);}exports.CircularDependencyError=E;exports.CliAuthError=C;exports.CliInternalError=f;exports.CliUserError=w;exports.KNOWN_CONFIG_KEYS=ie;exports.MissingDependencyError=v;exports.buildContext=Ie;exports.clientCredentialsFlow=O;exports.createAuthStore=A;exports.createConfigStore=S;exports.createGqlClients=P;exports.createLogger=N;exports.createProgram=Se;exports.defaultOutputAdapter=_;exports.extractGqlErrorMessage=z;exports.fetchWorkspaces=ue;exports.issueWorkspaceToken=$;exports.openBrowser=pe;exports.pollForToken=ce;exports.sortModules=j;exports.startDeviceCodeFlow=ae;
32
+ `)),t.on("command:*",()=>{e.output.printError(`Invalid command: ${t.args.join(" ")}`),e.output.printInfo(`Run \`${r.name} --help\` for available commands.`),process.exit(1);});async function i(o=process.argv){try{await t.parseAsync(o),o.length<=2&&t.outputHelp();}catch(u){$e(e,u);}}return {program:t,run:i}}function $e(e,n){if(n instanceof C&&(e.output.printError(n.message),n.hint&&e.output.printInfo(n.hint),process.exit(n.exitCode)),n instanceof h&&(e.output.printError(n.message),n.hint&&e.output.printInfo(n.hint),process.exit(n.exitCode)),n instanceof w&&(e.output.printError(`Internal error: ${n.message}`),n.cause&&e.logger.debug("caused by:",n.cause),process.exit(70)),n&&typeof n=="object"&&"code"in n&&"exitCode"in n){let t=n.exitCode;process.exit(typeof t=="number"?t:0);}let r=n instanceof Error?n.message:String(n);e.output.printError(r),process.exit(1);}exports.CircularDependencyError=E;exports.CliAuthError=C;exports.CliInternalError=w;exports.CliUserError=h;exports.KNOWN_CONFIG_KEYS=ae;exports.MissingDependencyError=T;exports.buildContext=Ae;exports.clientCredentialsFlow=S;exports.createAuthStore=A;exports.createConfigStore=O;exports.createGqlClients=R;exports.createLogger=N;exports.createProgram=Se;exports.defaultOutputAdapter=_;exports.extractGqlErrorMessage=B;exports.fetchWorkspaces=le;exports.issueWorkspaceToken=$;exports.openBrowser=de;exports.pollForToken=ue;exports.sortModules=j;exports.startDeviceCodeFlow=ce;
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- export { A as AuthStore, B as BuildContextOptions, b as CLIConfig, a as CLIContext, c as CircularDependencyError, d as CliAuthError, e as CliInternalError, C as CliModule, f as CliUserError, g as ConfigStore, E as Environment, G as GqlClient, h as GqlClients, K as KNOWN_CONFIG_KEYS, L as Logger, i as LoggerOptions, M as MissingDependencyError, O as OutputAdapter, j as OutputFormat, P as ProductDefaults, S as StoredAuth, T as TableConfig, k as buildContext, l as createAuthStore, m as createConfigStore, n as createGqlClients, o as createLogger, p as defaultOutputAdapter, q as extractGqlErrorMessage, s as sortModules } from './module-DxCuik6L.cjs';
1
+ export { A as AuthStore, B as BuildContextOptions, b as CLIConfig, a as CLIContext, c as CircularDependencyError, d as CliAuthError, e as CliInternalError, C as CliModule, f as CliUserError, g as ConfigStore, E as Environment, G as GqlClient, h as GqlClients, K as KNOWN_CONFIG_KEYS, L as Logger, i as LoggerOptions, M as MissingDependencyError, O as OutputAdapter, j as OutputFormat, P as ProductDefaults, S as StoredAuth, T as TableConfig, k as buildContext, l as createAuthStore, m as createConfigStore, n as createGqlClients, o as createLogger, p as defaultOutputAdapter, q as extractGqlErrorMessage, s as sortModules } from './module-DOIiVaXQ.cjs';
2
2
  export { ClientCredentialsResult, CreateProgramOptions, DeviceCodeResponse, DeviceCodeTokenResult, OIDCConfig, ProgramFactoryResult, clientCredentialsFlow, createProgram, fetchWorkspaces, issueWorkspaceToken, openBrowser, pollForToken, startDeviceCodeFlow } from './core/index.cjs';
3
3
  import 'commander';
4
4
  import 'graphql-request';
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { A as AuthStore, B as BuildContextOptions, b as CLIConfig, a as CLIContext, c as CircularDependencyError, d as CliAuthError, e as CliInternalError, C as CliModule, f as CliUserError, g as ConfigStore, E as Environment, G as GqlClient, h as GqlClients, K as KNOWN_CONFIG_KEYS, L as Logger, i as LoggerOptions, M as MissingDependencyError, O as OutputAdapter, j as OutputFormat, P as ProductDefaults, S as StoredAuth, T as TableConfig, k as buildContext, l as createAuthStore, m as createConfigStore, n as createGqlClients, o as createLogger, p as defaultOutputAdapter, q as extractGqlErrorMessage, s as sortModules } from './module-DxCuik6L.js';
1
+ export { A as AuthStore, B as BuildContextOptions, b as CLIConfig, a as CLIContext, c as CircularDependencyError, d as CliAuthError, e as CliInternalError, C as CliModule, f as CliUserError, g as ConfigStore, E as Environment, G as GqlClient, h as GqlClients, K as KNOWN_CONFIG_KEYS, L as Logger, i as LoggerOptions, M as MissingDependencyError, O as OutputAdapter, j as OutputFormat, P as ProductDefaults, S as StoredAuth, T as TableConfig, k as buildContext, l as createAuthStore, m as createConfigStore, n as createGqlClients, o as createLogger, p as defaultOutputAdapter, q as extractGqlErrorMessage, s as sortModules } from './module-DOIiVaXQ.js';
2
2
  export { ClientCredentialsResult, CreateProgramOptions, DeviceCodeResponse, DeviceCodeTokenResult, OIDCConfig, ProgramFactoryResult, clientCredentialsFlow, createProgram, fetchWorkspaces, issueWorkspaceToken, openBrowser, pollForToken, startDeviceCodeFlow } from './core/index.js';
3
3
  import 'commander';
4
4
  import 'graphql-request';
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- export{s as CircularDependencyError,p as CliAuthError,q as CliInternalError,o as CliUserError,b as KNOWN_CONFIG_KEYS,r as MissingDependencyError,n as buildContext,f as clientCredentialsFlow,a as createAuthStore,c as createConfigStore,k as createGqlClients,m as createLogger,u as createProgram,l as defaultOutputAdapter,j as extractGqlErrorMessage,h as fetchWorkspaces,g as issueWorkspaceToken,i as openBrowser,e as pollForToken,t as sortModules,d as startDeviceCodeFlow}from'./chunk-TCBALVP4.js';
1
+ export{s as CircularDependencyError,p as CliAuthError,q as CliInternalError,o as CliUserError,b as KNOWN_CONFIG_KEYS,r as MissingDependencyError,n as buildContext,f as clientCredentialsFlow,a as createAuthStore,c as createConfigStore,k as createGqlClients,m as createLogger,u as createProgram,l as defaultOutputAdapter,j as extractGqlErrorMessage,h as fetchWorkspaces,g as issueWorkspaceToken,i as openBrowser,e as pollForToken,t as sortModules,d as startDeviceCodeFlow}from'./chunk-IZXPWPKX.js';
@@ -33,6 +33,7 @@ interface CLIConfig {
33
33
  defaultFormat?: string;
34
34
  verbose?: boolean;
35
35
  authServiceEndpoint?: string;
36
+ productOrigin?: string;
36
37
  }
37
38
  interface ProductDefaults {
38
39
  configDirName: string;
@@ -41,6 +42,7 @@ interface ProductDefaults {
41
42
  workspaceEndpointDefault: string;
42
43
  globalEndpointDefault: string;
43
44
  envPrefix?: string;
45
+ productOrigins?: Readonly<Record<string, string>>;
44
46
  }
45
47
  interface ConfigStore {
46
48
  read(): CLIConfig;
@@ -53,8 +55,9 @@ interface ConfigStore {
53
55
  oidcIssuer: string;
54
56
  clientId: string;
55
57
  };
58
+ resolveProductOrigin(): string | undefined;
56
59
  }
57
- declare const KNOWN_CONFIG_KEYS: readonly ["workspaceEndpoint", "globalEndpoint", "oidcIssuer", "clientId", "defaultFormat", "verbose", "authServiceEndpoint"];
60
+ declare const KNOWN_CONFIG_KEYS: readonly ["workspaceEndpoint", "globalEndpoint", "oidcIssuer", "clientId", "defaultFormat", "verbose", "authServiceEndpoint", "productOrigin"];
58
61
  declare function createConfigStore(defaults: ProductDefaults): ConfigStore;
59
62
 
60
63
  interface GqlClient {
@@ -33,6 +33,7 @@ interface CLIConfig {
33
33
  defaultFormat?: string;
34
34
  verbose?: boolean;
35
35
  authServiceEndpoint?: string;
36
+ productOrigin?: string;
36
37
  }
37
38
  interface ProductDefaults {
38
39
  configDirName: string;
@@ -41,6 +42,7 @@ interface ProductDefaults {
41
42
  workspaceEndpointDefault: string;
42
43
  globalEndpointDefault: string;
43
44
  envPrefix?: string;
45
+ productOrigins?: Readonly<Record<string, string>>;
44
46
  }
45
47
  interface ConfigStore {
46
48
  read(): CLIConfig;
@@ -53,8 +55,9 @@ interface ConfigStore {
53
55
  oidcIssuer: string;
54
56
  clientId: string;
55
57
  };
58
+ resolveProductOrigin(): string | undefined;
56
59
  }
57
- declare const KNOWN_CONFIG_KEYS: readonly ["workspaceEndpoint", "globalEndpoint", "oidcIssuer", "clientId", "defaultFormat", "verbose", "authServiceEndpoint"];
60
+ declare const KNOWN_CONFIG_KEYS: readonly ["workspaceEndpoint", "globalEndpoint", "oidcIssuer", "clientId", "defaultFormat", "verbose", "authServiceEndpoint", "productOrigin"];
58
61
  declare function createConfigStore(defaults: ProductDefaults): ConfigStore;
59
62
 
60
63
  interface GqlClient {