@mirage-cli/dataforseo-cli 0.1.2 → 0.1.4
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/bin.js +666 -0
- package/dist/dfs.js +22 -45
- package/dist/index.js +22 -44
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1,32 +1,11 @@
|
|
|
1
|
-
import{
|
|
2
|
-
|
|
3
|
-
`)
|
|
4
|
-
|
|
5
|
-
`),l=" ".
|
|
6
|
-
|
|
7
|
-
`)
|
|
8
|
-
|
|
9
|
-
(Did you mean one of ${a.join(", ")}?)`;if(a.length===1)return`
|
|
10
|
-
(Did you mean ${a[0]}?)`;return""}da.suggestSimilar=na});var zo=O((fa)=>{var la=Y("node:events").EventEmitter,le=Y("node:child_process"),R=Y("node:path"),pe=Y("node:fs"),I=Y("node:process"),{Argument:pa,humanReadableArgName:ha}=Q(),{CommanderError:he}=N(),{Help:ga}=de(),{Option:xo,DualOptions:ma}=ce(),{suggestSimilar:Ro}=Do();class ge extends la{constructor(e){super();this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!0,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=e||"",this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._summary="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._outputConfiguration={writeOut:(o)=>I.stdout.write(o),writeErr:(o)=>I.stderr.write(o),getOutHelpWidth:()=>I.stdout.isTTY?I.stdout.columns:void 0,getErrHelpWidth:()=>I.stderr.isTTY?I.stderr.columns:void 0,outputError:(o,t)=>t(o)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={}}copyInheritedSettings(e){return this._outputConfiguration=e._outputConfiguration,this._helpOption=e._helpOption,this._helpCommand=e._helpCommand,this._helpConfiguration=e._helpConfiguration,this._exitCallback=e._exitCallback,this._storeOptionsAsProperties=e._storeOptionsAsProperties,this._combineFlagAndOptionalValue=e._combineFlagAndOptionalValue,this._allowExcessArguments=e._allowExcessArguments,this._enablePositionalOptions=e._enablePositionalOptions,this._showHelpAfterError=e._showHelpAfterError,this._showSuggestionAfterError=e._showSuggestionAfterError,this}_getCommandAndAncestors(){let e=[];for(let o=this;o;o=o.parent)e.push(o);return e}command(e,o,t){let a=o,s=t;if(typeof a==="object"&&a!==null)s=a,a=null;s=s||{};let[,i,n]=e.match(/([^ ]+) *(.*)/),r=this.createCommand(i);if(a)r.description(a),r._executableHandler=!0;if(s.isDefault)this._defaultCommandName=r._name;if(r._hidden=!!(s.noHelp||s.hidden),r._executableFile=s.executableFile||null,n)r.arguments(n);if(this._registerCommand(r),r.parent=this,r.copyInheritedSettings(this),a)return this;return r}createCommand(e){return new ge(e)}createHelp(){return Object.assign(new ga,this.configureHelp())}configureHelp(e){if(e===void 0)return this._helpConfiguration;return this._helpConfiguration=e,this}configureOutput(e){if(e===void 0)return this._outputConfiguration;return Object.assign(this._outputConfiguration,e),this}showHelpAfterError(e=!0){if(typeof e!=="string")e=!!e;return this._showHelpAfterError=e,this}showSuggestionAfterError(e=!0){return this._showSuggestionAfterError=!!e,this}addCommand(e,o){if(!e._name)throw Error(`Command passed to .addCommand() must have a name
|
|
11
|
-
- specify the name in Command constructor or using .name()`);if(o=o||{},o.isDefault)this._defaultCommandName=e._name;if(o.noHelp||o.hidden)e._hidden=!0;return this._registerCommand(e),e.parent=this,e._checkForBrokenPassThrough(),this}createArgument(e,o){return new pa(e,o)}argument(e,o,t,a){let s=this.createArgument(e,o);if(typeof t==="function")s.default(a).argParser(t);else s.default(t);return this.addArgument(s),this}arguments(e){return e.trim().split(/ +/).forEach((o)=>{this.argument(o)}),this}addArgument(e){let o=this.registeredArguments.slice(-1)[0];if(o&&o.variadic)throw Error(`only the last argument can be variadic '${o.name()}'`);if(e.required&&e.defaultValue!==void 0&&e.parseArg===void 0)throw Error(`a default value for a required argument is never used: '${e.name()}'`);return this.registeredArguments.push(e),this}helpCommand(e,o){if(typeof e==="boolean")return this._addImplicitHelpCommand=e,this;e=e??"help [command]";let[,t,a]=e.match(/([^ ]+) *(.*)/),s=o??"display help for command",i=this.createCommand(t);if(i.helpOption(!1),a)i.arguments(a);if(s)i.description(s);return this._addImplicitHelpCommand=!0,this._helpCommand=i,this}addHelpCommand(e,o){if(typeof e!=="object")return this.helpCommand(e,o),this;return this._addImplicitHelpCommand=!0,this._helpCommand=e,this}_getHelpCommand(){if(this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"))){if(this._helpCommand===void 0)this.helpCommand(void 0,void 0);return this._helpCommand}return null}hook(e,o){let t=["preSubcommand","preAction","postAction"];if(!t.includes(e))throw Error(`Unexpected value for event passed to hook : '${e}'.
|
|
12
|
-
Expecting one of '${t.join("', '")}'`);if(this._lifeCycleHooks[e])this._lifeCycleHooks[e].push(o);else this._lifeCycleHooks[e]=[o];return this}exitOverride(e){if(e)this._exitCallback=e;else this._exitCallback=(o)=>{if(o.code!=="commander.executeSubCommandAsync")throw o};return this}_exit(e,o,t){if(this._exitCallback)this._exitCallback(new he(e,o,t));I.exit(e)}action(e){let o=(t)=>{let a=this.registeredArguments.length,s=t.slice(0,a);if(this._storeOptionsAsProperties)s[a]=this;else s[a]=this.opts();return s.push(this),e.apply(this,s)};return this._actionHandler=o,this}createOption(e,o){return new xo(e,o)}_callParseArg(e,o,t,a){try{return e.parseArg(o,t)}catch(s){if(s.code==="commander.invalidArgument"){let i=`${a} ${s.message}`;this.error(i,{exitCode:s.exitCode,code:s.code})}throw s}}_registerOption(e){let o=e.short&&this._findOption(e.short)||e.long&&this._findOption(e.long);if(o){let t=e.long&&this._findOption(e.long)?e.long:e.short;throw Error(`Cannot add option '${e.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${t}'
|
|
13
|
-
- already used by option '${o.flags}'`)}this.options.push(e)}_registerCommand(e){let o=(a)=>{return[a.name()].concat(a.aliases())},t=o(e).find((a)=>this._findCommand(a));if(t){let a=o(this._findCommand(t)).join("|"),s=o(e).join("|");throw Error(`cannot add command '${s}' as already have command '${a}'`)}this.commands.push(e)}addOption(e){this._registerOption(e);let o=e.name(),t=e.attributeName();if(e.negate){let s=e.long.replace(/^--no-/,"--");if(!this._findOption(s))this.setOptionValueWithSource(t,e.defaultValue===void 0?!0:e.defaultValue,"default")}else if(e.defaultValue!==void 0)this.setOptionValueWithSource(t,e.defaultValue,"default");let a=(s,i,n)=>{if(s==null&&e.presetArg!==void 0)s=e.presetArg;let r=this.getOptionValue(t);if(s!==null&&e.parseArg)s=this._callParseArg(e,s,r,i);else if(s!==null&&e.variadic)s=e._concatValue(s,r);if(s==null)if(e.negate)s=!1;else if(e.isBoolean()||e.optional)s=!0;else s="";this.setOptionValueWithSource(t,s,n)};if(this.on("option:"+o,(s)=>{let i=`error: option '${e.flags}' argument '${s}' is invalid.`;a(s,i,"cli")}),e.envVar)this.on("optionEnv:"+o,(s)=>{let i=`error: option '${e.flags}' value '${s}' from env '${e.envVar}' is invalid.`;a(s,i,"env")});return this}_optionEx(e,o,t,a,s){if(typeof o==="object"&&o instanceof xo)throw Error("To add an Option object use addOption() instead of option() or requiredOption()");let i=this.createOption(o,t);if(i.makeOptionMandatory(!!e.mandatory),typeof a==="function")i.default(s).argParser(a);else if(a instanceof RegExp){let n=a;a=(r,d)=>{let l=n.exec(r);return l?l[0]:d},i.default(s).argParser(a)}else i.default(a);return this.addOption(i)}option(e,o,t,a){return this._optionEx({},e,o,t,a)}requiredOption(e,o,t,a){return this._optionEx({mandatory:!0},e,o,t,a)}combineFlagAndOptionalValue(e=!0){return this._combineFlagAndOptionalValue=!!e,this}allowUnknownOption(e=!0){return this._allowUnknownOption=!!e,this}allowExcessArguments(e=!0){return this._allowExcessArguments=!!e,this}enablePositionalOptions(e=!0){return this._enablePositionalOptions=!!e,this}passThroughOptions(e=!0){return this._passThroughOptions=!!e,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties(e=!0){if(this.options.length)throw Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!e,this}getOptionValue(e){if(this._storeOptionsAsProperties)return this[e];return this._optionValues[e]}setOptionValue(e,o){return this.setOptionValueWithSource(e,o,void 0)}setOptionValueWithSource(e,o,t){if(this._storeOptionsAsProperties)this[e]=o;else this._optionValues[e]=o;return this._optionValueSources[e]=t,this}getOptionValueSource(e){return this._optionValueSources[e]}getOptionValueSourceWithGlobals(e){let o;return this._getCommandAndAncestors().forEach((t)=>{if(t.getOptionValueSource(e)!==void 0)o=t.getOptionValueSource(e)}),o}_prepareUserArgs(e,o){if(e!==void 0&&!Array.isArray(e))throw Error("first parameter to parse must be array or undefined");if(o=o||{},e===void 0&&o.from===void 0){if(I.versions?.electron)o.from="electron";let a=I.execArgv??[];if(a.includes("-e")||a.includes("--eval")||a.includes("-p")||a.includes("--print"))o.from="eval"}if(e===void 0)e=I.argv;this.rawArgs=e.slice();let t;switch(o.from){case void 0:case"node":this._scriptPath=e[1],t=e.slice(2);break;case"electron":if(I.defaultApp)this._scriptPath=e[1],t=e.slice(2);else t=e.slice(1);break;case"user":t=e.slice(0);break;case"eval":t=e.slice(1);break;default:throw Error(`unexpected parse option { from: '${o.from}' }`)}if(!this._name&&this._scriptPath)this.nameFromFilename(this._scriptPath);return this._name=this._name||"program",t}parse(e,o){let t=this._prepareUserArgs(e,o);return this._parseCommand([],t),this}async parseAsync(e,o){let t=this._prepareUserArgs(e,o);return await this._parseCommand([],t),this}_executeSubCommand(e,o){o=o.slice();let t=!1,a=[".js",".ts",".tsx",".mjs",".cjs"];function s(l,_){let b=R.resolve(l,_);if(pe.existsSync(b))return b;if(a.includes(R.extname(_)))return;let P=a.find((L)=>pe.existsSync(`${b}${L}`));if(P)return`${b}${P}`;return}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let i=e._executableFile||`${this._name}-${e._name}`,n=this._executableDir||"";if(this._scriptPath){let l;try{l=pe.realpathSync(this._scriptPath)}catch(_){l=this._scriptPath}n=R.resolve(R.dirname(l),n)}if(n){let l=s(n,i);if(!l&&!e._executableFile&&this._scriptPath){let _=R.basename(this._scriptPath,R.extname(this._scriptPath));if(_!==this._name)l=s(n,`${_}-${e._name}`)}i=l||i}t=a.includes(R.extname(i));let r;if(I.platform!=="win32")if(t)o.unshift(i),o=Eo(I.execArgv).concat(o),r=le.spawn(I.argv[0],o,{stdio:"inherit"});else r=le.spawn(i,o,{stdio:"inherit"});else o.unshift(i),o=Eo(I.execArgv).concat(o),r=le.spawn(I.execPath,o,{stdio:"inherit"});if(!r.killed)["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach((_)=>{I.on(_,()=>{if(r.killed===!1&&r.exitCode===null)r.kill(_)})});let d=this._exitCallback;r.on("close",(l)=>{if(l=l??1,!d)I.exit(l);else d(new he(l,"commander.executeSubCommandAsync","(close)"))}),r.on("error",(l)=>{if(l.code==="ENOENT"){let _=n?`searched for local subcommand relative to directory '${n}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",b=`'${i}' does not exist
|
|
14
|
-
- if '${e._name}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
|
|
15
|
-
- if the default executable name is not suitable, use the executableFile option to supply a custom name or path
|
|
16
|
-
- ${_}`;throw Error(b)}else if(l.code==="EACCES")throw Error(`'${i}' not executable`);if(!d)I.exit(1);else{let _=new he(1,"commander.executeSubCommandAsync","(error)");_.nestedError=l,d(_)}}),this.runningCommand=r}_dispatchSubcommand(e,o,t){let a=this._findCommand(e);if(!a)this.help({error:!0});let s;return s=this._chainOrCallSubCommandHook(s,a,"preSubcommand"),s=this._chainOrCall(s,()=>{if(a._executableHandler)this._executeSubCommand(a,o.concat(t));else return a._parseCommand(o,t)}),s}_dispatchHelpCommand(e){if(!e)this.help();let o=this._findCommand(e);if(o&&!o._executableHandler)o.help();return this._dispatchSubcommand(e,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){if(this.registeredArguments.forEach((e,o)=>{if(e.required&&this.args[o]==null)this.missingArgument(e.name())}),this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)return;if(this.args.length>this.registeredArguments.length)this._excessArguments(this.args)}_processArguments(){let e=(t,a,s)=>{let i=a;if(a!==null&&t.parseArg){let n=`error: command-argument value '${a}' is invalid for argument '${t.name()}'.`;i=this._callParseArg(t,a,s,n)}return i};this._checkNumberOfArguments();let o=[];this.registeredArguments.forEach((t,a)=>{let s=t.defaultValue;if(t.variadic){if(a<this.args.length){if(s=this.args.slice(a),t.parseArg)s=s.reduce((i,n)=>{return e(t,n,i)},t.defaultValue)}else if(s===void 0)s=[]}else if(a<this.args.length){if(s=this.args[a],t.parseArg)s=e(t,s,t.defaultValue)}o[a]=s}),this.processedArgs=o}_chainOrCall(e,o){if(e&&e.then&&typeof e.then==="function")return e.then(()=>o());return o()}_chainOrCallHooks(e,o){let t=e,a=[];if(this._getCommandAndAncestors().reverse().filter((s)=>s._lifeCycleHooks[o]!==void 0).forEach((s)=>{s._lifeCycleHooks[o].forEach((i)=>{a.push({hookedCommand:s,callback:i})})}),o==="postAction")a.reverse();return a.forEach((s)=>{t=this._chainOrCall(t,()=>{return s.callback(s.hookedCommand,this)})}),t}_chainOrCallSubCommandHook(e,o,t){let a=e;if(this._lifeCycleHooks[t]!==void 0)this._lifeCycleHooks[t].forEach((s)=>{a=this._chainOrCall(a,()=>{return s(this,o)})});return a}_parseCommand(e,o){let t=this.parseOptions(o);if(this._parseOptionsEnv(),this._parseOptionsImplied(),e=e.concat(t.operands),o=t.unknown,this.args=e.concat(o),e&&this._findCommand(e[0]))return this._dispatchSubcommand(e[0],e.slice(1),o);if(this._getHelpCommand()&&e[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(e[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(o),this._dispatchSubcommand(this._defaultCommandName,e,o);if(this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName)this.help({error:!0});this._outputHelpIfRequested(t.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let a=()=>{if(t.unknown.length>0)this.unknownOption(t.unknown[0])},s=`command:${this.name()}`;if(this._actionHandler){a(),this._processArguments();let i;if(i=this._chainOrCallHooks(i,"preAction"),i=this._chainOrCall(i,()=>this._actionHandler(this.processedArgs)),this.parent)i=this._chainOrCall(i,()=>{this.parent.emit(s,e,o)});return i=this._chainOrCallHooks(i,"postAction"),i}if(this.parent&&this.parent.listenerCount(s))a(),this._processArguments(),this.parent.emit(s,e,o);else if(e.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",e,o);if(this.listenerCount("command:*"))this.emit("command:*",e,o);else if(this.commands.length)this.unknownCommand();else a(),this._processArguments()}else if(this.commands.length)a(),this.help({error:!0});else a(),this._processArguments()}_findCommand(e){if(!e)return;return this.commands.find((o)=>o._name===e||o._aliases.includes(e))}_findOption(e){return this.options.find((o)=>o.is(e))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach((e)=>{e.options.forEach((o)=>{if(o.mandatory&&e.getOptionValue(o.attributeName())===void 0)e.missingMandatoryOptionValue(o)})})}_checkForConflictingLocalOptions(){let e=this.options.filter((t)=>{let a=t.attributeName();if(this.getOptionValue(a)===void 0)return!1;return this.getOptionValueSource(a)!=="default"});e.filter((t)=>t.conflictsWith.length>0).forEach((t)=>{let a=e.find((s)=>t.conflictsWith.includes(s.attributeName()));if(a)this._conflictingOption(t,a)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach((e)=>{e._checkForConflictingLocalOptions()})}parseOptions(e){let o=[],t=[],a=o,s=e.slice();function i(r){return r.length>1&&r[0]==="-"}let n=null;while(s.length){let r=s.shift();if(r==="--"){if(a===t)a.push(r);a.push(...s);break}if(n&&!i(r)){this.emit(`option:${n.name()}`,r);continue}if(n=null,i(r)){let d=this._findOption(r);if(d){if(d.required){let l=s.shift();if(l===void 0)this.optionMissingArgument(d);this.emit(`option:${d.name()}`,l)}else if(d.optional){let l=null;if(s.length>0&&!i(s[0]))l=s.shift();this.emit(`option:${d.name()}`,l)}else this.emit(`option:${d.name()}`);n=d.variadic?d:null;continue}}if(r.length>2&&r[0]==="-"&&r[1]!=="-"){let d=this._findOption(`-${r[1]}`);if(d){if(d.required||d.optional&&this._combineFlagAndOptionalValue)this.emit(`option:${d.name()}`,r.slice(2));else this.emit(`option:${d.name()}`),s.unshift(`-${r.slice(2)}`);continue}}if(/^--[^=]+=/.test(r)){let d=r.indexOf("="),l=this._findOption(r.slice(0,d));if(l&&(l.required||l.optional)){this.emit(`option:${l.name()}`,r.slice(d+1));continue}}if(i(r))a=t;if((this._enablePositionalOptions||this._passThroughOptions)&&o.length===0&&t.length===0){if(this._findCommand(r)){if(o.push(r),s.length>0)t.push(...s);break}else if(this._getHelpCommand()&&r===this._getHelpCommand().name()){if(o.push(r),s.length>0)o.push(...s);break}else if(this._defaultCommandName){if(t.push(r),s.length>0)t.push(...s);break}}if(this._passThroughOptions){if(a.push(r),s.length>0)a.push(...s);break}a.push(r)}return{operands:o,unknown:t}}opts(){if(this._storeOptionsAsProperties){let e={},o=this.options.length;for(let t=0;t<o;t++){let a=this.options[t].attributeName();e[a]=a===this._versionOptionName?this._version:this[a]}return e}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((e,o)=>Object.assign(e,o.opts()),{})}error(e,o){if(this._outputConfiguration.outputError(`${e}
|
|
17
|
-
`,this._outputConfiguration.writeErr),typeof this._showHelpAfterError==="string")this._outputConfiguration.writeErr(`${this._showHelpAfterError}
|
|
18
|
-
`);else if(this._showHelpAfterError)this._outputConfiguration.writeErr(`
|
|
19
|
-
`),this.outputHelp({error:!0});let t=o||{},a=t.exitCode||1,s=t.code||"commander.error";this._exit(a,s,e)}_parseOptionsEnv(){this.options.forEach((e)=>{if(e.envVar&&e.envVar in I.env){let o=e.attributeName();if(this.getOptionValue(o)===void 0||["default","config","env"].includes(this.getOptionValueSource(o)))if(e.required||e.optional)this.emit(`optionEnv:${e.name()}`,I.env[e.envVar]);else this.emit(`optionEnv:${e.name()}`)}})}_parseOptionsImplied(){let e=new ma(this.options),o=(t)=>{return this.getOptionValue(t)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(t))};this.options.filter((t)=>t.implied!==void 0&&o(t.attributeName())&&e.valueFromOption(this.getOptionValue(t.attributeName()),t)).forEach((t)=>{Object.keys(t.implied).filter((a)=>!o(a)).forEach((a)=>{this.setOptionValueWithSource(a,t.implied[a],"implied")})})}missingArgument(e){let o=`error: missing required argument '${e}'`;this.error(o,{code:"commander.missingArgument"})}optionMissingArgument(e){let o=`error: option '${e.flags}' argument missing`;this.error(o,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(e){let o=`error: required option '${e.flags}' not specified`;this.error(o,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(e,o){let t=(i)=>{let n=i.attributeName(),r=this.getOptionValue(n),d=this.options.find((_)=>_.negate&&n===_.attributeName()),l=this.options.find((_)=>!_.negate&&n===_.attributeName());if(d&&(d.presetArg===void 0&&r===!1||d.presetArg!==void 0&&r===d.presetArg))return d;return l||i},a=(i)=>{let n=t(i),r=n.attributeName();if(this.getOptionValueSource(r)==="env")return`environment variable '${n.envVar}'`;return`option '${n.flags}'`},s=`error: ${a(e)} cannot be used with ${a(o)}`;this.error(s,{code:"commander.conflictingOption"})}unknownOption(e){if(this._allowUnknownOption)return;let o="";if(e.startsWith("--")&&this._showSuggestionAfterError){let a=[],s=this;do{let i=s.createHelp().visibleOptions(s).filter((n)=>n.long).map((n)=>n.long);a=a.concat(i),s=s.parent}while(s&&!s._enablePositionalOptions);o=Ro(e,a)}let t=`error: unknown option '${e}'${o}`;this.error(t,{code:"commander.unknownOption"})}_excessArguments(e){if(this._allowExcessArguments)return;let o=this.registeredArguments.length,t=o===1?"":"s",s=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${o} argument${t} but got ${e.length}.`;this.error(s,{code:"commander.excessArguments"})}unknownCommand(){let e=this.args[0],o="";if(this._showSuggestionAfterError){let a=[];this.createHelp().visibleCommands(this).forEach((s)=>{if(a.push(s.name()),s.alias())a.push(s.alias())}),o=Ro(e,a)}let t=`error: unknown command '${e}'${o}`;this.error(t,{code:"commander.unknownCommand"})}version(e,o,t){if(e===void 0)return this._version;this._version=e,o=o||"-V, --version",t=t||"output the version number";let a=this.createOption(o,t);return this._versionOptionName=a.attributeName(),this._registerOption(a),this.on("option:"+a.name(),()=>{this._outputConfiguration.writeOut(`${e}
|
|
20
|
-
`),this._exit(0,"commander.version",e)}),this}description(e,o){if(e===void 0&&o===void 0)return this._description;if(this._description=e,o)this._argsDescription=o;return this}summary(e){if(e===void 0)return this._summary;return this._summary=e,this}alias(e){if(e===void 0)return this._aliases[0];let o=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler)o=this.commands[this.commands.length-1];if(e===o._name)throw Error("Command alias can't be the same as its name");let t=this.parent?._findCommand(e);if(t){let a=[t.name()].concat(t.aliases()).join("|");throw Error(`cannot add alias '${e}' to command '${this.name()}' as already have command '${a}'`)}return o._aliases.push(e),this}aliases(e){if(e===void 0)return this._aliases;return e.forEach((o)=>this.alias(o)),this}usage(e){if(e===void 0){if(this._usage)return this._usage;let o=this.registeredArguments.map((t)=>{return ha(t)});return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?o:[]).join(" ")}return this._usage=e,this}name(e){if(e===void 0)return this._name;return this._name=e,this}nameFromFilename(e){return this._name=R.basename(e,R.extname(e)),this}executableDir(e){if(e===void 0)return this._executableDir;return this._executableDir=e,this}helpInformation(e){let o=this.createHelp();if(o.helpWidth===void 0)o.helpWidth=e&&e.error?this._outputConfiguration.getErrHelpWidth():this._outputConfiguration.getOutHelpWidth();return o.formatHelp(this,o)}_getHelpContext(e){e=e||{};let o={error:!!e.error},t;if(o.error)t=(a)=>this._outputConfiguration.writeErr(a);else t=(a)=>this._outputConfiguration.writeOut(a);return o.write=e.write||t,o.command=this,o}outputHelp(e){let o;if(typeof e==="function")o=e,e=void 0;let t=this._getHelpContext(e);this._getCommandAndAncestors().reverse().forEach((s)=>s.emit("beforeAllHelp",t)),this.emit("beforeHelp",t);let a=this.helpInformation(t);if(o){if(a=o(a),typeof a!=="string"&&!Buffer.isBuffer(a))throw Error("outputHelp callback must return a string or a Buffer")}if(t.write(a),this._getHelpOption()?.long)this.emit(this._getHelpOption().long);this.emit("afterHelp",t),this._getCommandAndAncestors().forEach((s)=>s.emit("afterAllHelp",t))}helpOption(e,o){if(typeof e==="boolean"){if(e)this._helpOption=this._helpOption??void 0;else this._helpOption=null;return this}return e=e??"-h, --help",o=o??"display help for command",this._helpOption=this.createOption(e,o),this}_getHelpOption(){if(this._helpOption===void 0)this.helpOption(void 0,void 0);return this._helpOption}addHelpOption(e){return this._helpOption=e,this}help(e){this.outputHelp(e);let o=I.exitCode||0;if(o===0&&e&&typeof e!=="function"&&e.error)o=1;this._exit(o,"commander.help","(outputHelp)")}addHelpText(e,o){let t=["beforeAll","before","after","afterAll"];if(!t.includes(e))throw Error(`Unexpected value for position to addHelpText.
|
|
21
|
-
Expecting one of '${t.join("', '")}'`);let a=`${e}Help`;return this.on(a,(s)=>{let i;if(typeof o==="function")i=o({error:s.error,command:s.command});else i=o;if(i)s.write(`${i}
|
|
22
|
-
`)}),this}_outputHelpIfRequested(e){let o=this._getHelpOption();if(o&&e.find((a)=>o.is(a)))this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)")}}function Eo(e){return e.map((o)=>{if(!o.startsWith("--inspect"))return o;let t,a="127.0.0.1",s="9229",i;if((i=o.match(/^(--inspect(-brk)?)$/))!==null)t=i[1];else if((i=o.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null)if(t=i[1],/^\d+$/.test(i[3]))s=i[3];else a=i[3];else if((i=o.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null)t=i[1],a=i[3],s=i[4];if(t&&s!=="0")return`${t}=${a}:${parseInt(s)+1}`;return o})}fa.Command=ge});var qo=O((ya)=>{var{Argument:Bo}=Q(),{Command:me}=zo(),{CommanderError:va,InvalidArgumentError:Oo}=N(),{Help:_a}=de(),{Option:Yo}=ce();ya.program=new me;ya.createCommand=(e)=>new me(e);ya.createOption=(e,o)=>new Yo(e,o);ya.createArgument=(e,o)=>new Bo(e,o);ya.Command=me;ya.Option=Yo;ya.Argument=Bo;ya.Help=_a;ya.CommanderError=va;ya.InvalidArgumentError=Oo;ya.InvalidOptionArgumentError=Oo});var Fo=Mt(qo(),1),{program:_s,createCommand:ys,createArgument:ks,createOption:ws,CommanderError:bs,InvalidArgumentError:Ts,InvalidOptionArgumentError:Is,Command:H,Argument:Ss,Option:Mo,Help:Ls}=Fo.default;var c=Object.freeze({NONE:"none",PATH:"path",TEXT:"text"});class p{short;long;valueKind;numericShorthand;description;defaultValue;required;constructor(e={}){this.short=e.short??null,this.long=e.long??null,this.valueKind=e.valueKind??c.NONE,this.numericShorthand=e.numericShorthand??!1,this.description=e.description??null,this.defaultValue=e.defaultValue??null,this.required=e.required??!1,Object.freeze(this)}get name(){return this.long??this.short??""}}class q{kind;name;variadic;required;constructor(e={}){this.kind=e.kind??c.PATH,this.name=e.name??"arg",this.variadic=e.variadic??!1,this.required=e.required??!0,Object.freeze(this)}}class h{options;positional;rest;ignoreTokens;description;constructor(e={}){this.options=Object.freeze([...e.options??[]]),this.positional=Object.freeze([...e.positional??[]]),this.rest=e.rest??null,this.ignoreTokens=new Set(e.ignoreTokens??[]),this.description=e.description??null,Object.freeze(this)}}class fe{flags;args;cachePaths;pathFlagValues;constructor(e){this.flags=e.flags,this.args=e.args,this.cachePaths=e.cachePaths??[],this.pathFlagValues=e.pathFlagValues??[]}paths(){return this.args.filter(([,e])=>e===c.PATH).map(([e])=>e)}routingPaths(){return[...this.paths(),...this.pathFlagValues]}texts(){return this.args.filter(([,e])=>e===c.TEXT).map(([e])=>e)}flag(e,o=null){return this.flags[e]??o}}class S{stdout;stderr;exitCode;reads;writes;cache;streamSource;constructor(e={}){this.stdout=Ko(e.stdout??null),this.stderr=Ko(e.stderr??null),this.exitCode=e.exitCode??0,this.reads=e.reads??{},this.writes=e.writes??{},this.cache=e.cache??[],this.streamSource=null}}function Ko(e){if(e===null||e===void 0)return null;if(e instanceof Uint8Array)return e;if(typeof e==="string")return new TextEncoder().encode(e);return null}function g(e){return Object.freeze({name:e.name,resource:e.resource??null,spec:e.spec,fn:e.fn,description:e.description??e.spec.description??null})}function G(e){return Object.freeze({name:e.name,description:e.description??null,commands:Object.freeze([...e.commands??[]]),groups:Object.freeze([...e.groups??[]])})}var Da=new TextDecoder;async function Co(e,o={}){let t=Array.isArray(o)?ue(e.spec,o):o,a={flags:t.flags??{},stdin:t.stdin??null},s=await e.fn({},t.paths??[],t.texts??[],a),[i,n]=xa(s),r=await No(i??n.stdout);return{bytes:r,text:Da.decode(r),result:n}}function xa(e){if(!e)return[null,new S];return e}async function No(e){if(e===null)return new Uint8Array;if(e instanceof Uint8Array)return e;let o=[];for await(let i of e)o.push(i);let t=0;for(let i of o)t+=i.byteLength;let a=new Uint8Array(t),s=0;for(let i of o)a.set(i,s),s+=i.byteLength;return a}function ue(e,o){let t={},a=[];for(let r of e.options)if(r.defaultValue!==null&&r.defaultValue!==void 0)t[r.name]=r.defaultValue;else if(r.valueKind===c.NONE)t[r.name]=!1;let s=0;while(s<o.length){let r=o[s]??"";if(r==="--"){a.push(...o.slice(s+1));break}let d=Ra(e,r);if(d){s+=Ea(d,r,o,s,t);continue}a.push(r),s+=1}let{paths:i,texts:n}=za(e,a);return{paths:i,texts:n,flags:t}}function Ra(e,o){if(o.startsWith("--")){let t=o.slice(2).split("=")[0];return e.options.find((a)=>a.long===t)}if(o.startsWith("-")&&o.length>1){let t=o[1];return e.options.find((a)=>a.short===t)}return}function Ea(e,o,t,a,s){if(e.valueKind===c.NONE)return s[e.name]=!0,1;if(o.includes("="))return s[e.name]=o.slice(o.indexOf("=")+1),1;return s[e.name]=t[a+1]??"",2}function za(e,o){let t=[],a=[],s=0;for(let i of e.positional){if(s>=o.length)break;if(i.variadic){V(i.kind,o.slice(s),t,a),s=o.length;break}V(i.kind,[o[s]],t,a),s+=1}if(s<o.length&&e.rest)V(e.rest.kind,o.slice(s),t,a);return{paths:t,texts:a}}function V(e,o,t,a){if(e===c.PATH)t.push(...o);else if(e===c.TEXT)a.push(...o)}function D(e){let o=new H(e.name);if(e.description)o.description(e.description);return Ba(o,e.spec),o.action(async(...t)=>{let a=t[t.length-1],s=t[t.length-2],i=t.slice(0,-2),{paths:n,texts:r,flags:d}=qa(e.spec,i,s),l=await e.fn({},n,r,{flags:d}),[_,b]=l??[null,new S],P=await No(_??b.stdout);if(P.byteLength>0)process.stdout.write(P);if(b.stderr)process.stderr.write(b.stderr);if(b.exitCode!==0)process.exit(b.exitCode)}),o}function U(e,o){let t=new H(o.name);if(o.description)t.description(o.description);for(let a of o.groups)U(t,a);for(let a of o.commands)t.addCommand(D(a));return e.addCommand(t),t}function Ba(e,o){for(let t of o.positional){let a=t.variadic?`<${t.name}...>`:t.required?`<${t.name}>`:`[${t.name}]`;e.argument(a)}if(o.rest)e.argument(`[${o.rest.name}...]`);for(let t of o.options)e.addOption(Oa(t))}function Oa(e){let o=new Mo(Ya(e),e.description??void 0);if(e.defaultValue!==null)o.default(e.defaultValue);if(e.required)o.makeOptionMandatory(!0);return o}function Ya(e){let o=[];if(e.short)o.push(`-${e.short}`);if(e.long)o.push(`--${e.long}`);let t=o.join(", ");if(e.valueKind!==c.NONE)t+=` <${e.long??e.short}>`;return t}function qa(e,o,t){let a=[],s=[];e.positional.forEach((n,r)=>{let d=o[r];if(d===void 0||d===null)return;let l=Array.isArray(d)?d:[String(d)];V(n.kind,l,a,s)});let i={};for(let n of e.options){let r=Fa(n.long??n.short??"");if(r in t){let d=t[r];if(typeof d==="string"||typeof d==="boolean")i[n.name]=d}}return{paths:a,texts:s,flags:i}}function Fa(e){return e.replace(/-([a-z])/g,(o,t)=>t.toUpperCase())}function Ho(e,o={}){return[typeof e==="string"?new TextEncoder().encode(e):e,new S({exitCode:o.exitCode??0,stderr:o.stderr??null})]}import{existsSync as Ma,mkdirSync as Ka,readFileSync as Ca,writeFileSync as Na,chmodSync as Ha}from"node:fs";import{homedir as Xa}from"node:os";import{dirname as Wa,join as ja}from"node:path";var F=ja(Xa(),".config","dataforseo","config.json");function ve(){return F}function M(){let e=Ja();if(e)return e;if(Ma(F)){let o=Ca(F,"utf8"),t=JSON.parse(o);if(t.login&&t.password)return{login:t.login,password:t.password}}throw Error(`No DataForSEO credentials found.
|
|
23
|
-
Either set DATAFORSEO_LOGIN and DATAFORSEO_PASSWORD env vars, or run: dfs login --login <email> --password <api_password>`)}function _e(e){return Ka(Wa(F),{recursive:!0}),Na(F,JSON.stringify(e,null,2)),Ha(F,384),F}function Z({login:e,password:o}){return"Basic "+Buffer.from(`${e}:${o}`).toString("base64")}function Ja(){let e=process.env.DATAFORSEO_LOGIN,o=process.env.DATAFORSEO_PASSWORD;if(e&&o)return{login:e,password:o};return null}var $a="https://api.dataforseo.com";async function v(e,o,t={}){let a=M(),s=Xo(e,t.baseUrl),i=Qa(o,t.wrapAsTaskArray??!0),n=new AbortController,r=setTimeout(()=>n.abort(),t.timeoutMs??120000),d;try{d=await fetch(s,{method:"POST",headers:{Authorization:Z(a),"Content-Type":"application/json","User-Agent":"dataforseo-cli/0.1.0"},body:i===void 0?void 0:JSON.stringify(i),signal:n.signal})}finally{clearTimeout(r)}let l=await d.text(),_;try{_=l?JSON.parse(l):{}}catch{throw Error(`HTTP ${d.status}: non-JSON response: ${l.slice(0,500)}`)}if(!d.ok){let b=_.status_message??`HTTP ${d.status}`;throw Error(`DataForSEO error: ${b}`)}return _}async function x(e,o={}){let t=M(),a=Xo(e,o.baseUrl),s=new AbortController,i=setTimeout(()=>s.abort(),o.timeoutMs??60000),n;try{n=await fetch(a,{method:"GET",headers:{Authorization:Z(t),"User-Agent":"dataforseo-cli/0.1.0"},signal:s.signal})}finally{clearTimeout(i)}let r=await n.text(),d=r?JSON.parse(r):{};if(!n.ok)throw Error(`DataForSEO error: ${d.status_message??`HTTP ${n.status}`}`);return d}function Xo(e,o){let t=e.trim();if(!t.startsWith("/"))t="/"+t;if(!t.startsWith("/v3/"))t="/v3"+t;return(o??$a)+t}function Qa(e,o){if(e===void 0||e===null)return;if(Array.isArray(e))return e;if(o&&typeof e==="object")return[e];return e}function ye(e){let o=e.tasks??[],t=[];for(let a of o){let s=a.result;if(!Array.isArray(s))continue;for(let i of s)if(i&&typeof i==="object"&&Array.isArray(i.items))t.push(...i.items);else t.push(i)}return t}function we(e,o){if(o.format==="raw")return JSON.stringify(e,null,2);let t=o.full?e:ye(e);switch(o.format){case"json":return JSON.stringify(t,null,2);case"ndjson":return Array.isArray(t)?t.map((a)=>JSON.stringify(a)).join(`
|
|
24
|
-
`):JSON.stringify(t);case"table":return Va(Wo(t),o.columns);case"csv":return Za(Wo(t),o.columns)}}function Wo(e){if(Array.isArray(e))return e.filter((o)=>o!==null&&typeof o==="object"&&!Array.isArray(o));if(e&&typeof e==="object")return[e];return[]}function Va(e,o){if(e.length===0)return"(no rows)";let t=o??Jo(e),a=t.map((i)=>Math.max(i.length,...e.map((n)=>ke(n[i]).length))),s=[];s.push(t.map((i,n)=>i.padEnd(a[n]??i.length)).join(" ")),s.push(a.map((i)=>"-".repeat(i)).join(" "));for(let i of e)s.push(t.map((n,r)=>ke(i[n]).padEnd(a[r]??0)).join(" "));return s.join(`
|
|
25
|
-
`)}function Za(e,o){if(e.length===0)return"";let t=o??Jo(e),a=[t.map(jo).join(",")];for(let s of e)a.push(t.map((i)=>jo(ke(s[i]))).join(","));return a.join(`
|
|
26
|
-
`)}function Jo(e){let o=new Set;for(let t of e)for(let a of Object.keys(t))o.add(a);return[...o]}function ke(e){if(e===null||e===void 0)return"";if(typeof e==="string")return e;if(typeof e==="number"||typeof e==="boolean")return String(e);return JSON.stringify(e)}function jo(e){if(/[",\n\r]/.test(e))return`"${e.replace(/"/g,'""')}"`;return e}var es=new TextEncoder,m=Object.freeze([new p({short:"o",long:"output",valueKind:c.TEXT,description:"Output format: json|ndjson|table|csv|raw (default json).",defaultValue:"json"}),new p({long:"columns",valueKind:c.TEXT,description:"Comma-separated columns for table/csv output."}),new p({long:"full",valueKind:c.NONE,description:"Emit the full response (skip the items extraction)."}),new p({long:"no-cost",valueKind:c.NONE,description:"Don't print the response cost on stderr."})]);function f(e,o){let t=o.flags??{},a=t.output??"json",s=t.full===!0,i=t["no-cost"]===!0,n=t.columns,r=typeof n==="string"?n.split(",").map((b)=>b.trim()).filter(Boolean):void 0,d=we(e,{format:a,full:s,columns:r}),l=es.encode(d.endsWith(`
|
|
27
|
-
`)?d:d+`
|
|
28
|
-
`),_=!i&&typeof e.cost==="number"&&e.cost>0?`[cost] $${e.cost.toFixed(4)}
|
|
29
|
-
`:null;return[l,new S({exitCode:0,stderr:_})]}var w=Object.freeze([new p({long:"location",valueKind:c.TEXT,description:'Location name (default "United States").',defaultValue:"United States"}),new p({long:"location-code",valueKind:c.TEXT,description:"Location code, overrides --location."}),new p({long:"language",valueKind:c.TEXT,description:'Language name (default "English").',defaultValue:"English"}),new p({long:"language-code",valueKind:c.TEXT,description:"Language code, overrides --language."})]);function k(e){let o=e.flags??{},t={},a=o["location-code"];if(typeof a==="string"&&a)t.locationCode=Number(a);else t.locationName=o.location??"United States";let s=o["language-code"];if(typeof s==="string"&&s)t.languageCode=s;else t.languageName=o.language??"English";return t}function u(e,o={}){return new q({kind:c.TEXT,name:e,...o})}function y(e,o,t){let a=e.flags?.[o];return typeof a==="string"?a:t??""}function A(e,o){return e.flags?.[o]===!0}function T(e,o,t){let a=e.flags?.[o];if(typeof a==="string"&&a)return Number(a);return t}function X(e){let o={};if(e.locationCode!==void 0)o.location_code=e.locationCode;else o.location_name=e.locationName??"United States";if(e.languageCode!==void 0)o.language_code=e.languageCode;else o.language_name=e.languageName??"English";return o}var os={chatgpt:"ai_optimization/chat_gpt/llm_responses/live",claude:"ai_optimization/claude/llm_responses/live",gemini:"ai_optimization/gemini/llm_responses/live",perplexity:"ai_optimization/perplexity/llm_responses/live"};async function be(e){return v("ai_optimization/ai_keyword_data/keywords_search_volume/live",{...X(e),keywords:e.keywords})}async function Te(e){return v("ai_optimization/llm_mentions/search/live",{...X(e),target:e.keywords.map((o)=>({keyword:o}))})}async function Ie(e){return v("ai_optimization/llm_mentions/top_pages/live",{...X(e),target:e.keywords.map((o)=>({keyword:o}))})}async function Se(e){return v("ai_optimization/llm_mentions/top_domains/live",{...X(e),target:e.keywords.map((o)=>({keyword:o}))})}async function Le(e){return v("ai_optimization/llm_mentions/aggregated_metrics/live",{...X(e),target:e.keywords.map((o)=>({keyword:o}))})}async function Ge(e){return v(os[e.model],{system_message:e.systemMessage,message_chain:[{role:"user",message:e.message}],max_output_tokens:e.maxOutputTokens??512,temperature:e.temperature??0.3,top_p:e.topP??0.5})}var K="ram",$o=g({name:"search-volume",resource:K,spec:new h({description:"AI-tool search volume — how often a keyword is typed at LLMs.",positional:[u("keywords",{variadic:!0})],options:[...w,...m]}),fn:async(e,o,t,a)=>{let s=await be({...k(a),keywords:[...t]});return f(s,a)}}),Qo=g({name:"mentions",resource:K,spec:new h({description:"Search LLM mentions for one or more keyword targets.",positional:[u("keywords",{variadic:!0})],options:[...w,...m]}),fn:async(e,o,t,a)=>{let s=await Te({...k(a),keywords:[...t]});return f(s,a)}}),Vo=g({name:"top-pages",resource:K,spec:new h({description:"Top pages cited by AI for the given keyword targets.",positional:[u("keywords",{variadic:!0})],options:[...w,...m]}),fn:async(e,o,t,a)=>{let s=await Ie({...k(a),keywords:[...t]});return f(s,a)}}),Zo=g({name:"top-domains",resource:K,spec:new h({description:"Top domains cited by AI for the given keyword targets.",positional:[u("keywords",{variadic:!0})],options:[...w,...m]}),fn:async(e,o,t,a)=>{let s=await Se({...k(a),keywords:[...t]});return f(s,a)}}),et=g({name:"metrics",resource:K,spec:new h({description:"Aggregated LLM mention metrics (volume, sentiment) for keyword targets.",positional:[u("keywords",{variadic:!0})],options:[...w,...m]}),fn:async(e,o,t,a)=>{let s=await Le({...k(a),keywords:[...t]});return f(s,a)}}),ot=g({name:"ask",resource:K,spec:new h({description:"Ask a specific LLM via DataForSEO's metered proxy.",positional:[u("message")],options:[new p({long:"model",valueKind:c.TEXT,description:"chatgpt | claude | gemini | perplexity.",defaultValue:"chatgpt"}),new p({long:"system",valueKind:c.TEXT,description:"Optional system message."}),new p({long:"max-tokens",valueKind:c.TEXT,description:"Max output tokens (default 512).",defaultValue:"512"}),new p({long:"temperature",valueKind:c.TEXT,description:"Sampling temperature (default 0.3).",defaultValue:"0.3"}),...m]}),fn:async(e,o,t,a)=>{let s=y(a,"model","chatgpt"),i=y(a,"system")||void 0,n=await Ge({model:s,message:t[0]??"",systemMessage:i,maxOutputTokens:T(a,"max-tokens",512),temperature:Number(y(a,"temperature","0.3"))});return f(n,a)}}),Ae=G({name:"ai",description:"AI Optimization: LLM mentions, top pages/domains, AI search volume, LLM proxy.",commands:[$o,Qo,Vo,Zo,et,ot]});async function Ue(e){return v("backlinks/summary/live",{target:e})}async function Pe(e){return v("backlinks/backlinks/live",{target:e.target,limit:e.limit??100,mode:e.mode??"as_is"})}async function De(e){return v("backlinks/referring_domains/live",{target:e.target,limit:e.limit??100})}async function xe(e){return v("backlinks/anchors/live",{target:e.target,limit:e.limit??100})}async function Re(e){return v("backlinks/competitors/live",{target:e.target,limit:e.limit??100})}async function Ee(e){return v("backlinks/bulk_ranks/live",{targets:e})}var C="ram",ee=new p({long:"limit",valueKind:c.TEXT,description:"Max results.",defaultValue:"100"}),tt=g({name:"summary",resource:C,spec:new h({description:"High-level backlink summary for a target.",positional:[u("target")],options:[...m]}),fn:async(e,o,t,a)=>{let s=await Ue(t[0]??"");return f(s,a)}}),at=g({name:"list",resource:C,spec:new h({description:"List individual backlinks.",positional:[u("target")],options:[ee,new p({long:"mode",valueKind:c.TEXT,description:"as_is | one_per_domain | one_per_anchor.",defaultValue:"as_is"}),...m]}),fn:async(e,o,t,a)=>{let s=await Pe({target:t[0]??"",limit:T(a,"limit",100),mode:y(a,"mode","as_is")});return f(s,a)}}),st=g({name:"referring-domains",resource:C,spec:new h({description:"Referring domains pointing to a target.",positional:[u("target")],options:[ee,...m]}),fn:async(e,o,t,a)=>{let s=await De({target:t[0]??"",limit:T(a,"limit",100)});return f(s,a)}}),it=g({name:"anchors",resource:C,spec:new h({description:"Anchor text distribution for a target.",positional:[u("target")],options:[ee,...m]}),fn:async(e,o,t,a)=>{let s=await xe({target:t[0]??"",limit:T(a,"limit",100)});return f(s,a)}}),rt=g({name:"competitors",resource:C,spec:new h({description:"Domains with similar backlink profiles.",positional:[u("target")],options:[ee,...m]}),fn:async(e,o,t,a)=>{let s=await Re({target:t[0]??"",limit:T(a,"limit",100)});return f(s,a)}}),nt=g({name:"ranks",resource:C,spec:new h({description:"Bulk DataForSEO domain rank for up to 1000 targets.",positional:[u("targets",{variadic:!0})],options:[...m]}),fn:async(e,o,t,a)=>{let s=await Ee([...t]);return f(s,a)}}),ze=G({name:"backlinks",description:"Backlink profiles, referring domains, anchors.",commands:[tt,at,st,it,rt,nt]});var dt=[{path:"/v3/serp/id_list",method:"post",operationId:"IdList",tag:"Serp",description:`This endpoint is designed to provide you with a list of IDs and metadata for all SERP tasks created within the specified time period, including both successful and uncompleted tasks.
|
|
1
|
+
import{Command as Ot}from"commander";var r=Object.freeze({NONE:"none",PATH:"path",TEXT:"text"});class n{short;long;valueKind;numericShorthand;description;defaultValue;required;constructor(e={}){this.short=e.short??null,this.long=e.long??null,this.valueKind=e.valueKind??r.NONE,this.numericShorthand=e.numericShorthand??!1,this.description=e.description??null,this.defaultValue=e.defaultValue??null,this.required=e.required??!1,Object.freeze(this)}get name(){return this.long??this.short??""}}class P{kind;name;variadic;required;constructor(e={}){this.kind=e.kind??r.PATH,this.name=e.name??"arg",this.variadic=e.variadic??!1,this.required=e.required??!0,Object.freeze(this)}}class d{options;positional;rest;ignoreTokens;description;constructor(e={}){this.options=Object.freeze([...e.options??[]]),this.positional=Object.freeze([...e.positional??[]]),this.rest=e.rest??null,this.ignoreTokens=new Set(e.ignoreTokens??[]),this.description=e.description??null,Object.freeze(this)}}class J{flags;args;cachePaths;pathFlagValues;constructor(e){this.flags=e.flags,this.args=e.args,this.cachePaths=e.cachePaths??[],this.pathFlagValues=e.pathFlagValues??[]}paths(){return this.args.filter(([,e])=>e===r.PATH).map(([e])=>e)}routingPaths(){return[...this.paths(),...this.pathFlagValues]}texts(){return this.args.filter(([,e])=>e===r.TEXT).map(([e])=>e)}flag(e,t=null){return this.flags[e]??t}}class w{stdout;stderr;exitCode;reads;writes;cache;streamSource;constructor(e={}){this.stdout=ro(e.stdout??null),this.stderr=ro(e.stderr??null),this.exitCode=e.exitCode??0,this.reads=e.reads??{},this.writes=e.writes??{},this.cache=e.cache??[],this.streamSource=null}}function ro(e){if(e===null||e===void 0)return null;if(e instanceof Uint8Array)return e;if(typeof e==="string")return new TextEncoder().encode(e);return null}import{Command as no,Option as tt}from"commander";function c(e){return Object.freeze({name:e.name,resource:e.resource??null,spec:e.spec,fn:e.fn,description:e.description??e.spec.description??null})}function b(e){return Object.freeze({name:e.name,description:e.description??null,commands:Object.freeze([...e.commands??[]]),groups:Object.freeze([...e.groups??[]])})}var at=new TextDecoder;async function co(e,t={}){let a=Array.isArray(t)?$(e.spec,t):t,o={flags:a.flags??{},stdin:a.stdin??null},s=await e.fn({},a.paths??[],a.texts??[],o),[i,m]=st(s),f=await lo(i??m.stdout);return{bytes:f,text:at.decode(f),result:m}}function st(e){if(!e)return[null,new w];return e}async function lo(e){if(e===null)return new Uint8Array;if(e instanceof Uint8Array)return e;let t=[];for await(let i of e)t.push(i);let a=0;for(let i of t)a+=i.byteLength;let o=new Uint8Array(a),s=0;for(let i of t)o.set(i,s),s+=i.byteLength;return o}function $(e,t){let a={},o=[];for(let f of e.options)if(f.defaultValue!==null&&f.defaultValue!==void 0)a[f.name]=f.defaultValue;else if(f.valueKind===r.NONE)a[f.name]=!1;let s=0;while(s<t.length){let f=t[s]??"";if(f==="--"){o.push(...t.slice(s+1));break}let v=it(e,f);if(v){s+=rt(v,f,t,s,a);continue}o.push(f),s+=1}let{paths:i,texts:m}=nt(e,o);return{paths:i,texts:m,flags:a}}function it(e,t){if(t.startsWith("--")){let a=t.slice(2).split("=")[0];return e.options.find((o)=>o.long===a)}if(t.startsWith("-")&&t.length>1){let a=t[1];return e.options.find((o)=>o.short===a)}return}function rt(e,t,a,o,s){if(e.valueKind===r.NONE)return s[e.name]=!0,1;if(t.includes("="))return s[e.name]=t.slice(t.indexOf("=")+1),1;return s[e.name]=a[o+1]??"",2}function nt(e,t){let a=[],o=[],s=0;for(let i of e.positional){if(s>=t.length)break;if(i.variadic){K(i.kind,t.slice(s),a,o),s=t.length;break}K(i.kind,[t[s]],a,o),s+=1}if(s<t.length&&e.rest)K(e.rest.kind,t.slice(s),a,o);return{paths:a,texts:o}}function K(e,t,a,o){if(e===r.PATH)a.push(...t);else if(e===r.TEXT)o.push(...t)}function A(e){let t=new no(e.name);if(e.description)t.description(e.description);return dt(t,e.spec),t.action(async(...a)=>{let o=a[a.length-1],s=a[a.length-2],i=a.slice(0,-2),{paths:m,texts:f,flags:v}=pt(e.spec,i,s),I=await e.fn({},m,f,{flags:v}),[D,G]=I??[null,new w],io=await lo(D??G.stdout);if(io.byteLength>0)process.stdout.write(io);if(G.stderr)process.stderr.write(G.stderr);if(G.exitCode!==0)process.exit(G.exitCode)}),t}function S(e,t){let a=new no(t.name);if(t.description)a.description(t.description);for(let o of t.groups)S(a,o);for(let o of t.commands)a.addCommand(A(o));return e.addCommand(a),a}function dt(e,t){for(let a of t.positional){let o=a.variadic?`<${a.name}...>`:a.required?`<${a.name}>`:`[${a.name}]`;e.argument(o)}if(t.rest)e.argument(`[${t.rest.name}...]`);for(let a of t.options)e.addOption(ct(a))}function ct(e){let t=new tt(lt(e),e.description??void 0);if(e.defaultValue!==null)t.default(e.defaultValue);if(e.required)t.makeOptionMandatory(!0);return t}function lt(e){let t=[];if(e.short)t.push(`-${e.short}`);if(e.long)t.push(`--${e.long}`);let a=t.join(", ");if(e.valueKind!==r.NONE)a+=` <${e.long??e.short}>`;return a}function pt(e,t,a){let o=[],s=[];e.positional.forEach((m,f)=>{let v=t[f];if(v===void 0||v===null)return;let I=Array.isArray(v)?v:[String(v)];K(m.kind,I,o,s)});let i={};for(let m of e.options){let f=ht(m.long??m.short??"");if(f in a){let v=a[f];if(typeof v==="string"||typeof v==="boolean")i[m.name]=v}}return{paths:o,texts:s,flags:i}}function ht(e){return e.replace(/-([a-z])/g,(t,a)=>a.toUpperCase())}function po(e,t={}){return[typeof e==="string"?new TextEncoder().encode(e):e,new w({exitCode:t.exitCode??0,stderr:t.stderr??null})]}import{existsSync as gt,mkdirSync as mt,readFileSync as ft,writeFileSync as ut,chmodSync as vt}from"node:fs";import{homedir as _t}from"node:os";import{dirname as yt,join as kt}from"node:path";var E=kt(_t(),".config","dataforseo","config.json");function Q(){return E}function R(){let e=wt();if(e)return e;if(gt(E)){let t=ft(E,"utf8"),a=JSON.parse(t);if(a.login&&a.password)return{login:a.login,password:a.password}}throw Error(`No DataForSEO credentials found.
|
|
2
|
+
Either set DATAFORSEO_LOGIN and DATAFORSEO_PASSWORD env vars, or run: dfs login --login <email> --password <api_password>`)}function Z(e){return mt(yt(E),{recursive:!0}),ut(E,JSON.stringify(e,null,2)),vt(E,384),E}function M({login:e,password:t}){return"Basic "+Buffer.from(`${e}:${t}`).toString("base64")}function wt(){let e=process.env.DATAFORSEO_LOGIN,t=process.env.DATAFORSEO_PASSWORD;if(e&&t)return{login:e,password:t};return null}var bt="https://api.dataforseo.com";async function g(e,t,a={}){let o=R(),s=ho(e,a.baseUrl),i=Tt(t,a.wrapAsTaskArray??!0),m=new AbortController,f=setTimeout(()=>m.abort(),a.timeoutMs??120000),v;try{v=await fetch(s,{method:"POST",headers:{Authorization:M(o),"Content-Type":"application/json","User-Agent":"dataforseo-cli/0.1.0"},body:i===void 0?void 0:JSON.stringify(i),signal:m.signal})}finally{clearTimeout(f)}let I=await v.text(),D;try{D=I?JSON.parse(I):{}}catch{throw Error(`HTTP ${v.status}: non-JSON response: ${I.slice(0,500)}`)}if(!v.ok){let G=D.status_message??`HTTP ${v.status}`;throw Error(`DataForSEO error: ${G}`)}return D}async function L(e,t={}){let a=R(),o=ho(e,t.baseUrl),s=new AbortController,i=setTimeout(()=>s.abort(),t.timeoutMs??60000),m;try{m=await fetch(o,{method:"GET",headers:{Authorization:M(a),"User-Agent":"dataforseo-cli/0.1.0"},signal:s.signal})}finally{clearTimeout(i)}let f=await m.text(),v=f?JSON.parse(f):{};if(!m.ok)throw Error(`DataForSEO error: ${v.status_message??`HTTP ${m.status}`}`);return v}function ho(e,t){let a=e.trim();if(!a.startsWith("/"))a="/"+a;if(!a.startsWith("/v3/"))a="/v3"+a;return(t??bt)+a}function Tt(e,t){if(e===void 0||e===null)return;if(Array.isArray(e))return e;if(t&&typeof e==="object")return[e];return e}function ee(e){let t=e.tasks??[],a=[];for(let o of t){let s=o.result;if(!Array.isArray(s))continue;for(let i of s)if(i&&typeof i==="object"&&Array.isArray(i.items))a.push(...i.items);else a.push(i)}return a}function te(e,t){if(t.format==="raw")return JSON.stringify(e,null,2);let a=t.full?e:ee(e);switch(t.format){case"json":return JSON.stringify(a,null,2);case"ndjson":return Array.isArray(a)?a.map((o)=>JSON.stringify(o)).join(`
|
|
3
|
+
`):JSON.stringify(a);case"table":return It(go(a),t.columns);case"csv":return St(go(a),t.columns)}}function go(e){if(Array.isArray(e))return e.filter((t)=>t!==null&&typeof t==="object"&&!Array.isArray(t));if(e&&typeof e==="object")return[e];return[]}function It(e,t){if(e.length===0)return"(no rows)";let a=t??fo(e),o=a.map((i)=>Math.max(i.length,...e.map((m)=>oe(m[i]).length))),s=[];s.push(a.map((i,m)=>i.padEnd(o[m]??i.length)).join(" ")),s.push(o.map((i)=>"-".repeat(i)).join(" "));for(let i of e)s.push(a.map((m,f)=>oe(i[m]).padEnd(o[f]??0)).join(" "));return s.join(`
|
|
4
|
+
`)}function St(e,t){if(e.length===0)return"";let a=t??fo(e),o=[a.map(mo).join(",")];for(let s of e)o.push(a.map((i)=>mo(oe(s[i]))).join(","));return o.join(`
|
|
5
|
+
`)}function fo(e){let t=new Set;for(let a of e)for(let o of Object.keys(a))t.add(o);return[...t]}function oe(e){if(e===null||e===void 0)return"";if(typeof e==="string")return e;if(typeof e==="number"||typeof e==="boolean")return String(e);return JSON.stringify(e)}function mo(e){if(/[",\n\r]/.test(e))return`"${e.replace(/"/g,'""')}"`;return e}var At=new TextEncoder,l=Object.freeze([new n({short:"o",long:"output",valueKind:r.TEXT,description:"Output format: json|ndjson|table|csv|raw (default json).",defaultValue:"json"}),new n({long:"columns",valueKind:r.TEXT,description:"Comma-separated columns for table/csv output."}),new n({long:"full",valueKind:r.NONE,description:"Emit the full response (skip the items extraction)."}),new n({long:"no-cost",valueKind:r.NONE,description:"Don't print the response cost on stderr."})]);function p(e,t){let a=t.flags??{},o=a.output??"json",s=a.full===!0,i=a["no-cost"]===!0,m=a.columns,f=typeof m==="string"?m.split(",").map((G)=>G.trim()).filter(Boolean):void 0,v=te(e,{format:o,full:s,columns:f}),I=At.encode(v.endsWith(`
|
|
6
|
+
`)?v:v+`
|
|
7
|
+
`),D=!i&&typeof e.cost==="number"&&e.cost>0?`[cost] $${e.cost.toFixed(4)}
|
|
8
|
+
`:null;return[I,new w({exitCode:0,stderr:D})]}var y=Object.freeze([new n({long:"location",valueKind:r.TEXT,description:'Location name (default "United States").',defaultValue:"United States"}),new n({long:"location-code",valueKind:r.TEXT,description:"Location code, overrides --location."}),new n({long:"language",valueKind:r.TEXT,description:'Language name (default "English").',defaultValue:"English"}),new n({long:"language-code",valueKind:r.TEXT,description:"Language code, overrides --language."})]);function _(e){let t=e.flags??{},a={},o=t["location-code"];if(typeof o==="string"&&o)a.locationCode=Number(o);else a.locationName=t.location??"United States";let s=t["language-code"];if(typeof s==="string"&&s)a.languageCode=s;else a.languageName=t.language??"English";return a}function h(e,t={}){return new P({kind:r.TEXT,name:e,...t})}function u(e,t,a){let o=e.flags?.[t];return typeof o==="string"?o:a??""}function T(e,t){return e.flags?.[t]===!0}function k(e,t,a){let o=e.flags?.[t];if(typeof o==="string"&&o)return Number(o);return a}function C(e){let t={};if(e.locationCode!==void 0)t.location_code=e.locationCode;else t.location_name=e.locationName??"United States";if(e.languageCode!==void 0)t.language_code=e.languageCode;else t.language_name=e.languageName??"English";return t}var Lt={chatgpt:"ai_optimization/chat_gpt/llm_responses/live",claude:"ai_optimization/claude/llm_responses/live",gemini:"ai_optimization/gemini/llm_responses/live",perplexity:"ai_optimization/perplexity/llm_responses/live"};async function ae(e){return g("ai_optimization/ai_keyword_data/keywords_search_volume/live",{...C(e),keywords:e.keywords})}async function se(e){return g("ai_optimization/llm_mentions/search/live",{...C(e),target:e.keywords.map((t)=>({keyword:t}))})}async function ie(e){return g("ai_optimization/llm_mentions/top_pages/live",{...C(e),target:e.keywords.map((t)=>({keyword:t}))})}async function re(e){return g("ai_optimization/llm_mentions/top_domains/live",{...C(e),target:e.keywords.map((t)=>({keyword:t}))})}async function ne(e){return g("ai_optimization/llm_mentions/aggregated_metrics/live",{...C(e),target:e.keywords.map((t)=>({keyword:t}))})}async function de(e){return g(Lt[e.model],{system_message:e.systemMessage,message_chain:[{role:"user",message:e.message}],max_output_tokens:e.maxOutputTokens??512,temperature:e.temperature??0.3,top_p:e.topP??0.5})}var O="ram",uo=c({name:"search-volume",resource:O,spec:new d({description:"AI-tool search volume — how often a keyword is typed at LLMs.",positional:[h("keywords",{variadic:!0})],options:[...y,...l]}),fn:async(e,t,a,o)=>{let s=await ae({..._(o),keywords:[...a]});return p(s,o)}}),vo=c({name:"mentions",resource:O,spec:new d({description:"Search LLM mentions for one or more keyword targets.",positional:[h("keywords",{variadic:!0})],options:[...y,...l]}),fn:async(e,t,a,o)=>{let s=await se({..._(o),keywords:[...a]});return p(s,o)}}),_o=c({name:"top-pages",resource:O,spec:new d({description:"Top pages cited by AI for the given keyword targets.",positional:[h("keywords",{variadic:!0})],options:[...y,...l]}),fn:async(e,t,a,o)=>{let s=await ie({..._(o),keywords:[...a]});return p(s,o)}}),yo=c({name:"top-domains",resource:O,spec:new d({description:"Top domains cited by AI for the given keyword targets.",positional:[h("keywords",{variadic:!0})],options:[...y,...l]}),fn:async(e,t,a,o)=>{let s=await re({..._(o),keywords:[...a]});return p(s,o)}}),ko=c({name:"metrics",resource:O,spec:new d({description:"Aggregated LLM mention metrics (volume, sentiment) for keyword targets.",positional:[h("keywords",{variadic:!0})],options:[...y,...l]}),fn:async(e,t,a,o)=>{let s=await ne({..._(o),keywords:[...a]});return p(s,o)}}),wo=c({name:"ask",resource:O,spec:new d({description:"Ask a specific LLM via DataForSEO's metered proxy.",positional:[h("message")],options:[new n({long:"model",valueKind:r.TEXT,description:"chatgpt | claude | gemini | perplexity.",defaultValue:"chatgpt"}),new n({long:"system",valueKind:r.TEXT,description:"Optional system message."}),new n({long:"max-tokens",valueKind:r.TEXT,description:"Max output tokens (default 512).",defaultValue:"512"}),new n({long:"temperature",valueKind:r.TEXT,description:"Sampling temperature (default 0.3).",defaultValue:"0.3"}),...l]}),fn:async(e,t,a,o)=>{let s=u(o,"model","chatgpt"),i=u(o,"system")||void 0,m=await de({model:s,message:a[0]??"",systemMessage:i,maxOutputTokens:k(o,"max-tokens",512),temperature:Number(u(o,"temperature","0.3"))});return p(m,o)}}),ce=b({name:"ai",description:"AI Optimization: LLM mentions, top pages/domains, AI search volume, LLM proxy.",commands:[uo,vo,_o,yo,ko,wo]});async function le(e){return g("backlinks/summary/live",{target:e})}async function pe(e){return g("backlinks/backlinks/live",{target:e.target,limit:e.limit??100,mode:e.mode??"as_is"})}async function he(e){return g("backlinks/referring_domains/live",{target:e.target,limit:e.limit??100})}async function ge(e){return g("backlinks/anchors/live",{target:e.target,limit:e.limit??100})}async function me(e){return g("backlinks/competitors/live",{target:e.target,limit:e.limit??100})}async function fe(e){return g("backlinks/bulk_ranks/live",{targets:e})}var z="ram",N=new n({long:"limit",valueKind:r.TEXT,description:"Max results.",defaultValue:"100"}),bo=c({name:"summary",resource:z,spec:new d({description:"High-level backlink summary for a target.",positional:[h("target")],options:[...l]}),fn:async(e,t,a,o)=>{let s=await le(a[0]??"");return p(s,o)}}),To=c({name:"list",resource:z,spec:new d({description:"List individual backlinks.",positional:[h("target")],options:[N,new n({long:"mode",valueKind:r.TEXT,description:"as_is | one_per_domain | one_per_anchor.",defaultValue:"as_is"}),...l]}),fn:async(e,t,a,o)=>{let s=await pe({target:a[0]??"",limit:k(o,"limit",100),mode:u(o,"mode","as_is")});return p(s,o)}}),Io=c({name:"referring-domains",resource:z,spec:new d({description:"Referring domains pointing to a target.",positional:[h("target")],options:[N,...l]}),fn:async(e,t,a,o)=>{let s=await he({target:a[0]??"",limit:k(o,"limit",100)});return p(s,o)}}),So=c({name:"anchors",resource:z,spec:new d({description:"Anchor text distribution for a target.",positional:[h("target")],options:[N,...l]}),fn:async(e,t,a,o)=>{let s=await ge({target:a[0]??"",limit:k(o,"limit",100)});return p(s,o)}}),Ao=c({name:"competitors",resource:z,spec:new d({description:"Domains with similar backlink profiles.",positional:[h("target")],options:[N,...l]}),fn:async(e,t,a,o)=>{let s=await me({target:a[0]??"",limit:k(o,"limit",100)});return p(s,o)}}),Lo=c({name:"ranks",resource:z,spec:new d({description:"Bulk DataForSEO domain rank for up to 1000 targets.",positional:[h("targets",{variadic:!0})],options:[...l]}),fn:async(e,t,a,o)=>{let s=await fe([...a]);return p(s,o)}}),ue=b({name:"backlinks",description:"Backlink profiles, referring domains, anchors.",commands:[bo,To,Io,So,Ao,Lo]});var Go=[{path:"/v3/serp/id_list",method:"post",operationId:"IdList",tag:"Serp",description:`This endpoint is designed to provide you with a list of IDs and metadata for all SERP tasks created within the specified time period, including both successful and uncompleted tasks.
|
|
30
9
|
for more info please visit 'https://docs.dataforseo.com/v3/serp/id_list/?bash'`,docUrl:"https://docs.dataforseo.com/v3/serp/id_list/",example:[{datetime_from:"2026-04-12 04:39:39 +00:00",datetime_to:"2026-04-14 04:39:39 +00:00",limit:100,offset:0,sort:"desc",include_metadata:!0}]},{path:"/v3/serp/errors",method:"post",operationId:"Errors",tag:"Serp",description:`By calling this endpoint you will receive information about the SERP API tasks that returned an error within the past 7 days.
|
|
31
10
|
for more info please visit 'https://docs.dataforseo.com/v3/serp/errors/?bash'`,docUrl:"https://docs.dataforseo.com/v3/serp/errors/",example:[{limit:10,offset:0,filtered_function:"pingback_url"}]},{path:"/v3/serp/screenshot",method:"post",operationId:"Screenshot",tag:"Serp",description:`Using the Live Page Screenshot endpoint, you can capture a screenshot of any SERP page.
|
|
32
11
|
for more info please visit 'https://docs.dataforseo.com/v3/serp/screenshot/?bash'`,docUrl:"https://docs.dataforseo.com/v3/serp/screenshot/",example:[{task_id:"06211235-0696-0139-1000-36727fbd3c90",browser_screen_scale_factor:0.5}]},{path:"/v3/serp/ai_summary",method:"post",operationId:"AiSummary",tag:"Serp",description:`The purpose of the Live SERP API AI Summary endpoint is to provide a summary of the content found on any SERP and generate a response based on the user’s specified prompt.
|
|
@@ -658,12 +637,12 @@ for more info please visit 'https://docs.dataforseo.com/v3/appendix/user_data/?b
|
|
|
658
637
|
for more info please visit 'https://docs.dataforseo.com/v3/appendix/errors/?bash'`,docUrl:"https://docs.dataforseo.com/v3/appendix/errors/"},{path:"/v3/appendix/webhook_resend",method:"post",operationId:"WebhookResend",tag:"Appendix",description:`Using this endpoint you can resend webhooks (pingbacks and postbacks) for up to 100 specified tasks.
|
|
659
638
|
Note: Your account will not be double-charged for resending a webhook.
|
|
660
639
|
for more info please visit 'https://docs.dataforseo.com/v3/appendix/webhook_resend/?bash'`,docUrl:"https://docs.dataforseo.com/v3/appendix/webhook_resend/",example:[{id:"08161139-0001-0066-1000-06491d097ed5"}]},{path:"/v3/appendix/status",method:"get",operationId:"AppendixStatus",tag:"Appendix",description:`By calling this API you will receive detailed information about the current status of all our APIs and endpoints. You will also get a full issue description if a problem occurs.
|
|
661
|
-
for more info please visit 'https://docs.dataforseo.com/v3/appendix/status/?bash'`,docUrl:"https://docs.dataforseo.com/v3/appendix/status/"}];var
|
|
662
|
-
`),new
|
|
663
|
-
`);return[
|
|
664
|
-
`),new
|
|
640
|
+
for more info please visit 'https://docs.dataforseo.com/v3/appendix/status/?bash'`,docUrl:"https://docs.dataforseo.com/v3/appendix/status/"}];var ve=Go;function _e(){return ve}function B(e){let t=xo(e);return ve.find((a)=>xo(a.path)===t)}function ye(e,t){let a=e.toLowerCase();return ve.filter((o)=>{if(t&&o.tag?.toLowerCase()!==t.toLowerCase())return!1;if(!a)return!0;return o.path.toLowerCase().includes(a)||o.operationId?.toLowerCase().includes(a)||o.description?.toLowerCase().includes(a)})}function xo(e){let t=e.trim();if(!t.startsWith("/"))t="/"+t;if(!t.startsWith("/v3/"))t="/v3"+t;return t.replace(/\/+$/,"")}var ke="ram",H=new TextEncoder,Uo=c({name:"list",resource:ke,spec:new d({description:"List endpoints, optionally filtered by tag and/or query.",options:[new n({short:"t",long:"tag",valueKind:r.TEXT,description:"Filter by tag."}),new n({short:"q",long:"query",valueKind:r.TEXT,description:"Substring match."}),new n({long:"json",valueKind:r.NONE,description:"Emit JSON instead of lines."})]}),fn:async(e,t,a,o)=>{let s=u(o,"tag")||void 0,i=ye(u(o,"query",""),s);if(T(o,"json"))return[H.encode(JSON.stringify(i,null,2)+`
|
|
641
|
+
`),new w];let m=i.map((f)=>`${f.method.toUpperCase().padEnd(4)} ${f.path}`).join(`
|
|
642
|
+
`);return[H.encode(m+`
|
|
643
|
+
`),new w({stderr:`
|
|
665
644
|
(${i.length} endpoints)
|
|
666
|
-
`})]}}),
|
|
645
|
+
`})]}}),Do=c({name:"show",resource:ke,spec:new d({description:"Show details for one endpoint.",positional:[h("path")]}),fn:async(e,t,a)=>{let o=a[0]??"",s=B(o);if(!s)return[null,new w({exitCode:1,stderr:`No endpoint matches ${o}
|
|
667
646
|
`})];let i=`${s.method.toUpperCase()} ${s.path}
|
|
668
647
|
`;if(s.tag)i+=`tag: ${s.tag}
|
|
669
648
|
`;if(s.operationId)i+=`operationId: ${s.operationId}
|
|
@@ -673,14 +652,13 @@ ${s.description}
|
|
|
673
652
|
`;if(s.example!==void 0)i+=`
|
|
674
653
|
example body:
|
|
675
654
|
${JSON.stringify(s.example,null,2)}
|
|
676
|
-
`;return[
|
|
677
|
-
`);return[
|
|
678
|
-
`),new
|
|
655
|
+
`;return[H.encode(i),new w]}}),Po=c({name:"tags",resource:ke,spec:new d({description:"List all tags and how many endpoints each has."}),fn:async()=>{let e=new Map;for(let o of _e()){let s=o.tag??"(untagged)";e.set(s,(e.get(s)??0)+1)}let a=[...e.entries()].sort((o,s)=>s[1]-o[1]).map(([o,s])=>`${String(s).padStart(4)} ${o}`).join(`
|
|
656
|
+
`);return[H.encode(a+`
|
|
657
|
+
`),new w]}}),we=b({name:"endpoints",description:"Discover and inspect DataForSEO endpoints.",commands:[Uo,Do,Po]});function V(e){let t={};if(e.locationCode!==void 0)t.location_code=e.locationCode;else t.location_name=e.locationName??"United States";if(e.languageCode!==void 0)t.language_code=e.languageCode;else t.language_name=e.languageName??"English";return t}async function be(e){return g("keywords_data/google_ads/search_volume/live",{...V(e),keywords:e.keywords,include_serp_info:e.includeSerpInfo??!1})}async function Te(e){return g("dataforseo_labs/google/keyword_ideas/live",{...V(e),keywords:e.keywords,limit:e.limit??100})}async function Ie(e){return g("dataforseo_labs/google/keyword_suggestions/live",{...V(e),keyword:e.keyword,limit:e.limit??100})}async function Se(e){return g("dataforseo_labs/google/ranked_keywords/live",{...V(e),target:e.target,limit:e.limit??100})}var j="ram";function W(e){return _(e)}var Eo=c({name:"search-volume",resource:j,spec:new d({description:"Get monthly search volume / CPC / competition for keywords.",positional:[h("keywords",{variadic:!0})],options:[...y,new n({long:"include-serp-info",valueKind:r.NONE,description:"Also return SERP feature snapshot."}),...l]}),fn:async(e,t,a,o)=>{let s=await be({...W(o),keywords:[...a],includeSerpInfo:T(o,"include-serp-info")});return p(s,o)}}),Ro=c({name:"ideas",resource:j,spec:new d({description:"Get keyword ideas (DataForSEO Labs).",positional:[h("keywords",{variadic:!0})],options:[...y,new n({long:"limit",valueKind:r.TEXT,description:"Max results.",defaultValue:"100"}),...l]}),fn:async(e,t,a,o)=>{let s=await Te({...W(o),keywords:[...a],limit:k(o,"limit",100)});return p(s,o)}}),Oo=c({name:"suggestions",resource:j,spec:new d({description:"Get keyword suggestions for a seed keyword.",positional:[h("keyword")],options:[...y,new n({long:"limit",valueKind:r.TEXT,description:"Max results.",defaultValue:"100"}),...l]}),fn:async(e,t,a,o)=>{let s=await Ie({...W(o),keyword:a[0]??"",limit:k(o,"limit",100)});return p(s,o)}}),zo=c({name:"ranked",resource:j,spec:new d({description:"Keywords a target domain or URL ranks for.",positional:[h("target")],options:[...y,new n({long:"limit",valueKind:r.TEXT,description:"Max results.",defaultValue:"100"}),...l]}),fn:async(e,t,a,o)=>{let s=await Se({...W(o),target:a[0]??"",limit:k(o,"limit",100)});return p(s,o)}}),Ae=b({name:"keywords",description:"Search volume, ideas, suggestions.",commands:[Eo,Ro,Oo,zo]});function x(e){let t={};if(e.locationCode!==void 0)t.location_code=e.locationCode;else t.location_name=e.locationName??"United States";if(e.languageCode!==void 0)t.language_code=e.languageCode;else t.language_name=e.languageName??"English";return t}async function Le(e){return g("dataforseo_labs/google/competitors_domain/live",{...x(e),target:e.target,limit:e.limit??100})}async function Ge(e){return g("dataforseo_labs/google/domain_intersection/live",{...x(e),target1:e.target1,target2:e.target2,limit:e.limit??100})}async function xe(e){return g("dataforseo_labs/google/domain_rank_overview/live",{...x(e),target:e.target})}async function Ue(e){return g("dataforseo_labs/google/related_keywords/live",{...x(e),keyword:e.keyword,limit:e.limit??100})}async function De(e){return g("dataforseo_labs/google/keyword_overview/live",{...x(e),keywords:e.keywords,include_serp_info:e.includeSerpInfo??!1,include_clickstream_data:e.includeClickstream??!1})}async function Pe(e){return g("dataforseo_labs/google/bulk_keyword_difficulty/live",{...x(e),keywords:e.keywords})}async function Ee(e){return g("dataforseo_labs/google/search_intent/live",{...x(e),keywords:e.keywords})}async function Re(e){return g("dataforseo_labs/google/top_searches/live",{...x(e),limit:e.limit??100})}async function Oe(e){return g("dataforseo_labs/google/historical_rank_overview/live",{...x(e),target:e.target})}var U="ram",X=new n({long:"limit",valueKind:r.TEXT,description:"Max results.",defaultValue:"100"}),Co=c({name:"competitors",resource:U,spec:new d({description:"Domains competing with the target on organic search.",positional:[h("target")],options:[...y,X,...l]}),fn:async(e,t,a,o)=>{let s=await Le({..._(o),target:a[0]??"",limit:k(o,"limit",100)});return p(s,o)}}),Bo=c({name:"intersection",resource:U,spec:new d({description:"Keyword overlap between two domains.",positional:[h("target1"),h("target2")],options:[...y,X,...l]}),fn:async(e,t,a,o)=>{let s=await Ge({..._(o),target1:a[0]??"",target2:a[1]??"",limit:k(o,"limit",100)});return p(s,o)}}),Fo=c({name:"overview",resource:U,spec:new d({description:"Domain rank overview (organic + paid traffic estimates).",positional:[h("target")],options:[...y,...l]}),fn:async(e,t,a,o)=>{let s=await xe({..._(o),target:a[0]??""});return p(s,o)}}),Yo=c({name:"related",resource:U,spec:new d({description:"Semantically related keywords.",positional:[h("keyword")],options:[...y,X,...l]}),fn:async(e,t,a,o)=>{let s=await Ue({..._(o),keyword:a[0]??"",limit:k(o,"limit",100)});return p(s,o)}}),qo=c({name:"keyword-overview",resource:U,spec:new d({description:"Full keyword profile: KD + volume + intent + SERP + backlinks for keywords.",positional:[h("keywords",{variadic:!0})],options:[...y,new n({long:"include-serp-info",valueKind:r.NONE,description:"Include SERP feature snapshot."}),new n({long:"include-clickstream",valueKind:r.NONE,description:"Include clickstream-derived volume."}),...l]}),fn:async(e,t,a,o)=>{let s=await De({..._(o),keywords:[...a],includeSerpInfo:T(o,"include-serp-info"),includeClickstream:T(o,"include-clickstream")});return p(s,o)}}),Ko=c({name:"bulk-difficulty",resource:U,spec:new d({description:"Bulk keyword difficulty (KD) for up to 1000 keywords in one call.",positional:[h("keywords",{variadic:!0})],options:[...y,...l]}),fn:async(e,t,a,o)=>{let s=await Pe({..._(o),keywords:[...a]});return p(s,o)}}),Mo=c({name:"intent",resource:U,spec:new d({description:"Classify search intent (informational/navigational/commercial/transactional) for keywords.",positional:[h("keywords",{variadic:!0})],options:[...y,...l]}),fn:async(e,t,a,o)=>{let s=await Ee({..._(o),keywords:[...a]});return p(s,o)}}),No=c({name:"top-searches",resource:U,spec:new d({description:"Currently-trending top searches in a location.",options:[...y,X,...l]}),fn:async(e,t,a,o)=>{let s=await Re({..._(o),limit:k(o,"limit",100)});return p(s,o)}}),Ho=c({name:"historical",resource:U,spec:new d({description:"Historical rank overview for a domain (month-by-month position counts).",positional:[h("target")],options:[...y,...l]}),fn:async(e,t,a,o)=>{let s=await Oe({..._(o),target:a[0]??""});return p(s,o)}}),ze=b({name:"labs",description:"DataForSEO Labs: competitors, gap analysis, keyword overview, intent, historical.",commands:[Co,Bo,Fo,Yo,qo,Ko,Mo,No,Ho]});var Vo="ram",jo=new TextEncoder,Ce=c({name:"login",resource:Vo,spec:new d({description:"Save DataForSEO credentials to ~/.config/dataforseo/config.json (chmod 600).",options:[new n({short:"l",long:"login",valueKind:r.TEXT,description:"API login (email).",required:!0}),new n({short:"p",long:"password",valueKind:r.TEXT,description:"API password.",required:!0}),new n({long:"no-verify",valueKind:r.NONE,description:"Skip the verification call."})]}),fn:async(e,t,a,o)=>{let s=u(o,"login"),i=u(o,"password");if(!T(o,"no-verify")){process.env.DATAFORSEO_LOGIN=s,process.env.DATAFORSEO_PASSWORD=i;try{await L("/v3/appendix/user_data")}catch(f){return[null,new w({exitCode:1,stderr:`Credentials rejected: ${f.message}
|
|
679
658
|
Run with --no-verify to save anyway.
|
|
680
|
-
`})]}}let
|
|
681
|
-
`),new
|
|
682
|
-
config: ${
|
|
683
|
-
`,
|
|
684
|
-
`;return[
|
|
685
|
-
`})];let i=
|
|
686
|
-
`),process.exit(1)}export{ao as whoamiCmd,ro as userData,po as userCmd,zt as trendsSubregionCmd,bo as trendsSubregion,Io as trendsGroup,Rt as trendsExploreCmd,ko as trendsExplore,Et as trendsDemographyCmd,wo as trendsDemography,D as toCommander,u as textOp,xt as serpYoutubeOrganicCmd,fo as serpYoutubeOrganic,_o as serpGroup,At as serpGoogleOrganicCmd,go as serpGoogleOrganic,Pt as serpGoogleNewsCmd,uo as serpGoogleNews,Ut as serpGoogleMapsCmd,mo as serpGoogleMaps,Dt as serpGoogleImagesCmd,vo as serpGoogleImages,Ye as searchEndpoints,_e as saveCredentials,k as resolveLocLang,we as render,ho as rawCmd,Ho as ok,U as mountGroup,to as loginCmd,co as locationsCmd,Oe as loadEndpoints,M as loadCredentials,so as listLocations,io as listLanguages,lo as languagesCmd,It as labsTopSearchesCmd,Ze as labsTopSearches,kt as labsRelatedCmd,Je as labsRelated,yt as labsOverviewCmd,je as labsOverview,wt as labsKeywordOverviewCmd,$e as labsKeywordOverview,_t as labsIntersectionCmd,We as labsIntersection,Tt as labsIntentCmd,Ve as labsIntent,St as labsHistoricalCmd,eo as labsHistorical,oo as labsGroup,vt as labsCompetitorsCmd,Xe as labsCompetitors,bt as labsBulkDifficultyCmd,Qe as labsBulkDifficulty,ft as keywordsSuggestionsCmd,Ce as keywordsSuggestions,gt as keywordsSearchVolumeCmd,Me as keywordsSearchVolume,ut as keywordsRankedCmd,Ne as keywordsRanked,mt as keywordsIdeasCmd,Ke as keywordsIdeas,He as keywordsGroup,Co as invoke,G as group,x as get,y as flagStr,T as flagNum,A as flagBool,W as findEndpoint,ye as extractItems,ht as endpointsTagsCmd,pt as endpointsShowCmd,lt as endpointsListCmd,Fe as endpointsGroup,ve as configPath,g as command,v as call,Bt as buildProgram,Z as basicAuthHeader,tt as backlinksSummaryCmd,Ue as backlinksSummary,st as backlinksReferringDomainsCmd,De as backlinksReferringDomains,nt as backlinksRanksCmd,Ee as backlinksRanks,at as backlinksListCmd,Pe as backlinksList,ze as backlinksGroup,rt as backlinksCompetitorsCmd,Re as backlinksCompetitors,it as backlinksAnchorsCmd,xe as backlinksAnchors,ue as argvToInput,f as applyOutput,Vo as aiTopPagesCmd,Ie as aiTopPages,Zo as aiTopDomainsCmd,Se as aiTopDomains,$o as aiSearchVolumeCmd,be as aiSearchVolume,et as aiMetricsCmd,Qo as aiMentionsCmd,Te as aiMentions,Le as aiMentionMetrics,Ae as aiGroup,ot as aiAskCmd,Ge as aiAsk,fe as ParsedArgs,p as Option,c as OperandKind,q as Operand,m as OUTPUT_OPTIONS,w as LOC_LANG_OPTIONS,S as IOResult,h as CommandSpec};
|
|
659
|
+
`})]}}let m=Z({login:s,password:i});return[jo.encode(`Saved credentials to ${m}
|
|
660
|
+
`),new w]}}),Be=c({name:"whoami",resource:Vo,spec:new d({description:"Show the configured login (and verify against DataForSEO)."}),fn:async()=>{let t=`login: ${R().login}
|
|
661
|
+
config: ${Q()}
|
|
662
|
+
`,o=(await L("/v3/appendix/user_data")).tasks?.[0]?.result?.[0];if(o?.money?.balance!==void 0)t+=`balance: $${o.money.balance.toFixed(2)}
|
|
663
|
+
`;return[jo.encode(t),new w]}});async function Fe(e="serp/google"){return L(`${e}/locations`)}async function Ye(e="serp/google"){return L(`${e}/languages`)}async function qe(){return L("/v3/appendix/user_data")}var Ke="ram",Me=c({name:"locations",resource:Ke,spec:new d({description:"List supported locations for a given API.",options:[new n({long:"api",valueKind:r.TEXT,description:"API path under /v3.",defaultValue:"serp/google"}),...l]}),fn:async(e,t,a,o)=>{let s=await Fe(u(o,"api","serp/google"));return p(s,o)}}),Ne=c({name:"languages",resource:Ke,spec:new d({description:"List supported languages for a given API.",options:[new n({long:"api",valueKind:r.TEXT,description:"API path under /v3.",defaultValue:"serp/google"}),...l]}),fn:async(e,t,a,o)=>{let s=await Ye(u(o,"api","serp/google"));return p(s,o)}}),He=c({name:"user",resource:Ke,spec:new d({description:"Show DataForSEO account info (balance, plan, limits).",options:[...l]}),fn:async(e,t,a,o)=>{let s=await qe();return p(s,{...o,flags:{...o.flags,full:!0}})}});import{readFileSync as xt}from"node:fs";var Ut="ram",Ve=c({name:"raw",resource:Ut,spec:new d({description:"Hit any DataForSEO endpoint by path (escape hatch over the full 437-endpoint API).",positional:[h("path")],options:[new n({short:"d",long:"data",valueKind:r.TEXT,description:"Inline JSON body."}),new n({short:"f",long:"data-file",valueKind:r.TEXT,description:"Read JSON body from file. '-' for stdin."}),new n({long:"kv",valueKind:r.TEXT,description:"Shorthand body fields, comma-separated, e.g. keyword=seo,location_code=2840."}),new n({long:"example",valueKind:r.NONE,description:"Use the spec's example body."}),new n({long:"method",valueKind:r.TEXT,description:"Override HTTP method."}),new n({long:"no-wrap",valueKind:r.NONE,description:"Don't auto-wrap a single task as [task]."}),...l],rest:new P({kind:r.TEXT,name:"kvpairs"})}),fn:async(e,t,a,o)=>{let s=a[0]??"";if(!s)return[null,new w({exitCode:2,stderr:`raw: missing <path>
|
|
664
|
+
`})];let i=B(s),f=(u(o,"method")||i?.method||"post").toLowerCase(),v=await Dt(o,i?.example,a.slice(1)),I;if(f==="get")I=await L(s);else I=await g(s,v,{wrapAsTaskArray:!T(o,"no-wrap")});return p(I,o)}});async function Dt(e,t,a){if(T(e,"example")){if(t===void 0)throw Error("No example body in spec for this endpoint.");return t}let o=u(e,"data");if(o)return JSON.parse(o);let s=u(e,"data-file");if(s){let f=s==="-"?await Rt():xt(s,"utf8");return JSON.parse(f)}let i=u(e,"kv"),m=[];if(i)m.push(...i.split(","));if(m.push(...a.filter((f)=>f.includes("="))),m.length>0)return Pt(m);return}function Pt(e){let t={};for(let a of e){let o=a.indexOf("=");if(o===-1)continue;t[a.slice(0,o).trim()]=Et(a.slice(o+1))}return t}function Et(e){if(e==="true")return!0;if(e==="false")return!1;if(e==="null")return null;if(/^-?\d+$/.test(e))return Number(e);if(/^-?\d*\.\d+$/.test(e))return Number(e);if(e.startsWith("[")&&e.endsWith("]")||e.startsWith("{")&&e.endsWith("}"))try{return JSON.parse(e)}catch{return e}return e}async function Rt(){let e=[];for await(let t of process.stdin)e.push(t);return Buffer.concat(e).toString("utf8")}function F(e){let t={};if(e.locationCode!==void 0)t.location_code=e.locationCode;else t.location_name=e.locationName??"United States";if(e.languageCode!==void 0)t.language_code=e.languageCode;else t.language_name=e.languageName??"English";return t}async function je(e){let t=e.advanced?"serp/google/organic/live/advanced":"serp/google/organic/live/regular";return g(t,{...F(e),keyword:e.keyword,device:e.device??"desktop",depth:e.depth??100})}async function We(e){return g("serp/google/maps/live/advanced",{...F(e),keyword:e.keyword,device:e.device??"desktop",depth:e.depth??100})}async function Xe(e){return g("serp/youtube/organic/live/advanced",{...F(e),keyword:e.keyword,depth:e.depth??100})}async function Je(e){return g("serp/google/news/live/advanced",{...F(e),keyword:e.keyword,device:e.device??"desktop",depth:e.depth??100})}async function $e(e){return g("serp/google/images/live/advanced",{...F(e),keyword:e.keyword,device:e.device??"desktop",depth:e.depth??100})}var Y="ram",q=[...y,new n({long:"device",valueKind:r.TEXT,description:"desktop | mobile.",defaultValue:"desktop"}),new n({long:"depth",valueKind:r.TEXT,description:"Result depth.",defaultValue:"100"})],Wo=c({name:"organic",resource:Y,spec:new d({description:"Live Google organic SERP for a keyword.",positional:[h("keyword")],options:[...q,new n({long:"advanced",valueKind:r.NONE,description:"Use the advanced endpoint with featured snippet detail."}),...l]}),fn:async(e,t,a,o)=>{let s=await je({..._(o),keyword:a[0]??"",device:u(o,"device","desktop"),depth:k(o,"depth",100),advanced:T(o,"advanced")});return p(s,o)}}),Xo=c({name:"maps",resource:Y,spec:new d({description:"Google Maps / local pack results.",positional:[h("keyword")],options:[...q,...l]}),fn:async(e,t,a,o)=>{let s=await We({..._(o),keyword:a[0]??"",device:u(o,"device","desktop"),depth:k(o,"depth",100)});return p(s,o)}}),Jo=c({name:"news",resource:Y,spec:new d({description:"Google News results for a keyword.",positional:[h("keyword")],options:[...q,...l]}),fn:async(e,t,a,o)=>{let s=await Je({..._(o),keyword:a[0]??"",device:u(o,"device","desktop"),depth:k(o,"depth",100)});return p(s,o)}}),$o=c({name:"images",resource:Y,spec:new d({description:"Google Images results for a keyword.",positional:[h("keyword")],options:[...q,...l]}),fn:async(e,t,a,o)=>{let s=await $e({..._(o),keyword:a[0]??"",device:u(o,"device","desktop"),depth:k(o,"depth",100)});return p(s,o)}}),Qo=c({name:"organic",resource:Y,spec:new d({description:"YouTube organic search results.",positional:[h("keyword")],options:[...q,...l]}),fn:async(e,t,a,o)=>{let s=await Xe({..._(o),keyword:a[0]??"",depth:k(o,"depth",100)});return p(s,o)}}),Qe=b({name:"serp",description:"SERP queries against Google / YouTube.",groups:[b({name:"google",description:"Google SERPs.",commands:[Wo,Xo,Jo,$o]}),b({name:"youtube",description:"YouTube SERPs.",commands:[Qo]})]});function Ze(e){let t={};if(e.locationCode!==void 0)t.location_code=e.locationCode;else t.location_name=e.locationName??"United States";if(e.languageCode!==void 0)t.language_code=e.languageCode;return t}async function eo(e){return g("keywords_data/google_trends/explore/live",{...Ze(e),keywords:e.keywords,type:e.type??"web",date_from:e.dateFrom,date_to:e.dateTo})}async function oo(e){return g("keywords_data/dataforseo_trends/demography/live",{...Ze(e),keywords:e.keywords})}async function to(e){return g("keywords_data/dataforseo_trends/subregion_interests/live",{...Ze(e),keywords:e.keywords})}var ao="ram",Zo=c({name:"explore",resource:ao,spec:new d({description:"Google Trends 'Explore' — popularity time series for keywords.",positional:[h("keywords",{variadic:!0})],options:[...y,new n({long:"type",valueKind:r.TEXT,description:"web | news | youtube | images | shopping.",defaultValue:"web"}),new n({long:"date-from",valueKind:r.TEXT,description:"Start date (YYYY-MM-DD)."}),new n({long:"date-to",valueKind:r.TEXT,description:"End date (YYYY-MM-DD)."}),...l]}),fn:async(e,t,a,o)=>{let s=await eo({..._(o),keywords:[...a],type:u(o,"type","web"),dateFrom:u(o,"date-from")||void 0,dateTo:u(o,"date-to")||void 0});return p(s,o)}}),et=c({name:"demography",resource:ao,spec:new d({description:"Age/gender demographics for keyword interest (DataForSEO Trends).",positional:[h("keywords",{variadic:!0})],options:[...y,...l]}),fn:async(e,t,a,o)=>{let s=await oo({..._(o),keywords:[...a]});return p(s,o)}}),ot=c({name:"subregion",resource:ao,spec:new d({description:"Regional popularity heatmap for keywords (DataForSEO Trends).",positional:[h("keywords",{variadic:!0})],options:[...y,...l]}),fn:async(e,t,a,o)=>{let s=await to({..._(o),keywords:[...a]});return p(s,o)}}),so=b({name:"trends",description:"Google Trends + DataForSEO Trends (time series, demography, region).",commands:[Zo,et,ot]});function zt(){let e=new Ot;return e.name("dfs").description("Ergonomic CLI for the DataForSEO API.\n\nCurated commands cover ~40 high-value endpoints.\nUse `dfs raw <path>` to hit any of the 437 endpoints by path,\nand `dfs endpoints list` / `dfs endpoints show` to discover them.").version("0.3.0"),e.addCommand(A(Ce)),e.addCommand(A(Be)),e.addCommand(A(Me)),e.addCommand(A(Ne)),e.addCommand(A(He)),e.addCommand(A(Ve)),S(e,Ae),S(e,Qe),S(e,ue),S(e,ze),S(e,ce),S(e,so),S(e,we),e}export{Be as whoamiCmd,qe as userData,He as userCmd,ot as trendsSubregionCmd,to as trendsSubregion,so as trendsGroup,Zo as trendsExploreCmd,eo as trendsExplore,et as trendsDemographyCmd,oo as trendsDemography,A as toCommander,h as textOp,Qo as serpYoutubeOrganicCmd,Xe as serpYoutubeOrganic,Qe as serpGroup,Wo as serpGoogleOrganicCmd,je as serpGoogleOrganic,Jo as serpGoogleNewsCmd,Je as serpGoogleNews,Xo as serpGoogleMapsCmd,We as serpGoogleMaps,$o as serpGoogleImagesCmd,$e as serpGoogleImages,ye as searchEndpoints,Z as saveCredentials,_ as resolveLocLang,te as render,Ve as rawCmd,po as ok,S as mountGroup,Ce as loginCmd,Me as locationsCmd,_e as loadEndpoints,R as loadCredentials,Fe as listLocations,Ye as listLanguages,Ne as languagesCmd,No as labsTopSearchesCmd,Re as labsTopSearches,Yo as labsRelatedCmd,Ue as labsRelated,Fo as labsOverviewCmd,xe as labsOverview,qo as labsKeywordOverviewCmd,De as labsKeywordOverview,Bo as labsIntersectionCmd,Ge as labsIntersection,Mo as labsIntentCmd,Ee as labsIntent,Ho as labsHistoricalCmd,Oe as labsHistorical,ze as labsGroup,Co as labsCompetitorsCmd,Le as labsCompetitors,Ko as labsBulkDifficultyCmd,Pe as labsBulkDifficulty,Oo as keywordsSuggestionsCmd,Ie as keywordsSuggestions,Eo as keywordsSearchVolumeCmd,be as keywordsSearchVolume,zo as keywordsRankedCmd,Se as keywordsRanked,Ro as keywordsIdeasCmd,Te as keywordsIdeas,Ae as keywordsGroup,co as invoke,b as group,L as get,u as flagStr,k as flagNum,T as flagBool,B as findEndpoint,ee as extractItems,Po as endpointsTagsCmd,Do as endpointsShowCmd,Uo as endpointsListCmd,we as endpointsGroup,Q as configPath,c as command,g as call,zt as buildProgram,M as basicAuthHeader,bo as backlinksSummaryCmd,le as backlinksSummary,Io as backlinksReferringDomainsCmd,he as backlinksReferringDomains,Lo as backlinksRanksCmd,fe as backlinksRanks,To as backlinksListCmd,pe as backlinksList,ue as backlinksGroup,Ao as backlinksCompetitorsCmd,me as backlinksCompetitors,So as backlinksAnchorsCmd,ge as backlinksAnchors,$ as argvToInput,p as applyOutput,_o as aiTopPagesCmd,ie as aiTopPages,yo as aiTopDomainsCmd,re as aiTopDomains,uo as aiSearchVolumeCmd,ae as aiSearchVolume,ko as aiMetricsCmd,vo as aiMentionsCmd,se as aiMentions,ne as aiMentionMetrics,ce as aiGroup,wo as aiAskCmd,de as aiAsk,J as ParsedArgs,n as Option,r as OperandKind,P as Operand,l as OUTPUT_OPTIONS,y as LOC_LANG_OPTIONS,w as IOResult,d as CommandSpec};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mirage-cli/dataforseo-cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Ergonomic CLI wrapper around the DataForSEO API (curated commands + raw escape hatch).",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -33,15 +33,15 @@
|
|
|
33
33
|
"README.md"
|
|
34
34
|
],
|
|
35
35
|
"bin": {
|
|
36
|
-
"dfs": "./dist/
|
|
37
|
-
"dataforseo": "./dist/
|
|
36
|
+
"dfs": "./dist/bin.js",
|
|
37
|
+
"dataforseo": "./dist/bin.js"
|
|
38
38
|
},
|
|
39
39
|
"scripts": {
|
|
40
40
|
"dev": "bun run src/dfs.ts",
|
|
41
41
|
"spec:build": "bun run scripts/build-spec-index.ts",
|
|
42
42
|
"spec:refresh": "bun run scripts/refresh-spec.ts && bun run scripts/build-spec-index.ts",
|
|
43
43
|
"prebuild": "bun run scripts/build-spec-index.ts",
|
|
44
|
-
"build": "bun build src/dfs.ts src/index.ts --target=node --outdir=dist --minify && bun run scripts/postbuild.ts && bun run scripts/build-types.ts",
|
|
44
|
+
"build": "bun build src/bin.ts src/dfs.ts src/index.ts --target=node --outdir=dist --external commander --minify && bun run scripts/postbuild.ts && bun run scripts/build-types.ts",
|
|
45
45
|
"compile": "bun build src/dfs.ts --compile --outfile=bin/dfs",
|
|
46
46
|
"test": "bun test --reporter=dots",
|
|
47
47
|
"typecheck": "tsc --noEmit"
|