@lakeql/cli 0.7.1 → 0.7.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/cli.mjs +1 -1
- package/package.json +5 -5
package/dist/cli.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import{a as e,c as t,i as n,l as r,n as i,o as a,r as o,s,t as c,u as l}from"./p
|
|
|
7
7
|
`);throw new M(`Validation failed for ${a}.`,{code:`ENDPOINT_DUPLICATE_FIELDS`,details:[e]})}console.log(`\n${p(`Loaded definition summary:`)}`),console.log(p(`tableName: ${l.tableName}`)),console.log(p(`catalog: ${l.catalog}`)),console.log(p(`schema: ${l.schema}`));let f=l.mutation?l.mutation.loadStrategy:`disabled`;console.log(p(`mutation: ${f}`)),console.log(`\n${p(`Fields:`)}`),console.log(p(q(l.fields))),console.log(``);let h=await F(n===process.cwd()?void 0:n),g=d.join(h,`schemas/custom`,l.catalog,l.schema,l.tableName);if(_(g)&&!i&&!await b(`Directory "${g}" already exists. Overwrite?`))throw N(`Aborted: endpoint generation was not confirmed.`);await Ye({definition:l,outputDir:g,skipRegistry:r,sourcePathOverride:n===process.cwd()?void 0:n}),console.log(m(`Endpoint generated successfully at: ${g}`))})}async function J(e){try{return(await te(e,{withFileTypes:!0})).filter(e=>e.isDirectory()).map(e=>e.name).toSorted()}catch{return[]}}async function Ze(e){let t=d.join(e,`schemas`,`generated`);if(!_(t))throw new M(`No generated schemas found at "${t}".`,{code:`GENERATE_IMPORT_CONFIG_NO_SCHEMAS`,hint:"Run `lakeql-cli pull` first to generate schemas.",exitCode:1});let n=await J(t);if(n.length===0)throw new M(`No catalogs found in "${t}".`,{code:`GENERATE_IMPORT_CONFIG_EMPTY`,hint:"Run `lakeql-cli pull` first to generate schemas.",exitCode:1});return(await Promise.all(n.map(async e=>{let n=d.join(t,e),r=await J(n);return(await Promise.all(r.map(async t=>{let r=await J(d.join(n,t));return r.length>0?{catalog:e,schema:t,tables:r}:null}))).filter(e=>e!==null)}))).flat()}function Qe(e){let t=[`/** @type {import('@lakeql/cli').BulkPullConfig} */`,`export default [`];for(let n of e){let e=JSON.stringify(n.tables,null,2).split(`
|
|
8
8
|
`).map((e,t)=>t===0?e:` ${e}`).join(`
|
|
9
9
|
`);t.push(` {`),t.push(` catalog: ${JSON.stringify(n.catalog)},`),t.push(` schema: ${JSON.stringify(n.schema)},`),t.push(` tables: ${e},`),t.push(` },`)}return t.push(`]`),t.push(``),t.join(`
|
|
10
|
-
`)}function $e(){let e=a();return e.action(async e=>{let{sourcePath:t,output:n,force:i}=e,a=Qe(await Ze(await F(t===(process.env.INIT_CWD??process.cwd())?void 0:t))),o=d.isAbsolute(n)?n:d.resolve(r(),n);if(!i&&_(o)&&(console.log(h(`File "${o}" already exists.`)),!await b(`Overwrite "${o}"?`)))throw N(`Aborted: import config generation was not confirmed.`);await ee(d.dirname(o),{recursive:!0}),await y(o,a,`utf-8`),console.log(m(`Written to "${o}".`))}),e}let et;function tt(){return me({runtimeEnv:process.env,server:{HIVE_CATALOG:A().min(1),HIVE_HOST:A(),HIVE_PASSWORD:A().min(1),HIVE_PORT:A().transform(e=>Number.parseInt(e,10)).pipe(_e()),HIVE_SOURCE:A().optional(),HIVE_USERNAME:A().min(1),LOG_LEVEL:ge([`info`,`warn`,`error`,`debug`]).default(`warn`)}})}function Y(){return et||=tt(),et}function nt(){let t=e();return t.action(async({catalog:e,schema:t,table:n})=>{let r=Y(),i=e??r.HIVE_CATALOG,a=new O({auth:{password:r.HIVE_PASSWORD,type:`basic`,username:r.HIVE_USERNAME},catalog:i,host:r.HIVE_HOST,port:r.HIVE_PORT}),o=t;if(o===void 0){let e;try{e=await a.schemas({catalog:i})}catch(e){throw P(`list schemas`,`list-columns (catalog=${i})`,e)}o=await x(`Choose a schema from the ${i} catalog`,{autocomplete:!0,choices:e})}let s=n;if(s===void 0){let e;try{e=await a.tables({catalog:i,schema:o})}catch(e){throw P(`list tables`,`list-columns (catalog=${i}, schema=${o})`,e)}s=await x(`Choose a table from "${i}.${o}"`,{autocomplete:!0,choices:e})}let c;try{c=await a.columns({catalog:i,schema:o,table:s})}catch(e){throw P(`list columns`,`list-columns (catalog=${i}, schema=${o}, table=${s})`,e)}let l=c.map(([e,t,n,r])=>({description:r,extra:n,name:e,type:t})),u=new k;u.column(`Column Name`,`name`),u.column(`Type`,`type`),u.column(`Extra`,`extra`),u.column(`Description`,`description`),u.render(l)}),t}function rt(){let e=n();return e.action(async({catalog:e})=>{let t=Y(),n=e??t.HIVE_CATALOG,r=new O({auth:{password:t.HIVE_PASSWORD,type:`basic`,username:t.HIVE_USERNAME},catalog:n,host:t.HIVE_HOST,port:t.HIVE_PORT}),i;try{i=await r.schemas({catalog:n})}catch(e){throw P(`list schemas`,`list-schemas (catalog=${n})`,e)}let a=new k;a.column(`Schema Name`,`s`),a.render(i.map(e=>({s:e})))}),e}function it(){let e=o();return e.action(async({catalog:e,schema:t})=>{let n=Y(),r=e??n.HIVE_CATALOG,i=new O({auth:{password:n.HIVE_PASSWORD,type:`basic`,username:n.HIVE_USERNAME},catalog:r,host:n.HIVE_HOST,port:n.HIVE_PORT}),a=t;if(a===void 0){let e;try{e=await i.schemas({catalog:r})}catch(e){throw P(`list schemas`,`list-tables (catalog=${r})`,e)}a=await x(`Choose a schema from the ${r} catalog`,{autocomplete:!0,choices:e})}let o;try{o=await i.tables({catalog:r,schema:a})}catch(e){throw P(`list tables`,`list-tables (catalog=${r}, schema=${a})`,e)}let s=new k;s.column(`Table Name`,`t`),s.render(o.map(e=>({t:e})))}),e}function at(){let e=i();return e.action(async({catalog:e,schema:t})=>{let n=Y(),r=e??n.HIVE_CATALOG,i=new O({auth:{password:n.HIVE_PASSWORD,type:`basic`,username:n.HIVE_USERNAME},catalog:r,host:n.HIVE_HOST,port:n.HIVE_PORT}),a=t;if(a===void 0){let e;try{e=await i.schemas({catalog:r})}catch(e){throw P(`list schemas`,`list-views (catalog=${r})`,e)}a=await x(`Choose a schema from the ${r} catalog`,{choices:e})}let o;try{o=await i.views({catalog:r,schema:a})}catch(e){throw P(`list views`,`list-views (catalog=${r}, schema=${a})`,e)}let s=new k;s.column(`View Name`,`v`),s.render(o.map(e=>({v:e})))}),e}const ot=j.object({schema:j.string().min(1),catalog:j.string().min(1).optional(),tables:j.array(j.string().min(1)).optional(),views:j.array(j.string().min(1)).optional()}).superRefine((e,t)=>{let n=Array.isArray(e.tables)&&e.tables.length>0,r=Array.isArray(e.views)&&e.views.length>0;!n&&!r&&t.addIssue({code:`custom`,message:`At least one non-empty list is required: tables or views.`,path:[`tables`]})}),st=j.array(ot);function X(e){return st.parse(e)}function ct(e){switch(e.replaceAll(/[^a-zA-Z]/gu,``)){case`varchar`:return`String`;case`decimal`:case`double`:case`float`:return`Float`;case`integer`:case`bigint`:return`Integer`;case`boolean`:return`Boolean`;case`timestamp`:return`DateTime`;case`date`:return`Date`;default:return`String`}}function lt(e,t){return typeof t==`string`?{name:e,type:ct(t)}:Array.isArray(t)?{name:e,type:`Array`,items:ut(t)}:typeof t==`object`&&t?{name:e,type:`Object`,fields:Z(t)}:{name:e,type:`String`}}function ut(e){if(e.length===0)return{type:`String`};let[t]=e;return typeof t==`string`?{type:ct(t)}:typeof t==`object`&&t&&!Array.isArray(t)?{type:`Object`,fields:Z(t)}:{type:`String`}}function Z(e){let t=[];for(let[n,r]of Object.entries(e))t.push(lt(n,r));return t}function dt(e){let{tableName:t,catalog:n,schema:r,parsedColumns:i}=e;return{version:`1.0`,tableName:t,catalog:n,schema:r,fields:Z(i),mutation:!1}}async function Q(e){let{trinoClient:t,catalog:n,schema:r,tables:i,resolvedTargetPath:a,skipRegistry:o,sourcePathOverride:s}=e;for(let e of i)await Ye({definition:dt({tableName:e,catalog:n,schema:r,parsedColumns:ye((await t.columns({catalog:n,schema:r,table:e})).map(e=>be({keys:[`name`,`type`,`extra`,`description`],values:e})))}),outputDir:d.join(a,`schemas/generated`,n,r,e),skipRegistry:o,sourcePathOverride:s})}async function ft(e){let t=r(),n;if(e){let r=d.isAbsolute(e)?e:d.resolve(t,e),i=d.parse(r);n=d.join(i.dir,i.name)}let{config:i}=await S({name:`import`,cwd:t,configFile:n,
|
|
10
|
+
`)}function $e(){let e=a();return e.action(async e=>{let{sourcePath:t,output:n,force:i}=e,a=Qe(await Ze(await F(t===(process.env.INIT_CWD??process.cwd())?void 0:t))),o=d.isAbsolute(n)?n:d.resolve(r(),n);if(!i&&_(o)&&(console.log(h(`File "${o}" already exists.`)),!await b(`Overwrite "${o}"?`)))throw N(`Aborted: import config generation was not confirmed.`);await ee(d.dirname(o),{recursive:!0}),await y(o,a,`utf-8`),console.log(m(`Written to "${o}".`))}),e}let et;function tt(){return me({runtimeEnv:process.env,server:{HIVE_CATALOG:A().min(1),HIVE_HOST:A(),HIVE_PASSWORD:A().min(1),HIVE_PORT:A().transform(e=>Number.parseInt(e,10)).pipe(_e()),HIVE_SOURCE:A().optional(),HIVE_USERNAME:A().min(1),LOG_LEVEL:ge([`info`,`warn`,`error`,`debug`]).default(`warn`)}})}function Y(){return et||=tt(),et}function nt(){let t=e();return t.action(async({catalog:e,schema:t,table:n})=>{let r=Y(),i=e??r.HIVE_CATALOG,a=new O({auth:{password:r.HIVE_PASSWORD,type:`basic`,username:r.HIVE_USERNAME},catalog:i,host:r.HIVE_HOST,port:r.HIVE_PORT}),o=t;if(o===void 0){let e;try{e=await a.schemas({catalog:i})}catch(e){throw P(`list schemas`,`list-columns (catalog=${i})`,e)}o=await x(`Choose a schema from the ${i} catalog`,{autocomplete:!0,choices:e})}let s=n;if(s===void 0){let e;try{e=await a.tables({catalog:i,schema:o})}catch(e){throw P(`list tables`,`list-columns (catalog=${i}, schema=${o})`,e)}s=await x(`Choose a table from "${i}.${o}"`,{autocomplete:!0,choices:e})}let c;try{c=await a.columns({catalog:i,schema:o,table:s})}catch(e){throw P(`list columns`,`list-columns (catalog=${i}, schema=${o}, table=${s})`,e)}let l=c.map(([e,t,n,r])=>({description:r,extra:n,name:e,type:t})),u=new k;u.column(`Column Name`,`name`),u.column(`Type`,`type`),u.column(`Extra`,`extra`),u.column(`Description`,`description`),u.render(l)}),t}function rt(){let e=n();return e.action(async({catalog:e})=>{let t=Y(),n=e??t.HIVE_CATALOG,r=new O({auth:{password:t.HIVE_PASSWORD,type:`basic`,username:t.HIVE_USERNAME},catalog:n,host:t.HIVE_HOST,port:t.HIVE_PORT}),i;try{i=await r.schemas({catalog:n})}catch(e){throw P(`list schemas`,`list-schemas (catalog=${n})`,e)}let a=new k;a.column(`Schema Name`,`s`),a.render(i.map(e=>({s:e})))}),e}function it(){let e=o();return e.action(async({catalog:e,schema:t})=>{let n=Y(),r=e??n.HIVE_CATALOG,i=new O({auth:{password:n.HIVE_PASSWORD,type:`basic`,username:n.HIVE_USERNAME},catalog:r,host:n.HIVE_HOST,port:n.HIVE_PORT}),a=t;if(a===void 0){let e;try{e=await i.schemas({catalog:r})}catch(e){throw P(`list schemas`,`list-tables (catalog=${r})`,e)}a=await x(`Choose a schema from the ${r} catalog`,{autocomplete:!0,choices:e})}let o;try{o=await i.tables({catalog:r,schema:a})}catch(e){throw P(`list tables`,`list-tables (catalog=${r}, schema=${a})`,e)}let s=new k;s.column(`Table Name`,`t`),s.render(o.map(e=>({t:e})))}),e}function at(){let e=i();return e.action(async({catalog:e,schema:t})=>{let n=Y(),r=e??n.HIVE_CATALOG,i=new O({auth:{password:n.HIVE_PASSWORD,type:`basic`,username:n.HIVE_USERNAME},catalog:r,host:n.HIVE_HOST,port:n.HIVE_PORT}),a=t;if(a===void 0){let e;try{e=await i.schemas({catalog:r})}catch(e){throw P(`list schemas`,`list-views (catalog=${r})`,e)}a=await x(`Choose a schema from the ${r} catalog`,{choices:e})}let o;try{o=await i.views({catalog:r,schema:a})}catch(e){throw P(`list views`,`list-views (catalog=${r}, schema=${a})`,e)}let s=new k;s.column(`View Name`,`v`),s.render(o.map(e=>({v:e})))}),e}const ot=j.object({schema:j.string().min(1),catalog:j.string().min(1).optional(),tables:j.array(j.string().min(1)).optional(),views:j.array(j.string().min(1)).optional()}).superRefine((e,t)=>{let n=Array.isArray(e.tables)&&e.tables.length>0,r=Array.isArray(e.views)&&e.views.length>0;!n&&!r&&t.addIssue({code:`custom`,message:`At least one non-empty list is required: tables or views.`,path:[`tables`]})}),st=j.array(ot);function X(e){return st.parse(e)}function ct(e){switch(e.replaceAll(/[^a-zA-Z]/gu,``)){case`varchar`:return`String`;case`decimal`:case`double`:case`float`:return`Float`;case`integer`:case`bigint`:return`Integer`;case`boolean`:return`Boolean`;case`timestamp`:return`DateTime`;case`date`:return`Date`;default:return`String`}}function lt(e,t){return typeof t==`string`?{name:e,type:ct(t)}:Array.isArray(t)?{name:e,type:`Array`,items:ut(t)}:typeof t==`object`&&t?{name:e,type:`Object`,fields:Z(t)}:{name:e,type:`String`}}function ut(e){if(e.length===0)return{type:`String`};let[t]=e;return typeof t==`string`?{type:ct(t)}:typeof t==`object`&&t&&!Array.isArray(t)?{type:`Object`,fields:Z(t)}:{type:`String`}}function Z(e){let t=[];for(let[n,r]of Object.entries(e))t.push(lt(n,r));return t}function dt(e){let{tableName:t,catalog:n,schema:r,parsedColumns:i}=e;return{version:`1.0`,tableName:t,catalog:n,schema:r,fields:Z(i),mutation:!1}}async function Q(e){let{trinoClient:t,catalog:n,schema:r,tables:i,resolvedTargetPath:a,skipRegistry:o,sourcePathOverride:s}=e;for(let e of i)await Ye({definition:dt({tableName:e,catalog:n,schema:r,parsedColumns:ye((await t.columns({catalog:n,schema:r,table:e})).map(e=>be({keys:[`name`,`type`,`extra`,`description`],values:e})))}),outputDir:d.join(a,`schemas/generated`,n,r,e),skipRegistry:o,sourcePathOverride:s})}async function ft(e){let t=r(),n;if(e){let r=d.isAbsolute(e)?e:d.resolve(t,e),i=d.parse(r);n=d.join(i.dir,i.name)}let{config:i}=await S({name:`import`,cwd:t,configFile:n,packageJson:!1,globalRc:!1,rcFile:!1,dotenv:!1}),a=i;return Array.isArray(a)?X(a):a&&typeof a==`object`&&`default`in a&&Array.isArray(a.default)?X(a.default):X([])}async function pt(e){let{configPath:t,catalog:n,sourcePathOverride:r,skipRegistry:i}=e,a=Y(),o=await F(r),s;try{s=await ft(t)}catch(e){throw e instanceof he?new M(`Invalid bulk pull config.`,{code:`BULK_CONFIG_INVALID`,details:e.issues.map(e=>` - ${e.path.length>0?e.path.join(`.`):`root`}: ${e.message}`),hint:`Ensure each entry defines a schema and at least one non-empty list: tables or views.`,cause:e}):e}if(s.length===0){console.log(p(`No entries found in bulk config.`));return}await new ve([{title:`Pull data`,task:(e,t)=>t.newListr(s.map(e=>{let t=n??e.catalog??a.HIVE_CATALOG,i=(e.tables?.length??0)+(e.views?.length??0);return{title:`${t}/${e.schema} — ${i} item(s)`,task:async(n,s)=>{let c=new O({auth:{password:a.HIVE_PASSWORD,type:`basic`,username:a.HIVE_USERNAME},catalog:t,host:a.HIVE_HOST,port:a.HIVE_PORT});if(e.tables&&e.tables.length>0){s.output=`Pulling ${e.tables.length} table(s)...`;try{await Q({trinoClient:c,catalog:t,schema:e.schema,tables:e.tables,resolvedTargetPath:o,skipRegistry:!0,sourcePathOverride:r})}catch(n){throw P(`pull tables`,`bulk pull (catalog=${t}, schema=${e.schema}, tables=${e.tables.join(`,`)})`,n)}}if(e.views&&e.views.length>0){s.output=`Pulling ${e.views.length} view(s)...`;try{await Q({trinoClient:c,catalog:t,schema:e.schema,tables:e.views,resolvedTargetPath:o,skipRegistry:!0,sourcePathOverride:r})}catch(n){throw P(`pull views`,`bulk pull (catalog=${t}, schema=${e.schema}, views=${e.views.join(`,`)})`,n)}}s.title=`${t}/${e.schema} — ${i} item(s) pulled`}}}),{concurrent:!0,exitOnError:!1})},{title:`Create registry`,enabled:!i,task:async()=>{await I(r)}}],{concurrent:!1,exitOnError:!0}).run()}async function mt(e,t,n){try{return await n()}catch(n){throw P(e,t,n)}}function ht(){let e=c();return e.action(async e=>{let{skipRegistry:t,sourcePath:n,bulk:r,bulkConfig:i}=e,a=n===(process.env.INIT_CWD??process.cwd())?void 0:n;if(r){await pt({configPath:i,catalog:e.catalog,sourcePathOverride:a,skipRegistry:t});return}let o=Y(),s=e.catalog??o.HIVE_CATALOG,{schema:c,table:l,type:u}=e,d=await F(a),f=new O({auth:{password:o.HIVE_PASSWORD,type:`basic`,username:o.HIVE_USERNAME},catalog:s,host:o.HIVE_HOST,port:o.HIVE_PORT});if(!c){let e=await mt(`list schemas`,`pull (catalog=${s})`,()=>f.schemas({catalog:s}));c=await x(`Choose a schema from the ${s} catalog`,{autocomplete:!0,choices:e})}if(l.length===0&&(u??=await x(`What do you want to see from ${s}/${c}`,{choices:[{label:`Show tables`,value:`tables`},{label:`Show views`,value:`views`}]})),l.length===0){u??=`tables`;let e=[];if(e=await mt(u===`views`?`list views`:`list tables`,`pull (catalog=${s}, schema=${c})`,()=>u===`views`?f.views({catalog:s,schema:c}):f.tables({catalog:s,schema:c})),e.length===0)throw new M(`No ${u} found in schema '${s}.${c}'.`,{code:`PULL_NO_RESULTS`,hint:`Use a different schema or check permissions for '${s}.${c}'.`,exitCode:0});l=await re(`Choose the ${u} to pull`,{autocomplete:!0,choices:e,validators:[ae.required()]})}console.log(p(`Pulling ${l.length} item(s) from ${s}.${c} into ${d}/schemas/generated...`));let h=l.length>10;await new ve([{title:`Pull ${l.length} item(s)`,task:async(e,t)=>{if(!h)return t.newListr(l.map(e=>({title:`${s}.${c}.${e}`,task:async()=>{await Q({trinoClient:f,catalog:s,schema:c,tables:[e],resolvedTargetPath:d,skipRegistry:!0,sourcePathOverride:a})}})),{concurrent:!1,exitOnError:!0});let n=[...l],r=new Set,i=0,o=Math.min(8,l.length),u=()=>{let e=[...r].slice(0,5).map(e=>` - ${s}.${c}.${e}`).join(`
|
|
11
11
|
`),n=r.size>5?`\n ... +${r.size-5} more active`:``;t.output=`Completed ${i}/${l.length} | Active ${r.size}/${o}${e?`\n${e}${n}`:``}`};u();let p=async()=>{for(;n.length>0;){let e=n.shift();if(!e)return;r.add(e),u(),await Q({trinoClient:f,catalog:s,schema:c,tables:[e],resolvedTargetPath:d,skipRegistry:!0,sourcePathOverride:a}),r.delete(e),i+=1,u()}};await Promise.all(Array.from({length:o},()=>p())),t.output=`Completed ${i}/${l.length}`}},{title:`Create registry`,enabled:!t,task:async()=>{await I(a)}}],{concurrent:!1,exitOnError:!0}).run(),console.log(m(`Pull completed: ${l.length} item(s) generated under ${d}/schemas/generated/${s}/${c}`))}),e}const gt=[`lakeql.config.mjs`,`lakeql.config.ts`,`lakeql.config.json`];function _t(e){return`/** @type {import('@lakeql/cli').LakeQLConfig} */\nexport default {\n${Object.entries(e).map(([e,t])=>` ${e}: ${JSON.stringify(t)},`).join(`
|
|
12
12
|
`)}\n}\n`}function vt(e){for(let t of gt)if(_(d.join(e,t)))return t;return null}function yt(){return l().action(async()=>{let e=r(),t=vt(e);if(t&&await x(`${t} already exists. Overwrite?`,{choices:[{label:`Yes`,value:`yes`},{label:`No`,value:`no`}]})===`no`){console.log(p(`Aborted.`));return}let n=await x(`Config format:`,{choices:[{label:`lakeql.config.mjs (recommended)`,value:`mjs`},{label:`lakeql.config.json`,value:`json`}]}),i=_(d.join(e,`src`)),a;if(i)a=`src`,console.log(p(`Detected src/ directory - generated code will be placed in src/`));else{let e=await x(`Where should generated code be placed?`,{choices:[{label:`./ (project root)`,value:`.`},{label:`Custom path`,value:`__custom__`}]});a=e,e===`__custom__`&&(a=await ie(`Enter the source path (relative to project root):`,{defaultValue:`.`}))}let o={sourcePath:a},s=n===`mjs`?`lakeql.config.mjs`:`lakeql.config.json`,c=d.join(e,s);await y(c,n===`mjs`?_t(o):`${JSON.stringify(o,null,2)}\n`),console.log(m(`Created ${s} at ${c}`))})}function bt(e){let t=new u;return t.configureHelp({sortSubcommands:!0}),t.name(`lakeql-cli`).description(`LakeQL CLI`).version(e.version).addCommand(rt()).addCommand(it()).addCommand(at()).addCommand(nt()).addCommand(ht()).addCommand(Xe()).addCommand(Oe()).addCommand($e()).addCommand(yt()),t}async function xt(e=process.argv.slice(2),t){let n=bt(t??await g());return e.length===0?(n.outputHelp(),0):(await n.parseAsync(e,{from:`user`}),0)}function $(e){if(!(typeof e!=`object`||!e))return e}function St(e){let t=$(e),n=t?.message;for(;t?.cause;){let e=$(t.cause);if(!e)break;e.message&&(n=e.message),t=e}return n}function Ct(e){if(e instanceof M&&e.code)return e.code;let t=$(e);return t?.code?t.code:$(t?.cause)?.code}function wt(e){if(e instanceof M&&e.hint)return e.hint;let t=St(e)?.toLowerCase()??``,n=Ct(e);if(t.includes(`fetch failed`)||n===`ECONNREFUSED`||n===`ENOTFOUND`||n===`ETIMEDOUT`)return`Could not reach Trino. Verify HIVE_HOST/HIVE_PORT and that the Trino endpoint is reachable from your network.`;if(t.includes(`invalid environment variables`)||t.includes(`required`))return`Missing or invalid environment variables. Set HIVE_HOST, HIVE_PORT, HIVE_USERNAME, HIVE_PASSWORD and HIVE_CATALOG.`}function Tt(e){let t=[e instanceof M&&e.exitCode===0?`LakeQL CLI aborted.`:`LakeQL CLI failed.`],n=e instanceof Error?e.message:typeof e==`string`?e:`Unknown error`;t.push(`Reason: ${n}`),e instanceof M&&e.details?.length&&t.push(...e.details);let r=St(e);r&&r!==n&&t.push(`Root cause: ${r}`);let i=Ct(e);i&&t.push(`Error code: ${i}`);let a=wt(e);return a&&t.push(`Hint: ${a}`),t}xt().catch(e=>{let t=xe(e)?N():e,n=Tt(t),r=t instanceof M&&t.exitCode===0?h:f,i=n.map((e,t)=>t===0?r(e):p(e)).join(`
|
|
13
13
|
`);console.error(i);let a=t instanceof M?t.exitCode:1;process.exit(a)});export{};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lakeql/cli",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.2",
|
|
4
4
|
"description": "CLI for introspecting Trino schemas and generating type-safe GraphQL endpoints",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -62,13 +62,13 @@
|
|
|
62
62
|
"lodash-es": "4.18.1",
|
|
63
63
|
"read-pkg": "10.1.0",
|
|
64
64
|
"zod": "4.4.3",
|
|
65
|
-
"@lakeql/file-generator": "0.1.9",
|
|
66
65
|
"@lakeql/column-parser": "0.1.4",
|
|
67
|
-
"@lakeql/helpers": "0.1.4",
|
|
68
66
|
"@lakeql/logger": "0.2.1",
|
|
69
|
-
"@lakeql/
|
|
67
|
+
"@lakeql/response-transformer": "0.1.4",
|
|
70
68
|
"@lakeql/trino-client": "0.4.0",
|
|
71
|
-
"@lakeql/
|
|
69
|
+
"@lakeql/schema-generator": "0.4.3",
|
|
70
|
+
"@lakeql/file-generator": "0.1.9",
|
|
71
|
+
"@lakeql/helpers": "0.1.4"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
74
|
"@types/lodash-es": "4.17.12",
|