@lakeql/cli 0.2.4 → 0.4.0

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 CHANGED
@@ -1,9 +1,10 @@
1
1
  #!/usr/bin/env node
2
- import{Command as e,Option as t}from"@commander-js/extra-typings";import{readPackage as n}from"read-pkg";import{existsSync as r,readFileSync as i}from"node:fs";import{mkdir as a,readFile as o,rm as s,writeFile as c}from"node:fs/promises";import l from"node:path";import{generateCode as u}from"@lakeql/file-generator";import{generateConfig as d}from"@lakeql/file-generator/config";import{generateInterface as f}from"@lakeql/file-generator/interface";import{generateQuerySchema as ee}from"@lakeql/file-generator/query-schema";import{generateModel as p}from"@lakeql/schema-generator/graphql-schema";import{generateJsonSchemaFromFields as m}from"@lakeql/schema-generator/json-schema";import{generateConfigReqistry as h}from"@lakeql/file-generator/config-registry";import{globby as g}from"globby";import{camelCase as _,upperFirst as v}from"lodash-es";import y from"typescript";import{endpointDefinitionSchema as b,findDuplicateFieldNames as x}from"@lakeql/schema-generator/endpoint-schema";import{TrinoClient as S}from"@lakeql/trino-client";import{multiselect as C,question as w,select as T,validators as E}from"@topcli/prompts";import{ClimtTable as D}from"climt";import{createEnv as O}from"@t3-oss/env-core";import k from"dotenv";import{enum as te,number as ne,string as A}from"zod/v4";import{parseColumns as j}from"@lakeql/column-parser";import{error as M}from"@lakeql/logger/console";import{convertTrinoResponse as re}from"@lakeql/response-transformer";import N from"kleur";function P(e,t=0){let n=[],r=` `.repeat(t+1);for(let i of e)if(i.type===`Object`)n.push(`${r}${i.name}: Object`),i.fields&&n.push(P(i.fields,t+1));else if(i.type===`Array`){let e=i.items?.type??`Unknown`;n.push(`${r}${i.name}: Array<${e}>`),i.items?.type===`Object`&&i.items.fields&&n.push(P(i.items.fields,t+1))}else n.push(`${r}${i.name}: ${i.type}`);return n.filter(e=>e.length>0).join(`
3
- `)}function F(){return process.env.INIT_CWD??process.cwd()}const I=`lakeql.config.json`,ie={sourcePath:`.`};function ae(){let e=l.join(F(),I);if(!r(e))return ie;let t=i(e,`utf-8`),n=JSON.parse(t);return{...ie,...n}}function L(e){let t=ae(),n=F(),r=e??t.sourcePath;return l.isAbsolute(r)?r:l.resolve(n,r)}const R=new t(`--catalog <catalog>`,`catalog to use`).env(`HIVE_CATALOG`),z=new t(`--schema <schema>`,`schema to use`),oe=new t(`--table <table>`,`table to use`),se=new t(`--type <type>`,`Show tables or views`),B=new t(`--source-path <path>`,"Base path for generated code (resolved from the command invocation directory). Files are created in `schemas/generated|custom` inside this path.").default(F(),`command invocation directory`),ce=new t(`--skip-registry`,`Skip config registry generation`).default(!1);function le(){return new e(`create-registry`).description("Generates the config registry to ensure the type-safety while using `createPermission`").addOption(B).action(async({sourcePath:e})=>{await V(e!==process.env.INIT_CWD&&e!==process.cwd()?e:void 0)})}async function V(e){let t=L(e),n=await u({fileName:`config-registry.ts`,nodes:h({configPaths:(await g(`schemas/**/config.ts`,{cwd:t,onlyFiles:!0})).map(e=>{let t=l.parse(e);return l.join(t.dir,t.name)})})});r(l.join(t,`config-registry.ts`))&&await s(l.join(t,`config-registry.ts`),{force:!0,recursive:!0}),await c(l.join(t,`config-registry.ts`),n.text)}function ue(e,t){return{baseClassName:`${v(_(e))}_${v(_(t))}`,queryName:`${_(e)}${v(_(t))}`,mutationName:`create${_(e)}${v(_(t))}`}}const{factory:H}=y;function U(e){return H.createIdentifier(e)}function W(e){return U(e)}function G(e){return H.createStringLiteral(e)}function K(e,t){return H.createPropertyAssignment(U(e),t)}function q(e,t=!0){return H.createObjectLiteralExpression(e,t)}function de(e){return e?H.createTrue():H.createFalse()}function fe(e){return H.createParameterDeclaration(void 0,void 0,U(e))}function pe(e,t,n){return H.createArrowFunction(n?.async?[H.createToken(y.SyntaxKind.AsyncKeyword)]:void 0,void 0,e.map(e=>typeof e==`string`?fe(e):e),void 0,H.createToken(y.SyntaxKind.EqualsGreaterThanToken),t)}function me(e){return H.createParenthesizedExpression(e)}function he(e,t=!0){return pe([`t`],me(q(e,t)))}function J(e,t){return H.createPropertyAccessExpression(typeof e==`string`?U(e):e,U(t))}function ge(e,t=[],n){return H.createCallExpression(e,n,t)}function Y(e,t,n=[],r){return ge(J(e,t),n,r)}function _e(e,t=[],n){return Y(`builder`,e,t,n)}function ve(e,t){return H.createVariableStatement(void 0,H.createVariableDeclarationList([H.createVariableDeclaration(U(e),void 0,void 0,t)],y.NodeFlags.Const))}function X(e,t,n){return H.createImportDeclaration(void 0,H.createImportClause(n?.typeOnly??!1,void 0,H.createNamedImports(t.map(e=>H.createImportSpecifier(!1,void 0,U(e))))),G(e))}function ye(e,t,n){return H.createImportDeclaration(void 0,H.createImportClause(n?.typeOnly??!1,U(t),void 0),G(e))}function be({models:e,mutationName:t,mutationConfig:n,hasValidations:r,fieldDefinitions:i}){if(!n)return[];let a=Object.values(e).find(e=>e.root);if(!a)return[];let o=xe(i),s=Object.values(e).filter(e=>!e.root);return[...Se(r),...s.map(t=>Ce(t,e,o)),Ce(a,e,o),De(t,a,n,r)]}function xe(e){let t=new Map;if(!e)return t;for(let n of e){let e=n.options?.required===!0;t.set(n.name,e)}return t}function Se(e){let t=[X(`@lakeql/adapters`,[`executeWritePipeline`]),X(`@lakeql/trino-client`,[`TrinoClient`]),X(`@lakeql/api/builder`,[`builder`]),X(`~/env`,[`env`]),X(`./config`,[`hiveConfig`]),ye(`./json-schema.json`,`jsonSchema`)];return e&&t.push(X(`./validations`,[`validationSchema`])),t}function Ce(e,t,n){let r=`${e.modelName}Input`,i=Object.values(e.fields).map(e=>we(e,t,n));return ve(r,_e(`inputType`,[G(r),q([K(`fields`,he(i))])]))}function we(e,t,n){let r=K(`required`,de(n.get(e.name)??!0));if(e.isArray){let t=e.graphqlType.replace(/^\[/u,``).replace(/\]$/u,``),n=Ee(t);if(n)return K(e.name,Y(`t`,n,[q([r],!1)]));let i=`${t}Input`;return K(e.name,Y(`t`,`field`,[q([K(`type`,y.factory.createArrayLiteralExpression([W(i)])),r],!1)]))}let i=Te(e.graphqlType);if(i)return K(e.name,Y(`t`,i,[q([r],!1)]));if(Object.keys(t).includes(e.graphqlType)){let t=`${e.graphqlType}Input`;return K(e.name,Y(`t`,`field`,[q([K(`type`,W(t)),r],!1)]))}return K(e.name,Y(`t`,`string`,[q([r],!1)]))}function Te(e){switch(e){case`String`:return`string`;case`Int`:return`int`;case`Float`:return`float`;case`Boolean`:return`boolean`;default:return}}function Ee(e){switch(e){case`String`:return`stringList`;case`Int`:return`intList`;case`Float`:return`floatList`;case`Boolean`:return`booleanList`;default:return}}function De(e,t,n,r){let i=`${t.modelName}Input`,a=[];r&&a.push(y.factory.createExpressionStatement(Y(`validationSchema`,`parse`,[W(`input`)]))),a.push(y.factory.createVariableStatement(void 0,y.factory.createVariableDeclarationList([y.factory.createVariableDeclaration(W(`trinoClient`),void 0,void 0,y.factory.createNewExpression(W(`TrinoClient`),void 0,[q([K(`host`,J(`env`,`HIVE_HOST`)),K(`port`,J(`env`,`HIVE_PORT`)),K(`auth`,q([K(`type`,G(`basic`)),K(`username`,J(`env`,`HIVE_USERNAME`)),K(`password`,J(`env`,`HIVE_PASSWORD`))],!1)),K(`catalog`,J(`env`,`HIVE_CATALOG`)),K(`source`,J(`env`,`HIVE_SOURCE`))])]))],y.NodeFlags.Const)));let o=y.factory.createAwaitExpression(ge(W(`executeWritePipeline`),[q([K(`records`,W(`input`)),K(`jsonSchema`,y.factory.createAsExpression(W(`jsonSchema`),y.factory.createKeywordTypeNode(y.SyntaxKind.AnyKeyword))),K(`config`,q([K(`loadStrategy`,G(n.loadStrategy)),K(`basePath`,G(n.basePath)),K(`s3`,q([K(`bucket`,J(`env`,`S3_BUCKET`)),K(`region`,J(`env`,`S3_REGION`)),K(`endpoint`,J(`env`,`S3_ENDPOINT`)),K(`credentials`,q([K(`accessKeyId`,J(`env`,`S3_ACCESS_KEY_ID`)),K(`secretAccessKey`,J(`env`,`S3_SECRET_ACCESS_KEY`))],!1))])),K(`table`,q([K(`catalog`,J(`hiveConfig`,`catalog`)),K(`schema`,J(`hiveConfig`,`schema`)),K(`tableName`,J(`hiveConfig`,`tableName`))],!1)),K(`trinoClient`,W(`trinoClient`))]))])]));a.push(y.factory.createExpressionStatement(o)),a.push(y.factory.createReturnStatement(y.factory.createTrue()));let s=y.factory.createBlock(a,!0),c=pe([fe(`_root`),y.factory.createParameterDeclaration(void 0,void 0,y.factory.createObjectBindingPattern([y.factory.createBindingElement(void 0,void 0,y.factory.createIdentifier(`input`))]))],s,{async:!0}),l=K(e,Y(`t`,`boolean`,[q([K(`args`,q([K(`input`,Y(`t`,`arg`,[q([K(`type`,W(i)),K(`required`,de(!0))],!1)]))],!1)),K(`resolve`,c)])]));return y.factory.createExpressionStatement(_e(`mutationFields`,[he([l])]))}function Z(e){if(typeof e!=`object`||!e)return e;if(Array.isArray(e))return e.map(Z);let t={},n=Object.keys(e).toSorted();for(let r of n)t[r]=Z(e[r]);return t}function Oe(e){let t=Z(e);return`${JSON.stringify(t,null,2).replaceAll(`\r
2
+ import{Command as e,Option as t}from"@commander-js/extra-typings";import{readPackage as n}from"read-pkg";import{existsSync as r}from"node:fs";import{mkdir as i,readFile as a,rm as o,writeFile as s}from"node:fs/promises";import c from"node:path";import{confirm as l,multiselect as u,question as d,select as f,validators as p}from"@topcli/prompts";import{loadConfig as m}from"c12";import{generateCode as h}from"@lakeql/file-generator";import{generateConfig as g}from"@lakeql/file-generator/config";import{generateInterface as _}from"@lakeql/file-generator/interface";import{generateQuerySchema as ee}from"@lakeql/file-generator/query-schema";import{generateModel as te}from"@lakeql/schema-generator/graphql-schema";import{generateJsonSchemaFromFields as ne}from"@lakeql/schema-generator/json-schema";import{generateConfigReqistry as v}from"@lakeql/file-generator/config-registry";import{globby as y}from"globby";import{camelCase as b,upperFirst as x}from"lodash-es";import S from"typescript";import{endpointDefinitionSchema as C,findDuplicateFieldNames as re}from"@lakeql/schema-generator/endpoint-schema";import{TrinoClient as w}from"@lakeql/trino-client";import{ClimtTable as T}from"climt";import{createEnv as E}from"@t3-oss/env-core";import D from"dotenv";import{enum as O,number as ie,string as k}from"zod/v4";import{error as A}from"@lakeql/logger/console";import{Listr as ae}from"listr2";import{parseColumns as oe}from"@lakeql/column-parser";import{convertTrinoResponse as j}from"@lakeql/response-transformer";import M from"kleur";function N(e,t=0){let n=[],r=` `.repeat(t+1);for(let i of e)if(i.type===`Object`)n.push(`${r}${i.name}: Object`),i.fields&&n.push(N(i.fields,t+1));else if(i.type===`Array`){let e=i.items?.type??`Unknown`;n.push(`${r}${i.name}: Array<${e}>`),i.items?.type===`Object`&&i.items.fields&&n.push(N(i.items.fields,t+1))}else n.push(`${r}${i.name}: ${i.type}`);return n.filter(e=>e.length>0).join(`
3
+ `)}function P(){return process.env.INIT_CWD??process.cwd()}const se={sourcePath:`.`};async function ce(){let{config:e}=await m({name:`lakeql`,cwd:P(),defaults:se,packageJson:!1,globalRc:!1,rcFile:!1,dotenv:!1});return e}async function F(e){let t=await ce(),n=P(),r=e??t.sourcePath;return c.isAbsolute(r)?r:c.resolve(n,r)}const I=new t(`--catalog <catalog>`,`catalog to use`).env(`HIVE_CATALOG`),L=new t(`--schema <schema>`,`schema to use`),le=new t(`--table <table>`,`table to use`),ue=new t(`--type <type>`,`Show tables or views`),R=new t(`--source-path <path>`,"Base path for generated code (resolved from the command invocation directory). Files are created in `schemas/generated|custom` inside this path.").default(P(),`command invocation directory`),de=new t(`--skip-registry`,`Skip config registry generation`).default(!1);function fe(){return new e(`create-registry`).description("Generates the config registry to ensure the type-safety while using `createPermission`").addOption(R).action(async({sourcePath:e})=>{await z(e!==process.env.INIT_CWD&&e!==process.cwd()?e:void 0)})}async function z(e){let t=await F(e),n=await h({fileName:`config-registry.ts`,nodes:v({configPaths:(await y(`schemas/**/config.ts`,{cwd:t,onlyFiles:!0})).map(e=>{let t=c.parse(e);return c.join(t.dir,t.name)})})});r(c.join(t,`config-registry.ts`))&&await o(c.join(t,`config-registry.ts`),{force:!0,recursive:!0}),await s(c.join(t,`config-registry.ts`),n.text)}function pe(e,t){return{baseClassName:`${x(b(e))}_${x(b(t))}`,queryName:`${b(e)}${x(b(t))}`,mutationName:`create${b(e)}${x(b(t))}`}}const{factory:B}=S;function V(e){return B.createIdentifier(e)}function H(e){return V(e)}function U(e){return B.createStringLiteral(e)}function W(e,t){return B.createPropertyAssignment(V(e),t)}function G(e,t=!0){return B.createObjectLiteralExpression(e,t)}function me(e){return e?B.createTrue():B.createFalse()}function he(e){return B.createParameterDeclaration(void 0,void 0,V(e))}function K(e,t,n){return B.createArrowFunction(n?.async?[B.createToken(S.SyntaxKind.AsyncKeyword)]:void 0,void 0,e.map(e=>typeof e==`string`?he(e):e),void 0,B.createToken(S.SyntaxKind.EqualsGreaterThanToken),t)}function ge(e){return B.createParenthesizedExpression(e)}function _e(e,t=!0){return K([`t`],ge(G(e,t)))}function q(e,t){return B.createPropertyAccessExpression(typeof e==`string`?V(e):e,V(t))}function ve(e,t=[],n){return B.createCallExpression(e,n,t)}function J(e,t,n=[],r){return ve(q(e,t),n,r)}function ye(e,t=[],n){return J(`builder`,e,t,n)}function be(e,t){return B.createVariableStatement(void 0,B.createVariableDeclarationList([B.createVariableDeclaration(V(e),void 0,void 0,t)],S.NodeFlags.Const))}function Y(e,t,n){return B.createImportDeclaration(void 0,B.createImportClause(n?.typeOnly??!1,void 0,B.createNamedImports(t.map(e=>B.createImportSpecifier(!1,void 0,V(e))))),U(e))}function xe(e,t,n){return B.createImportDeclaration(void 0,B.createImportClause(n?.typeOnly??!1,V(t),void 0),U(e))}function Se({models:e,mutationName:t,mutationConfig:n,hasValidations:r,fieldDefinitions:i}){if(!n)return[];let a=Object.values(e).find(e=>e.root);if(!a)return[];let o=Ce(i),s=Object.values(e).filter(e=>!e.root);return[...we(r),...s.map(t=>Te(t,e,o)),Te(a,e,o),ke(t,a,r)]}function Ce(e){let t=new Map;if(!e)return t;for(let n of e){let e=n.options?.required===!0;t.set(n.name,e)}return t}function we(e){let t=[Y(`@lakeql/adapters`,[`executeWritePipeline`]),Y(`@lakeql/trino-client`,[`TrinoClient`]),Y(`@lakeql/api/builder`,[`builder`]),Y(`~/env`,[`env`]),Y(`./config`,[`hiveConfig`,`storageConfig`]),xe(`./json-schema.json`,`jsonSchema`)];return e&&t.push(Y(`./validations`,[`validationSchema`])),t}function Te(e,t,n){let r=`${e.modelName}Input`,i=Object.values(e.fields).map(e=>Ee(e,t,n));return be(r,ye(`inputType`,[U(r),G([W(`fields`,_e(i))])]))}function Ee(e,t,n){let r=W(`required`,me(n.get(e.name)??!0));if(e.isArray){let t=e.graphqlType.replace(/^\[/u,``).replace(/\]$/u,``),n=Oe(t);if(n)return W(e.name,J(`t`,n,[G([r],!1)]));let i=`${t}Input`;return W(e.name,J(`t`,`field`,[G([W(`type`,S.factory.createArrayLiteralExpression([H(i)])),r],!1)]))}let i=De(e.graphqlType);if(i)return W(e.name,J(`t`,i,[G([r],!1)]));if(Object.keys(t).includes(e.graphqlType)){let t=`${e.graphqlType}Input`;return W(e.name,J(`t`,`field`,[G([W(`type`,H(t)),r],!1)]))}return W(e.name,J(`t`,`string`,[G([r],!1)]))}function De(e){switch(e){case`String`:return`string`;case`Int`:return`int`;case`Float`:return`float`;case`Boolean`:return`boolean`;default:return}}function Oe(e){switch(e){case`String`:return`stringList`;case`Int`:return`intList`;case`Float`:return`floatList`;case`Boolean`:return`booleanList`;default:return}}function ke(e,t,n){let r=`${t.modelName}Input`,i=[];n&&i.push(S.factory.createExpressionStatement(J(`validationSchema`,`parse`,[H(`input`)]))),i.push(S.factory.createVariableStatement(void 0,S.factory.createVariableDeclarationList([S.factory.createVariableDeclaration(H(`trinoClient`),void 0,void 0,S.factory.createNewExpression(H(`TrinoClient`),void 0,[G([W(`host`,q(`env`,`HIVE_HOST`)),W(`port`,q(`env`,`HIVE_PORT`)),W(`auth`,G([W(`type`,U(`basic`)),W(`username`,q(`env`,`HIVE_USERNAME`)),W(`password`,q(`env`,`HIVE_PASSWORD`))],!1)),W(`catalog`,q(`env`,`HIVE_CATALOG`)),W(`source`,q(`env`,`HIVE_SOURCE`))])]))],S.NodeFlags.Const)));let a=S.factory.createAwaitExpression(ve(H(`executeWritePipeline`),[G([W(`records`,H(`input`)),W(`jsonSchema`,S.factory.createAsExpression(H(`jsonSchema`),S.factory.createKeywordTypeNode(S.SyntaxKind.AnyKeyword))),W(`config`,G([W(`loadStrategy`,q(`storageConfig`,`loadStrategy`)),W(`bucket`,q(`storageConfig`,`bucket`)),W(`basePath`,q(`storageConfig`,`basePath`)),W(`table`,G([W(`catalog`,q(`hiveConfig`,`catalog`)),W(`schema`,q(`hiveConfig`,`schema`)),W(`tableName`,q(`hiveConfig`,`tableName`))],!1)),W(`trinoClient`,H(`trinoClient`))]))])]));i.push(S.factory.createExpressionStatement(a)),i.push(S.factory.createReturnStatement(S.factory.createTrue()));let o=S.factory.createBlock(i,!0),s=K([he(`_root`),S.factory.createParameterDeclaration(void 0,void 0,S.factory.createObjectBindingPattern([S.factory.createBindingElement(void 0,void 0,S.factory.createIdentifier(`input`))]))],o,{async:!0}),c=W(e,J(`t`,`boolean`,[G([W(`args`,G([W(`input`,J(`t`,`arg`,[G([W(`type`,H(r)),W(`required`,me(!0))],!1)]))],!1)),W(`resolve`,s)])]));return S.factory.createExpressionStatement(ye(`mutationFields`,[_e([c])]))}function X(e){if(typeof e!=`object`||!e)return e;if(Array.isArray(e))return e.map(X);let t={},n=Object.keys(e).toSorted();for(let r of n)t[r]=X(e[r]);return t}function Ae(e){let t=X(e);return`${JSON.stringify(t,null,2).replaceAll(`\r
4
4
  `,`
5
- `)}\n`}async function ke(e){let{definition:t,outputDir:n,skipRegistry:i,sourcePathOverride:o}=e,{catalog:h,schema:g,tableName:_,fields:v}=t,{baseClassName:y,queryName:b,mutationName:x}=ue(g,_),S=m(v),C=p({isRoot:!0,models:{},name:y,source:S}),w=Object.values(C).find(e=>e.root===!0),T=w?.fields?Object.values(w.fields).filter(e=>e.filter===!0).map(e=>({name:e.name,type:e.graphqlType})):[],E=[...new Set(T.map(e=>e.type))],D=[...new Set(Object.values(C).filter(e=>e.transformFields.length>0).flatMap(e=>e.transformFields))],O=[...new Set(Object.values(C).filter(e=>e.dateTimeFields.length>0).flatMap(e=>e.dateTimeFields))],k=await u({fileName:`config.ts`,nodes:d({catalog:h,queryName:b,schema:g,tableName:_,mutationName:[x]})}),te=await u({fileName:`interface.ts`,nodes:f(C)}),ne=await u({fileName:`query-schema.ts`,nodes:ee({dateTimeFields:O,filterFields:T,filterTypes:E,models:C,queryName:b,transformFields:D})}),A=v.some(e=>e.options?.validations&&e.options.validations.length>0),j=be({models:C,mutationName:x,mutationConfig:t.mutation,hasValidations:A,fieldDefinitions:v}),M=``;j.length>0&&(M=(await u({fileName:`mutation-schema.ts`,nodes:j})).text);let re=Oe(S),N=Oe(t),P=[{fileName:`config.ts`,content:k.text},{fileName:`interface.ts`,content:te.text},{fileName:`query-schema.ts`,content:ne.text},{fileName:`json-schema.json`,content:re},{fileName:`endpoint.json`,content:N}];M&&P.push({fileName:`mutation-schema.ts`,content:M}),r(n)&&await s(n,{force:!0,recursive:!0}),await a(n,{recursive:!0});for(let e of P)await c(l.join(n,e.fileName),e.content);return i||await V(o),{files:P,outputDir:n}}function Ae(){return new e(`create-endpoint`).description(`Create a custom endpoint from a JSON definition file`).addOption(new t(`--from-file <path>`,`Path to a JSON definition file conforming to the Endpoint_Definition_Format`).makeOptionMandatory(!0)).addOption(B).addOption(ce).action(async e=>{let{fromFile:t,sourcePath:n,skipRegistry:i}=e,a=l.isAbsolute(t)?t:l.resolve(process.cwd(),t);r(a)||(console.error(`Error: File not found: ${a}`),process.exit(1));let s;try{s=await o(a,`utf-8`)}catch(e){let t=e instanceof Error?e.message:String(e);console.error(`Error: Cannot read file: ${a}: ${t}`),process.exit(1)}let c;try{c=JSON.parse(s)}catch(e){let t=e instanceof Error?e.message:String(e);console.error(`Error: Invalid JSON in ${a}: ${t}`),process.exit(1)}let u=b.safeParse(c);if(!u.success){let e=u.error.issues.map(e=>` - ${e.path.length>0?e.path.join(`.`):`root`}: ${e.message}`).join(`
6
- `);console.error(`Error: Validation failed for ${a}:\n${e}`),process.exit(1)}let d=u.data,f=x(d.fields);if(f.length>0){let e=f.map(e=>{let t=e.path.length>0?e.path.join(`.`):`root`;return` - Duplicate field "${e.name}" at level: ${t}`}).join(`
7
- `);console.error(`Error: Validation failed for ${a}:\n${e}`),process.exit(1)}console.log(`
8
- Loaded definition summary:`),console.log(` tableName: ${d.tableName}`),console.log(` catalog: ${d.catalog}`),console.log(` schema: ${d.schema}`);let ee=d.mutation?d.mutation.loadStrategy:`disabled`;console.log(` mutation: ${ee}`),console.log(`
9
- Fields:`),console.log(P(d.fields)),console.log(``);let p=L(n===process.cwd()?void 0:n),m=l.join(p,`schemas/custom`,d.catalog,d.schema,d.tableName);await ke({definition:d,outputDir:m,skipRegistry:i,sourcePathOverride:n===process.cwd()?void 0:n}),console.log(`Endpoint generated successfully at: ${m}`)})}let je;function Me(){return k.config({path:`../../.env`}),O({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(ne()),HIVE_SOURCE:A().optional(),HIVE_USERNAME:A().min(1),LOG_LEVEL:te([`info`,`warn`,`error`,`debug`]).default(`warn`)}})}function Q(){return je||=Me(),je}function Ne(){let t=new e(`list-columns`);return t.description(`Lists the columns for the specified table`).addOption(R).addOption(z.makeOptionMandatory()).addOption(oe.makeOptionMandatory()).action(async({catalog:e,schema:t,table:n})=>{let r=Q(),i=e??r.HIVE_CATALOG,a=new S({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=await a.schemas({catalog:i});o=await T(`Choose a schema from the ${i} catalog`,{autocomplete:!0,choices:e})}let s=n;if(s===void 0){let e=await a.tables({catalog:i,schema:o});s=await T(`Choose a table from "${i}.${o}"`,{autocomplete:!0,choices:e})}let c=(await a.columns({catalog:i,schema:o,table:s})).map(([e,t,n,r])=>({description:r,extra:n,name:e,type:t})),l=new D;l.column(`Column Name`,`name`),l.column(`Type`,`type`),l.column(`Extra`,`extra`),l.column(`Description`,`description`),l.render(c)}),t}function Pe(){let t=new e(`list-schemas`);return t.description(`Lists the available schemas for the configured catalog`).addOption(R).action(async({catalog:e})=>{let t=Q(),n=e??t.HIVE_CATALOG,r=await new S({auth:{password:t.HIVE_PASSWORD,type:`basic`,username:t.HIVE_USERNAME},catalog:n,host:t.HIVE_HOST,port:t.HIVE_PORT}).schemas({catalog:n}),i=new D;i.column(`Schema Name`,`s`),i.render(r.map(e=>({s:e})))}),t}function Fe(){let t=new e(`list-tables`);return t.description(`Lists the available tables for the configured catalog/schema`).addOption(R).addOption(z).action(async({catalog:e,schema:t})=>{let n=Q(),r=e??n.HIVE_CATALOG,i=new S({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=await i.schemas({catalog:r});a=await T(`Choose a schema from the ${r} catalog`,{autocomplete:!0,choices:e})}let o=await i.tables({catalog:r,schema:a}),s=new D;s.column(`Table Name`,`t`),s.render(o.map(e=>({t:e})))}),t}function Ie(){let t=new e(`list-views`);return t.description(`Lists the available views for the configured catalog/schema`).addOption(R).addOption(z).action(async({catalog:e,schema:t})=>{let n=Q(),r=e??n.HIVE_CATALOG,i=new S({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=await i.schemas({catalog:r});a=await T(`Choose a schema from the ${r} catalog`,{choices:e})}let o=await i.views({catalog:r,schema:a}),s=new D;s.column(`View Name`,`v`),s.render(o.map(e=>({v:e})))}),t}function Le(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 Re(e,t){return typeof t==`string`?{name:e,type:Le(t)}:Array.isArray(t)?{name:e,type:`Array`,items:ze(t)}:typeof t==`object`&&t?{name:e,type:`Object`,fields:$(t)}:{name:e,type:`String`}}function ze(e){if(e.length===0)return{type:`String`};let[t]=e;return typeof t==`string`?{type:Le(t)}:typeof t==`object`&&t&&!Array.isArray(t)?{type:`Object`,fields:$(t)}:{type:`String`}}function $(e){let t=[];for(let[n,r]of Object.entries(e))t.push(Re(n,r));return t}function Be(e){let{tableName:t,catalog:n,schema:r,parsedColumns:i}=e;return{version:`1.0`,tableName:t,catalog:n,schema:r,fields:$(i),mutation:!1}}function Ve(){let t=new e(`pull`),n=t.description(`Interactive query endpoint generation based on a remote table`).addOption(R).addOption(se).addOption(z.makeOptionMandatory(!1)).addOption(oe.makeOptionMandatory(!1).default([]).argParser((e,t)=>[...t,e])).addOption(ce).addOption(B);return n.action(async e=>{let n=Q(),{skipRegistry:r,sourcePath:i}=e,a=e.catalog??n.HIVE_CATALOG,{schema:o,table:s,type:c}=e,u=i===(process.env.INIT_CWD??process.cwd())?void 0:i,d=L(u),f=new S({auth:{password:n.HIVE_PASSWORD,type:`basic`,username:n.HIVE_USERNAME},catalog:a,host:n.HIVE_HOST,port:n.HIVE_PORT});if(!o){let e=await f.schemas({catalog:a});o=await T(`Choose a schema from the ${a} catalog`,{autocomplete:!0,choices:e})}if(s.length===0&&(c??=await T(`What do you want to see from ${a}/${o}`,{choices:[{label:`Show tables`,value:`tables`},{label:`Show views`,value:`views`}]})),s.length===0){let e=[];e=c===`views`?await f.views({catalog:a,schema:o}):await f.tables({catalog:a,schema:o}),e.length===0&&t.error(M(`There are no tables in schema '${a}.${o}'.`),{exitCode:0}),s=await C(`Choose the tables to pull`,{autocomplete:!0,choices:e,validators:[E.required()]})}for(let e of s){let t=j((await f.columns({catalog:a,schema:o,table:e})).map(e=>re({keys:[`name`,`type`,`extra`,`description`],values:e})));await ke({definition:Be({tableName:e,catalog:a,schema:o,parsedColumns:t}),outputDir:l.join(d,`schemas/generated`,a,o,e),skipRegistry:r,sourcePathOverride:u})}}),n}function He(){return new e(`init`).description(`Initialize a lakeql.config.json configuration file`).action(async()=>{let e=F(),t=l.join(e,I);if(r(t)&&await T(`lakeql.config.json already exists. Overwrite?`,{choices:[{label:`Yes`,value:`yes`},{label:`No`,value:`no`}]})===`no`){console.log(N.yellow(`Aborted.`));return}let n=r(l.join(e,`src`)),i;if(n)i=`src`,console.log(N.cyan(`Detected src/ directory — generated code will be placed in src/`));else{let e=await T(`Where should generated code be placed?`,{choices:[{label:`./ (project root)`,value:`.`},{label:`Custom path`,value:`__custom__`}]});i=e,e===`__custom__`&&(i=await w(`Enter the source path (relative to project root):`,{defaultValue:`.`}))}await c(t,`${JSON.stringify({sourcePath:i},null,2)}\n`),console.log(N.green(`Created ${I} at ${t}`))})}async function Ue(){let t=await n(),r=new e;r.configureHelp({sortSubcommands:!0}),r.name(`lakeql-cli`).description(`LakeQL CLI`).version(t.version).addCommand(Pe()).addCommand(Fe()).addCommand(Ie()).addCommand(Ne()).addCommand(Ve()).addCommand(Ae()).addCommand(le()).addCommand(He()),await r.parseAsync()}Ue().catch(()=>{process.exit(1)});export{};
5
+ `)}\n`}async function je(e){let{definition:t,outputDir:n,skipRegistry:a,sourcePathOverride:l}=e,{catalog:u,schema:d,tableName:f,fields:p}=t,{baseClassName:m,queryName:v,mutationName:y}=pe(d,f),b=ne(p),x=te({isRoot:!0,models:{},name:m,source:b}),S=Object.values(x).find(e=>e.root===!0),C=S?.fields?Object.values(S.fields).filter(e=>e.filter===!0).map(e=>({name:e.name,type:e.graphqlType})):[],re=[...new Set(C.map(e=>e.type))],w=[...new Set(Object.values(x).filter(e=>e.transformFields.length>0).flatMap(e=>e.transformFields))],T=[...new Set(Object.values(x).filter(e=>e.dateTimeFields.length>0).flatMap(e=>e.dateTimeFields))],E=await h({fileName:`config.ts`,nodes:g({catalog:u,queryName:v,schema:d,tableName:f,mutationName:[y],storageConfig:t.mutation?{loadStrategy:t.mutation.loadStrategy,type:t.mutation.type,bucket:t.mutation.bucket,basePath:t.mutation.basePath,region:t.mutation.region,endpoint:t.mutation.endpoint}:void 0})}),D=await h({fileName:`interface.ts`,nodes:_(x)}),O=await h({fileName:`query-schema.ts`,nodes:ee({dateTimeFields:T,filterFields:C,filterTypes:re,models:x,queryName:v,transformFields:w})}),ie=p.some(e=>e.options?.validations&&e.options.validations.length>0),k=Se({models:x,mutationName:y,mutationConfig:t.mutation,hasValidations:ie,fieldDefinitions:p}),A=``;k.length>0&&(A=(await h({fileName:`mutation-schema.ts`,nodes:k})).text);let ae=Ae(b),oe=Ae(t),j=[{fileName:`config.ts`,content:E.text},{fileName:`interface.ts`,content:D.text},{fileName:`query-schema.ts`,content:O.text},{fileName:`json-schema.json`,content:ae},{fileName:`endpoint.json`,content:oe}];A&&j.push({fileName:`mutation-schema.ts`,content:A}),r(n)&&await o(n,{force:!0,recursive:!0}),await i(n,{recursive:!0});for(let e of j)await s(c.join(n,e.fileName),e.content);return a||await z(l),{files:j,outputDir:n}}function Me(){return new e(`create-endpoint`).description(`Create a custom endpoint from a JSON definition file`).addOption(new t(`--from-file <path>`,`Path to a JSON definition file conforming to the Endpoint_Definition_Format`).makeOptionMandatory(!0)).addOption(R).addOption(de).addOption(new t(`--force`,`Overwrite existing files without prompting`).default(!1)).action(async e=>{let{fromFile:t,sourcePath:n,skipRegistry:i,force:o}=e,s=c.isAbsolute(t)?t:c.resolve(process.cwd(),t);r(s)||(console.error(`Error: File not found: ${s}`),process.exit(1));let u;try{u=await a(s,`utf-8`)}catch(e){let t=e instanceof Error?e.message:String(e);console.error(`Error: Cannot read file: ${s}: ${t}`),process.exit(1)}let d;try{d=JSON.parse(u)}catch(e){let t=e instanceof Error?e.message:String(e);console.error(`Error: Invalid JSON in ${s}: ${t}`),process.exit(1)}let f=C.safeParse(d);if(!f.success){let e=f.error.issues.map(e=>` - ${e.path.length>0?e.path.join(`.`):`root`}: ${e.message}`).join(`
6
+ `);console.error(`Error: Validation failed for ${s}:\n${e}`),process.exit(1)}let p=f.data,m=re(p.fields);if(m.length>0){let e=m.map(e=>{let t=e.path.length>0?e.path.join(`.`):`root`;return` - Duplicate field "${e.name}" at level: ${t}`}).join(`
7
+ `);console.error(`Error: Validation failed for ${s}:\n${e}`),process.exit(1)}console.log(`
8
+ Loaded definition summary:`),console.log(` tableName: ${p.tableName}`),console.log(` catalog: ${p.catalog}`),console.log(` schema: ${p.schema}`);let h=p.mutation?p.mutation.loadStrategy:`disabled`;console.log(` mutation: ${h}`),console.log(`
9
+ Fields:`),console.log(N(p.fields)),console.log(``);let g=await F(n===process.cwd()?void 0:n),_=c.join(g,`schemas/custom`,p.catalog,p.schema,p.tableName);r(_)&&!o&&(await l(`Directory "${_}" already exists. Overwrite?`)||(console.log(`Aborted.`),process.exit(0))),await je({definition:p,outputDir:_,skipRegistry:i,sourcePathOverride:n===process.cwd()?void 0:n}),console.log(`Endpoint generated successfully at: ${_}`)})}let Ne;function Pe(){return D.config({path:`../../.env`}),E({runtimeEnv:process.env,server:{HIVE_CATALOG:k().min(1),HIVE_HOST:k(),HIVE_PASSWORD:k().min(1),HIVE_PORT:k().transform(e=>Number.parseInt(e,10)).pipe(ie()),HIVE_SOURCE:k().optional(),HIVE_USERNAME:k().min(1),LOG_LEVEL:O([`info`,`warn`,`error`,`debug`]).default(`warn`)}})}function Z(){return Ne||=Pe(),Ne}function Fe(){let t=new e(`list-columns`);return t.description(`Lists the columns for the specified table`).addOption(I).addOption(L.makeOptionMandatory()).addOption(le.makeOptionMandatory()).action(async({catalog:e,schema:t,table:n})=>{let r=Z(),i=e??r.HIVE_CATALOG,a=new w({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=await a.schemas({catalog:i});o=await f(`Choose a schema from the ${i} catalog`,{autocomplete:!0,choices:e})}let s=n;if(s===void 0){let e=await a.tables({catalog:i,schema:o});s=await f(`Choose a table from "${i}.${o}"`,{autocomplete:!0,choices:e})}let c=(await a.columns({catalog:i,schema:o,table:s})).map(([e,t,n,r])=>({description:r,extra:n,name:e,type:t})),l=new T;l.column(`Column Name`,`name`),l.column(`Type`,`type`),l.column(`Extra`,`extra`),l.column(`Description`,`description`),l.render(c)}),t}function Ie(){let t=new e(`list-schemas`);return t.description(`Lists the available schemas for the configured catalog`).addOption(I).action(async({catalog:e})=>{let t=Z(),n=e??t.HIVE_CATALOG,r=await new w({auth:{password:t.HIVE_PASSWORD,type:`basic`,username:t.HIVE_USERNAME},catalog:n,host:t.HIVE_HOST,port:t.HIVE_PORT}).schemas({catalog:n}),i=new T;i.column(`Schema Name`,`s`),i.render(r.map(e=>({s:e})))}),t}function Le(){let t=new e(`list-tables`);return t.description(`Lists the available tables for the configured catalog/schema`).addOption(I).addOption(L).action(async({catalog:e,schema:t})=>{let n=Z(),r=e??n.HIVE_CATALOG,i=new w({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=await i.schemas({catalog:r});a=await f(`Choose a schema from the ${r} catalog`,{autocomplete:!0,choices:e})}let o=await i.tables({catalog:r,schema:a}),s=new T;s.column(`Table Name`,`t`),s.render(o.map(e=>({t:e})))}),t}function Re(){let t=new e(`list-views`);return t.description(`Lists the available views for the configured catalog/schema`).addOption(I).addOption(L).action(async({catalog:e,schema:t})=>{let n=Z(),r=e??n.HIVE_CATALOG,i=new w({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=await i.schemas({catalog:r});a=await f(`Choose a schema from the ${r} catalog`,{choices:e})}let o=await i.views({catalog:r,schema:a}),s=new T;s.column(`View Name`,`v`),s.render(o.map(e=>({v:e})))}),t}function ze(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 Be(e,t){return typeof t==`string`?{name:e,type:ze(t)}:Array.isArray(t)?{name:e,type:`Array`,items:Ve(t)}:typeof t==`object`&&t?{name:e,type:`Object`,fields:Q(t)}:{name:e,type:`String`}}function Ve(e){if(e.length===0)return{type:`String`};let[t]=e;return typeof t==`string`?{type:ze(t)}:typeof t==`object`&&t&&!Array.isArray(t)?{type:`Object`,fields:Q(t)}:{type:`String`}}function Q(e){let t=[];for(let[n,r]of Object.entries(e))t.push(Be(n,r));return t}function He(e){let{tableName:t,catalog:n,schema:r,parsedColumns:i}=e;return{version:`1.0`,tableName:t,catalog:n,schema:r,fields:Q(i),mutation:!1}}async function $(e){let{trinoClient:t,catalog:n,schema:r,tables:i,resolvedTargetPath:a,skipRegistry:o,sourcePathOverride:s}=e;for(let e of i)await je({definition:He({tableName:e,catalog:n,schema:r,parsedColumns:oe((await t.columns({catalog:n,schema:r,table:e})).map(e=>j({keys:[`name`,`type`,`extra`,`description`],values:e})))}),outputDir:c.join(a,`schemas/generated`,n,r,e),skipRegistry:o,sourcePathOverride:s})}async function Ue(e){let t=P(),n;if(e){let r=c.isAbsolute(e)?e:c.resolve(t,e),i=c.parse(r);n=c.join(i.dir,i.name)}let{config:r}=await m({name:`import`,cwd:t,configFile:n,defaults:{default:[]},packageJson:!1,globalRc:!1,rcFile:!1,dotenv:!1}),i=r;return Array.isArray(i)?i:i&&typeof i==`object`&&`default`in i&&Array.isArray(i.default)?i.default:[]}async function We(e){let{configPath:t,catalog:n,sourcePathOverride:r,skipRegistry:i}=e,a=Z(),o=await F(r),s=await Ue(t);if(s.length===0){console.log(`No entries found in bulk config.`);return}await new ae([{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 w({auth:{password:a.HIVE_PASSWORD,type:`basic`,username:a.HIVE_USERNAME},catalog:t,host:a.HIVE_HOST,port:a.HIVE_PORT});e.tables&&e.tables.length>0&&(s.output=`Pulling ${e.tables.length} table(s)...`,await $({trinoClient:c,catalog:t,schema:e.schema,tables:e.tables,resolvedTargetPath:o,skipRegistry:!0,sourcePathOverride:r})),e.views&&e.views.length>0&&(s.output=`Pulling ${e.views.length} view(s)...`,await $({trinoClient:c,catalog:t,schema:e.schema,tables:e.views,resolvedTargetPath:o,skipRegistry:!0,sourcePathOverride:r})),s.title=`${t}/${e.schema} — ${i} item(s) pulled`}}}),{concurrent:!0,exitOnError:!1})},{title:`Create registry`,enabled:!i,task:async()=>{await z(r)}}],{concurrent:!1,exitOnError:!0}).run()}const Ge=new t(`--bulk`,`Run in bulk mode using a config file`).default(!1),Ke=new t(`--bulk-config <path>`,`Path to the bulk import config file (default: import.config.{mjs,ts,js,json})`);function qe(){let t=new e(`pull`),n=t.description(`Interactive query endpoint generation based on a remote table`).addOption(I).addOption(ue).addOption(L.makeOptionMandatory(!1)).addOption(le.makeOptionMandatory(!1).default([]).argParser((e,t)=>[...t,e])).addOption(de).addOption(R).addOption(Ge).addOption(Ke);return n.action(async e=>{let{skipRegistry:n,sourcePath:r,bulk:i,bulkConfig:a}=e,o=r===(process.env.INIT_CWD??process.cwd())?void 0:r;if(i){await We({configPath:a,catalog:e.catalog,sourcePathOverride:o,skipRegistry:n});return}let s=Z(),c=e.catalog??s.HIVE_CATALOG,{schema:l,table:d,type:m}=e,h=await F(o),g=new w({auth:{password:s.HIVE_PASSWORD,type:`basic`,username:s.HIVE_USERNAME},catalog:c,host:s.HIVE_HOST,port:s.HIVE_PORT});if(!l){let e=await g.schemas({catalog:c});l=await f(`Choose a schema from the ${c} catalog`,{autocomplete:!0,choices:e})}if(d.length===0&&(m??=await f(`What do you want to see from ${c}/${l}`,{choices:[{label:`Show tables`,value:`tables`},{label:`Show views`,value:`views`}]})),d.length===0){m??=`tables`;let e=[];e=m===`views`?await g.views({catalog:c,schema:l}):await g.tables({catalog:c,schema:l}),e.length===0&&t.error(A(`There are no ${m} in schema '${c}.${l}'.`),{exitCode:0}),d=await u(`Choose the ${m} to pull`,{autocomplete:!0,choices:e,validators:[p.required()]})}await $({trinoClient:g,catalog:c,schema:l,tables:[...d],resolvedTargetPath:h,skipRegistry:n,sourcePathOverride:o})}),n}const Je=[`lakeql.config.mjs`,`lakeql.config.ts`,`lakeql.config.json`];function Ye(e){return`/** @type {import('@lakeql/cli').LakeQLConfig} */\nexport default {\n${Object.entries(e).map(([e,t])=>` ${e}: ${JSON.stringify(t)},`).join(`
10
+ `)}\n}\n`}function Xe(e){for(let t of Je)if(r(c.join(e,t)))return t;return null}function Ze(){return new e(`init`).description(`Initialize a lakeql config file`).action(async()=>{let e=P(),t=Xe(e);if(t&&await f(`${t} already exists. Overwrite?`,{choices:[{label:`Yes`,value:`yes`},{label:`No`,value:`no`}]})===`no`){console.log(M.yellow(`Aborted.`));return}let n=await f(`Config format:`,{choices:[{label:`lakeql.config.mjs (recommended)`,value:`mjs`},{label:`lakeql.config.json`,value:`json`}]}),i=r(c.join(e,`src`)),a;if(i)a=`src`,console.log(M.cyan(`Detected src/ directory — generated code will be placed in src/`));else{let e=await f(`Where should generated code be placed?`,{choices:[{label:`./ (project root)`,value:`.`},{label:`Custom path`,value:`__custom__`}]});a=e,e===`__custom__`&&(a=await d(`Enter the source path (relative to project root):`,{defaultValue:`.`}))}let o={sourcePath:a},l=n===`mjs`?`lakeql.config.mjs`:`lakeql.config.json`,u=c.join(e,l);await s(u,n===`mjs`?Ye(o):`${JSON.stringify(o,null,2)}\n`),console.log(M.green(`Created ${l} at ${u}`))})}async function Qe(){let t=await n(),r=new e;r.configureHelp({sortSubcommands:!0}),r.name(`lakeql-cli`).description(`LakeQL CLI`).version(t.version).addCommand(Ie()).addCommand(Le()).addCommand(Re()).addCommand(Fe()).addCommand(qe()).addCommand(Me()).addCommand(fe()).addCommand(Ze()),await r.parseAsync()}Qe().catch(()=>{process.exit(1)});export{};
@@ -0,0 +1,40 @@
1
+ //#region src/bulk-pull-config.d.ts
2
+ /**
3
+ * Configuration for a single pull entry in a bulk import.
4
+ */
5
+ interface BulkPullEntry {
6
+ /** The schema to pull from. */
7
+ schema: string;
8
+ /** Optional catalog override. Falls back to CLI --catalog or ENV. */
9
+ catalog?: string;
10
+ /** List of tables to pull. */
11
+ tables?: string[];
12
+ /** List of views to pull. */
13
+ views?: string[];
14
+ }
15
+ /**
16
+ * Bulk pull configuration — a simple array of pull entries.
17
+ *
18
+ * @example
19
+ * ```js
20
+ * // import.config.mjs
21
+ * /** @type {import('@lakeql/cli').BulkPullConfig} *\/
22
+ * export default [
23
+ * { schema: "schema1", tables: ["table1", "table2"] },
24
+ * { schema: "schema2", catalog: "other", views: ["view1"] },
25
+ * ]
26
+ * ```
27
+ */
28
+ type BulkPullConfig = BulkPullEntry[];
29
+ //#endregion
30
+ //#region src/config.d.ts
31
+ interface LakeQLConfig {
32
+ /**
33
+ * Base path for code generation (schemas, config-registry, etc.).
34
+ * Relative paths are resolved from the project root (where the config file lives).
35
+ * @default "."
36
+ */
37
+ sourcePath: string;
38
+ }
39
+ //#endregion
40
+ export type { BulkPullConfig, BulkPullEntry, LakeQLConfig };
package/dist/index.mjs ADDED
@@ -0,0 +1 @@
1
+ export{};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lakeql/cli",
3
- "version": "0.2.4",
3
+ "version": "0.4.0",
4
4
  "description": "CLI for introspecting Trino schemas and generating type-safe GraphQL endpoints",
5
5
  "keywords": [
6
6
  "cli",
@@ -38,6 +38,10 @@
38
38
  "sideEffects": false,
39
39
  "exports": {
40
40
  ".": {
41
+ "import": "./dist/index.mjs",
42
+ "types": "./dist/index.d.mts"
43
+ },
44
+ "./cli": {
41
45
  "import": "./dist/cli.mjs"
42
46
  }
43
47
  },
@@ -45,23 +49,24 @@
45
49
  "@commander-js/extra-typings": "15.0.0",
46
50
  "@t3-oss/env-core": "0.13.11",
47
51
  "@topcli/prompts": "3.1.0",
52
+ "c12": "4.0.0-beta.5",
48
53
  "climt": "0.2.0",
49
54
  "commander": "15.0.0",
50
55
  "dotenv": "17.4.2",
51
56
  "globby": "16.2.0",
52
57
  "handlebars": "4.7.9",
53
58
  "kleur": "4.1.5",
59
+ "listr2": "10.2.1",
54
60
  "lodash-es": "4.18.1",
55
- "ora": "9.4.0",
56
61
  "read-pkg": "10.1.0",
57
62
  "zod": "4.4.3",
58
63
  "@lakeql/column-parser": "0.1.2",
64
+ "@lakeql/helpers": "0.1.2",
59
65
  "@lakeql/logger": "0.1.2",
60
- "@lakeql/file-generator": "0.1.4",
61
66
  "@lakeql/response-transformer": "0.1.2",
62
- "@lakeql/schema-generator": "0.2.1",
63
- "@lakeql/trino-client": "0.3.0",
64
- "@lakeql/helpers": "0.1.2"
67
+ "@lakeql/schema-generator": "0.3.0",
68
+ "@lakeql/file-generator": "0.1.5",
69
+ "@lakeql/trino-client": "0.3.0"
65
70
  },
66
71
  "devDependencies": {
67
72
  "@types/lodash-es": "4.17.12",