@api-now/cli 1.7.0 → 1.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +1 -1
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire } from 'module'; const require = createRequire(import.meta.url); import { fileURLToPath } from 'url'; import { dirname } from 'path'; const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename);
3
- var Po=Object.create;var ns=Object.defineProperty;var Ro=Object.getOwnPropertyDescriptor;var Co=Object.getOwnPropertyNames;var Do=Object.getPrototypeOf,Uo=Object.prototype.hasOwnProperty;var Lo=(o,e)=>()=>{try{return e||o((e={exports:{}}).exports,e),e.exports}catch(t){throw e=0,t}},Ea=(o,e)=>{for(var t in e)ns(o,t,{get:e[t],enumerable:!0})},Mo=(o,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Co(e))!Uo.call(o,r)&&r!==t&&ns(o,r,{get:()=>e[r],enumerable:!(i=Ro(e,r))||i.enumerable});return o};var zo=(o,e,t)=>(t=o!=null?Po(Do(o)):{},Mo(e||!o||!o.__esModule?ns(t,"default",{value:o,enumerable:!0}):t,o));var Bn=Lo((zk,Gn)=>{var ta=Object.defineProperty,td=Object.getOwnPropertyDescriptor,id=Object.getOwnPropertyNames,rd=Object.prototype.hasOwnProperty,sd=(o,e)=>{for(var t in e)ta(o,t,{get:e[t],enumerable:!0})},ad=(o,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of id(e))!rd.call(o,r)&&r!==t&&ta(o,r,{get:()=>e[r],enumerable:!(i=td(e,r))||i.enumerable});return o},nd=o=>ad(ta({},"__esModule",{value:!0}),o),Fn={};sd(Fn,{AmfModelExpander:()=>cd,JsonLd:()=>Rt,JsonLdOptions:()=>qn});Gn.exports=nd(Fn);var od=class Kn{validate(e){if(e===void 0)throw new Error("Node must not be undefined");if(Array.isArray(e))throw new Error("Node must not be an array");if(e["@id"]===void 0)throw new Error("Node must have an @id")}static empty(){return new Kn}withNode(e){this.validate(e);let t=e["@id"];if(this[t]!==void 0)throw new Error(`Cannot add node with duplicate id ${e["@id"]} to dictionary`);return this[t]=e,this}withNodes(e){return e.forEach(t=>this.withNode(t)),this}},Br=class{static targetOrLink(o,e){let t=e[o["@id"]];return t!==void 0?t:o}static isLinkObject(o){let e=typeof o=="object",t=!Array.isArray(o),i=o["@id"]!==void 0,r=Object.keys(o).length===1;return e&&t&&i&&r}static isArrayOfLinks(o){return o.every(e=>this.isLinkObject(e))}},ld=class{static embedNodeLinks(o,e,t){let r=t||(()=>!0);return Object.entries(o).filter(([s,a])=>r(s,a)).forEach(([s,a])=>{typeof a=="object"&&(Br.isLinkObject(a)?o[s]=Br.targetOrLink(a,e):Array.isArray(a)&&Br.isArrayOfLinks(a)&&(o[s]=a.map(n=>Br.targetOrLink(n,e))))}),o}},zn=class ea{static expandIris(e,t){Object.entries(e).forEach(([i,r])=>{delete e[i];let s=ea.expandIri(i,t);e[s]=r})}static compactIris(e,t){Object.entries(e).forEach(([i,r])=>{delete e[i];let s=ea.compactIri(i,t);e[s]=r})}static compactIri(e,t){switch(typeof t){case"string":return e.replace(t,"");case"object":if(Array.isArray(t))throw new Error("Context must be either an object or a string");if(this.isCompacted(e,t))return e;try{let[i,r]=Object.entries(t).find(([s,a])=>e.startsWith(a));return e.replace(r,`${i}:`)}catch{return e}default:throw new Error("Context must be either an object or a string")}}static expandIri(e,t){switch(typeof t){case"string":return`${t}${e}`;case"object":if(Array.isArray(t))throw new Error("Context must be either an object or a string");if(this.isCompacted(e,t))try{let[i,r]=Object.entries(t).find(([s,a])=>e.startsWith(s));return e.replace(`${i}:`,r)}catch{return e}else return e;default:throw new Error("Context must be either an object or a string")}}static isCompacted(e,t){let i=!0;return Object.values(t).forEach(r=>{e.startsWith(r)&&(i=!1)}),i}},Vn=class{static expandStructure(o){return Object.entries(o).forEach(([e,t])=>{switch(e){case"@id":break;case"@type":this.expandType(o,t);break;default:this.expandValue(o,e,t);break}}),o}static expandType(o,e){typeof e=="string"?o["@type"]=[e]:o["@type"]=e}static expandValue(o,e,t){switch(typeof t){case"string":case"number":case"boolean":o[e]=[{"@value":t}];break;case"object":Array.isArray(t)?t.map(r=>{switch(typeof r){case"string":case"number":case"boolean":return[{"@value":t}];default:return r}}):o[e]=[t]}}static compactStructure(o){if(Array.isArray(o)){let[e]=o;return this.compactStructure(e)}else return Object.entries(o).forEach(([e,t])=>{switch(e){case"@id":break;case"@type":this.compactType(o,t);break;default:this.compactValue(o,e,t);break}}),o}static compactType(o,e){Array.isArray(e)&&e.length===1&&(o["@type"]=e[0])}static compactValue(o,e,t){if(t.length===1){let[i]=t;this.isWrappedScalar(i)?o[e]=i["@value"]:o[e]=i}else t.map(i=>this.isWrappedScalar(i)?i["@value"]:i)}static isWrappedScalar(o){return o["@value"]!==void 0}},Rt=class{static process(o,e){let t=this.getGraph(o),i=this.getContext(o),r=od.empty().withNodes(t);t.forEach(a=>{e.embeddedLinks&&ld.embedNodeLinks(a,r,e.linkEmbeddingFilter),i!==void 0&&(e.expandedIris?zn.expandIris(a,i):e.compactedIris&&zn.compactIris(a,i)),e.expandedStructure?Vn.expandStructure(a):e.compactedStructure&&Vn.compactStructure(a)});let s=e.rootNodeId===void 0?{"@graph":t}:this.findNode(t,e.rootNodeId);return i!==void 0&&(s["@context"]=i),e.expandedStructure?[s]:s}static getContext(o){return o["@context"]}static getGraph(o){return o["@graph"]}static findNode(o,e){return o.find(t=>t["@id"]===e)}static stringify(o,e=!1){return JSON.stringify(o,null,e?2:0)}},qn=class Jn{expandedIris;expandedStructure;embeddedLinks;compactedIris;compactedStructure;rootNodeId;linkEmbeddingFilter;static apply(){return new Jn}withCompactedStructure(){return this.expandedStructure=!1,this.compactedStructure=!0,this}withRootNode(e){return this.rootNodeId=e,this}withExpandedStructure(){return this.expandedStructure=!0,this.compactedStructure=!1,this}withExpandedIris(){return this.expandedIris=!0,this.compactedIris=!1,this}withCompactedIris(){return this.expandedIris=!1,this.compactedIris=!0,this}withEmbeddedLinks(e){return this.linkEmbeddingFilter=e,this.embeddedLinks=!0,this}},cd=class{static expand(o){if(this.isInExpandedForm(o))return o;{let e=(r,s)=>!r.endsWith("fixPoint");this.preprocessLegacyRootNodeId(o);let t=this.resolveRootNodeId(o),i=qn.apply().withEmbeddedLinks(e).withCompactedIris().withExpandedStructure().withRootNode(t);return Rt.process(o,i)}}static isInExpandedForm(o){return o["@graph"]===void 0}static preprocessLegacyRootNodeId(o){let e=Rt.getGraph(o);if(e!=null){let t=Rt.findNode(e,"./");t!=null&&(t["@id"]="")}}static resolveRootNodeId(o){let e=Rt.getGraph(o);if(e==null||Rt.findNode(e,"")!=null)return"";let t=Rt.getContext(o);if(t!=null&&t["@base"]!=null){let r=t["@base"];if(Rt.findNode(e,r)!=null)return r}let i=e.find(r=>Object.entries(r).some(([s,a])=>(s==="doc:root"||s==="http://a.ml/vocabularies/document#root")&&a===!0));return i!=null?i["@id"]:""}}});import lp from"update-notifier";import{Command as cp}from"commander";var gi={name:"@api-now/cli",description:"API Now! CLI",version:"1.7.0",private:!1,publishConfig:{registry:"https://registry.npmjs.org/","@api-now:registry":"https://registry.npmjs.org/",access:"public"},files:["dist"],engines:{node:">=22.0.0"},type:"module",bin:{apinow:"dist/index.js"},scripts:{build:"node esbuild.config.js",postbuild:"node dist/index.js --help",dev:"tsx src/index.ts",typecheck:"tsc --noEmit",lint:'eslint "src/**/*.ts"',format:'prettier --write "src/**/*.ts"',test:"tsx --test tests/**/*.test.ts",prepare:"husky",prepublishOnly:"npm run build",knip:"knip"},dependencies:{"@inquirer/prompts":"^8.5.0","@api-now/json":"^1.0.0",commander:"^15.0.0",nanoid:"^5.1.6",open:"^11.0.0",tslib:"^2.8.1","update-notifier":"^7.3.1",winston:"^3.19.0"},devDependencies:{"@api-now/core":"^1.10.0","@commitlint/cli":"^21.0.1","@commitlint/config-conventional":"^21.0.1","@eslint/js":"^10.0.1","@semantic-release/changelog":"^6.0.3","@semantic-release/git":"^10.0.1","@types/node":"^25.9.1","@types/update-notifier":"^6.0.8",esbuild:"^0.28.0",eslint:"^10.4.0","eslint-config-prettier":"^10.1.8","eslint-plugin-prettier":"^5.5.6",globals:"^17.6.0",husky:"^9.1.7",knip:"^6.14.2",prettier:"^3.8.3","semantic-release":"^25.0.3",tsx:"^4.7.1",typescript:"^6.0.3","typescript-eslint":"^8.60.0"}};import os from"node:os";import dt from"node:path";import we from"node:fs";var Zi="https://api.apinow.app",ls="apinow-cli",Fo="config.json",cs=class{_resolved=null;get resolved(){this._resolved||this.load();let e=this._resolved;if(!e)throw new Error("Configuration could not be loaded.");return e}configDir=this.#e();configPath=dt.join(this.configDir,Fo);load(){let e=this.#i(),t=this.#r(),i=process.env.APINOW_API_TOKEN||process.env.APINOW_TOKEN||t.token||e.token,r=process.env.APINOW_API_URL||t.apiUrl||e.apiUrl||Zi,s=t.org||e.org||"";this._resolved={token:i,apiUrl:r,org:s,format:"text"}}saturate(e){this._resolved||this.load();let t=this._resolved;if(!t)throw new Error("Configuration could not be loaded.");this._resolved={token:t.token,apiUrl:e.apiUrl||t.apiUrl,org:t.org,format:e.format==="json"?"json":"text"}}#e(){if(process.platform==="win32"){let e=process.env.APPDATA||dt.join(os.homedir(),"AppData","Roaming");if(!e)throw new Error("Could not determine the configuration directory.");return dt.join(e,ls)}return process.platform==="darwin"?dt.join(os.homedir(),"Library","Preferences",ls):dt.join(process.env.XDG_CONFIG_HOME||dt.join(os.homedir(),".config"),ls)}#t(){let e=process.cwd();for(;;){let t=dt.join(e,"apinow.json");if(we.existsSync(t))try{if(we.statSync(t).isFile())return t}catch{}let i=dt.join(e,".apinowrc.json");if(we.existsSync(i))try{if(we.statSync(i).isFile())return i}catch{}let r=dt.dirname(e);if(r===e)break;e=r}return null}#r(){let e=this.#t();if(!e)return{};try{let t=we.readFileSync(e,"utf8");return JSON.parse(t)}catch{return{}}}#i(){try{if(!we.existsSync(this.configPath))return{apiUrl:Zi};let e=we.readFileSync(this.configPath,"utf8"),t=JSON.parse(e);return{apiUrl:Zi,...t}}catch{return{apiUrl:Zi}}}writeProperty(e,t){let i=this.#i();i[e]=t,this.#s(i)}#s(e){try{let i={...this.#i(),...e};we.existsSync(this.configDir)||we.mkdirSync(this.configDir,{recursive:!0}),we.writeFileSync(this.configPath,JSON.stringify(i,null,2),"utf8")}catch(t){console.error("Failed to write configuration:",t)}}clearConfigKey(e){try{let t=this.#i();delete t[e],we.existsSync(this.configDir)||we.mkdirSync(this.configDir,{recursive:!0}),we.writeFileSync(this.configPath,JSON.stringify(t,null,2),"utf8")}catch(t){console.error(`Failed to clear key ${e} from configuration:`,t)}}reset(){try{we.existsSync(this.configPath)&&we.unlinkSync(this.configPath),we.existsSync(this.configDir)&&we.readdirSync(this.configDir).length===0&&we.rmdirSync(this.configDir),this._resolved=null}catch(e){console.error("Failed to reset configuration:",e)}}},P=new cs;import{styleText as Qt}from"node:util";import Ko from"node:path";import qo from"node:os";import Jo from"node:crypto";import Ke from"winston";var Go=Jo.randomBytes(4).toString("hex"),Bo=Date.now(),Qi=Ko.join(qo.tmpdir(),`apinow-cli-${Bo}-${Go}.log`),Na=new Ke.transports.Console({stderrLevels:Object.keys(Ke.config.cli.levels),level:"info",format:Ke.format.combine(Ke.format.colorize(),Ke.format.simple())}),Wo=new Ke.transports.File({filename:Qi,level:"debug",format:Ke.format.combine(Ke.format.timestamp(),Ke.format.printf(({timestamp:o,level:e,message:t})=>{let i=typeof t=="string"?t.replace(/\u001b\[\d+m/g,""):t;return`${o} [${e.toUpperCase()}]: ${i}`}))}),S=Ke.createLogger({levels:Ke.config.cli.levels,level:"debug",transports:[Na,Wo]});function Ia(o){Na.level=o}var ds=gi.version;var X={green:o=>Qt("green",o),red:o=>Qt("red",o),yellow:o=>Qt("yellow",o),cyan:o=>Qt("cyan",o),dim:o=>Qt("dim",o),bold:o=>Qt("bold",o)};function Ho(o,e,t){if(o.length===0)return"No data available.";let i={},r=t||e;for(let l=0;l<e.length;l++){let c=e[l],p=r[l]||c;i[c]=p.length}for(let l of o)for(let c of e){let p=typeof l[c]=="object"&&l[c]!==null?JSON.stringify(l[c]):String(l[c]??"");p.length>(i[c]||0)&&(i[c]=p.length)}let s=e.map((l,c)=>(r[c]||l).toUpperCase().padEnd(i[l])).join(" "),a=e.map(l=>"-".repeat(i[l])).join(" "),n=o.map(l=>e.map(c=>(typeof l[c]=="object"&&l[c]!==null?JSON.stringify(l[c]):String(l[c]??"")).padEnd(i[c])).join(" "));return[s,a,...n].join(`
3
+ var Po=Object.create;var ns=Object.defineProperty;var Ro=Object.getOwnPropertyDescriptor;var Co=Object.getOwnPropertyNames;var Do=Object.getPrototypeOf,Uo=Object.prototype.hasOwnProperty;var Lo=(o,e)=>()=>{try{return e||o((e={exports:{}}).exports,e),e.exports}catch(t){throw e=0,t}},Ea=(o,e)=>{for(var t in e)ns(o,t,{get:e[t],enumerable:!0})},Mo=(o,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Co(e))!Uo.call(o,r)&&r!==t&&ns(o,r,{get:()=>e[r],enumerable:!(i=Ro(e,r))||i.enumerable});return o};var zo=(o,e,t)=>(t=o!=null?Po(Do(o)):{},Mo(e||!o||!o.__esModule?ns(t,"default",{value:o,enumerable:!0}):t,o));var Bn=Lo((zk,Gn)=>{var ta=Object.defineProperty,td=Object.getOwnPropertyDescriptor,id=Object.getOwnPropertyNames,rd=Object.prototype.hasOwnProperty,sd=(o,e)=>{for(var t in e)ta(o,t,{get:e[t],enumerable:!0})},ad=(o,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of id(e))!rd.call(o,r)&&r!==t&&ta(o,r,{get:()=>e[r],enumerable:!(i=td(e,r))||i.enumerable});return o},nd=o=>ad(ta({},"__esModule",{value:!0}),o),Fn={};sd(Fn,{AmfModelExpander:()=>cd,JsonLd:()=>Rt,JsonLdOptions:()=>qn});Gn.exports=nd(Fn);var od=class Kn{validate(e){if(e===void 0)throw new Error("Node must not be undefined");if(Array.isArray(e))throw new Error("Node must not be an array");if(e["@id"]===void 0)throw new Error("Node must have an @id")}static empty(){return new Kn}withNode(e){this.validate(e);let t=e["@id"];if(this[t]!==void 0)throw new Error(`Cannot add node with duplicate id ${e["@id"]} to dictionary`);return this[t]=e,this}withNodes(e){return e.forEach(t=>this.withNode(t)),this}},Br=class{static targetOrLink(o,e){let t=e[o["@id"]];return t!==void 0?t:o}static isLinkObject(o){let e=typeof o=="object",t=!Array.isArray(o),i=o["@id"]!==void 0,r=Object.keys(o).length===1;return e&&t&&i&&r}static isArrayOfLinks(o){return o.every(e=>this.isLinkObject(e))}},ld=class{static embedNodeLinks(o,e,t){let r=t||(()=>!0);return Object.entries(o).filter(([s,a])=>r(s,a)).forEach(([s,a])=>{typeof a=="object"&&(Br.isLinkObject(a)?o[s]=Br.targetOrLink(a,e):Array.isArray(a)&&Br.isArrayOfLinks(a)&&(o[s]=a.map(n=>Br.targetOrLink(n,e))))}),o}},zn=class ea{static expandIris(e,t){Object.entries(e).forEach(([i,r])=>{delete e[i];let s=ea.expandIri(i,t);e[s]=r})}static compactIris(e,t){Object.entries(e).forEach(([i,r])=>{delete e[i];let s=ea.compactIri(i,t);e[s]=r})}static compactIri(e,t){switch(typeof t){case"string":return e.replace(t,"");case"object":if(Array.isArray(t))throw new Error("Context must be either an object or a string");if(this.isCompacted(e,t))return e;try{let[i,r]=Object.entries(t).find(([s,a])=>e.startsWith(a));return e.replace(r,`${i}:`)}catch{return e}default:throw new Error("Context must be either an object or a string")}}static expandIri(e,t){switch(typeof t){case"string":return`${t}${e}`;case"object":if(Array.isArray(t))throw new Error("Context must be either an object or a string");if(this.isCompacted(e,t))try{let[i,r]=Object.entries(t).find(([s,a])=>e.startsWith(s));return e.replace(`${i}:`,r)}catch{return e}else return e;default:throw new Error("Context must be either an object or a string")}}static isCompacted(e,t){let i=!0;return Object.values(t).forEach(r=>{e.startsWith(r)&&(i=!1)}),i}},Vn=class{static expandStructure(o){return Object.entries(o).forEach(([e,t])=>{switch(e){case"@id":break;case"@type":this.expandType(o,t);break;default:this.expandValue(o,e,t);break}}),o}static expandType(o,e){typeof e=="string"?o["@type"]=[e]:o["@type"]=e}static expandValue(o,e,t){switch(typeof t){case"string":case"number":case"boolean":o[e]=[{"@value":t}];break;case"object":Array.isArray(t)?t.map(r=>{switch(typeof r){case"string":case"number":case"boolean":return[{"@value":t}];default:return r}}):o[e]=[t]}}static compactStructure(o){if(Array.isArray(o)){let[e]=o;return this.compactStructure(e)}else return Object.entries(o).forEach(([e,t])=>{switch(e){case"@id":break;case"@type":this.compactType(o,t);break;default:this.compactValue(o,e,t);break}}),o}static compactType(o,e){Array.isArray(e)&&e.length===1&&(o["@type"]=e[0])}static compactValue(o,e,t){if(t.length===1){let[i]=t;this.isWrappedScalar(i)?o[e]=i["@value"]:o[e]=i}else t.map(i=>this.isWrappedScalar(i)?i["@value"]:i)}static isWrappedScalar(o){return o["@value"]!==void 0}},Rt=class{static process(o,e){let t=this.getGraph(o),i=this.getContext(o),r=od.empty().withNodes(t);t.forEach(a=>{e.embeddedLinks&&ld.embedNodeLinks(a,r,e.linkEmbeddingFilter),i!==void 0&&(e.expandedIris?zn.expandIris(a,i):e.compactedIris&&zn.compactIris(a,i)),e.expandedStructure?Vn.expandStructure(a):e.compactedStructure&&Vn.compactStructure(a)});let s=e.rootNodeId===void 0?{"@graph":t}:this.findNode(t,e.rootNodeId);return i!==void 0&&(s["@context"]=i),e.expandedStructure?[s]:s}static getContext(o){return o["@context"]}static getGraph(o){return o["@graph"]}static findNode(o,e){return o.find(t=>t["@id"]===e)}static stringify(o,e=!1){return JSON.stringify(o,null,e?2:0)}},qn=class Jn{expandedIris;expandedStructure;embeddedLinks;compactedIris;compactedStructure;rootNodeId;linkEmbeddingFilter;static apply(){return new Jn}withCompactedStructure(){return this.expandedStructure=!1,this.compactedStructure=!0,this}withRootNode(e){return this.rootNodeId=e,this}withExpandedStructure(){return this.expandedStructure=!0,this.compactedStructure=!1,this}withExpandedIris(){return this.expandedIris=!0,this.compactedIris=!1,this}withCompactedIris(){return this.expandedIris=!1,this.compactedIris=!0,this}withEmbeddedLinks(e){return this.linkEmbeddingFilter=e,this.embeddedLinks=!0,this}},cd=class{static expand(o){if(this.isInExpandedForm(o))return o;{let e=(r,s)=>!r.endsWith("fixPoint");this.preprocessLegacyRootNodeId(o);let t=this.resolveRootNodeId(o),i=qn.apply().withEmbeddedLinks(e).withCompactedIris().withExpandedStructure().withRootNode(t);return Rt.process(o,i)}}static isInExpandedForm(o){return o["@graph"]===void 0}static preprocessLegacyRootNodeId(o){let e=Rt.getGraph(o);if(e!=null){let t=Rt.findNode(e,"./");t!=null&&(t["@id"]="")}}static resolveRootNodeId(o){let e=Rt.getGraph(o);if(e==null||Rt.findNode(e,"")!=null)return"";let t=Rt.getContext(o);if(t!=null&&t["@base"]!=null){let r=t["@base"];if(Rt.findNode(e,r)!=null)return r}let i=e.find(r=>Object.entries(r).some(([s,a])=>(s==="doc:root"||s==="http://a.ml/vocabularies/document#root")&&a===!0));return i!=null?i["@id"]:""}}});import lp from"update-notifier";import{Command as cp}from"commander";var gi={name:"@api-now/cli",description:"API Now! CLI",version:"1.7.1",private:!1,publishConfig:{registry:"https://registry.npmjs.org/","@api-now:registry":"https://registry.npmjs.org/",access:"public"},files:["dist"],engines:{node:">=22.0.0"},type:"module",bin:{apinow:"dist/index.js"},scripts:{build:"node esbuild.config.js",postbuild:"node dist/index.js --help",dev:"tsx src/index.ts",typecheck:"tsc --noEmit",lint:'eslint "src/**/*.ts"',format:'prettier --write "src/**/*.ts"',test:"tsx --test tests/**/*.test.ts",prepare:"husky",prepublishOnly:"npm run build",knip:"knip"},dependencies:{"@inquirer/prompts":"^8.5.0",commander:"^15.0.0",nanoid:"^5.1.6",open:"^11.0.0",tslib:"^2.8.1","update-notifier":"^7.3.1",winston:"^3.19.0"},devDependencies:{"@api-now/core":"^1.10.0","@api-now/json":"^1.0.0","@commitlint/cli":"^21.0.1","@commitlint/config-conventional":"^21.0.1","@eslint/js":"^10.0.1","@semantic-release/changelog":"^6.0.3","@semantic-release/git":"^10.0.1","@types/node":"^25.9.1","@types/update-notifier":"^6.0.8",esbuild:"^0.28.0",eslint:"^10.4.0","eslint-config-prettier":"^10.1.8","eslint-plugin-prettier":"^5.5.6",globals:"^17.6.0",husky:"^9.1.7",knip:"^6.14.2",prettier:"^3.8.3","semantic-release":"^25.0.3",tsx:"^4.7.1",typescript:"^6.0.3","typescript-eslint":"^8.60.0"}};import os from"node:os";import dt from"node:path";import we from"node:fs";var Zi="https://api.apinow.app",ls="apinow-cli",Fo="config.json",cs=class{_resolved=null;get resolved(){this._resolved||this.load();let e=this._resolved;if(!e)throw new Error("Configuration could not be loaded.");return e}configDir=this.#e();configPath=dt.join(this.configDir,Fo);load(){let e=this.#i(),t=this.#r(),i=process.env.APINOW_API_TOKEN||process.env.APINOW_TOKEN||t.token||e.token,r=process.env.APINOW_API_URL||t.apiUrl||e.apiUrl||Zi,s=t.org||e.org||"";this._resolved={token:i,apiUrl:r,org:s,format:"text"}}saturate(e){this._resolved||this.load();let t=this._resolved;if(!t)throw new Error("Configuration could not be loaded.");this._resolved={token:t.token,apiUrl:e.apiUrl||t.apiUrl,org:t.org,format:e.format==="json"?"json":"text"}}#e(){if(process.platform==="win32"){let e=process.env.APPDATA||dt.join(os.homedir(),"AppData","Roaming");if(!e)throw new Error("Could not determine the configuration directory.");return dt.join(e,ls)}return process.platform==="darwin"?dt.join(os.homedir(),"Library","Preferences",ls):dt.join(process.env.XDG_CONFIG_HOME||dt.join(os.homedir(),".config"),ls)}#t(){let e=process.cwd();for(;;){let t=dt.join(e,"apinow.json");if(we.existsSync(t))try{if(we.statSync(t).isFile())return t}catch{}let i=dt.join(e,".apinowrc.json");if(we.existsSync(i))try{if(we.statSync(i).isFile())return i}catch{}let r=dt.dirname(e);if(r===e)break;e=r}return null}#r(){let e=this.#t();if(!e)return{};try{let t=we.readFileSync(e,"utf8");return JSON.parse(t)}catch{return{}}}#i(){try{if(!we.existsSync(this.configPath))return{apiUrl:Zi};let e=we.readFileSync(this.configPath,"utf8"),t=JSON.parse(e);return{apiUrl:Zi,...t}}catch{return{apiUrl:Zi}}}writeProperty(e,t){let i=this.#i();i[e]=t,this.#s(i)}#s(e){try{let i={...this.#i(),...e};we.existsSync(this.configDir)||we.mkdirSync(this.configDir,{recursive:!0}),we.writeFileSync(this.configPath,JSON.stringify(i,null,2),"utf8")}catch(t){console.error("Failed to write configuration:",t)}}clearConfigKey(e){try{let t=this.#i();delete t[e],we.existsSync(this.configDir)||we.mkdirSync(this.configDir,{recursive:!0}),we.writeFileSync(this.configPath,JSON.stringify(t,null,2),"utf8")}catch(t){console.error(`Failed to clear key ${e} from configuration:`,t)}}reset(){try{we.existsSync(this.configPath)&&we.unlinkSync(this.configPath),we.existsSync(this.configDir)&&we.readdirSync(this.configDir).length===0&&we.rmdirSync(this.configDir),this._resolved=null}catch(e){console.error("Failed to reset configuration:",e)}}},P=new cs;import{styleText as Qt}from"node:util";import Ko from"node:path";import qo from"node:os";import Jo from"node:crypto";import Ke from"winston";var Go=Jo.randomBytes(4).toString("hex"),Bo=Date.now(),Qi=Ko.join(qo.tmpdir(),`apinow-cli-${Bo}-${Go}.log`),Na=new Ke.transports.Console({stderrLevels:Object.keys(Ke.config.cli.levels),level:"info",format:Ke.format.combine(Ke.format.colorize(),Ke.format.simple())}),Wo=new Ke.transports.File({filename:Qi,level:"debug",format:Ke.format.combine(Ke.format.timestamp(),Ke.format.printf(({timestamp:o,level:e,message:t})=>{let i=typeof t=="string"?t.replace(/\u001b\[\d+m/g,""):t;return`${o} [${e.toUpperCase()}]: ${i}`}))}),S=Ke.createLogger({levels:Ke.config.cli.levels,level:"debug",transports:[Na,Wo]});function Ia(o){Na.level=o}var ds=gi.version;var X={green:o=>Qt("green",o),red:o=>Qt("red",o),yellow:o=>Qt("yellow",o),cyan:o=>Qt("cyan",o),dim:o=>Qt("dim",o),bold:o=>Qt("bold",o)};function Ho(o,e,t){if(o.length===0)return"No data available.";let i={},r=t||e;for(let l=0;l<e.length;l++){let c=e[l],p=r[l]||c;i[c]=p.length}for(let l of o)for(let c of e){let p=typeof l[c]=="object"&&l[c]!==null?JSON.stringify(l[c]):String(l[c]??"");p.length>(i[c]||0)&&(i[c]=p.length)}let s=e.map((l,c)=>(r[c]||l).toUpperCase().padEnd(i[l])).join(" "),a=e.map(l=>"-".repeat(i[l])).join(" "),n=o.map(l=>e.map(c=>(typeof l[c]=="object"&&l[c]!==null?JSON.stringify(l[c]):String(l[c]??"")).padEnd(i[c])).join(" "));return[s,a,...n].join(`
4
4
  `)}var B=class{format;constructor(e={}){this.format=e.format||"text"}success(e,t){this.format==="json"?console.log(JSON.stringify({success:!0,message:e,data:t},null,2)):(console.log(X.green(`\u2714 ${e}`)),t!==void 0&&(typeof t=="object"&&t!==null?this.object(t):console.log(t)))}error(e){let t=e.code||"CLI_ERR_UNKNOWN";if(this.format==="json")console.error(JSON.stringify({success:!1,code:t,cliVersion:ds,logFile:Qi,...e},null,2));else{if(console.error(X.red(`\u2716 Error [${t}]: ${e.message}`)),e.detail&&console.error(X.dim(e.detail)),e.errors&&e.errors.length>0){console.error(`
5
5
  Validation errors:`);for(let i of e.errors)console.error(` - ${X.yellow(i.field)}: ${i.message}`)}if(console.error(X.dim(`(cli v${ds})`)),console.error(X.dim(`Log file: ${Qi}`)),t==="CLI_ERR_UNKNOWN"){let i="https://github.com/api-now/cli",r=encodeURIComponent(`[BUG] CLI Crash: ${e.message}`),s=encodeURIComponent(`**CLI Version:** ${ds}
6
6
  **Error Code:** ${t}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@api-now/cli",
3
3
  "description": "API Now! CLI",
4
- "version": "1.7.0",
4
+ "version": "1.7.1",
5
5
  "private": false,
6
6
  "publishConfig": {
7
7
  "registry": "https://registry.npmjs.org/",
@@ -32,7 +32,6 @@
32
32
  },
33
33
  "dependencies": {
34
34
  "@inquirer/prompts": "^8.5.0",
35
- "@api-now/json": "^1.0.0",
36
35
  "commander": "^15.0.0",
37
36
  "nanoid": "^5.1.6",
38
37
  "open": "^11.0.0",
@@ -42,6 +41,7 @@
42
41
  },
43
42
  "devDependencies": {
44
43
  "@api-now/core": "^1.10.0",
44
+ "@api-now/json": "^1.0.0",
45
45
  "@commitlint/cli": "^21.0.1",
46
46
  "@commitlint/config-conventional": "^21.0.1",
47
47
  "@eslint/js": "^10.0.1",