@goldskycom/cli 9.8.0 → 9.8.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/index.js CHANGED
@@ -568,9 +568,9 @@ Status`));let i=[];e.map(s=>{var c;let o=(c=BZ(s,t))==null?void 0:c.runtimeDetai
568
568
  `)})}function qZ(e,t,r="all"){return e.map(n=>{let i=zwe(n,t),s;switch(r){case"all":{s=JSON.stringify(i);break}case"summary":{s=JSON.stringify(kdt(i,["id","name","resource_size","version","status"]));break}case"usableWithApplyCmd":default:{s=JSON.stringify(Ddt(i,["created_at","is_deleted","project_id","runtime_details","updated_at","updated_by_user_id"]));break}}return jM.default.stringify(JSON.parse(s),{indent:2})})}function Edt(e,t,r="all"){qZ(e,t,r).forEach(n=>console.log(n))}function Uwe(e,t){e.forEach(r=>{let n=Gwe(r);console.log(t==="json"?JSON.stringify(n,void 0,2):jM.default.stringify(n,{indent:2})),console.log(`
569
569
  `)})}function zwe(e,t){let r=BZ(e,t),n=e;return r&&(n=Od(po({},e),{runtime_details:r.runtimeDetails})),n}function BZ(e,t){return t.find(r=>r.name===e.name&&r.version===e.version)}function Adt(e,t){var r;if(e==="")return t;if(e==="runtime_details")return(r=this[e])==null?void 0:r.status;if(["id","name","version","status","resource_size"].includes(e))return t}function Ddt(e,t){let r=po({},e);for(let n of t)delete r[n];return r}function kdt(e,t){let r={};for(let n of t)Object.prototype.hasOwnProperty.call(e,n)&&(r[n]=e[n]);return r}function Gwe(e){return"sources"in e&&"transforms"in e&&"sinks"in e?po(po(po({},e.sources),e.transforms),e.sinks):e.definition}var jZ={};eu(jZ,{builder:()=>Rdt,command:()=>Pdt,describe:()=>Idt,handler:()=>Odt,postRequestReceivedMessaging:()=>mk});var LZ=Kl($f()),Pdt="apply <config-path>",Idt="Apply the provided pipeline yaml config. This command creates the pipeline if it doesn't exist or updates the existing pipeline. This command is idempotent.",Rdt=e=>e.positional("config-path",{describe:"path to the yaml pipeline config file.",type:"string",demandOption:!0}).option("save-progress",{describe:"Take a snapshot of the pipeline before applying the update. Only applies if the pipeline already has status: ACTIVE. Defaults to saving progress unless pipeline is being updated to status=INACTIVE.",type:"boolean",demandOption:!1}).option("skip-validation",{describe:"skips the validation of the transforms when updating the pipeline. Defaults to false",type:"boolean",demandOption:!1}).option("use-latest-snapshot",{describe:"attempts to use the latest available snapshot.",type:"boolean",demandOption:!1}),Odt=async e=>{let t=Rj(e.configPath);e.saveProgress!=null&&(t.save_progress=e.saveProgress),e.useLatestSnapshot!=null&&(t.use_latest_snapshot=e.useLatestSnapshot),e.skipTransformValidation!=null&&(t.skip_transform_validation=e.useLatestSnapshot);let r=cd();r.start("Applying pipeline config");let[n,i,s]=await wb(t),o=t.name;if(n)throw ls(r,n.message);if(s&&s.statusCode===202)mk(o,r);else if(i)ls(r,`Successfully applied config to pipeline: ${o}`),i.status!=="INACTIVE"&&console.log(`
570
570
  ${["To monitor the status of your pipeline:","",`Using the CLI: \`goldsky pipeline monitor ${i.name}\``,`Using the dashboard: https://app.goldsky.com/dashboard/pipelines/stream/${i.name}/${i.version}`].join(`
571
- `)}`);else throw ls(r,"Failed to apply pipeline config, please try again")};function mk(e,t){let r=`${LZ.default.bold(`goldsky pipeline monitor ${e} --update-request`)}`,n=`${LZ.default.bold(`goldsky pipeline cancel-update ${e}`)}`;ls(t,"Update request received. It may take some time to complete."),f_(`Please run ${r} to track progress.`),f_(`Or, ${n} to cancel the request.`)}var Fdt=e=>[...e.keys()].find(t=>t.startsWith("public_dataset_")&&t.includes("_logs")),Tdt=e=>[...e.keys()].find(t=>t.startsWith("public_dataset_")&&t.includes("decoded_traces"));function MM(e){let t;return e.definition?t=aR(e.definition):t=Ij(e.definitionPath),{name:e.name,description:e.description,resource_size:e.resourceSize,status:e.status,skip_transform_validation:e.skipTransformValidation,definition:t}}async function $M(e){console.log(""),vg("With Goldsky pipelines, you sync data to your own infrastructure to power your APIs and for data analytics.");let t=await N0e(),r=await Mve(t),n=[];if(Fdt(r)){let a=Array.from(r.entries()).filter(([l])=>l.includes("_logs")).map(([l,u])=>u),c=await Uve(a);n.push(...c)}Tdt(r)&&n.push(...zve([...r.values()]));let i=await y_e(t,[...r.values()],n,e.experimental),s={sources:[...r.values()],transforms:n,sinks:i};return{name:e.name,description:e.description,resource_size:e.resourceSize,status:e.status,skip_transform_validation:e.skipTransformValidation,definition:s}}async function UM(e,t,r){let n=cd();n.start("Creating pipeline");let[i,s,o]=await wb(e);if(i)throw ls(n,i.message);if(s)o&&o.statusCode===202?mk(e.name,n):(ls(n,`Created pipeline: ${s.name}`),r&&!t&&Gw([s],[],r),s.status!=="INACTIVE"&&console.log(`
571
+ `)}`);else throw ls(r,"Failed to apply pipeline config, please try again")};function mk(e,t){let r=`${LZ.default.bold(`goldsky pipeline monitor ${e} --update-request`)}`,n=`${LZ.default.bold(`goldsky pipeline cancel-update ${e}`)}`;ls(t,"Update request received. It may take some time to complete."),f_(`Please run ${r} to track progress.`),f_(`Or, ${n} to cancel the request.`)}var Fdt=e=>[...e.keys()].find(t=>t.startsWith("public_dataset_")&&t.includes("_logs")),Tdt=e=>[...e.keys()].find(t=>t.startsWith("public_dataset_")&&t.includes("decoded_traces"));function MM(e){let t;return e.definition?t=aR(e.definition):t=Ij(e.definitionPath),{name:e.name,description:e.description,resource_size:e.resourceSize,status:e.status,skip_transform_validation:e.skipTransformValidation,dedicated_ips:e.dedicatedEgressIp,definition:t}}async function $M(e){console.log(""),vg("With Goldsky pipelines, you sync data to your own infrastructure to power your APIs and for data analytics.");let t=await N0e(),r=await Mve(t),n=[];if(Fdt(r)){let a=Array.from(r.entries()).filter(([l])=>l.includes("_logs")).map(([l,u])=>u),c=await Uve(a);n.push(...c)}Tdt(r)&&n.push(...zve([...r.values()]));let i=await y_e(t,[...r.values()],n,e.experimental),s={sources:[...r.values()],transforms:n,sinks:i};return{name:e.name,description:e.description,resource_size:e.resourceSize,status:e.status,skip_transform_validation:e.skipTransformValidation,dedicated_ips:e.dedicatedEgressIp,definition:s}}async function UM(e,t,r){let n=cd();n.start("Creating pipeline");let[i,s,o]=await wb(e);if(i)throw ls(n,i.message);if(s)o&&o.statusCode===202?mk(e.name,n):(ls(n,`Created pipeline: ${s.name}`),r&&!t&&Gw([s],[],r),s.status!=="INACTIVE"&&console.log(`
572
572
  ${["To monitor the status of your pipeline:","",`Using the CLI: \`goldsky pipeline monitor ${s.name}\``,`Using the dashboard: https://app.goldsky.com/dashboard/pipelines/stream/${s.name}/${s.version}`].join(`
573
- `)}`));else throw ls(n,"Failed to create pipeline, please try again")}async function zM(e){switch(await dh({message:"What would you like to do?",options:[{value:"direct_indexing",label:"Sync your data with Mirror",hint:"Mirror unrolls data for custom integrations and sends a live stream to your database or warehouse"},{value:"deploy_subgraph",label:"Deploy a subgraph",hint:"Use this if you have your own subgraph"},{value:"see_usage",label:"See all commands",hint:"Displays all available `goldsky` commands"}]})){case"direct_indexing":{let r=await Mo({message:"What's the name of your pipeline?"}),n=await $M({name:r,apiHost:e,resourceSize:"s",status:"ACTIVE"});await UM(n,!0);break}case"deploy_subgraph":YS(`Please use \`goldsky subgraph deploy --help\` to see available subgraph commands or visit ${C0e} for further instructions.`);break;case"see_usage":throw YS("Below is a list of top-level CLI commands. Run `goldsky <cmd> --help` for details on individual commands."),new Error("showHelp")}}async function Vwe({apiHost:e}){let t=cd();t.start("Fetching project overview...");let[r,n]=await io.get("/api/admin/project/v1/overview");if(r)throw ls(t,"Could not fetch project overview"),gf(vh(r));ls(t,"Fetched project overview"),Ff(`You are currently logged in to project "${n.data.name}".
573
+ `)}`));else throw ls(n,"Failed to create pipeline, please try again")}async function zM(e){switch(await dh({message:"What would you like to do?",options:[{value:"direct_indexing",label:"Sync your data with Mirror",hint:"Mirror unrolls data for custom integrations and sends a live stream to your database or warehouse"},{value:"deploy_subgraph",label:"Deploy a subgraph",hint:"Use this if you have your own subgraph"},{value:"see_usage",label:"See all commands",hint:"Displays all available `goldsky` commands"}]})){case"direct_indexing":{let r=await Mo({message:"What's the name of your pipeline?"}),n=await $M({name:r,apiHost:e,resourceSize:"s",status:"ACTIVE",dedicatedEgressIp:!1});await UM(n,!0);break}case"deploy_subgraph":YS(`Please use \`goldsky subgraph deploy --help\` to see available subgraph commands or visit ${C0e} for further instructions.`);break;case"see_usage":throw YS("Below is a list of top-level CLI commands. Run `goldsky <cmd> --help` for details on individual commands."),new Error("showHelp")}}async function Vwe({apiHost:e}){let t=cd();t.start("Fetching project overview...");let[r,n]=await io.get("/api/admin/project/v1/overview");if(r)throw ls(t,"Could not fetch project overview"),gf(vh(r));ls(t,"Fetched project overview"),Ff(`You are currently logged in to project "${n.data.name}".
574
574
 
575
575
  ${MZ.default.bold("Subgraphs")}
576
576
  Active: ${n.data.subgraphs.activeCount}
@@ -582,7 +582,7 @@ Paused: ${n.data.pipelines.pausedCount}
582
582
  Inactive: ${n.data.pipelines.inactiveCount}`,"Project overview"),await zM(e)}var Xwe=require("node:child_process"),Wwe=Kl(aZ());async function Hwe({apiHost:e}){await dh({message:"Do you already have a Goldsky account?",options:[{value:!1,label:"No",hint:"Let's create a new account"},{value:!0,label:"Yes",hint:"Let's log in"}]})?await qj({apiHost:e}):await Ndt({apiHost:e}),Ff("Now that you are logged in, here are a few things you can do next.","Authentication successful"),await zM(e)}async function Ndt({apiHost:e}){let t=`cliaccountcreation_${(0,Wwe.default)()}`,n=`${e.includes("localhost")||e.includes("127.0.0.1")?"http://127.0.0.1:3005":e.includes("internal.goldsky.com")?"https://dev.goldsky.com":"https://app.goldsky.com"}/signup?account_creation_id=${t}`;Ff(`Please visit ${n} to create a new account.`,"Account creation");try{(0,Xwe.spawn)("open",[n])}catch(s){}let i=cd();i.start("Please complete the account creation at the link displayed above...");try{let s=await qdt(t);if(!s)throw ls(i,"Account creation timed out. Please run `goldsky` to try again.");ls(i,"Account created"),await Nj(s),gE(s)}catch(s){let o=s;throw(o==null?void 0:o.status)===409?ls(i,"It looks like you already have a Goldsky account. Please visit https://app.goldsky.com/dashboard/settings to create a new API key. You can then use the `goldsky login` CLI command to log in."):(ls(i,"Account creation failed"),gf(vh(s)))}}async function qdt(e){let t=0,r=5,n=5;for(;t<n*60;){let i=await T0e(e);if(i.apiToken)return i.apiToken;if(i.status!==204)throw i;await new Promise(s=>setTimeout(s,r*1e3)),t+=r}}var Bdt="$0",Ldt="Get started with Goldsky",jdt=e=>e,Mdt=async({apiHost:e})=>{let t=O0e();console.log(""),vg("Crypto Data Live-Streamed"),Ff("Goldsky powers hundreds of crypto businesses building rich, instant, data-driven experiences.","Welcome to the Goldsky CLI"),await t?await Vwe({apiHost:e}):await Hwe({apiHost:e})};var pie={};eu(pie,{builder:()=>UZt,command:()=>MZt,describe:()=>$Zt,handler:()=>zZt});var uie={};eu(uie,{builder:()=>TZt,command:()=>OZt,describe:()=>FZt,handler:()=>NZt});var oie={};eu(oie,{builder:()=>bZt,command:()=>gZt,describe:()=>yZt,handler:()=>SZt});var xje=require("fs");var ZZ=Kl(_Ce());var wCe={barCompleteChar:"\u25A0",barIncompleteChar:" ",format:"{bar} {percentage}% | {value}/{total}"},fk=e=>new ZZ.default.SingleBar(po(po({},wCe),e||{})),CCe=()=>new ZZ.default.MultiBar(Od(po({},wCe),{hideCursor:!0,clearOnComplete:!0,stopOnComplete:!0,emptyOnZero:!0,forceRedraw:!0}));var xCe=require("child_process");var Vw=()=>{let e=cd();e.start("Checking prerequisites");try{(0,xCe.execSync)("duckdb --version",{stdio:"ignore"})}catch(t){throw ls(e,"Please install DuckDB. This helps us efficiently process indexed.xyz data. Instructions can be found at https://duckdb.org/docs/installation")}ls(e,"Checked prerequisites")};var Sje=Kl(require("crypto")),SP=require("fs"),MV=Kl(require("path")),vje=Kl(xS());var $V=Kl(yje());var cZt=()=>{var e,t;return new vje.S3Client({credentials:{accessKeyId:(e=process.env.INDEXED_ACCESS_KEY_ID)!=null?e:"27fa1255881f94d1c05b56ba1d47e1fb",secretAccessKey:(t=process.env.INDEXED_SECRET_ACCESS_KEY)!=null?t:"53f7c1e9edbd9f34d82819c8f3707d83a968d813edc4d9d4be127f99b990fc10"},endpoint:"https://ed5d915e0259fcddb2ab1ce5592040c3.r2.cloudflarestorage.com",region:"auto"})},UV=(e,t)=>!e||t==="2.0.0"?"*":Sje.default.createHash("md5").update(e).digest("hex").slice(-2),vP=({version:e})=>{switch(e){case"1.0.0":case"1.2.0":return"indexed-xyz";case"2.0.0":return"indexed-xyz-wnam"}throw new Error(`Unsupported version: ${e}`)},_P=({network:e,datasetType:t,tableName:r,partitionKey:n,version:i})=>{e==="ethereum"&&i==="1.0.0"&&(i="1.2.0");let s=n==="*"?"":`/partition_key=${n}`;return`${e}/${t}/${r}/v${i}${s}`},lZt=e=>{let t=!1;return r=>{t?e.setTotal(r.count.total):(e.start(r.count.total,0),t=!0)}},bje,uZt=(e,t,r)=>n=>{e&&e(n.filePath),t.increment(),t.getProgress()===1&&(t.stop(),r&&!bje&&(bje=ku("Waiting for new data...").start()))},dZt=(e,t,r)=>{let n=new $V.TransferMonitor;return n.on("progress",lZt(t)),n.on("done",uZt(e,t,r)),n},_je=(e,t,r="")=>{(0,SP.readdirSync)(e).forEach(i=>{let s=MV.default.join(e,i),o=(0,SP.statSync)(s);if(o.isDirectory()){let a=MV.default.join(r,i);_je(s,t,a)}else if(o.isFile()){let a=MV.default.join(r,i);t.add(a)}})},CC=e=>{Ff(`1. Open a second terminal in this directory
583
583
  2. Start DuckDB with \`duckdb\`
584
584
  3. Write your DuckDB SQL queries, e.g. \`SELECT COUNT(*) FROM './data/${e}/*.parquet';\``,"Query data (even while syncing)")},wP=async({sourceBucket:e,sourcePath:t,destinationPath:r,processFile:n,relocations:i,syncProgress:s,shouldSyncContinuously:o=!0})=>{let a=cZt(),{sync:c}=new $V.default({client:a});(0,SP.mkdirSync)(r,{recursive:!0});let l=new Set;do _je(r,l),await c(`s3://${e}/${t}`,r,{filters:[{exclude:()=>!0},{include:u=>!l.has(u)}],relocations:i,monitor:dZt(n,s,o)});while(o)};var wje=require("child_process");var zV=async()=>Mo({message:"What is the contract address you are interested in? (leave blank for all logs)"},{required:!1}).then(e=>{var t;return(t=e==null?void 0:e.toLowerCase())!=null?t:""}),GV=(e,t)=>r=>{let n=r.split("/").pop(),i=`./data/${e}/${n}`;if(!t)throw new Error("Contract address is required");try{(0,wje.execSync)(`duckdb -c "COPY (SELECT * FROM '${r}' WHERE lower(address) IN (lower('${t}'))) TO '${i}' (FORMAT 'parquet');"`)}catch(s){}},pZt=e=>{switch(e){case"2.0.0":return["*"]}return Array.from({length:256},(t,r)=>r.toString(16).padStart(2,"0").toLowerCase())},mZt=async(e,t=10)=>{let r=0,n=async()=>{for(;r<e.length;){let s=e[r];r++,s&&(await s(),await n())}},i=e.slice(0,t);await Promise.all(i.map(n))},VV=async({network:e,processedPath:t,tableName:r,version:n})=>{let i=pZt(n),s=CCe(),o=1,a=i.map(c=>async()=>{let l=vP({version:n}),u=_P({datasetType:"raw",network:e,partitionKey:c,tableName:r,version:n}),m=s.create(0,0);await wP({sourceBucket:l,sourcePath:u,destinationPath:"./data",relocations:[f=>{let y=f.split("/").pop();return`${t}/${y}`}],syncProgress:m,shouldSyncContinuously:!1}),s.log(`Processed ${o++} / ${i.length} parts
585
- `),s.remove(m)});await mZt(a),console.log("Sync complete.")},xC=()=>{let e=cd();e.start(),ls(e,'Syncing... data is stored in the "./data" directory. Stop with Ctrl + C.'),console.log("")};function EC(e){return e.toLowerCase()}function AC(e){return e.toLowerCase()}function Cje(e){return e.toLowerCase()}function CP(e){return e.toLowerCase()}function XV(e){return`${e.charAt(0).toUpperCase()}${e.slice(1).toLowerCase()}`}function WV(e){return e.toUpperCase()}var fZt="1.0.0",hZt={ethereum:"1.2.0",zksync:"2.0.0",optimism:"2.0.0"};function DC(e){return hZt[e]||fZt}var gZt="decoded-logs",yZt="Sync decoded logs for a smart contract from a network to this computer",bZt=e=>e.option("contract-address",{describe:"The contract address you are interested in",type:"string",default:""}).option("network",{describe:"The network of indexed.xyz data to synchronize",type:"string",default:"ethereum",coerce:EC}).option("dataVersion",{describe:"The version of indexed.xyz data to synchronize",type:"string",hidden:!0}),SZt=async e=>{try{console.log(""),vg("Sync decoded logs from indexed.xyz to your local computer"),Vw();let t=e.network.toLowerCase(),r=e.dataVersion,n=e.contractAddress.toLowerCase();if(!n&&r!=="2.0.0"&&(n=await zV()),n&&!r&&(r=t==="ethereum"?"1.2.0":"1.0.0"),r||(r=DC(t)),n&&r==="2.0.0"&&!await ny({message:"This dataset is not partitioned for contract address filtering, you will need to download the whole dataset to filter. Do you want to continue?",initialValue:!1})){console.log("Aborting sync.");return}let i=UV(n,r),s=vP({version:r}),o=_P({datasetType:"decoded",network:t,partitionKey:i,tableName:"logs",version:r}),a=`${t}/decoded/logs/${n}`;(0,xje.mkdirSync)(`./data/${a}`,{recursive:!0}),CC(a),xC(),await wP({sourceBucket:s,sourcePath:o,destinationPath:"./data/.tmp",processFile:n?GV(a,n):void 0,syncProgress:fk(),relocations:n?void 0:[c=>{let l=c.split("/").pop();return`${a}/${l}`}]})}catch(t){throw await Fw("Syncing failed.",t),t}};var aie={};eu(aie,{builder:()=>wZt,command:()=>vZt,describe:()=>_Zt,handler:()=>CZt});var Eje=require("fs");var vZt="raw-blocks",_Zt="Sync all blocks from a network",wZt=e=>e.option("network",{describe:"The network of indexed.xyz data to synchronize",type:"string",default:"ethereum",coerce:EC}).option("dataVersion",{describe:"The version of indexed.xyz data to synchronize",type:"string",hidden:!0}),CZt=async e=>{try{console.log(""),vg("Sync raw blocks from indexed.xyz to your local computer"),Vw();let t=e.network.toLowerCase(),r="raw",n="blocks",i=`${t}/${r}/${n}`;(0,Eje.mkdirSync)(`./data/${i}`,{recursive:!0}),CC(i),xC(),await VV({network:t,processedPath:i,tableName:n,version:e.dataVersion||DC(t)})}catch(t){throw await Fw("Syncing failed.",t),t}};var cie={};eu(cie,{builder:()=>AZt,command:()=>xZt,describe:()=>EZt,handler:()=>DZt});var Aje=require("fs");var xZt="raw-logs",EZt="Sync all logs from a network",AZt=e=>e.option("contract-address",{describe:"The contract address you are interested in",type:"string",default:""}).option("network",{describe:"The network of indexed.xyz data to synchronize",type:"string",default:"ethereum",coerce:EC}).option("dataVersion",{describe:"The version of indexed.xyz data to synchronize",type:"string",hidden:!0}),DZt=async e=>{try{console.log(""),vg("Sync raw logs from indexed.xyz to your local computer"),Vw();let t=e.network.toLowerCase(),r=e.dataVersion,n=e.contractAddress.toLowerCase();if(!n&&r!=="2.0.0"&&(n=await zV()),r||(r=DC(t)),n&&r==="2.0.0"&&!await ny({message:"This dataset is not partitioned for contract address filtering, you will need to download the whole dataset to filter. Do you want to continue?",initialValue:!1})){console.log("Aborting sync.");return}let i=UV(n,r),s=vP({version:r}),o=_P({datasetType:"raw",network:t,partitionKey:i,tableName:"logs",version:r}),a=`${t}/raw/logs/${n}`;(0,Aje.mkdirSync)(`./data/${a}`,{recursive:!0}),CC(a),xC(),await wP({sourceBucket:s,sourcePath:o,destinationPath:"./data/.tmp",processFile:n?GV(a,n):void 0,syncProgress:fk(),relocations:n?void 0:[c=>{let l=c.split("/").pop();return`${a}/${l}`}]})}catch(t){throw await Fw("Syncing failed.",t),t}};var lie={};eu(lie,{builder:()=>IZt,command:()=>kZt,describe:()=>PZt,handler:()=>RZt});var Dje=require("fs");var kZt="raw-transactions",PZt="Sync all transactions from a network",IZt=e=>e.option("network",{describe:"The network of indexed.xyz data to synchronize",type:"string",default:"ethereum",coerce:EC}).option("dataVersion",{describe:"The version of indexed.xyz data to synchronize",type:"string",hidden:!0}),RZt=async e=>{try{console.log(""),vg("Sync raw transactions from indexed.xyz to your local computer"),Vw();let t=e.network.toLowerCase(),r="raw",n="transactions",i=`${t}/${r}/${n}`;(0,Dje.mkdirSync)(`./data/${i}`,{recursive:!0}),CC(i),xC(),await VV({network:t,processedPath:i,tableName:n,version:e.dataVersion||DC(t)})}catch(t){throw await Fw("Syncing failed.",t),t}};var OZt="sync",FZt="Commands related to syncing indexed.xyz real-time raw & decoded crypto datasets",TZt=e=>e.command(oie).command(aie).command(cie).command(lie).demandCommand(1),NZt=async()=>{};var die={};eu(die,{builder:()=>LZt,command:()=>qZt,describe:()=>BZt,handler:()=>jZt});var qZt="rill",BZt="Analyze indexed.xyz data with Rill",LZt=e=>e,jZt=e=>{console.log(""),vg("Analyze indexed.xyz data with Rill Data"),Ff("Please refer to https://www.rilldata.com/indexed-xyz for the latest news on analyzing Indexed.xyz data with Rill.")};var MZt="indexed",$Zt="Analyze blockchain data with indexed.xyz",UZt=e=>e.command(uie).command("rill",!1,die).version(!1).demandCommand(1),zZt=async()=>{};var mie={};eu(mie,{builder:()=>XZt,command:()=>GZt,describe:()=>VZt,handler:()=>WZt});var GZt="login",VZt="Log in to Goldsky to enable authenticated CLI commands",XZt=e=>e.version(!1),WZt=async({apiHost:e,token:t})=>{await qj({apiHost:e,token:t})};var fie={};eu(fie,{builder:()=>ZZt,command:()=>HZt,describe:()=>KZt,handler:()=>YZt});var HZt="logout",KZt="Log out of Goldsky on this computer",ZZt=e=>e.version(!1),YZt=async({apiHost:e})=>{await F0e({apiHost:e})};var Gie={};eu(Gie,{builder:()=>FJt,command:()=>RJt,describe:()=>OJt,handler:()=>TJt});var gie={};eu(gie,{builder:()=>eYt,command:()=>JZt,describe:()=>QZt,handler:()=>tYt});var hie=Kl($f());function HV(e,t){return io.get(r=>`/api/admin/streams/v1/${r.name}?version=${r.version||""}&pipelineConfigVersion=${t}`,{params:e})}function kje(e){return io.post("/api/admin/streams/v1/runtime-details",{body:{namesAndVersions:[{name:e.name,version:e.version}]}})}async function KV(e,t,r,n){let i=ku("Fetching pipeline");n||(i=i.start());let[s,o]=await HV(e,r);if(s)throw i.fail(s.message),s;{if(n||i.succeed(),n){Uwe(o instanceof Array?o:[o],t);return}let a=ku("Fetching pipeline runtime details").start(),[c,l]=await kje(e);c?a.warn("Couldn't load pipeline runtime details"):a.succeed(),Gw(o,c?[]:l,t)}}var JZt="get <nameOrConfigPath>",QZt="Get a pipeline",eYt=e=>e.positional("nameOrConfigPath",{describe:"pipeline name or config file path",type:"string",demandOption:!0}).option("outputFormat",{describe:"format of the output. Either json or table. Defaults to json.",alias:["output"],type:"string",choices:Qn.AllStreamCliOuputFormats,default:"yaml",coerce:AC,deprecated:!0}).option("pipelineConfigVersion",{describe:"[BETA] define v3 to see an experimental new pipeline configuration output. Defaults to v2.",type:"string",choices:["v2","v3"],default:"v3",hidden:!0}).option("definition",{describe:"print the pipeline's definition only (sources, transforms, sinks)",type:"boolean"}).option("version",{describe:"pipeline version. Returns latest version of the pipeline if not set. Passing 'all' returns all versions.",type:"string"}),tYt=async e=>{e.outputFormat!=="yaml"&&(console.warn(hie.default.yellow('The "--output" and "--output-format" flags are deprecated and will be removed in a future major release of the CLI. The default output format going forward will be yaml.')),console.warn(""));let t=Fy(e.nameOrConfigPath);await KV({name:t,version:e.version},e.outputFormat,e.pipelineConfigVersion,e.definition),e.pipelineConfigVersion==="v2"&&console.warn(hie.default.yellow(`[deprecated] You requested the legacy v2 pipeline config. See ${Dj} for the latest config documentation.`))};var bie={};eu(bie,{builder:()=>iYt,command:()=>rYt,describe:()=>nYt,handler:()=>sYt});var yie=Kl($f());var rYt="get-definition <name>",nYt=yie.default.yellow('[deprecated] Get a shareable pipeline definition. Use "pipeline get <name> --definition" instead.'),iYt=e=>e.positional("name",{describe:"pipeline name",type:"string",demandOption:!0}).option("outputFormat",{describe:"format of the output. Either json or yaml. Defaults to yaml.",alias:["output"],type:"string",default:"yaml",choices:Qn.AllStreamCliOuputFormats.filter(t=>t!=="table"),demandOption:!1,coerce:AC,deprecated:!0}).option("pipelineConfigVersion",{describe:"[BETA] define v3 to see an experimental new pipeline configuration output. Defaults to v2.",type:"string",choices:["v2","v3"],default:"v2",hidden:!0}),sYt=async e=>{console.warn(yie.default.yellow('[deprecated] Use "pipeline get <name> --definition" instead')),console.warn(""),await KV({name:e.name},e.outputFormat,e.pipelineConfigVersion,!0)};var Sie={};eu(Sie,{builder:()=>cYt,command:()=>oYt,describe:()=>aYt,handler:()=>lYt});var lA=Kl($f());var oYt="create <name>",aYt="Create a pipeline",cYt=e=>e.positional("name",{describe:"name of the new pipeline",type:"string",demandOption:!0}).option("output",{describe:"format of the output. Either json or table. Defaults to table.",alias:["outputFormat"],type:"string",default:"yaml",choices:Qn.AllStreamCliOuputFormats,demandOption:!1}).option("resource-size",{describe:"runtime resource size for when the pipeline runs",alias:["resourceSize"],choices:Qn.AllResourceSizes,default:"s",type:"string",demandOption:!0,coerce:CP,deprecated:lA.default.yellow("Use 'pipeline resize'")}).option("skip-transform-validation",{describe:"skips the validation of the transforms when creating the pipeline.",type:"boolean",demandOption:!1}).option("description",{describe:"the description of the new pipeline",type:"string",demandOption:!1,deprecated:lA.default.yellow("Use 'pipeline apply'")}).option("definition",{describe:"definition of the pipeline that includes sources, transforms, sinks. Provided as json eg: `{sources: [], transforms: [], sinks:[]}`",type:"string",demandOption:!1,deprecated:lA.default.yellow("Use 'pipeline apply'")}).option("definition-path",{describe:"path to a json/yaml file with the definition of the pipeline that includes sources, transforms, sinks.",type:"string",demandOption:!1,deprecated:lA.default.yellow("Use 'pipeline apply'")}).option("status",{describe:"the desired status of the pipeline",type:"string",choices:Qn.AllStreamStatusValidAtCreate,default:"ACTIVE",demandOption:!1,coerce:WV,deprecated:lA.default.yellow("Use 'pipeline start/stop/pause'")}).conflicts("definition","definition-path"),lYt=async e=>{await uYt(e.name);let t,r=!1;e.definition||e.definitionPath?(console.warn(lA.default.yellow('[deprecated] Use "pipeline apply" instead')),console.warn(""),t=MM(e)):(r=!0,t=await $M(e)),await UM(t,r,e.outputFormat)};async function uYt(e){let[t]=await io.post("/api/admin/streams/v1/validate-new-stream",{body:{name:e}});if(t)throw t}var vie={};eu(vie,{builder:()=>mYt,command:()=>dYt,describe:()=>pYt,handler:()=>fYt});var ZV=Kl($f());var dYt="update <name>",pYt=ZV.default.yellow('[deprecated] Update a pipeline. Use "pipeline apply" instead.'),mYt=e=>e.positional("name",{describe:"name of the pipeline to update.",type:"string",demandOption:!0}).option("outputFormat",{describe:"format of the output. Either json or table. Defaults to json.",alias:["output"],type:"string",choices:Qn.AllStreamCliOuputFormats,default:"yaml",demandOption:!0,coerce:AC,deprecated:!0}).option("resource-size",{describe:"runtime resource size for when the pipeline runs ",alias:["resourceSize"],choices:Qn.AllResourceSizes,type:"string",demandOption:!1,coerce:CP}).option("status",{describe:"status of the pipeline",type:"string",choices:Qn.AllStreamStatuses,demandOption:!1,coerce:WV}).option("save-progress",{describe:"takes a snapshot of the pipeline before applying the update. Only applies if the pipeline already has status: ACTIVE. Defaults to saving progress unless pipeline is being updated to status=INACTIVE.",type:"boolean",demandOption:!1}).option("skip-transform-validation",{describe:"skips the validation of the transforms when updating the pipeline.",type:"boolean",demandOption:!1}).option("use-latest-snapshot",{describe:"attempts to use the latest available snapshot.",type:"boolean",demandOption:!1}).option("definition",{describe:"definition of the pipeline that includes sources, transforms, sinks. Provided as json eg: `{sources: [], transforms: [], sinks:[]}`",type:"string",demandOption:!1}).option("definition-path",{describe:"path to a json/yaml file with the definition of the pipeline that includes sources, transforms, sinks.",type:"string",demandOption:!1}).option("description",{describe:"description of the pipeline`",type:"string",demandOption:!1}).conflicts("definition","definition-path"),fYt=async e=>{console.warn(ZV.default.yellow('[deprecated] Use "pipeline apply" instead')),console.warn(""),e.outputFormat!=="yaml"&&(console.warn(ZV.default.yellow('The "--output" and "--output-format" flags are deprecated and will be removed in a future major release of the CLI. The default output format going forward will be yaml.')),console.warn(""));let t={name:e.name,status:e.status,description:e.description,resource_size:e.resourceSize,save_progress:e.saveProgress,skip_transform_validation:e.skipTransformValidation,use_latest_snapshot:e.useLatestSnapshot,update_only:!0},r;e.definition?r=Od(po({},t),{definition:aR(e.definition)}):e.definitionPath&&(r=Od(po({},t),{definition:Ij(e.definitionPath)}));let n=cd();n.start("Updating pipeline");let i=r||t,[s,o,a]=await wb(i);if(s)throw ls(n,s.message);{let c=e.name;if(a&&a.statusCode===202)mk(c,n);else if(o)ls(n,`Updated pipeline: ${c}`),e.outputFormat&&Gw([o],[],e.outputFormat),o.status!=="INACTIVE"&&console.log(`
585
+ `),s.remove(m)});await mZt(a),console.log("Sync complete.")},xC=()=>{let e=cd();e.start(),ls(e,'Syncing... data is stored in the "./data" directory. Stop with Ctrl + C.'),console.log("")};function EC(e){return e.toLowerCase()}function AC(e){return e.toLowerCase()}function Cje(e){return e.toLowerCase()}function CP(e){return e.toLowerCase()}function XV(e){return`${e.charAt(0).toUpperCase()}${e.slice(1).toLowerCase()}`}function WV(e){return e.toUpperCase()}var fZt="1.0.0",hZt={ethereum:"1.2.0",zksync:"2.0.0",optimism:"2.0.0"};function DC(e){return hZt[e]||fZt}var gZt="decoded-logs",yZt="Sync decoded logs for a smart contract from a network to this computer",bZt=e=>e.option("contract-address",{describe:"The contract address you are interested in",type:"string",default:""}).option("network",{describe:"The network of indexed.xyz data to synchronize",type:"string",default:"ethereum",coerce:EC}).option("dataVersion",{describe:"The version of indexed.xyz data to synchronize",type:"string",hidden:!0}),SZt=async e=>{try{console.log(""),vg("Sync decoded logs from indexed.xyz to your local computer"),Vw();let t=e.network.toLowerCase(),r=e.dataVersion,n=e.contractAddress.toLowerCase();if(!n&&r!=="2.0.0"&&(n=await zV()),n&&!r&&(r=t==="ethereum"?"1.2.0":"1.0.0"),r||(r=DC(t)),n&&r==="2.0.0"&&!await ny({message:"This dataset is not partitioned for contract address filtering, you will need to download the whole dataset to filter. Do you want to continue?",initialValue:!1})){console.log("Aborting sync.");return}let i=UV(n,r),s=vP({version:r}),o=_P({datasetType:"decoded",network:t,partitionKey:i,tableName:"logs",version:r}),a=`${t}/decoded/logs/${n}`;(0,xje.mkdirSync)(`./data/${a}`,{recursive:!0}),CC(a),xC(),await wP({sourceBucket:s,sourcePath:o,destinationPath:"./data/.tmp",processFile:n?GV(a,n):void 0,syncProgress:fk(),relocations:n?void 0:[c=>{let l=c.split("/").pop();return`${a}/${l}`}]})}catch(t){throw await Fw("Syncing failed.",t),t}};var aie={};eu(aie,{builder:()=>wZt,command:()=>vZt,describe:()=>_Zt,handler:()=>CZt});var Eje=require("fs");var vZt="raw-blocks",_Zt="Sync all blocks from a network",wZt=e=>e.option("network",{describe:"The network of indexed.xyz data to synchronize",type:"string",default:"ethereum",coerce:EC}).option("dataVersion",{describe:"The version of indexed.xyz data to synchronize",type:"string",hidden:!0}),CZt=async e=>{try{console.log(""),vg("Sync raw blocks from indexed.xyz to your local computer"),Vw();let t=e.network.toLowerCase(),r="raw",n="blocks",i=`${t}/${r}/${n}`;(0,Eje.mkdirSync)(`./data/${i}`,{recursive:!0}),CC(i),xC(),await VV({network:t,processedPath:i,tableName:n,version:e.dataVersion||DC(t)})}catch(t){throw await Fw("Syncing failed.",t),t}};var cie={};eu(cie,{builder:()=>AZt,command:()=>xZt,describe:()=>EZt,handler:()=>DZt});var Aje=require("fs");var xZt="raw-logs",EZt="Sync all logs from a network",AZt=e=>e.option("contract-address",{describe:"The contract address you are interested in",type:"string",default:""}).option("network",{describe:"The network of indexed.xyz data to synchronize",type:"string",default:"ethereum",coerce:EC}).option("dataVersion",{describe:"The version of indexed.xyz data to synchronize",type:"string",hidden:!0}),DZt=async e=>{try{console.log(""),vg("Sync raw logs from indexed.xyz to your local computer"),Vw();let t=e.network.toLowerCase(),r=e.dataVersion,n=e.contractAddress.toLowerCase();if(!n&&r!=="2.0.0"&&(n=await zV()),r||(r=DC(t)),n&&r==="2.0.0"&&!await ny({message:"This dataset is not partitioned for contract address filtering, you will need to download the whole dataset to filter. Do you want to continue?",initialValue:!1})){console.log("Aborting sync.");return}let i=UV(n,r),s=vP({version:r}),o=_P({datasetType:"raw",network:t,partitionKey:i,tableName:"logs",version:r}),a=`${t}/raw/logs/${n}`;(0,Aje.mkdirSync)(`./data/${a}`,{recursive:!0}),CC(a),xC(),await wP({sourceBucket:s,sourcePath:o,destinationPath:"./data/.tmp",processFile:n?GV(a,n):void 0,syncProgress:fk(),relocations:n?void 0:[c=>{let l=c.split("/").pop();return`${a}/${l}`}]})}catch(t){throw await Fw("Syncing failed.",t),t}};var lie={};eu(lie,{builder:()=>IZt,command:()=>kZt,describe:()=>PZt,handler:()=>RZt});var Dje=require("fs");var kZt="raw-transactions",PZt="Sync all transactions from a network",IZt=e=>e.option("network",{describe:"The network of indexed.xyz data to synchronize",type:"string",default:"ethereum",coerce:EC}).option("dataVersion",{describe:"The version of indexed.xyz data to synchronize",type:"string",hidden:!0}),RZt=async e=>{try{console.log(""),vg("Sync raw transactions from indexed.xyz to your local computer"),Vw();let t=e.network.toLowerCase(),r="raw",n="transactions",i=`${t}/${r}/${n}`;(0,Dje.mkdirSync)(`./data/${i}`,{recursive:!0}),CC(i),xC(),await VV({network:t,processedPath:i,tableName:n,version:e.dataVersion||DC(t)})}catch(t){throw await Fw("Syncing failed.",t),t}};var OZt="sync",FZt="Commands related to syncing indexed.xyz real-time raw & decoded crypto datasets",TZt=e=>e.command(oie).command(aie).command(cie).command(lie).demandCommand(1),NZt=async()=>{};var die={};eu(die,{builder:()=>LZt,command:()=>qZt,describe:()=>BZt,handler:()=>jZt});var qZt="rill",BZt="Analyze indexed.xyz data with Rill",LZt=e=>e,jZt=e=>{console.log(""),vg("Analyze indexed.xyz data with Rill Data"),Ff("Please refer to https://www.rilldata.com/indexed-xyz for the latest news on analyzing Indexed.xyz data with Rill.")};var MZt="indexed",$Zt="Analyze blockchain data with indexed.xyz",UZt=e=>e.command(uie).command("rill",!1,die).version(!1).demandCommand(1),zZt=async()=>{};var mie={};eu(mie,{builder:()=>XZt,command:()=>GZt,describe:()=>VZt,handler:()=>WZt});var GZt="login",VZt="Log in to Goldsky to enable authenticated CLI commands",XZt=e=>e.version(!1),WZt=async({apiHost:e,token:t})=>{await qj({apiHost:e,token:t})};var fie={};eu(fie,{builder:()=>ZZt,command:()=>HZt,describe:()=>KZt,handler:()=>YZt});var HZt="logout",KZt="Log out of Goldsky on this computer",ZZt=e=>e.version(!1),YZt=async({apiHost:e})=>{await F0e({apiHost:e})};var Gie={};eu(Gie,{builder:()=>FJt,command:()=>RJt,describe:()=>OJt,handler:()=>TJt});var gie={};eu(gie,{builder:()=>eYt,command:()=>JZt,describe:()=>QZt,handler:()=>tYt});var hie=Kl($f());function HV(e,t){return io.get(r=>`/api/admin/streams/v1/${r.name}?version=${r.version||""}&pipelineConfigVersion=${t}`,{params:e})}function kje(e){return io.post("/api/admin/streams/v1/runtime-details",{body:{namesAndVersions:[{name:e.name,version:e.version}]}})}async function KV(e,t,r,n){let i=ku("Fetching pipeline");n||(i=i.start());let[s,o]=await HV(e,r);if(s)throw i.fail(s.message),s;{if(n||i.succeed(),n){Uwe(o instanceof Array?o:[o],t);return}let a=ku("Fetching pipeline runtime details").start(),[c,l]=await kje(e);c?a.warn("Couldn't load pipeline runtime details"):a.succeed(),Gw(o,c?[]:l,t)}}var JZt="get <nameOrConfigPath>",QZt="Get a pipeline",eYt=e=>e.positional("nameOrConfigPath",{describe:"pipeline name or config file path",type:"string",demandOption:!0}).option("outputFormat",{describe:"format of the output. Either json or table. Defaults to json.",alias:["output"],type:"string",choices:Qn.AllStreamCliOuputFormats,default:"yaml",coerce:AC,deprecated:!0}).option("pipelineConfigVersion",{describe:"[BETA] define v3 to see an experimental new pipeline configuration output. Defaults to v2.",type:"string",choices:["v2","v3"],default:"v3",hidden:!0}).option("definition",{describe:"print the pipeline's definition only (sources, transforms, sinks)",type:"boolean"}).option("version",{describe:"pipeline version. Returns latest version of the pipeline if not set. Passing 'all' returns all versions.",type:"string"}),tYt=async e=>{e.outputFormat!=="yaml"&&(console.warn(hie.default.yellow('The "--output" and "--output-format" flags are deprecated and will be removed in a future major release of the CLI. The default output format going forward will be yaml.')),console.warn(""));let t=Fy(e.nameOrConfigPath);await KV({name:t,version:e.version},e.outputFormat,e.pipelineConfigVersion,e.definition),e.pipelineConfigVersion==="v2"&&console.warn(hie.default.yellow(`[deprecated] You requested the legacy v2 pipeline config. See ${Dj} for the latest config documentation.`))};var bie={};eu(bie,{builder:()=>iYt,command:()=>rYt,describe:()=>nYt,handler:()=>sYt});var yie=Kl($f());var rYt="get-definition <name>",nYt=yie.default.yellow('[deprecated] Get a shareable pipeline definition. Use "pipeline get <name> --definition" instead.'),iYt=e=>e.positional("name",{describe:"pipeline name",type:"string",demandOption:!0}).option("outputFormat",{describe:"format of the output. Either json or yaml. Defaults to yaml.",alias:["output"],type:"string",default:"yaml",choices:Qn.AllStreamCliOuputFormats.filter(t=>t!=="table"),demandOption:!1,coerce:AC,deprecated:!0}).option("pipelineConfigVersion",{describe:"[BETA] define v3 to see an experimental new pipeline configuration output. Defaults to v2.",type:"string",choices:["v2","v3"],default:"v2",hidden:!0}),sYt=async e=>{console.warn(yie.default.yellow('[deprecated] Use "pipeline get <name> --definition" instead')),console.warn(""),await KV({name:e.name},e.outputFormat,e.pipelineConfigVersion,!0)};var Sie={};eu(Sie,{builder:()=>cYt,command:()=>oYt,describe:()=>aYt,handler:()=>lYt});var lA=Kl($f());var oYt="create <name>",aYt="Create a pipeline",cYt=e=>e.positional("name",{describe:"name of the new pipeline",type:"string",demandOption:!0}).option("output",{describe:"format of the output. Either json or table. Defaults to table.",alias:["outputFormat"],type:"string",default:"yaml",choices:Qn.AllStreamCliOuputFormats,demandOption:!1}).option("resource-size",{describe:"runtime resource size for when the pipeline runs",alias:["resourceSize"],choices:Qn.AllResourceSizes,default:"s",type:"string",demandOption:!0,coerce:CP,deprecated:lA.default.yellow("Use 'pipeline resize'")}).option("skip-transform-validation",{describe:"skips the validation of the transforms when creating the pipeline.",type:"boolean",demandOption:!1}).option("description",{describe:"the description of the new pipeline",type:"string",demandOption:!1,deprecated:lA.default.yellow("Use 'pipeline apply'")}).option("definition",{describe:"definition of the pipeline that includes sources, transforms, sinks. Provided as json eg: `{sources: [], transforms: [], sinks:[]}`",type:"string",demandOption:!1,deprecated:lA.default.yellow("Use 'pipeline apply'")}).option("definition-path",{describe:"path to a json/yaml file with the definition of the pipeline that includes sources, transforms, sinks.",type:"string",demandOption:!1,deprecated:lA.default.yellow("Use 'pipeline apply'")}).option("status",{describe:"the desired status of the pipeline",type:"string",choices:Qn.AllStreamStatusValidAtCreate,default:"ACTIVE",demandOption:!1,coerce:WV,deprecated:lA.default.yellow("Use 'pipeline start/stop/pause'")}).option("dedicated-egress-ip",{describe:"Whether the pipeline should use dedicated egress IPs",type:"boolean",default:!1,demandOption:!0,hidden:!0}).conflicts("definition","definition-path"),lYt=async e=>{await uYt(e.name);let t,r=!1;e.definition||e.definitionPath?(console.warn(lA.default.yellow('[deprecated] Use "pipeline apply" instead')),console.warn(""),t=MM(e)):(r=!0,t=await $M(e)),await UM(t,r,e.outputFormat)};async function uYt(e){let[t]=await io.post("/api/admin/streams/v1/validate-new-stream",{body:{name:e}});if(t)throw t}var vie={};eu(vie,{builder:()=>mYt,command:()=>dYt,describe:()=>pYt,handler:()=>fYt});var ZV=Kl($f());var dYt="update <name>",pYt=ZV.default.yellow('[deprecated] Update a pipeline. Use "pipeline apply" instead.'),mYt=e=>e.positional("name",{describe:"name of the pipeline to update.",type:"string",demandOption:!0}).option("outputFormat",{describe:"format of the output. Either json or table. Defaults to json.",alias:["output"],type:"string",choices:Qn.AllStreamCliOuputFormats,default:"yaml",demandOption:!0,coerce:AC,deprecated:!0}).option("resource-size",{describe:"runtime resource size for when the pipeline runs ",alias:["resourceSize"],choices:Qn.AllResourceSizes,type:"string",demandOption:!1,coerce:CP}).option("status",{describe:"status of the pipeline",type:"string",choices:Qn.AllStreamStatuses,demandOption:!1,coerce:WV}).option("save-progress",{describe:"takes a snapshot of the pipeline before applying the update. Only applies if the pipeline already has status: ACTIVE. Defaults to saving progress unless pipeline is being updated to status=INACTIVE.",type:"boolean",demandOption:!1}).option("skip-transform-validation",{describe:"skips the validation of the transforms when updating the pipeline.",type:"boolean",demandOption:!1}).option("use-latest-snapshot",{describe:"attempts to use the latest available snapshot.",type:"boolean",demandOption:!1}).option("definition",{describe:"definition of the pipeline that includes sources, transforms, sinks. Provided as json eg: `{sources: [], transforms: [], sinks:[]}`",type:"string",demandOption:!1}).option("definition-path",{describe:"path to a json/yaml file with the definition of the pipeline that includes sources, transforms, sinks.",type:"string",demandOption:!1}).option("description",{describe:"description of the pipeline`",type:"string",demandOption:!1}).conflicts("definition","definition-path"),fYt=async e=>{console.warn(ZV.default.yellow('[deprecated] Use "pipeline apply" instead')),console.warn(""),e.outputFormat!=="yaml"&&(console.warn(ZV.default.yellow('The "--output" and "--output-format" flags are deprecated and will be removed in a future major release of the CLI. The default output format going forward will be yaml.')),console.warn(""));let t={name:e.name,status:e.status,description:e.description,resource_size:e.resourceSize,save_progress:e.saveProgress,skip_transform_validation:e.skipTransformValidation,use_latest_snapshot:e.useLatestSnapshot,update_only:!0},r;e.definition?r=Od(po({},t),{definition:aR(e.definition)}):e.definitionPath&&(r=Od(po({},t),{definition:Ij(e.definitionPath)}));let n=cd();n.start("Updating pipeline");let i=r||t,[s,o,a]=await wb(i);if(s)throw ls(n,s.message);{let c=e.name;if(a&&a.statusCode===202)mk(c,n);else if(o)ls(n,`Updated pipeline: ${c}`),e.outputFormat&&Gw([o],[],e.outputFormat),o.status!=="INACTIVE"&&console.log(`
586
586
  ${["To monitor the status of your pipeline:","",`Using the CLI: \`goldsky pipeline monitor ${o.name}\``,`Using the dashboard: https://app.goldsky.com/dashboard/pipelines/stream/${o.name}/${o.version}`].join(`
587
587
  `)}`);else throw ls(n,"Failed to update pipeline, please try again")}};var _ie={};eu(_ie,{builder:()=>yYt,command:()=>hYt,describe:()=>gYt,handler:()=>bYt});async function Pje(e){let t=ku("Deleting pipeline").start(),[r]=await io.delete_(()=>`/api/admin/streams/v1/${e.name}`);if(r)throw t.fail(r.message),r;t.succeed(`Deleted pipeline with name: ${e.name}`)}var hYt="delete <nameOrConfigPath>",gYt="Delete a pipeline",yYt=e=>e.positional("nameOrConfigPath",{describe:"pipeline name or config file path",type:"string",demandOption:!0}).option("f",{alias:"force",describe:"Force the deletion without prompting for confirmation",type:"boolean",default:!1}),bYt=async e=>{let t=Fy(e.nameOrConfigPath);if(!e.force){let r=await R0({message:"Please enter the pipeline name to confirm you want to delete it",validate(n){if(n!==t)return"Invalid pipeline name. To cancel, use Ctrl + C."}});if(Rg(r)){let n="Pipeline deletion cancelled.";throw Sg(n),gf(n)}}await Pje({name:t})};var wie={};eu(wie,{builder:()=>_Yt,command:()=>SYt,describe:()=>vYt,handler:()=>wYt});var Ije=Kl($f());function YV(){return io.get("/api/admin/streams/v1/")}async function Rje(e,t="all",r=!1){let n=ku("Listing pipelines").start(),[i,s]=await YV();if(i)throw n.fail(i.message),i;if(n.succeed(),s.length>0){let o=s.map(c=>({name:c.name,version:c.version})),a=[];if(r){let c=ku("Fetching pipeline runtime details").start(),[l,u]=await io.post("/api/admin/streams/v1/runtime-details",{body:{namesAndVersions:o}});l?c.warn("Couldn't load pipeline runtime details"):(c.succeed(),a=u)}Gw(s,a,e,t)}else console.log(`No pipelines found. Create one with ${Ije.default.bold("goldsky pipeline create")}.`)}var SYt="list",vYt="List all pipelines",_Yt=e=>e.option("output",{describe:"format of the output. Either json or table. Defaults to json.",alias:["outputFormat"],type:"string",choices:Qn.AllStreamCliOuputFormats,default:"table"}).option("outputVerbosity",{describe:"Either summary or all. Defaults to summary.",type:"string",choices:Mwe,default:"summary",coerce:Cje}).option("include-runtime-details",{describe:"includes runtime details for each pipeline like runtime status and errors. Defaults to false.",type:"boolean",demandOption:!1,default:!1}),wYt=async e=>{await Rje(e.output,e.outputVerbosity,e.includeRuntimeDetails),console.log("Specify `--include-runtime-details true` to include runtime details like pipeline status and errors."),console.log(""),console.log("Use `goldsky pipeline get <pipeline-name>` to load more details for a given pipeline."),console.log("Alternatively, try `goldsky pipeline monitor <pipeline-name>` to continuously monitor an active pipeline."),console.log("")};var Fie={};eu(Fie,{builder:()=>ZYt,command:()=>HYt,describe:()=>KYt,handler:()=>YYt});var JN=Kl($f());var zje=Kl(Uje());var YN=Kl($f());async function Gje(e){let t=cd();t.start("Checking update status");let[r,n]=await Hje(e);if(r)throw ls(t,r.message);let i=`You can monitor the pipeline with ${YN.default.bold(`goldsky pipeline monitor ${e}`)}`;switch(n.status){case"COMPLETED":Vje(t,i);break;case"CANCELED":Xje(t,i);break;case"TIMED_OUT":case"FAILED":{Wje(t,n,i);break}case"IN_PROGRESS":{await MYt(e,t,i);break}}}async function MYt(e,t,r){ls(t,"Monitoring update progress");let n=fk({format:"Snapshot creation in progress: {bar} {percentage}%",hideCursor:!0,clearOnComplete:!0,stopOnComplete:!0,emptyOnZero:!0,forceRedraw:!0});f_(`You may cancel the update request by running ${YN.default.bold(`goldsky pipeline cancel-update ${e}
588
588
  `)}`);let i=100;for(n.start(i,0);;){let[s,o]=await Hje(e);if(s){t.message("Encountered an error while communicating with the API. Will retry..."),await new Promise(a=>setTimeout(a,15e3));continue}else{let a=o.status;if((a==="IN_PROGRESS"||a==="TRIGGERED")&&o.progressPercent)n.update(o.progressPercent);else if(a==="COMPLETED")n.update(i),Vje(t,r),dA();else{if(a==="FAILED"||a==="TIMED_OUT")throw Wje(t,o,r),new Error(`Latest update request has ${a.toLocaleLowerCase().replace("_"," ")}. This may be because the pipeline is having issues.`);a==="CANCELED"&&(Xje(t,r),dA())}}await new Promise(a=>setTimeout(a,5e3))}}function Vje(e,t){ls(e,"Latest update request has successfully completed."),f_(t)}function Xje(e,t){ls(e,"Latest update request was cancelled."),f_(t)}function Wje(e,t,r){let n=t.status;ls(e,`Latest update request has ${n.toLocaleLowerCase().replace("_"," ")}. This may be because the pipeline is having issues.`),f_(r);let i=t.latestCompletedSnapshot;if(i&&i.startedAt){let o=i.startedAt,a=`${YN.default.bold((0,zje.format)(new Date(o),"en_US"))}`;f_(`Or, you may use an older snapshot from ${a} by retrying the update request with the ${YN.default.bold("--use-latest-snapshot")} flag.`)}}async function Hje(e){return io.get(t=>`/api/admin/streams/v1/${t.name}/update-status`,{params:{name:e}})}async function r4(e,t,r){if(r){await Gje(e.name);return}let n=ku("Validating request").start();if(e.version==="all"){let a="Cannot monitor all versions of the pipeline, please provide a specific version or no version to monitor the latest";throw n.fail(a),new Error(a)}n.succeed();let i=ku("Fetching pipeline").start(),[s,o]=await io.get(a=>`/api/admin/streams/v1/${a.name}?version=${a.version||""}`,{params:e});if(s)throw i.fail(s.message),s;{i.succeed();let a=o[0],c=ku("Validating pipeline status");if(a.status==="INACTIVE"){let l=`Stream has status '${a.status}', only 'ACTIVE' pipelines can be monitored`;throw c.fail(l),new Error(l)}c.succeed(),await $Yt(a,t)}}async function $Yt(e,t){let r=new Set(["Timestamp","Status"]),n={"total.records.received":"Total records received","total.records.processed":"Total records written"},i=10,s=5,o=0,a=0,c=ku("Fetching runtime details").start(),l=ku(),u;do{let[y,C]=await UYt(e.name,e.version.toString());if(y)o++,Kje(c,l).warn(`Attempt: ${o}. Encountered error fetching pipeline runtime status. Retrying...`);else if((C==null?void 0:C.length)===0)o++;else{o=0,a++,c.isSpinning?c.succeed():l.isSpinning&&(process.stdout.clearLine(0),process.stdout.moveCursor(0,-1),process.stdout.cursorTo(Number.MAX_SAFE_INTEGER));let{errors:I,status:F,jobStats:T}=C[0].runtimeDetails,M=[Zje(),XYt(F)];if(GYt(T,n,r,M),VYt(I,r,M),!u){let Y=Array.from(r.values());u=WYt(Y),u.write(Y.map(de=>JN.default.green(de)))}u.write(M)}t&&a===t||await zYt(c,l,i)}while(o<=s&&a<(t||Number.MAX_VALUE));let m=Kje(c,l);t&&a===t&&(m.succeed(`Successfully printed ${t} data refreshes!`),dA());let f=`Encountered continuous errors attempting to monitor the pipeline! Either the pipeline has an 'INACTIVE' or 'PAUSED' status, or there might be other issues.
@@ -632,7 +632,7 @@ ${Wg.default.goldsky.pink.underline(w0e)}`,Wg.default.goldsky.orange.bold("Suppo
632
632
  --host ${e.url.substring(8)} \\
633
633
  --user "${e.username}" \\
634
634
  --password "${e.password}"
635
- `)}function $5e(){let e="clickhouse";return dle()==="currentDir"&&(e=`./${e}`),e}var Edr="connect",Adr="Connect to your Goldsky ClickHouse database",Ddr=e=>e,kdr=async()=>{console.log(""),vg("Goldsky ClickHouse - Connect"),Ff("Goldsky ClickHouse is based on ClickHouse (https://clickhouse.com).","Get started"),B5e();let e=await N5e();switch(await dh({message:"How would you like to connect?",options:[{label:"Automatically connect",value:"automatically",hint:"Once you hit Enter, you will be connected to the ClickHouse database."},{label:"Manually connect",value:"manually",hint:"Once you hit Enter, you will see the connection details."}]})){case"automatically":j5e(e);break;case"manually":M5e(e);break}};var Pdr="clickhouse",Idr="Commands related to Goldsky ClickHouse",Rdr=e=>e.command(ple).version(!1).demandCommand(1),Odr=async()=>{};var Fdr="db",Tdr="Commands related to Goldsky DB",Ndr=e=>e.command(mle).version(!1).demandCommand(1),qdr=async()=>{};var Zle={};eu(Zle,{builder:()=>vmr,command:()=>bmr,describe:()=>Smr,handler:()=>_mr});var Wle={};eu(Wle,{builder:()=>lmr,command:()=>amr,describe:()=>cmr,handler:()=>Xle});var Z6e=Kl(X6e()),Ule=require("crypto");var CI=Kl(require("os"));var MA={name:"@goldskycom/cli",version:"9.8.0",description:"The Goldsky CLI to deploy subgraphs, index & transform blockchain data, configure webhooks, and access your data in real-time.",main:"dist/index.js",keywords:["goldsky","web3","blockchain","real-time","data pipelines","streams","webhooks"],author:"Goldsky",scripts:{lint:"eslint --max-warnings 0 .","lint:summary":"pnpm lint --format summary || pnpm lint",typecheck:"tsc --noEmit",clean:"rimraf ./binaries ./dist ./tsconfig.tsbuildinfo",build:"pnpm clean && tsc --noEmit --skipLibCheck && node ./scripts/build.js && chmod a+x bin/goldsky","build:binaries":"pnpm build && rimraf ./binaries && node ./scripts/binaries-build.js","deploy:binaries":"node ./scripts/binaries-deploy.js","dev:debug":"NODE_ENV=development ts-node src/index.ts","dev:dist":"NODE_ENV=development node dist/index.js",prepublishOnly:"pnpm build","test:unit":"pnpm build && tsc --skipLibCheck && NODE_ENV=unit-tests node --test --test-reporter spec dist","docs:reference:generate":"pnpm build && GOLDSKY_PARSE_CLI_OUTPUT_FOR_DOCS=true ts-node ./scripts/reference-docs/index.ts","docs:reference:copy":"test -f ./cli-reference.md && test -f ../../../docs/reference/cli.mdx && cp ./cli-reference.md ../../../docs/reference/cli.mdx","docs:reference:update":"pnpm docs:reference:generate && pnpm docs:reference:copy"},bin:{goldsky:"bin/goldsky"},files:["bin/goldsky","dist"],devDependencies:{"@aws-sdk/abort-controller":"^3.272.0","@aws-sdk/client-s3":"^3.272.0","@clack/prompts":"^0.7.0","@goldskyio/core":"workspace:*","@sinclair/typebox":"^0.32.34","@types/cli-progress":"^3.11.0","@types/form-data":"^2.5.0","@types/jszip":"^3.4.1","@types/node":"^18.15.0","@types/readline-sync":"^1.4.4","@types/semver":"^7.5.1","@types/yaml":"^1.9.7","@types/yargs":"^17.0.7",abitype:"0.1.7",ajv:"^8.11.2",axios:"^1.4.0",chalk:"^4.1.2","cli-progress":"^3.12.0",conf:"10.2.0","form-data":"^4.0.0",jszip:"^3.7.1",ora:"4.1.1",pkg:"^5.7.0","s3-sync-client":"^4.3.1",semver:"^7.3.7","simple-update-notifier":"^2.0.0",table:"^6.8.1",typescript:"^5.3.3",yaml:"^1.10.2",yargs:"^17.7.2"},license:"",dependencies:{cuid:"^2.1.8","parse-duration":"^1.0.3","readline-sync":"^1.4.10","timeago.js":"^4.0.2"}};var Z9;function W6e(){if(Z9)return Z9;let e=CI.default.cpus()||[];return Z9={systemPlatform:CI.default.platform(),systemRelease:CI.default.release(),systemArchitecture:CI.default.arch(),cpuCount:e.length,cpuModel:e.length?e[0].model:null,cpuSpeed:e.length?e[0].speed:null,memoryInMb:Math.trunc(CI.default.totalmem()/Math.pow(1024,2)),isCI:!!process.env.CI,cliVersion:MA.version},Z9}var Y6e=Kl($f());var Y9="telemetry.enabled",H6e="telemetry.notifiedAt",K6e="telemetry.anonymousId",Gy=imr(),tmr=(0,Ule.randomBytes)(32).toString("hex"),rmr=omr();smr();function zle(){Gy&&Gy.set(Y9,!0)}function J6e(){Gy&&Gy.set(Y9,!1)}function Q6e(){return!!(Gy!=null&&Gy.get(Y9,!1))}function nmr(){return Gy?Gy.get(Y9,!0)!==!1:!1}function eVe(e){return Gle("CLI_COMMAND",{command:Vle(e)})}function tVe(e){return Gle("CLI_COMMAND_FAILED",Od(po({},e),{command:Vle(e.command)}))}function rVe(e){return Gle("CLI_COMMAND_SUCCEEDED",Od(po({},e),{command:Vle(e.command)}))}function imr(){try{return new Z6e.default({projectName:"goldsky"})}catch(e){return null}}function smr(){!Gy||nVe()||Gy.get(H6e)===void 0&&(Gy.set(H6e,Date.now().toString()),zle(),console.log(`${(0,Y6e.cyan)("Attention")}: Goldsky now collects completely anonymous telemetry regarding usage. This is used to guide Goldsky's CLI roadmap and to provide support.`),console.log("You can learn more, including how to opt-out of this anonymous program, by heading over to:"),console.log(x0e),console.log())}function nVe(){return!nmr()||!!process.env.GOLDSKY_CLI_TELEMETRY_DISABLED}async function Gle(e,t){if(nVe())return Promise.resolve();let r={anonymousId:rmr,sessionId:tmr};try{io.setAuth(""),await io.post("/api/public/telemetry/v1/cli",{body:{context:r,environment:W6e(),events:[{name:e,properties:t}]}})}catch(n){}finally{await Tj()}}function omr(){let e=Gy&&Gy.get(K6e);if(e)return e;let t=(0,Ule.randomBytes)(32).toString("hex");return Gy&&Gy.set(K6e,t),t}function Vle(e){return e.replace(/--token\s+\S+\s?/,"").trim()}var amr="status",cmr="Display the CLI telemetry status",lmr=e=>e,Xle=()=>{console.log(`Anonymous CLI telemetry is ${Q6e()?"enabled":"disabled"}.`)};var Hle={};eu(Hle,{builder:()=>pmr,command:()=>umr,describe:()=>dmr,handler:()=>mmr});var umr="enable",dmr="Enable anonymous CLI telemetry",pmr=e=>e,mmr=()=>{zle(),console.log("Anonymous CLI telemetry enabled.")};var Kle={};eu(Kle,{builder:()=>gmr,command:()=>fmr,describe:()=>hmr,handler:()=>ymr});var fmr="disable",hmr="Disable anonymous CLI telemetry",gmr=e=>e,ymr=()=>{J6e(),console.log("Anonymous CLI telemetry disabled.")};var bmr="telemetry",Smr="Commands related to CLI telemetry",vmr=e=>e.command(Wle).command(Hle).command(Kle).version(!1),_mr=()=>{Xle()};var dw=Kl($f());dw.default.goldsky={red:dw.default.hex("#ff6984"),orange:dw.default.hex("#ffbf60"),yellow:dw.default.hex("#ffe23c"),green:dw.default.hex("#94ffab"),blue:dw.default.hex("#8bc7ff"),purple:dw.default.hex("#ab9fff"),pink:dw.default.hex("#ff9ffb")};var uVe=Kl(lVe()),dVe=async()=>{await(0,uVe.default)({pkg:MA,alwaysRun:!0})};var Lmr=e=>["subgraph init","subgraph list","subgraph tag delete"].includes(e),jmr=wX(process.argv);dVe().then(Tj).then(async()=>{let e=Xde(jmr).scriptName("goldsky").usage("$0 <cmd> args").check(t=>{if(t.nameAndVersion&&typeof t.nameAndVersion=="string"&&!Lmr(t._.join(" "))&&!t.nameAndVersion.match(/^.*\/.*$/))throw new Error(`The provided <nameAndValue> "${t.nameAndVersion}" does not match the "name/version" pattern, such as "my-subgraph/1.0.0".`);return!0}).option("apiHost",{alias:"api-host",describe:"Goldsky API host path",type:"string",default:OL,hidden:!0}).option("token",{describe:"CLI Auth Token",type:"string",default:""}).option("color",{describe:"Colorize output",type:"boolean",default:!0}).option("experimental",{describe:"Enable experimental features",type:"boolean",default:!jI,hidden:!0}).command($Z).command(mie).command(fie).command(lle).command(sse).command(Gie).command("db",!1,fle).command(Wie).command(pie).command(pse).command(Zle).version(MA.version).alias("v","version").alias("h","help").strict().demandCommand(1).middleware([({color:t})=>{t||(pVe.default.level=0)},t=>{io.setApiHost(t.apiHost),io.setApiClientAndVersion("cli",MA.version)},t=>{if(t._.length>0)return eVe(t._.join(" "))},t=>{t.token&&gE(t.token)}]).fail(function(t,r,n){if((r==null?void 0:r.message)==="showHelp"&&n.showHelp("log"),r)throw t?console.error(t):r!=null&&r.message&&console.error(r.message),r;n.showHelp("log"),t&&console.error(t),process.exit(1)});process.env.GOLDSKY_PARSE_CLI_OUTPUT_FOR_DOCS&&e.wrap(null);try{await e.parse(),dA()}catch(t){Mmr(t)}});var mVe=Date.now();async function Mmr(e){await tVe({command:process.argv.slice(2).join(" "),duration:Date.now()-mVe,errorName:e instanceof Error?e.name:"ApiError",errorMessage:t()}),process.exit(1);function t(){return e instanceof Error?e.message:typeof e!="string"&&"reason"in e?e.reason:e.message||e.error||JSON.stringify(e)}}function dA(){rVe({command:process.argv.slice(2).join(" "),duration:Date.now()-mVe}).finally(()=>{process.exit(0)})}0&&(module.exports={exit});
635
+ `)}function $5e(){let e="clickhouse";return dle()==="currentDir"&&(e=`./${e}`),e}var Edr="connect",Adr="Connect to your Goldsky ClickHouse database",Ddr=e=>e,kdr=async()=>{console.log(""),vg("Goldsky ClickHouse - Connect"),Ff("Goldsky ClickHouse is based on ClickHouse (https://clickhouse.com).","Get started"),B5e();let e=await N5e();switch(await dh({message:"How would you like to connect?",options:[{label:"Automatically connect",value:"automatically",hint:"Once you hit Enter, you will be connected to the ClickHouse database."},{label:"Manually connect",value:"manually",hint:"Once you hit Enter, you will see the connection details."}]})){case"automatically":j5e(e);break;case"manually":M5e(e);break}};var Pdr="clickhouse",Idr="Commands related to Goldsky ClickHouse",Rdr=e=>e.command(ple).version(!1).demandCommand(1),Odr=async()=>{};var Fdr="db",Tdr="Commands related to Goldsky DB",Ndr=e=>e.command(mle).version(!1).demandCommand(1),qdr=async()=>{};var Zle={};eu(Zle,{builder:()=>vmr,command:()=>bmr,describe:()=>Smr,handler:()=>_mr});var Wle={};eu(Wle,{builder:()=>lmr,command:()=>amr,describe:()=>cmr,handler:()=>Xle});var Z6e=Kl(X6e()),Ule=require("crypto");var CI=Kl(require("os"));var MA={name:"@goldskycom/cli",version:"9.8.1",description:"The Goldsky CLI to deploy subgraphs, index & transform blockchain data, configure webhooks, and access your data in real-time.",main:"dist/index.js",keywords:["goldsky","web3","blockchain","real-time","data pipelines","streams","webhooks"],author:"Goldsky",scripts:{lint:"eslint --max-warnings 0 .","lint:summary":"pnpm lint --format summary || pnpm lint",typecheck:"tsc --noEmit",clean:"rimraf ./binaries ./dist ./tsconfig.tsbuildinfo",build:"pnpm clean && tsc --noEmit --skipLibCheck && node ./scripts/build.js && chmod a+x bin/goldsky","build:binaries":"pnpm build && rimraf ./binaries && node ./scripts/binaries-build.js","deploy:binaries":"node ./scripts/binaries-deploy.js","dev:debug":"NODE_ENV=development ts-node src/index.ts","dev:dist":"NODE_ENV=development node dist/index.js",prepublishOnly:"pnpm build","test:unit":"pnpm build && tsc --skipLibCheck && NODE_ENV=unit-tests node --test --test-reporter spec dist","docs:reference:generate":"pnpm build && GOLDSKY_PARSE_CLI_OUTPUT_FOR_DOCS=true ts-node ./scripts/reference-docs/index.ts","docs:reference:copy":"test -f ./cli-reference.md && test -f ../../../docs/reference/cli.mdx && cp ./cli-reference.md ../../../docs/reference/cli.mdx","docs:reference:update":"pnpm docs:reference:generate && pnpm docs:reference:copy"},bin:{goldsky:"bin/goldsky"},files:["bin/goldsky","dist"],devDependencies:{"@aws-sdk/abort-controller":"^3.272.0","@aws-sdk/client-s3":"^3.272.0","@clack/prompts":"^0.7.0","@goldskyio/core":"workspace:*","@sinclair/typebox":"^0.32.34","@types/cli-progress":"^3.11.0","@types/form-data":"^2.5.0","@types/jszip":"^3.4.1","@types/node":"^18.15.0","@types/readline-sync":"^1.4.4","@types/semver":"^7.5.1","@types/yaml":"^1.9.7","@types/yargs":"^17.0.7",abitype:"0.1.7",ajv:"^8.11.2",axios:"^1.4.0",chalk:"^4.1.2","cli-progress":"^3.12.0",conf:"10.2.0","form-data":"^4.0.0",jszip:"^3.7.1",ora:"4.1.1",pkg:"^5.7.0","s3-sync-client":"^4.3.1",semver:"^7.3.7","simple-update-notifier":"^2.0.0",table:"^6.8.1",typescript:"^5.3.3",yaml:"^1.10.2",yargs:"^17.7.2"},license:"",dependencies:{cuid:"^2.1.8","parse-duration":"^1.0.3","readline-sync":"^1.4.10","timeago.js":"^4.0.2"}};var Z9;function W6e(){if(Z9)return Z9;let e=CI.default.cpus()||[];return Z9={systemPlatform:CI.default.platform(),systemRelease:CI.default.release(),systemArchitecture:CI.default.arch(),cpuCount:e.length,cpuModel:e.length?e[0].model:null,cpuSpeed:e.length?e[0].speed:null,memoryInMb:Math.trunc(CI.default.totalmem()/Math.pow(1024,2)),isCI:!!process.env.CI,cliVersion:MA.version},Z9}var Y6e=Kl($f());var Y9="telemetry.enabled",H6e="telemetry.notifiedAt",K6e="telemetry.anonymousId",Gy=imr(),tmr=(0,Ule.randomBytes)(32).toString("hex"),rmr=omr();smr();function zle(){Gy&&Gy.set(Y9,!0)}function J6e(){Gy&&Gy.set(Y9,!1)}function Q6e(){return!!(Gy!=null&&Gy.get(Y9,!1))}function nmr(){return Gy?Gy.get(Y9,!0)!==!1:!1}function eVe(e){return Gle("CLI_COMMAND",{command:Vle(e)})}function tVe(e){return Gle("CLI_COMMAND_FAILED",Od(po({},e),{command:Vle(e.command)}))}function rVe(e){return Gle("CLI_COMMAND_SUCCEEDED",Od(po({},e),{command:Vle(e.command)}))}function imr(){try{return new Z6e.default({projectName:"goldsky"})}catch(e){return null}}function smr(){!Gy||nVe()||Gy.get(H6e)===void 0&&(Gy.set(H6e,Date.now().toString()),zle(),console.log(`${(0,Y6e.cyan)("Attention")}: Goldsky now collects completely anonymous telemetry regarding usage. This is used to guide Goldsky's CLI roadmap and to provide support.`),console.log("You can learn more, including how to opt-out of this anonymous program, by heading over to:"),console.log(x0e),console.log())}function nVe(){return!nmr()||!!process.env.GOLDSKY_CLI_TELEMETRY_DISABLED}async function Gle(e,t){if(nVe())return Promise.resolve();let r={anonymousId:rmr,sessionId:tmr};try{io.setAuth(""),await io.post("/api/public/telemetry/v1/cli",{body:{context:r,environment:W6e(),events:[{name:e,properties:t}]}})}catch(n){}finally{await Tj()}}function omr(){let e=Gy&&Gy.get(K6e);if(e)return e;let t=(0,Ule.randomBytes)(32).toString("hex");return Gy&&Gy.set(K6e,t),t}function Vle(e){return e.replace(/--token\s+\S+\s?/,"").trim()}var amr="status",cmr="Display the CLI telemetry status",lmr=e=>e,Xle=()=>{console.log(`Anonymous CLI telemetry is ${Q6e()?"enabled":"disabled"}.`)};var Hle={};eu(Hle,{builder:()=>pmr,command:()=>umr,describe:()=>dmr,handler:()=>mmr});var umr="enable",dmr="Enable anonymous CLI telemetry",pmr=e=>e,mmr=()=>{zle(),console.log("Anonymous CLI telemetry enabled.")};var Kle={};eu(Kle,{builder:()=>gmr,command:()=>fmr,describe:()=>hmr,handler:()=>ymr});var fmr="disable",hmr="Disable anonymous CLI telemetry",gmr=e=>e,ymr=()=>{J6e(),console.log("Anonymous CLI telemetry disabled.")};var bmr="telemetry",Smr="Commands related to CLI telemetry",vmr=e=>e.command(Wle).command(Hle).command(Kle).version(!1),_mr=()=>{Xle()};var dw=Kl($f());dw.default.goldsky={red:dw.default.hex("#ff6984"),orange:dw.default.hex("#ffbf60"),yellow:dw.default.hex("#ffe23c"),green:dw.default.hex("#94ffab"),blue:dw.default.hex("#8bc7ff"),purple:dw.default.hex("#ab9fff"),pink:dw.default.hex("#ff9ffb")};var uVe=Kl(lVe()),dVe=async()=>{await(0,uVe.default)({pkg:MA,alwaysRun:!0})};var Lmr=e=>["subgraph init","subgraph list","subgraph tag delete"].includes(e),jmr=wX(process.argv);dVe().then(Tj).then(async()=>{let e=Xde(jmr).scriptName("goldsky").usage("$0 <cmd> args").check(t=>{if(t.nameAndVersion&&typeof t.nameAndVersion=="string"&&!Lmr(t._.join(" "))&&!t.nameAndVersion.match(/^.*\/.*$/))throw new Error(`The provided <nameAndValue> "${t.nameAndVersion}" does not match the "name/version" pattern, such as "my-subgraph/1.0.0".`);return!0}).option("apiHost",{alias:"api-host",describe:"Goldsky API host path",type:"string",default:OL,hidden:!0}).option("token",{describe:"CLI Auth Token",type:"string",default:""}).option("color",{describe:"Colorize output",type:"boolean",default:!0}).option("experimental",{describe:"Enable experimental features",type:"boolean",default:!jI,hidden:!0}).command($Z).command(mie).command(fie).command(lle).command(sse).command(Gie).command("db",!1,fle).command(Wie).command(pie).command(pse).command(Zle).version(MA.version).alias("v","version").alias("h","help").strict().demandCommand(1).middleware([({color:t})=>{t||(pVe.default.level=0)},t=>{io.setApiHost(t.apiHost),io.setApiClientAndVersion("cli",MA.version)},t=>{if(t._.length>0)return eVe(t._.join(" "))},t=>{t.token&&gE(t.token)}]).fail(function(t,r,n){if((r==null?void 0:r.message)==="showHelp"&&n.showHelp("log"),r)throw t?console.error(t):r!=null&&r.message&&console.error(r.message),r;n.showHelp("log"),t&&console.error(t),process.exit(1)});process.env.GOLDSKY_PARSE_CLI_OUTPUT_FOR_DOCS&&e.wrap(null);try{await e.parse(),dA()}catch(t){Mmr(t)}});var mVe=Date.now();async function Mmr(e){await tVe({command:process.argv.slice(2).join(" "),duration:Date.now()-mVe,errorName:e instanceof Error?e.name:"ApiError",errorMessage:t()}),process.exit(1);function t(){return e instanceof Error?e.message:typeof e!="string"&&"reason"in e?e.reason:e.message||e.error||JSON.stringify(e)}}function dA(){rVe({command:process.argv.slice(2).join(" "),duration:Date.now()-mVe}).finally(()=>{process.exit(0)})}0&&(module.exports={exit});
636
636
  /*!
637
637
  * mime-db
638
638
  * Copyright(c) 2014 Jonathan Ong