@burdenoff/cli-sdk 2026.1108.1 → 2026.1110.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-N5KCAJXG.js → chunk-6HSWVWQW.js} +3 -3
- package/dist/chunk-MT2F54AC.js +34 -0
- package/dist/chunk-WTNQ5PEC.js +1 -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-BwJmqefL.d.ts → module-CLaW1ycq.d.cts} +17 -1
- package/dist/{module-BwJmqefL.d.cts → module-CLaW1ycq.d.ts} +17 -1
- package/dist/modules/adaptercloud/index.cjs +8 -8
- package/dist/modules/adaptercloud/index.d.cts +1 -1
- package/dist/modules/adaptercloud/index.d.ts +1 -1
- package/dist/modules/adaptercloud/index.js +2 -2
- package/dist/modules/artistrybase/index.cjs +10 -10
- package/dist/modules/artistrybase/index.d.cts +1 -1
- package/dist/modules/artistrybase/index.d.ts +1 -1
- package/dist/modules/artistrybase/index.js +2 -2
- package/dist/modules/assethandler/index.cjs +6 -6
- package/dist/modules/assethandler/index.d.cts +1 -1
- package/dist/modules/assethandler/index.d.ts +1 -1
- package/dist/modules/assethandler/index.js +2 -2
- package/dist/modules/atheletebridge/index.cjs +8 -8
- package/dist/modules/atheletebridge/index.d.cts +1 -1
- package/dist/modules/atheletebridge/index.d.ts +1 -1
- package/dist/modules/atheletebridge/index.js +2 -2
- package/dist/modules/auth/index.cjs +5 -5
- package/dist/modules/auth/index.d.cts +1 -1
- package/dist/modules/auth/index.d.ts +1 -1
- package/dist/modules/auth/index.js +4 -4
- package/dist/modules/billing/index.cjs +5 -5
- package/dist/modules/billing/index.d.cts +1 -1
- package/dist/modules/billing/index.d.ts +1 -1
- package/dist/modules/billing/index.js +2 -2
- package/dist/modules/brainyrich/index.cjs +10 -10
- package/dist/modules/brainyrich/index.d.cts +1 -1
- package/dist/modules/brainyrich/index.d.ts +1 -1
- package/dist/modules/brainyrich/index.js +2 -2
- package/dist/modules/buildmyiq/index.cjs +6 -6
- package/dist/modules/buildmyiq/index.d.cts +1 -1
- package/dist/modules/buildmyiq/index.d.ts +1 -1
- package/dist/modules/buildmyiq/index.js +2 -2
- package/dist/modules/channels/index.cjs +11 -11
- package/dist/modules/channels/index.d.cts +1 -1
- package/dist/modules/channels/index.d.ts +1 -1
- package/dist/modules/channels/index.js +2 -2
- package/dist/modules/collabkin/index.cjs +7 -7
- package/dist/modules/collabkin/index.d.cts +1 -1
- package/dist/modules/collabkin/index.d.ts +1 -1
- package/dist/modules/collabkin/index.js +2 -2
- package/dist/modules/comradecircle/index.cjs +8 -8
- package/dist/modules/comradecircle/index.d.cts +1 -1
- package/dist/modules/comradecircle/index.d.ts +1 -1
- package/dist/modules/comradecircle/index.js +2 -2
- package/dist/modules/conversations/index.cjs +9 -9
- package/dist/modules/conversations/index.d.cts +1 -1
- package/dist/modules/conversations/index.d.ts +1 -1
- package/dist/modules/conversations/index.js +2 -2
- package/dist/modules/coolandlovely/index.cjs +7 -7
- package/dist/modules/coolandlovely/index.d.cts +1 -1
- package/dist/modules/coolandlovely/index.d.ts +1 -1
- package/dist/modules/coolandlovely/index.js +2 -2
- package/dist/modules/cosmicintersection/index.cjs +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 +2 -2
- package/dist/modules/crewfoundry/index.cjs +19 -19
- package/dist/modules/crewfoundry/index.d.cts +1 -1
- package/dist/modules/crewfoundry/index.d.ts +1 -1
- package/dist/modules/crewfoundry/index.js +2 -2
- package/dist/modules/devportal/index.cjs +5 -5
- package/dist/modules/devportal/index.d.cts +1 -1
- package/dist/modules/devportal/index.d.ts +1 -1
- package/dist/modules/devportal/index.js +2 -2
- package/dist/modules/ecoimpacthub/index.cjs +7 -7
- package/dist/modules/ecoimpacthub/index.d.cts +1 -1
- package/dist/modules/ecoimpacthub/index.d.ts +1 -1
- package/dist/modules/ecoimpacthub/index.js +2 -2
- package/dist/modules/eventfullymanaged/index.cjs +24 -24
- package/dist/modules/eventfullymanaged/index.d.cts +1 -1
- package/dist/modules/eventfullymanaged/index.d.ts +1 -1
- package/dist/modules/eventfullymanaged/index.js +2 -2
- package/dist/modules/export/index.cjs +9 -9
- package/dist/modules/export/index.d.cts +1 -1
- package/dist/modules/export/index.d.ts +1 -1
- package/dist/modules/export/index.js +2 -2
- package/dist/modules/files/index.cjs +4 -4
- package/dist/modules/files/index.d.cts +1 -1
- package/dist/modules/files/index.d.ts +1 -1
- package/dist/modules/files/index.js +2 -2
- package/dist/modules/fluidgrids/index.cjs +8 -8
- package/dist/modules/fluidgrids/index.d.cts +1 -1
- package/dist/modules/fluidgrids/index.d.ts +1 -1
- package/dist/modules/fluidgrids/index.js +3 -3
- package/dist/modules/ggnomad/index.cjs +7 -7
- package/dist/modules/ggnomad/index.d.cts +1 -1
- package/dist/modules/ggnomad/index.d.ts +1 -1
- package/dist/modules/ggnomad/index.js +2 -2
- package/dist/modules/govcitizenhub/index.cjs +4 -4
- package/dist/modules/govcitizenhub/index.d.cts +1 -1
- package/dist/modules/govcitizenhub/index.d.ts +1 -1
- package/dist/modules/govcitizenhub/index.js +2 -2
- package/dist/modules/groups/index.cjs +8 -8
- package/dist/modules/groups/index.d.cts +1 -1
- package/dist/modules/groups/index.d.ts +1 -1
- package/dist/modules/groups/index.js +2 -2
- package/dist/modules/headshotmarketing/index.cjs +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 +2 -2
- package/dist/modules/health/index.d.cts +1 -1
- package/dist/modules/health/index.d.ts +1 -1
- package/dist/modules/hookmovies/index.cjs +10 -10
- package/dist/modules/hookmovies/index.d.cts +1 -1
- package/dist/modules/hookmovies/index.d.ts +1 -1
- package/dist/modules/hookmovies/index.js +2 -2
- package/dist/modules/housingvista/index.cjs +8 -8
- package/dist/modules/housingvista/index.d.cts +1 -1
- package/dist/modules/housingvista/index.d.ts +1 -1
- package/dist/modules/housingvista/index.js +2 -2
- package/dist/modules/integrations/index.cjs +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 +2 -2
- package/dist/modules/intelwatchtower/index.cjs +7 -7
- package/dist/modules/intelwatchtower/index.d.cts +1 -1
- package/dist/modules/intelwatchtower/index.d.ts +1 -1
- package/dist/modules/intelwatchtower/index.js +2 -2
- package/dist/modules/kadaikodi/index.cjs +6 -6
- package/dist/modules/kadaikodi/index.d.cts +1 -1
- package/dist/modules/kadaikodi/index.d.ts +1 -1
- package/dist/modules/kadaikodi/index.js +2 -2
- package/dist/modules/labsofscience/index.cjs +4 -4
- package/dist/modules/labsofscience/index.d.cts +1 -1
- package/dist/modules/labsofscience/index.d.ts +1 -1
- package/dist/modules/labsofscience/index.js +2 -2
- package/dist/modules/manufacturedops/index.cjs +3 -3
- package/dist/modules/manufacturedops/index.d.cts +1 -1
- package/dist/modules/manufacturedops/index.d.ts +1 -1
- package/dist/modules/manufacturedops/index.js +2 -2
- package/dist/modules/movethewheels/index.cjs +8 -8
- package/dist/modules/movethewheels/index.d.cts +1 -1
- package/dist/modules/movethewheels/index.d.ts +1 -1
- package/dist/modules/movethewheels/index.js +2 -2
- package/dist/modules/mybodyshield/index.cjs +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 +2 -2
- package/dist/modules/notifications/index.cjs +2 -2
- package/dist/modules/notifications/index.d.cts +1 -1
- package/dist/modules/notifications/index.d.ts +1 -1
- package/dist/modules/notifications/index.js +1 -1
- package/dist/modules/organizations/index.cjs +5 -5
- package/dist/modules/organizations/index.d.cts +1 -1
- package/dist/modules/organizations/index.d.ts +1 -1
- package/dist/modules/organizations/index.js +1 -1
- package/dist/modules/planmagnet/index.cjs +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 +2 -2
- package/dist/modules/products/index.cjs +5 -5
- package/dist/modules/products/index.d.cts +1 -1
- package/dist/modules/products/index.d.ts +1 -1
- package/dist/modules/products/index.js +2 -2
- package/dist/modules/proserviceworld/index.cjs +6 -6
- package/dist/modules/proserviceworld/index.d.cts +1 -1
- package/dist/modules/proserviceworld/index.d.ts +1 -1
- package/dist/modules/proserviceworld/index.js +2 -2
- package/dist/modules/rbac/index.cjs +4 -4
- package/dist/modules/rbac/index.d.cts +1 -1
- package/dist/modules/rbac/index.d.ts +1 -1
- package/dist/modules/rbac/index.js +2 -2
- package/dist/modules/sandbox/index.cjs +11 -11
- 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 +14 -14
- package/dist/modules/scheduler/index.d.cts +1 -1
- package/dist/modules/scheduler/index.d.ts +1 -1
- package/dist/modules/scheduler/index.js +2 -2
- package/dist/modules/security/index.cjs +9 -9
- package/dist/modules/security/index.d.cts +1 -1
- package/dist/modules/security/index.d.ts +1 -1
- package/dist/modules/security/index.js +2 -2
- package/dist/modules/semanticfed/index.cjs +8 -8
- 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 +2 -2
- package/dist/modules/subscriberbot/index.cjs +1 -1
- package/dist/modules/subscriberbot/index.d.cts +1 -1
- package/dist/modules/subscriberbot/index.d.ts +1 -1
- package/dist/modules/subscriberbot/index.js +2 -2
- package/dist/modules/support/index.cjs +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 +2 -2
- package/dist/modules/tags/index.cjs +7 -7
- package/dist/modules/tags/index.d.cts +1 -1
- package/dist/modules/tags/index.d.ts +1 -1
- package/dist/modules/tags/index.js +2 -2
- package/dist/modules/technospam/index.cjs +4 -4
- package/dist/modules/technospam/index.d.cts +1 -1
- package/dist/modules/technospam/index.d.ts +1 -1
- package/dist/modules/technospam/index.js +2 -2
- package/dist/modules/theculturepost/index.cjs +10 -10
- package/dist/modules/theculturepost/index.d.cts +1 -1
- package/dist/modules/theculturepost/index.d.ts +1 -1
- package/dist/modules/theculturepost/index.js +2 -2
- package/dist/modules/theglobalfuel/index.cjs +7 -7
- package/dist/modules/theglobalfuel/index.d.cts +1 -1
- package/dist/modules/theglobalfuel/index.d.ts +1 -1
- package/dist/modules/theglobalfuel/index.js +2 -2
- package/dist/modules/timecampus/index.cjs +8 -8
- package/dist/modules/timecampus/index.d.cts +1 -1
- package/dist/modules/timecampus/index.d.ts +1 -1
- package/dist/modules/timecampus/index.js +2 -2
- package/dist/modules/tours/index.cjs +3 -3
- package/dist/modules/tours/index.d.cts +1 -1
- package/dist/modules/tours/index.d.ts +1 -1
- package/dist/modules/tours/index.js +2 -2
- package/dist/modules/vibecontrols/index.cjs +27 -27
- package/dist/modules/vibecontrols/index.d.cts +1 -1
- package/dist/modules/vibecontrols/index.d.ts +1 -1
- package/dist/modules/vibecontrols/index.js +5 -5
- package/dist/modules/workspaces/index.cjs +6 -6
- package/dist/modules/workspaces/index.d.cts +1 -1
- package/dist/modules/workspaces/index.d.ts +1 -1
- package/dist/modules/workspaces/index.js +2 -2
- package/package.json +3 -3
- package/dist/chunk-2OISIPE6.js +0 -34
- package/dist/chunk-VL67DTWH.js +0 -1
|
@@ -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-WTNQ5PEC.js';import {q as q$1}from'./chunk-MT2F54AC.js';var h=`
|
|
2
2
|
query SemConnector($id: ID!) {
|
|
3
3
|
semConnector(id: $id) {
|
|
4
4
|
id name kind description isActive capabilities
|
|
@@ -302,6 +302,6 @@ import {b as b$1,h as h$1,j as j$1}from'./chunk-VL67DTWH.js';import {o}from'./ch
|
|
|
302
302
|
}
|
|
303
303
|
}
|
|
304
304
|
}
|
|
305
|
-
`;function Ct(e,t){try{return JSON.parse(t)}catch{throw new
|
|
305
|
+
`;function Ct(e,t){try{return JSON.parse(t)}catch{throw new q$1(`--${e} must be valid JSON`)}}function l(e){let t=Number.parseInt(e,10);if(Number.isNaN(t))throw new q$1(`Expected an integer but got "${e}"`);return t}function yt(e){return e.split(",").map(t=>t.trim()).filter(t=>t.length>0)}function $t(e){let t={};return e.limit!==void 0&&(t.limit=e.limit),e.offset!==void 0&&(t.offset=e.offset),e.cursor&&(t.cursor=e.cursor),Object.keys(t).length?t:void 0}var f=["table","json","csv","yaml"];function C(e){if(e===void 0)return;let t=e.toLowerCase();if(f.includes(t))return t;throw new q$1(`--format must be one of ${f.join(", ")} (got "${e}")`)}function w(e){return e==null?"NULL":typeof e=="object"?JSON.stringify(e):String(e)}function y(e){if(e==null)return "";let t=typeof e=="object"?JSON.stringify(e):String(e);return /[",\r\n]/.test(t)?`"${t.replace(/"/g,'""')}"`:t}function _(e){let t=e.columns.map(o=>o.name),n=[t.map(y).join(",")];for(let o of e.rows)n.push(t.map(i=>y(o[i])).join(","));return `${n.join(`\r
|
|
306
306
|
`)}\r
|
|
307
|
-
`}function T(e,t){if(!e||e.trim()==="")throw new
|
|
307
|
+
`}function T(e,t){if(!e||e.trim()==="")throw new q$1('A SQL statement is required, e.g. semanticfed sql "SELECT * FROM customers LIMIT 10"');let n={sql:e};if(t.model&&(n.modelId=t.model),t.maxRows!==void 0){if(t.maxRows<1)throw new q$1("--max-rows must be a positive integer");n.maxRows=t.maxRows;}if(t.timeout!==void 0){if(t.timeout<1)throw new q$1("--timeout must be a positive integer");n.timeoutMs=t.timeout;}return n}function M(e,t){let n=j$1(),o=e??n.getFormat({});if(o==="csv"){if(!n.printRaw)throw new q$1("This output adapter cannot print CSV; use --format json or table");n.printRaw(_(t));}else if(o==="table"){let i=t.columns.map(r=>r.name);n.printTable(i,t.rows.map(r=>i.map(m=>w(r[m]))));let s=t.columns.filter(r=>r.masked).map(r=>r.name);n.printInfo(`${t.rowCount} row${t.rowCount===1?"":"s"} in ${Math.round(t.durationMs)} ms`+(s.length?` (masked: ${s.join(", ")})`:""));}else n.formatAndOutput({format:o},t);t.truncated&&n.printWarning("Result truncated: more rows matched than were returned (raise --max-rows, max 10000, or add LIMIT/WHERE).");}function ht(e){e.command("sql").description("Run a read-only SQL SELECT against a semantic model (sql catalog: list tables)").argument("[statement]","One SELECT statement; tables are entities, columns their fields").option("--model <id>","Semantic model ID (optional when the workspace has one model)").option("--max-rows <n>","Maximum rows returned (server default 1000, max 10000)",l).option("--timeout <ms>","Execution time limit in ms (default 30000, 1000-60000)",l).option("-f, --format <format>","Output format: table|json|csv|yaml").action(async(n,o)=>{try{let i=C(o.format),s=T(n,o),r=await b$1(A,{input:s});M(i,r.semExecuteSql);}catch(i){h$1(i);}}).command("catalog").description("List the tables and columns a semantic model exposes to SQL").option("--model <id>","Semantic model ID (optional when the workspace has one model)").option("-f, --format <format>","Output format: table|json|yaml").action(async(n,o)=>{try{let i=o.optsWithGlobals(),s=C(i.format);if(s==="csv")throw new q$1("sql catalog supports --format table, json or yaml");let m=(await b$1(g,{modelId:i.model||void 0})).semSqlCatalog;j$1().formatAndOutput({format:s},m,{headers:["Table","Column","Kind","Type","Primary","Aggregation"],rows:m.tables.flatMap(S=>S.columns.map(d=>[S.name,d.name,d.kind,d.dataType,d.isPrimary?"yes":"",d.aggregation??""]))});}catch(i){h$1(i);}});}export{Z as A,tt as B,et as C,nt as D,it as E,ot as F,at as G,rt as H,st as I,dt as J,mt as K,ut as L,ct as M,pt as N,Ct as O,l as P,yt as Q,$t as R,ht as S,h as a,x as b,R as c,k as d,D as e,b as f,q as g,L as h,O as i,N as j,U as k,Q as l,P as m,v as n,F as o,j as p,H as q,Y as r,K as s,V as t,W as u,J as v,B as w,G as x,X as y,z};
|
|
@@ -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 x from'cross-fetch';import {Command}from'commander';var U=300*1e3;function R(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 i(a){r(),writeFileSync(n,JSON.stringify(a,null,2),{encoding:"utf8",mode:384});try{chmodSync(n,384);}catch{}}function s(){try{existsSync(n)&&unlinkSync(n);}catch{}}function o(){let a=t();return a?.expiresAt?Date.now()>=a.expiresAt:false}function c(){let a=t();return a?.expiresAt?Date.now()+U>=a.expiresAt:false}function l(){let a=t();return a?.workspaceTokenExpiresAt?Date.now()>=a.workspaceTokenExpiresAt:false}function m(){let a=t();return a?.workspaceTokenExpiresAt?Date.now()+U>=a.workspaceTokenExpiresAt:false}function y(){return t()?.accessToken?!o():false}return {read:t,write:i,clear:s,isTokenExpired:o,isTokenExpiringSoon:c,isWorkspaceTokenExpired:l,isWorkspaceTokenExpiringSoon:m,isAuthenticated:y}}var pe=["workspaceEndpoint","globalEndpoint","oidcIssuer","clientId","defaultFormat","verbose","authServiceEndpoint","productOrigin"];function $(e){let n=join(homedir(),".config",e.configDirName),r=join(n,"config.json"),t={workspaceEndpoint:e.workspaceEndpointDefault,globalEndpoint:e.globalEndpointDefault};function i(){existsSync(n)||mkdirSync(n,{recursive:true,mode:448});}function s(u){if(e.envPrefix){let d=process.env[`${e.envPrefix}_${u}`];if(d)return d}let p=process.env[u];return p&&p.length>0?p:void 0}function o(u){if(!e.envPrefix)return;let p=process.env[`${e.envPrefix}_${u}`];return p&&p.length>0?p:void 0}function c(){let u={};try{existsSync(r)&&(u=JSON.parse(readFileSync(r,"utf8")));}catch{}return {...t,...u,workspaceEndpoint:s("WORKSPACE_ENDPOINT")??u.workspaceEndpoint??t.workspaceEndpoint,globalEndpoint:s("GLOBAL_ENDPOINT")??u.globalEndpoint??t.globalEndpoint,oidcIssuer:s("OIDC_ISSUER")??u.oidcIssuer,clientId:s("CLIENT_ID")??u.clientId,productOrigin:o("ORIGIN")??u.productOrigin}}function l(u){i(),writeFileSync(r,JSON.stringify(u,null,2),{encoding:"utf8"});try{chmodSync(r,384);}catch{}}function m(u){return c()[u]}function y(u,p){let d=c();d[u]=p,l(d);}function a(){let u=c(),p=u.clientId||e.oidcClientId,d=u.oidcIssuer;if(!d){let f=u.globalEndpoint;f.includes("localhost")||f.includes("127.0.0.1")?d=f.replace(/\/graphql$/,"").replace(/\/global\/graphql$/,"/global"):d=e.oidcIssuerProd??"https://graphql.burdenoff.com/global";}return {oidcIssuer:d,clientId:p}}function g(){let u=c();if(u.productOrigin)return u.productOrigin;if(e.productOrigins)try{let p=new URL(u.workspaceEndpoint).hostname.toLowerCase();return e.productOrigins[p]}catch{return}}return {read:c,write:l,get:m,set:y,path:()=>r,dir:()=>n,resolveOIDC:a,resolveProductOrigin:g}}async function de(e){let n=`${e.oidcIssuer}/oidc/device/code`,r=new URLSearchParams({client_id:e.clientId,scope:"openid profile email offline_access"}),t=await x(n,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:r.toString()});if(!t.ok){let s=await t.text().catch(()=>"Unknown error");throw new Error(`Device code request failed (${t.status}): ${s}`)}let i=await t.json();return {deviceCode:i.device_code,userCode:i.user_code,verificationUri:i.verification_uri,verificationUriComplete:i.verification_uri_complete??null,expiresIn:i.expires_in,interval:i.interval??5}}async function ge(e,n,r){let t=`${r.oidcIssuer}/oauth/device/token`,i=n;for(;;){await new Promise(l=>setTimeout(l,i*1e3));let s=await x(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 s.json();if(s.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":i+=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 P(e,n,r,t){let s=await x(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(!s.ok){let c=await s.text().catch(()=>"Unknown error");throw new Error(`App authentication failed (${s.status}): ${c}`)}let o=await s.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 q(e,n,r,t){let s=await x(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(!s.ok){let l=await s.text().catch(()=>"Unknown error");throw new Error(`Workspace token request failed (${s.status}): ${l}`)}let o=await s.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 l=c?.error?.message??"Unknown error";throw new Error(`Workspace token failed: ${l}`)}return {token:c.token,expiresAt:c.expiresAt??"",scopes:c.scopes??[]}}async function fe(e,n){let t=await x(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 s=await t.text().catch(()=>"Unknown error");throw new Error(`Failed to fetch workspaces (${t.status}): ${s}`)}let i=await t.json();if(i.errors?.length)throw new Error(`Failed to fetch workspaces: ${i.errors[0]?.message??"unknown error"}`);return i.data?.myWorkspaces?.items??[]}function me(e){try{let n=new URL(e);return n.protocol==="http:"||n.protocol==="https:"}catch{return false}}async function ke(e){try{if(!me(e))return !1;let{execFile:n}=await import('child_process'),r=process.platform,t,i;return r==="darwin"?(t="open",i=[e]):r==="win32"?(t="cmd",i=["/c","start","",e]):(t="xdg-open",i=[e]),new Promise(s=>{n(t,i,o=>{s(!o);});})}catch{return false}}var we=3e4,V=3,he=1e3;function ye(e){return new Promise(n=>setTimeout(n,e))}function Ce(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 J(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 i=n.response?.status;return typeof i=="number"&&Number.isInteger(i)?`GraphQL request failed (HTTP ${i})`:"GraphQL request failed"}return e instanceof Error?e.message:String(e)}var I=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 Y(e){let n=J(e);if(!v(e)||!v(e.response))return new Error(n);let r=e.response,t=typeof r.status=="number"?r.status:void 0,i=Array.isArray(r.errors)?r.errors.flatMap(s=>{if(!v(s)||typeof s.message!="string")return [];let o=Array.isArray(s.path)?s.path.filter(l=>typeof l=="string"||typeof l=="number"):void 0,c=xe(s.extensions);return [{message:s.message,...o?{path:o}:{},...c?{extensions:c}:{}}]}):void 0;return new I(n,{...t!==void 0?{status:t}:{},...i?{errors:i}:{}})}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 L(e,n,r){let t;for(let i=0;i<V;i++)try{let s=new AbortController,o=setTimeout(()=>s.abort(),we);try{return await e.request({document:n,variables:r,signal:s.signal})}finally{clearTimeout(o);}}catch(s){if(t=s,s&&typeof s=="object"&&"response"in s){let o=s.response;if(o&&typeof o.status=="number"&&o.status>=400&&o.status<500)break}if(Ce(s)&&i<V-1){let o=he*Math.pow(2,i);await ye(o);continue}break}throw Y(t)}function D(e,n){let r=null,t=null;function i(){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 s(){let a=n.read();if(!a)return;if(a.authMethod==="client_credentials"&&a.clientId&&a.clientSecret){let d=e.read();try{let f=await P(d.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(),u=new GraphQLClient(g.globalEndpoint);u.setHeaders({Authorization:`Bearer ${a.accessToken}`});let p=`
|
|
21
|
+
mutation RefreshToken($token: String!) {
|
|
22
|
+
refreshToken(token: $token) {
|
|
23
|
+
accessToken
|
|
24
|
+
refreshToken
|
|
25
|
+
expiresIn
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
`;try{let f=(await u.request(p,{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 u=await q(g.workspaceEndpoint,a.accessToken,a.workspaceId,a.organizationId);n.write({...a,workspaceToken:u.token,workspaceTokenExpiresAt:new Date(u.expiresAt).getTime()}),r=null;}catch{}}async function c(){n.isTokenExpiringSoon()&&await s(),n.read()?.workspaceToken&&n.isWorkspaceTokenExpiringSoon()&&await o();}return {workspace:{async request(a,g){await c();let{workspace:u}=r?{workspace:r}:i();return u.setHeaders(B(n.read(),e.resolveProductOrigin())),L(u,a,g)}},global:{async request(a,g){let{global:u}=t?{global:t}:i();return u.setHeaders(T(n.read())),L(u,a,g)}},workspaceAuthOnly:{async request(a,g){let u=e.read(),p=n.read(),d=new GraphQLClient(u.workspaceEndpoint),f=T(p),M=e.resolveProductOrigin();return M&&(f.Origin=M),d.setHeaders(f),L(d,a,g)}},reset(){r=null,t=null;}}}function G(){return !!(process.stdout.isTTY&&process.stdin.isTTY)}function Q(e){if(e.format){let n=e.format.toLowerCase();if(n==="json"||n==="table"||n==="yaml")return n}return G()?"table":"json"}function _(e){console.log(JSON.stringify(e,null,2));}function K(e,n){if(e.length===0)return;let r=e.map((s,o)=>{let c=s.length;for(let l of n){let m=l[o]??"";m.length>c&&(c=m.length);}return Math.min(c,50)}),t=r.map(s=>"-".repeat(s+2)).join("+"),i=s=>s.map((o,c)=>` ${(o??"").padEnd(r[c]??0)} `).join("|");console.log(i(e)),console.log(t);for(let s of n)console.log(i(s));}function N(e,n){let r=" ".repeat(n),t=[];for(let[i,s]of Object.entries(e))if(s==null)t.push(`${r}${i}: null`);else if(Array.isArray(s)){t.push(`${r}${i}:`);for(let o of s)typeof o=="object"&&o!==null?(t.push(`${r} -`),t.push(N(o,n+2))):t.push(`${r} - ${String(o)}`);}else typeof s=="object"?(t.push(`${r}${i}:`),t.push(N(s,n+1))):t.push(`${r}${i}: ${String(s)}`);return t.join(`
|
|
29
|
+
`)}function X(e){if(typeof e!="object"||e===null){console.log(String(e));return}console.log(N(e,0));}function be(e){process.stdout.write(e.endsWith(`
|
|
30
|
+
`)?e:`${e}
|
|
31
|
+
`);}function Ee(e){console.log(`\u2713 ${e}`);}function Z(e){console.error(`\u2717 ${e}`);}function ve(e){console.warn(`! ${e}`);}function Te(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(Q(e)){case "json":_(n);break;case "yaml":X(n);break;case "table":r?K(r.headers,r.rows):_(n);break}}async function Re(e,n){return n?true:G()?new Promise(r=>{process.stdout.write(`${e} [y/N] `),process.stdin.setEncoding("utf8"),process.stdin.once("data",t=>{let i=t.trim().toLowerCase();r(i==="y"||i==="yes");}),process.stdin.resume();}):(Z(`${e} Use --force to skip confirmation.`),false)}var j={isInteractive:G,getFormat:Q,formatAndOutput:Se,printJson:_,printTable:K,printYaml:X,printRaw:be,printSuccess:Ee,printError:Z,printWarning:ve,printInfo:Te,formatDate:Ie,formatStatus:Ae,truncate:Oe,confirm:Re};function F(e={}){let{verbose:n=false,quiet:r=false}=e;return {debug(t,...i){n&&console.error(`[debug] ${t}`,...i);},info(t,...i){r||console.error(`[info] ${t}`,...i);},warn(t,...i){console.error(`[warn] ${t}`,...i);},error(t,...i){console.error(`[error] ${t}`,...i);}}}function $e(e){return e.includes("localhost")||e.includes("127.0.0.1")?"local":e.includes("alpha")||e.includes("staging")?"staging":"prod"}function Pe(e){return !!e&&typeof e.debug=="function"&&typeof e.info=="function"}function qe(e){let n=$(e.defaults),r=R(n.dir()),t=D(n,r),i=e.output??j,s=Pe(e.logger)?e.logger:F(e.logger),o=e.env??$e(n.read().workspaceEndpoint);return {productName:e.productName,productVersion:e.productVersion,defaults:e.defaults,config:n,auth:r,gql:t,output:i,logger:s,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;}},b=class extends C{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 A=class extends h{constructor(n,r){super(`Module '${n}' declares dependency on '${r}', but '${r}' is not in the module list.`),this.name="MissingDependencyError";}},O=class extends h{constructor(n){super(`Circular dependency detected among modules: ${n.join(" -> ")}`),this.name="CircularDependencyError";}};function W(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 c of o.dependsOn??[])if(!n.has(c))throw new A(o.id,c);let r=[],t=new Set,i=new Set;function s(o,c){if(!i.has(o.id)){if(t.has(o.id))throw new O([...c,o.id]);t.add(o.id);for(let l of o.dependsOn??[]){let m=n.get(l);m&&s(m,[...c,o.id]);}t.delete(o.id),i.add(o.id),r.push(o);}}for(let o of e)s(o,[]);return r}function De(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,c)=>{let l=t.opts().format;if(typeof l!="string")return;c.options.some(y=>y.attributeName()==="format")&&c.getOptionValue("format")===void 0&&c.setOptionValue("format",l);});let i=W(n);for(let o of i)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 s(o=process.argv){try{await t.parseAsync(o),o.length<=2&&t.outputHelp();}catch(c){_e(e,c);}}return {program:t,run:s}}function _e(e,n){if(n instanceof b&&(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 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{R as a,pe as b,$ as c,de as d,ge as e,P as f,q as g,fe as h,ke as i,J as j,I as k,Y as l,D as m,j as n,F as o,qe as p,C as q,b as r,h as s,A as t,O as u,W as v,De as w};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {b as b$1,q as q$1,r,s}from'./chunk-MT2F54AC.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};
|
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 M=300*1e3;function S(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 i(a){r(),fs.writeFileSync(n,JSON.stringify(a,null,2),{encoding:"utf8",mode:384});try{fs.chmodSync(n,384);}catch{}}function s(){try{fs.existsSync(n)&&fs.unlinkSync(n);}catch{}}function o(){let a=t();return a?.expiresAt?Date.now()>=a.expiresAt:false}function c(){let a=t();return a?.expiresAt?Date.now()+M>=a.expiresAt:false}function l(){let a=t();return a?.workspaceTokenExpiresAt?Date.now()>=a.workspaceTokenExpiresAt:false}function m(){let a=t();return a?.workspaceTokenExpiresAt?Date.now()+M>=a.workspaceTokenExpiresAt:false}function h(){return t()?.accessToken?!o():false}return {read:t,write:i,clear:s,isTokenExpired:o,isTokenExpiringSoon:c,isWorkspaceTokenExpired:l,isWorkspaceTokenExpiringSoon:m,isAuthenticated:h}}var le=["workspaceEndpoint","globalEndpoint","oidcIssuer","clientId","defaultFormat","verbose","authServiceEndpoint","productOrigin"];function R(e){let n=path.join(os.homedir(),".config",e.configDirName),r=path.join(n,"config.json"),t={workspaceEndpoint:e.workspaceEndpointDefault,globalEndpoint:e.globalEndpointDefault};function i(){fs.existsSync(n)||fs.mkdirSync(n,{recursive:true,mode:448});}function s(u){if(e.envPrefix){let d=process.env[`${e.envPrefix}_${u}`];if(d)return d}let p=process.env[u];return p&&p.length>0?p:void 0}function o(u){if(!e.envPrefix)return;let p=process.env[`${e.envPrefix}_${u}`];return p&&p.length>0?p:void 0}function c(){let u={};try{fs.existsSync(r)&&(u=JSON.parse(fs.readFileSync(r,"utf8")));}catch{}return {...t,...u,workspaceEndpoint:s("WORKSPACE_ENDPOINT")??u.workspaceEndpoint??t.workspaceEndpoint,globalEndpoint:s("GLOBAL_ENDPOINT")??u.globalEndpoint??t.globalEndpoint,oidcIssuer:s("OIDC_ISSUER")??u.oidcIssuer,clientId:s("CLIENT_ID")??u.clientId,productOrigin:o("ORIGIN")??u.productOrigin}}function l(u){i(),fs.writeFileSync(r,JSON.stringify(u,null,2),{encoding:"utf8"});try{fs.chmodSync(r,384);}catch{}}function m(u){return c()[u]}function h(u,p){let d=c();d[u]=p,l(d);}function a(){let u=c(),p=u.clientId||e.oidcClientId,d=u.oidcIssuer;if(!d){let f=u.globalEndpoint;f.includes("localhost")||f.includes("127.0.0.1")?d=f.replace(/\/graphql$/,"").replace(/\/global\/graphql$/,"/global"):d=e.oidcIssuerProd??"https://graphql.burdenoff.com/global";}return {oidcIssuer:d,clientId:p}}function g(){let u=c();if(u.productOrigin)return u.productOrigin;if(e.productOrigins)try{let p=new URL(u.workspaceEndpoint).hostname.toLowerCase();return e.productOrigins[p]}catch{return}}return {read:c,write:l,get:m,set:h,path:()=>r,dir:()=>n,resolveOIDC:a,resolveProductOrigin:g}}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 s=await t.text().catch(()=>"Unknown error");throw new Error(`Device code request failed (${t.status}): ${s}`)}let i=await t.json();return {deviceCode:i.device_code,userCode:i.user_code,verificationUri:i.verification_uri,verificationUriComplete:i.verification_uri_complete??null,expiresIn:i.expires_in,interval:i.interval??5}}async function de(e,n,r){let t=`${r.oidcIssuer}/oauth/device/token`,i=n;for(;;){await new Promise(l=>setTimeout(l,i*1e3));let s=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 s.json();if(s.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":i+=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 $(e,n,r,t){let s=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(!s.ok){let
|
|
7
|
+
`,variables:{input:{clientId:n,clientSecret:r,scopes:t}}})});if(!s.ok){let c=await s.text().catch(()=>"Unknown error");throw new Error(`App authentication failed (${s.status}): ${c}`)}let o=await s.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 s=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(!s.ok){let l=await s.text().catch(()=>"Unknown error");throw new Error(`Workspace token request failed (${s.status}): ${l}`)}let o=await s.json();if(o.errors?.length)throw new Error(`Workspace token failed: ${o.errors[0]?.message??"unknown error"}`);let
|
|
14
|
+
`,variables:{input:{workspaceId:r,organizationId:t}}})});if(!s.ok){let l=await s.text().catch(()=>"Unknown error");throw new Error(`Workspace token request failed (${s.status}): ${l}`)}let o=await s.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 l=c?.error?.message??"Unknown error";throw new Error(`Workspace token failed: ${l}`)}return {token:c.token,expiresAt:c.expiresAt??"",scopes:c.scopes??[]}}async function ge(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 s=await t.text().catch(()=>"Unknown error");throw new Error(`Failed to fetch workspaces (${t.status}): ${s}`)}let i=await t.json();if(i.errors?.length)throw new Error(`Failed to fetch workspaces: ${i.errors[0]?.message??"unknown error"}`);return i.data?.myWorkspaces?.items??[]}function
|
|
20
|
+
`,variables:{limit:50}})});if(!t.ok){let s=await t.text().catch(()=>"Unknown error");throw new Error(`Failed to fetch workspaces (${t.status}): ${s}`)}let i=await t.json();if(i.errors?.length)throw new Error(`Failed to fetch workspaces: ${i.errors[0]?.message??"unknown error"}`);return i.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,i;return r==="darwin"?(t="open",i=[e]):r==="win32"?(t="cmd",i=["/c","start","",e]):(t="xdg-open",i=[e]),new Promise(s=>{n(t,i,o=>{s(!o);});})}catch{return false}}var ke=3e4,H=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 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 i=n.response?.status;return typeof i=="number"&&Number.isInteger(i)?`GraphQL request failed (HTTP ${i})`:"GraphQL request failed"}return e instanceof Error?e.message:String(e)}var T=class extends Error{response;constructor(n,r){super(n),this.name="GqlRequestError",this.response=r;}};function E(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Ce(e){if(!E(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(!E(e)||!E(e.response))return new Error(n);let r=e.response,t=typeof r.status=="number"?r.status:void 0,i=Array.isArray(r.errors)?r.errors.flatMap(s=>{if(!E(s)||typeof s.message!="string")return [];let o=Array.isArray(s.path)?s.path.filter(l=>typeof l=="string"||typeof l=="number"):void 0,c=Ce(s.extensions);return [{message:s.message,...o?{path:o}:{},...c?{extensions:c}:{}}]}):void 0;return new T(n,{...t!==void 0?{status:t}:{},...i?{errors:i}:{}})}function v(e){let n={};return e?.accessToken&&(n.Authorization=`Bearer ${e.accessToken}`),e?.organizationId&&(n["x-org-id"]=e.organizationId),n}function V(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 q(e,n,r){let t;for(let i=0;i<H;i++)try{let s=new AbortController,o=setTimeout(()=>s.abort(),ke);try{return await e.request({document:n,variables:r,signal:s.signal})}finally{clearTimeout(o);}}catch(s){if(t=s,s&&typeof s=="object"&&"response"in s){let o=s.response;if(o&&typeof o.status=="number"&&o.status>=400&&o.status<500)break}if(ye(s)&&i<H-1){let o=we*Math.pow(2,i);await he(o);continue}break}throw J(t)}function L(e,n){let r=null,t=null;function i(){let a=e.read(),g=n.read();return r=new graphqlRequest.GraphQLClient(a.workspaceEndpoint),r.setHeaders(V(g,e.resolveProductOrigin())),t=new graphqlRequest.GraphQLClient(a.globalEndpoint),t.setHeaders(v(g)),{workspace:r,global:t}}async function s(){let a=n.read();if(!a)return;if(a.authMethod==="client_credentials"&&a.clientId&&a.clientSecret){let d=e.read();try{let f=await $(d.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(),u=new graphqlRequest.GraphQLClient(g.globalEndpoint);u.setHeaders({Authorization:`Bearer ${a.accessToken}`});let p=`
|
|
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 f=(await
|
|
29
|
-
`)}function
|
|
28
|
+
`;try{let f=(await u.request(p,{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 u=await P(g.workspaceEndpoint,a.accessToken,a.workspaceId,a.organizationId);n.write({...a,workspaceToken:u.token,workspaceTokenExpiresAt:new Date(u.expiresAt).getTime()}),r=null;}catch{}}async function c(){n.isTokenExpiringSoon()&&await s(),n.read()?.workspaceToken&&n.isWorkspaceTokenExpiringSoon()&&await o();}return {workspace:{async request(a,g){await c();let{workspace:u}=r?{workspace:r}:i();return u.setHeaders(V(n.read(),e.resolveProductOrigin())),q(u,a,g)}},global:{async request(a,g){let{global:u}=t?{global:t}:i();return u.setHeaders(v(n.read())),q(u,a,g)}},workspaceAuthOnly:{async request(a,g){let u=e.read(),p=n.read(),d=new graphqlRequest.GraphQLClient(u.workspaceEndpoint),f=v(p),W=e.resolveProductOrigin();return W&&(f.Origin=W),d.setHeaders(f),q(d,a,g)}},reset(){r=null,t=null;}}}function N(){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 N()?"table":"json"}function D(e){console.log(JSON.stringify(e,null,2));}function Q(e,n){if(e.length===0)return;let r=e.map((s,o)=>{let c=s.length;for(let l of n){let m=l[o]??"";m.length>c&&(c=m.length);}return Math.min(c,50)}),t=r.map(s=>"-".repeat(s+2)).join("+"),i=s=>s.map((o,c)=>` ${(o??"").padEnd(r[c]??0)} `).join("|");console.log(i(e)),console.log(t);for(let s of n)console.log(i(s));}function _(e,n){let r=" ".repeat(n),t=[];for(let[i,s]of Object.entries(e))if(s==null)t.push(`${r}${i}: null`);else if(Array.isArray(s)){t.push(`${r}${i}:`);for(let o of s)typeof o=="object"&&o!==null?(t.push(`${r} -`),t.push(_(o,n+2))):t.push(`${r} - ${String(o)}`);}else typeof s=="object"?(t.push(`${r}${i}:`),t.push(_(s,n+1))):t.push(`${r}${i}: ${String(s)}`);return t.join(`
|
|
29
|
+
`)}function K(e){if(typeof e!="object"||e===null){console.log(String(e));return}console.log(_(e,0));}function xe(e){process.stdout.write(e.endsWith(`
|
|
30
30
|
`)?e:`${e}
|
|
31
|
-
`);}function
|
|
31
|
+
`);}function be(e){console.log(`\u2713 ${e}`);}function X(e){console.error(`\u2717 ${e}`);}function Ee(e){console.warn(`! ${e}`);}function ve(e){console.log(`\u2139 ${e}`);}function Te(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(Y(e)){case "json":D(n);break;case "yaml":K(n);break;case "table":r?Q(r.headers,r.rows):D(n);break}}async function Se(e,n){return n?true:N()?new Promise(r=>{process.stdout.write(`${e} [y/N] `),process.stdin.setEncoding("utf8"),process.stdin.once("data",t=>{let i=t.trim().toLowerCase();r(i==="y"||i==="yes");}),process.stdin.resume();}):(X(`${e} Use --force to skip confirmation.`),false)}var G={isInteractive:N,getFormat:Y,formatAndOutput:Oe,printJson:D,printTable:Q,printYaml:K,printRaw:xe,printSuccess:be,printError:X,printWarning:Ee,printInfo:ve,formatDate:Te,formatStatus:Ie,truncate:Ae,confirm:Se};function j(e={}){let{verbose:n=false,quiet:r=false}=e;return {debug(t,...i){n&&console.error(`[debug] ${t}`,...i);},info(t,...i){r||console.error(`[info] ${t}`,...i);},warn(t,...i){console.error(`[warn] ${t}`,...i);},error(t,...i){console.error(`[error] ${t}`,...i);}}}function Re(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=R(e.defaults),r=S(n.dir()),t=L(n,r),i=e.output??G,s=$e(e.logger)?e.logger:j(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:i,logger:s,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";}},w=class extends Error{cause;constructor(n,r){super(n),this.name="CliInternalError",this.cause=r;}};var I=class extends w{constructor(n,r){super(`Module '${n}' declares dependency on '${r}', but '${r}' is not in the module list.`),this.name="MissingDependencyError";}},A=class extends w{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 w(`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 I(o.id,c);let r=[],t=new Set,i=new Set;function s(o,c){if(!i.has(o.id)){if(t.has(o.id))throw new A([...c,o.id]);t.add(o.id);for(let l of o.dependsOn??[]){let m=n.get(l);m&&s(m,[...c,o.id]);}t.delete(o.id),i.add(o.id),r.push(o);}}for(let o of e)s(o,[]);return r}function Le(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,c)=>{let l=t.opts().format;if(typeof l!="string")return;c.options.some(h=>h.attributeName()==="format")&&c.getOptionValue("format")===void 0&&c.setOptionValue("format",l);});let i=F(n);for(let o of i)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 s(o=process.argv){try{await t.parseAsync(o),o.length<=2&&t.outputHelp();}catch(
|
|
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 s(o=process.argv){try{await t.parseAsync(o),o.length<=2&&t.outputHelp();}catch(c){De(e,c);}}return {program:t,run:s}}function De(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 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=A;exports.CliAuthError=x;exports.CliInternalError=w;exports.CliUserError=y;exports.GqlRequestError=T;exports.KNOWN_CONFIG_KEYS=le;exports.MissingDependencyError=I;exports.buildContext=Pe;exports.clientCredentialsFlow=$;exports.createAuthStore=S;exports.createConfigStore=R;exports.createGqlClients=L;exports.createLogger=j;exports.createProgram=Le;exports.defaultOutputAdapter=G;exports.extractGqlErrorMessage=B;exports.fetchWorkspaces=ge;exports.issueWorkspaceToken=P;exports.openBrowser=me;exports.pollForToken=de;exports.sortModules=F;exports.startDeviceCodeFlow=pe;exports.toGqlRequestError=J;
|
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, K as KNOWN_CONFIG_KEYS, L as Logger,
|
|
1
|
+
import { a as CLIContext, C as CliModule } from '../module-CLaW1ycq.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-CLaW1ycq.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, K as KNOWN_CONFIG_KEYS, L as Logger,
|
|
1
|
+
import { a as CLIContext, C as CliModule } from '../module-CLaW1ycq.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-CLaW1ycq.js';
|
|
3
3
|
import { Command } from 'commander';
|
|
4
4
|
import 'graphql-request';
|
|
5
5
|
|
package/dist/core/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{
|
|
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-MT2F54AC.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'),x=require('cross-fetch'),commander=require('commander');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var x__default=/*#__PURE__*/_interopDefault(x);var M=300*1e3;function S(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 i(a){r(),fs.writeFileSync(n,JSON.stringify(a,null,2),{encoding:"utf8",mode:384});try{fs.chmodSync(n,384);}catch{}}function s(){try{fs.existsSync(n)&&fs.unlinkSync(n);}catch{}}function o(){let a=t();return a?.expiresAt?Date.now()>=a.expiresAt:false}function c(){let a=t();return a?.expiresAt?Date.now()+M>=a.expiresAt:false}function l(){let a=t();return a?.workspaceTokenExpiresAt?Date.now()>=a.workspaceTokenExpiresAt:false}function m(){let a=t();return a?.workspaceTokenExpiresAt?Date.now()+M>=a.workspaceTokenExpiresAt:false}function h(){return t()?.accessToken?!o():false}return {read:t,write:i,clear:s,isTokenExpired:o,isTokenExpiringSoon:c,isWorkspaceTokenExpired:l,isWorkspaceTokenExpiringSoon:m,isAuthenticated:h}}var le=["workspaceEndpoint","globalEndpoint","oidcIssuer","clientId","defaultFormat","verbose","authServiceEndpoint","productOrigin"];function R(e){let n=path.join(os.homedir(),".config",e.configDirName),r=path.join(n,"config.json"),t={workspaceEndpoint:e.workspaceEndpointDefault,globalEndpoint:e.globalEndpointDefault};function i(){fs.existsSync(n)||fs.mkdirSync(n,{recursive:true,mode:448});}function s(u){if(e.envPrefix){let d=process.env[`${e.envPrefix}_${u}`];if(d)return d}let p=process.env[u];return p&&p.length>0?p:void 0}function o(u){if(!e.envPrefix)return;let p=process.env[`${e.envPrefix}_${u}`];return p&&p.length>0?p:void 0}function c(){let u={};try{fs.existsSync(r)&&(u=JSON.parse(fs.readFileSync(r,"utf8")));}catch{}return {...t,...u,workspaceEndpoint:s("WORKSPACE_ENDPOINT")??u.workspaceEndpoint??t.workspaceEndpoint,globalEndpoint:s("GLOBAL_ENDPOINT")??u.globalEndpoint??t.globalEndpoint,oidcIssuer:s("OIDC_ISSUER")??u.oidcIssuer,clientId:s("CLIENT_ID")??u.clientId,productOrigin:o("ORIGIN")??u.productOrigin}}function l(u){i(),fs.writeFileSync(r,JSON.stringify(u,null,2),{encoding:"utf8"});try{fs.chmodSync(r,384);}catch{}}function m(u){return c()[u]}function h(u,p){let d=c();d[u]=p,l(d);}function a(){let u=c(),p=u.clientId||e.oidcClientId,d=u.oidcIssuer;if(!d){let f=u.globalEndpoint;f.includes("localhost")||f.includes("127.0.0.1")?d=f.replace(/\/graphql$/,"").replace(/\/global\/graphql$/,"/global"):d=e.oidcIssuerProd??"https://graphql.burdenoff.com/global";}return {oidcIssuer:d,clientId:p}}function g(){let u=c();if(u.productOrigin)return u.productOrigin;if(e.productOrigins)try{let p=new URL(u.workspaceEndpoint).hostname.toLowerCase();return e.productOrigins[p]}catch{return}}return {read:c,write:l,get:m,set:h,path:()=>r,dir:()=>n,resolveOIDC:a,resolveProductOrigin:g}}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 x__default.default(n,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:r.toString()});if(!t.ok){let s=await t.text().catch(()=>"Unknown error");throw new Error(`Device code request failed (${t.status}): ${s}`)}let i=await t.json();return {deviceCode:i.device_code,userCode:i.user_code,verificationUri:i.verification_uri,verificationUriComplete:i.verification_uri_complete??null,expiresIn:i.expires_in,interval:i.interval??5}}async function de(e,n,r){let t=`${r.oidcIssuer}/oauth/device/token`,i=n;for(;;){await new Promise(l=>setTimeout(l,i*1e3));let s=await x__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 s.json();if(s.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":i+=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 $(e,n,r,t){let s=await x__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(!s.ok){let
|
|
7
|
+
`,variables:{input:{clientId:n,clientSecret:r,scopes:t}}})});if(!s.ok){let c=await s.text().catch(()=>"Unknown error");throw new Error(`App authentication failed (${s.status}): ${c}`)}let o=await s.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 s=await x__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(!s.ok){let l=await s.text().catch(()=>"Unknown error");throw new Error(`Workspace token request failed (${s.status}): ${l}`)}let o=await s.json();if(o.errors?.length)throw new Error(`Workspace token failed: ${o.errors[0]?.message??"unknown error"}`);let
|
|
14
|
+
`,variables:{input:{workspaceId:r,organizationId:t}}})});if(!s.ok){let l=await s.text().catch(()=>"Unknown error");throw new Error(`Workspace token request failed (${s.status}): ${l}`)}let o=await s.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 l=c?.error?.message??"Unknown error";throw new Error(`Workspace token failed: ${l}`)}return {token:c.token,expiresAt:c.expiresAt??"",scopes:c.scopes??[]}}async function ge(e,n){let t=await x__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 s=await t.text().catch(()=>"Unknown error");throw new Error(`Failed to fetch workspaces (${t.status}): ${s}`)}let i=await t.json();if(i.errors?.length)throw new Error(`Failed to fetch workspaces: ${i.errors[0]?.message??"unknown error"}`);return i.data?.myWorkspaces?.items??[]}function
|
|
20
|
+
`,variables:{limit:50}})});if(!t.ok){let s=await t.text().catch(()=>"Unknown error");throw new Error(`Failed to fetch workspaces (${t.status}): ${s}`)}let i=await t.json();if(i.errors?.length)throw new Error(`Failed to fetch workspaces: ${i.errors[0]?.message??"unknown error"}`);return i.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,i;return r==="darwin"?(t="open",i=[e]):r==="win32"?(t="cmd",i=["/c","start","",e]):(t="xdg-open",i=[e]),new Promise(s=>{n(t,i,o=>{s(!o);});})}catch{return false}}var ke=3e4,H=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 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 i=n.response?.status;return typeof i=="number"&&Number.isInteger(i)?`GraphQL request failed (HTTP ${i})`:"GraphQL request failed"}return e instanceof Error?e.message:String(e)}var T=class extends Error{response;constructor(n,r){super(n),this.name="GqlRequestError",this.response=r;}};function E(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function xe(e){if(!E(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(!E(e)||!E(e.response))return new Error(n);let r=e.response,t=typeof r.status=="number"?r.status:void 0,i=Array.isArray(r.errors)?r.errors.flatMap(s=>{if(!E(s)||typeof s.message!="string")return [];let o=Array.isArray(s.path)?s.path.filter(l=>typeof l=="string"||typeof l=="number"):void 0,c=xe(s.extensions);return [{message:s.message,...o?{path:o}:{},...c?{extensions:c}:{}}]}):void 0;return new T(n,{...t!==void 0?{status:t}:{},...i?{errors:i}:{}})}function v(e){let n={};return e?.accessToken&&(n.Authorization=`Bearer ${e.accessToken}`),e?.organizationId&&(n["x-org-id"]=e.organizationId),n}function V(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 q(e,n,r){let t;for(let i=0;i<H;i++)try{let s=new AbortController,o=setTimeout(()=>s.abort(),ke);try{return await e.request({document:n,variables:r,signal:s.signal})}finally{clearTimeout(o);}}catch(s){if(t=s,s&&typeof s=="object"&&"response"in s){let o=s.response;if(o&&typeof o.status=="number"&&o.status>=400&&o.status<500)break}if(ye(s)&&i<H-1){let o=we*Math.pow(2,i);await he(o);continue}break}throw J(t)}function L(e,n){let r=null,t=null;function i(){let a=e.read(),g=n.read();return r=new graphqlRequest.GraphQLClient(a.workspaceEndpoint),r.setHeaders(V(g,e.resolveProductOrigin())),t=new graphqlRequest.GraphQLClient(a.globalEndpoint),t.setHeaders(v(g)),{workspace:r,global:t}}async function s(){let a=n.read();if(!a)return;if(a.authMethod==="client_credentials"&&a.clientId&&a.clientSecret){let d=e.read();try{let f=await $(d.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(),u=new graphqlRequest.GraphQLClient(g.globalEndpoint);u.setHeaders({Authorization:`Bearer ${a.accessToken}`});let p=`
|
|
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 f=(await
|
|
29
|
-
`)}function
|
|
28
|
+
`;try{let f=(await u.request(p,{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 u=await P(g.workspaceEndpoint,a.accessToken,a.workspaceId,a.organizationId);n.write({...a,workspaceToken:u.token,workspaceTokenExpiresAt:new Date(u.expiresAt).getTime()}),r=null;}catch{}}async function c(){n.isTokenExpiringSoon()&&await s(),n.read()?.workspaceToken&&n.isWorkspaceTokenExpiringSoon()&&await o();}return {workspace:{async request(a,g){await c();let{workspace:u}=r?{workspace:r}:i();return u.setHeaders(V(n.read(),e.resolveProductOrigin())),q(u,a,g)}},global:{async request(a,g){let{global:u}=t?{global:t}:i();return u.setHeaders(v(n.read())),q(u,a,g)}},workspaceAuthOnly:{async request(a,g){let u=e.read(),p=n.read(),d=new graphqlRequest.GraphQLClient(u.workspaceEndpoint),f=v(p),W=e.resolveProductOrigin();return W&&(f.Origin=W),d.setHeaders(f),q(d,a,g)}},reset(){r=null,t=null;}}}function N(){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 N()?"table":"json"}function D(e){console.log(JSON.stringify(e,null,2));}function Q(e,n){if(e.length===0)return;let r=e.map((s,o)=>{let c=s.length;for(let l of n){let m=l[o]??"";m.length>c&&(c=m.length);}return Math.min(c,50)}),t=r.map(s=>"-".repeat(s+2)).join("+"),i=s=>s.map((o,c)=>` ${(o??"").padEnd(r[c]??0)} `).join("|");console.log(i(e)),console.log(t);for(let s of n)console.log(i(s));}function _(e,n){let r=" ".repeat(n),t=[];for(let[i,s]of Object.entries(e))if(s==null)t.push(`${r}${i}: null`);else if(Array.isArray(s)){t.push(`${r}${i}:`);for(let o of s)typeof o=="object"&&o!==null?(t.push(`${r} -`),t.push(_(o,n+2))):t.push(`${r} - ${String(o)}`);}else typeof s=="object"?(t.push(`${r}${i}:`),t.push(_(s,n+1))):t.push(`${r}${i}: ${String(s)}`);return t.join(`
|
|
29
|
+
`)}function K(e){if(typeof e!="object"||e===null){console.log(String(e));return}console.log(_(e,0));}function Ce(e){process.stdout.write(e.endsWith(`
|
|
30
30
|
`)?e:`${e}
|
|
31
|
-
`);}function
|
|
31
|
+
`);}function be(e){console.log(`\u2713 ${e}`);}function X(e){console.error(`\u2717 ${e}`);}function Ee(e){console.warn(`! ${e}`);}function ve(e){console.log(`\u2139 ${e}`);}function Te(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(Y(e)){case "json":D(n);break;case "yaml":K(n);break;case "table":r?Q(r.headers,r.rows):D(n);break}}async function Se(e,n){return n?true:N()?new Promise(r=>{process.stdout.write(`${e} [y/N] `),process.stdin.setEncoding("utf8"),process.stdin.once("data",t=>{let i=t.trim().toLowerCase();r(i==="y"||i==="yes");}),process.stdin.resume();}):(X(`${e} Use --force to skip confirmation.`),false)}var G={isInteractive:N,getFormat:Y,formatAndOutput:Oe,printJson:D,printTable:Q,printYaml:K,printRaw:Ce,printSuccess:be,printError:X,printWarning:Ee,printInfo:ve,formatDate:Te,formatStatus:Ie,truncate:Ae,confirm:Se};function j(e={}){let{verbose:n=false,quiet:r=false}=e;return {debug(t,...i){n&&console.error(`[debug] ${t}`,...i);},info(t,...i){r||console.error(`[info] ${t}`,...i);},warn(t,...i){console.error(`[warn] ${t}`,...i);},error(t,...i){console.error(`[error] ${t}`,...i);}}}function Re(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=R(e.defaults),r=S(n.dir()),t=L(n,r),i=e.output??G,s=$e(e.logger)?e.logger:j(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:i,logger:s,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;}},C=class extends y{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 I=class extends w{constructor(n,r){super(`Module '${n}' declares dependency on '${r}', but '${r}' is not in the module list.`),this.name="MissingDependencyError";}},A=class extends w{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 w(`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 I(o.id,c);let r=[],t=new Set,i=new Set;function s(o,c){if(!i.has(o.id)){if(t.has(o.id))throw new A([...c,o.id]);t.add(o.id);for(let l of o.dependsOn??[]){let m=n.get(l);m&&s(m,[...c,o.id]);}t.delete(o.id),i.add(o.id),r.push(o);}}for(let o of e)s(o,[]);return r}function Le(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,c)=>{let l=t.opts().format;if(typeof l!="string")return;c.options.some(h=>h.attributeName()==="format")&&c.getOptionValue("format")===void 0&&c.setOptionValue("format",l);});let i=F(n);for(let o of i)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 s(o=process.argv){try{await t.parseAsync(o),o.length<=2&&t.outputHelp();}catch(
|
|
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 s(o=process.argv){try{await t.parseAsync(o),o.length<=2&&t.outputHelp();}catch(c){De(e,c);}}return {program:t,run:s}}function De(e,n){if(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(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=A;exports.CliAuthError=C;exports.CliInternalError=w;exports.CliUserError=y;exports.GqlRequestError=T;exports.KNOWN_CONFIG_KEYS=le;exports.MissingDependencyError=I;exports.buildContext=Pe;exports.clientCredentialsFlow=$;exports.createAuthStore=S;exports.createConfigStore=R;exports.createGqlClients=L;exports.createLogger=j;exports.createProgram=Le;exports.defaultOutputAdapter=G;exports.extractGqlErrorMessage=B;exports.fetchWorkspaces=ge;exports.issueWorkspaceToken=P;exports.openBrowser=me;exports.pollForToken=de;exports.sortModules=F;exports.startDeviceCodeFlow=pe;exports.toGqlRequestError=J;
|
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,
|
|
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-CLaW1ycq.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,
|
|
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-CLaW1ycq.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{
|
|
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-MT2F54AC.js';
|
|
@@ -70,6 +70,22 @@ interface GqlClients {
|
|
|
70
70
|
reset(): void;
|
|
71
71
|
}
|
|
72
72
|
declare function extractGqlErrorMessage(error: unknown): string;
|
|
73
|
+
interface GqlRequestErrorEntry {
|
|
74
|
+
message: string;
|
|
75
|
+
path?: Array<string | number>;
|
|
76
|
+
extensions?: Record<string, string | number | boolean | null>;
|
|
77
|
+
}
|
|
78
|
+
declare class GqlRequestError extends Error {
|
|
79
|
+
readonly response: {
|
|
80
|
+
status?: number;
|
|
81
|
+
errors?: GqlRequestErrorEntry[];
|
|
82
|
+
};
|
|
83
|
+
constructor(message: string, response: {
|
|
84
|
+
status?: number;
|
|
85
|
+
errors?: GqlRequestErrorEntry[];
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
declare function toGqlRequestError(error: unknown): Error;
|
|
73
89
|
declare function createGqlClients(config: ConfigStore, authStore: AuthStore): GqlClients;
|
|
74
90
|
|
|
75
91
|
type OutputFormat = 'json' | 'table' | 'yaml';
|
|
@@ -168,4 +184,4 @@ declare class CircularDependencyError extends CliInternalError {
|
|
|
168
184
|
}
|
|
169
185
|
declare function sortModules(modules: readonly CliModule[]): CliModule[];
|
|
170
186
|
|
|
171
|
-
export { type AuthStore as A, type BuildContextOptions as B, type CliModule as C, type Environment as E, type GqlClient as G, KNOWN_CONFIG_KEYS as K, type Logger as L, MissingDependencyError as M, type OutputAdapter as O, type ProductDefaults as P, type StoredAuth as S, type TableConfig as T, type CLIContext as a, type CLIConfig as b, CircularDependencyError as c, CliAuthError as d, CliInternalError as e, CliUserError as f, type ConfigStore as g, type GqlClients as h, type LoggerOptions as
|
|
187
|
+
export { type AuthStore as A, type BuildContextOptions as B, type CliModule as C, type Environment as E, type GqlClient as G, KNOWN_CONFIG_KEYS as K, type Logger as L, MissingDependencyError as M, type OutputAdapter as O, type ProductDefaults as P, type StoredAuth as S, type TableConfig as T, type CLIContext as a, type CLIConfig as b, CircularDependencyError as c, CliAuthError as d, CliInternalError as e, CliUserError as f, type ConfigStore as g, type GqlClients as h, GqlRequestError as i, type GqlRequestErrorEntry as j, type LoggerOptions as k, type OutputFormat as l, buildContext as m, createAuthStore as n, createConfigStore as o, createGqlClients as p, createLogger as q, defaultOutputAdapter as r, extractGqlErrorMessage as s, sortModules as t, toGqlRequestError as u };
|
|
@@ -70,6 +70,22 @@ interface GqlClients {
|
|
|
70
70
|
reset(): void;
|
|
71
71
|
}
|
|
72
72
|
declare function extractGqlErrorMessage(error: unknown): string;
|
|
73
|
+
interface GqlRequestErrorEntry {
|
|
74
|
+
message: string;
|
|
75
|
+
path?: Array<string | number>;
|
|
76
|
+
extensions?: Record<string, string | number | boolean | null>;
|
|
77
|
+
}
|
|
78
|
+
declare class GqlRequestError extends Error {
|
|
79
|
+
readonly response: {
|
|
80
|
+
status?: number;
|
|
81
|
+
errors?: GqlRequestErrorEntry[];
|
|
82
|
+
};
|
|
83
|
+
constructor(message: string, response: {
|
|
84
|
+
status?: number;
|
|
85
|
+
errors?: GqlRequestErrorEntry[];
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
declare function toGqlRequestError(error: unknown): Error;
|
|
73
89
|
declare function createGqlClients(config: ConfigStore, authStore: AuthStore): GqlClients;
|
|
74
90
|
|
|
75
91
|
type OutputFormat = 'json' | 'table' | 'yaml';
|
|
@@ -168,4 +184,4 @@ declare class CircularDependencyError extends CliInternalError {
|
|
|
168
184
|
}
|
|
169
185
|
declare function sortModules(modules: readonly CliModule[]): CliModule[];
|
|
170
186
|
|
|
171
|
-
export { type AuthStore as A, type BuildContextOptions as B, type CliModule as C, type Environment as E, type GqlClient as G, KNOWN_CONFIG_KEYS as K, type Logger as L, MissingDependencyError as M, type OutputAdapter as O, type ProductDefaults as P, type StoredAuth as S, type TableConfig as T, type CLIContext as a, type CLIConfig as b, CircularDependencyError as c, CliAuthError as d, CliInternalError as e, CliUserError as f, type ConfigStore as g, type GqlClients as h, type LoggerOptions as
|
|
187
|
+
export { type AuthStore as A, type BuildContextOptions as B, type CliModule as C, type Environment as E, type GqlClient as G, KNOWN_CONFIG_KEYS as K, type Logger as L, MissingDependencyError as M, type OutputAdapter as O, type ProductDefaults as P, type StoredAuth as S, type TableConfig as T, type CLIContext as a, type CLIConfig as b, CircularDependencyError as c, CliAuthError as d, CliInternalError as e, CliUserError as f, type ConfigStore as g, type GqlClients as h, GqlRequestError as i, type GqlRequestErrorEntry as j, type LoggerOptions as k, type OutputFormat as l, buildContext as m, createAuthStore as n, createConfigStore as o, createGqlClients as p, createLogger as q, defaultOutputAdapter as r, extractGqlErrorMessage as s, sortModules as t, toGqlRequestError as u };
|