@burdenoff/cli-sdk 2026.1110.2 → 2026.1123.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-WTNQ5PEC.js → chunk-3ZVMC2AF.js} +1 -1
- package/dist/{chunk-6HSWVWQW.js → chunk-ASSY2L5R.js} +1 -1
- package/dist/chunk-ZT6KOG7N.js +34 -0
- package/dist/core/index.cjs +8 -8
- package/dist/core/index.d.cts +2 -2
- package/dist/core/index.d.ts +2 -2
- package/dist/core/index.js +1 -1
- package/dist/index.cjs +8 -8
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/{module-CLaW1ycq.d.ts → module-BNVKV_pI.d.cts} +11 -1
- package/dist/{module-CLaW1ycq.d.cts → module-BNVKV_pI.d.ts} +11 -1
- package/dist/modules/adaptercloud/index.cjs +4 -4
- package/dist/modules/adaptercloud/index.d.cts +1 -1
- package/dist/modules/adaptercloud/index.d.ts +1 -1
- package/dist/modules/adaptercloud/index.js +1 -1
- package/dist/modules/artistrybase/index.cjs +3 -3
- package/dist/modules/artistrybase/index.d.cts +1 -1
- package/dist/modules/artistrybase/index.d.ts +1 -1
- package/dist/modules/artistrybase/index.js +1 -1
- package/dist/modules/assethandler/index.cjs +7 -7
- package/dist/modules/assethandler/index.d.cts +1 -1
- package/dist/modules/assethandler/index.d.ts +1 -1
- package/dist/modules/assethandler/index.js +1 -1
- package/dist/modules/atheletebridge/index.cjs +4 -4
- package/dist/modules/atheletebridge/index.d.cts +1 -1
- package/dist/modules/atheletebridge/index.d.ts +1 -1
- package/dist/modules/atheletebridge/index.js +1 -1
- package/dist/modules/auth/index.d.cts +1 -1
- package/dist/modules/auth/index.d.ts +1 -1
- package/dist/modules/auth/index.js +1 -1
- package/dist/modules/billing/index.cjs +8 -8
- package/dist/modules/billing/index.d.cts +1 -1
- package/dist/modules/billing/index.d.ts +1 -1
- package/dist/modules/billing/index.js +1 -1
- package/dist/modules/brainyrich/index.cjs +8 -8
- package/dist/modules/brainyrich/index.d.cts +1 -1
- package/dist/modules/brainyrich/index.d.ts +1 -1
- package/dist/modules/brainyrich/index.js +1 -1
- package/dist/modules/buildmyiq/index.d.cts +1 -1
- package/dist/modules/buildmyiq/index.d.ts +1 -1
- package/dist/modules/buildmyiq/index.js +1 -1
- package/dist/modules/channels/index.cjs +8 -8
- package/dist/modules/channels/index.d.cts +1 -1
- package/dist/modules/channels/index.d.ts +1 -1
- package/dist/modules/channels/index.js +1 -1
- package/dist/modules/collabkin/index.cjs +3 -3
- package/dist/modules/collabkin/index.d.cts +1 -1
- package/dist/modules/collabkin/index.d.ts +1 -1
- package/dist/modules/collabkin/index.js +1 -1
- package/dist/modules/comradecircle/index.cjs +10 -10
- package/dist/modules/comradecircle/index.d.cts +1 -1
- package/dist/modules/comradecircle/index.d.ts +1 -1
- package/dist/modules/comradecircle/index.js +1 -1
- package/dist/modules/conversations/index.cjs +4 -4
- package/dist/modules/conversations/index.d.cts +1 -1
- package/dist/modules/conversations/index.d.ts +1 -1
- package/dist/modules/conversations/index.js +1 -1
- package/dist/modules/coolandlovely/index.cjs +3 -3
- package/dist/modules/coolandlovely/index.d.cts +1 -1
- package/dist/modules/coolandlovely/index.d.ts +1 -1
- package/dist/modules/coolandlovely/index.js +1 -1
- package/dist/modules/cosmicintersection/index.cjs +4 -4
- package/dist/modules/cosmicintersection/index.d.cts +1 -1
- package/dist/modules/cosmicintersection/index.d.ts +1 -1
- package/dist/modules/cosmicintersection/index.js +1 -1
- package/dist/modules/crewfoundry/index.cjs +7 -7
- package/dist/modules/crewfoundry/index.d.cts +1 -1
- package/dist/modules/crewfoundry/index.d.ts +1 -1
- package/dist/modules/crewfoundry/index.js +1 -1
- package/dist/modules/devportal/index.cjs +6 -6
- package/dist/modules/devportal/index.d.cts +1 -1
- package/dist/modules/devportal/index.d.ts +1 -1
- package/dist/modules/devportal/index.js +1 -1
- package/dist/modules/ecoimpacthub/index.cjs +3 -3
- package/dist/modules/ecoimpacthub/index.d.cts +1 -1
- package/dist/modules/ecoimpacthub/index.d.ts +1 -1
- package/dist/modules/ecoimpacthub/index.js +1 -1
- package/dist/modules/eventfullymanaged/index.cjs +13 -13
- package/dist/modules/eventfullymanaged/index.d.cts +1 -1
- package/dist/modules/eventfullymanaged/index.d.ts +1 -1
- package/dist/modules/eventfullymanaged/index.js +1 -1
- package/dist/modules/export/index.cjs +5 -5
- package/dist/modules/export/index.d.cts +1 -1
- package/dist/modules/export/index.d.ts +1 -1
- package/dist/modules/export/index.js +1 -1
- package/dist/modules/files/index.cjs +7 -7
- package/dist/modules/files/index.d.cts +1 -1
- package/dist/modules/files/index.d.ts +1 -1
- package/dist/modules/files/index.js +1 -1
- package/dist/modules/fluidgrids/index.cjs +5 -5
- package/dist/modules/fluidgrids/index.d.cts +1 -1
- package/dist/modules/fluidgrids/index.d.ts +1 -1
- package/dist/modules/fluidgrids/index.js +1 -1
- package/dist/modules/ggnomad/index.cjs +6 -6
- package/dist/modules/ggnomad/index.d.cts +1 -1
- package/dist/modules/ggnomad/index.d.ts +1 -1
- package/dist/modules/ggnomad/index.js +1 -1
- package/dist/modules/govcitizenhub/index.cjs +6 -6
- package/dist/modules/govcitizenhub/index.d.cts +1 -1
- package/dist/modules/govcitizenhub/index.d.ts +1 -1
- package/dist/modules/govcitizenhub/index.js +1 -1
- package/dist/modules/groups/index.cjs +2 -2
- package/dist/modules/groups/index.d.cts +1 -1
- package/dist/modules/groups/index.d.ts +1 -1
- package/dist/modules/groups/index.js +1 -1
- package/dist/modules/headshotmarketing/index.d.cts +1 -1
- package/dist/modules/headshotmarketing/index.d.ts +1 -1
- package/dist/modules/headshotmarketing/index.js +1 -1
- package/dist/modules/health/index.d.cts +1 -1
- package/dist/modules/health/index.d.ts +1 -1
- package/dist/modules/hookmovies/index.cjs +4 -4
- package/dist/modules/hookmovies/index.d.cts +1 -1
- package/dist/modules/hookmovies/index.d.ts +1 -1
- package/dist/modules/hookmovies/index.js +1 -1
- package/dist/modules/housingvista/index.cjs +13 -13
- package/dist/modules/housingvista/index.d.cts +1 -1
- package/dist/modules/housingvista/index.d.ts +1 -1
- package/dist/modules/housingvista/index.js +1 -1
- package/dist/modules/integrations/index.cjs +7 -7
- package/dist/modules/integrations/index.d.cts +1 -1
- package/dist/modules/integrations/index.d.ts +1 -1
- package/dist/modules/integrations/index.js +1 -1
- package/dist/modules/intelwatchtower/index.cjs +6 -6
- package/dist/modules/intelwatchtower/index.d.cts +1 -1
- package/dist/modules/intelwatchtower/index.d.ts +1 -1
- package/dist/modules/intelwatchtower/index.js +1 -1
- package/dist/modules/kadaikodi/index.cjs +5 -5
- package/dist/modules/kadaikodi/index.d.cts +1 -1
- package/dist/modules/kadaikodi/index.d.ts +1 -1
- package/dist/modules/kadaikodi/index.js +1 -1
- package/dist/modules/labsofscience/index.cjs +6 -6
- package/dist/modules/labsofscience/index.d.cts +1 -1
- package/dist/modules/labsofscience/index.d.ts +1 -1
- package/dist/modules/labsofscience/index.js +1 -1
- package/dist/modules/manufacturedops/index.cjs +8 -8
- package/dist/modules/manufacturedops/index.d.cts +1 -1
- package/dist/modules/manufacturedops/index.d.ts +1 -1
- package/dist/modules/manufacturedops/index.js +1 -1
- package/dist/modules/movethewheels/index.cjs +18 -18
- package/dist/modules/movethewheels/index.d.cts +1 -1
- package/dist/modules/movethewheels/index.d.ts +1 -1
- package/dist/modules/movethewheels/index.js +1 -1
- package/dist/modules/mybodyshield/index.cjs +5 -5
- package/dist/modules/mybodyshield/index.d.cts +1 -1
- package/dist/modules/mybodyshield/index.d.ts +1 -1
- package/dist/modules/mybodyshield/index.js +1 -1
- package/dist/modules/notifications/index.cjs +4 -4
- package/dist/modules/notifications/index.d.cts +1 -1
- package/dist/modules/notifications/index.d.ts +1 -1
- package/dist/modules/notifications/index.js +1 -1
- package/dist/modules/organizations/index.cjs +2 -2
- package/dist/modules/organizations/index.d.cts +1 -1
- package/dist/modules/organizations/index.d.ts +1 -1
- package/dist/modules/organizations/index.js +1 -1
- package/dist/modules/planmagnet/index.cjs +17 -17
- package/dist/modules/planmagnet/index.d.cts +1 -1
- package/dist/modules/planmagnet/index.d.ts +1 -1
- package/dist/modules/planmagnet/index.js +1 -1
- package/dist/modules/products/index.cjs +8 -8
- package/dist/modules/products/index.d.cts +1 -1
- package/dist/modules/products/index.d.ts +1 -1
- package/dist/modules/products/index.js +1 -1
- package/dist/modules/proserviceworld/index.cjs +4 -4
- package/dist/modules/proserviceworld/index.d.cts +1 -1
- package/dist/modules/proserviceworld/index.d.ts +1 -1
- package/dist/modules/proserviceworld/index.js +1 -1
- package/dist/modules/rbac/index.cjs +5 -5
- package/dist/modules/rbac/index.d.cts +1 -1
- package/dist/modules/rbac/index.d.ts +1 -1
- package/dist/modules/rbac/index.js +1 -1
- package/dist/modules/sandbox/index.cjs +1 -1
- package/dist/modules/sandbox/index.d.cts +1 -1
- package/dist/modules/sandbox/index.d.ts +1 -1
- package/dist/modules/sandbox/index.js +1 -1
- package/dist/modules/scheduler/index.cjs +6 -6
- package/dist/modules/scheduler/index.d.cts +1 -1
- package/dist/modules/scheduler/index.d.ts +1 -1
- package/dist/modules/scheduler/index.js +1 -1
- package/dist/modules/security/index.cjs +7 -7
- package/dist/modules/security/index.d.cts +1 -1
- package/dist/modules/security/index.d.ts +1 -1
- package/dist/modules/security/index.js +1 -1
- package/dist/modules/semanticfed/index.cjs +7 -7
- package/dist/modules/semanticfed/index.d.cts +1 -1
- package/dist/modules/semanticfed/index.d.ts +1 -1
- package/dist/modules/semanticfed/index.js +1 -1
- package/dist/modules/semanticfed-sql/index.cjs +4 -4
- package/dist/modules/semanticfed-sql/index.d.cts +1 -1
- package/dist/modules/semanticfed-sql/index.d.ts +1 -1
- package/dist/modules/semanticfed-sql/index.js +1 -1
- package/dist/modules/store/index.cjs +7 -7
- package/dist/modules/store/index.d.cts +1 -1
- package/dist/modules/store/index.d.ts +1 -1
- package/dist/modules/store/index.js +1 -1
- package/dist/modules/subscriberbot/index.cjs +4 -4
- package/dist/modules/subscriberbot/index.d.cts +1 -1
- package/dist/modules/subscriberbot/index.d.ts +1 -1
- package/dist/modules/subscriberbot/index.js +1 -1
- package/dist/modules/support/index.cjs +2 -2
- package/dist/modules/support/index.d.cts +1 -1
- package/dist/modules/support/index.d.ts +1 -1
- package/dist/modules/support/index.js +1 -1
- package/dist/modules/tags/index.cjs +2 -2
- package/dist/modules/tags/index.d.cts +1 -1
- package/dist/modules/tags/index.d.ts +1 -1
- package/dist/modules/tags/index.js +1 -1
- package/dist/modules/technospam/index.cjs +10 -10
- package/dist/modules/technospam/index.d.cts +1 -1
- package/dist/modules/technospam/index.d.ts +1 -1
- package/dist/modules/technospam/index.js +1 -1
- package/dist/modules/theculturepost/index.cjs +8 -8
- package/dist/modules/theculturepost/index.d.cts +1 -1
- package/dist/modules/theculturepost/index.d.ts +1 -1
- package/dist/modules/theculturepost/index.js +1 -1
- package/dist/modules/theglobalfuel/index.cjs +4 -4
- package/dist/modules/theglobalfuel/index.d.cts +1 -1
- package/dist/modules/theglobalfuel/index.d.ts +1 -1
- package/dist/modules/theglobalfuel/index.js +1 -1
- package/dist/modules/timecampus/index.cjs +72 -61
- package/dist/modules/timecampus/index.d.cts +7 -3
- package/dist/modules/timecampus/index.d.ts +7 -3
- package/dist/modules/timecampus/index.js +72 -61
- package/dist/modules/tours/index.cjs +2 -2
- package/dist/modules/tours/index.d.cts +1 -1
- package/dist/modules/tours/index.d.ts +1 -1
- package/dist/modules/tours/index.js +1 -1
- package/dist/modules/vibecontrols/index.cjs +32 -32
- package/dist/modules/vibecontrols/index.d.cts +1 -1
- package/dist/modules/vibecontrols/index.d.ts +1 -1
- package/dist/modules/vibecontrols/index.js +1 -1
- package/dist/modules/workspaces/index.cjs +7 -7
- package/dist/modules/workspaces/index.d.cts +1 -1
- package/dist/modules/workspaces/index.d.ts +1 -1
- package/dist/modules/workspaces/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-MT2F54AC.js +0 -34
|
@@ -1 +1 @@
|
|
|
1
|
-
import {b as b$1,q as q$1,r,s}from'./chunk-
|
|
1
|
+
import {b as b$1,q as q$1,r,s}from'./chunk-ZT6KOG7N.js';var o=null;function b(t){o=t;}function e(){if(!o)throw new s("vibecontrols module helpers used before setHelpersContext was called");return o}function p(){let t=e();if(!t.auth.isAuthenticated())throw new r("Authentication required.",{hint:`Run \`${t.productName} auth login\` to authenticate.`})}async function w(t,n){return p(),e().gql.workspace.request(t,n)}async function T(t,n){return e().gql.global.request(t,n)}async function q(t,n){return e().gql.workspaceAuthOnly.request(t,n)}async function A(t,n){return e().gql.global.request(t,n)}function k(){e().gql.reset();}function v(t){return /^(error|fail|failed|failure|timeout|cancel)/i.test(t.status)||t.exitCode!==null&&t.exitCode!==void 0&&t.exitCode!==0?true:t.webhookStatusCode!==null&&t.webhookStatusCode!==void 0&&t.webhookStatusCode>=400}function S(t){let n=t instanceof Error?t.message:String(t);throw new q$1(n)}function E(t,n,a){e().output.formatAndOutput(t,n,a);}function I(){return e().output}function O(t){e().output.printSuccess(t);}function D(t){e().output.printError(t);}function y(t){e().output.printInfo(t);}function N(t){e().output.printWarning(t);}function R(t){e().output.printJson(t);}function F(t){return e().output.formatStatus(t)}function W(t){return e().output.formatDate(t)}function L(t,n){return e().output.truncate(t,n)}function V(t,n){return e().output.confirm(t,n)}function P(t,n){e().output.printTable(t,n);}function _(){return e()}function K(){return e().auth.read()}function G(t){e().auth.write(t);}function B(){e().auth.clear();}function Y(){return e().config.read()}function j(t){return e().config.get(t)}function H(t,n){e().config.set(t,n);}function J(){return e().config.path()}var U=b$1;function $(){return e().config.resolveOIDC()}function z(t){return t?t.expiresAt?Date.now()>=t.expiresAt:false:e().auth.isTokenExpired()}export{H as A,J as B,U as C,$ as D,z as E,b as a,w as b,T as c,q as d,A as e,k as f,v as g,S as h,E as i,I as j,O as k,D as l,y as m,N as n,R as o,F as p,W as q,L as r,V as s,P as t,_ as u,K as v,G as w,B as x,Y as y,j as z};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {b as b$1,h as h$1,j as j$1}from'./chunk-
|
|
1
|
+
import {b as b$1,h as h$1,j as j$1}from'./chunk-3ZVMC2AF.js';import {q as q$1}from'./chunk-ZT6KOG7N.js';var h=`
|
|
2
2
|
query SemConnector($id: ID!) {
|
|
3
3
|
semConnector(id: $id) {
|
|
4
4
|
id name kind description isActive capabilities
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import {existsSync,readFileSync,writeFileSync,chmodSync,unlinkSync,mkdirSync}from'fs';import {join}from'path';import {homedir}from'os';import {GraphQLClient}from'graphql-request';import b from'cross-fetch';import {Command}from'commander';var z=300*1e3;function $(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 c=readFileSync(n,"utf8");return JSON.parse(c)}catch{return null}}function s(c){r(),writeFileSync(n,JSON.stringify(c,null,2),{encoding:"utf8",mode:384});try{chmodSync(n,384);}catch{}}function i(){try{existsSync(n)&&unlinkSync(n);}catch{}}function o(){let c=t();return c?.expiresAt?Date.now()>=c.expiresAt:false}function a(){let c=t();return c?.expiresAt?Date.now()+z>=c.expiresAt:false}function l(){let c=t();return c?.workspaceTokenExpiresAt?Date.now()>=c.workspaceTokenExpiresAt:false}function m(){let c=t();return c?.workspaceTokenExpiresAt?Date.now()+z>=c.workspaceTokenExpiresAt:false}function x(){return t()?.accessToken?!o():false}return {read:t,write:s,clear:i,isTokenExpired:o,isTokenExpiringSoon:a,isWorkspaceTokenExpired:l,isWorkspaceTokenExpiringSoon:m,isAuthenticated:x}}var pe=["workspaceEndpoint","globalEndpoint","oidcIssuer","clientId","defaultFormat","verbose","authServiceEndpoint","productOrigin"];function P(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(u){if(e.envPrefix){let g=process.env[`${e.envPrefix}_${u}`];if(g)return g}let d=process.env[u];return d&&d.length>0?d:void 0}function o(u){if(!e.envPrefix)return;let d=process.env[`${e.envPrefix}_${u}`];return d&&d.length>0?d:void 0}function a(){let u={};try{existsSync(r)&&(u=JSON.parse(readFileSync(r,"utf8")));}catch{}return {...t,...u,workspaceEndpoint:i("WORKSPACE_ENDPOINT")??u.workspaceEndpoint??t.workspaceEndpoint,globalEndpoint:i("GLOBAL_ENDPOINT")??u.globalEndpoint??t.globalEndpoint,oidcIssuer:i("OIDC_ISSUER")??u.oidcIssuer,clientId:i("CLIENT_ID")??u.clientId,productOrigin:o("ORIGIN")??u.productOrigin}}function l(u){s(),writeFileSync(r,JSON.stringify(u,null,2),{encoding:"utf8"});try{chmodSync(r,384);}catch{}}function m(u){return a()[u]}function x(u,d){let g=a();g[u]=d,l(g);}function c(){let u=a(),d=u.clientId||e.oidcClientId,g=u.oidcIssuer;if(!g){let p=u.globalEndpoint;p.includes("localhost")||p.includes("127.0.0.1")?g=p.replace(/\/graphql$/,"").replace(/\/global\/graphql$/,"/global"):g=e.oidcIssuerProd??"https://graphql.burdenoff.com/global";}return {oidcIssuer:g,clientId:d}}function f(){let u=a();if(u.productOrigin)return u.productOrigin;if(e.productOrigins)try{let d=new URL(u.workspaceEndpoint).hostname.toLowerCase();return e.productOrigins[d]}catch{return}}return {read:a,write:l,get:m,set:x,path:()=>r,dir:()=>n,resolveOIDC:c,resolveProductOrigin:f}}async function le(e){let n=`${e.oidcIssuer}/oidc/device/code`,r=new URLSearchParams({client_id:e.clientId,scope:"openid profile email offline_access"}),t=await b(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 de(e,n,r){let t=`${r.oidcIssuer}/oauth/device/token`,s=n;for(;;){await new Promise(l=>setTimeout(l,s*1e3));let i=await b(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 a=o.error;switch(a){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??a??"Unknown error"}`)}}}async function D(e,n,r,t){let i=await b(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 a=await i.text().catch(()=>"Unknown error");throw new Error(`App authentication failed (${i.status}): ${a}`)}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 L(e,n,r,t){let i=await b(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 l=await i.text().catch(()=>"Unknown error");throw new Error(`Workspace token request failed (${i.status}): ${l}`)}let o=await i.json();if(o.errors?.length)throw new Error(`Workspace token failed: ${o.errors[0]?.message??"unknown error"}`);let a=o.data?.issueWorkspaceToken;if(!a?.success||!a.token){let l=a?.error?.message??"Unknown error";throw new Error(`Workspace token failed: ${l}`)}return {token:a.token,expiresAt:a.expiresAt??"",scopes:a.scopes??[]}}async function ge(e,n){let t=await b(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 fe(e){try{let n=new URL(e);return n.protocol==="http:"||n.protocol==="https:"}catch{return false}}async function me(e){try{if(!fe(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 ke=3e4,we=3,he=1e3;function ye(e){return new Promise(n=>setTimeout(n,e))}function xe(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;let s=n.response?.status;return typeof s=="number"&&Number.isInteger(s)?`GraphQL request failed (HTTP ${s})`:"GraphQL request failed"}return e instanceof Error?e.message:String(e)}var O=class extends Error{response;constructor(n,r){super(n),this.name="GqlRequestError",this.response=r;}};function I(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Ce(e){if(!I(e))return;let n={};for(let[r,t]of Object.entries(e))(t===null||typeof t=="string"||typeof t=="number"||typeof t=="boolean")&&(n[r]=t);return n}function J(e){let n=B(e);if(!I(e)||!I(e.response))return new Error(n);let r=e.response,t=typeof r.status=="number"?r.status:void 0,s=Array.isArray(r.errors)?r.errors.flatMap(i=>{if(!I(i)||typeof i.message!="string")return [];let o=Array.isArray(i.path)?i.path.filter(l=>typeof l=="string"||typeof l=="number"):void 0,a=Ce(i.extensions);return [{message:i.message,...o?{path:o}:{},...a?{extensions:a}:{}}]}):void 0;return new O(n,{...t!==void 0?{status:t}:{},...s?{errors:s}:{}})}function A(e){let n={};return e?.accessToken&&(n.Authorization=`Bearer ${e.accessToken}`),e?.organizationId&&(n["x-org-id"]=e.organizationId),n}function _(e,n){let r=A(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 v(e,n,r,t=we){let s;for(let i=0;i<t;i++)try{let o=new AbortController,a=setTimeout(()=>o.abort(),ke);try{return await e.request({document:n,variables:r,signal:o.signal})}finally{clearTimeout(a);}}catch(o){if(s=o,o&&typeof o=="object"&&"response"in o){let a=o.response;if(a&&typeof a.status=="number"&&a.status>=400&&a.status<500)break}if(xe(o)&&i<t-1){let a=he*Math.pow(2,i);await ye(a);continue}break}throw J(s)}function G(e,n){let r=null,t=null;function s(){let c=e.read(),f=n.read();return r=new GraphQLClient(c.workspaceEndpoint),r.setHeaders(_(f,e.resolveProductOrigin())),t=new GraphQLClient(c.globalEndpoint),t.setHeaders(A(f)),{workspace:r,global:t}}async function i(){let c=n.read();if(!c)return;if(c.authMethod==="client_credentials"&&c.clientId&&c.clientSecret){let g=e.read();try{let p=await D(g.globalEndpoint,c.clientId,c.clientSecret);n.write({...c,accessToken:p.accessToken,expiresAt:Date.now()+p.expiresIn*1e3}),r=null,t=null;}catch{}return}if(!c.refreshToken)return;let f=e.read(),u=new GraphQLClient(f.globalEndpoint);u.setHeaders({Authorization:`Bearer ${c.accessToken}`});let d=`
|
|
21
|
+
mutation RefreshToken($token: String!) {
|
|
22
|
+
refreshToken(token: $token) {
|
|
23
|
+
accessToken
|
|
24
|
+
refreshToken
|
|
25
|
+
expiresIn
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
`;try{let p=(await u.request(d,{token:c.refreshToken})).refreshToken;n.write({...c,accessToken:p.accessToken,refreshToken:p.refreshToken,expiresAt:Date.now()+p.expiresIn*1e3}),r=null,t=null;}catch{}}async function o(){let c=n.read();if(!c?.accessToken||!c.workspaceId||!c.organizationId)return;let f=e.read();try{let u=await L(f.workspaceEndpoint,c.accessToken,c.workspaceId,c.organizationId);n.write({...c,workspaceToken:u.token,workspaceTokenExpiresAt:new Date(u.expiresAt).getTime()}),r=null;}catch{}}async function a(){n.isTokenExpiringSoon()&&await i(),n.read()?.workspaceToken&&n.isWorkspaceTokenExpiringSoon()&&await o();}return {workspace:{async request(c,f,u){function d(p){let h=n.read();if(!h?.accessToken||!h.workspaceToken||h.workspaceId!==p.workspaceId||e.read().workspaceEndpoint!==p.endpoint)throw new Error("Workspace or gateway changed before the request.");return h}if(u){let p=d(u.scope);if(p.expiresAt&&Date.now()>=p.expiresAt||p.workspaceTokenExpiresAt&&Date.now()>=p.workspaceTokenExpiresAt)throw new Error("TimeCampus session expired. Sign in again before sending capture.");let h=new GraphQLClient(u.scope.endpoint,{headers:_(p,e.resolveProductOrigin()),redirect:"error"});return v(h,c,f,1)}await a();let{workspace:g}=r?{workspace:r}:s();return g.setHeaders(_(n.read(),e.resolveProductOrigin())),v(g,c,f)}},global:{async request(c,f){let{global:u}=t?{global:t}:s();return u.setHeaders(A(n.read())),v(u,c,f)}},workspaceAuthOnly:{async request(c,f){let u=e.read(),d=n.read(),g=new GraphQLClient(u.workspaceEndpoint),p=A(d),h=e.resolveProductOrigin();return h&&(p.Origin=h),g.setHeaders(p),v(g,c,f)}},reset(){r=null,t=null;}}}function j(){return !!(process.stdout.isTTY&&process.stdin.isTTY)}function Y(e){if(e.format){let n=e.format.toLowerCase();if(n==="json"||n==="table"||n==="yaml")return n}return j()?"table":"json"}function N(e){console.log(JSON.stringify(e,null,2));}function Q(e,n){if(e.length===0)return;let r=e.map((i,o)=>{let a=i.length;for(let l of n){let m=l[o]??"";m.length>a&&(a=m.length);}return Math.min(a,50)}),t=r.map(i=>"-".repeat(i+2)).join("+"),s=i=>i.map((o,a)=>` ${(o??"").padEnd(r[a]??0)} `).join("|");console.log(s(e)),console.log(t);for(let i of n)console.log(s(i));}function W(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(W(o,n+2))):t.push(`${r} - ${String(o)}`);}else typeof i=="object"?(t.push(`${r}${s}:`),t.push(W(i,n+1))):t.push(`${r}${s}: ${String(i)}`);return t.join(`
|
|
29
|
+
`)}function K(e){if(typeof e!="object"||e===null){console.log(String(e));return}console.log(W(e,0));}function be(e){process.stdout.write(e.endsWith(`
|
|
30
|
+
`)?e:`${e}
|
|
31
|
+
`);}function Ee(e){console.log(`\u2713 ${e}`);}function X(e){console.error(`\u2717 ${e}`);}function Te(e){console.warn(`! ${e}`);}function ve(e){console.log(`\u2139 ${e}`);}function Ie(e){if(!e)return "-";try{return new Date(e).toLocaleString()}catch{return e}}function Ae(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 Oe(e,n){return e?e.length<=n?e:e.substring(0,n-3)+"...":"-"}function Se(e,n,r){switch(Y(e)){case "json":N(n);break;case "yaml":K(n);break;case "table":r?Q(r.headers,r.rows):N(n);break}}async function Re(e,n){return n?true:j()?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();}):(X(`${e} Use --force to skip confirmation.`),false)}var F={isInteractive:j,getFormat:Y,formatAndOutput:Se,printJson:N,printTable:Q,printYaml:K,printRaw:be,printSuccess:Ee,printError:X,printWarning:Te,printInfo:ve,formatDate:Ie,formatStatus:Ae,truncate:Oe,confirm:Re};function M(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 qe(e){return e.includes("localhost")||e.includes("127.0.0.1")?"local":e.includes("alpha")||e.includes("staging")?"staging":"prod"}function $e(e){return !!e&&typeof e.debug=="function"&&typeof e.info=="function"}function Pe(e){let n=P(e.defaults),r=$(n.dir()),t=G(n,r),s=e.output??F,i=$e(e.logger)?e.logger:M(e.logger),o=e.env??qe(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 C=class extends Error{exitCode;hint;constructor(n,r){super(n),this.name="CliUserError",this.exitCode=r?.exitCode??1,this.hint=r?.hint;}},T=class extends C{constructor(n,r){super(n,{exitCode:2,hint:r?.hint??"Run `<product> auth login` to authenticate."}),this.name="CliAuthError";}},y=class extends Error{cause;constructor(n,r){super(n),this.name="CliInternalError",this.cause=r;}};var S=class extends y{constructor(n,r){super(`Module '${n}' declares dependency on '${r}', but '${r}' is not in the module list.`),this.name="MissingDependencyError";}},R=class extends y{constructor(n){super(`Circular dependency detected among modules: ${n.join(" -> ")}`),this.name="CircularDependencyError";}};function U(e){let n=new Map;for(let o of e){if(n.has(o.id))throw new y(`Duplicate module id: '${o.id}'`);n.set(o.id,o);}for(let o of e)for(let a of o.dependsOn??[])if(!n.has(a))throw new S(o.id,a);let r=[],t=new Set,s=new Set;function i(o,a){if(!s.has(o.id)){if(t.has(o.id))throw new R([...a,o.id]);t.add(o.id);for(let l of o.dependsOn??[]){let m=n.get(l);m&&i(m,[...a,o.id]);}t.delete(o.id),s.add(o.id),r.push(o);}}for(let o of e)i(o,[]);return r}function Le(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"),t.hook("preAction",(o,a)=>{let l=t.opts().format;if(typeof l!="string")return;a.options.some(x=>x.attributeName()==="format")&&a.getOptionValue("format")===void 0&&a.setOptionValue("format",l);});let s=U(n);for(let o of s)o.register(t,e);r.helpExamples?.length&&t.addHelpText("after",`
|
|
32
|
+
Examples:
|
|
33
|
+
`+r.helpExamples.map(o=>" "+o).join(`
|
|
34
|
+
`)),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(a){_e(e,a);}}return {program:t,run:i}}function _e(e,n){if(n instanceof T&&(e.output.printError(n.message),n.hint&&e.output.printInfo(n.hint),process.exit(n.exitCode)),n instanceof C&&(e.output.printError(n.message),n.hint&&e.output.printInfo(n.hint),process.exit(n.exitCode)),n instanceof y&&(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{$ as a,pe as b,P as c,le as d,de as e,D as f,L as g,ge as h,me as i,B as j,O as k,J as l,G as m,F as n,M as o,Pe as p,C as q,T as r,y as s,S as t,R as u,U as v,Le as w};
|
package/dist/core/index.cjs
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
'use strict';var fs=require('fs'),path=require('path'),os=require('os'),graphqlRequest=require('graphql-request'),C=require('cross-fetch'),commander=require('commander');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var C__default=/*#__PURE__*/_interopDefault(C);var
|
|
1
|
+
'use strict';var fs=require('fs'),path=require('path'),os=require('os'),graphqlRequest=require('graphql-request'),C=require('cross-fetch'),commander=require('commander');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var C__default=/*#__PURE__*/_interopDefault(C);var U=300*1e3;function q(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 c=fs.readFileSync(n,"utf8");return JSON.parse(c)}catch{return null}}function s(c){r(),fs.writeFileSync(n,JSON.stringify(c,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 c=t();return c?.expiresAt?Date.now()>=c.expiresAt:false}function a(){let c=t();return c?.expiresAt?Date.now()+U>=c.expiresAt:false}function l(){let c=t();return c?.workspaceTokenExpiresAt?Date.now()>=c.workspaceTokenExpiresAt:false}function m(){let c=t();return c?.workspaceTokenExpiresAt?Date.now()+U>=c.workspaceTokenExpiresAt:false}function y(){return t()?.accessToken?!o():false}return {read:t,write:s,clear:i,isTokenExpired:o,isTokenExpiringSoon:a,isWorkspaceTokenExpired:l,isWorkspaceTokenExpiringSoon:m,isAuthenticated:y}}var ue=["workspaceEndpoint","globalEndpoint","oidcIssuer","clientId","defaultFormat","verbose","authServiceEndpoint","productOrigin"];function $(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(u){if(e.envPrefix){let g=process.env[`${e.envPrefix}_${u}`];if(g)return g}let d=process.env[u];return d&&d.length>0?d:void 0}function o(u){if(!e.envPrefix)return;let d=process.env[`${e.envPrefix}_${u}`];return d&&d.length>0?d:void 0}function a(){let u={};try{fs.existsSync(r)&&(u=JSON.parse(fs.readFileSync(r,"utf8")));}catch{}return {...t,...u,workspaceEndpoint:i("WORKSPACE_ENDPOINT")??u.workspaceEndpoint??t.workspaceEndpoint,globalEndpoint:i("GLOBAL_ENDPOINT")??u.globalEndpoint??t.globalEndpoint,oidcIssuer:i("OIDC_ISSUER")??u.oidcIssuer,clientId:i("CLIENT_ID")??u.clientId,productOrigin:o("ORIGIN")??u.productOrigin}}function l(u){s(),fs.writeFileSync(r,JSON.stringify(u,null,2),{encoding:"utf8"});try{fs.chmodSync(r,384);}catch{}}function m(u){return a()[u]}function y(u,d){let g=a();g[u]=d,l(g);}function c(){let u=a(),d=u.clientId||e.oidcClientId,g=u.oidcIssuer;if(!g){let p=u.globalEndpoint;p.includes("localhost")||p.includes("127.0.0.1")?g=p.replace(/\/graphql$/,"").replace(/\/global\/graphql$/,"/global"):g=e.oidcIssuerProd??"https://graphql.burdenoff.com/global";}return {oidcIssuer:g,clientId:d}}function f(){let u=a();if(u.productOrigin)return u.productOrigin;if(e.productOrigins)try{let d=new URL(u.workspaceEndpoint).hostname.toLowerCase();return e.productOrigins[d]}catch{return}}return {read:a,write:l,get:m,set:y,path:()=>r,dir:()=>n,resolveOIDC:c,resolveProductOrigin:f}}async function pe(e){let n=`${e.oidcIssuer}/oidc/device/code`,r=new URLSearchParams({client_id:e.clientId,scope:"openid profile email offline_access"}),t=await C__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 le(e,n,r){let t=`${r.oidcIssuer}/oauth/device/token`,s=n;for(;;){await new Promise(l=>setTimeout(l,s*1e3));let i=await C__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 a=o.error;switch(a){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??a??"Unknown error"}`)}}}async function P(e,n,r,t){let i=await C__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(!
|
|
7
|
+
`,variables:{input:{clientId:n,clientSecret:r,scopes:t}}})});if(!i.ok){let a=await i.text().catch(()=>"Unknown error");throw new Error(`App authentication failed (${i.status}): ${a}`)}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 D(e,n,r,t){let i=await C__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(!
|
|
14
|
+
`,variables:{input:{workspaceId:r,organizationId:t}}})});if(!i.ok){let l=await i.text().catch(()=>"Unknown error");throw new Error(`Workspace token request failed (${i.status}): ${l}`)}let o=await i.json();if(o.errors?.length)throw new Error(`Workspace token failed: ${o.errors[0]?.message??"unknown error"}`);let a=o.data?.issueWorkspaceToken;if(!a?.success||!a.token){let l=a?.error?.message??"Unknown error";throw new Error(`Workspace token failed: ${l}`)}return {token:a.token,expiresAt:a.expiresAt??"",scopes:a.scopes??[]}}async function de(e,n){let t=await C__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
|
|
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 ge(e){try{let n=new URL(e);return n.protocol==="http:"||n.protocol==="https:"}catch{return false}}async function fe(e){try{if(!ge(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 me=3e4,ke=3,we=1e3;function he(e){return new Promise(n=>setTimeout(n,e))}function ye(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;let s=n.response?.status;return typeof s=="number"&&Number.isInteger(s)?`GraphQL request failed (HTTP ${s})`:"GraphQL request failed"}return e instanceof Error?e.message:String(e)}var A=class extends Error{response;constructor(n,r){super(n),this.name="GqlRequestError",this.response=r;}};function v(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function xe(e){if(!v(e))return;let n={};for(let[r,t]of Object.entries(e))(t===null||typeof t=="string"||typeof t=="number"||typeof t=="boolean")&&(n[r]=t);return n}function B(e){let n=H(e);if(!v(e)||!v(e.response))return new Error(n);let r=e.response,t=typeof r.status=="number"?r.status:void 0,s=Array.isArray(r.errors)?r.errors.flatMap(i=>{if(!v(i)||typeof i.message!="string")return [];let o=Array.isArray(i.path)?i.path.filter(l=>typeof l=="string"||typeof l=="number"):void 0,a=xe(i.extensions);return [{message:i.message,...o?{path:o}:{},...a?{extensions:a}:{}}]}):void 0;return new A(n,{...t!==void 0?{status:t}:{},...s?{errors:s}:{}})}function I(e){let n={};return e?.accessToken&&(n.Authorization=`Bearer ${e.accessToken}`),e?.organizationId&&(n["x-org-id"]=e.organizationId),n}function L(e,n){let r=I(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 T(e,n,r,t=ke){let s;for(let i=0;i<t;i++)try{let o=new AbortController,a=setTimeout(()=>o.abort(),me);try{return await e.request({document:n,variables:r,signal:o.signal})}finally{clearTimeout(a);}}catch(o){if(s=o,o&&typeof o=="object"&&"response"in o){let a=o.response;if(a&&typeof a.status=="number"&&a.status>=400&&a.status<500)break}if(ye(o)&&i<t-1){let a=we*Math.pow(2,i);await he(a);continue}break}throw B(s)}function _(e,n){let r=null,t=null;function s(){let c=e.read(),f=n.read();return r=new graphqlRequest.GraphQLClient(c.workspaceEndpoint),r.setHeaders(L(f,e.resolveProductOrigin())),t=new graphqlRequest.GraphQLClient(c.globalEndpoint),t.setHeaders(I(f)),{workspace:r,global:t}}async function i(){let c=n.read();if(!c)return;if(c.authMethod==="client_credentials"&&c.clientId&&c.clientSecret){let g=e.read();try{let p=await P(g.globalEndpoint,c.clientId,c.clientSecret);n.write({...c,accessToken:p.accessToken,expiresAt:Date.now()+p.expiresIn*1e3}),r=null,t=null;}catch{}return}if(!c.refreshToken)return;let f=e.read(),u=new graphqlRequest.GraphQLClient(f.globalEndpoint);u.setHeaders({Authorization:`Bearer ${c.accessToken}`});let d=`
|
|
21
21
|
mutation RefreshToken($token: String!) {
|
|
22
22
|
refreshToken(token: $token) {
|
|
23
23
|
accessToken
|
|
@@ -25,10 +25,10 @@
|
|
|
25
25
|
expiresIn
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
|
-
`;try{let
|
|
29
|
-
`)}function
|
|
28
|
+
`;try{let p=(await u.request(d,{token:c.refreshToken})).refreshToken;n.write({...c,accessToken:p.accessToken,refreshToken:p.refreshToken,expiresAt:Date.now()+p.expiresIn*1e3}),r=null,t=null;}catch{}}async function o(){let c=n.read();if(!c?.accessToken||!c.workspaceId||!c.organizationId)return;let f=e.read();try{let u=await D(f.workspaceEndpoint,c.accessToken,c.workspaceId,c.organizationId);n.write({...c,workspaceToken:u.token,workspaceTokenExpiresAt:new Date(u.expiresAt).getTime()}),r=null;}catch{}}async function a(){n.isTokenExpiringSoon()&&await i(),n.read()?.workspaceToken&&n.isWorkspaceTokenExpiringSoon()&&await o();}return {workspace:{async request(c,f,u){function d(p){let w=n.read();if(!w?.accessToken||!w.workspaceToken||w.workspaceId!==p.workspaceId||e.read().workspaceEndpoint!==p.endpoint)throw new Error("Workspace or gateway changed before the request.");return w}if(u){let p=d(u.scope);if(p.expiresAt&&Date.now()>=p.expiresAt||p.workspaceTokenExpiresAt&&Date.now()>=p.workspaceTokenExpiresAt)throw new Error("TimeCampus session expired. Sign in again before sending capture.");let w=new graphqlRequest.GraphQLClient(u.scope.endpoint,{headers:L(p,e.resolveProductOrigin()),redirect:"error"});return T(w,c,f,1)}await a();let{workspace:g}=r?{workspace:r}:s();return g.setHeaders(L(n.read(),e.resolveProductOrigin())),T(g,c,f)}},global:{async request(c,f){let{global:u}=t?{global:t}:s();return u.setHeaders(I(n.read())),T(u,c,f)}},workspaceAuthOnly:{async request(c,f){let u=e.read(),d=n.read(),g=new graphqlRequest.GraphQLClient(u.workspaceEndpoint),p=I(d),w=e.resolveProductOrigin();return w&&(p.Origin=w),g.setHeaders(p),T(g,c,f)}},reset(){r=null,t=null;}}}function W(){return !!(process.stdout.isTTY&&process.stdin.isTTY)}function J(e){if(e.format){let n=e.format.toLowerCase();if(n==="json"||n==="table"||n==="yaml")return n}return W()?"table":"json"}function G(e){console.log(JSON.stringify(e,null,2));}function Y(e,n){if(e.length===0)return;let r=e.map((i,o)=>{let a=i.length;for(let l of n){let m=l[o]??"";m.length>a&&(a=m.length);}return Math.min(a,50)}),t=r.map(i=>"-".repeat(i+2)).join("+"),s=i=>i.map((o,a)=>` ${(o??"").padEnd(r[a]??0)} `).join("|");console.log(s(e)),console.log(t);for(let i of n)console.log(s(i));}function N(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(N(o,n+2))):t.push(`${r} - ${String(o)}`);}else typeof i=="object"?(t.push(`${r}${s}:`),t.push(N(i,n+1))):t.push(`${r}${s}: ${String(i)}`);return t.join(`
|
|
29
|
+
`)}function Q(e){if(typeof e!="object"||e===null){console.log(String(e));return}console.log(N(e,0));}function Ce(e){process.stdout.write(e.endsWith(`
|
|
30
30
|
`)?e:`${e}
|
|
31
|
-
`);}function be(e){console.log(`\u2713 ${e}`);}function
|
|
31
|
+
`);}function be(e){console.log(`\u2713 ${e}`);}function K(e){console.error(`\u2717 ${e}`);}function Ee(e){console.warn(`! ${e}`);}function Te(e){console.log(`\u2139 ${e}`);}function ve(e){if(!e)return "-";try{return new Date(e).toLocaleString()}catch{return e}}function Ie(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 Ae(e,n){return e?e.length<=n?e:e.substring(0,n-3)+"...":"-"}function Oe(e,n,r){switch(J(e)){case "json":G(n);break;case "yaml":Q(n);break;case "table":r?Y(r.headers,r.rows):G(n);break}}async function Se(e,n){return n?true:W()?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 j={isInteractive:W,getFormat:J,formatAndOutput:Oe,printJson:G,printTable:Y,printYaml:Q,printRaw:Ce,printSuccess:be,printError:K,printWarning:Ee,printInfo:Te,formatDate:ve,formatStatus:Ie,truncate:Ae,confirm:Se};function F(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 Re(e){return e.includes("localhost")||e.includes("127.0.0.1")?"local":e.includes("alpha")||e.includes("staging")?"staging":"prod"}function qe(e){return !!e&&typeof e.debug=="function"&&typeof e.info=="function"}function $e(e){let n=$(e.defaults),r=q(n.dir()),t=_(n,r),s=e.output??j,i=qe(e.logger)?e.logger:F(e.logger),o=e.env??Re(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 x=class extends Error{exitCode;hint;constructor(n,r){super(n),this.name="CliUserError",this.exitCode=r?.exitCode??1,this.hint=r?.hint;}},E=class extends x{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 O=class extends h{constructor(n,r){super(`Module '${n}' declares dependency on '${r}', but '${r}' is not in the module list.`),this.name="MissingDependencyError";}},S=class extends h{constructor(n){super(`Circular dependency detected among modules: ${n.join(" -> ")}`),this.name="CircularDependencyError";}};function M(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 a of o.dependsOn??[])if(!n.has(a))throw new O(o.id,a);let r=[],t=new Set,s=new Set;function i(o,a){if(!s.has(o.id)){if(t.has(o.id))throw new S([...a,o.id]);t.add(o.id);for(let l of o.dependsOn??[]){let m=n.get(l);m&&i(m,[...a,o.id]);}t.delete(o.id),s.add(o.id),r.push(o);}}for(let o of e)i(o,[]);return r}function De(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"),t.hook("preAction",(o,a)=>{let l=t.opts().format;if(typeof l!="string")return;a.options.some(y=>y.attributeName()==="format")&&a.getOptionValue("format")===void 0&&a.setOptionValue("format",l);});let s=M(n);for(let o of s)o.register(t,e);r.helpExamples?.length&&t.addHelpText("after",`
|
|
32
32
|
Examples:
|
|
33
33
|
`+r.helpExamples.map(o=>" "+o).join(`
|
|
34
|
-
`)),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
|
|
34
|
+
`)),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(a){Le(e,a);}}return {program:t,run:i}}function Le(e,n){if(n instanceof E&&(e.output.printError(n.message),n.hint&&e.output.printInfo(n.hint),process.exit(n.exitCode)),n instanceof x&&(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);}exports.CircularDependencyError=S;exports.CliAuthError=E;exports.CliInternalError=h;exports.CliUserError=x;exports.GqlRequestError=A;exports.KNOWN_CONFIG_KEYS=ue;exports.MissingDependencyError=O;exports.buildContext=$e;exports.clientCredentialsFlow=P;exports.createAuthStore=q;exports.createConfigStore=$;exports.createGqlClients=_;exports.createLogger=F;exports.createProgram=De;exports.defaultOutputAdapter=j;exports.extractGqlErrorMessage=H;exports.fetchWorkspaces=de;exports.issueWorkspaceToken=D;exports.openBrowser=fe;exports.pollForToken=le;exports.sortModules=M;exports.startDeviceCodeFlow=pe;exports.toGqlRequestError=B;
|
package/dist/core/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as CLIContext, C as CliModule } from '../module-
|
|
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, i as GqlRequestError, j as GqlRequestErrorEntry, K as KNOWN_CONFIG_KEYS, L as Logger, k as LoggerOptions, M as MissingDependencyError, O as OutputAdapter, l as OutputFormat, P as ProductDefaults, S as StoredAuth, T as TableConfig, m as buildContext, n as createAuthStore, o as createConfigStore, p as createGqlClients, q as createLogger, r as defaultOutputAdapter, s as extractGqlErrorMessage, t as sortModules, u as toGqlRequestError } from '../module-
|
|
1
|
+
import { a as CLIContext, C as CliModule } from '../module-BNVKV_pI.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, i as GqlRequestError, j as GqlRequestErrorEntry, K as KNOWN_CONFIG_KEYS, L as Logger, k as LoggerOptions, M as MissingDependencyError, O as OutputAdapter, l as OutputFormat, P as ProductDefaults, S as StoredAuth, T as TableConfig, m as buildContext, n as createAuthStore, o as createConfigStore, p as createGqlClients, q as createLogger, r as defaultOutputAdapter, s as extractGqlErrorMessage, t as sortModules, u as toGqlRequestError } from '../module-BNVKV_pI.cjs';
|
|
3
3
|
import { Command } from 'commander';
|
|
4
4
|
import 'graphql-request';
|
|
5
5
|
|
package/dist/core/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as CLIContext, C as CliModule } from '../module-
|
|
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, i as GqlRequestError, j as GqlRequestErrorEntry, K as KNOWN_CONFIG_KEYS, L as Logger, k as LoggerOptions, M as MissingDependencyError, O as OutputAdapter, l as OutputFormat, P as ProductDefaults, S as StoredAuth, T as TableConfig, m as buildContext, n as createAuthStore, o as createConfigStore, p as createGqlClients, q as createLogger, r as defaultOutputAdapter, s as extractGqlErrorMessage, t as sortModules, u as toGqlRequestError } from '../module-
|
|
1
|
+
import { a as CLIContext, C as CliModule } from '../module-BNVKV_pI.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, i as GqlRequestError, j as GqlRequestErrorEntry, K as KNOWN_CONFIG_KEYS, L as Logger, k as LoggerOptions, M as MissingDependencyError, O as OutputAdapter, l as OutputFormat, P as ProductDefaults, S as StoredAuth, T as TableConfig, m as buildContext, n as createAuthStore, o as createConfigStore, p as createGqlClients, q as createLogger, r as defaultOutputAdapter, s as extractGqlErrorMessage, t as sortModules, u as toGqlRequestError } from '../module-BNVKV_pI.js';
|
|
3
3
|
import { Command } from 'commander';
|
|
4
4
|
import 'graphql-request';
|
|
5
5
|
|
package/dist/core/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{u as CircularDependencyError,r as CliAuthError,s as CliInternalError,q as CliUserError,k as GqlRequestError,b as KNOWN_CONFIG_KEYS,t as MissingDependencyError,p as buildContext,f as clientCredentialsFlow,a as createAuthStore,c as createConfigStore,m as createGqlClients,o as createLogger,w as createProgram,n as defaultOutputAdapter,j as extractGqlErrorMessage,h as fetchWorkspaces,g as issueWorkspaceToken,i as openBrowser,e as pollForToken,v as sortModules,d as startDeviceCodeFlow,l as toGqlRequestError}from'../chunk-
|
|
1
|
+
export{u as CircularDependencyError,r as CliAuthError,s as CliInternalError,q as CliUserError,k as GqlRequestError,b as KNOWN_CONFIG_KEYS,t as MissingDependencyError,p as buildContext,f as clientCredentialsFlow,a as createAuthStore,c as createConfigStore,m as createGqlClients,o as createLogger,w as createProgram,n as defaultOutputAdapter,j as extractGqlErrorMessage,h as fetchWorkspaces,g as issueWorkspaceToken,i as openBrowser,e as pollForToken,v as sortModules,d as startDeviceCodeFlow,l as toGqlRequestError}from'../chunk-ZT6KOG7N.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'),
|
|
1
|
+
'use strict';var fs=require('fs'),path=require('path'),os=require('os'),graphqlRequest=require('graphql-request'),C=require('cross-fetch'),commander=require('commander');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var C__default=/*#__PURE__*/_interopDefault(C);var U=300*1e3;function q(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 c=fs.readFileSync(n,"utf8");return JSON.parse(c)}catch{return null}}function s(c){r(),fs.writeFileSync(n,JSON.stringify(c,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 c=t();return c?.expiresAt?Date.now()>=c.expiresAt:false}function a(){let c=t();return c?.expiresAt?Date.now()+U>=c.expiresAt:false}function l(){let c=t();return c?.workspaceTokenExpiresAt?Date.now()>=c.workspaceTokenExpiresAt:false}function m(){let c=t();return c?.workspaceTokenExpiresAt?Date.now()+U>=c.workspaceTokenExpiresAt:false}function y(){return t()?.accessToken?!o():false}return {read:t,write:s,clear:i,isTokenExpired:o,isTokenExpiringSoon:a,isWorkspaceTokenExpired:l,isWorkspaceTokenExpiringSoon:m,isAuthenticated:y}}var ue=["workspaceEndpoint","globalEndpoint","oidcIssuer","clientId","defaultFormat","verbose","authServiceEndpoint","productOrigin"];function $(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(u){if(e.envPrefix){let g=process.env[`${e.envPrefix}_${u}`];if(g)return g}let d=process.env[u];return d&&d.length>0?d:void 0}function o(u){if(!e.envPrefix)return;let d=process.env[`${e.envPrefix}_${u}`];return d&&d.length>0?d:void 0}function a(){let u={};try{fs.existsSync(r)&&(u=JSON.parse(fs.readFileSync(r,"utf8")));}catch{}return {...t,...u,workspaceEndpoint:i("WORKSPACE_ENDPOINT")??u.workspaceEndpoint??t.workspaceEndpoint,globalEndpoint:i("GLOBAL_ENDPOINT")??u.globalEndpoint??t.globalEndpoint,oidcIssuer:i("OIDC_ISSUER")??u.oidcIssuer,clientId:i("CLIENT_ID")??u.clientId,productOrigin:o("ORIGIN")??u.productOrigin}}function l(u){s(),fs.writeFileSync(r,JSON.stringify(u,null,2),{encoding:"utf8"});try{fs.chmodSync(r,384);}catch{}}function m(u){return a()[u]}function y(u,d){let g=a();g[u]=d,l(g);}function c(){let u=a(),d=u.clientId||e.oidcClientId,g=u.oidcIssuer;if(!g){let p=u.globalEndpoint;p.includes("localhost")||p.includes("127.0.0.1")?g=p.replace(/\/graphql$/,"").replace(/\/global\/graphql$/,"/global"):g=e.oidcIssuerProd??"https://graphql.burdenoff.com/global";}return {oidcIssuer:g,clientId:d}}function f(){let u=a();if(u.productOrigin)return u.productOrigin;if(e.productOrigins)try{let d=new URL(u.workspaceEndpoint).hostname.toLowerCase();return e.productOrigins[d]}catch{return}}return {read:a,write:l,get:m,set:y,path:()=>r,dir:()=>n,resolveOIDC:c,resolveProductOrigin:f}}async function pe(e){let n=`${e.oidcIssuer}/oidc/device/code`,r=new URLSearchParams({client_id:e.clientId,scope:"openid profile email offline_access"}),t=await C__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 le(e,n,r){let t=`${r.oidcIssuer}/oauth/device/token`,s=n;for(;;){await new Promise(l=>setTimeout(l,s*1e3));let i=await C__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 a=o.error;switch(a){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??a??"Unknown error"}`)}}}async function P(e,n,r,t){let i=await C__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(!
|
|
7
|
+
`,variables:{input:{clientId:n,clientSecret:r,scopes:t}}})});if(!i.ok){let a=await i.text().catch(()=>"Unknown error");throw new Error(`App authentication failed (${i.status}): ${a}`)}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 D(e,n,r,t){let i=await C__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(!
|
|
14
|
+
`,variables:{input:{workspaceId:r,organizationId:t}}})});if(!i.ok){let l=await i.text().catch(()=>"Unknown error");throw new Error(`Workspace token request failed (${i.status}): ${l}`)}let o=await i.json();if(o.errors?.length)throw new Error(`Workspace token failed: ${o.errors[0]?.message??"unknown error"}`);let a=o.data?.issueWorkspaceToken;if(!a?.success||!a.token){let l=a?.error?.message??"Unknown error";throw new Error(`Workspace token failed: ${l}`)}return {token:a.token,expiresAt:a.expiresAt??"",scopes:a.scopes??[]}}async function de(e,n){let t=await C__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
|
|
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 ge(e){try{let n=new URL(e);return n.protocol==="http:"||n.protocol==="https:"}catch{return false}}async function fe(e){try{if(!ge(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 me=3e4,ke=3,we=1e3;function he(e){return new Promise(n=>setTimeout(n,e))}function ye(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;let s=n.response?.status;return typeof s=="number"&&Number.isInteger(s)?`GraphQL request failed (HTTP ${s})`:"GraphQL request failed"}return e instanceof Error?e.message:String(e)}var A=class extends Error{response;constructor(n,r){super(n),this.name="GqlRequestError",this.response=r;}};function v(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function xe(e){if(!v(e))return;let n={};for(let[r,t]of Object.entries(e))(t===null||typeof t=="string"||typeof t=="number"||typeof t=="boolean")&&(n[r]=t);return n}function B(e){let n=H(e);if(!v(e)||!v(e.response))return new Error(n);let r=e.response,t=typeof r.status=="number"?r.status:void 0,s=Array.isArray(r.errors)?r.errors.flatMap(i=>{if(!v(i)||typeof i.message!="string")return [];let o=Array.isArray(i.path)?i.path.filter(l=>typeof l=="string"||typeof l=="number"):void 0,a=xe(i.extensions);return [{message:i.message,...o?{path:o}:{},...a?{extensions:a}:{}}]}):void 0;return new A(n,{...t!==void 0?{status:t}:{},...s?{errors:s}:{}})}function I(e){let n={};return e?.accessToken&&(n.Authorization=`Bearer ${e.accessToken}`),e?.organizationId&&(n["x-org-id"]=e.organizationId),n}function L(e,n){let r=I(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 T(e,n,r,t=ke){let s;for(let i=0;i<t;i++)try{let o=new AbortController,a=setTimeout(()=>o.abort(),me);try{return await e.request({document:n,variables:r,signal:o.signal})}finally{clearTimeout(a);}}catch(o){if(s=o,o&&typeof o=="object"&&"response"in o){let a=o.response;if(a&&typeof a.status=="number"&&a.status>=400&&a.status<500)break}if(ye(o)&&i<t-1){let a=we*Math.pow(2,i);await he(a);continue}break}throw B(s)}function _(e,n){let r=null,t=null;function s(){let c=e.read(),f=n.read();return r=new graphqlRequest.GraphQLClient(c.workspaceEndpoint),r.setHeaders(L(f,e.resolveProductOrigin())),t=new graphqlRequest.GraphQLClient(c.globalEndpoint),t.setHeaders(I(f)),{workspace:r,global:t}}async function i(){let c=n.read();if(!c)return;if(c.authMethod==="client_credentials"&&c.clientId&&c.clientSecret){let g=e.read();try{let p=await P(g.globalEndpoint,c.clientId,c.clientSecret);n.write({...c,accessToken:p.accessToken,expiresAt:Date.now()+p.expiresIn*1e3}),r=null,t=null;}catch{}return}if(!c.refreshToken)return;let f=e.read(),u=new graphqlRequest.GraphQLClient(f.globalEndpoint);u.setHeaders({Authorization:`Bearer ${c.accessToken}`});let d=`
|
|
21
21
|
mutation RefreshToken($token: String!) {
|
|
22
22
|
refreshToken(token: $token) {
|
|
23
23
|
accessToken
|
|
@@ -25,10 +25,10 @@
|
|
|
25
25
|
expiresIn
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
|
-
`;try{let
|
|
29
|
-
`)}function
|
|
28
|
+
`;try{let p=(await u.request(d,{token:c.refreshToken})).refreshToken;n.write({...c,accessToken:p.accessToken,refreshToken:p.refreshToken,expiresAt:Date.now()+p.expiresIn*1e3}),r=null,t=null;}catch{}}async function o(){let c=n.read();if(!c?.accessToken||!c.workspaceId||!c.organizationId)return;let f=e.read();try{let u=await D(f.workspaceEndpoint,c.accessToken,c.workspaceId,c.organizationId);n.write({...c,workspaceToken:u.token,workspaceTokenExpiresAt:new Date(u.expiresAt).getTime()}),r=null;}catch{}}async function a(){n.isTokenExpiringSoon()&&await i(),n.read()?.workspaceToken&&n.isWorkspaceTokenExpiringSoon()&&await o();}return {workspace:{async request(c,f,u){function d(p){let w=n.read();if(!w?.accessToken||!w.workspaceToken||w.workspaceId!==p.workspaceId||e.read().workspaceEndpoint!==p.endpoint)throw new Error("Workspace or gateway changed before the request.");return w}if(u){let p=d(u.scope);if(p.expiresAt&&Date.now()>=p.expiresAt||p.workspaceTokenExpiresAt&&Date.now()>=p.workspaceTokenExpiresAt)throw new Error("TimeCampus session expired. Sign in again before sending capture.");let w=new graphqlRequest.GraphQLClient(u.scope.endpoint,{headers:L(p,e.resolveProductOrigin()),redirect:"error"});return T(w,c,f,1)}await a();let{workspace:g}=r?{workspace:r}:s();return g.setHeaders(L(n.read(),e.resolveProductOrigin())),T(g,c,f)}},global:{async request(c,f){let{global:u}=t?{global:t}:s();return u.setHeaders(I(n.read())),T(u,c,f)}},workspaceAuthOnly:{async request(c,f){let u=e.read(),d=n.read(),g=new graphqlRequest.GraphQLClient(u.workspaceEndpoint),p=I(d),w=e.resolveProductOrigin();return w&&(p.Origin=w),g.setHeaders(p),T(g,c,f)}},reset(){r=null,t=null;}}}function W(){return !!(process.stdout.isTTY&&process.stdin.isTTY)}function J(e){if(e.format){let n=e.format.toLowerCase();if(n==="json"||n==="table"||n==="yaml")return n}return W()?"table":"json"}function G(e){console.log(JSON.stringify(e,null,2));}function Y(e,n){if(e.length===0)return;let r=e.map((i,o)=>{let a=i.length;for(let l of n){let m=l[o]??"";m.length>a&&(a=m.length);}return Math.min(a,50)}),t=r.map(i=>"-".repeat(i+2)).join("+"),s=i=>i.map((o,a)=>` ${(o??"").padEnd(r[a]??0)} `).join("|");console.log(s(e)),console.log(t);for(let i of n)console.log(s(i));}function N(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(N(o,n+2))):t.push(`${r} - ${String(o)}`);}else typeof i=="object"?(t.push(`${r}${s}:`),t.push(N(i,n+1))):t.push(`${r}${s}: ${String(i)}`);return t.join(`
|
|
29
|
+
`)}function Q(e){if(typeof e!="object"||e===null){console.log(String(e));return}console.log(N(e,0));}function Ce(e){process.stdout.write(e.endsWith(`
|
|
30
30
|
`)?e:`${e}
|
|
31
|
-
`);}function be(e){console.log(`\u2713 ${e}`);}function
|
|
31
|
+
`);}function be(e){console.log(`\u2713 ${e}`);}function K(e){console.error(`\u2717 ${e}`);}function Ee(e){console.warn(`! ${e}`);}function Te(e){console.log(`\u2139 ${e}`);}function ve(e){if(!e)return "-";try{return new Date(e).toLocaleString()}catch{return e}}function Ie(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 Ae(e,n){return e?e.length<=n?e:e.substring(0,n-3)+"...":"-"}function Oe(e,n,r){switch(J(e)){case "json":G(n);break;case "yaml":Q(n);break;case "table":r?Y(r.headers,r.rows):G(n);break}}async function Se(e,n){return n?true:W()?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 j={isInteractive:W,getFormat:J,formatAndOutput:Oe,printJson:G,printTable:Y,printYaml:Q,printRaw:Ce,printSuccess:be,printError:K,printWarning:Ee,printInfo:Te,formatDate:ve,formatStatus:Ie,truncate:Ae,confirm:Se};function F(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 Re(e){return e.includes("localhost")||e.includes("127.0.0.1")?"local":e.includes("alpha")||e.includes("staging")?"staging":"prod"}function qe(e){return !!e&&typeof e.debug=="function"&&typeof e.info=="function"}function $e(e){let n=$(e.defaults),r=q(n.dir()),t=_(n,r),s=e.output??j,i=qe(e.logger)?e.logger:F(e.logger),o=e.env??Re(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 x=class extends Error{exitCode;hint;constructor(n,r){super(n),this.name="CliUserError",this.exitCode=r?.exitCode??1,this.hint=r?.hint;}},E=class extends x{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 O=class extends h{constructor(n,r){super(`Module '${n}' declares dependency on '${r}', but '${r}' is not in the module list.`),this.name="MissingDependencyError";}},S=class extends h{constructor(n){super(`Circular dependency detected among modules: ${n.join(" -> ")}`),this.name="CircularDependencyError";}};function M(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 a of o.dependsOn??[])if(!n.has(a))throw new O(o.id,a);let r=[],t=new Set,s=new Set;function i(o,a){if(!s.has(o.id)){if(t.has(o.id))throw new S([...a,o.id]);t.add(o.id);for(let l of o.dependsOn??[]){let m=n.get(l);m&&i(m,[...a,o.id]);}t.delete(o.id),s.add(o.id),r.push(o);}}for(let o of e)i(o,[]);return r}function De(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"),t.hook("preAction",(o,a)=>{let l=t.opts().format;if(typeof l!="string")return;a.options.some(y=>y.attributeName()==="format")&&a.getOptionValue("format")===void 0&&a.setOptionValue("format",l);});let s=M(n);for(let o of s)o.register(t,e);r.helpExamples?.length&&t.addHelpText("after",`
|
|
32
32
|
Examples:
|
|
33
33
|
`+r.helpExamples.map(o=>" "+o).join(`
|
|
34
|
-
`)),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
|
|
34
|
+
`)),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(a){Le(e,a);}}return {program:t,run:i}}function Le(e,n){if(n instanceof E&&(e.output.printError(n.message),n.hint&&e.output.printInfo(n.hint),process.exit(n.exitCode)),n instanceof x&&(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);}exports.CircularDependencyError=S;exports.CliAuthError=E;exports.CliInternalError=h;exports.CliUserError=x;exports.GqlRequestError=A;exports.KNOWN_CONFIG_KEYS=ue;exports.MissingDependencyError=O;exports.buildContext=$e;exports.clientCredentialsFlow=P;exports.createAuthStore=q;exports.createConfigStore=$;exports.createGqlClients=_;exports.createLogger=F;exports.createProgram=De;exports.defaultOutputAdapter=j;exports.extractGqlErrorMessage=H;exports.fetchWorkspaces=de;exports.issueWorkspaceToken=D;exports.openBrowser=fe;exports.pollForToken=le;exports.sortModules=M;exports.startDeviceCodeFlow=pe;exports.toGqlRequestError=B;
|
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, i as GqlRequestError, j as GqlRequestErrorEntry, K as KNOWN_CONFIG_KEYS, L as Logger, k as LoggerOptions, M as MissingDependencyError, O as OutputAdapter, l as OutputFormat, P as ProductDefaults, S as StoredAuth, T as TableConfig, m as buildContext, n as createAuthStore, o as createConfigStore, p as createGqlClients, q as createLogger, r as defaultOutputAdapter, s as extractGqlErrorMessage, t as sortModules, u as toGqlRequestError } from './module-
|
|
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, i as GqlRequestError, j as GqlRequestErrorEntry, K as KNOWN_CONFIG_KEYS, L as Logger, k as LoggerOptions, M as MissingDependencyError, O as OutputAdapter, l as OutputFormat, P as ProductDefaults, S as StoredAuth, T as TableConfig, m as buildContext, n as createAuthStore, o as createConfigStore, p as createGqlClients, q as createLogger, r as defaultOutputAdapter, s as extractGqlErrorMessage, t as sortModules, u as toGqlRequestError } from './module-BNVKV_pI.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, i as GqlRequestError, j as GqlRequestErrorEntry, K as KNOWN_CONFIG_KEYS, L as Logger, k as LoggerOptions, M as MissingDependencyError, O as OutputAdapter, l as OutputFormat, P as ProductDefaults, S as StoredAuth, T as TableConfig, m as buildContext, n as createAuthStore, o as createConfigStore, p as createGqlClients, q as createLogger, r as defaultOutputAdapter, s as extractGqlErrorMessage, t as sortModules, u as toGqlRequestError } from './module-
|
|
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, i as GqlRequestError, j as GqlRequestErrorEntry, K as KNOWN_CONFIG_KEYS, L as Logger, k as LoggerOptions, M as MissingDependencyError, O as OutputAdapter, l as OutputFormat, P as ProductDefaults, S as StoredAuth, T as TableConfig, m as buildContext, n as createAuthStore, o as createConfigStore, p as createGqlClients, q as createLogger, r as defaultOutputAdapter, s as extractGqlErrorMessage, t as sortModules, u as toGqlRequestError } from './module-BNVKV_pI.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{u as CircularDependencyError,r as CliAuthError,s as CliInternalError,q as CliUserError,k as GqlRequestError,b as KNOWN_CONFIG_KEYS,t as MissingDependencyError,p as buildContext,f as clientCredentialsFlow,a as createAuthStore,c as createConfigStore,m as createGqlClients,o as createLogger,w as createProgram,n as defaultOutputAdapter,j as extractGqlErrorMessage,h as fetchWorkspaces,g as issueWorkspaceToken,i as openBrowser,e as pollForToken,v as sortModules,d as startDeviceCodeFlow,l as toGqlRequestError}from'./chunk-
|
|
1
|
+
export{u as CircularDependencyError,r as CliAuthError,s as CliInternalError,q as CliUserError,k as GqlRequestError,b as KNOWN_CONFIG_KEYS,t as MissingDependencyError,p as buildContext,f as clientCredentialsFlow,a as createAuthStore,c as createConfigStore,m as createGqlClients,o as createLogger,w as createProgram,n as defaultOutputAdapter,j as extractGqlErrorMessage,h as fetchWorkspaces,g as issueWorkspaceToken,i as openBrowser,e as pollForToken,v as sortModules,d as startDeviceCodeFlow,l as toGqlRequestError}from'./chunk-ZT6KOG7N.js';
|
|
@@ -63,8 +63,18 @@ declare function createConfigStore(defaults: ProductDefaults): ConfigStore;
|
|
|
63
63
|
interface GqlClient {
|
|
64
64
|
request<T>(document: RequestDocument, variables?: Variables): Promise<T>;
|
|
65
65
|
}
|
|
66
|
+
interface WorkspaceGqlClient extends GqlClient {
|
|
67
|
+
request<T>(document: RequestDocument, variables?: Variables, options?: WorkspaceRequestOptions): Promise<T>;
|
|
68
|
+
}
|
|
69
|
+
interface WorkspaceRequestOptions {
|
|
70
|
+
scope: {
|
|
71
|
+
workspaceId: string;
|
|
72
|
+
endpoint: string;
|
|
73
|
+
};
|
|
74
|
+
retry: false;
|
|
75
|
+
}
|
|
66
76
|
interface GqlClients {
|
|
67
|
-
workspace:
|
|
77
|
+
workspace: WorkspaceGqlClient;
|
|
68
78
|
global: GqlClient;
|
|
69
79
|
workspaceAuthOnly: GqlClient;
|
|
70
80
|
reset(): void;
|
|
@@ -63,8 +63,18 @@ declare function createConfigStore(defaults: ProductDefaults): ConfigStore;
|
|
|
63
63
|
interface GqlClient {
|
|
64
64
|
request<T>(document: RequestDocument, variables?: Variables): Promise<T>;
|
|
65
65
|
}
|
|
66
|
+
interface WorkspaceGqlClient extends GqlClient {
|
|
67
|
+
request<T>(document: RequestDocument, variables?: Variables, options?: WorkspaceRequestOptions): Promise<T>;
|
|
68
|
+
}
|
|
69
|
+
interface WorkspaceRequestOptions {
|
|
70
|
+
scope: {
|
|
71
|
+
workspaceId: string;
|
|
72
|
+
endpoint: string;
|
|
73
|
+
};
|
|
74
|
+
retry: false;
|
|
75
|
+
}
|
|
66
76
|
interface GqlClients {
|
|
67
|
-
workspace:
|
|
77
|
+
workspace: WorkspaceGqlClient;
|
|
68
78
|
global: GqlClient;
|
|
69
79
|
workspaceAuthOnly: GqlClient;
|
|
70
80
|
reset(): void;
|