@spree/cli 2.1.1 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +41 -1
- package/dist/index.js +376 -156
- package/package.json +7 -4
package/dist/index.js
CHANGED
|
@@ -1,173 +1,393 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire as __createRequire } from "node:module";
|
|
3
3
|
const require = __createRequire(import.meta.url);
|
|
4
|
-
var
|
|
5
|
-
`)}displayWidth(t){return
|
|
6
|
-
`+" ".repeat(r+c)),
|
|
7
|
-
${
|
|
8
|
-
`)}};function
|
|
4
|
+
var Zm=Object.create;var Mo=Object.defineProperty;var eh=Object.getOwnPropertyDescriptor;var th=Object.getOwnPropertyNames;var rh=Object.getPrototypeOf,ih=Object.prototype.hasOwnProperty;var se=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var q=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var nh=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of th(t))!ih.call(e,n)&&n!==r&&Mo(e,n,{get:()=>t[n],enumerable:!(i=eh(t,n))||i.enumerable});return e};var B=(e,t,r)=>(r=e!=null?Zm(rh(e)):{},nh(t||!e||!e.__esModule?Mo(r,"default",{value:e,enumerable:!0}):r,e));var Dt=q(on=>{"use strict";var gr=class extends Error{constructor(t,r,i){super(i),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=r,this.exitCode=t,this.nestedError=void 0}},sn=class extends gr{constructor(t){super(1,"commander.invalidArgument",t),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};on.CommanderError=gr;on.InvalidArgumentError=sn});var _r=q(cn=>{"use strict";var{InvalidArgumentError:sh}=Dt(),an=class{constructor(t,r){switch(this.description=r||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,t[0]){case"<":this.required=!0,this._name=t.slice(1,-1);break;case"[":this.required=!1,this._name=t.slice(1,-1);break;default:this.required=!0,this._name=t;break}this._name.endsWith("...")&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(t,r){return r===this.defaultValue||!Array.isArray(r)?[t]:(r.push(t),r)}default(t,r){return this.defaultValue=t,this.defaultValueDescription=r,this}argParser(t){return this.parseArg=t,this}choices(t){return this.argChoices=t.slice(),this.parseArg=(r,i)=>{if(!this.argChoices.includes(r))throw new sh(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._collectValue(r,i):r},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function oh(e){let t=e.name()+(e.variadic===!0?"...":"");return e.required?"<"+t+">":"["+t+"]"}cn.Argument=an;cn.humanReadableArgName=oh});var un=q(dn=>{"use strict";var{humanReadableArgName:ah}=_r(),pn=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(t){this.helpWidth=this.helpWidth??t.helpWidth??80}visibleCommands(t){let r=t.commands.filter(n=>!n._hidden),i=t._getHelpCommand();return i&&!i._hidden&&r.push(i),this.sortSubcommands&&r.sort((n,s)=>n.name().localeCompare(s.name())),r}compareOptions(t,r){let i=n=>n.short?n.short.replace(/^-/,""):n.long.replace(/^--/,"");return i(t).localeCompare(i(r))}visibleOptions(t){let r=t.options.filter(n=>!n.hidden),i=t._getHelpOption();if(i&&!i.hidden){let n=i.short&&t._findOption(i.short),s=i.long&&t._findOption(i.long);!n&&!s?r.push(i):i.long&&!s?r.push(t.createOption(i.long,i.description)):i.short&&!n&&r.push(t.createOption(i.short,i.description))}return this.sortOptions&&r.sort(this.compareOptions),r}visibleGlobalOptions(t){if(!this.showGlobalOptions)return[];let r=[];for(let i=t.parent;i;i=i.parent){let n=i.options.filter(s=>!s.hidden);r.push(...n)}return this.sortOptions&&r.sort(this.compareOptions),r}visibleArguments(t){return t._argsDescription&&t.registeredArguments.forEach(r=>{r.description=r.description||t._argsDescription[r.name()]||""}),t.registeredArguments.find(r=>r.description)?t.registeredArguments:[]}subcommandTerm(t){let r=t.registeredArguments.map(i=>ah(i)).join(" ");return t._name+(t._aliases[0]?"|"+t._aliases[0]:"")+(t.options.length?" [options]":"")+(r?" "+r:"")}optionTerm(t){return t.flags}argumentTerm(t){return t.name()}longestSubcommandTermLength(t,r){return r.visibleCommands(t).reduce((i,n)=>Math.max(i,this.displayWidth(r.styleSubcommandTerm(r.subcommandTerm(n)))),0)}longestOptionTermLength(t,r){return r.visibleOptions(t).reduce((i,n)=>Math.max(i,this.displayWidth(r.styleOptionTerm(r.optionTerm(n)))),0)}longestGlobalOptionTermLength(t,r){return r.visibleGlobalOptions(t).reduce((i,n)=>Math.max(i,this.displayWidth(r.styleOptionTerm(r.optionTerm(n)))),0)}longestArgumentTermLength(t,r){return r.visibleArguments(t).reduce((i,n)=>Math.max(i,this.displayWidth(r.styleArgumentTerm(r.argumentTerm(n)))),0)}commandUsage(t){let r=t._name;t._aliases[0]&&(r=r+"|"+t._aliases[0]);let i="";for(let n=t.parent;n;n=n.parent)i=n.name()+" "+i;return i+r+" "+t.usage()}commandDescription(t){return t.description()}subcommandDescription(t){return t.summary()||t.description()}optionDescription(t){let r=[];if(t.argChoices&&r.push(`choices: ${t.argChoices.map(i=>JSON.stringify(i)).join(", ")}`),t.defaultValue!==void 0&&(t.required||t.optional||t.isBoolean()&&typeof t.defaultValue=="boolean")&&r.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`),t.presetArg!==void 0&&t.optional&&r.push(`preset: ${JSON.stringify(t.presetArg)}`),t.envVar!==void 0&&r.push(`env: ${t.envVar}`),r.length>0){let i=`(${r.join(", ")})`;return t.description?`${t.description} ${i}`:i}return t.description}argumentDescription(t){let r=[];if(t.argChoices&&r.push(`choices: ${t.argChoices.map(i=>JSON.stringify(i)).join(", ")}`),t.defaultValue!==void 0&&r.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`),r.length>0){let i=`(${r.join(", ")})`;return t.description?`${t.description} ${i}`:i}return t.description}formatItemList(t,r,i){return r.length===0?[]:[i.styleTitle(t),...r,""]}groupItems(t,r,i){let n=new Map;return t.forEach(s=>{let o=i(s);n.has(o)||n.set(o,[])}),r.forEach(s=>{let o=i(s);n.has(o)||n.set(o,[]),n.get(o).push(s)}),n}formatHelp(t,r){let i=r.padWidth(t,r),n=r.helpWidth??80;function s(u,l){return r.formatItem(u,i,l,r)}let o=[`${r.styleTitle("Usage:")} ${r.styleUsage(r.commandUsage(t))}`,""],a=r.commandDescription(t);a.length>0&&(o=o.concat([r.boxWrap(r.styleCommandDescription(a),n),""]));let c=r.visibleArguments(t).map(u=>s(r.styleArgumentTerm(r.argumentTerm(u)),r.styleArgumentDescription(r.argumentDescription(u))));if(o=o.concat(this.formatItemList("Arguments:",c,r)),this.groupItems(t.options,r.visibleOptions(t),u=>u.helpGroupHeading??"Options:").forEach((u,l)=>{let m=u.map(h=>s(r.styleOptionTerm(r.optionTerm(h)),r.styleOptionDescription(r.optionDescription(h))));o=o.concat(this.formatItemList(l,m,r))}),r.showGlobalOptions){let u=r.visibleGlobalOptions(t).map(l=>s(r.styleOptionTerm(r.optionTerm(l)),r.styleOptionDescription(r.optionDescription(l))));o=o.concat(this.formatItemList("Global Options:",u,r))}return this.groupItems(t.commands,r.visibleCommands(t),u=>u.helpGroup()||"Commands:").forEach((u,l)=>{let m=u.map(h=>s(r.styleSubcommandTerm(r.subcommandTerm(h)),r.styleSubcommandDescription(r.subcommandDescription(h))));o=o.concat(this.formatItemList(l,m,r))}),o.join(`
|
|
5
|
+
`)}displayWidth(t){return Fo(t).length}styleTitle(t){return t}styleUsage(t){return t.split(" ").map(r=>r==="[options]"?this.styleOptionText(r):r==="[command]"?this.styleSubcommandText(r):r[0]==="["||r[0]==="<"?this.styleArgumentText(r):this.styleCommandText(r)).join(" ")}styleCommandDescription(t){return this.styleDescriptionText(t)}styleOptionDescription(t){return this.styleDescriptionText(t)}styleSubcommandDescription(t){return this.styleDescriptionText(t)}styleArgumentDescription(t){return this.styleDescriptionText(t)}styleDescriptionText(t){return t}styleOptionTerm(t){return this.styleOptionText(t)}styleSubcommandTerm(t){return t.split(" ").map(r=>r==="[options]"?this.styleOptionText(r):r[0]==="["||r[0]==="<"?this.styleArgumentText(r):this.styleSubcommandText(r)).join(" ")}styleArgumentTerm(t){return this.styleArgumentText(t)}styleOptionText(t){return t}styleArgumentText(t){return t}styleSubcommandText(t){return t}styleCommandText(t){return t}padWidth(t,r){return Math.max(r.longestOptionTermLength(t,r),r.longestGlobalOptionTermLength(t,r),r.longestSubcommandTermLength(t,r),r.longestArgumentTermLength(t,r))}preformatted(t){return/\n[^\S\r\n]/.test(t)}formatItem(t,r,i,n){let o=" ".repeat(2);if(!i)return o+t;let a=t.padEnd(r+t.length-n.displayWidth(t)),c=2,p=(this.helpWidth??80)-r-c-2,u;return p<this.minWidthToWrap||n.preformatted(i)?u=i:u=n.boxWrap(i,p).replace(/\n/g,`
|
|
6
|
+
`+" ".repeat(r+c)),o+a+" ".repeat(c)+u.replace(/\n/g,`
|
|
7
|
+
${o}`)}boxWrap(t,r){if(r<this.minWidthToWrap)return t;let i=t.split(/\r\n|\n/),n=/[\s]*[^\s]+/g,s=[];return i.forEach(o=>{let a=o.match(n);if(a===null){s.push("");return}let c=[a.shift()],d=this.displayWidth(c[0]);a.forEach(p=>{let u=this.displayWidth(p);if(d+u<=r){c.push(p),d+=u;return}s.push(c.join(""));let l=p.trimStart();c=[l],d=this.displayWidth(l)}),s.push(c.join(""))}),s.join(`
|
|
8
|
+
`)}};function Fo(e){let t=/\x1b\[\d*(;\d*)*m/g;return e.replace(t,"")}dn.Help=pn;dn.stripColor=Fo});var yn=q(hn=>{"use strict";var{InvalidArgumentError:ch}=Dt(),ln=class{constructor(t,r){this.flags=t,this.description=r||"",this.required=t.includes("<"),this.optional=t.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(t),this.mandatory=!1;let i=ph(t);this.short=i.shortFlag,this.long=i.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith("--no-")),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0,this.helpGroupHeading=void 0}default(t,r){return this.defaultValue=t,this.defaultValueDescription=r,this}preset(t){return this.presetArg=t,this}conflicts(t){return this.conflictsWith=this.conflictsWith.concat(t),this}implies(t){let r=t;return typeof t=="string"&&(r={[t]:!0}),this.implied=Object.assign(this.implied||{},r),this}env(t){return this.envVar=t,this}argParser(t){return this.parseArg=t,this}makeOptionMandatory(t=!0){return this.mandatory=!!t,this}hideHelp(t=!0){return this.hidden=!!t,this}_collectValue(t,r){return r===this.defaultValue||!Array.isArray(r)?[t]:(r.push(t),r)}choices(t){return this.argChoices=t.slice(),this.parseArg=(r,i)=>{if(!this.argChoices.includes(r))throw new ch(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._collectValue(r,i):r},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return this.negate?Uo(this.name().replace(/^no-/,"")):Uo(this.name())}helpGroup(t){return this.helpGroupHeading=t,this}is(t){return this.short===t||this.long===t}isBoolean(){return!this.required&&!this.optional&&!this.negate}},mn=class{constructor(t){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,t.forEach(r=>{r.negate?this.negativeOptions.set(r.attributeName(),r):this.positiveOptions.set(r.attributeName(),r)}),this.negativeOptions.forEach((r,i)=>{this.positiveOptions.has(i)&&this.dualOptions.add(i)})}valueFromOption(t,r){let i=r.attributeName();if(!this.dualOptions.has(i))return!0;let n=this.negativeOptions.get(i).presetArg,s=n!==void 0?n:!1;return r.negate===(s===t)}};function Uo(e){return e.split("-").reduce((t,r)=>t+r[0].toUpperCase()+r.slice(1))}function ph(e){let t,r,i=/^-[^-]$/,n=/^--[^-]/,s=e.split(/[ |,]+/).concat("guard");if(i.test(s[0])&&(t=s.shift()),n.test(s[0])&&(r=s.shift()),!t&&i.test(s[0])&&(t=s.shift()),!t&&n.test(s[0])&&(t=r,r=s.shift()),s[0].startsWith("-")){let o=s[0],a=`option creation failed due to '${o}' in option flags '${e}'`;throw/^-[^-][^-]/.test(o)?new Error(`${a}
|
|
9
9
|
- a short flag is a single dash and a single character
|
|
10
10
|
- either use a single dash and a single character (for a short flag)
|
|
11
|
-
- or use a double dash for a long option (and can have two, like '--ws, --workspace')`):
|
|
12
|
-
- too many short flags`):
|
|
11
|
+
- or use a double dash for a long option (and can have two, like '--ws, --workspace')`):i.test(o)?new Error(`${a}
|
|
12
|
+
- too many short flags`):n.test(o)?new Error(`${a}
|
|
13
13
|
- too many long flags`):new Error(`${a}
|
|
14
|
-
- unrecognised flag format`)}if(t===void 0&&r===void 0)throw new Error(`option creation failed due to no flags found in '${e}'.`);return{shortFlag:t,longFlag:r}}
|
|
15
|
-
(Did you mean one of ${
|
|
16
|
-
(Did you mean ${
|
|
17
|
-
- specify the name in Command constructor or using .name()`);return r=r||{},r.isDefault&&(this._defaultCommandName=t._name),(r.noHelp||r.hidden)&&(t._hidden=!0),this._registerCommand(t),t.parent=this,t._checkForBrokenPassThrough(),this}createArgument(t,r){return new
|
|
18
|
-
Expecting one of '${
|
|
19
|
-
- already used by option '${r.flags}'`)}this._initOptionGroup(t),this.options.push(t)}_registerCommand(t){let r=
|
|
20
|
-
- either make a new Command for each call to parse, or stop storing options as properties`);this._name=this._savedState._name,this._scriptPath=null,this.rawArgs=[],this._optionValues={...this._savedState._optionValues},this._optionValueSources={...this._savedState._optionValueSources},this.args=[],this.processedArgs=[]}_checkForMissingExecutable(t,r,
|
|
21
|
-
- if '${
|
|
14
|
+
- unrecognised flag format`)}if(t===void 0&&r===void 0)throw new Error(`option creation failed due to no flags found in '${e}'.`);return{shortFlag:t,longFlag:r}}hn.Option=ln;hn.DualOptions=mn});var No=q(Bo=>{"use strict";function dh(e,t){if(Math.abs(e.length-t.length)>3)return Math.max(e.length,t.length);let r=[];for(let i=0;i<=e.length;i++)r[i]=[i];for(let i=0;i<=t.length;i++)r[0][i]=i;for(let i=1;i<=t.length;i++)for(let n=1;n<=e.length;n++){let s=1;e[n-1]===t[i-1]?s=0:s=1,r[n][i]=Math.min(r[n-1][i]+1,r[n][i-1]+1,r[n-1][i-1]+s),n>1&&i>1&&e[n-1]===t[i-2]&&e[n-2]===t[i-1]&&(r[n][i]=Math.min(r[n][i],r[n-2][i-2]+1))}return r[e.length][t.length]}function uh(e,t){if(!t||t.length===0)return"";t=Array.from(new Set(t));let r=e.startsWith("--");r&&(e=e.slice(2),t=t.map(o=>o.slice(2)));let i=[],n=3,s=.4;return t.forEach(o=>{if(o.length<=1)return;let a=dh(e,o),c=Math.max(e.length,o.length);(c-a)/c>s&&(a<n?(n=a,i=[o]):a===n&&i.push(o))}),i.sort((o,a)=>o.localeCompare(a)),r&&(i=i.map(o=>`--${o}`)),i.length>1?`
|
|
15
|
+
(Did you mean one of ${i.join(", ")}?)`:i.length===1?`
|
|
16
|
+
(Did you mean ${i[0]}?)`:""}Bo.suggestSimilar=uh});var Wo=q(xn=>{"use strict";var lh=se("events").EventEmitter,fn=se("child_process"),Re=se("path"),br=se("fs"),T=se("process"),{Argument:mh,humanReadableArgName:hh}=_r(),{CommanderError:gn}=Dt(),{Help:yh,stripColor:fh}=un(),{Option:Go,DualOptions:gh}=yn(),{suggestSimilar:zo}=No(),_n=class e extends lh{constructor(t){super(),this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!1,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=t||"",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._savedState=null,this._outputConfiguration={writeOut:r=>T.stdout.write(r),writeErr:r=>T.stderr.write(r),outputError:(r,i)=>i(r),getOutHelpWidth:()=>T.stdout.isTTY?T.stdout.columns:void 0,getErrHelpWidth:()=>T.stderr.isTTY?T.stderr.columns:void 0,getOutHasColors:()=>bn()??(T.stdout.isTTY&&T.stdout.hasColors?.()),getErrHasColors:()=>bn()??(T.stderr.isTTY&&T.stderr.hasColors?.()),stripColor:r=>fh(r)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={},this._helpGroupHeading=void 0,this._defaultCommandGroup=void 0,this._defaultOptionGroup=void 0}copyInheritedSettings(t){return this._outputConfiguration=t._outputConfiguration,this._helpOption=t._helpOption,this._helpCommand=t._helpCommand,this._helpConfiguration=t._helpConfiguration,this._exitCallback=t._exitCallback,this._storeOptionsAsProperties=t._storeOptionsAsProperties,this._combineFlagAndOptionalValue=t._combineFlagAndOptionalValue,this._allowExcessArguments=t._allowExcessArguments,this._enablePositionalOptions=t._enablePositionalOptions,this._showHelpAfterError=t._showHelpAfterError,this._showSuggestionAfterError=t._showSuggestionAfterError,this}_getCommandAndAncestors(){let t=[];for(let r=this;r;r=r.parent)t.push(r);return t}command(t,r,i){let n=r,s=i;typeof n=="object"&&n!==null&&(s=n,n=null),s=s||{};let[,o,a]=t.match(/([^ ]+) *(.*)/),c=this.createCommand(o);return n&&(c.description(n),c._executableHandler=!0),s.isDefault&&(this._defaultCommandName=c._name),c._hidden=!!(s.noHelp||s.hidden),c._executableFile=s.executableFile||null,a&&c.arguments(a),this._registerCommand(c),c.parent=this,c.copyInheritedSettings(this),n?this:c}createCommand(t){return new e(t)}createHelp(){return Object.assign(new yh,this.configureHelp())}configureHelp(t){return t===void 0?this._helpConfiguration:(this._helpConfiguration=t,this)}configureOutput(t){return t===void 0?this._outputConfiguration:(this._outputConfiguration={...this._outputConfiguration,...t},this)}showHelpAfterError(t=!0){return typeof t!="string"&&(t=!!t),this._showHelpAfterError=t,this}showSuggestionAfterError(t=!0){return this._showSuggestionAfterError=!!t,this}addCommand(t,r){if(!t._name)throw new Error(`Command passed to .addCommand() must have a name
|
|
17
|
+
- specify the name in Command constructor or using .name()`);return r=r||{},r.isDefault&&(this._defaultCommandName=t._name),(r.noHelp||r.hidden)&&(t._hidden=!0),this._registerCommand(t),t.parent=this,t._checkForBrokenPassThrough(),this}createArgument(t,r){return new mh(t,r)}argument(t,r,i,n){let s=this.createArgument(t,r);return typeof i=="function"?s.default(n).argParser(i):s.default(i),this.addArgument(s),this}arguments(t){return t.trim().split(/ +/).forEach(r=>{this.argument(r)}),this}addArgument(t){let r=this.registeredArguments.slice(-1)[0];if(r?.variadic)throw new Error(`only the last argument can be variadic '${r.name()}'`);if(t.required&&t.defaultValue!==void 0&&t.parseArg===void 0)throw new Error(`a default value for a required argument is never used: '${t.name()}'`);return this.registeredArguments.push(t),this}helpCommand(t,r){if(typeof t=="boolean")return this._addImplicitHelpCommand=t,t&&this._defaultCommandGroup&&this._initCommandGroup(this._getHelpCommand()),this;let i=t??"help [command]",[,n,s]=i.match(/([^ ]+) *(.*)/),o=r??"display help for command",a=this.createCommand(n);return a.helpOption(!1),s&&a.arguments(s),o&&a.description(o),this._addImplicitHelpCommand=!0,this._helpCommand=a,(t||r)&&this._initCommandGroup(a),this}addHelpCommand(t,r){return typeof t!="object"?(this.helpCommand(t,r),this):(this._addImplicitHelpCommand=!0,this._helpCommand=t,this._initCommandGroup(t),this)}_getHelpCommand(){return this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"))?(this._helpCommand===void 0&&this.helpCommand(void 0,void 0),this._helpCommand):null}hook(t,r){let i=["preSubcommand","preAction","postAction"];if(!i.includes(t))throw new Error(`Unexpected value for event passed to hook : '${t}'.
|
|
18
|
+
Expecting one of '${i.join("', '")}'`);return this._lifeCycleHooks[t]?this._lifeCycleHooks[t].push(r):this._lifeCycleHooks[t]=[r],this}exitOverride(t){return t?this._exitCallback=t:this._exitCallback=r=>{if(r.code!=="commander.executeSubCommandAsync")throw r},this}_exit(t,r,i){this._exitCallback&&this._exitCallback(new gn(t,r,i)),T.exit(t)}action(t){let r=i=>{let n=this.registeredArguments.length,s=i.slice(0,n);return this._storeOptionsAsProperties?s[n]=this:s[n]=this.opts(),s.push(this),t.apply(this,s)};return this._actionHandler=r,this}createOption(t,r){return new Go(t,r)}_callParseArg(t,r,i,n){try{return t.parseArg(r,i)}catch(s){if(s.code==="commander.invalidArgument"){let o=`${n} ${s.message}`;this.error(o,{exitCode:s.exitCode,code:s.code})}throw s}}_registerOption(t){let r=t.short&&this._findOption(t.short)||t.long&&this._findOption(t.long);if(r){let i=t.long&&this._findOption(t.long)?t.long:t.short;throw new Error(`Cannot add option '${t.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${i}'
|
|
19
|
+
- already used by option '${r.flags}'`)}this._initOptionGroup(t),this.options.push(t)}_registerCommand(t){let r=n=>[n.name()].concat(n.aliases()),i=r(t).find(n=>this._findCommand(n));if(i){let n=r(this._findCommand(i)).join("|"),s=r(t).join("|");throw new Error(`cannot add command '${s}' as already have command '${n}'`)}this._initCommandGroup(t),this.commands.push(t)}addOption(t){this._registerOption(t);let r=t.name(),i=t.attributeName();if(t.negate){let s=t.long.replace(/^--no-/,"--");this._findOption(s)||this.setOptionValueWithSource(i,t.defaultValue===void 0?!0:t.defaultValue,"default")}else t.defaultValue!==void 0&&this.setOptionValueWithSource(i,t.defaultValue,"default");let n=(s,o,a)=>{s==null&&t.presetArg!==void 0&&(s=t.presetArg);let c=this.getOptionValue(i);s!==null&&t.parseArg?s=this._callParseArg(t,s,c,o):s!==null&&t.variadic&&(s=t._collectValue(s,c)),s==null&&(t.negate?s=!1:t.isBoolean()||t.optional?s=!0:s=""),this.setOptionValueWithSource(i,s,a)};return this.on("option:"+r,s=>{let o=`error: option '${t.flags}' argument '${s}' is invalid.`;n(s,o,"cli")}),t.envVar&&this.on("optionEnv:"+r,s=>{let o=`error: option '${t.flags}' value '${s}' from env '${t.envVar}' is invalid.`;n(s,o,"env")}),this}_optionEx(t,r,i,n,s){if(typeof r=="object"&&r instanceof Go)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");let o=this.createOption(r,i);if(o.makeOptionMandatory(!!t.mandatory),typeof n=="function")o.default(s).argParser(n);else if(n instanceof RegExp){let a=n;n=(c,d)=>{let p=a.exec(c);return p?p[0]:d},o.default(s).argParser(n)}else o.default(n);return this.addOption(o)}option(t,r,i,n){return this._optionEx({},t,r,i,n)}requiredOption(t,r,i,n){return this._optionEx({mandatory:!0},t,r,i,n)}combineFlagAndOptionalValue(t=!0){return this._combineFlagAndOptionalValue=!!t,this}allowUnknownOption(t=!0){return this._allowUnknownOption=!!t,this}allowExcessArguments(t=!0){return this._allowExcessArguments=!!t,this}enablePositionalOptions(t=!0){return this._enablePositionalOptions=!!t,this}passThroughOptions(t=!0){return this._passThroughOptions=!!t,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw new Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties(t=!0){if(this.options.length)throw new Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw new Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!t,this}getOptionValue(t){return this._storeOptionsAsProperties?this[t]:this._optionValues[t]}setOptionValue(t,r){return this.setOptionValueWithSource(t,r,void 0)}setOptionValueWithSource(t,r,i){return this._storeOptionsAsProperties?this[t]=r:this._optionValues[t]=r,this._optionValueSources[t]=i,this}getOptionValueSource(t){return this._optionValueSources[t]}getOptionValueSourceWithGlobals(t){let r;return this._getCommandAndAncestors().forEach(i=>{i.getOptionValueSource(t)!==void 0&&(r=i.getOptionValueSource(t))}),r}_prepareUserArgs(t,r){if(t!==void 0&&!Array.isArray(t))throw new Error("first parameter to parse must be array or undefined");if(r=r||{},t===void 0&&r.from===void 0){T.versions?.electron&&(r.from="electron");let n=T.execArgv??[];(n.includes("-e")||n.includes("--eval")||n.includes("-p")||n.includes("--print"))&&(r.from="eval")}t===void 0&&(t=T.argv),this.rawArgs=t.slice();let i;switch(r.from){case void 0:case"node":this._scriptPath=t[1],i=t.slice(2);break;case"electron":T.defaultApp?(this._scriptPath=t[1],i=t.slice(2)):i=t.slice(1);break;case"user":i=t.slice(0);break;case"eval":i=t.slice(1);break;default:throw new Error(`unexpected parse option { from: '${r.from}' }`)}return!this._name&&this._scriptPath&&this.nameFromFilename(this._scriptPath),this._name=this._name||"program",i}parse(t,r){this._prepareForParse();let i=this._prepareUserArgs(t,r);return this._parseCommand([],i),this}async parseAsync(t,r){this._prepareForParse();let i=this._prepareUserArgs(t,r);return await this._parseCommand([],i),this}_prepareForParse(){this._savedState===null?this.saveStateBeforeParse():this.restoreStateBeforeParse()}saveStateBeforeParse(){this._savedState={_name:this._name,_optionValues:{...this._optionValues},_optionValueSources:{...this._optionValueSources}}}restoreStateBeforeParse(){if(this._storeOptionsAsProperties)throw new Error(`Can not call parse again when storeOptionsAsProperties is true.
|
|
20
|
+
- either make a new Command for each call to parse, or stop storing options as properties`);this._name=this._savedState._name,this._scriptPath=null,this.rawArgs=[],this._optionValues={...this._savedState._optionValues},this._optionValueSources={...this._savedState._optionValueSources},this.args=[],this.processedArgs=[]}_checkForMissingExecutable(t,r,i){if(br.existsSync(t))return;let n=r?`searched for local subcommand relative to directory '${r}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",s=`'${t}' does not exist
|
|
21
|
+
- if '${i}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
|
|
22
22
|
- if the default executable name is not suitable, use the executableFile option to supply a custom name or path
|
|
23
|
-
- ${
|
|
23
|
+
- ${n}`;throw new Error(s)}_executeSubCommand(t,r){r=r.slice();let i=!1,n=[".js",".ts",".tsx",".mjs",".cjs"];function s(p,u){let l=Re.resolve(p,u);if(br.existsSync(l))return l;if(n.includes(Re.extname(u)))return;let m=n.find(h=>br.existsSync(`${l}${h}`));if(m)return`${l}${m}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let o=t._executableFile||`${this._name}-${t._name}`,a=this._executableDir||"";if(this._scriptPath){let p;try{p=br.realpathSync(this._scriptPath)}catch{p=this._scriptPath}a=Re.resolve(Re.dirname(p),a)}if(a){let p=s(a,o);if(!p&&!t._executableFile&&this._scriptPath){let u=Re.basename(this._scriptPath,Re.extname(this._scriptPath));u!==this._name&&(p=s(a,`${u}-${t._name}`))}o=p||o}i=n.includes(Re.extname(o));let c;T.platform!=="win32"?i?(r.unshift(o),r=Vo(T.execArgv).concat(r),c=fn.spawn(T.argv[0],r,{stdio:"inherit"})):c=fn.spawn(o,r,{stdio:"inherit"}):(this._checkForMissingExecutable(o,a,t._name),r.unshift(o),r=Vo(T.execArgv).concat(r),c=fn.spawn(T.execPath,r,{stdio:"inherit"})),c.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(u=>{T.on(u,()=>{c.killed===!1&&c.exitCode===null&&c.kill(u)})});let d=this._exitCallback;c.on("close",p=>{p=p??1,d?d(new gn(p,"commander.executeSubCommandAsync","(close)")):T.exit(p)}),c.on("error",p=>{if(p.code==="ENOENT")this._checkForMissingExecutable(o,a,t._name);else if(p.code==="EACCES")throw new Error(`'${o}' not executable`);if(!d)T.exit(1);else{let u=new gn(1,"commander.executeSubCommandAsync","(error)");u.nestedError=p,d(u)}}),this.runningCommand=c}_dispatchSubcommand(t,r,i){let n=this._findCommand(t);n||this.help({error:!0}),n._prepareForParse();let s;return s=this._chainOrCallSubCommandHook(s,n,"preSubcommand"),s=this._chainOrCall(s,()=>{if(n._executableHandler)this._executeSubCommand(n,r.concat(i));else return n._parseCommand(r,i)}),s}_dispatchHelpCommand(t){t||this.help();let r=this._findCommand(t);return r&&!r._executableHandler&&r.help(),this._dispatchSubcommand(t,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){this.registeredArguments.forEach((t,r)=>{t.required&&this.args[r]==null&&this.missingArgument(t.name())}),!(this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)&&this.args.length>this.registeredArguments.length&&this._excessArguments(this.args)}_processArguments(){let t=(i,n,s)=>{let o=n;if(n!==null&&i.parseArg){let a=`error: command-argument value '${n}' is invalid for argument '${i.name()}'.`;o=this._callParseArg(i,n,s,a)}return o};this._checkNumberOfArguments();let r=[];this.registeredArguments.forEach((i,n)=>{let s=i.defaultValue;i.variadic?n<this.args.length?(s=this.args.slice(n),i.parseArg&&(s=s.reduce((o,a)=>t(i,a,o),i.defaultValue))):s===void 0&&(s=[]):n<this.args.length&&(s=this.args[n],i.parseArg&&(s=t(i,s,i.defaultValue))),r[n]=s}),this.processedArgs=r}_chainOrCall(t,r){return t?.then&&typeof t.then=="function"?t.then(()=>r()):r()}_chainOrCallHooks(t,r){let i=t,n=[];return this._getCommandAndAncestors().reverse().filter(s=>s._lifeCycleHooks[r]!==void 0).forEach(s=>{s._lifeCycleHooks[r].forEach(o=>{n.push({hookedCommand:s,callback:o})})}),r==="postAction"&&n.reverse(),n.forEach(s=>{i=this._chainOrCall(i,()=>s.callback(s.hookedCommand,this))}),i}_chainOrCallSubCommandHook(t,r,i){let n=t;return this._lifeCycleHooks[i]!==void 0&&this._lifeCycleHooks[i].forEach(s=>{n=this._chainOrCall(n,()=>s(this,r))}),n}_parseCommand(t,r){let i=this.parseOptions(r);if(this._parseOptionsEnv(),this._parseOptionsImplied(),t=t.concat(i.operands),r=i.unknown,this.args=t.concat(r),t&&this._findCommand(t[0]))return this._dispatchSubcommand(t[0],t.slice(1),r);if(this._getHelpCommand()&&t[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(t[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(r),this._dispatchSubcommand(this._defaultCommandName,t,r);this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName&&this.help({error:!0}),this._outputHelpIfRequested(i.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let n=()=>{i.unknown.length>0&&this.unknownOption(i.unknown[0])},s=`command:${this.name()}`;if(this._actionHandler){n(),this._processArguments();let o;return o=this._chainOrCallHooks(o,"preAction"),o=this._chainOrCall(o,()=>this._actionHandler(this.processedArgs)),this.parent&&(o=this._chainOrCall(o,()=>{this.parent.emit(s,t,r)})),o=this._chainOrCallHooks(o,"postAction"),o}if(this.parent?.listenerCount(s))n(),this._processArguments(),this.parent.emit(s,t,r);else if(t.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",t,r);this.listenerCount("command:*")?this.emit("command:*",t,r):this.commands.length?this.unknownCommand():(n(),this._processArguments())}else this.commands.length?(n(),this.help({error:!0})):(n(),this._processArguments())}_findCommand(t){if(t)return this.commands.find(r=>r._name===t||r._aliases.includes(t))}_findOption(t){return this.options.find(r=>r.is(t))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(t=>{t.options.forEach(r=>{r.mandatory&&t.getOptionValue(r.attributeName())===void 0&&t.missingMandatoryOptionValue(r)})})}_checkForConflictingLocalOptions(){let t=this.options.filter(i=>{let n=i.attributeName();return this.getOptionValue(n)===void 0?!1:this.getOptionValueSource(n)!=="default"});t.filter(i=>i.conflictsWith.length>0).forEach(i=>{let n=t.find(s=>i.conflictsWith.includes(s.attributeName()));n&&this._conflictingOption(i,n)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(t=>{t._checkForConflictingLocalOptions()})}parseOptions(t){let r=[],i=[],n=r;function s(p){return p.length>1&&p[0]==="-"}let o=p=>/^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/.test(p)?!this._getCommandAndAncestors().some(u=>u.options.map(l=>l.short).some(l=>/^-\d$/.test(l))):!1,a=null,c=null,d=0;for(;d<t.length||c;){let p=c??t[d++];if(c=null,p==="--"){n===i&&n.push(p),n.push(...t.slice(d));break}if(a&&(!s(p)||o(p))){this.emit(`option:${a.name()}`,p);continue}if(a=null,s(p)){let u=this._findOption(p);if(u){if(u.required){let l=t[d++];l===void 0&&this.optionMissingArgument(u),this.emit(`option:${u.name()}`,l)}else if(u.optional){let l=null;d<t.length&&(!s(t[d])||o(t[d]))&&(l=t[d++]),this.emit(`option:${u.name()}`,l)}else this.emit(`option:${u.name()}`);a=u.variadic?u:null;continue}}if(p.length>2&&p[0]==="-"&&p[1]!=="-"){let u=this._findOption(`-${p[1]}`);if(u){u.required||u.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${u.name()}`,p.slice(2)):(this.emit(`option:${u.name()}`),c=`-${p.slice(2)}`);continue}}if(/^--[^=]+=/.test(p)){let u=p.indexOf("="),l=this._findOption(p.slice(0,u));if(l&&(l.required||l.optional)){this.emit(`option:${l.name()}`,p.slice(u+1));continue}}if(n===r&&s(p)&&!(this.commands.length===0&&o(p))&&(n=i),(this._enablePositionalOptions||this._passThroughOptions)&&r.length===0&&i.length===0){if(this._findCommand(p)){r.push(p),i.push(...t.slice(d));break}else if(this._getHelpCommand()&&p===this._getHelpCommand().name()){r.push(p,...t.slice(d));break}else if(this._defaultCommandName){i.push(p,...t.slice(d));break}}if(this._passThroughOptions){n.push(p,...t.slice(d));break}n.push(p)}return{operands:r,unknown:i}}opts(){if(this._storeOptionsAsProperties){let t={},r=this.options.length;for(let i=0;i<r;i++){let n=this.options[i].attributeName();t[n]=n===this._versionOptionName?this._version:this[n]}return t}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((t,r)=>Object.assign(t,r.opts()),{})}error(t,r){this._outputConfiguration.outputError(`${t}
|
|
24
24
|
`,this._outputConfiguration.writeErr),typeof this._showHelpAfterError=="string"?this._outputConfiguration.writeErr(`${this._showHelpAfterError}
|
|
25
25
|
`):this._showHelpAfterError&&(this._outputConfiguration.writeErr(`
|
|
26
|
-
`),this.outputHelp({error:!0}));let
|
|
27
|
-
`),this._exit(0,"commander.version",t)}),this}description(t,r){return t===void 0&&r===void 0?this._description:(this._description=t,r&&(this._argsDescription=r),this)}summary(t){return t===void 0?this._summary:(this._summary=t,this)}alias(t){if(t===void 0)return this._aliases[0];let r=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(r=this.commands[this.commands.length-1]),t===r._name)throw new Error("Command alias can't be the same as its name");let
|
|
28
|
-
Expecting one of '${
|
|
29
|
-
`)}),this}_outputHelpIfRequested(t){let r=this._getHelpOption();r&&t.find(o=>r.is(o))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function us(e){return e.map(t=>{if(!t.startsWith("--inspect"))return t;let r,n="127.0.0.1",o="9229",i;return(i=t.match(/^(--inspect(-brk)?)$/))!==null?r=i[1]:(i=t.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(r=i[1],/^\d+$/.test(i[3])?o=i[3]:n=i[3]):(i=t.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(r=i[1],n=i[3],o=i[4]),r&&o!=="0"?`${r}=${n}:${parseInt(o)+1}`:t})}function Vn(){if($.env.NO_COLOR||$.env.FORCE_COLOR==="0"||$.env.FORCE_COLOR==="false")return!1;if($.env.FORCE_COLOR||$.env.CLICOLOR_FORCE!==void 0)return!0}Wn.Command=Gn;Wn.useColor=Vn});var hs=S(oe=>{"use strict";var{Argument:ms}=Jt(),{Command:Hn}=ds(),{CommanderError:fp,InvalidArgumentError:ps}=wt(),{Help:hp}=Ln(),{Option:fs}=Nn();oe.program=new Hn;oe.createCommand=e=>new Hn(e);oe.createOption=(e,t)=>new fs(e,t);oe.createArgument=(e,t)=>new ms(e,t);oe.Command=Hn;oe.Option=fs;oe.Argument=ms;oe.Help=hp;oe.CommanderError=fp;oe.InvalidArgumentError=ps;oe.InvalidOptionArgumentError=ps});var ue=S((g_,zn)=>{"use strict";var Qt=process||{},ys=Qt.argv||[],Zt=Qt.env||{},gp=!(Zt.NO_COLOR||ys.includes("--no-color"))&&(!!Zt.FORCE_COLOR||ys.includes("--color")||Qt.platform==="win32"||(Qt.stdout||{}).isTTY&&Zt.TERM!=="dumb"||!!Zt.CI),bp=(e,t,r=e)=>n=>{let o=""+n,i=o.indexOf(t,e.length);return~i?e+yp(o,t,r,i)+t:e+o+t},yp=(e,t,r,n)=>{let o="",i=0;do o+=e.substring(i,n)+r,i=n+t.length,n=e.indexOf(t,i);while(~n);return o+e.substring(i)},xs=(e=gp)=>{let t=e?bp:()=>String;return{isColorSupported:e,reset:t("\x1B[0m","\x1B[0m"),bold:t("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:t("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:t("\x1B[3m","\x1B[23m"),underline:t("\x1B[4m","\x1B[24m"),inverse:t("\x1B[7m","\x1B[27m"),hidden:t("\x1B[8m","\x1B[28m"),strikethrough:t("\x1B[9m","\x1B[29m"),black:t("\x1B[30m","\x1B[39m"),red:t("\x1B[31m","\x1B[39m"),green:t("\x1B[32m","\x1B[39m"),yellow:t("\x1B[33m","\x1B[39m"),blue:t("\x1B[34m","\x1B[39m"),magenta:t("\x1B[35m","\x1B[39m"),cyan:t("\x1B[36m","\x1B[39m"),white:t("\x1B[37m","\x1B[39m"),gray:t("\x1B[90m","\x1B[39m"),bgBlack:t("\x1B[40m","\x1B[49m"),bgRed:t("\x1B[41m","\x1B[49m"),bgGreen:t("\x1B[42m","\x1B[49m"),bgYellow:t("\x1B[43m","\x1B[49m"),bgBlue:t("\x1B[44m","\x1B[49m"),bgMagenta:t("\x1B[45m","\x1B[49m"),bgCyan:t("\x1B[46m","\x1B[49m"),bgWhite:t("\x1B[47m","\x1B[49m"),blackBright:t("\x1B[90m","\x1B[39m"),redBright:t("\x1B[91m","\x1B[39m"),greenBright:t("\x1B[92m","\x1B[39m"),yellowBright:t("\x1B[93m","\x1B[39m"),blueBright:t("\x1B[94m","\x1B[39m"),magentaBright:t("\x1B[95m","\x1B[39m"),cyanBright:t("\x1B[96m","\x1B[39m"),whiteBright:t("\x1B[97m","\x1B[39m"),bgBlackBright:t("\x1B[100m","\x1B[49m"),bgRedBright:t("\x1B[101m","\x1B[49m"),bgGreenBright:t("\x1B[102m","\x1B[49m"),bgYellowBright:t("\x1B[103m","\x1B[49m"),bgBlueBright:t("\x1B[104m","\x1B[49m"),bgMagentaBright:t("\x1B[105m","\x1B[49m"),bgCyanBright:t("\x1B[106m","\x1B[49m"),bgWhiteBright:t("\x1B[107m","\x1B[49m")}};zn.exports=xs();zn.exports.createColors=xs});var Xn=S(($_,Ps)=>{"use strict";var Jn={to(e,t){return t?`\x1B[${t+1};${e+1}H`:`\x1B[${e+1}G`},move(e,t){let r="";return e<0?r+=`\x1B[${-e}D`:e>0&&(r+=`\x1B[${e}C`),t<0?r+=`\x1B[${-t}A`:t>0&&(r+=`\x1B[${t}B`),r},up:(e=1)=>`\x1B[${e}A`,down:(e=1)=>`\x1B[${e}B`,forward:(e=1)=>`\x1B[${e}C`,backward:(e=1)=>`\x1B[${e}D`,nextLine:(e=1)=>"\x1B[E".repeat(e),prevLine:(e=1)=>"\x1B[F".repeat(e),left:"\x1B[G",hide:"\x1B[?25l",show:"\x1B[?25h",save:"\x1B7",restore:"\x1B8"},Rp={up:(e=1)=>"\x1B[S".repeat(e),down:(e=1)=>"\x1B[T".repeat(e)},Mp={screen:"\x1B[2J",up:(e=1)=>"\x1B[1J".repeat(e),down:(e=1)=>"\x1B[J".repeat(e),line:"\x1B[2K",lineEnd:"\x1B[K",lineStart:"\x1B[1K",lines(e){let t="";for(let r=0;r<e;r++)t+=this.line+(r<e-1?Jn.up():"");return e&&(t+=Jn.left),t}};Ps.exports={cursor:Jn,scroll:Rp,erase:Mp,beep:"\x07"}});var so=S(et=>{"use strict";Object.defineProperty(et,"__esModule",{value:!0});et.DEFAULT_COLOR_MAP=void 0;et.DEFAULT_COLOR_MAP={red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m",white_bold:"\x1B[01m",reset:"\x1B[0m"};var io=class{constructor(t=et.DEFAULT_COLOR_MAP){this.text="",this.colorMap=t}addCharsWithColor(t,r){let n=this.colorMap[t];this.text+=n!==void 0?`${n}${r}${this.colorMap.reset}`:r}renderConsole(){return this.text}};et.default=io});var $t=S(B=>{"use strict";Object.defineProperty(B,"__esModule",{value:!0});B.DEFAULT_HEADER_ALIGNMENT=B.DEFAULT_ROW_ALIGNMENT=B.DEFAULT_HEADER_FONT_COLOR=B.DEFAULT_ROW_FONT_COLOR=B.COLORS=B.ALIGNMENTS=B.DEFAULT_TABLE_STYLE=B.DEFAULT_ROW_SEPARATOR=B.DEFAULT_COLUMN_LEN=void 0;B.DEFAULT_COLUMN_LEN=20;B.DEFAULT_ROW_SEPARATOR=!1;B.DEFAULT_TABLE_STYLE={headerTop:{left:"\u250C",mid:"\u252C",right:"\u2510",other:"\u2500"},headerBottom:{left:"\u251C",mid:"\u253C",right:"\u2524",other:"\u2500"},tableBottom:{left:"\u2514",mid:"\u2534",right:"\u2518",other:"\u2500"},vertical:"\u2502",rowSeparator:{left:"\u251C",mid:"\u253C",right:"\u2524",other:"\u2500"}};B.ALIGNMENTS=["right","left","center"];B.COLORS=["red","green","yellow","white","blue","magenta","cyan","white_bold","reset"];B.DEFAULT_ROW_FONT_COLOR="white";B.DEFAULT_HEADER_FONT_COLOR="white_bold";B.DEFAULT_ROW_ALIGNMENT="right";B.DEFAULT_HEADER_ALIGNMENT="center"});var Ws=S(ao=>{"use strict";Object.defineProperty(ao,"__esModule",{value:!0});var nf=[{first:768,last:879},{first:1155,last:1158},{first:1160,last:1161},{first:1425,last:1469},{first:1471,last:1471},{first:1473,last:1474},{first:1476,last:1477},{first:1479,last:1479},{first:1536,last:1539},{first:1552,last:1557},{first:1611,last:1630},{first:1648,last:1648},{first:1750,last:1764},{first:1767,last:1768},{first:1770,last:1773},{first:1807,last:1807},{first:1809,last:1809},{first:1840,last:1866},{first:1958,last:1968},{first:2027,last:2035},{first:2305,last:2306},{first:2364,last:2364},{first:2369,last:2376},{first:2381,last:2381},{first:2385,last:2388},{first:2402,last:2403},{first:2433,last:2433},{first:2492,last:2492},{first:2497,last:2500},{first:2509,last:2509},{first:2530,last:2531},{first:2561,last:2562},{first:2620,last:2620},{first:2625,last:2626},{first:2631,last:2632},{first:2635,last:2637},{first:2672,last:2673},{first:2689,last:2690},{first:2748,last:2748},{first:2753,last:2757},{first:2759,last:2760},{first:2765,last:2765},{first:2786,last:2787},{first:2817,last:2817},{first:2876,last:2876},{first:2879,last:2879},{first:2881,last:2883},{first:2893,last:2893},{first:2902,last:2902},{first:2946,last:2946},{first:3008,last:3008},{first:3021,last:3021},{first:3134,last:3136},{first:3142,last:3144},{first:3146,last:3149},{first:3157,last:3158},{first:3260,last:3260},{first:3263,last:3263},{first:3270,last:3270},{first:3276,last:3277},{first:3298,last:3299},{first:3393,last:3395},{first:3405,last:3405},{first:3530,last:3530},{first:3538,last:3540},{first:3542,last:3542},{first:3633,last:3633},{first:3636,last:3642},{first:3655,last:3662},{first:3761,last:3761},{first:3764,last:3769},{first:3771,last:3772},{first:3784,last:3789},{first:3864,last:3865},{first:3893,last:3893},{first:3895,last:3895},{first:3897,last:3897},{first:3953,last:3966},{first:3968,last:3972},{first:3974,last:3975},{first:3984,last:3991},{first:3993,last:4028},{first:4038,last:4038},{first:4141,last:4144},{first:4146,last:4146},{first:4150,last:4151},{first:4153,last:4153},{first:4184,last:4185},{first:4448,last:4607},{first:4959,last:4959},{first:5906,last:5908},{first:5938,last:5940},{first:5970,last:5971},{first:6002,last:6003},{first:6068,last:6069},{first:6071,last:6077},{first:6086,last:6086},{first:6089,last:6099},{first:6109,last:6109},{first:6155,last:6157},{first:6313,last:6313},{first:6432,last:6434},{first:6439,last:6440},{first:6450,last:6450},{first:6457,last:6459},{first:6679,last:6680},{first:6912,last:6915},{first:6964,last:6964},{first:6966,last:6970},{first:6972,last:6972},{first:6978,last:6978},{first:7019,last:7027},{first:7616,last:7626},{first:7678,last:7679},{first:8203,last:8207},{first:8234,last:8238},{first:8288,last:8291},{first:8298,last:8303},{first:8400,last:8431},{first:12330,last:12335},{first:12441,last:12442},{first:43014,last:43014},{first:43019,last:43019},{first:43045,last:43046},{first:64286,last:64286},{first:65024,last:65039},{first:65056,last:65059},{first:65279,last:65279},{first:65529,last:65531},{first:68097,last:68099},{first:68101,last:68102},{first:68108,last:68111},{first:68152,last:68154},{first:68159,last:68159},{first:119143,last:119145},{first:119155,last:119170},{first:119173,last:119179},{first:119210,last:119213},{first:119362,last:119364},{first:917505,last:917505},{first:917536,last:917631},{first:917760,last:917999}];ao.default=nf});var Hs=S(co=>{"use strict";Object.defineProperty(co,"__esModule",{value:!0});var of=(e,t,r)=>{let n=0,o,i=r;if(e<t[0].first||e>t[i].last)return 0;for(;i>=n;)if(o=Math.floor((n+i)/2),e>t[o].last)n=o+1;else if(e<t[o].first)i=o-1;else return 1;return 0};co.default=of});var lo=S(Ct=>{"use strict";var qs=Ct&&Ct.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Ct,"__esModule",{value:!0});var zs=qs(Ws()),sf=qs(Hs()),af=e=>e===0?0:e<32||e>=127&&e<160?-1:(0,sf.default)(e,zs.default,zs.default.length-1)?0:1+ +(e>=4352&&(e<=4447||e===9001||e===9002||e>=11904&&e<=42191&&e!==12351||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65040&&e<=65049||e>=65072&&e<=65135||e>=65280&&e<=65376||e>=65504&&e<=65510||e>=131072&&e<=196605||e>=196608&&e<=262141));Ct.default=af});var Ys=S(Ot=>{"use strict";var cf=Ot&&Ot.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Ot,"__esModule",{value:!0});var lf=cf(lo()),uf=e=>{let t=0;for(let r=0;r<e.length;r++){let n=e.charCodeAt(r),o=(0,lf.default)(n);if(o<0)return-1;t+=o}return t};Ot.default=uf});var Js=S(ke=>{"use strict";var Ks=ke&&ke.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(ke,"__esModule",{value:!0});ke.wcswidth=ke.wcwidth=void 0;var df=Ks(Ys());ke.wcswidth=df.default;var mf=Ks(lo());ke.wcwidth=mf.default});var uo=S(He=>{"use strict";Object.defineProperty(He,"__esModule",{value:!0});He.findWidthInConsole=He.stripAnsi=void 0;var pf=Js(),ff=/\x1b\[\d{1,3}(;\d{1,3})*m/g,hf=e=>e.replace(ff,"");He.stripAnsi=hf;var gf=(e,t)=>{let r=0;return e=(0,He.stripAnsi)(e),t&&Object.entries(t).forEach(([n,o])=>{let i=new RegExp(n,"g");r+=(e.match(i)||[]).length*o,e=e.replace(n,"")}),r+=(0,pf.wcswidth)(e),r};He.findWidthInConsole=gf});var po=S(be=>{"use strict";Object.defineProperty(be,"__esModule",{value:!0});be.biggestWordInSentence=be.textWithPadding=be.splitTextIntoTextsOfMinLen=void 0;var mo=uo(),bf=(e,t,r)=>{let n=[];return e.split(/[\n\r]/).forEach(i=>{let s=i.split(" "),a=[],c=0;s.forEach(u=>{let l=(0,mo.findWidthInConsole)(u,r);c+l<=t?(c+=l+1,a.push(u)):(a.length>0&&n.push(a.join(" ")),a=[u],c=l+1)}),n.push(a.join(" "))}),n};be.splitTextIntoTextsOfMinLen=bf;var yf=(e,t,r,n)=>{let o=(0,mo.findWidthInConsole)(e,n),i=Math.floor((r-o)/2),s=r-i-o;if(r<o){let a=(0,be.splitTextIntoTextsOfMinLen)(e,r);return a.length===1?e:a.map(c=>(0,be.textWithPadding)(c,t,r,n)).join(`
|
|
30
|
-
`)}switch(t){case"left":return e.concat(" ".repeat(r-
|
|
31
|
-
`)};se.renderTable=Yf;var Kf=(e,t)=>{let r=new Uf.default(t);return r.addRows(e),(0,se.renderTable)(r)};se.renderSimpleTable=Kf;var Jf=(e,t)=>{console.log((0,se.renderSimpleTable)(e,t))};se.printSimpleTable=Jf});var bo=S(So=>{"use strict";Object.defineProperty(So,"__esModule",{value:!0});var Xf=so(),pr=$t(),yo=vt(),xo=Zs(),Zf=go(),Qf=()=>0,eh=()=>!0,wo=class{initSimple(t){this.columns=t.map(r=>({name:r,title:r,alignment:pr.DEFAULT_ROW_ALIGNMENT}))}initDetailed(t){var r;this.title=t?.title||this.title,this.tableStyle=Object.assign(Object.assign({},this.tableStyle),t?.style),this.sortFunction=t?.sort||this.sortFunction,this.filterFunction=t?.filter||this.filterFunction,this.enabledColumns=t?.enabledColumns||this.enabledColumns,this.disabledColumns=t?.disabledColumns||this.disabledColumns,this.computedColumns=t?.computedColumns||this.computedColumns,this.columns=((r=t?.columns)===null||r===void 0?void 0:r.map(n=>(0,xo.rawColumnToInternalColumn)(n,t?.defaultColumnOptions)))||this.columns,this.rowSeparator=t?.rowSeparator||this.rowSeparator,this.charLength=t?.charLength||this.charLength,this.defaultColumnOptions=t?.defaultColumnOptions||this.defaultColumnOptions,t?.shouldDisableColors?this.colorMap={}:t?.colorMap&&(this.colorMap=Object.assign(Object.assign({},this.colorMap),t.colorMap)),t.rows!==void 0&&this.addRows(t.rows)}constructor(t){this.rows=[],this.columns=[],this.title=void 0,this.tableStyle=pr.DEFAULT_TABLE_STYLE,this.filterFunction=eh,this.sortFunction=Qf,this.enabledColumns=[],this.disabledColumns=[],this.computedColumns=[],this.rowSeparator=pr.DEFAULT_ROW_SEPARATOR,this.colorMap=Xf.DEFAULT_COLOR_MAP,this.charLength={},this.defaultColumnOptions=void 0,this.transforms={},t instanceof Array?this.initSimple(t):typeof t=="object"&&this.initDetailed(t)}createColumnFromRow(t){let r=this.columns.map(n=>n.name);Object.keys(t).forEach(n=>{r.includes(n)||this.columns.push((0,xo.rawColumnToInternalColumn)((0,yo.createColumFromOnlyName)(n),this.defaultColumnOptions))})}addColumn(t){let r=typeof t=="string"?(0,yo.createColumFromOnlyName)(t):t;this.columns.push((0,xo.rawColumnToInternalColumn)(r,this.defaultColumnOptions))}addColumns(t){t.forEach(r=>{this.addColumn(r)})}addRow(t,r){this.createColumnFromRow(t),this.rows.push((0,yo.createRow)(r?.color||pr.DEFAULT_ROW_FONT_COLOR,t,r?.separator!==void 0?r?.separator:this.rowSeparator))}addRows(t,r){t.forEach(n=>{this.addRow(n,r)})}renderTable(){return(0,Zf.renderTable)(this)}};So.default=wo});var sa=S(Tt=>{"use strict";var th=Tt&&Tt.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Tt,"__esModule",{value:!0});var rh=th(bo()),ia=vt(),_o=class{constructor(t){this.table=new rh.default(t)}addColumn(t){return this.table.addColumn(t),this}addColumns(t){return this.table.addColumns(t),this}addRow(t,r){return this.table.addRow(t,(0,ia.convertRawRowOptionsToStandard)(r)),this}addRows(t,r){return this.table.addRows(t,(0,ia.convertRawRowOptionsToStandard)(r)),this}printTable(){let t=this.table.renderTable();console.log(t)}render(){return this.table.renderTable()}};Tt.default=_o});var ca=S(ye=>{"use strict";var nh=ye&&ye.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(ye,"__esModule",{value:!0});ye.renderTable=ye.printTable=ye.Table=void 0;var oh=nh(sa());ye.Table=oh.default;var aa=go();Object.defineProperty(ye,"printTable",{enumerable:!0,get:function(){return aa.printSimpleTable}});Object.defineProperty(ye,"renderTable",{enumerable:!0,get:function(){return aa.renderSimpleTable}})});var Ba=S((dC,Ua)=>{"use strict";Ua.exports=Na;Na.sync=sg;var Fa=ee("fs");function ig(e,t){var r=t.pathExt!==void 0?t.pathExt:process.env.PATHEXT;if(!r||(r=r.split(";"),r.indexOf("")!==-1))return!0;for(var n=0;n<r.length;n++){var o=r[n].toLowerCase();if(o&&e.substr(-o.length).toLowerCase()===o)return!0}return!1}function ja(e,t,r){return!e.isSymbolicLink()&&!e.isFile()?!1:ig(t,r)}function Na(e,t,r){Fa.stat(e,function(n,o){r(n,n?!1:ja(o,e,t))})}function sg(e,t){return ja(Fa.statSync(e),e,t)}});var za=S((mC,Ha)=>{"use strict";Ha.exports=Va;Va.sync=ag;var Ga=ee("fs");function Va(e,t,r){Ga.stat(e,function(n,o){r(n,n?!1:Wa(o,t))})}function ag(e,t){return Wa(Ga.statSync(e),t)}function Wa(e,t){return e.isFile()&&cg(e,t)}function cg(e,t){var r=e.mode,n=e.uid,o=e.gid,i=t.uid!==void 0?t.uid:process.getuid&&process.getuid(),s=t.gid!==void 0?t.gid:process.getgid&&process.getgid(),a=parseInt("100",8),c=parseInt("010",8),u=parseInt("001",8),l=a|c,d=r&u||r&c&&o===s||r&a&&n===i||r&l&&i===0;return d}});var Ya=S((fC,qa)=>{"use strict";var pC=ee("fs"),Tr;process.platform==="win32"||global.TESTING_WINDOWS?Tr=Ba():Tr=za();qa.exports=Po;Po.sync=lg;function Po(e,t,r){if(typeof t=="function"&&(r=t,t={}),!r){if(typeof Promise!="function")throw new TypeError("callback not provided");return new Promise(function(n,o){Po(e,t||{},function(i,s){i?o(i):n(s)})})}Tr(e,t||{},function(n,o){n&&(n.code==="EACCES"||t&&t.ignoreErrors)&&(n=null,o=!1),r(n,o)})}function lg(e,t){try{return Tr.sync(e,t||{})}catch(r){if(t&&t.ignoreErrors||r.code==="EACCES")return!1;throw r}}});var tc=S((hC,ec)=>{"use strict";var at=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",Ka=ee("path"),ug=at?";":":",Ja=Ya(),Xa=e=>Object.assign(new Error(`not found: ${e}`),{code:"ENOENT"}),Za=(e,t)=>{let r=t.colon||ug,n=e.match(/\//)||at&&e.match(/\\/)?[""]:[...at?[process.cwd()]:[],...(t.path||process.env.PATH||"").split(r)],o=at?t.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",i=at?o.split(r):[""];return at&&e.indexOf(".")!==-1&&i[0]!==""&&i.unshift(""),{pathEnv:n,pathExt:i,pathExtExe:o}},Qa=(e,t,r)=>{typeof t=="function"&&(r=t,t={}),t||(t={});let{pathEnv:n,pathExt:o,pathExtExe:i}=Za(e,t),s=[],a=u=>new Promise((l,d)=>{if(u===n.length)return t.all&&s.length?l(s):d(Xa(e));let m=n[u],p=/^".*"$/.test(m)?m.slice(1,-1):m,f=Ka.join(p,e),g=!p&&/^\.[\\\/]/.test(e)?e.slice(0,2)+f:f;l(c(g,u,0))}),c=(u,l,d)=>new Promise((m,p)=>{if(d===o.length)return m(a(l+1));let f=o[d];Ja(u+f,{pathExt:i},(g,w)=>{if(!g&&w)if(t.all)s.push(u+f);else return m(u+f);return m(c(u,l,d+1))})});return r?a(0).then(u=>r(null,u),r):a(0)},dg=(e,t)=>{t=t||{};let{pathEnv:r,pathExt:n,pathExtExe:o}=Za(e,t),i=[];for(let s=0;s<r.length;s++){let a=r[s],c=/^".*"$/.test(a)?a.slice(1,-1):a,u=Ka.join(c,e),l=!c&&/^\.[\\\/]/.test(e)?e.slice(0,2)+u:u;for(let d=0;d<n.length;d++){let m=l+n[d];try{if(Ja.sync(m,{pathExt:o}))if(t.all)i.push(m);else return m}catch{}}}if(t.all&&i.length)return i;if(t.nothrow)return null;throw Xa(e)};ec.exports=Qa;Qa.sync=dg});var nc=S((gC,Lo)=>{"use strict";var rc=(e={})=>{let t=e.env||process.env;return(e.platform||process.platform)!=="win32"?"PATH":Object.keys(t).reverse().find(n=>n.toUpperCase()==="PATH")||"Path"};Lo.exports=rc;Lo.exports.default=rc});var ac=S((bC,sc)=>{"use strict";var oc=ee("path"),mg=tc(),pg=nc();function ic(e,t){let r=e.options.env||process.env,n=process.cwd(),o=e.options.cwd!=null,i=o&&process.chdir!==void 0&&!process.chdir.disabled;if(i)try{process.chdir(e.options.cwd)}catch{}let s;try{s=mg.sync(e.command,{path:r[pg({env:r})],pathExt:t?oc.delimiter:void 0})}catch{}finally{i&&process.chdir(n)}return s&&(s=oc.resolve(o?e.options.cwd:"",s)),s}function fg(e){return ic(e)||ic(e,!0)}sc.exports=fg});var cc=S((yC,Fo)=>{"use strict";var ko=/([()\][%!^"`<>&|;, *?])/g;function hg(e){return e=e.replace(ko,"^$1"),e}function gg(e,t){return e=`${e}`,e=e.replace(/(?=(\\+?)?)\1"/g,'$1$1\\"'),e=e.replace(/(?=(\\+?)?)\1$/,"$1$1"),e=`"${e}"`,e=e.replace(ko,"^$1"),t&&(e=e.replace(ko,"^$1")),e}Fo.exports.command=hg;Fo.exports.argument=gg});var uc=S((xC,lc)=>{"use strict";lc.exports=/^#!(.*)/});var mc=S((wC,dc)=>{"use strict";var bg=uc();dc.exports=(e="")=>{let t=e.match(bg);if(!t)return null;let[r,n]=t[0].replace(/#! ?/,"").split(" "),o=r.split("/").pop();return o==="env"?n:n?`${o} ${n}`:o}});var fc=S((SC,pc)=>{"use strict";var jo=ee("fs"),yg=mc();function xg(e){let r=Buffer.alloc(150),n;try{n=jo.openSync(e,"r"),jo.readSync(n,r,0,150,0),jo.closeSync(n)}catch{}return yg(r.toString())}pc.exports=xg});var yc=S((_C,bc)=>{"use strict";var wg=ee("path"),hc=ac(),gc=cc(),Sg=fc(),_g=process.platform==="win32",Eg=/\.(?:com|exe)$/i,$g=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function Cg(e){e.file=hc(e);let t=e.file&&Sg(e.file);return t?(e.args.unshift(e.file),e.command=t,hc(e)):e.file}function Og(e){if(!_g)return e;let t=Cg(e),r=!Eg.test(t);if(e.options.forceShell||r){let n=$g.test(t);e.command=wg.normalize(e.command),e.command=gc.command(e.command),e.args=e.args.map(i=>gc.argument(i,n));let o=[e.command].concat(e.args).join(" ");e.args=["/d","/s","/c",`"${o}"`],e.command=process.env.comspec||"cmd.exe",e.options.windowsVerbatimArguments=!0}return e}function vg(e,t,r){t&&!Array.isArray(t)&&(r=t,t=null),t=t?t.slice(0):[],r=Object.assign({},r);let n={command:e,args:t,options:r,file:void 0,original:{command:e,args:t}};return r.shell?n:Og(n)}bc.exports=vg});var Sc=S((EC,wc)=>{"use strict";var No=process.platform==="win32";function Uo(e,t){return Object.assign(new Error(`${t} ${e.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${t} ${e.command}`,path:e.command,spawnargs:e.args})}function Tg(e,t){if(!No)return;let r=e.emit;e.emit=function(n,o){if(n==="exit"){let i=xc(o,t);if(i)return r.call(e,"error",i)}return r.apply(e,arguments)}}function xc(e,t){return No&&e===1&&!t.file?Uo(t.original,"spawn"):null}function Ag(e,t){return No&&e===1&&!t.file?Uo(t.original,"spawnSync"):null}wc.exports={hookChildProcess:Tg,verifyENOENT:xc,verifyENOENTSync:Ag,notFoundError:Uo}});var $c=S(($C,ct)=>{"use strict";var _c=ee("child_process"),Bo=yc(),Go=Sc();function Ec(e,t,r){let n=Bo(e,t,r),o=_c.spawn(n.command,n.args,n.options);return Go.hookChildProcess(o,n),o}function Ig(e,t,r){let n=Bo(e,t,r),o=_c.spawnSync(n.command,n.args,n.options);return o.error=o.error||Go.verifyENOENTSync(o.status,n),o}ct.exports=Ec;ct.exports.spawn=Ec;ct.exports.sync=Ig;ct.exports._parse=Bo;ct.exports._enoent=Go});var gs=q(hs(),1),{program:i_,createCommand:s_,createArgument:a_,createOption:c_,CommanderError:l_,InvalidArgumentError:u_,InvalidOptionArgumentError:d_,Command:bs,Argument:m_,Option:p_,Help:f_}=gs.default;var zm=q(ue(),1);import{styleText as Zn}from"util";import{stdout as eo,stdin as ks}from"process";import*as Pe from"readline";import Pp from"readline";var ws=(()=>{let e=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return t=>{let r=0;for(e.lastIndex=0;e.test(t);)r+=1;return t.length-r}})(),Ss=e=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,_s=e=>e===8987||e===9001||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12441&&e<=12543||e>=12549&&e<=12591||e>=12593&&e<=12686||e>=12688&&e<=12771||e>=12783&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=19903||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e>=131072&&e<=196605||e>=196608&&e<=262141;var xp=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,wp=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,Es=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu,Sp=/\t{1,1000}/y,$s=new RegExp("[\\u{1F1E6}-\\u{1F1FF}]{2}|\\u{1F3F4}[\\u{E0061}-\\u{E007A}]{2}[\\u{E0030}-\\u{E0039}\\u{E0061}-\\u{E007A}]{1,3}\\u{E007F}|(?:\\p{Emoji}\\uFE0F\\u20E3?|\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|\\p{Emoji_Presentation})(?:\\u200D(?:\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|\\p{Emoji_Presentation}|\\p{Emoji}\\uFE0F\\u20E3?))*","yu"),_p=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,Ep=new RegExp("\\p{M}+","gu"),$p={limit:1/0,ellipsis:""},Cs=(e,t={},r={})=>{let n=t.limit??1/0,o=t.ellipsis??"",i=t?.ellipsisWidth??(o?Cs(o,$p,r).width:0),s=0,a=r.controlWidth??0,c=r.tabWidth??8,u=r.emojiWidth??2,l=2,d=r.regularWidth??1,m=r.wideWidth??l,p=[[_p,d],[xp,s],[wp,a],[Sp,c],[$s,u],[Es,m]],f=0,g=0,w=e.length,x=0,C=!1,v=w,A=Math.max(0,n-i),E=0,R=0,M=0,L=0;e:for(;;){if(R>E||g>=w&&g>f){let k=e.slice(E,R)||e.slice(f,g);x=0;for(let Q of k.replaceAll(Ep,"")){let N=Q.codePointAt(0)||0;if(Ss(N)?L=l:_s(N)?L=m:L=d,M+L>A&&(v=Math.min(v,Math.max(E,f)+x)),M+L>n){C=!0;break e}x+=Q.length,M+=L}E=R=0}if(g>=w)break e;for(let k=0,Q=p.length;k<Q;k++){let[N,qt]=p[k];if(N.lastIndex=g,N.test(e)){if(x=N===Es?ws(e.slice(g,N.lastIndex)):N===$s?1:N.lastIndex-g,L=x*qt,M+L>A&&(v=Math.min(v,g+Math.floor((A-M)/qt))),M+L>n){C=!0;break e}M+=L,E=f,R=g,g=f=N.lastIndex;continue e}}g+=1}return{width:C?A:M,index:C?v:w,truncated:C,ellipsed:C&&n>=i}},Os=Cs;var Cp={limit:1/0,ellipsis:"",ellipsisWidth:0},Op=(e,t={})=>Os(e,Cp,t).width,Y=Op;var er="\x1B",Ds="\x9B",vp=39,Yn="\x07",Rs="[",Tp="]",Ms="m",Kn=`${Tp}8;;`,vs=new RegExp(`(?:\\${Rs}(?<code>\\d+)m|\\${Kn}(?<uri>.*)${Yn})`,"y"),Ts=e=>{if(e>=30&&e<=37||e>=90&&e<=97)return 39;if(e>=40&&e<=47||e>=100&&e<=107)return 49;if(e===1||e===2)return 22;if(e===3)return 23;if(e===4)return 24;if(e===7)return 27;if(e===8)return 28;if(e===9)return 29;if(e===0)return 0},As=e=>`${er}${Rs}${e}${Ms}`,Is=e=>`${er}${Kn}${e}${Yn}`,qn=(e,t,r)=>{let n=t[Symbol.iterator](),o=!1,i=!1,s=e.at(-1),a=s===void 0?0:Y(s),c=n.next(),u=n.next(),l=0;for(;!c.done;){let d=c.value,m=Y(d);a+m<=r?e[e.length-1]+=d:(e.push(d),a=0),(d===er||d===Ds)&&(o=!0,i=t.startsWith(Kn,l+1)),o?i?d===Yn&&(o=!1,i=!1):d===Ms&&(o=!1):(a+=m,a===r&&!u.done&&(e.push(""),a=0)),c=u,u=n.next(),l+=d.length}s=e.at(-1),!a&&s!==void 0&&s.length&&e.length>1&&(e[e.length-2]+=e.pop())},Ap=e=>{let t=e.split(" "),r=t.length;for(;r&&!Y(t[r-1]);)r--;return r===t.length?e:t.slice(0,r).join(" ")+t.slice(r).join("")},Ip=(e,t,r={})=>{if(r.trim!==!1&&e.trim()==="")return"";let n="",o,i,s=e.split(" "),a=[""],c=0;for(let d=0;d<s.length;d++){let m=s[d];if(r.trim!==!1){let f=a.at(-1)??"",g=f.trimStart();f.length!==g.length&&(a[a.length-1]=g,c=Y(g))}d!==0&&(c>=t&&(r.wordWrap===!1||r.trim===!1)&&(a.push(""),c=0),(c||r.trim===!1)&&(a[a.length-1]+=" ",c++));let p=Y(m);if(r.hard&&p>t){let f=t-c,g=1+Math.floor((p-f-1)/t);Math.floor((p-1)/t)<g&&a.push(""),qn(a,m,t),c=Y(a.at(-1)??"");continue}if(c+p>t&&c&&p){if(r.wordWrap===!1&&c<t){qn(a,m,t),c=Y(a.at(-1)??"");continue}a.push(""),c=0}if(c+p>t&&r.wordWrap===!1){qn(a,m,t),c=Y(a.at(-1)??"");continue}a[a.length-1]+=m,c+=p}r.trim!==!1&&(a=a.map(d=>Ap(d)));let u=a.join(`
|
|
32
|
-
`)
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
`)
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
`).map(
|
|
39
|
-
`)
|
|
40
|
-
`),tr(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let e=ge(this._prevFrame,process.stdout.columns,{hard:!0,trim:!1}).split(`
|
|
41
|
-
`).length-1;this.output.write(z.cursor.move(-999,e*-1))}render(){let e=ge(this._render(this)??"",process.stdout.columns,{hard:!0,trim:!1});if(e!==this._prevFrame){if(this.state==="initial")this.output.write(z.cursor.hide);else{let t=Fp(this._prevFrame,e),r=ro(this.output);if(this.restoreCursor(),t){let n=Math.max(0,t.numLinesAfter-r),o=Math.max(0,t.numLinesBefore-r),i=t.lines.find(s=>s>=n);if(i===void 0){this._prevFrame=e;return}if(t.lines.length===1){this.output.write(z.cursor.move(0,i-o)),this.output.write(z.erase.lines(1));let s=e.split(`
|
|
42
|
-
`);this.output.write(s[i]),this._prevFrame=e,this.output.write(z.cursor.move(0,s.length-i-1));return}else if(t.lines.length>1){if(n<o)i=n;else{let a=i-o;a>0&&this.output.write(z.cursor.move(0,a))}this.output.write(z.erase.down());let s=e.split(`
|
|
43
|
-
`).slice(i);this.output.write(s.join(`
|
|
44
|
-
`)),this._prevFrame=e;return}}this.output.write(z.erase.down())}this.output.write(e),this.state==="initial"&&(this.state="active"),this._prevFrame=e}}};var nr=class extends ar{get cursor(){return this.value?0:1}get _value(){return this.cursor===0}constructor(t){super(t,!1),this.value=!!t.initialValue,this.on("userInput",()=>{this.value=this._value}),this.on("confirm",r=>{this.output.write(z.cursor.move(0,-1)),this.value=r,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}};var or=class extends ar{_mask="\u2022";get cursor(){return this._cursor}get masked(){return this.userInput.replaceAll(/./g,this._mask)}get userInputWithCursor(){if(this.state==="submit"||this.state==="cancel")return this.masked;let t=this.userInput;if(this.cursor>=t.length)return`${this.masked}${Zn(["inverse","hidden"],"_")}`;let r=this.masked,n=r.slice(0,this.cursor),o=r.slice(this.cursor);return`${n}${Zn("inverse",o[0])}${o.slice(1)}`}clear(){this._clearUserInput()}constructor({mask:t,...r}){super(r),this._mask=t??"\u2022",this.on("userInput",n=>{this._setValue(n)})}},ir=class extends ar{options;cursor=0;get _selectedValue(){return this.options[this.cursor]}changeValue(){this.value=this._selectedValue.value}constructor(t){super(t,!1),this.options=t.options;let r=this.options.findIndex(({value:o})=>o===t.initialValue),n=r===-1?0:r;this.cursor=this.options[n].disabled?rr(n,1,this.options):n,this.changeValue(),this.on("cursor",o=>{switch(o){case"left":case"up":this.cursor=rr(this.cursor,-1,this.options);break;case"down":case"right":this.cursor=rr(this.cursor,1,this.options);break}this.changeValue()})}};var sr=class extends ar{get userInputWithCursor(){if(this.state==="submit")return this.userInput;let t=this.userInput;if(this.cursor>=t.length)return`${this.userInput}\u2588`;let r=t.slice(0,this.cursor),[n,...o]=t.slice(this.cursor);return`${r}${Zn("inverse",n)}${o.join("")}`}get cursor(){return this._cursor}constructor(t){super({...t,initialUserInput:t.initialUserInput??t.initialValue}),this.on("userInput",r=>{this._setValue(r)}),this.on("finalize",()=>{this.value||(this.value=t.defaultValue),this.value===void 0&&(this.value="")})}};import{styleText as h,stripVTControlCharacters as B_}from"util";import ie from"process";var Et=q(Xn(),1);import{existsSync as z_,lstatSync as q_,readdirSync as Y_}from"fs";import{dirname as J_,join as X_}from"path";function Np(){return ie.platform!=="win32"?ie.env.TERM!=="linux":!!ie.env.CI||!!ie.env.WT_SESSION||!!ie.env.TERMINUS_SUBLIME||ie.env.ConEmuTask==="{cmd::Cmder}"||ie.env.TERM_PROGRAM==="Terminus-Sublime"||ie.env.TERM_PROGRAM==="vscode"||ie.env.TERM==="xterm-256color"||ie.env.TERM==="alacritty"||ie.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var no=Np(),Up=()=>process.env.CI==="true";var T=(e,t)=>no?e:t,Bp=T("\u25C6","*"),Ns=T("\u25A0","x"),Us=T("\u25B2","x"),ur=T("\u25C7","o"),Z_=T("\u250C","T"),_=T("\u2502","|"),Le=T("\u2514","\u2014"),Q_=T("\u2510","T"),eE=T("\u2518","\u2014"),oo=T("\u25CF",">"),lr=T("\u25CB"," "),tE=T("\u25FB","[\u2022]"),rE=T("\u25FC","[+]"),nE=T("\u25FB","[ ]"),Gp=T("\u25AA","\u2022"),js=T("\u2500","-"),Vp=T("\u256E","+"),Wp=T("\u251C","+"),Hp=T("\u256F","+"),zp=T("\u2570","+"),oE=T("\u256D","+"),qp=T("\u25CF","\u2022"),Yp=T("\u25C6","*"),Kp=T("\u25B2","!"),Jp=T("\u25A0","x"),dr=e=>{switch(e){case"initial":case"active":return h("cyan",Bp);case"cancel":return h("red",Ns);case"error":return h("yellow",Us);case"submit":return h("green",ur)}},Xp=e=>{switch(e){case"initial":case"active":return h("cyan",_);case"cancel":return h("red",_);case"error":return h("yellow",_);case"submit":return h("green",_)}},Zp=(e,t,r,n,o)=>{let i=t,s=0;for(let a=r;a<n;a++){let c=e[a];if(i=i-c.length,s++,i<=o)break}return{lineCount:i,removals:s}},Qp=({cursor:e,options:t,style:r,output:n=process.stdout,maxItems:o=Number.POSITIVE_INFINITY,columnPadding:i=0,rowPadding:s=4})=>{let a=St(n)-i,c=ro(n),u=h("dim","..."),l=Math.max(c-s,0),d=Math.max(Math.min(o,l),5),m=0;e>=d-3&&(m=Math.max(Math.min(e-d+3,t.length-d),0));let p=d<t.length&&m>0,f=d<t.length&&m+d<t.length,g=Math.min(m+d,t.length),w=[],x=0;p&&x++,f&&x++;let C=m+(p?1:0),v=g-(f?1:0);for(let E=C;E<v;E++){let R=ge(r(t[E],E===e),a,{hard:!0,trim:!1}).split(`
|
|
45
|
-
`);w.push(R),x+=R.length}if(x>l){let E=0,R=0,M=x,L=e-C,k=(Q,N)=>Zp(w,M,Q,N,l);p?({lineCount:M,removals:E}=k(0,L),M>l&&({lineCount:M,removals:R}=k(L+1,w.length))):({lineCount:M,removals:R}=k(L+1,w.length),M>l&&({lineCount:M,removals:E}=k(0,L))),E>0&&(p=!0,w.splice(0,E)),R>0&&(f=!0,w.splice(w.length-R,R))}let A=[];p&&A.push(u);for(let E of w)for(let R of E)A.push(R);return f&&A.push(u),A};var We=e=>{let t=e.active??"Yes",r=e.inactive??"No";return new nr({active:t,inactive:r,signal:e.signal,input:e.input,output:e.output,initialValue:e.initialValue??!0,render(){let n=e.withGuide??H.withGuide,o=`${dr(this.state)} `,i=n?`${h("gray",_)} `:"",s=_t(e.output,e.message,i,o),a=`${n?`${h("gray",_)}
|
|
46
|
-
`:""}${s}
|
|
47
|
-
`,c=this.value?t:r;switch(this.state){case"submit":{let u=n?`${h("gray",_)} `:"";return`${a}${u}${h("dim",c)}`}case"cancel":{let u=n?`${h("gray",_)} `:"";return`${a}${u}${h(["strikethrough","dim"],c)}${n?`
|
|
48
|
-
${h("gray",_)}`:""}`}default:{let u=n?`${h("cyan",_)} `:"",l=n?h("cyan",Le):"";return`${a}${u}${this.value?`${h("green",oo)} ${t}`:`${h("dim",lr)} ${h("dim",t)}`}${e.vertical?n?`
|
|
49
|
-
${h("cyan",_)} `:`
|
|
50
|
-
`:` ${h("dim","/")} `}${this.value?`${h("dim",lr)} ${h("dim",r)}`:`${h("green",oo)} ${r}`}
|
|
51
|
-
${l}
|
|
52
|
-
`}}}}).prompt()};var I={message:(e=[],{symbol:t=h("gray",_),secondarySymbol:r=h("gray",_),output:n=process.stdout,spacing:o=1,withGuide:i}={})=>{let s=[],a=i??H.withGuide,c=a?r:"",u=a?`${t} `:"",l=a?`${r} `:"";for(let m=0;m<o;m++)s.push(c);let d=Array.isArray(e)?e:e.split(`
|
|
53
|
-
`);if(d.length>0){let[m,...p]=d;m.length>0?s.push(`${u}${m}`):s.push(a?t:"");for(let f of p)f.length>0?s.push(`${l}${f}`):s.push(a?r:"")}n.write(`${s.join(`
|
|
54
|
-
`)}
|
|
55
|
-
`)},info:(e,t)=>{I.message(e,{...t,symbol:h("blue",qp)})},success:(e,t)=>{I.message(e,{...t,symbol:h("green",Yp)})},step:(e,t)=>{I.message(e,{...t,symbol:h("green",ur)})},warn:(e,t)=>{I.message(e,{...t,symbol:h("yellow",Kp)})},warning:(e,t)=>{I.warn(e,t)},error:(e,t)=>{I.message(e,{...t,symbol:h("red",Jp)})}},G=(e="",t)=>{let r=t?.output??process.stdout,n=t?.withGuide??H.withGuide?`${h("gray",Le)} `:"";r.write(`${n}${h("red",e)}
|
|
56
|
-
|
|
57
|
-
`)};var Bs=(e="",t)=>{let r=t?.output??process.stdout,n=t?.withGuide??H.withGuide?`${h("gray",_)}
|
|
58
|
-
${h("gray",Le)} `:"";r.write(`${n}${e}
|
|
59
|
-
|
|
60
|
-
`)};var ef=e=>h("dim",e),tf=(e,t,r)=>{let n={hard:!0,trim:!1},o=ge(e,t,n).split(`
|
|
61
|
-
`),i=o.reduce((c,u)=>Math.max(Y(u),c),0),s=o.map(r).reduce((c,u)=>Math.max(Y(u),c),0),a=t-(s-i);return ge(e,a,n)},Z=(e="",t="",r)=>{let n=r?.output??ie.stdout,o=r?.withGuide??H.withGuide,i=r?.format??ef,s=["",...tf(e,St(n)-6,i).split(`
|
|
62
|
-
`).map(i),""],a=Y(t),c=Math.max(s.reduce((m,p)=>{let f=Y(p);return f>m?f:m},0),a)+2,u=s.map(m=>`${h("gray",_)} ${m}${" ".repeat(c-Y(m))}${h("gray",_)}`).join(`
|
|
63
|
-
`),l=o?`${h("gray",_)}
|
|
64
|
-
`:"",d=o?Wp:zp;n.write(`${l}${h("green",ur)} ${h("reset",t)} ${h("gray",js.repeat(Math.max(c-a-1,1))+Vp)}
|
|
65
|
-
${u}
|
|
66
|
-
${h("gray",d+js.repeat(c+2)+Hp)}
|
|
67
|
-
`)},Gs=e=>new or({validate:e.validate,mask:e.mask??Gp,signal:e.signal,input:e.input,output:e.output,render(){let t=e.withGuide??H.withGuide,r=`${t?`${h("gray",_)}
|
|
68
|
-
`:""}${dr(this.state)} ${e.message}
|
|
69
|
-
`,n=this.userInputWithCursor,o=this.masked;switch(this.state){case"error":{let i=t?`${h("yellow",_)} `:"",s=t?`${h("yellow",Le)} `:"",a=o??"";return e.clearOnError&&this.clear(),`${r.trim()}
|
|
70
|
-
${i}${a}
|
|
71
|
-
${s}${h("yellow",this.error)}
|
|
72
|
-
`}case"submit":{let i=t?`${h("gray",_)} `:"",s=o?h("dim",o):"";return`${r}${i}${s}`}case"cancel":{let i=t?`${h("gray",_)} `:"",s=o?h(["strikethrough","dim"],o):"";return`${r}${i}${s}${o&&t?`
|
|
73
|
-
${h("gray",_)}`:""}`}default:{let i=t?`${h("cyan",_)} `:"",s=t?h("cyan",Le):"";return`${r}${i}${n}
|
|
74
|
-
${s}
|
|
75
|
-
`}}}}).prompt();var rf=e=>h("magenta",e),U=({indicator:e="dots",onCancel:t,output:r=process.stdout,cancelMessage:n,errorMessage:o,frames:i=no?["\u25D2","\u25D0","\u25D3","\u25D1"]:["\u2022","o","O","0"],delay:s=no?80:120,signal:a,...c}={})=>{let u=Up(),l,d,m=!1,p=!1,f="",g,w=performance.now(),x=St(r),C=c?.styleFrame??rf,v=F=>{let ne=F>1?o??H.messages.error:n??H.messages.cancel;p=F===1,m&&(xt(ne,F),p&&typeof t=="function"&&t())},A=()=>v(2),E=()=>v(1),R=()=>{process.on("uncaughtExceptionMonitor",A),process.on("unhandledRejection",A),process.on("SIGINT",E),process.on("SIGTERM",E),process.on("exit",v),a&&a.addEventListener("abort",E)},M=()=>{process.removeListener("uncaughtExceptionMonitor",A),process.removeListener("unhandledRejection",A),process.removeListener("SIGINT",E),process.removeListener("SIGTERM",E),process.removeListener("exit",v),a&&a.removeEventListener("abort",E)},L=()=>{if(g===void 0)return;u&&r.write(`
|
|
76
|
-
`);let F=ge(g,x,{hard:!0,trim:!1}).split(`
|
|
77
|
-
`);F.length>1&&r.write(Et.cursor.up(F.length-1)),r.write(Et.cursor.to(0)),r.write(Et.erase.down())},k=F=>F.replace(/\.+$/,""),Q=F=>{let ne=(performance.now()-F)/1e3,Oe=Math.floor(ne/60),ve=Math.floor(ne%60);return Oe>0?`[${Oe}m ${ve}s]`:`[${ve}s]`},N=c.withGuide??H.withGuide,qt=(F="")=>{m=!0,l=Fs({output:r}),f=k(F),w=performance.now(),N&&r.write(`${h("gray",_)}
|
|
78
|
-
`);let ne=0,Oe=0;R(),d=setInterval(()=>{if(u&&f===g)return;L(),g=f;let ve=C(i[ne]),Yt;if(u)Yt=`${ve} ${f}...`;else if(e==="timer")Yt=`${ve} ${f} ${Q(w)}`;else{let Ym=".".repeat(Math.floor(Oe)).slice(0,3);Yt=`${ve} ${f}${Ym}`}let qm=ge(Yt,x,{hard:!0,trim:!1});r.write(qm),ne=ne+1<i.length?ne+1:0,Oe=Oe<4?Oe+.125:0},s)},xt=(F="",ne=0,Oe=!1)=>{if(!m)return;m=!1,clearInterval(d),L();let ve=ne===0?h("green",ur):ne===1?h("red",Ns):h("red",Us);f=F??f,Oe||(e==="timer"?r.write(`${ve} ${f} ${Q(w)}
|
|
79
|
-
`):r.write(`${ve} ${f}
|
|
80
|
-
`)),M(),l()};return{start:qt,stop:(F="")=>xt(F,0),message:(F="")=>{f=k(F??f)},cancel:(F="")=>xt(F,1),error:(F="")=>xt(F,2),clear:()=>xt("",0,!0),get isCancelled(){return p}}},iE={light:T("\u2500","-"),heavy:T("\u2501","="),block:T("\u2588","#")};var cr=(e,t)=>e.includes(`
|
|
81
|
-
`)?e.split(`
|
|
82
|
-
`).map(r=>t(r)).join(`
|
|
83
|
-
`):t(e),Vs=e=>{let t=(r,n)=>{let o=r.label??String(r.value);switch(n){case"disabled":return`${h("gray",lr)} ${cr(o,i=>h("gray",i))}${r.hint?` ${h("dim",`(${r.hint??"disabled"})`)}`:""}`;case"selected":return`${cr(o,i=>h("dim",i))}`;case"active":return`${h("green",oo)} ${o}${r.hint?` ${h("dim",`(${r.hint})`)}`:""}`;case"cancelled":return`${cr(o,i=>h(["strikethrough","dim"],i))}`;default:return`${h("dim",lr)} ${cr(o,i=>h("dim",i))}`}};return new ir({options:e.options,signal:e.signal,input:e.input,output:e.output,initialValue:e.initialValue,render(){let r=e.withGuide??H.withGuide,n=`${dr(this.state)} `,o=`${Xp(this.state)} `,i=_t(e.output,e.message,o,n),s=`${r?`${h("gray",_)}
|
|
84
|
-
`:""}${i}
|
|
85
|
-
`;switch(this.state){case"submit":{let a=r?`${h("gray",_)} `:"",c=_t(e.output,t(this.options[this.cursor],"selected"),a);return`${s}${c}`}case"cancel":{let a=r?`${h("gray",_)} `:"",c=_t(e.output,t(this.options[this.cursor],"cancelled"),a);return`${s}${c}${r?`
|
|
86
|
-
${h("gray",_)}`:""}`}default:{let a=r?`${h("cyan",_)} `:"",c=r?h("cyan",Le):"",u=s.split(`
|
|
87
|
-
`).length,l=r?2:1;return`${s}${a}${Qp({output:e.output,cursor:this.cursor,options:this.options,maxItems:e.maxItems,columnPadding:a.length,rowPadding:u+l,style:(d,m)=>t(d,d.disabled?"disabled":m?"active":"inactive")}).join(`
|
|
88
|
-
${a}`)}
|
|
89
|
-
${c}
|
|
90
|
-
`}}}}).prompt()};var sE=`${h("gray",_)} `;var mr=e=>new sr({validate:e.validate,placeholder:e.placeholder,defaultValue:e.defaultValue,initialValue:e.initialValue,output:e.output,signal:e.signal,input:e.input,render(){let t=e?.withGuide??H.withGuide,r=`${`${t?`${h("gray",_)}
|
|
91
|
-
`:""}${dr(this.state)} `}${e.message}
|
|
92
|
-
`,n=e.placeholder?h("inverse",e.placeholder[0])+h("dim",e.placeholder.slice(1)):h(["inverse","hidden"],"_"),o=this.userInput?this.userInputWithCursor:n,i=this.value??"";switch(this.state){case"error":{let s=this.error?` ${h("yellow",this.error)}`:"",a=t?`${h("yellow",_)} `:"",c=t?h("yellow",Le):"";return`${r.trim()}
|
|
93
|
-
${a}${o}
|
|
94
|
-
${c}${s}
|
|
95
|
-
`}case"submit":{let s=i?` ${h("dim",i)}`:"",a=t?h("gray",_):"";return`${r}${a}${s}`}case"cancel":{let s=i?` ${h(["strikethrough","dim"],i)}`:"",a=t?h("gray",_):"";return`${r}${a}${s}${i.trim()?`
|
|
96
|
-
${a}`:""}`}default:{let s=t?`${h("cyan",_)} `:"",a=t?h("cyan",Le):"";return`${r}${s}${o}
|
|
97
|
-
${a}
|
|
98
|
-
`}}}}).prompt();var hm=q(ca(),1),Ge=q(ue(),1);import At from"fs";import Eo from"path";var fr="spree@example.com",hr="spree123";function b(e=process.cwd()){let t=Eo.join(e,"docker-compose.yml");if(!At.existsSync(t))throw new Error(`Not a Spree project directory. No docker-compose.yml found.
|
|
99
|
-
Run this command from a directory created with create-spree-app.`);let r=ih(e);return{mode:"docker",projectDir:e,port:r}}function nt(e){let t=Eo.join(e,".env");if(!At.existsSync(t))return!1;try{let r=At.readFileSync(t,"utf-8");return/^\s*SPREE_PATH\s*=/m.test(r)}catch{return!1}}function ih(e){let t=Eo.join(e,".env");if(!At.existsSync(t))return 3e3;let n=At.readFileSync(t,"utf-8").match(/^SPREE_PORT=(\d+)/m);return n?Number(n[1]):3e3}function j(e){if(typeof e!="object"||e===null)return!1;let t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}import{fileURLToPath as sh}from"url";var ot=(e,t)=>{let r=Co(ah(e));if(typeof r!="string")throw new TypeError(`${t} must be a string or a file URL: ${r}.`);return r},ah=e=>$o(e)?e.toString():e,$o=e=>typeof e!="string"&&e&&Object.getPrototypeOf(e)===String.prototype,Co=e=>e instanceof URL?sh(e):e;var gr=(e,t=[],r={})=>{let n=ot(e,"First argument"),[o,i]=j(t)?[[],t]:[t,r];if(!Array.isArray(o))throw new TypeError(`Second argument must be either an array of arguments or an options object: ${o}`);if(o.some(c=>typeof c=="object"&&c!==null))throw new TypeError(`Second argument must be an array of strings: ${o}`);let s=o.map(String),a=s.find(c=>c.includes("\0"));if(a!==void 0)throw new TypeError(`Arguments cannot contain null bytes ("\\0"): ${a}`);if(!j(i))throw new TypeError(`Last argument must be an options object: ${i}`);return[n,s,i]};import{ChildProcess as fh}from"child_process";import{StringDecoder as ch}from"string_decoder";var{toString:ua}=Object.prototype,da=e=>ua.call(e)==="[object ArrayBuffer]",V=e=>ua.call(e)==="[object Uint8Array]",Ie=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength),lh=new TextEncoder,ma=e=>lh.encode(e),uh=new TextDecoder,br=e=>uh.decode(e),pa=(e,t)=>dh(e,t).join(""),dh=(e,t)=>{if(t==="utf8"&&e.every(i=>typeof i=="string"))return e;let r=new ch(t),n=e.map(i=>typeof i=="string"?ma(i):i).map(i=>r.write(i)),o=r.end();return o===""?n:[...n,o]},It=e=>e.length===1&&V(e[0])?e[0]:Oo(mh(e)),mh=e=>e.map(t=>typeof t=="string"?ma(t):t),Oo=e=>{let t=new Uint8Array(ph(e)),r=0;for(let n of e)t.set(n,r),r+=n.length;return t},ph=e=>{let t=0;for(let r of e)t+=r.length;return t};var ba=e=>Array.isArray(e)&&Array.isArray(e.raw),ya=(e,t)=>{let r=[];for(let[i,s]of e.entries())r=hh({templates:e,expressions:t,tokens:r,index:i,template:s});if(r.length===0)throw new TypeError("Template script must not be empty");let[n,...o]=r;return[n,o,{}]},hh=({templates:e,expressions:t,tokens:r,index:n,template:o})=>{if(o===void 0)throw new TypeError(`Invalid backslash sequence: ${e.raw[n]}`);let{nextTokens:i,leadingWhitespaces:s,trailingWhitespaces:a}=gh(o,e.raw[n]),c=ha(r,i,s);if(n===t.length)return c;let u=t[n],l=Array.isArray(u)?u.map(d=>ga(d)):[ga(u)];return ha(c,l,a)},gh=(e,t)=>{if(t.length===0)return{nextTokens:[],leadingWhitespaces:!1,trailingWhitespaces:!1};let r=[],n=0,o=fa.has(t[0]);for(let s=0,a=0;s<e.length;s+=1,a+=1){let c=t[a];if(fa.has(c))n!==s&&r.push(e.slice(n,s)),n=s+1;else if(c==="\\"){let u=t[a+1];u===`
|
|
100
|
-
`?(s-=1,a+=1):u==="u"&&t[a+2]==="{"?a=t.indexOf("}",a+3):a+=bh[u]??1}}let i=n===e.length;return i||r.push(e.slice(n)),{nextTokens:r,leadingWhitespaces:o,trailingWhitespaces:i}},fa=new Set([" "," ","\r",`
|
|
101
|
-
`]),bh={x:3,u:5},ha=(e,t,r)=>r||e.length===0||t.length===0?[...e,...t]:[...e.slice(0,-1),`${e.at(-1)}${t[0]}`,...t.slice(1)],ga=e=>{let t=typeof e;if(t==="string")return e;if(t==="number")return String(e);if(j(e)&&("stdout"in e||"isMaxBuffer"in e))return yh(e);throw e instanceof fh||Object.prototype.toString.call(e)==="[object Promise]"?new TypeError("Unexpected subprocess in template expression. Please use ${await subprocess} instead of ${subprocess}."):new TypeError(`Unexpected "${t}" in template expression`)},yh=({stdout:e})=>{if(typeof e=="string")return e;if(V(e))return br(e);throw e===void 0?new TypeError(`Missing result.stdout in template expression. This is probably due to the previous subprocess' "stdout" option.`):new TypeError(`Unexpected "${typeof e}" stdout in template expression`)};import{spawnSync as _x}from"child_process";import{debuglog as xh}from"util";import vo from"process";var me=e=>yr.includes(e),yr=[vo.stdin,vo.stdout,vo.stderr],ae=["stdin","stdout","stderr"],xr=e=>ae[e]??`stdio[${e}]`;var wa=e=>{let t={...e};for(let r of Io)t[r]=To(e,r);return t},To=(e,t)=>{let r=Array.from({length:wh(e)+1}),n=Sh(e[t],r,t);return Oh(n,t)},wh=({stdio:e})=>Array.isArray(e)?Math.max(e.length,ae.length):ae.length,Sh=(e,t,r)=>j(e)?_h(e,t,r):t.fill(e),_h=(e,t,r)=>{for(let n of Object.keys(e).sort(Eh))for(let o of $h(n,r,t))t[o]=e[n];return t},Eh=(e,t)=>xa(e)<xa(t)?1:-1,xa=e=>e==="stdout"||e==="stderr"?0:e==="all"?2:1,$h=(e,t,r)=>{if(e==="ipc")return[r.length-1];let n=Ao(e);if(n===void 0||n===0)throw new TypeError(`"${t}.${e}" is invalid.
|
|
102
|
-
It must be "${t}.stdout", "${t}.stderr", "${t}.all", "${t}.ipc", or "${t}.fd3", "${t}.fd4" (and so on).`);if(n>=r.length)throw new TypeError(`"${t}.${e}" is invalid: that file descriptor does not exist.
|
|
103
|
-
Please set the "stdio" option to ensure that file descriptor exists.`);return n==="all"?[1,2]:[n]},Ao=e=>{if(e==="all")return e;if(ae.includes(e))return ae.indexOf(e);let t=Ch.exec(e);if(t!==null)return Number(t[1])},Ch=/^fd(\d+)$/,Oh=(e,t)=>e.map(r=>r===void 0?Th[t]:r),vh=xh("execa").enabled?"full":"none",Th={lines:!1,buffer:!0,maxBuffer:1e3*1e3*100,verbose:vh,stripFinalNewline:!0},Io=["lines","buffer","maxBuffer","verbose","stripFinalNewline"],De=(e,t)=>t==="ipc"?e.at(-1):e[t];var it=({verbose:e},t)=>Do(e,t)!=="none",st=({verbose:e},t)=>!["none","short"].includes(Do(e,t)),Sa=({verbose:e},t)=>{let r=Do(e,t);return wr(r)?r:void 0},Do=(e,t)=>t===void 0?Ah(e):De(e,t),Ah=e=>e.find(t=>wr(t))??Sr.findLast(t=>e.includes(t)),wr=e=>typeof e=="function",Sr=["none","short","full"];import{inspect as Xh}from"util";import{platform as Ih}from"process";import{stripVTControlCharacters as Dh}from"util";var _a=(e,t)=>{let r=[e,...t],n=r.join(" "),o=r.map(i=>Fh(Ea(i))).join(" ");return{command:n,escapedCommand:o}},Dt=e=>Dh(e).split(`
|
|
104
|
-
`).map(t=>Ea(t)).join(`
|
|
105
|
-
`),Ea=e=>e.replaceAll(Ph,t=>Rh(t)),Rh=e=>{let t=Lh[e];if(t!==void 0)return t;let r=e.codePointAt(0),n=r.toString(16);return r<=kh?`\\u${n.padStart(4,"0")}`:`\\U${n}`},Mh=()=>{try{return new RegExp("\\p{Separator}|\\p{Other}","gu")}catch{return/[\s\u0000-\u001F\u007F-\u009F\u00AD]/g}},Ph=Mh(),Lh={" ":" ","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r"," ":"\\t"},kh=65535,Fh=e=>jh.test(e)?e:Ih==="win32"?`"${e.replaceAll('"','""')}"`:`'${e.replaceAll("'","'\\''")}'`,jh=/^[\w./-]+$/;import $a from"process";function Ro(){let{env:e}=$a,{TERM:t,TERM_PROGRAM:r}=e;return $a.platform!=="win32"?t!=="linux":!!e.WT_SESSION||!!e.TERMINUS_SUBLIME||e.ConEmuTask==="{cmd::Cmder}"||r==="Terminus-Sublime"||r==="vscode"||t==="xterm-256color"||t==="alacritty"||t==="rxvt-unicode"||t==="rxvt-unicode-256color"||e.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var Ca={circleQuestionMark:"(?)",questionMarkPrefix:"(?)",square:"\u2588",squareDarkShade:"\u2593",squareMediumShade:"\u2592",squareLightShade:"\u2591",squareTop:"\u2580",squareBottom:"\u2584",squareLeft:"\u258C",squareRight:"\u2590",squareCenter:"\u25A0",bullet:"\u25CF",dot:"\u2024",ellipsis:"\u2026",pointerSmall:"\u203A",triangleUp:"\u25B2",triangleUpSmall:"\u25B4",triangleDown:"\u25BC",triangleDownSmall:"\u25BE",triangleLeftSmall:"\u25C2",triangleRightSmall:"\u25B8",home:"\u2302",heart:"\u2665",musicNote:"\u266A",musicNoteBeamed:"\u266B",arrowUp:"\u2191",arrowDown:"\u2193",arrowLeft:"\u2190",arrowRight:"\u2192",arrowLeftRight:"\u2194",arrowUpDown:"\u2195",almostEqual:"\u2248",notEqual:"\u2260",lessOrEqual:"\u2264",greaterOrEqual:"\u2265",identical:"\u2261",infinity:"\u221E",subscriptZero:"\u2080",subscriptOne:"\u2081",subscriptTwo:"\u2082",subscriptThree:"\u2083",subscriptFour:"\u2084",subscriptFive:"\u2085",subscriptSix:"\u2086",subscriptSeven:"\u2087",subscriptEight:"\u2088",subscriptNine:"\u2089",oneHalf:"\xBD",oneThird:"\u2153",oneQuarter:"\xBC",oneFifth:"\u2155",oneSixth:"\u2159",oneEighth:"\u215B",twoThirds:"\u2154",twoFifths:"\u2156",threeQuarters:"\xBE",threeFifths:"\u2157",threeEighths:"\u215C",fourFifths:"\u2158",fiveSixths:"\u215A",fiveEighths:"\u215D",sevenEighths:"\u215E",line:"\u2500",lineBold:"\u2501",lineDouble:"\u2550",lineDashed0:"\u2504",lineDashed1:"\u2505",lineDashed2:"\u2508",lineDashed3:"\u2509",lineDashed4:"\u254C",lineDashed5:"\u254D",lineDashed6:"\u2574",lineDashed7:"\u2576",lineDashed8:"\u2578",lineDashed9:"\u257A",lineDashed10:"\u257C",lineDashed11:"\u257E",lineDashed12:"\u2212",lineDashed13:"\u2013",lineDashed14:"\u2010",lineDashed15:"\u2043",lineVertical:"\u2502",lineVerticalBold:"\u2503",lineVerticalDouble:"\u2551",lineVerticalDashed0:"\u2506",lineVerticalDashed1:"\u2507",lineVerticalDashed2:"\u250A",lineVerticalDashed3:"\u250B",lineVerticalDashed4:"\u254E",lineVerticalDashed5:"\u254F",lineVerticalDashed6:"\u2575",lineVerticalDashed7:"\u2577",lineVerticalDashed8:"\u2579",lineVerticalDashed9:"\u257B",lineVerticalDashed10:"\u257D",lineVerticalDashed11:"\u257F",lineDownLeft:"\u2510",lineDownLeftArc:"\u256E",lineDownBoldLeftBold:"\u2513",lineDownBoldLeft:"\u2512",lineDownLeftBold:"\u2511",lineDownDoubleLeftDouble:"\u2557",lineDownDoubleLeft:"\u2556",lineDownLeftDouble:"\u2555",lineDownRight:"\u250C",lineDownRightArc:"\u256D",lineDownBoldRightBold:"\u250F",lineDownBoldRight:"\u250E",lineDownRightBold:"\u250D",lineDownDoubleRightDouble:"\u2554",lineDownDoubleRight:"\u2553",lineDownRightDouble:"\u2552",lineUpLeft:"\u2518",lineUpLeftArc:"\u256F",lineUpBoldLeftBold:"\u251B",lineUpBoldLeft:"\u251A",lineUpLeftBold:"\u2519",lineUpDoubleLeftDouble:"\u255D",lineUpDoubleLeft:"\u255C",lineUpLeftDouble:"\u255B",lineUpRight:"\u2514",lineUpRightArc:"\u2570",lineUpBoldRightBold:"\u2517",lineUpBoldRight:"\u2516",lineUpRightBold:"\u2515",lineUpDoubleRightDouble:"\u255A",lineUpDoubleRight:"\u2559",lineUpRightDouble:"\u2558",lineUpDownLeft:"\u2524",lineUpBoldDownBoldLeftBold:"\u252B",lineUpBoldDownBoldLeft:"\u2528",lineUpDownLeftBold:"\u2525",lineUpBoldDownLeftBold:"\u2529",lineUpDownBoldLeftBold:"\u252A",lineUpDownBoldLeft:"\u2527",lineUpBoldDownLeft:"\u2526",lineUpDoubleDownDoubleLeftDouble:"\u2563",lineUpDoubleDownDoubleLeft:"\u2562",lineUpDownLeftDouble:"\u2561",lineUpDownRight:"\u251C",lineUpBoldDownBoldRightBold:"\u2523",lineUpBoldDownBoldRight:"\u2520",lineUpDownRightBold:"\u251D",lineUpBoldDownRightBold:"\u2521",lineUpDownBoldRightBold:"\u2522",lineUpDownBoldRight:"\u251F",lineUpBoldDownRight:"\u251E",lineUpDoubleDownDoubleRightDouble:"\u2560",lineUpDoubleDownDoubleRight:"\u255F",lineUpDownRightDouble:"\u255E",lineDownLeftRight:"\u252C",lineDownBoldLeftBoldRightBold:"\u2533",lineDownLeftBoldRightBold:"\u252F",lineDownBoldLeftRight:"\u2530",lineDownBoldLeftBoldRight:"\u2531",lineDownBoldLeftRightBold:"\u2532",lineDownLeftRightBold:"\u252E",lineDownLeftBoldRight:"\u252D",lineDownDoubleLeftDoubleRightDouble:"\u2566",lineDownDoubleLeftRight:"\u2565",lineDownLeftDoubleRightDouble:"\u2564",lineUpLeftRight:"\u2534",lineUpBoldLeftBoldRightBold:"\u253B",lineUpLeftBoldRightBold:"\u2537",lineUpBoldLeftRight:"\u2538",lineUpBoldLeftBoldRight:"\u2539",lineUpBoldLeftRightBold:"\u253A",lineUpLeftRightBold:"\u2536",lineUpLeftBoldRight:"\u2535",lineUpDoubleLeftDoubleRightDouble:"\u2569",lineUpDoubleLeftRight:"\u2568",lineUpLeftDoubleRightDouble:"\u2567",lineUpDownLeftRight:"\u253C",lineUpBoldDownBoldLeftBoldRightBold:"\u254B",lineUpDownBoldLeftBoldRightBold:"\u2548",lineUpBoldDownLeftBoldRightBold:"\u2547",lineUpBoldDownBoldLeftRightBold:"\u254A",lineUpBoldDownBoldLeftBoldRight:"\u2549",lineUpBoldDownLeftRight:"\u2540",lineUpDownBoldLeftRight:"\u2541",lineUpDownLeftBoldRight:"\u253D",lineUpDownLeftRightBold:"\u253E",lineUpBoldDownBoldLeftRight:"\u2542",lineUpDownLeftBoldRightBold:"\u253F",lineUpBoldDownLeftBoldRight:"\u2543",lineUpBoldDownLeftRightBold:"\u2544",lineUpDownBoldLeftBoldRight:"\u2545",lineUpDownBoldLeftRightBold:"\u2546",lineUpDoubleDownDoubleLeftDoubleRightDouble:"\u256C",lineUpDoubleDownDoubleLeftRight:"\u256B",lineUpDownLeftDoubleRightDouble:"\u256A",lineCross:"\u2573",lineBackslash:"\u2572",lineSlash:"\u2571"},Oa={tick:"\u2714",info:"\u2139",warning:"\u26A0",cross:"\u2718",squareSmall:"\u25FB",squareSmallFilled:"\u25FC",circle:"\u25EF",circleFilled:"\u25C9",circleDotted:"\u25CC",circleDouble:"\u25CE",circleCircle:"\u24DE",circleCross:"\u24E7",circlePipe:"\u24BE",radioOn:"\u25C9",radioOff:"\u25EF",checkboxOn:"\u2612",checkboxOff:"\u2610",checkboxCircleOn:"\u24E7",checkboxCircleOff:"\u24BE",pointer:"\u276F",triangleUpOutline:"\u25B3",triangleLeft:"\u25C0",triangleRight:"\u25B6",lozenge:"\u25C6",lozengeOutline:"\u25C7",hamburger:"\u2630",smiley:"\u32E1",mustache:"\u0DF4",star:"\u2605",play:"\u25B6",nodejs:"\u2B22",oneSeventh:"\u2150",oneNinth:"\u2151",oneTenth:"\u2152"},Nh={tick:"\u221A",info:"i",warning:"\u203C",cross:"\xD7",squareSmall:"\u25A1",squareSmallFilled:"\u25A0",circle:"( )",circleFilled:"(*)",circleDotted:"( )",circleDouble:"( )",circleCircle:"(\u25CB)",circleCross:"(\xD7)",circlePipe:"(\u2502)",radioOn:"(*)",radioOff:"( )",checkboxOn:"[\xD7]",checkboxOff:"[ ]",checkboxCircleOn:"(\xD7)",checkboxCircleOff:"( )",pointer:">",triangleUpOutline:"\u2206",triangleLeft:"\u25C4",triangleRight:"\u25BA",lozenge:"\u2666",lozengeOutline:"\u25CA",hamburger:"\u2261",smiley:"\u263A",mustache:"\u250C\u2500\u2510",star:"\u2736",play:"\u25BA",nodejs:"\u2666",oneSeventh:"1/7",oneNinth:"1/9",oneTenth:"1/10"},Uh={...Ca,...Oa},Bh={...Ca,...Nh},Gh=Ro(),Vh=Gh?Uh:Bh,_r=Vh,t$=Object.entries(Oa);import Wh from"tty";var Hh=Wh?.WriteStream?.prototype?.hasColors?.()??!1,y=(e,t)=>{if(!Hh)return o=>o;let r=`\x1B[${e}m`,n=`\x1B[${t}m`;return o=>{let i=o+"",s=i.indexOf(n);if(s===-1)return r+i+n;let a=r,c=0,l=(t===22?n:"")+r;for(;s!==-1;)a+=i.slice(c,s)+l,c=s+n.length,s=i.indexOf(n,c);return a+=i.slice(c)+n,a}},o$=y(0,0),va=y(1,22),i$=y(2,22),s$=y(3,23),a$=y(4,24),c$=y(53,55),l$=y(7,27),u$=y(8,28),d$=y(9,29),m$=y(30,39),p$=y(31,39),f$=y(32,39),h$=y(33,39),g$=y(34,39),b$=y(35,39),y$=y(36,39),x$=y(37,39),Er=y(90,39),w$=y(40,49),S$=y(41,49),_$=y(42,49),E$=y(43,49),$$=y(44,49),C$=y(45,49),O$=y(46,49),v$=y(47,49),T$=y(100,49),Ta=y(91,39),A$=y(92,39),Aa=y(93,39),I$=y(94,39),D$=y(95,39),R$=y(96,39),M$=y(97,39),P$=y(101,49),L$=y(102,49),k$=y(103,49),F$=y(104,49),j$=y(105,49),N$=y(106,49),U$=y(107,49);var Ra=({type:e,message:t,timestamp:r,piped:n,commandId:o,result:{failed:i=!1}={},options:{reject:s=!0}})=>{let a=zh(r),c=qh[e]({failed:i,reject:s,piped:n}),u=Yh[e]({reject:s});return`${Er(`[${a}]`)} ${Er(`[${o}]`)} ${u(c)} ${u(t)}`},zh=e=>`${$r(e.getHours(),2)}:${$r(e.getMinutes(),2)}:${$r(e.getSeconds(),2)}.${$r(e.getMilliseconds(),3)}`,$r=(e,t)=>String(e).padStart(t,"0"),Ia=({failed:e,reject:t})=>e?t?_r.cross:_r.warning:_r.tick,qh={command:({piped:e})=>e?"|":"$",output:()=>" ",ipc:()=>"*",error:Ia,duration:Ia},Da=e=>e,Yh={command:()=>va,output:()=>Da,ipc:()=>Da,error:({reject:e})=>e?Ta:Aa,duration:()=>Er};var Ma=(e,t,r)=>{let n=Sa(t,r);return e.map(({verboseLine:o,verboseObject:i})=>Kh(o,i,n)).filter(o=>o!==void 0).map(o=>Jh(o)).join("")},Kh=(e,t,r)=>{if(r===void 0)return e;let n=r(e,t);if(typeof n=="string")return n},Jh=e=>e.endsWith(`
|
|
26
|
+
`),this.outputHelp({error:!0}));let i=r||{},n=i.exitCode||1,s=i.code||"commander.error";this._exit(n,s,t)}_parseOptionsEnv(){this.options.forEach(t=>{if(t.envVar&&t.envVar in T.env){let r=t.attributeName();(this.getOptionValue(r)===void 0||["default","config","env"].includes(this.getOptionValueSource(r)))&&(t.required||t.optional?this.emit(`optionEnv:${t.name()}`,T.env[t.envVar]):this.emit(`optionEnv:${t.name()}`))}})}_parseOptionsImplied(){let t=new gh(this.options),r=i=>this.getOptionValue(i)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(i));this.options.filter(i=>i.implied!==void 0&&r(i.attributeName())&&t.valueFromOption(this.getOptionValue(i.attributeName()),i)).forEach(i=>{Object.keys(i.implied).filter(n=>!r(n)).forEach(n=>{this.setOptionValueWithSource(n,i.implied[n],"implied")})})}missingArgument(t){let r=`error: missing required argument '${t}'`;this.error(r,{code:"commander.missingArgument"})}optionMissingArgument(t){let r=`error: option '${t.flags}' argument missing`;this.error(r,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(t){let r=`error: required option '${t.flags}' not specified`;this.error(r,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(t,r){let i=o=>{let a=o.attributeName(),c=this.getOptionValue(a),d=this.options.find(u=>u.negate&&a===u.attributeName()),p=this.options.find(u=>!u.negate&&a===u.attributeName());return d&&(d.presetArg===void 0&&c===!1||d.presetArg!==void 0&&c===d.presetArg)?d:p||o},n=o=>{let a=i(o),c=a.attributeName();return this.getOptionValueSource(c)==="env"?`environment variable '${a.envVar}'`:`option '${a.flags}'`},s=`error: ${n(t)} cannot be used with ${n(r)}`;this.error(s,{code:"commander.conflictingOption"})}unknownOption(t){if(this._allowUnknownOption)return;let r="";if(t.startsWith("--")&&this._showSuggestionAfterError){let n=[],s=this;do{let o=s.createHelp().visibleOptions(s).filter(a=>a.long).map(a=>a.long);n=n.concat(o),s=s.parent}while(s&&!s._enablePositionalOptions);r=zo(t,n)}let i=`error: unknown option '${t}'${r}`;this.error(i,{code:"commander.unknownOption"})}_excessArguments(t){if(this._allowExcessArguments)return;let r=this.registeredArguments.length,i=r===1?"":"s",s=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${r} argument${i} but got ${t.length}.`;this.error(s,{code:"commander.excessArguments"})}unknownCommand(){let t=this.args[0],r="";if(this._showSuggestionAfterError){let n=[];this.createHelp().visibleCommands(this).forEach(s=>{n.push(s.name()),s.alias()&&n.push(s.alias())}),r=zo(t,n)}let i=`error: unknown command '${t}'${r}`;this.error(i,{code:"commander.unknownCommand"})}version(t,r,i){if(t===void 0)return this._version;this._version=t,r=r||"-V, --version",i=i||"output the version number";let n=this.createOption(r,i);return this._versionOptionName=n.attributeName(),this._registerOption(n),this.on("option:"+n.name(),()=>{this._outputConfiguration.writeOut(`${t}
|
|
27
|
+
`),this._exit(0,"commander.version",t)}),this}description(t,r){return t===void 0&&r===void 0?this._description:(this._description=t,r&&(this._argsDescription=r),this)}summary(t){return t===void 0?this._summary:(this._summary=t,this)}alias(t){if(t===void 0)return this._aliases[0];let r=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(r=this.commands[this.commands.length-1]),t===r._name)throw new Error("Command alias can't be the same as its name");let i=this.parent?._findCommand(t);if(i){let n=[i.name()].concat(i.aliases()).join("|");throw new Error(`cannot add alias '${t}' to command '${this.name()}' as already have command '${n}'`)}return r._aliases.push(t),this}aliases(t){return t===void 0?this._aliases:(t.forEach(r=>this.alias(r)),this)}usage(t){if(t===void 0){if(this._usage)return this._usage;let r=this.registeredArguments.map(i=>hh(i));return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?r:[]).join(" ")}return this._usage=t,this}name(t){return t===void 0?this._name:(this._name=t,this)}helpGroup(t){return t===void 0?this._helpGroupHeading??"":(this._helpGroupHeading=t,this)}commandsGroup(t){return t===void 0?this._defaultCommandGroup??"":(this._defaultCommandGroup=t,this)}optionsGroup(t){return t===void 0?this._defaultOptionGroup??"":(this._defaultOptionGroup=t,this)}_initOptionGroup(t){this._defaultOptionGroup&&!t.helpGroupHeading&&t.helpGroup(this._defaultOptionGroup)}_initCommandGroup(t){this._defaultCommandGroup&&!t.helpGroup()&&t.helpGroup(this._defaultCommandGroup)}nameFromFilename(t){return this._name=Re.basename(t,Re.extname(t)),this}executableDir(t){return t===void 0?this._executableDir:(this._executableDir=t,this)}helpInformation(t){let r=this.createHelp(),i=this._getOutputContext(t);r.prepareContext({error:i.error,helpWidth:i.helpWidth,outputHasColors:i.hasColors});let n=r.formatHelp(this,r);return i.hasColors?n:this._outputConfiguration.stripColor(n)}_getOutputContext(t){t=t||{};let r=!!t.error,i,n,s;return r?(i=a=>this._outputConfiguration.writeErr(a),n=this._outputConfiguration.getErrHasColors(),s=this._outputConfiguration.getErrHelpWidth()):(i=a=>this._outputConfiguration.writeOut(a),n=this._outputConfiguration.getOutHasColors(),s=this._outputConfiguration.getOutHelpWidth()),{error:r,write:a=>(n||(a=this._outputConfiguration.stripColor(a)),i(a)),hasColors:n,helpWidth:s}}outputHelp(t){let r;typeof t=="function"&&(r=t,t=void 0);let i=this._getOutputContext(t),n={error:i.error,write:i.write,command:this};this._getCommandAndAncestors().reverse().forEach(o=>o.emit("beforeAllHelp",n)),this.emit("beforeHelp",n);let s=this.helpInformation({error:i.error});if(r&&(s=r(s),typeof s!="string"&&!Buffer.isBuffer(s)))throw new Error("outputHelp callback must return a string or a Buffer");i.write(s),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit("afterHelp",n),this._getCommandAndAncestors().forEach(o=>o.emit("afterAllHelp",n))}helpOption(t,r){return typeof t=="boolean"?(t?(this._helpOption===null&&(this._helpOption=void 0),this._defaultOptionGroup&&this._initOptionGroup(this._getHelpOption())):this._helpOption=null,this):(this._helpOption=this.createOption(t??"-h, --help",r??"display help for command"),(t||r)&&this._initOptionGroup(this._helpOption),this)}_getHelpOption(){return this._helpOption===void 0&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(t){return this._helpOption=t,this._initOptionGroup(t),this}help(t){this.outputHelp(t);let r=Number(T.exitCode??0);r===0&&t&&typeof t!="function"&&t.error&&(r=1),this._exit(r,"commander.help","(outputHelp)")}addHelpText(t,r){let i=["beforeAll","before","after","afterAll"];if(!i.includes(t))throw new Error(`Unexpected value for position to addHelpText.
|
|
28
|
+
Expecting one of '${i.join("', '")}'`);let n=`${t}Help`;return this.on(n,s=>{let o;typeof r=="function"?o=r({error:s.error,command:s.command}):o=r,o&&s.write(`${o}
|
|
29
|
+
`)}),this}_outputHelpIfRequested(t){let r=this._getHelpOption();r&&t.find(n=>r.is(n))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function Vo(e){return e.map(t=>{if(!t.startsWith("--inspect"))return t;let r,i="127.0.0.1",n="9229",s;return(s=t.match(/^(--inspect(-brk)?)$/))!==null?r=s[1]:(s=t.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(r=s[1],/^\d+$/.test(s[3])?n=s[3]:i=s[3]):(s=t.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(r=s[1],i=s[3],n=s[4]),r&&n!=="0"?`${r}=${i}:${parseInt(n)+1}`:t})}function bn(){if(T.env.NO_COLOR||T.env.FORCE_COLOR==="0"||T.env.FORCE_COLOR==="false")return!1;if(T.env.FORCE_COLOR||T.env.CLICOLOR_FORCE!==void 0)return!0}xn.Command=_n;xn.useColor=bn});var Jo=q(pe=>{"use strict";var{Argument:Ho}=_r(),{Command:wn}=Wo(),{CommanderError:_h,InvalidArgumentError:Ko}=Dt(),{Help:bh}=un(),{Option:Yo}=yn();pe.program=new wn;pe.createCommand=e=>new wn(e);pe.createOption=(e,t)=>new Yo(e,t);pe.createArgument=(e,t)=>new Ho(e,t);pe.Command=wn;pe.Option=Yo;pe.Argument=Ho;pe.Help=bh;pe.CommanderError=_h;pe.InvalidArgumentError=Ko;pe.InvalidOptionArgumentError=Ko});var X=q((KS,kn)=>{"use strict";var wr=process||{},ea=wr.argv||[],xr=wr.env||{},xh=!(xr.NO_COLOR||ea.includes("--no-color"))&&(!!xr.FORCE_COLOR||ea.includes("--color")||wr.platform==="win32"||(wr.stdout||{}).isTTY&&xr.TERM!=="dumb"||!!xr.CI),wh=(e,t,r=e)=>i=>{let n=""+i,s=n.indexOf(t,e.length);return~s?e+kh(n,t,r,s)+t:e+n+t},kh=(e,t,r,i)=>{let n="",s=0;do n+=e.substring(s,i)+r,s=i+t.length,i=e.indexOf(t,s);while(~i);return n+e.substring(s)},ta=(e=xh)=>{let t=e?wh:()=>String;return{isColorSupported:e,reset:t("\x1B[0m","\x1B[0m"),bold:t("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:t("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:t("\x1B[3m","\x1B[23m"),underline:t("\x1B[4m","\x1B[24m"),inverse:t("\x1B[7m","\x1B[27m"),hidden:t("\x1B[8m","\x1B[28m"),strikethrough:t("\x1B[9m","\x1B[29m"),black:t("\x1B[30m","\x1B[39m"),red:t("\x1B[31m","\x1B[39m"),green:t("\x1B[32m","\x1B[39m"),yellow:t("\x1B[33m","\x1B[39m"),blue:t("\x1B[34m","\x1B[39m"),magenta:t("\x1B[35m","\x1B[39m"),cyan:t("\x1B[36m","\x1B[39m"),white:t("\x1B[37m","\x1B[39m"),gray:t("\x1B[90m","\x1B[39m"),bgBlack:t("\x1B[40m","\x1B[49m"),bgRed:t("\x1B[41m","\x1B[49m"),bgGreen:t("\x1B[42m","\x1B[49m"),bgYellow:t("\x1B[43m","\x1B[49m"),bgBlue:t("\x1B[44m","\x1B[49m"),bgMagenta:t("\x1B[45m","\x1B[49m"),bgCyan:t("\x1B[46m","\x1B[49m"),bgWhite:t("\x1B[47m","\x1B[49m"),blackBright:t("\x1B[90m","\x1B[39m"),redBright:t("\x1B[91m","\x1B[39m"),greenBright:t("\x1B[92m","\x1B[39m"),yellowBright:t("\x1B[93m","\x1B[39m"),blueBright:t("\x1B[94m","\x1B[39m"),magentaBright:t("\x1B[95m","\x1B[39m"),cyanBright:t("\x1B[96m","\x1B[39m"),whiteBright:t("\x1B[97m","\x1B[39m"),bgBlackBright:t("\x1B[100m","\x1B[49m"),bgRedBright:t("\x1B[101m","\x1B[49m"),bgGreenBright:t("\x1B[102m","\x1B[49m"),bgYellowBright:t("\x1B[103m","\x1B[49m"),bgBlueBright:t("\x1B[104m","\x1B[49m"),bgMagentaBright:t("\x1B[105m","\x1B[49m"),bgCyanBright:t("\x1B[106m","\x1B[49m"),bgWhiteBright:t("\x1B[107m","\x1B[49m")}};kn.exports=ta();kn.exports.createColors=ta});var vn=q(ht=>{"use strict";Object.defineProperty(ht,"__esModule",{value:!0});ht.DEFAULT_COLOR_MAP=void 0;ht.DEFAULT_COLOR_MAP={red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m",white_bold:"\x1B[01m",reset:"\x1B[0m"};var Sn=class{constructor(t=ht.DEFAULT_COLOR_MAP){this.text="",this.colorMap=t}addCharsWithColor(t,r){let i=this.colorMap[t];this.text+=i!==void 0?`${i}${r}${this.colorMap.reset}`:r}renderConsole(){return this.text}};ht.default=Sn});var Lt=q(W=>{"use strict";Object.defineProperty(W,"__esModule",{value:!0});W.DEFAULT_HEADER_ALIGNMENT=W.DEFAULT_ROW_ALIGNMENT=W.DEFAULT_HEADER_FONT_COLOR=W.DEFAULT_ROW_FONT_COLOR=W.COLORS=W.ALIGNMENTS=W.DEFAULT_TABLE_STYLE=W.DEFAULT_ROW_SEPARATOR=W.DEFAULT_COLUMN_LEN=void 0;W.DEFAULT_COLUMN_LEN=20;W.DEFAULT_ROW_SEPARATOR=!1;W.DEFAULT_TABLE_STYLE={headerTop:{left:"\u250C",mid:"\u252C",right:"\u2510",other:"\u2500"},headerBottom:{left:"\u251C",mid:"\u253C",right:"\u2524",other:"\u2500"},tableBottom:{left:"\u2514",mid:"\u2534",right:"\u2518",other:"\u2500"},vertical:"\u2502",rowSeparator:{left:"\u251C",mid:"\u253C",right:"\u2524",other:"\u2500"}};W.ALIGNMENTS=["right","left","center"];W.COLORS=["red","green","yellow","white","blue","magenta","cyan","white_bold","reset"];W.DEFAULT_ROW_FONT_COLOR="white";W.DEFAULT_HEADER_FONT_COLOR="white_bold";W.DEFAULT_ROW_ALIGNMENT="right";W.DEFAULT_HEADER_ALIGNMENT="center"});var na=q(qn=>{"use strict";Object.defineProperty(qn,"__esModule",{value:!0});var Th=[{first:768,last:879},{first:1155,last:1158},{first:1160,last:1161},{first:1425,last:1469},{first:1471,last:1471},{first:1473,last:1474},{first:1476,last:1477},{first:1479,last:1479},{first:1536,last:1539},{first:1552,last:1557},{first:1611,last:1630},{first:1648,last:1648},{first:1750,last:1764},{first:1767,last:1768},{first:1770,last:1773},{first:1807,last:1807},{first:1809,last:1809},{first:1840,last:1866},{first:1958,last:1968},{first:2027,last:2035},{first:2305,last:2306},{first:2364,last:2364},{first:2369,last:2376},{first:2381,last:2381},{first:2385,last:2388},{first:2402,last:2403},{first:2433,last:2433},{first:2492,last:2492},{first:2497,last:2500},{first:2509,last:2509},{first:2530,last:2531},{first:2561,last:2562},{first:2620,last:2620},{first:2625,last:2626},{first:2631,last:2632},{first:2635,last:2637},{first:2672,last:2673},{first:2689,last:2690},{first:2748,last:2748},{first:2753,last:2757},{first:2759,last:2760},{first:2765,last:2765},{first:2786,last:2787},{first:2817,last:2817},{first:2876,last:2876},{first:2879,last:2879},{first:2881,last:2883},{first:2893,last:2893},{first:2902,last:2902},{first:2946,last:2946},{first:3008,last:3008},{first:3021,last:3021},{first:3134,last:3136},{first:3142,last:3144},{first:3146,last:3149},{first:3157,last:3158},{first:3260,last:3260},{first:3263,last:3263},{first:3270,last:3270},{first:3276,last:3277},{first:3298,last:3299},{first:3393,last:3395},{first:3405,last:3405},{first:3530,last:3530},{first:3538,last:3540},{first:3542,last:3542},{first:3633,last:3633},{first:3636,last:3642},{first:3655,last:3662},{first:3761,last:3761},{first:3764,last:3769},{first:3771,last:3772},{first:3784,last:3789},{first:3864,last:3865},{first:3893,last:3893},{first:3895,last:3895},{first:3897,last:3897},{first:3953,last:3966},{first:3968,last:3972},{first:3974,last:3975},{first:3984,last:3991},{first:3993,last:4028},{first:4038,last:4038},{first:4141,last:4144},{first:4146,last:4146},{first:4150,last:4151},{first:4153,last:4153},{first:4184,last:4185},{first:4448,last:4607},{first:4959,last:4959},{first:5906,last:5908},{first:5938,last:5940},{first:5970,last:5971},{first:6002,last:6003},{first:6068,last:6069},{first:6071,last:6077},{first:6086,last:6086},{first:6089,last:6099},{first:6109,last:6109},{first:6155,last:6157},{first:6313,last:6313},{first:6432,last:6434},{first:6439,last:6440},{first:6450,last:6450},{first:6457,last:6459},{first:6679,last:6680},{first:6912,last:6915},{first:6964,last:6964},{first:6966,last:6970},{first:6972,last:6972},{first:6978,last:6978},{first:7019,last:7027},{first:7616,last:7626},{first:7678,last:7679},{first:8203,last:8207},{first:8234,last:8238},{first:8288,last:8291},{first:8298,last:8303},{first:8400,last:8431},{first:12330,last:12335},{first:12441,last:12442},{first:43014,last:43014},{first:43019,last:43019},{first:43045,last:43046},{first:64286,last:64286},{first:65024,last:65039},{first:65056,last:65059},{first:65279,last:65279},{first:65529,last:65531},{first:68097,last:68099},{first:68101,last:68102},{first:68108,last:68111},{first:68152,last:68154},{first:68159,last:68159},{first:119143,last:119145},{first:119155,last:119170},{first:119173,last:119179},{first:119210,last:119213},{first:119362,last:119364},{first:917505,last:917505},{first:917536,last:917631},{first:917760,last:917999}];qn.default=Th});var sa=q($n=>{"use strict";Object.defineProperty($n,"__esModule",{value:!0});var Ph=(e,t,r)=>{let i=0,n,s=r;if(e<t[0].first||e>t[s].last)return 0;for(;s>=i;)if(n=Math.floor((i+s)/2),e>t[n].last)i=n+1;else if(e<t[n].first)s=n-1;else return 1;return 0};$n.default=Ph});var Cn=q(Mt=>{"use strict";var aa=Mt&&Mt.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Mt,"__esModule",{value:!0});var oa=aa(na()),Oh=aa(sa()),Ih=e=>e===0?0:e<32||e>=127&&e<160?-1:(0,Oh.default)(e,oa.default,oa.default.length-1)?0:1+ +(e>=4352&&(e<=4447||e===9001||e===9002||e>=11904&&e<=42191&&e!==12351||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65040&&e<=65049||e>=65072&&e<=65135||e>=65280&&e<=65376||e>=65504&&e<=65510||e>=131072&&e<=196605||e>=196608&&e<=262141));Mt.default=Ih});var ca=q(Ft=>{"use strict";var Rh=Ft&&Ft.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Ft,"__esModule",{value:!0});var jh=Rh(Cn()),Dh=e=>{let t=0;for(let r=0;r<e.length;r++){let i=e.charCodeAt(r),n=(0,jh.default)(i);if(n<0)return-1;t+=n}return t};Ft.default=Dh});var da=q(Ne=>{"use strict";var pa=Ne&&Ne.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Ne,"__esModule",{value:!0});Ne.wcswidth=Ne.wcwidth=void 0;var Lh=pa(ca());Ne.wcswidth=Lh.default;var Mh=pa(Cn());Ne.wcwidth=Mh.default});var An=q(tt=>{"use strict";Object.defineProperty(tt,"__esModule",{value:!0});tt.findWidthInConsole=tt.stripAnsi=void 0;var Fh=da(),Uh=/\x1b\[\d{1,3}(;\d{1,3})*m/g,Bh=e=>e.replace(Uh,"");tt.stripAnsi=Bh;var Nh=(e,t)=>{let r=0;return e=(0,tt.stripAnsi)(e),t&&Object.entries(t).forEach(([i,n])=>{let s=new RegExp(i,"g");r+=(e.match(s)||[]).length*n,e=e.replace(i,"")}),r+=(0,Fh.wcswidth)(e),r};tt.findWidthInConsole=Nh});var Tn=q(xe=>{"use strict";Object.defineProperty(xe,"__esModule",{value:!0});xe.biggestWordInSentence=xe.textWithPadding=xe.splitTextIntoTextsOfMinLen=void 0;var En=An(),Gh=(e,t,r)=>{let i=[];return e.split(/[\n\r]/).forEach(s=>{let o=s.split(" "),a=[],c=0;o.forEach(d=>{let p=(0,En.findWidthInConsole)(d,r);c+p<=t?(c+=p+1,a.push(d)):(a.length>0&&i.push(a.join(" ")),a=[d],c=p+1)}),i.push(a.join(" "))}),i};xe.splitTextIntoTextsOfMinLen=Gh;var zh=(e,t,r,i)=>{let n=(0,En.findWidthInConsole)(e,i),s=Math.floor((r-n)/2),o=r-s-n;if(r<n){let a=(0,xe.splitTextIntoTextsOfMinLen)(e,r);return a.length===1?e:a.map(c=>(0,xe.textWithPadding)(c,t,r,i)).join(`
|
|
30
|
+
`)}switch(t){case"left":return e.concat(" ".repeat(r-n));case"center":return" ".repeat(s).concat(e).concat(" ".repeat(o));default:return" ".repeat(r-n).concat(e)}};xe.textWithPadding=zh;var Vh=(e,t)=>e.split(" ").reduce((r,i)=>Math.max(r,(0,En.findWidthInConsole)(i,t)),0);xe.biggestWordInSentence=Vh});var Ut=q(M=>{"use strict";Object.defineProperty(M,"__esModule",{value:!0});M.getWidthLimitedColumnsArray=M.createHeaderAsRow=M.renderTableHorizontalBorders=M.findLenOfColumn=M.createRow=M.createColumFromOnlyName=M.createTableHorizontalBorders=M.convertRawRowOptionsToStandard=M.evaluateCellText=M.cellText=void 0;var ua=An(),Pn=Tn(),On=Lt(),yt=(e,t)=>Math.max(e,t),Wh=e=>e==null?"":`${e}`;M.cellText=Wh;var Hh=(e,t)=>t?`${t(e)}`:(0,M.cellText)(e);M.evaluateCellText=Hh;var Kh=e=>{if(e)return{color:e.color,separator:e.separator||On.DEFAULT_ROW_SEPARATOR}};M.convertRawRowOptionsToStandard=Kh;var Yh=({left:e,mid:t,right:r,other:i},n)=>{let s=e;return n.forEach(o=>{s+=i.repeat(o+2),s+=t}),s=s.slice(0,-t.length),s+=r,s};M.createTableHorizontalBorders=Yh;var Jh=e=>({name:e,title:e});M.createColumFromOnlyName=Jh;var Xh=(e,t,r)=>({color:e,separator:r,text:t});M.createRow=Xh;var Qh=(e,t,r)=>{let i=e.name,n=e.title,s=e.transform,o=yt(0,e?.minLen||0);return e.maxLen?(o=yt(o,yt(e.maxLen,(0,Pn.biggestWordInSentence)(n,r))),o=t.reduce((a,c)=>yt(a,(0,Pn.biggestWordInSentence)((0,M.evaluateCellText)(c.text[i],s),r)),o),o):(o=yt(o,(0,ua.findWidthInConsole)(n,r)),t.forEach(a=>{o=yt(o,(0,ua.findWidthInConsole)((0,M.evaluateCellText)(a.text[i],s),r))}),o)};M.findLenOfColumn=Qh;var Zh=(e,t)=>(0,M.createTableHorizontalBorders)(e,t);M.renderTableHorizontalBorders=Zh;var ey=(e,t)=>{let r=On.DEFAULT_HEADER_FONT_COLOR,i=e(r,{},!1);return t.forEach(n=>{i.text[n.name]=n.title}),i};M.createHeaderAsRow=ey;var ty=(e,t,r)=>{let i={};return e.forEach(n=>{i[n.name]=(0,Pn.splitTextIntoTextsOfMinLen)((0,M.cellText)(t.text[n.name]),n.length||On.DEFAULT_COLUMN_LEN,r)}),i};M.getWidthLimitedColumnsArray=ty});var la=q(je=>{"use strict";Object.defineProperty(je,"__esModule",{value:!0});je.rawColumnToInternalColumn=je.objIfExists=void 0;var ry=Lt(),iy=(e,t)=>t?{[e]:t}:{};je.objIfExists=iy;var ny=(e,t)=>{var r;return Object.assign(Object.assign(Object.assign(Object.assign({name:e.name,title:(r=e.title)!==null&&r!==void 0?r:e.name},(0,je.objIfExists)("color",e.color||t?.color)),(0,je.objIfExists)("maxLen",e.maxLen||t?.maxLen)),(0,je.objIfExists)("minLen",e.minLen||t?.minLen)),{alignment:e.alignment||t?.alignment||ry.DEFAULT_ROW_ALIGNMENT,transform:e.transform})};je.rawColumnToInternalColumn=ny});var ma=q(ft=>{"use strict";Object.defineProperty(ft,"__esModule",{value:!0});ft.preProcessRows=ft.preProcessColumns=void 0;var sy=Ut(),oy=e=>{e.computedColumns.length&&e.computedColumns.forEach(t=>{e.columns.some(i=>i.name===t.name)||(e.addColumn(Object.assign(Object.assign({},t),e.defaultColumnOptions)),e.rows.forEach((i,n,s)=>{let o=s.map(a=>a.text);i.text[t.name]=t.function(i.text,n,o)}))})},ay=e=>{e.enabledColumns.length&&(e.columns=e.columns.filter(t=>e.enabledColumns.includes(t.name)))},cy=e=>{e.disabledColumns.length&&(e.columns=e.columns.filter(t=>!e.disabledColumns.includes(t.name)))},py=e=>{e.columns.forEach(t=>{t.length=(0,sy.findLenOfColumn)(t,e.rows,e.charLength)})},dy=e=>{oy(e),cy(e),ay(e),py(e)};ft.preProcessColumns=dy;var uy=e=>{let t=e.rows.filter(r=>e.filterFunction(r.text)).sort((r,i)=>e.sortFunction(r.text,i.text));e.rows=t};ft.preProcessRows=uy});var In=q(de=>{"use strict";var ya=de&&de.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(de,"__esModule",{value:!0});de.printSimpleTable=de.renderSimpleTable=de.renderTable=void 0;var fa=ya(vn()),ga=Tn(),ye=Lt(),Ge=Ut(),ly=ya(Rn()),ha=ma(),my=(e,t,r,i,n,s,o,a)=>{let c=new fa.default(o);return c.addCharsWithColor("",e.vertical),t.forEach(d=>{let u=r<i[d.name].length?(0,Ge.cellText)(i[d.name][r]):"";c.addCharsWithColor(ye.DEFAULT_ROW_FONT_COLOR," "),c.addCharsWithColor(n&&ye.DEFAULT_HEADER_FONT_COLOR||d.color||s.color,(0,ga.textWithPadding)(u,d.alignment||ye.DEFAULT_ROW_ALIGNMENT,d.length||ye.DEFAULT_COLUMN_LEN,a)),c.addCharsWithColor("",` ${e.vertical}`)}),c.renderConsole()},_a=(e,t,r,i,n,s)=>{let o=(0,Ge.getWidthLimitedColumnsArray)(t,r,s),a=Object.values(o).reduce((d,p)=>Math.max(d,p.length),0),c=[];for(let d=0;d<a;d+=1){let p=my(e,t,d,o,n,r,i,s);c.push(p)}return c},hy=(e,t)=>{let r=JSON.parse(JSON.stringify(e)),i={};return t.filter(n=>!!n.transform).forEach(n=>{i[n.name]=n.transform}),Object.keys(i).forEach(n=>{r.text[n]=i[n](r.text[n])}),r},yy=(e,t)=>{let r=[],i=hy(t,e.columns);return r=r.concat(_a(e.tableStyle,e.columns,i,e.colorMap,void 0,e.charLength)),r},fy=e=>{let t=[];if(e.title===void 0)return t;let r=()=>{let s=(o,a)=>o+a+2+1;return e.columns.map(o=>o.length||ye.DEFAULT_COLUMN_LEN).reduce(s,1)},i=(0,ga.textWithPadding)(e.title,ye.DEFAULT_HEADER_ALIGNMENT,r()),n=new fa.default(e.colorMap);return n.addCharsWithColor(ye.DEFAULT_HEADER_FONT_COLOR,i),t.push(n.renderConsole()),t},gy=e=>{let t=[];t.push((0,Ge.renderTableHorizontalBorders)(e.tableStyle.headerTop,e.columns.map(i=>i.length||ye.DEFAULT_COLUMN_LEN)));let r=(0,Ge.createHeaderAsRow)(Ge.createRow,e.columns);return t=t.concat(_a(e.tableStyle,e.columns,r,e.colorMap,!0)),t.push((0,Ge.renderTableHorizontalBorders)(e.tableStyle.headerBottom,e.columns.map(i=>i.length||ye.DEFAULT_COLUMN_LEN))),t},_y=e=>{let t=[];return t.push((0,Ge.renderTableHorizontalBorders)(e.tableStyle.tableBottom,e.columns.map(r=>r.length||ye.DEFAULT_COLUMN_LEN))),t},by=(e,t)=>{let r=[],i=e.rows.length-1;return e.rows.indexOf(t)!==i&&t.separator&&r.push((0,Ge.renderTableHorizontalBorders)(e.tableStyle.rowSeparator,e.columns.map(s=>s.length||ye.DEFAULT_COLUMN_LEN))),r},xy=e=>{(0,ha.preProcessColumns)(e),(0,ha.preProcessRows)(e);let t=[];return fy(e).forEach(r=>t.push(r)),gy(e).forEach(r=>t.push(r)),e.rows.forEach(r=>{yy(e,r).forEach(i=>t.push(i)),by(e,r).forEach(i=>t.push(i))}),_y(e).forEach(r=>t.push(r)),t.join(`
|
|
31
|
+
`)};de.renderTable=xy;var wy=(e,t)=>{let r=new ly.default(t);return r.addRows(e),(0,de.renderTable)(r)};de.renderSimpleTable=wy;var ky=(e,t)=>{console.log((0,de.renderSimpleTable)(e,t))};de.printSimpleTable=ky});var Rn=q(Mn=>{"use strict";Object.defineProperty(Mn,"__esModule",{value:!0});var Sy=vn(),Sr=Lt(),jn=Ut(),Dn=la(),vy=In(),qy=()=>0,$y=()=>!0,Ln=class{initSimple(t){this.columns=t.map(r=>({name:r,title:r,alignment:Sr.DEFAULT_ROW_ALIGNMENT}))}initDetailed(t){var r;this.title=t?.title||this.title,this.tableStyle=Object.assign(Object.assign({},this.tableStyle),t?.style),this.sortFunction=t?.sort||this.sortFunction,this.filterFunction=t?.filter||this.filterFunction,this.enabledColumns=t?.enabledColumns||this.enabledColumns,this.disabledColumns=t?.disabledColumns||this.disabledColumns,this.computedColumns=t?.computedColumns||this.computedColumns,this.columns=((r=t?.columns)===null||r===void 0?void 0:r.map(i=>(0,Dn.rawColumnToInternalColumn)(i,t?.defaultColumnOptions)))||this.columns,this.rowSeparator=t?.rowSeparator||this.rowSeparator,this.charLength=t?.charLength||this.charLength,this.defaultColumnOptions=t?.defaultColumnOptions||this.defaultColumnOptions,t?.shouldDisableColors?this.colorMap={}:t?.colorMap&&(this.colorMap=Object.assign(Object.assign({},this.colorMap),t.colorMap)),t.rows!==void 0&&this.addRows(t.rows)}constructor(t){this.rows=[],this.columns=[],this.title=void 0,this.tableStyle=Sr.DEFAULT_TABLE_STYLE,this.filterFunction=$y,this.sortFunction=qy,this.enabledColumns=[],this.disabledColumns=[],this.computedColumns=[],this.rowSeparator=Sr.DEFAULT_ROW_SEPARATOR,this.colorMap=Sy.DEFAULT_COLOR_MAP,this.charLength={},this.defaultColumnOptions=void 0,this.transforms={},t instanceof Array?this.initSimple(t):typeof t=="object"&&this.initDetailed(t)}createColumnFromRow(t){let r=this.columns.map(i=>i.name);Object.keys(t).forEach(i=>{r.includes(i)||this.columns.push((0,Dn.rawColumnToInternalColumn)((0,jn.createColumFromOnlyName)(i),this.defaultColumnOptions))})}addColumn(t){let r=typeof t=="string"?(0,jn.createColumFromOnlyName)(t):t;this.columns.push((0,Dn.rawColumnToInternalColumn)(r,this.defaultColumnOptions))}addColumns(t){t.forEach(r=>{this.addColumn(r)})}addRow(t,r){this.createColumnFromRow(t),this.rows.push((0,jn.createRow)(r?.color||Sr.DEFAULT_ROW_FONT_COLOR,t,r?.separator!==void 0?r?.separator:this.rowSeparator))}addRows(t,r){t.forEach(i=>{this.addRow(i,r)})}renderTable(){return(0,vy.renderTable)(this)}};Mn.default=Ln});var xa=q(Bt=>{"use strict";var Cy=Bt&&Bt.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Bt,"__esModule",{value:!0});var Ay=Cy(Rn()),ba=Ut(),Fn=class{constructor(t){this.table=new Ay.default(t)}addColumn(t){return this.table.addColumn(t),this}addColumns(t){return this.table.addColumns(t),this}addRow(t,r){return this.table.addRow(t,(0,ba.convertRawRowOptionsToStandard)(r)),this}addRows(t,r){return this.table.addRows(t,(0,ba.convertRawRowOptionsToStandard)(r)),this}printTable(){let t=this.table.renderTable();console.log(t)}render(){return this.table.renderTable()}};Bt.default=Fn});var Nt=q(we=>{"use strict";var Ey=we&&we.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(we,"__esModule",{value:!0});we.renderTable=we.printTable=we.Table=void 0;var Ty=Ey(xa());we.Table=Ty.default;var wa=In();Object.defineProperty(we,"printTable",{enumerable:!0,get:function(){return wa.printSimpleTable}});Object.defineProperty(we,"renderTable",{enumerable:!0,get:function(){return wa.renderSimpleTable}})});var tc=q((i$,ec)=>{"use strict";ec.exports=Za;Za.sync=jf;var Xa=se("fs");function Rf(e,t){var r=t.pathExt!==void 0?t.pathExt:process.env.PATHEXT;if(!r||(r=r.split(";"),r.indexOf("")!==-1))return!0;for(var i=0;i<r.length;i++){var n=r[i].toLowerCase();if(n&&e.substr(-n.length).toLowerCase()===n)return!0}return!1}function Qa(e,t,r){return!e.isSymbolicLink()&&!e.isFile()?!1:Rf(t,r)}function Za(e,t,r){Xa.stat(e,function(i,n){r(i,i?!1:Qa(n,e,t))})}function jf(e,t){return Qa(Xa.statSync(e),e,t)}});var oc=q((n$,sc)=>{"use strict";sc.exports=ic;ic.sync=Df;var rc=se("fs");function ic(e,t,r){rc.stat(e,function(i,n){r(i,i?!1:nc(n,t))})}function Df(e,t){return nc(rc.statSync(e),t)}function nc(e,t){return e.isFile()&&Lf(e,t)}function Lf(e,t){var r=e.mode,i=e.uid,n=e.gid,s=t.uid!==void 0?t.uid:process.getuid&&process.getuid(),o=t.gid!==void 0?t.gid:process.getgid&&process.getgid(),a=parseInt("100",8),c=parseInt("010",8),d=parseInt("001",8),p=a|c,u=r&d||r&c&&n===o||r&a&&i===s||r&p&&s===0;return u}});var cc=q((o$,ac)=>{"use strict";var s$=se("fs"),Fr;process.platform==="win32"||global.TESTING_WINDOWS?Fr=tc():Fr=oc();ac.exports=Qn;Qn.sync=Mf;function Qn(e,t,r){if(typeof t=="function"&&(r=t,t={}),!r){if(typeof Promise!="function")throw new TypeError("callback not provided");return new Promise(function(i,n){Qn(e,t||{},function(s,o){s?n(s):i(o)})})}Fr(e,t||{},function(i,n){i&&(i.code==="EACCES"||t&&t.ignoreErrors)&&(i=null,n=!1),r(i,n)})}function Mf(e,t){try{return Fr.sync(e,t||{})}catch(r){if(t&&t.ignoreErrors||r.code==="EACCES")return!1;throw r}}});var yc=q((a$,hc)=>{"use strict";var wt=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",pc=se("path"),Ff=wt?";":":",dc=cc(),uc=e=>Object.assign(new Error(`not found: ${e}`),{code:"ENOENT"}),lc=(e,t)=>{let r=t.colon||Ff,i=e.match(/\//)||wt&&e.match(/\\/)?[""]:[...wt?[process.cwd()]:[],...(t.path||process.env.PATH||"").split(r)],n=wt?t.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",s=wt?n.split(r):[""];return wt&&e.indexOf(".")!==-1&&s[0]!==""&&s.unshift(""),{pathEnv:i,pathExt:s,pathExtExe:n}},mc=(e,t,r)=>{typeof t=="function"&&(r=t,t={}),t||(t={});let{pathEnv:i,pathExt:n,pathExtExe:s}=lc(e,t),o=[],a=d=>new Promise((p,u)=>{if(d===i.length)return t.all&&o.length?p(o):u(uc(e));let l=i[d],m=/^".*"$/.test(l)?l.slice(1,-1):l,h=pc.join(m,e),f=!m&&/^\.[\\\/]/.test(e)?e.slice(0,2)+h:h;p(c(f,d,0))}),c=(d,p,u)=>new Promise((l,m)=>{if(u===n.length)return l(a(p+1));let h=n[u];dc(d+h,{pathExt:s},(f,x)=>{if(!f&&x)if(t.all)o.push(d+h);else return l(d+h);return l(c(d,p,u+1))})});return r?a(0).then(d=>r(null,d),r):a(0)},Uf=(e,t)=>{t=t||{};let{pathEnv:r,pathExt:i,pathExtExe:n}=lc(e,t),s=[];for(let o=0;o<r.length;o++){let a=r[o],c=/^".*"$/.test(a)?a.slice(1,-1):a,d=pc.join(c,e),p=!c&&/^\.[\\\/]/.test(e)?e.slice(0,2)+d:d;for(let u=0;u<i.length;u++){let l=p+i[u];try{if(dc.sync(l,{pathExt:n}))if(t.all)s.push(l);else return l}catch{}}}if(t.all&&s.length)return s;if(t.nothrow)return null;throw uc(e)};hc.exports=mc;mc.sync=Uf});var gc=q((c$,Zn)=>{"use strict";var fc=(e={})=>{let t=e.env||process.env;return(e.platform||process.platform)!=="win32"?"PATH":Object.keys(t).reverse().find(i=>i.toUpperCase()==="PATH")||"Path"};Zn.exports=fc;Zn.exports.default=fc});var wc=q((p$,xc)=>{"use strict";var _c=se("path"),Bf=yc(),Nf=gc();function bc(e,t){let r=e.options.env||process.env,i=process.cwd(),n=e.options.cwd!=null,s=n&&process.chdir!==void 0&&!process.chdir.disabled;if(s)try{process.chdir(e.options.cwd)}catch{}let o;try{o=Bf.sync(e.command,{path:r[Nf({env:r})],pathExt:t?_c.delimiter:void 0})}catch{}finally{s&&process.chdir(i)}return o&&(o=_c.resolve(n?e.options.cwd:"",o)),o}function Gf(e){return bc(e)||bc(e,!0)}xc.exports=Gf});var kc=q((d$,ts)=>{"use strict";var es=/([()\][%!^"`<>&|;, *?])/g;function zf(e){return e=e.replace(es,"^$1"),e}function Vf(e,t){return e=`${e}`,e=e.replace(/(?=(\\+?)?)\1"/g,'$1$1\\"'),e=e.replace(/(?=(\\+?)?)\1$/,"$1$1"),e=`"${e}"`,e=e.replace(es,"^$1"),t&&(e=e.replace(es,"^$1")),e}ts.exports.command=zf;ts.exports.argument=Vf});var vc=q((u$,Sc)=>{"use strict";Sc.exports=/^#!(.*)/});var $c=q((l$,qc)=>{"use strict";var Wf=vc();qc.exports=(e="")=>{let t=e.match(Wf);if(!t)return null;let[r,i]=t[0].replace(/#! ?/,"").split(" "),n=r.split("/").pop();return n==="env"?i:i?`${n} ${i}`:n}});var Ac=q((m$,Cc)=>{"use strict";var rs=se("fs"),Hf=$c();function Kf(e){let r=Buffer.alloc(150),i;try{i=rs.openSync(e,"r"),rs.readSync(i,r,0,150,0),rs.closeSync(i)}catch{}return Hf(r.toString())}Cc.exports=Kf});var Oc=q((h$,Pc)=>{"use strict";var Yf=se("path"),Ec=wc(),Tc=kc(),Jf=Ac(),Xf=process.platform==="win32",Qf=/\.(?:com|exe)$/i,Zf=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function eg(e){e.file=Ec(e);let t=e.file&&Jf(e.file);return t?(e.args.unshift(e.file),e.command=t,Ec(e)):e.file}function tg(e){if(!Xf)return e;let t=eg(e),r=!Qf.test(t);if(e.options.forceShell||r){let i=Zf.test(t);e.command=Yf.normalize(e.command),e.command=Tc.command(e.command),e.args=e.args.map(s=>Tc.argument(s,i));let n=[e.command].concat(e.args).join(" ");e.args=["/d","/s","/c",`"${n}"`],e.command=process.env.comspec||"cmd.exe",e.options.windowsVerbatimArguments=!0}return e}function rg(e,t,r){t&&!Array.isArray(t)&&(r=t,t=null),t=t?t.slice(0):[],r=Object.assign({},r);let i={command:e,args:t,options:r,file:void 0,original:{command:e,args:t}};return r.shell?i:tg(i)}Pc.exports=rg});var jc=q((y$,Rc)=>{"use strict";var is=process.platform==="win32";function ns(e,t){return Object.assign(new Error(`${t} ${e.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${t} ${e.command}`,path:e.command,spawnargs:e.args})}function ig(e,t){if(!is)return;let r=e.emit;e.emit=function(i,n){if(i==="exit"){let s=Ic(n,t);if(s)return r.call(e,"error",s)}return r.apply(e,arguments)}}function Ic(e,t){return is&&e===1&&!t.file?ns(t.original,"spawn"):null}function ng(e,t){return is&&e===1&&!t.file?ns(t.original,"spawnSync"):null}Rc.exports={hookChildProcess:ig,verifyENOENT:Ic,verifyENOENTSync:ng,notFoundError:ns}});var Mc=q((f$,kt)=>{"use strict";var Dc=se("child_process"),ss=Oc(),os=jc();function Lc(e,t,r){let i=ss(e,t,r),n=Dc.spawn(i.command,i.args,i.options);return os.hookChildProcess(n,i),n}function sg(e,t,r){let i=ss(e,t,r),n=Dc.spawnSync(i.command,i.args,i.options);return n.error=n.error||os.verifyENOENTSync(n.status,i),n}kt.exports=Lc;kt.exports.spawn=Lc;kt.exports.sync=sg;kt.exports._parse=ss;kt.exports._enoent=os});var Ao=q((n1,sm)=>{"use strict";var Co={to(e,t){return t?`\x1B[${t+1};${e+1}H`:`\x1B[${e+1}G`},move(e,t){let r="";return e<0?r+=`\x1B[${-e}D`:e>0&&(r+=`\x1B[${e}C`),t<0?r+=`\x1B[${-t}A`:t>0&&(r+=`\x1B[${t}B`),r},up:(e=1)=>`\x1B[${e}A`,down:(e=1)=>`\x1B[${e}B`,forward:(e=1)=>`\x1B[${e}C`,backward:(e=1)=>`\x1B[${e}D`,nextLine:(e=1)=>"\x1B[E".repeat(e),prevLine:(e=1)=>"\x1B[F".repeat(e),left:"\x1B[G",hide:"\x1B[?25l",show:"\x1B[?25h",save:"\x1B7",restore:"\x1B8"},Ok={up:(e=1)=>"\x1B[S".repeat(e),down:(e=1)=>"\x1B[T".repeat(e)},Ik={screen:"\x1B[2J",up:(e=1)=>"\x1B[1J".repeat(e),down:(e=1)=>"\x1B[J".repeat(e),line:"\x1B[2K",lineEnd:"\x1B[K",lineStart:"\x1B[1K",lines(e){let t="";for(let r=0;r<e;r++)t+=this.line+(r<e-1?Co.up():"");return e&&(t+=Co.left),t}};sm.exports={cursor:Co,scroll:Ok,erase:Ik,beep:"\x07"}});var Xo=B(Jo(),1),{program:MS,createCommand:FS,createArgument:US,createOption:BS,CommanderError:NS,InvalidArgumentError:GS,InvalidOptionArgumentError:zS,Command:Qo,Argument:VS,Option:Zo,Help:WS}=Xo.default;var Jm=B(X(),1);function A(e){if(!e)return;let t={};return e.expand?.length&&(t.expand=e.expand.join(",")),e.fields?.length&&(t.fields=e.fields.join(",")),Object.keys(t).length>0?t:void 0}function Sh(e){return e===!1?!1:{maxRetries:e?.maxRetries??2,retryOnStatus:e?.retryOnStatus??[429,500,502,503,504],baseDelay:e?.baseDelay??300,maxDelay:e?.maxDelay??1e4,retryOnNetworkError:e?.retryOnNetworkError??!0}}var vh=new Set(["page","limit","expand","sort","fields"]);function b(e){let t={};for(let[r,i]of Object.entries(e))if(i!==void 0){if(vh.has(r)){t[r]=Array.isArray(i)?i.join(","):i;continue}if(r.startsWith("q[")){t[r]=i;continue}if(Array.isArray(i)){let n=r.endsWith("[]")?r.slice(0,-2):r;t[`q[${n}][]`]=i}else t[`q[${r}]`]=i}return t}var et=class extends Error{code;status;details;constructor(e,t){super(e.error.message),this.name="SpreeError",this.code=e.error.code,this.status=t,this.details=e.error.details}};function ra(e,t){let r=t.baseDelay*2**e,i=Math.random()*t.baseDelay;return Math.min(r+i,t.maxDelay)}function ia(e){return new Promise(t=>setTimeout(t,e))}function qh(){return`spree-sdk-retry-${crypto.randomUUID()}`}function $h(e,t,r,i){return e==="GET"||e==="HEAD"||i?r.retryOnStatus.includes(t):t===429}function Ch(e,t,r){return t.retryOnNetworkError?e==="GET"||e==="HEAD"||r:!1}function Ah(e,t,r,i){return async function(s,o,a={}){let{token:c,spreeToken:d,idempotencyKey:p,headers:u={},body:l,params:m}=a,h=a.locale??i?.locale,f=a.currency??i?.currency,x=a.country??i?.country,_=a.channel??i?.channel,v=typeof window<"u"?window.location.origin:void 0,C=e.baseUrl||v;if(!C)throw new TypeError("sdk-core: baseUrl is required in non-browser environments (no window.location to resolve relative URLs against)");let E=new URL(`${e.baseUrl}${t}${o}`,C);m&&Object.entries(m).forEach(([N,S])=>{if(S!==void 0)if(Array.isArray(S))for(let Te of S)E.searchParams.append(N,String(Te));else E.searchParams.set(N,String(S))});let w={"Content-Type":"application/json",...u};r.headerValue&&(w[r.headerName]=r.headerValue),c&&(w.Authorization=`Bearer ${c}`),d&&(w["x-spree-token"]=d),h&&(w["x-spree-locale"]=h),f&&(w["x-spree-currency"]=f),x&&(w["x-spree-country"]=x),_&&(w["x-spree-channel"]=_);let O=p??(s!=="GET"&&s!=="HEAD"&&e.retryConfig?qh():void 0);O&&(w["Idempotency-Key"]=O);let R=!!O,F=e.retryConfig?e.retryConfig.maxRetries+1:1;for(let N=0;N<F;N++)try{let S=await e.fetchFn(E.toString(),{method:s,headers:w,body:l?JSON.stringify(l):void 0,credentials:e.credentials});if(!S.ok){if(!(N>=F-1)&&e.retryConfig&&$h(s,S.status,e.retryConfig,R)){let U=S.headers.get("Retry-After"),ne=U?Math.min(parseInt(U,10)*1e3,e.retryConfig.maxDelay):ra(N,e.retryConfig);await ia(ne);continue}let Pe=await S.json();throw new et(Pe,S.status)}return S.status===204?void 0:S.status===202?S.headers.get("content-type")?.includes("application/json")?S.json():void 0:S.json()}catch(S){if(S instanceof et)throw S;if(!(N>=F-1)&&e.retryConfig&&Ch(s,e.retryConfig,R)){let Pe=ra(N,e.retryConfig);await ia(Pe);continue}throw S}throw new Error("Unexpected end of retry loop")}}var Ze={"Spree::Product":"/products","Spree::Variant":"/variants","Spree::Order":"/orders","Spree::User":"/customers","Spree::Category":"/categories","Spree::OptionType":"/option_types"},Eh=class{request;constructor(e){this.request=e}parentScopedCustomFields(e){return{list:(t,r,i)=>this.request("GET",`${e}/${t}/custom_fields`,{...i,params:r?b(r):void 0}),get:(t,r,i)=>this.request("GET",`${e}/${t}/custom_fields/${r}`,i),create:(t,r,i)=>this.request("POST",`${e}/${t}/custom_fields`,{...i,body:r}),update:(t,r,i,n)=>this.request("PATCH",`${e}/${t}/custom_fields/${r}`,{...n,body:i}),delete:(t,r,i)=>this.request("DELETE",`${e}/${t}/custom_fields/${r}`,i)}}customFields(e,t){let r=Ze[e];if(!r)throw new Error(`Unknown custom-field owner type: ${e}. Add it to CUSTOM_FIELD_OWNER_PATHS.`);let i=this.parentScopedCustomFields(r);return{list:(n,s)=>i.list(t,n,s),get:(n,s)=>i.get(t,n,s),create:(n,s)=>i.create(t,n,s),update:(n,s,o)=>i.update(t,n,s,o),delete:(n,s)=>i.delete(t,n,s)}}customFieldDefinitions={list:(e,t)=>this.request("GET","/custom_field_definitions",{...t,params:e?b(e):void 0}),get:(e,t)=>this.request("GET",`/custom_field_definitions/${e}`,t),create:(e,t)=>this.request("POST","/custom_field_definitions",{...t,body:e}),update:(e,t,r)=>this.request("PATCH",`/custom_field_definitions/${e}`,{...r,body:t}),delete:(e,t)=>this.request("DELETE",`/custom_field_definitions/${e}`,t)};auth={login:(e,t)=>this.request("POST","/auth/login",{...t,body:e}),refresh:e=>this.request("POST","/auth/refresh",e),logout:e=>this.request("POST","/auth/logout",e),lookupInvitation:(e,t,r)=>this.request("GET",`/auth/invitations/${e}/lookup`,{...r,params:{token:t}}),acceptInvitation:(e,t,r,i)=>this.request("POST",`/auth/invitations/${e}/accept`,{...i,params:{token:t},body:r})};me={get:e=>this.request("GET","/me",e)};dashboard={analytics:(e,t)=>this.request("GET","/dashboard/analytics",{...t,params:e})};store={get:e=>this.request("GET","/store",e),update:(e,t)=>this.request("PATCH","/store",{...t,body:e})};products={list:(e,t)=>this.request("GET","/products",{...t,params:e?b(e):void 0}),get:(e,t,r)=>this.request("GET",`/products/${e}`,{...r,params:A(t)}),create:(e,t)=>this.request("POST","/products",{...t,body:e}),update:(e,t,r)=>this.request("PATCH",`/products/${e}`,{...r,body:t}),delete:(e,t)=>this.request("DELETE",`/products/${e}`,t),clone:(e,t)=>this.request("POST",`/products/${e}/clone`,t),bulkStatusUpdate:(e,t)=>this.request("POST","/products/bulk_status_update",{...t,body:e}),bulkAddToCategories:(e,t)=>this.request("POST","/products/bulk_add_to_categories",{...t,body:e}),bulkRemoveFromCategories:(e,t)=>this.request("POST","/products/bulk_remove_from_categories",{...t,body:e}),bulkAddToChannels:(e,t)=>this.request("POST","/products/bulk_add_to_channels",{...t,body:e}),bulkRemoveFromChannels:(e,t)=>this.request("POST","/products/bulk_remove_from_channels",{...t,body:e}),bulkAddTags:(e,t)=>this.request("POST","/products/bulk_add_tags",{...t,body:e}),bulkRemoveTags:(e,t)=>this.request("POST","/products/bulk_remove_tags",{...t,body:e}),bulkDestroy:(e,t)=>this.request("DELETE","/products/bulk_destroy",{...t,body:e}),media:{list:(e,t,r)=>this.request("GET",`/products/${e}/media`,{...r,params:t?b(t):void 0}),create:(e,t,r)=>this.request("POST",`/products/${e}/media`,{...r,body:t}),update:(e,t,r,i)=>this.request("PATCH",`/products/${e}/media/${t}`,{...i,body:r}),delete:(e,t,r)=>this.request("DELETE",`/products/${e}/media/${t}`,r)},variants:{list:(e,t,r)=>this.request("GET",`/products/${e}/variants`,{...r,params:t?b(t):void 0}),get:(e,t,r,i)=>this.request("GET",`/products/${e}/variants/${t}`,{...i,params:A(r)}),create:(e,t,r)=>this.request("POST",`/products/${e}/variants`,{...r,body:t}),update:(e,t,r,i)=>this.request("PATCH",`/products/${e}/variants/${t}`,{...i,body:r}),delete:(e,t,r)=>this.request("DELETE",`/products/${e}/variants/${t}`,r),media:{list:(e,t,r,i)=>this.request("GET",`/products/${e}/variants/${t}/media`,{...i,params:r?b(r):void 0}),create:(e,t,r,i)=>this.request("POST",`/products/${e}/variants/${t}/media`,{...i,body:r}),update:(e,t,r,i,n)=>this.request("PATCH",`/products/${e}/variants/${t}/media/${r}`,{...n,body:i}),delete:(e,t,r,i)=>this.request("DELETE",`/products/${e}/variants/${t}/media/${r}`,i)}},customFields:this.parentScopedCustomFields(Ze["Spree::Product"])};orders={list:(e,t)=>this.request("GET","/orders",{...t,params:e?b(e):void 0}),get:(e,t,r)=>this.request("GET",`/orders/${e}`,{...r,params:A(t)}),create:(e,t)=>this.request("POST","/orders",{...t,body:e}),update:(e,t,r)=>this.request("PATCH",`/orders/${e}`,{...r,body:t}),delete:(e,t)=>this.request("DELETE",`/orders/${e}`,t),complete:(e,t,r)=>this.request("PATCH",`/orders/${e}/complete`,{...r,body:t}),cancel:(e,t,r)=>this.request("PATCH",`/orders/${e}/cancel`,{...r,body:t}),approve:(e,t,r)=>this.request("PATCH",`/orders/${e}/approve`,{...r,body:t}),resume:(e,t)=>this.request("PATCH",`/orders/${e}/resume`,t),resendConfirmation:(e,t)=>this.request("POST",`/orders/${e}/resend_confirmation`,t),giftCards:{apply:(e,t,r)=>this.request("POST",`/orders/${e}/gift_cards`,{...r,body:t}),remove:(e,t,r)=>this.request("DELETE",`/orders/${e}/gift_cards/${t}`,r)},storeCredits:{apply:(e,t,r)=>this.request("POST",`/orders/${e}/store_credits`,{...r,body:t}),remove:(e,t)=>this.request("DELETE",`/orders/${e}/store_credits`,t)},items:{list:(e,t,r)=>this.request("GET",`/orders/${e}/items`,{...r,params:t?b(t):void 0}),get:(e,t,r,i)=>this.request("GET",`/orders/${e}/items/${t}`,{...i,params:A(r)}),create:(e,t,r)=>this.request("POST",`/orders/${e}/items`,{...r,body:t}),update:(e,t,r,i)=>this.request("PATCH",`/orders/${e}/items/${t}`,{...i,body:r}),delete:(e,t,r)=>this.request("DELETE",`/orders/${e}/items/${t}`,r)},fulfillments:{list:(e,t,r)=>this.request("GET",`/orders/${e}/fulfillments`,{...r,params:t?b(t):void 0}),get:(e,t,r,i)=>this.request("GET",`/orders/${e}/fulfillments/${t}`,{...i,params:A(r)}),update:(e,t,r,i)=>this.request("PATCH",`/orders/${e}/fulfillments/${t}`,{...i,body:r}),fulfill:(e,t,r)=>this.request("PATCH",`/orders/${e}/fulfillments/${t}/fulfill`,r),cancel:(e,t,r)=>this.request("PATCH",`/orders/${e}/fulfillments/${t}/cancel`,r),resume:(e,t,r)=>this.request("PATCH",`/orders/${e}/fulfillments/${t}/resume`,r),split:(e,t,r,i)=>this.request("PATCH",`/orders/${e}/fulfillments/${t}/split`,{...i,body:r})},payments:{list:(e,t,r)=>this.request("GET",`/orders/${e}/payments`,{...r,params:t?b(t):void 0}),get:(e,t,r,i)=>this.request("GET",`/orders/${e}/payments/${t}`,{...i,params:A(r)}),create:(e,t,r)=>this.request("POST",`/orders/${e}/payments`,{...r,body:t}),capture:(e,t,r)=>this.request("PATCH",`/orders/${e}/payments/${t}/capture`,r),void:(e,t,r)=>this.request("PATCH",`/orders/${e}/payments/${t}/void`,r)},refunds:{list:(e,t,r)=>this.request("GET",`/orders/${e}/refunds`,{...r,params:t?b(t):void 0}),create:(e,t,r)=>this.request("POST",`/orders/${e}/refunds`,{...r,body:t})},adjustments:{list:(e,t,r)=>this.request("GET",`/orders/${e}/adjustments`,{...r,params:t?b(t):void 0}),get:(e,t,r)=>this.request("GET",`/orders/${e}/adjustments/${t}`,r)},customFields:this.parentScopedCustomFields(Ze["Spree::Order"])};optionTypes={list:(e,t)=>this.request("GET","/option_types",{...t,params:e?b(e):void 0}),get:(e,t,r)=>this.request("GET",`/option_types/${e}`,{...r,params:A(t)}),create:(e,t)=>this.request("POST","/option_types",{...t,body:e}),update:(e,t,r)=>this.request("PATCH",`/option_types/${e}`,{...r,body:t}),delete:(e,t)=>this.request("DELETE",`/option_types/${e}`,t),customFields:this.parentScopedCustomFields(Ze["Spree::OptionType"])};paymentMethods={list:(e,t)=>this.request("GET","/payment_methods",{...t,params:e?b(e):void 0}),get:(e,t,r)=>this.request("GET",`/payment_methods/${e}`,{...r,params:A(t)}),create:(e,t)=>this.request("POST","/payment_methods",{...t,body:e}),update:(e,t,r)=>this.request("PATCH",`/payment_methods/${e}`,{...r,body:t}),delete:(e,t)=>this.request("DELETE",`/payment_methods/${e}`,t),types:e=>this.request("GET","/payment_methods/types",e)};priceLists={list:(e,t)=>this.request("GET","/price_lists",{...t,params:e?b(e):void 0}),get:(e,t,r)=>this.request("GET",`/price_lists/${e}`,{...r,params:A(t)}),create:(e,t)=>this.request("POST","/price_lists",{...t,body:e}),update:(e,t,r)=>this.request("PATCH",`/price_lists/${e}`,{...r,body:t}),delete:(e,t)=>this.request("DELETE",`/price_lists/${e}`,t),activate:(e,t)=>this.request("PATCH",`/price_lists/${e}/activate`,t),deactivate:(e,t)=>this.request("PATCH",`/price_lists/${e}/deactivate`,t),ruleTypes:e=>this.request("GET","/price_lists/price_rule_types",e)};prices={list:(e,t)=>this.request("GET","/prices",{...t,params:e?b(e):void 0}),get:(e,t,r)=>this.request("GET",`/prices/${e}`,{...r,params:A(t)}),create:(e,t)=>this.request("POST","/prices",{...t,body:e}),update:(e,t,r)=>this.request("PATCH",`/prices/${e}`,{...r,body:t}),delete:(e,t)=>this.request("DELETE",`/prices/${e}`,t),bulkUpsert:(e,t)=>this.request("POST","/prices/bulk_upsert",{...t,body:e}),bulkDestroy:(e,t)=>this.request("DELETE","/prices/bulk_destroy",{...t,body:e})};promotions={list:(e,t)=>this.request("GET","/promotions",{...t,params:e?b(e):void 0}),get:(e,t,r)=>this.request("GET",`/promotions/${e}`,{...r,params:A(t)}),create:(e,t)=>this.request("POST","/promotions",{...t,body:e}),update:(e,t,r)=>this.request("PATCH",`/promotions/${e}`,{...r,body:t}),delete:(e,t)=>this.request("DELETE",`/promotions/${e}`,t),actions:{list:(e,t,r)=>this.request("GET",`/promotions/${e}/promotion_actions`,{...r,params:t?b(t):void 0}),get:(e,t,r)=>this.request("GET",`/promotions/${e}/promotion_actions/${t}`,r),create:(e,t,r)=>this.request("POST",`/promotions/${e}/promotion_actions`,{...r,body:t}),update:(e,t,r,i)=>this.request("PATCH",`/promotions/${e}/promotion_actions/${t}`,{...i,body:r}),delete:(e,t,r)=>this.request("DELETE",`/promotions/${e}/promotion_actions/${t}`,r)},rules:{list:(e,t,r)=>this.request("GET",`/promotions/${e}/promotion_rules`,{...r,params:t?b(t):void 0}),get:(e,t,r)=>this.request("GET",`/promotions/${e}/promotion_rules/${t}`,r),create:(e,t,r)=>this.request("POST",`/promotions/${e}/promotion_rules`,{...r,body:t}),update:(e,t,r,i)=>this.request("PATCH",`/promotions/${e}/promotion_rules/${t}`,{...i,body:r}),delete:(e,t,r)=>this.request("DELETE",`/promotions/${e}/promotion_rules/${t}`,r)},couponCodes:{list:(e,t,r)=>this.request("GET",`/promotions/${e}/coupon_codes`,{...r,params:t?b(t):void 0}),get:(e,t,r)=>this.request("GET",`/promotions/${e}/coupon_codes/${t}`,r)}};promotionActions={types:e=>this.request("GET","/promotion_actions/types",e),calculators:(e,t)=>this.request("GET","/promotion_actions/calculators",{...t,params:{type:e}})};promotionRules={types:e=>this.request("GET","/promotion_rules/types",e)};tags={list:(e,t)=>this.request("GET","/tags",{...t,params:e})};customerGroups={list:(e,t)=>this.request("GET","/customer_groups",{...t,params:e?b(e):void 0}),get:(e,t,r)=>this.request("GET",`/customer_groups/${e}`,{...r,params:A(t)}),create:(e,t)=>this.request("POST","/customer_groups",{...t,body:e}),update:(e,t,r)=>this.request("PATCH",`/customer_groups/${e}`,{...r,body:t}),delete:(e,t)=>this.request("DELETE",`/customer_groups/${e}`,t)};giftCards={list:(e,t)=>this.request("GET","/gift_cards",{...t,params:e?b(e):void 0}),get:(e,t,r)=>this.request("GET",`/gift_cards/${e}`,{...r,params:A(t)}),create:(e,t)=>this.request("POST","/gift_cards",{...t,body:e}),update:(e,t,r)=>this.request("PATCH",`/gift_cards/${e}`,{...r,body:t}),delete:(e,t)=>this.request("DELETE",`/gift_cards/${e}`,t)};giftCardBatches={list:(e,t)=>this.request("GET","/gift_card_batches",{...t,params:e?b(e):void 0}),get:(e,t)=>this.request("GET",`/gift_card_batches/${e}`,t),create:(e,t)=>this.request("POST","/gift_card_batches",{...t,body:e})};exports={list:(e,t)=>this.request("GET","/exports",{...t,params:e?b(e):void 0}),get:(e,t)=>this.request("GET",`/exports/${e}`,t),create:(e,t)=>this.request("POST","/exports",{...t,body:e}),delete:(e,t)=>this.request("DELETE",`/exports/${e}`,t)};customers={list:(e,t)=>this.request("GET","/customers",{...t,params:e?b(e):void 0}),get:(e,t,r)=>this.request("GET",`/customers/${e}`,{...r,params:A(t)}),creditCards:{list:(e,t,r)=>this.request("GET",`/customers/${e}/credit_cards`,{...r,params:t?b(t):void 0}),get:(e,t,r,i)=>this.request("GET",`/customers/${e}/credit_cards/${t}`,{...i,params:A(r)}),delete:(e,t,r)=>this.request("DELETE",`/customers/${e}/credit_cards/${t}`,r)},create:(e,t)=>this.request("POST","/customers",{...t,body:e}),update:(e,t,r)=>this.request("PATCH",`/customers/${e}`,{...r,body:t}),delete:(e,t)=>this.request("DELETE",`/customers/${e}`,t),bulkAddToGroups:(e,t)=>this.request("POST","/customers/bulk_add_to_groups",{...t,body:e}),bulkRemoveFromGroups:(e,t)=>this.request("POST","/customers/bulk_remove_from_groups",{...t,body:e}),bulkAddTags:(e,t)=>this.request("POST","/customers/bulk_add_tags",{...t,body:e}),bulkRemoveTags:(e,t)=>this.request("POST","/customers/bulk_remove_tags",{...t,body:e}),addresses:{list:(e,t,r)=>this.request("GET",`/customers/${e}/addresses`,{...r,params:t?b(t):void 0}),get:(e,t,r,i)=>this.request("GET",`/customers/${e}/addresses/${t}`,{...i,params:A(r)}),create:(e,t,r)=>this.request("POST",`/customers/${e}/addresses`,{...r,body:t}),update:(e,t,r,i)=>this.request("PATCH",`/customers/${e}/addresses/${t}`,{...i,body:r}),delete:(e,t,r)=>this.request("DELETE",`/customers/${e}/addresses/${t}`,r)},storeCredits:{list:(e,t,r)=>this.request("GET",`/customers/${e}/store_credits`,{...r,params:t?b(t):void 0}),get:(e,t,r,i)=>this.request("GET",`/customers/${e}/store_credits/${t}`,{...i,params:A(r)}),create:(e,t,r)=>this.request("POST",`/customers/${e}/store_credits`,{...r,body:t}),update:(e,t,r,i)=>this.request("PATCH",`/customers/${e}/store_credits/${t}`,{...i,body:r}),delete:(e,t,r)=>this.request("DELETE",`/customers/${e}/store_credits/${t}`,r)},customFields:this.parentScopedCustomFields(Ze["Spree::User"])};categories={list:(e,t)=>this.request("GET","/categories",{...t,params:e?b(e):void 0}),customFields:this.parentScopedCustomFields(Ze["Spree::Category"])};variants={list:(e,t)=>this.request("GET","/variants",{...t,params:e?b(e):void 0}),get:(e,t,r)=>this.request("GET",`/variants/${e}`,{...r,params:A(t)}),customFields:this.parentScopedCustomFields(Ze["Spree::Variant"])};taxCategories={list:(e,t)=>this.request("GET","/tax_categories",{...t,params:e?b(e):void 0}),get:(e,t,r)=>this.request("GET",`/tax_categories/${e}`,{...r,params:A(t)}),create:(e,t)=>this.request("POST","/tax_categories",{...t,body:e}),update:(e,t,r)=>this.request("PATCH",`/tax_categories/${e}`,{...r,body:t}),delete:(e,t)=>this.request("DELETE",`/tax_categories/${e}`,t)};channels={list:(e,t)=>this.request("GET","/channels",{...t,params:e?b(e):void 0}),get:(e,t,r)=>this.request("GET",`/channels/${e}`,{...r,params:A(t)}),create:(e,t)=>this.request("POST","/channels",{...t,body:e}),update:(e,t,r)=>this.request("PATCH",`/channels/${e}`,{...r,body:t}),delete:(e,t)=>this.request("DELETE",`/channels/${e}`,t),addProducts:(e,t,r)=>this.request("POST",`/channels/${e}/add_products`,{...r,body:t}),removeProducts:(e,t,r)=>this.request("POST",`/channels/${e}/remove_products`,{...r,body:t})};markets={list:(e,t)=>this.request("GET","/markets",{...t,params:e?b(e):void 0}),get:(e,t,r)=>this.request("GET",`/markets/${e}`,{...r,params:A(t)}),create:(e,t)=>this.request("POST","/markets",{...t,body:e}),update:(e,t,r)=>this.request("PATCH",`/markets/${e}`,{...r,body:t}),delete:(e,t)=>this.request("DELETE",`/markets/${e}`,t)};storeCreditCategories={list:(e,t)=>this.request("GET","/store_credit_categories",{...t,params:e?b(e):void 0}),get:(e,t,r)=>this.request("GET",`/store_credit_categories/${e}`,{...r,params:A(t)})};stockLocations={list:(e,t)=>this.request("GET","/stock_locations",{...t,params:e?b(e):void 0}),get:(e,t,r)=>this.request("GET",`/stock_locations/${e}`,{...r,params:A(t)}),create:(e,t)=>this.request("POST","/stock_locations",{...t,body:e}),update:(e,t,r)=>this.request("PATCH",`/stock_locations/${e}`,{...r,body:t}),delete:(e,t)=>this.request("DELETE",`/stock_locations/${e}`,t)};stockItems={list:(e,t)=>this.request("GET","/stock_items",{...t,params:e?b(e):void 0}),get:(e,t,r)=>this.request("GET",`/stock_items/${e}`,{...r,params:A(t)}),update:(e,t,r)=>this.request("PATCH",`/stock_items/${e}`,{...r,body:t}),delete:(e,t)=>this.request("DELETE",`/stock_items/${e}`,t)};stockTransfers={list:(e,t)=>this.request("GET","/stock_transfers",{...t,params:e?b(e):void 0}),get:(e,t,r)=>this.request("GET",`/stock_transfers/${e}`,{...r,params:A(t)}),create:(e,t)=>this.request("POST","/stock_transfers",{...t,body:e}),delete:(e,t)=>this.request("DELETE",`/stock_transfers/${e}`,t)};countries={list:(e,t)=>this.request("GET","/countries",{...t,params:e?b(e):void 0}),get:(e,t,r)=>this.request("GET",`/countries/${e}`,{...r,params:A(t)})};directUploads={create:(e,t)=>this.request("POST","/direct_uploads",{...t,body:e})};adminUsers={list:(e,t)=>this.request("GET","/admin_users",{...t,params:e?b(e):void 0}),get:(e,t,r)=>this.request("GET",`/admin_users/${e}`,{...r,params:A(t)}),update:(e,t,r)=>this.request("PATCH",`/admin_users/${e}`,{...r,body:t}),delete:(e,t)=>this.request("DELETE",`/admin_users/${e}`,t)};invitations={list:(e,t)=>this.request("GET","/invitations",{...t,params:e?b(e):void 0}),get:(e,t,r)=>this.request("GET",`/invitations/${e}`,{...r,params:A(t)}),create:(e,t)=>this.request("POST","/invitations",{...t,body:e}),delete:(e,t)=>this.request("DELETE",`/invitations/${e}`,t),resend:(e,t)=>this.request("PATCH",`/invitations/${e}/resend`,t)};apiKeys={list:(e,t)=>this.request("GET","/api_keys",{...t,params:e?b(e):void 0}),get:(e,t,r)=>this.request("GET",`/api_keys/${e}`,{...r,params:A(t)}),create:(e,t)=>this.request("POST","/api_keys",{...t,body:e}),update:(e,t,r)=>this.request("PATCH",`/api_keys/${e}`,{...r,body:t}),delete:(e,t)=>this.request("DELETE",`/api_keys/${e}`,t),revoke:(e,t)=>this.request("PATCH",`/api_keys/${e}/revoke`,t)};allowedOrigins={list:(e,t)=>this.request("GET","/allowed_origins",{...t,params:e?b(e):void 0}),get:(e,t,r)=>this.request("GET",`/allowed_origins/${e}`,{...r,params:A(t)}),create:(e,t)=>this.request("POST","/allowed_origins",{...t,body:e}),update:(e,t,r)=>this.request("PATCH",`/allowed_origins/${e}`,{...r,body:t}),delete:(e,t)=>this.request("DELETE",`/allowed_origins/${e}`,t)};webhookEndpoints={list:(e,t)=>this.request("GET","/webhook_endpoints",{...t,params:e?b(e):void 0}),get:(e,t,r)=>this.request("GET",`/webhook_endpoints/${e}`,{...r,params:A(t)}),create:(e,t)=>this.request("POST","/webhook_endpoints",{...t,body:e}),update:(e,t,r)=>this.request("PATCH",`/webhook_endpoints/${e}`,{...r,body:t}),delete:(e,t)=>this.request("DELETE",`/webhook_endpoints/${e}`,t),sendTest:(e,t)=>this.request("POST",`/webhook_endpoints/${e}/send_test`,t),enable:(e,t)=>this.request("PATCH",`/webhook_endpoints/${e}/enable`,t),disable:(e,t,r)=>this.request("PATCH",`/webhook_endpoints/${e}/disable`,{...r,body:t}),deliveries:{list:(e,t,r)=>this.request("GET",`/webhook_endpoints/${e}/deliveries`,{...r,params:t?b(t):void 0}),get:(e,t,r)=>this.request("GET",`/webhook_endpoints/${e}/deliveries/${t}`,r),redeliver:(e,t,r)=>this.request("POST",`/webhook_endpoints/${e}/deliveries/${t}/redeliver`,r)}};roles={list:(e,t)=>this.request("GET","/roles",{...t,params:e?b(e):void 0}),get:(e,t,r)=>this.request("GET",`/roles/${e}`,{...r,params:A(t)})}};function kr(e){let t=e.baseUrl.replace(/\/$/,""),r=e.fetch||fetch.bind(globalThis),i=Sh(e.retry),n={baseUrl:t,fetchFn:r,retryConfig:i,credentials:e.credentials??"include"},s=e.jwtToken,o=e.storeId,a=null,c="/api/v3/admin",d=async(l,m,h={})=>{let f={};o&&(f["X-Spree-Store-Id"]=o);let x={...h,headers:{...f,...h.headers}},_=()=>{let v=e.secretKey?{headerName:"X-Spree-Api-Key",headerValue:e.secretKey}:{headerName:"Authorization",headerValue:s?`Bearer ${s}`:""};return Ah(n,c,v)(l,m,x)};try{return await _()}catch(v){if(v instanceof et&&v.status===401&&a&&!m.includes("/auth/")&&await a())return _();throw v}},p=new Eh(d),u=Object.create(p);return u.setStore=l=>{o=l},u.setToken=l=>{s=l},u.onUnauthorized=l=>{a=l},u}var Bl=B(Nt(),1),Ye=B(X(),1);var ka=B(X(),1);import Py from"fs";var Un=Symbol("no-body");async function Sa(e){if(e===void 0)return Un;let t;if(e==="-")t=await Oy();else if(e.startsWith("@")){let r=e.slice(1);try{t=Py.readFileSync(r,"utf-8")}catch(i){throw i?.code==="ENOENT"?new Error(`Request body file not found: ${r}`):new Error(`Could not read request body file ${r}: ${i.message}`)}}else t=e;try{return JSON.parse(t)}catch{let r=e==="-"?" (from stdin)":e.startsWith("@")?` (${e.slice(1)})`:"";throw new Error(`Request body is not valid JSON${r}`)}}async function Oy(){process.stdin.isTTY&&process.stderr.write(`${ka.default.dim("Reading request body from stdin \u2014 paste JSON and press Ctrl-D...")}
|
|
32
|
+
`);let e=[];for await(let t of process.stdin)e.push(t);return Buffer.concat(e).toString("utf-8")}var So=B(Nt(),1),ae=B(X(),1);var or=B(X(),1);import Ue from"fs";import ok from"os";import It from"path";var vr="spree@example.com",qr="spree123";import Gt from"fs";import Bn from"path";function g(e=process.cwd()){let t=Bn.join(e,"docker-compose.yml");if(!Gt.existsSync(t))throw new Error(`Not a Spree project directory. No docker-compose.yml found.
|
|
33
|
+
Run this command from a directory created with create-spree-app.`);let r=Iy(e);return{mode:"docker",projectDir:e,port:r}}function gt(e){let t=Bn.join(e,".env");if(!Gt.existsSync(t))return!1;try{let r=Gt.readFileSync(t,"utf-8");return/^\s*SPREE_PATH\s*=/m.test(r)}catch{return!1}}function Iy(e){let t=Bn.join(e,".env");if(!Gt.existsSync(t))return 3e3;let i=Gt.readFileSync(t,"utf-8").match(/^SPREE_PORT=(\d+)/m);return i?Number(i[1]):3e3}function V(e){if(typeof e!="object"||e===null)return!1;let t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}import{fileURLToPath as Ry}from"url";var _t=(e,t)=>{let r=Gn(jy(e));if(typeof r!="string")throw new TypeError(`${t} must be a string or a file URL: ${r}.`);return r},jy=e=>Nn(e)?e.toString():e,Nn=e=>typeof e!="string"&&e&&Object.getPrototypeOf(e)===String.prototype,Gn=e=>e instanceof URL?Ry(e):e;var Cr=(e,t=[],r={})=>{let i=_t(e,"First argument"),[n,s]=V(t)?[[],t]:[t,r];if(!Array.isArray(n))throw new TypeError(`Second argument must be either an array of arguments or an options object: ${n}`);if(n.some(c=>typeof c=="object"&&c!==null))throw new TypeError(`Second argument must be an array of strings: ${n}`);let o=n.map(String),a=o.find(c=>c.includes("\0"));if(a!==void 0)throw new TypeError(`Arguments cannot contain null bytes ("\\0"): ${a}`);if(!V(s))throw new TypeError(`Last argument must be an options object: ${s}`);return[i,o,s]};import{ChildProcess as Ny}from"child_process";import{StringDecoder as Dy}from"string_decoder";var{toString:va}=Object.prototype,qa=e=>va.call(e)==="[object ArrayBuffer]",H=e=>va.call(e)==="[object Uint8Array]",De=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength),Ly=new TextEncoder,$a=e=>Ly.encode(e),My=new TextDecoder,Ar=e=>My.decode(e),Ca=(e,t)=>Fy(e,t).join(""),Fy=(e,t)=>{if(t==="utf8"&&e.every(s=>typeof s=="string"))return e;let r=new Dy(t),i=e.map(s=>typeof s=="string"?$a(s):s).map(s=>r.write(s)),n=r.end();return n===""?i:[...i,n]},zt=e=>e.length===1&&H(e[0])?e[0]:zn(Uy(e)),Uy=e=>e.map(t=>typeof t=="string"?$a(t):t),zn=e=>{let t=new Uint8Array(By(e)),r=0;for(let i of e)t.set(i,r),r+=i.length;return t},By=e=>{let t=0;for(let r of e)t+=r.length;return t};var Pa=e=>Array.isArray(e)&&Array.isArray(e.raw),Oa=(e,t)=>{let r=[];for(let[s,o]of e.entries())r=Gy({templates:e,expressions:t,tokens:r,index:s,template:o});if(r.length===0)throw new TypeError("Template script must not be empty");let[i,...n]=r;return[i,n,{}]},Gy=({templates:e,expressions:t,tokens:r,index:i,template:n})=>{if(n===void 0)throw new TypeError(`Invalid backslash sequence: ${e.raw[i]}`);let{nextTokens:s,leadingWhitespaces:o,trailingWhitespaces:a}=zy(n,e.raw[i]),c=Ea(r,s,o);if(i===t.length)return c;let d=t[i],p=Array.isArray(d)?d.map(u=>Ta(u)):[Ta(d)];return Ea(c,p,a)},zy=(e,t)=>{if(t.length===0)return{nextTokens:[],leadingWhitespaces:!1,trailingWhitespaces:!1};let r=[],i=0,n=Aa.has(t[0]);for(let o=0,a=0;o<e.length;o+=1,a+=1){let c=t[a];if(Aa.has(c))i!==o&&r.push(e.slice(i,o)),i=o+1;else if(c==="\\"){let d=t[a+1];d===`
|
|
34
|
+
`?(o-=1,a+=1):d==="u"&&t[a+2]==="{"?a=t.indexOf("}",a+3):a+=Vy[d]??1}}let s=i===e.length;return s||r.push(e.slice(i)),{nextTokens:r,leadingWhitespaces:n,trailingWhitespaces:s}},Aa=new Set([" "," ","\r",`
|
|
35
|
+
`]),Vy={x:3,u:5},Ea=(e,t,r)=>r||e.length===0||t.length===0?[...e,...t]:[...e.slice(0,-1),`${e.at(-1)}${t[0]}`,...t.slice(1)],Ta=e=>{let t=typeof e;if(t==="string")return e;if(t==="number")return String(e);if(V(e)&&("stdout"in e||"isMaxBuffer"in e))return Wy(e);throw e instanceof Ny||Object.prototype.toString.call(e)==="[object Promise]"?new TypeError("Unexpected subprocess in template expression. Please use ${await subprocess} instead of ${subprocess}."):new TypeError(`Unexpected "${t}" in template expression`)},Wy=({stdout:e})=>{if(typeof e=="string")return e;if(H(e))return Ar(e);throw e===void 0?new TypeError(`Missing result.stdout in template expression. This is probably due to the previous subprocess' "stdout" option.`):new TypeError(`Unexpected "${typeof e}" stdout in template expression`)};import{spawnSync as Xx}from"child_process";import{debuglog as Hy}from"util";import Vn from"process";var fe=e=>Er.includes(e),Er=[Vn.stdin,Vn.stdout,Vn.stderr],ue=["stdin","stdout","stderr"],Tr=e=>ue[e]??`stdio[${e}]`;var Ra=e=>{let t={...e};for(let r of Kn)t[r]=Wn(e,r);return t},Wn=(e,t)=>{let r=Array.from({length:Ky(e)+1}),i=Yy(e[t],r,t);return ef(i,t)},Ky=({stdio:e})=>Array.isArray(e)?Math.max(e.length,ue.length):ue.length,Yy=(e,t,r)=>V(e)?Jy(e,t,r):t.fill(e),Jy=(e,t,r)=>{for(let i of Object.keys(e).sort(Xy))for(let n of Qy(i,r,t))t[n]=e[i];return t},Xy=(e,t)=>Ia(e)<Ia(t)?1:-1,Ia=e=>e==="stdout"||e==="stderr"?0:e==="all"?2:1,Qy=(e,t,r)=>{if(e==="ipc")return[r.length-1];let i=Hn(e);if(i===void 0||i===0)throw new TypeError(`"${t}.${e}" is invalid.
|
|
36
|
+
It must be "${t}.stdout", "${t}.stderr", "${t}.all", "${t}.ipc", or "${t}.fd3", "${t}.fd4" (and so on).`);if(i>=r.length)throw new TypeError(`"${t}.${e}" is invalid: that file descriptor does not exist.
|
|
37
|
+
Please set the "stdio" option to ensure that file descriptor exists.`);return i==="all"?[1,2]:[i]},Hn=e=>{if(e==="all")return e;if(ue.includes(e))return ue.indexOf(e);let t=Zy.exec(e);if(t!==null)return Number(t[1])},Zy=/^fd(\d+)$/,ef=(e,t)=>e.map(r=>r===void 0?rf[t]:r),tf=Hy("execa").enabled?"full":"none",rf={lines:!1,buffer:!0,maxBuffer:1e3*1e3*100,verbose:tf,stripFinalNewline:!0},Kn=["lines","buffer","maxBuffer","verbose","stripFinalNewline"],Le=(e,t)=>t==="ipc"?e.at(-1):e[t];var bt=({verbose:e},t)=>Yn(e,t)!=="none",xt=({verbose:e},t)=>!["none","short"].includes(Yn(e,t)),ja=({verbose:e},t)=>{let r=Yn(e,t);return Pr(r)?r:void 0},Yn=(e,t)=>t===void 0?nf(e):Le(e,t),nf=e=>e.find(t=>Pr(t))??Or.findLast(t=>e.includes(t)),Pr=e=>typeof e=="function",Or=["none","short","full"];import{inspect as $f}from"util";import{platform as sf}from"process";import{stripVTControlCharacters as of}from"util";var Da=(e,t)=>{let r=[e,...t],i=r.join(" "),n=r.map(s=>lf(La(s))).join(" ");return{command:i,escapedCommand:n}},Vt=e=>of(e).split(`
|
|
38
|
+
`).map(t=>La(t)).join(`
|
|
39
|
+
`),La=e=>e.replaceAll(pf,t=>af(t)),af=e=>{let t=df[e];if(t!==void 0)return t;let r=e.codePointAt(0),i=r.toString(16);return r<=uf?`\\u${i.padStart(4,"0")}`:`\\U${i}`},cf=()=>{try{return new RegExp("\\p{Separator}|\\p{Other}","gu")}catch{return/[\s\u0000-\u001F\u007F-\u009F\u00AD]/g}},pf=cf(),df={" ":" ","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r"," ":"\\t"},uf=65535,lf=e=>mf.test(e)?e:sf==="win32"?`"${e.replaceAll('"','""')}"`:`'${e.replaceAll("'","'\\''")}'`,mf=/^[\w./-]+$/;import Ma from"process";function Jn(){let{env:e}=Ma,{TERM:t,TERM_PROGRAM:r}=e;return Ma.platform!=="win32"?t!=="linux":!!e.WT_SESSION||!!e.TERMINUS_SUBLIME||e.ConEmuTask==="{cmd::Cmder}"||r==="Terminus-Sublime"||r==="vscode"||t==="xterm-256color"||t==="alacritty"||t==="rxvt-unicode"||t==="rxvt-unicode-256color"||e.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var Fa={circleQuestionMark:"(?)",questionMarkPrefix:"(?)",square:"\u2588",squareDarkShade:"\u2593",squareMediumShade:"\u2592",squareLightShade:"\u2591",squareTop:"\u2580",squareBottom:"\u2584",squareLeft:"\u258C",squareRight:"\u2590",squareCenter:"\u25A0",bullet:"\u25CF",dot:"\u2024",ellipsis:"\u2026",pointerSmall:"\u203A",triangleUp:"\u25B2",triangleUpSmall:"\u25B4",triangleDown:"\u25BC",triangleDownSmall:"\u25BE",triangleLeftSmall:"\u25C2",triangleRightSmall:"\u25B8",home:"\u2302",heart:"\u2665",musicNote:"\u266A",musicNoteBeamed:"\u266B",arrowUp:"\u2191",arrowDown:"\u2193",arrowLeft:"\u2190",arrowRight:"\u2192",arrowLeftRight:"\u2194",arrowUpDown:"\u2195",almostEqual:"\u2248",notEqual:"\u2260",lessOrEqual:"\u2264",greaterOrEqual:"\u2265",identical:"\u2261",infinity:"\u221E",subscriptZero:"\u2080",subscriptOne:"\u2081",subscriptTwo:"\u2082",subscriptThree:"\u2083",subscriptFour:"\u2084",subscriptFive:"\u2085",subscriptSix:"\u2086",subscriptSeven:"\u2087",subscriptEight:"\u2088",subscriptNine:"\u2089",oneHalf:"\xBD",oneThird:"\u2153",oneQuarter:"\xBC",oneFifth:"\u2155",oneSixth:"\u2159",oneEighth:"\u215B",twoThirds:"\u2154",twoFifths:"\u2156",threeQuarters:"\xBE",threeFifths:"\u2157",threeEighths:"\u215C",fourFifths:"\u2158",fiveSixths:"\u215A",fiveEighths:"\u215D",sevenEighths:"\u215E",line:"\u2500",lineBold:"\u2501",lineDouble:"\u2550",lineDashed0:"\u2504",lineDashed1:"\u2505",lineDashed2:"\u2508",lineDashed3:"\u2509",lineDashed4:"\u254C",lineDashed5:"\u254D",lineDashed6:"\u2574",lineDashed7:"\u2576",lineDashed8:"\u2578",lineDashed9:"\u257A",lineDashed10:"\u257C",lineDashed11:"\u257E",lineDashed12:"\u2212",lineDashed13:"\u2013",lineDashed14:"\u2010",lineDashed15:"\u2043",lineVertical:"\u2502",lineVerticalBold:"\u2503",lineVerticalDouble:"\u2551",lineVerticalDashed0:"\u2506",lineVerticalDashed1:"\u2507",lineVerticalDashed2:"\u250A",lineVerticalDashed3:"\u250B",lineVerticalDashed4:"\u254E",lineVerticalDashed5:"\u254F",lineVerticalDashed6:"\u2575",lineVerticalDashed7:"\u2577",lineVerticalDashed8:"\u2579",lineVerticalDashed9:"\u257B",lineVerticalDashed10:"\u257D",lineVerticalDashed11:"\u257F",lineDownLeft:"\u2510",lineDownLeftArc:"\u256E",lineDownBoldLeftBold:"\u2513",lineDownBoldLeft:"\u2512",lineDownLeftBold:"\u2511",lineDownDoubleLeftDouble:"\u2557",lineDownDoubleLeft:"\u2556",lineDownLeftDouble:"\u2555",lineDownRight:"\u250C",lineDownRightArc:"\u256D",lineDownBoldRightBold:"\u250F",lineDownBoldRight:"\u250E",lineDownRightBold:"\u250D",lineDownDoubleRightDouble:"\u2554",lineDownDoubleRight:"\u2553",lineDownRightDouble:"\u2552",lineUpLeft:"\u2518",lineUpLeftArc:"\u256F",lineUpBoldLeftBold:"\u251B",lineUpBoldLeft:"\u251A",lineUpLeftBold:"\u2519",lineUpDoubleLeftDouble:"\u255D",lineUpDoubleLeft:"\u255C",lineUpLeftDouble:"\u255B",lineUpRight:"\u2514",lineUpRightArc:"\u2570",lineUpBoldRightBold:"\u2517",lineUpBoldRight:"\u2516",lineUpRightBold:"\u2515",lineUpDoubleRightDouble:"\u255A",lineUpDoubleRight:"\u2559",lineUpRightDouble:"\u2558",lineUpDownLeft:"\u2524",lineUpBoldDownBoldLeftBold:"\u252B",lineUpBoldDownBoldLeft:"\u2528",lineUpDownLeftBold:"\u2525",lineUpBoldDownLeftBold:"\u2529",lineUpDownBoldLeftBold:"\u252A",lineUpDownBoldLeft:"\u2527",lineUpBoldDownLeft:"\u2526",lineUpDoubleDownDoubleLeftDouble:"\u2563",lineUpDoubleDownDoubleLeft:"\u2562",lineUpDownLeftDouble:"\u2561",lineUpDownRight:"\u251C",lineUpBoldDownBoldRightBold:"\u2523",lineUpBoldDownBoldRight:"\u2520",lineUpDownRightBold:"\u251D",lineUpBoldDownRightBold:"\u2521",lineUpDownBoldRightBold:"\u2522",lineUpDownBoldRight:"\u251F",lineUpBoldDownRight:"\u251E",lineUpDoubleDownDoubleRightDouble:"\u2560",lineUpDoubleDownDoubleRight:"\u255F",lineUpDownRightDouble:"\u255E",lineDownLeftRight:"\u252C",lineDownBoldLeftBoldRightBold:"\u2533",lineDownLeftBoldRightBold:"\u252F",lineDownBoldLeftRight:"\u2530",lineDownBoldLeftBoldRight:"\u2531",lineDownBoldLeftRightBold:"\u2532",lineDownLeftRightBold:"\u252E",lineDownLeftBoldRight:"\u252D",lineDownDoubleLeftDoubleRightDouble:"\u2566",lineDownDoubleLeftRight:"\u2565",lineDownLeftDoubleRightDouble:"\u2564",lineUpLeftRight:"\u2534",lineUpBoldLeftBoldRightBold:"\u253B",lineUpLeftBoldRightBold:"\u2537",lineUpBoldLeftRight:"\u2538",lineUpBoldLeftBoldRight:"\u2539",lineUpBoldLeftRightBold:"\u253A",lineUpLeftRightBold:"\u2536",lineUpLeftBoldRight:"\u2535",lineUpDoubleLeftDoubleRightDouble:"\u2569",lineUpDoubleLeftRight:"\u2568",lineUpLeftDoubleRightDouble:"\u2567",lineUpDownLeftRight:"\u253C",lineUpBoldDownBoldLeftBoldRightBold:"\u254B",lineUpDownBoldLeftBoldRightBold:"\u2548",lineUpBoldDownLeftBoldRightBold:"\u2547",lineUpBoldDownBoldLeftRightBold:"\u254A",lineUpBoldDownBoldLeftBoldRight:"\u2549",lineUpBoldDownLeftRight:"\u2540",lineUpDownBoldLeftRight:"\u2541",lineUpDownLeftBoldRight:"\u253D",lineUpDownLeftRightBold:"\u253E",lineUpBoldDownBoldLeftRight:"\u2542",lineUpDownLeftBoldRightBold:"\u253F",lineUpBoldDownLeftBoldRight:"\u2543",lineUpBoldDownLeftRightBold:"\u2544",lineUpDownBoldLeftBoldRight:"\u2545",lineUpDownBoldLeftRightBold:"\u2546",lineUpDoubleDownDoubleLeftDoubleRightDouble:"\u256C",lineUpDoubleDownDoubleLeftRight:"\u256B",lineUpDownLeftDoubleRightDouble:"\u256A",lineCross:"\u2573",lineBackslash:"\u2572",lineSlash:"\u2571"},Ua={tick:"\u2714",info:"\u2139",warning:"\u26A0",cross:"\u2718",squareSmall:"\u25FB",squareSmallFilled:"\u25FC",circle:"\u25EF",circleFilled:"\u25C9",circleDotted:"\u25CC",circleDouble:"\u25CE",circleCircle:"\u24DE",circleCross:"\u24E7",circlePipe:"\u24BE",radioOn:"\u25C9",radioOff:"\u25EF",checkboxOn:"\u2612",checkboxOff:"\u2610",checkboxCircleOn:"\u24E7",checkboxCircleOff:"\u24BE",pointer:"\u276F",triangleUpOutline:"\u25B3",triangleLeft:"\u25C0",triangleRight:"\u25B6",lozenge:"\u25C6",lozengeOutline:"\u25C7",hamburger:"\u2630",smiley:"\u32E1",mustache:"\u0DF4",star:"\u2605",play:"\u25B6",nodejs:"\u2B22",oneSeventh:"\u2150",oneNinth:"\u2151",oneTenth:"\u2152"},hf={tick:"\u221A",info:"i",warning:"\u203C",cross:"\xD7",squareSmall:"\u25A1",squareSmallFilled:"\u25A0",circle:"( )",circleFilled:"(*)",circleDotted:"( )",circleDouble:"( )",circleCircle:"(\u25CB)",circleCross:"(\xD7)",circlePipe:"(\u2502)",radioOn:"(*)",radioOff:"( )",checkboxOn:"[\xD7]",checkboxOff:"[ ]",checkboxCircleOn:"(\xD7)",checkboxCircleOff:"( )",pointer:">",triangleUpOutline:"\u2206",triangleLeft:"\u25C4",triangleRight:"\u25BA",lozenge:"\u2666",lozengeOutline:"\u25CA",hamburger:"\u2261",smiley:"\u263A",mustache:"\u250C\u2500\u2510",star:"\u2736",play:"\u25BA",nodejs:"\u2666",oneSeventh:"1/7",oneNinth:"1/9",oneTenth:"1/10"},yf={...Fa,...Ua},ff={...Fa,...hf},gf=Jn(),_f=gf?yf:ff,Ir=_f,Hv=Object.entries(Ua);import bf from"tty";var xf=bf?.WriteStream?.prototype?.hasColors?.()??!1,k=(e,t)=>{if(!xf)return n=>n;let r=`\x1B[${e}m`,i=`\x1B[${t}m`;return n=>{let s=n+"",o=s.indexOf(i);if(o===-1)return r+s+i;let a=r,c=0,p=(t===22?i:"")+r;for(;o!==-1;)a+=s.slice(c,o)+p,c=o+i.length,o=s.indexOf(i,c);return a+=s.slice(c)+i,a}},Jv=k(0,0),Ba=k(1,22),Xv=k(2,22),Qv=k(3,23),Zv=k(4,24),eq=k(53,55),tq=k(7,27),rq=k(8,28),iq=k(9,29),nq=k(30,39),sq=k(31,39),oq=k(32,39),aq=k(33,39),cq=k(34,39),pq=k(35,39),dq=k(36,39),uq=k(37,39),Rr=k(90,39),lq=k(40,49),mq=k(41,49),hq=k(42,49),yq=k(43,49),fq=k(44,49),gq=k(45,49),_q=k(46,49),bq=k(47,49),xq=k(100,49),Na=k(91,39),wq=k(92,39),Ga=k(93,39),kq=k(94,39),Sq=k(95,39),vq=k(96,39),qq=k(97,39),$q=k(101,49),Cq=k(102,49),Aq=k(103,49),Eq=k(104,49),Tq=k(105,49),Pq=k(106,49),Oq=k(107,49);var Wa=({type:e,message:t,timestamp:r,piped:i,commandId:n,result:{failed:s=!1}={},options:{reject:o=!0}})=>{let a=wf(r),c=kf[e]({failed:s,reject:o,piped:i}),d=Sf[e]({reject:o});return`${Rr(`[${a}]`)} ${Rr(`[${n}]`)} ${d(c)} ${d(t)}`},wf=e=>`${jr(e.getHours(),2)}:${jr(e.getMinutes(),2)}:${jr(e.getSeconds(),2)}.${jr(e.getMilliseconds(),3)}`,jr=(e,t)=>String(e).padStart(t,"0"),za=({failed:e,reject:t})=>e?t?Ir.cross:Ir.warning:Ir.tick,kf={command:({piped:e})=>e?"|":"$",output:()=>" ",ipc:()=>"*",error:za,duration:za},Va=e=>e,Sf={command:()=>Ba,output:()=>Va,ipc:()=>Va,error:({reject:e})=>e?Na:Ga,duration:()=>Rr};var Ha=(e,t,r)=>{let i=ja(t,r);return e.map(({verboseLine:n,verboseObject:s})=>vf(n,s,i)).filter(n=>n!==void 0).map(n=>qf(n)).join("")},vf=(e,t,r)=>{if(r===void 0)return e;let i=r(e,t);if(typeof i=="string")return i},qf=e=>e.endsWith(`
|
|
106
40
|
`)?e:`${e}
|
|
107
|
-
`;var
|
|
108
|
-
`).map(r=>
|
|
109
|
-
${
|
|
110
|
-
${
|
|
111
|
-
${
|
|
112
|
-
Available signal numbers: ${
|
|
41
|
+
`;var ke=({type:e,verboseMessage:t,fdNumber:r,verboseInfo:i,result:n})=>{let s=Cf({type:e,result:n,verboseInfo:i}),o=Af(t,s),a=Ha(o,i,r);a!==""&&console.warn(a.slice(0,-1))},Cf=({type:e,result:t,verboseInfo:{escapedCommand:r,commandId:i,rawOptions:{piped:n=!1,...s}}})=>({type:e,escapedCommand:r,commandId:`${i}`,timestamp:new Date,piped:n,result:t,options:s}),Af=(e,t)=>e.split(`
|
|
42
|
+
`).map(r=>Ef({...t,message:r})),Ef=e=>({verboseLine:Wa(e),verboseObject:e}),Dr=e=>{let t=typeof e=="string"?e:$f(e);return Vt(t).replaceAll(" "," ".repeat(Tf))},Tf=2;var Ka=(e,t)=>{bt(t)&&ke({type:"command",verboseMessage:e,verboseInfo:t})};var Ya=(e,t,r)=>{If(e);let i=Pf(e);return{verbose:e,escapedCommand:t,commandId:i,rawOptions:r}},Pf=e=>bt({verbose:e})?Of++:void 0,Of=0n,If=e=>{for(let t of e){if(t===!1)throw new TypeError(`The "verbose: false" option was renamed to "verbose: 'none'".`);if(t===!0)throw new TypeError(`The "verbose: true" option was renamed to "verbose: 'short'".`);if(!Or.includes(t)&&!Pr(t)){let r=Or.map(i=>`'${i}'`).join(", ");throw new TypeError(`The "verbose" option must not be ${t}. Allowed values are: ${r} or a function.`)}}};import{hrtime as Ja}from"process";var Lr=()=>Ja.bigint(),Xn=e=>Number(Ja.bigint()-e)/1e6;var Mr=(e,t,r)=>{let i=Lr(),{command:n,escapedCommand:s}=Da(e,t),o=Wn(r,"verbose"),a=Ya(o,s,{...r});return Ka(s,a),{command:n,escapedCommand:s,startTime:i,verboseInfo:a}};var Yp=B(Mc(),1);import f_ from"path";import Kp from"process";import Nr from"process";import rt from"path";function Ur(e={}){let{env:t=process.env,platform:r=process.platform}=e;return r!=="win32"?"PATH":Object.keys(t).reverse().find(i=>i.toUpperCase()==="PATH")||"Path"}import{promisify as og}from"util";import{execFile as ag,execFileSync as x$}from"child_process";import Fc from"path";import{fileURLToPath as cg}from"url";var S$=og(ag);function Br(e){return e instanceof URL?cg(e):e}function Uc(e){return{*[Symbol.iterator](){let t=Fc.resolve(Br(e)),r;for(;r!==t;)yield t,r=t,t=Fc.resolve(t,"..")}}}var v$=10*1024*1024;var pg=({cwd:e=Nr.cwd(),path:t=Nr.env[Ur()],preferLocal:r=!0,execPath:i=Nr.execPath,addExecPath:n=!0}={})=>{let s=rt.resolve(Br(e)),o=[],a=t.split(rt.delimiter);return r&&dg(o,a,s),n&&ug(o,a,i,s),t===""||t===rt.delimiter?`${o.join(rt.delimiter)}${t}`:[...o,t].join(rt.delimiter)},dg=(e,t,r)=>{for(let i of Uc(r)){let n=rt.join(i,"node_modules/.bin");t.includes(n)||e.push(n)}},ug=(e,t,r,i)=>{let n=rt.resolve(i,Br(r),"..");t.includes(n)||e.push(n)},Bc=({env:e=Nr.env,...t}={})=>{e={...e};let r=Ur({env:e});return t.path=e[r],e[r]=pg(t),e};import{setTimeout as $g}from"timers/promises";var Nc=(e,t,r)=>{let i=r?Ht:Wt,n=e instanceof ge?{}:{cause:e};return new i(t,n)},ge=class extends Error{},Gc=(e,t)=>{Object.defineProperty(e.prototype,"name",{value:t,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,Vc,{value:!0,writable:!1,enumerable:!1,configurable:!1})},zc=e=>Gr(e)&&Vc in e,Vc=Symbol("isExecaError"),Gr=e=>Object.prototype.toString.call(e)==="[object Error]",Wt=class extends Error{};Gc(Wt,Wt.name);var Ht=class extends Error{};Gc(Ht,Ht.name);import{constants as Kt}from"os";import{constants as yg}from"os";var Wc=()=>{let e=Kc-Hc+1;return Array.from({length:e},lg)},lg=(e,t)=>({name:`SIGRT${t+1}`,number:Hc+t,action:"terminate",description:"Application-specific signal (realtime)",standard:"posix"}),Hc=34,Kc=64;import{constants as mg}from"os";var Yc=[{name:"SIGHUP",number:1,action:"terminate",description:"Terminal closed",standard:"posix"},{name:"SIGINT",number:2,action:"terminate",description:"User interruption with CTRL-C",standard:"ansi"},{name:"SIGQUIT",number:3,action:"core",description:"User interruption with CTRL-\\",standard:"posix"},{name:"SIGILL",number:4,action:"core",description:"Invalid machine instruction",standard:"ansi"},{name:"SIGTRAP",number:5,action:"core",description:"Debugger breakpoint",standard:"posix"},{name:"SIGABRT",number:6,action:"core",description:"Aborted",standard:"ansi"},{name:"SIGIOT",number:6,action:"core",description:"Aborted",standard:"bsd"},{name:"SIGBUS",number:7,action:"core",description:"Bus error due to misaligned, non-existing address or paging error",standard:"bsd"},{name:"SIGEMT",number:7,action:"terminate",description:"Command should be emulated but is not implemented",standard:"other"},{name:"SIGFPE",number:8,action:"core",description:"Floating point arithmetic error",standard:"ansi"},{name:"SIGKILL",number:9,action:"terminate",description:"Forced termination",standard:"posix",forced:!0},{name:"SIGUSR1",number:10,action:"terminate",description:"Application-specific signal",standard:"posix"},{name:"SIGSEGV",number:11,action:"core",description:"Segmentation fault",standard:"ansi"},{name:"SIGUSR2",number:12,action:"terminate",description:"Application-specific signal",standard:"posix"},{name:"SIGPIPE",number:13,action:"terminate",description:"Broken pipe or socket",standard:"posix"},{name:"SIGALRM",number:14,action:"terminate",description:"Timeout or timer",standard:"posix"},{name:"SIGTERM",number:15,action:"terminate",description:"Termination",standard:"ansi"},{name:"SIGSTKFLT",number:16,action:"terminate",description:"Stack is empty or overflowed",standard:"other"},{name:"SIGCHLD",number:17,action:"ignore",description:"Child process terminated, paused or unpaused",standard:"posix"},{name:"SIGCLD",number:17,action:"ignore",description:"Child process terminated, paused or unpaused",standard:"other"},{name:"SIGCONT",number:18,action:"unpause",description:"Unpaused",standard:"posix",forced:!0},{name:"SIGSTOP",number:19,action:"pause",description:"Paused",standard:"posix",forced:!0},{name:"SIGTSTP",number:20,action:"pause",description:'Paused using CTRL-Z or "suspend"',standard:"posix"},{name:"SIGTTIN",number:21,action:"pause",description:"Background process cannot read terminal input",standard:"posix"},{name:"SIGBREAK",number:21,action:"terminate",description:"User interruption with CTRL-BREAK",standard:"other"},{name:"SIGTTOU",number:22,action:"pause",description:"Background process cannot write to terminal output",standard:"posix"},{name:"SIGURG",number:23,action:"ignore",description:"Socket received out-of-band data",standard:"bsd"},{name:"SIGXCPU",number:24,action:"core",description:"Process timed out",standard:"bsd"},{name:"SIGXFSZ",number:25,action:"core",description:"File too big",standard:"bsd"},{name:"SIGVTALRM",number:26,action:"terminate",description:"Timeout or timer",standard:"bsd"},{name:"SIGPROF",number:27,action:"terminate",description:"Timeout or timer",standard:"bsd"},{name:"SIGWINCH",number:28,action:"ignore",description:"Terminal window size changed",standard:"bsd"},{name:"SIGIO",number:29,action:"terminate",description:"I/O is available",standard:"other"},{name:"SIGPOLL",number:29,action:"terminate",description:"Watched event",standard:"other"},{name:"SIGINFO",number:29,action:"ignore",description:"Request for process information",standard:"other"},{name:"SIGPWR",number:30,action:"terminate",description:"Device running out of power",standard:"systemv"},{name:"SIGSYS",number:31,action:"core",description:"Invalid system call",standard:"other"},{name:"SIGUNUSED",number:31,action:"terminate",description:"Invalid system call",standard:"other"}];var as=()=>{let e=Wc();return[...Yc,...e].map(hg)},hg=({name:e,number:t,description:r,action:i,forced:n=!1,standard:s})=>{let{signals:{[e]:o}}=mg,a=o!==void 0;return{name:e,number:a?o:t,description:r,supported:a,action:i,forced:n,standard:s}};var fg=()=>{let e=as();return Object.fromEntries(e.map(gg))},gg=({name:e,number:t,description:r,supported:i,action:n,forced:s,standard:o})=>[e,{name:e,number:t,description:r,supported:i,action:n,forced:s,standard:o}],Jc=fg(),_g=()=>{let e=as(),t=65,r=Array.from({length:t},(i,n)=>bg(n,e));return Object.assign({},...r)},bg=(e,t)=>{let r=xg(e,t);if(r===void 0)return{};let{name:i,description:n,supported:s,action:o,forced:a,standard:c}=r;return{[e]:{name:i,number:e,description:n,supported:s,action:o,forced:a,standard:c}}},xg=(e,t)=>{let r=t.find(({name:i})=>yg.signals[i]===e);return r!==void 0?r:t.find(i=>i.number===e)},B$=_g();var Qc=e=>{let t="option `killSignal`";if(e===0)throw new TypeError(`Invalid ${t}: 0 cannot be used.`);return ep(e,t)},Zc=e=>e===0?e:ep(e,"`subprocess.kill()`'s argument"),ep=(e,t)=>{if(Number.isInteger(e))return wg(e,t);if(typeof e=="string")return Sg(e,t);throw new TypeError(`Invalid ${t} ${String(e)}: it must be a string or an integer.
|
|
43
|
+
${cs()}`)},wg=(e,t)=>{if(Xc.has(e))return Xc.get(e);throw new TypeError(`Invalid ${t} ${e}: this signal integer does not exist.
|
|
44
|
+
${cs()}`)},kg=()=>new Map(Object.entries(Kt.signals).reverse().map(([e,t])=>[t,e])),Xc=kg(),Sg=(e,t)=>{if(e in Kt.signals)return e;throw e.toUpperCase()in Kt.signals?new TypeError(`Invalid ${t} '${e}': please rename it to '${e.toUpperCase()}'.`):new TypeError(`Invalid ${t} '${e}': this signal name does not exist.
|
|
45
|
+
${cs()}`)},cs=()=>`Available signal names: ${vg()}.
|
|
46
|
+
Available signal numbers: ${qg()}.`,vg=()=>Object.keys(Kt.signals).sort().map(e=>`'${e}'`).join(", "),qg=()=>[...new Set(Object.values(Kt.signals).sort((e,t)=>e-t))].join(", "),zr=e=>Jc[e].description;var tp=e=>{if(e===!1)return e;if(e===!0)return Cg;if(!Number.isFinite(e)||e<0)throw new TypeError(`Expected the \`forceKillAfterDelay\` option to be a non-negative integer, got \`${e}\` (${typeof e})`);return e},Cg=1e3*5,rp=({kill:e,options:{forceKillAfterDelay:t,killSignal:r},onInternalError:i,context:n,controller:s},o,a)=>{let{signal:c,error:d}=Ag(o,a,r);Eg(d,i);let p=e(c);return Tg({kill:e,signal:c,forceKillAfterDelay:t,killSignal:r,killResult:p,context:n,controller:s}),p},Ag=(e,t,r)=>{let[i=r,n]=Gr(e)?[void 0,e]:[e,t];if(typeof i!="string"&&!Number.isInteger(i))throw new TypeError(`The first argument must be an error instance or a signal name string/integer: ${String(i)}`);if(n!==void 0&&!Gr(n))throw new TypeError(`The second argument is optional. If specified, it must be an error instance: ${n}`);return{signal:Zc(i),error:n}},Eg=(e,t)=>{e!==void 0&&t.reject(e)},Tg=async({kill:e,signal:t,forceKillAfterDelay:r,killSignal:i,killResult:n,context:s,controller:o})=>{t===i&&n&&ps({kill:e,forceKillAfterDelay:r,context:s,controllerSignal:o.signal})},ps=async({kill:e,forceKillAfterDelay:t,context:r,controllerSignal:i})=>{if(t!==!1)try{await $g(t,void 0,{signal:i}),e("SIGKILL")&&(r.isForcefullyTerminated??=!0)}catch{}};import{once as Pg}from"events";var Vr=async(e,t)=>{e.aborted||await Pg(e,"abort",{signal:t})};var ip=({cancelSignal:e})=>{if(e!==void 0&&Object.prototype.toString.call(e)!=="[object AbortSignal]")throw new Error(`The \`cancelSignal\` option must be an AbortSignal: ${String(e)}`)},np=({subprocess:e,cancelSignal:t,gracefulCancel:r,context:i,controller:n})=>t===void 0||r?[]:[Og(e,t,i,n)],Og=async(e,t,r,{signal:i})=>{throw await Vr(t,i),r.terminationReason??="cancel",e.kill(),t.reason};import{scheduler as Zg}from"timers/promises";import{promisify as Jg}from"util";var St=({methodName:e,isSubprocess:t,ipc:r,isConnected:i})=>{Ig(e,t,r),ds(e,t,i)},Ig=(e,t,r)=>{if(!r)throw new Error(`${_e(e,t)} can only be used if the \`ipc\` option is \`true\`.`)},ds=(e,t,r)=>{if(!r)throw new Error(`${_e(e,t)} cannot be used: the ${ze(t)} has already exited or disconnected.`)},sp=e=>{throw new Error(`${_e("getOneMessage",e)} could not complete: the ${ze(e)} exited or disconnected.`)},op=e=>{throw new Error(`${_e("sendMessage",e)} failed: the ${ze(e)} is sending a message too, instead of listening to incoming messages.
|
|
113
47
|
This can be fixed by both sending a message and listening to incoming messages at the same time:
|
|
114
48
|
|
|
115
49
|
const [receivedMessage] = await Promise.all([
|
|
116
|
-
${
|
|
117
|
-
${
|
|
118
|
-
]);`)},
|
|
119
|
-
It must be ${
|
|
120
|
-
It is optional and defaults to "${
|
|
121
|
-
Please set the "stdio" option to ensure that file descriptor exists.`);if(
|
|
122
|
-
Please set this option with "pipe" instead.`},
|
|
123
|
-
Please rename it to ${
|
|
124
|
-
Please rename it to one of: ${r}.`)},
|
|
125
|
-
${e.message}`,e}},
|
|
126
|
-
${
|
|
50
|
+
${_e("getOneMessage",e)},
|
|
51
|
+
${_e("sendMessage",e,"message, {strict: true}")},
|
|
52
|
+
]);`)},Wr=(e,t)=>new Error(`${_e("sendMessage",t)} failed when sending an acknowledgment response to the ${ze(t)}.`,{cause:e}),ap=e=>{throw new Error(`${_e("sendMessage",e)} failed: the ${ze(e)} is not listening to incoming messages.`)},cp=e=>{throw new Error(`${_e("sendMessage",e)} failed: the ${ze(e)} exited without listening to incoming messages.`)},pp=()=>new Error(`\`cancelSignal\` aborted: the ${ze(!0)} disconnected.`),dp=()=>{throw new Error("`getCancelSignal()` cannot be used without setting the `cancelSignal` subprocess option.")},up=({error:e,methodName:t,isSubprocess:r})=>{if(e.code==="EPIPE")throw new Error(`${_e(t,r)} cannot be used: the ${ze(r)} is disconnecting.`,{cause:e})},lp=({error:e,methodName:t,isSubprocess:r,message:i})=>{if(Rg(e))throw new Error(`${_e(t,r)}'s argument type is invalid: the message cannot be serialized: ${String(i)}.`,{cause:e})},Rg=({code:e,message:t})=>jg.has(e)||Dg.some(r=>t.includes(r)),jg=new Set(["ERR_MISSING_ARGS","ERR_INVALID_ARG_TYPE"]),Dg=["could not be cloned","circular structure","call stack size exceeded"],_e=(e,t,r="")=>e==="cancelSignal"?"`cancelSignal`'s `controller.abort()`":`${Lg(t)}${e}(${r})`,Lg=e=>e?"":"subprocess.",ze=e=>e?"parent process":"subprocess",vt=e=>{e.connected&&e.disconnect()};var Se=()=>{let e={},t=new Promise((r,i)=>{Object.assign(e,{resolve:r,reject:i})});return Object.assign(t,e)};var Kr=(e,t="stdin")=>{let{options:i,fileDescriptors:n}=ve.get(e),s=mp(n,t,!0),o=e.stdio[s];if(o===null)throw new TypeError(hp(s,t,i,!0));return o},qt=(e,t="stdout")=>{let{options:i,fileDescriptors:n}=ve.get(e),s=mp(n,t,!1),o=s==="all"?e.all:e.stdio[s];if(o==null)throw new TypeError(hp(s,t,i,!1));return o},ve=new WeakMap,mp=(e,t,r)=>{let i=Mg(t,r);return Fg(i,t,r,e),i},Mg=(e,t)=>{let r=Hn(e);if(r!==void 0)return r;let{validOptions:i,defaultValue:n}=t?{validOptions:'"stdin"',defaultValue:"stdin"}:{validOptions:'"stdout", "stderr", "all"',defaultValue:"stdout"};throw new TypeError(`"${Yt(t)}" must not be "${e}".
|
|
53
|
+
It must be ${i} or "fd3", "fd4" (and so on).
|
|
54
|
+
It is optional and defaults to "${n}".`)},Fg=(e,t,r,i)=>{let n=i[yp(e)];if(n===void 0)throw new TypeError(`"${Yt(r)}" must not be ${t}. That file descriptor does not exist.
|
|
55
|
+
Please set the "stdio" option to ensure that file descriptor exists.`);if(n.direction==="input"&&!r)throw new TypeError(`"${Yt(r)}" must not be ${t}. It must be a readable stream, not writable.`);if(n.direction!=="input"&&r)throw new TypeError(`"${Yt(r)}" must not be ${t}. It must be a writable stream, not readable.`)},hp=(e,t,r,i)=>{if(e==="all"&&!r.all)return`The "all" option must be true to use "from: 'all'".`;let{optionName:n,optionValue:s}=Ug(e,r);return`The "${n}: ${Hr(s)}" option is incompatible with using "${Yt(i)}: ${Hr(t)}".
|
|
56
|
+
Please set this option with "pipe" instead.`},Ug=(e,{stdin:t,stdout:r,stderr:i,stdio:n})=>{let s=yp(e);return s===0&&t!==void 0?{optionName:"stdin",optionValue:t}:s===1&&r!==void 0?{optionName:"stdout",optionValue:r}:s===2&&i!==void 0?{optionName:"stderr",optionValue:i}:{optionName:`stdio[${s}]`,optionValue:n[s]}},yp=e=>e==="all"?1:e,Yt=e=>e?"to":"from",Hr=e=>typeof e=="string"?`'${e}'`:typeof e=="number"?`${e}`:"Stream";import{once as Wg}from"events";import{addAbortListener as Bg}from"events";var it=(e,t,r)=>{let i=e.getMaxListeners();i===0||i===Number.POSITIVE_INFINITY||(e.setMaxListeners(i+t),Bg(r,()=>{e.setMaxListeners(e.getMaxListeners()-t)}))};import{EventEmitter as zg}from"events";import{once as Ng}from"events";import{scheduler as Gg}from"timers/promises";var Yr=(e,t)=>{t&&us(e)},us=e=>{e.refCounted()},Jr=(e,t)=>{t&&ls(e)},ls=e=>{e.unrefCounted()},fp=(e,t)=>{t&&(ls(e),ls(e))},gp=(e,t)=>{t&&(us(e),us(e))};var _p=async({anyProcess:e,channel:t,isSubprocess:r,ipcEmitter:i},n)=>{if(wp(n)||Sp(n))return;Xr.has(e)||Xr.set(e,[]);let s=Xr.get(e);if(s.push(n),!(s.length>1))for(;s.length>0;){await kp(e,i,n),await Gg.yield();let o=await xp({wrappedMessage:s[0],anyProcess:e,channel:t,isSubprocess:r,ipcEmitter:i});s.shift(),i.emit("message",o),i.emit("message:done")}},bp=async({anyProcess:e,channel:t,isSubprocess:r,ipcEmitter:i,boundOnMessage:n})=>{ms();let s=Xr.get(e);for(;s?.length>0;)await Ng(i,"message:done");e.removeListener("message",n),gp(t,r),i.connected=!1,i.emit("disconnect")},Xr=new WeakMap;var Ve=(e,t,r)=>{if(Qr.has(e))return Qr.get(e);let i=new zg;return i.connected=!0,Qr.set(e,i),Vg({ipcEmitter:i,anyProcess:e,channel:t,isSubprocess:r}),i},Qr=new WeakMap,Vg=({ipcEmitter:e,anyProcess:t,channel:r,isSubprocess:i})=>{let n=_p.bind(void 0,{anyProcess:t,channel:r,isSubprocess:i,ipcEmitter:e});t.on("message",n),t.once("disconnect",bp.bind(void 0,{anyProcess:t,channel:r,isSubprocess:i,ipcEmitter:e,boundOnMessage:n})),fp(r,i)},Zr=e=>{let t=Qr.get(e);return t===void 0?e.channel!==null:t.connected};var vp=({anyProcess:e,channel:t,isSubprocess:r,message:i,strict:n})=>{if(!n)return i;let s=Ve(e,t,r),o=ri(e,s);return{id:Hg++,type:ti,message:i,hasListeners:o}},Hg=0n,qp=(e,t)=>{if(!(t?.type!==ti||t.hasListeners))for(let{id:r}of e)r!==void 0&&ei[r].resolve({isDeadlock:!0,hasListeners:!1})},xp=async({wrappedMessage:e,anyProcess:t,channel:r,isSubprocess:i,ipcEmitter:n})=>{if(e?.type!==ti||!t.connected)return e;let{id:s,message:o}=e,a={id:s,type:Cp,message:ri(t,n)};try{await ii({anyProcess:t,channel:r,isSubprocess:i,ipc:!0},a)}catch(c){n.emit("strict:error",c)}return o},wp=e=>{if(e?.type!==Cp)return!1;let{id:t,message:r}=e;return ei[t]?.resolve({isDeadlock:!1,hasListeners:r}),!0},$p=async(e,t,r)=>{if(e?.type!==ti)return;let i=Se();ei[e.id]=i;let n=new AbortController;try{let{isDeadlock:s,hasListeners:o}=await Promise.race([i,Kg(t,r,n)]);s&&op(r),o||ap(r)}finally{n.abort(),delete ei[e.id]}},ei={},Kg=async(e,t,{signal:r})=>{it(e,1,r),await Wg(e,"disconnect",{signal:r}),cp(t)},ti="execa:ipc:request",Cp="execa:ipc:response";var Ap=(e,t,r)=>{Jt.has(e)||Jt.set(e,new Set);let i=Jt.get(e),n=Se(),s=r?t.id:void 0,o={onMessageSent:n,id:s};return i.add(o),{outgoingMessages:i,outgoingMessage:o}},Ep=({outgoingMessages:e,outgoingMessage:t})=>{e.delete(t),t.onMessageSent.resolve()},kp=async(e,t,r)=>{for(;!ri(e,t)&&Jt.get(e)?.size>0;){let i=[...Jt.get(e)];qp(i,r),await Promise.all(i.map(({onMessageSent:n})=>n))}},Jt=new WeakMap,ri=(e,t)=>t.listenerCount("message")>Yg(e),Yg=e=>ve.has(e)&&!Le(ve.get(e).options.buffer,"ipc")?1:0;var ii=({anyProcess:e,channel:t,isSubprocess:r,ipc:i},n,{strict:s=!1}={})=>{let o="sendMessage";return St({methodName:o,isSubprocess:r,ipc:i,isConnected:e.connected}),Xg({anyProcess:e,channel:t,methodName:o,isSubprocess:r,message:n,strict:s})},Xg=async({anyProcess:e,channel:t,methodName:r,isSubprocess:i,message:n,strict:s})=>{let o=vp({anyProcess:e,channel:t,isSubprocess:i,message:n,strict:s}),a=Ap(e,o,s);try{await ys({anyProcess:e,methodName:r,isSubprocess:i,wrappedMessage:o,message:n})}catch(c){throw vt(e),c}finally{Ep(a)}},ys=async({anyProcess:e,methodName:t,isSubprocess:r,wrappedMessage:i,message:n})=>{let s=Qg(e);try{await Promise.all([$p(i,e,r),s(i)])}catch(o){throw up({error:o,methodName:t,isSubprocess:r}),lp({error:o,methodName:t,isSubprocess:r,message:n}),o}},Qg=e=>{if(hs.has(e))return hs.get(e);let t=Jg(e.send.bind(e));return hs.set(e,t),t},hs=new WeakMap;var Pp=(e,t)=>{let r="cancelSignal";return ds(r,!1,e.connected),ys({anyProcess:e,methodName:r,isSubprocess:!1,wrappedMessage:{type:Ip,message:t},message:t})},Op=async({anyProcess:e,channel:t,isSubprocess:r,ipc:i})=>(await e_({anyProcess:e,channel:t,isSubprocess:r,ipc:i}),fs.signal),e_=async({anyProcess:e,channel:t,isSubprocess:r,ipc:i})=>{if(!Tp){if(Tp=!0,!i){dp();return}if(t===null){ms();return}Ve(e,t,r),await Zg.yield()}},Tp=!1,Sp=e=>e?.type!==Ip?!1:(fs.abort(e.message),!0),Ip="execa:ipc:cancel",ms=()=>{fs.abort(pp())},fs=new AbortController;var Rp=({gracefulCancel:e,cancelSignal:t,ipc:r,serialization:i})=>{if(e){if(t===void 0)throw new Error("The `cancelSignal` option must be defined when setting the `gracefulCancel` option.");if(!r)throw new Error("The `ipc` option cannot be false when setting the `gracefulCancel` option.");if(i==="json")throw new Error("The `serialization` option cannot be 'json' when setting the `gracefulCancel` option.")}},jp=({subprocess:e,cancelSignal:t,gracefulCancel:r,forceKillAfterDelay:i,context:n,controller:s})=>r?[t_({subprocess:e,cancelSignal:t,forceKillAfterDelay:i,context:n,controller:s})]:[],t_=async({subprocess:e,cancelSignal:t,forceKillAfterDelay:r,context:i,controller:{signal:n}})=>{await Vr(t,n);let s=r_(t);throw await Pp(e,s),ps({kill:e.kill,forceKillAfterDelay:r,context:i,controllerSignal:n}),i.terminationReason??="gracefulCancel",t.reason},r_=({reason:e})=>{if(!(e instanceof DOMException))return e;let t=new Error(e.message);return Object.defineProperty(t,"stack",{value:e.stack,enumerable:!1,configurable:!0,writable:!0}),t};import{setTimeout as i_}from"timers/promises";var Dp=({timeout:e})=>{if(e!==void 0&&(!Number.isFinite(e)||e<0))throw new TypeError(`Expected the \`timeout\` option to be a non-negative integer, got \`${e}\` (${typeof e})`)},Lp=(e,t,r,i)=>t===0||t===void 0?[]:[n_(e,t,r,i)],n_=async(e,t,r,{signal:i})=>{throw await i_(t,void 0,{signal:i}),r.terminationReason??="timeout",e.kill(),new ge};import{execPath as s_,execArgv as o_}from"process";import Mp from"path";var Fp=({options:e})=>{if(e.node===!1)throw new TypeError('The "node" option cannot be false with `execaNode()`.');return{options:{...e,node:!0}}},Up=(e,t,{node:r=!1,nodePath:i=s_,nodeOptions:n=o_.filter(c=>!c.startsWith("--inspect")),cwd:s,execPath:o,...a})=>{if(o!==void 0)throw new TypeError('The "execPath" option has been removed. Please use the "nodePath" option instead.');let c=_t(i,'The "nodePath" option'),d=Mp.resolve(s,c),p={...a,nodePath:d,node:r,cwd:s};if(!r)return[e,t,p];if(Mp.basename(e,".exe")==="node")throw new TypeError('When the "node" option is true, the first argument does not need to be "node".');return[d,[...n,e,...t],{ipc:!0,...p,shell:!1}]};import{serialize as a_}from"v8";var Bp=({ipcInput:e,ipc:t,serialization:r})=>{if(e!==void 0){if(!t)throw new Error("The `ipcInput` option cannot be set unless the `ipc` option is `true`.");d_[r](e)}},c_=e=>{try{a_(e)}catch(t){throw new Error("The `ipcInput` option is not serializable with a structured clone.",{cause:t})}},p_=e=>{try{JSON.stringify(e)}catch(t){throw new Error("The `ipcInput` option is not serializable with JSON.",{cause:t})}},d_={advanced:c_,json:p_},Np=async(e,t)=>{t!==void 0&&await e.sendMessage(t)};var zp=({encoding:e})=>{if(gs.has(e))return;let t=l_(e);if(t!==void 0)throw new TypeError(`Invalid option \`encoding: ${ni(e)}\`.
|
|
57
|
+
Please rename it to ${ni(t)}.`);let r=[...gs].map(i=>ni(i)).join(", ");throw new TypeError(`Invalid option \`encoding: ${ni(e)}\`.
|
|
58
|
+
Please rename it to one of: ${r}.`)},u_=new Set(["utf8","utf16le"]),oe=new Set(["buffer","hex","base64","base64url","latin1","ascii"]),gs=new Set([...u_,...oe]),l_=e=>{if(e===null)return"buffer";if(typeof e!="string")return;let t=e.toLowerCase();if(t in Gp)return Gp[t];if(gs.has(t))return t},Gp={"utf-8":"utf8","utf-16le":"utf16le","ucs-2":"utf16le",ucs2:"utf16le",binary:"latin1"},ni=e=>typeof e=="string"?`"${e}"`:String(e);import{statSync as m_}from"fs";import h_ from"path";import y_ from"process";var Vp=(e=Wp())=>{let t=_t(e,'The "cwd" option');return h_.resolve(t)},Wp=()=>{try{return y_.cwd()}catch(e){throw e.message=`The current directory does not exist.
|
|
59
|
+
${e.message}`,e}},Hp=(e,t)=>{if(t===Wp())return e;let r;try{r=m_(t)}catch(i){return`The "cwd" option is invalid: ${t}.
|
|
60
|
+
${i.message}
|
|
127
61
|
${e}`}return r.isDirectory()?e:`The "cwd" option is not a directory: ${t}.
|
|
128
|
-
${e}`};var
|
|
129
|
-
`,
|
|
130
|
-
${
|
|
131
|
-
`)].map(
|
|
132
|
-
|
|
133
|
-
`);return{originalMessage:
|
|
134
|
-
`):eu(e),eu=e=>typeof e=="string"?e:V(e)?br(e):"";var on=({command:e,escapedCommand:t,stdio:r,all:n,ipcOutput:o,options:{cwd:i},startTime:s})=>ru({command:e,escapedCommand:t,cwd:i,durationMs:Mo(s),failed:!1,timedOut:!1,isCanceled:!1,isGracefullyCanceled:!1,isTerminated:!1,isMaxBuffer:!1,isForcefullyTerminated:!1,exitCode:0,stdout:r[1],stderr:r[2],all:n,stdio:r,ipcOutput:o,pipedFrom:[]}),ft=({error:e,command:t,escapedCommand:r,fileDescriptors:n,options:o,startTime:i,isSync:s})=>Nt({error:e,command:t,escapedCommand:r,startTime:i,timedOut:!1,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:!1,isForcefullyTerminated:!1,stdio:Array.from({length:n.length}),ipcOutput:[],options:o,isSync:s}),Nt=({error:e,command:t,escapedCommand:r,startTime:n,timedOut:o,isCanceled:i,isGracefullyCanceled:s,isMaxBuffer:a,isForcefullyTerminated:c,exitCode:u,signal:l,stdio:d,all:m,ipcOutput:p,options:{timeoutDuration:f,timeout:g=f,forceKillAfterDelay:w,killSignal:x,cwd:C,maxBuffer:v},isSync:A})=>{let{exitCode:E,signal:R,signalDescription:M}=Iy(u,l),{originalMessage:L,shortMessage:k,message:Q}=tu({stdio:d,all:m,ipcOutput:p,originalError:e,signal:R,signalDescription:M,exitCode:E,escapedCommand:r,timedOut:o,isCanceled:i,isGracefullyCanceled:s,isMaxBuffer:a,isForcefullyTerminated:c,forceKillAfterDelay:w,killSignal:x,maxBuffer:v,timeout:g,cwd:C}),N=Tc(e,Q,A);return Object.assign(N,Ay({error:N,command:t,escapedCommand:r,startTime:n,timedOut:o,isCanceled:i,isGracefullyCanceled:s,isMaxBuffer:a,isForcefullyTerminated:c,exitCode:E,signal:R,signalDescription:M,stdio:d,all:m,ipcOutput:p,cwd:C,originalMessage:L,shortMessage:k})),N},Ay=({error:e,command:t,escapedCommand:r,startTime:n,timedOut:o,isCanceled:i,isGracefullyCanceled:s,isMaxBuffer:a,isForcefullyTerminated:c,exitCode:u,signal:l,signalDescription:d,stdio:m,all:p,ipcOutput:f,cwd:g,originalMessage:w,shortMessage:x})=>ru({shortMessage:x,originalMessage:w,command:t,escapedCommand:r,cwd:g,durationMs:Mo(n),failed:!0,timedOut:o,isCanceled:i,isGracefullyCanceled:s,isTerminated:l!==void 0,isMaxBuffer:a,isForcefullyTerminated:c,exitCode:u,signal:l,signalDescription:d,code:e.cause?.code,stdout:m[1],stderr:m[2],all:p,stdio:m,ipcOutput:f,pipedFrom:[]}),ru=e=>Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0)),Iy=(e,t)=>{let r=e===null?void 0:e,n=t===null?void 0:t,o=n===void 0?void 0:Mr(t);return{exitCode:r,signal:n,signalDescription:o}};var nu=e=>Number.isFinite(e)?e:0;function Dy(e){return{days:Math.trunc(e/864e5),hours:Math.trunc(e/36e5%24),minutes:Math.trunc(e/6e4%60),seconds:Math.trunc(e/1e3%60),milliseconds:Math.trunc(e%1e3),microseconds:Math.trunc(nu(e*1e3)%1e3),nanoseconds:Math.trunc(nu(e*1e6)%1e3)}}function Ry(e){return{days:e/86400000n,hours:e/3600000n%24n,minutes:e/60000n%60n,seconds:e/1000n%60n,milliseconds:e%1000n,microseconds:0n,nanoseconds:0n}}function ii(e){switch(typeof e){case"number":{if(Number.isFinite(e))return Dy(e);break}case"bigint":return Ry(e)}throw new TypeError("Expected a finite number or bigint")}var My=e=>e===0||e===0n,Py=(e,t)=>t===1||t===1n?e:`${e}s`,Ly=1e-7,ky=24n*60n*60n*1000n;function si(e,t){let r=typeof e=="bigint";if(!r&&!Number.isFinite(e))throw new TypeError("Expected a finite number or bigint");t={...t};let n=e<0?"-":"";e=e<0?-e:e,t.colonNotation&&(t.compact=!1,t.formatSubMilliseconds=!1,t.separateMilliseconds=!1,t.verbose=!1),t.compact&&(t.unitCount=1,t.secondsDecimalDigits=0,t.millisecondsDecimalDigits=0);let o=[],i=(l,d)=>{let m=Math.floor(l*10**d+Ly);return(Math.round(m)/10**d).toFixed(d)},s=(l,d,m,p)=>{if(!((o.length===0||!t.colonNotation)&&My(l)&&!(t.colonNotation&&m==="m"))){if(p??=String(l),t.colonNotation){let f=p.includes(".")?p.split(".")[0].length:p.length,g=o.length>0?2:1;p="0".repeat(Math.max(0,g-f))+p}else p+=t.verbose?" "+Py(d,l):m;o.push(p)}},a=ii(e),c=BigInt(a.days);if(t.hideYearAndDays?s(BigInt(c)*24n+BigInt(a.hours),"hour","h"):(t.hideYear?s(c,"day","d"):(s(c/365n,"year","y"),s(c%365n,"day","d")),s(Number(a.hours),"hour","h")),s(Number(a.minutes),"minute","m"),!t.hideSeconds)if(t.separateMilliseconds||t.formatSubMilliseconds||!t.colonNotation&&e<1e3&&!t.subSecondsAsDecimals){let l=Number(a.seconds),d=Number(a.milliseconds),m=Number(a.microseconds),p=Number(a.nanoseconds);if(s(l,"second","s"),t.formatSubMilliseconds)s(d,"millisecond","ms"),s(m,"microsecond","\xB5s"),s(p,"nanosecond","ns");else{let f=d+m/1e3+p/1e6,g=typeof t.millisecondsDecimalDigits=="number"?t.millisecondsDecimalDigits:0,w=f>=1?Math.round(f):Math.ceil(f),x=g?f.toFixed(g):w;s(Number.parseFloat(x),"millisecond","ms",x)}}else{let l=(r?Number(e%ky):e)/1e3%60,d=typeof t.secondsDecimalDigits=="number"?t.secondsDecimalDigits:1,m=i(l,d),p=t.keepDecimalsOnWholeSeconds?m:m.replace(/\.0+$/,"");s(Number.parseFloat(p),"second","s",p)}if(o.length===0)return n+"0"+(t.verbose?" milliseconds":"ms");let u=t.colonNotation?":":" ";return typeof t.unitCount=="number"&&(o=o.slice(0,Math.max(t.unitCount,1))),n+o.join(u)}var ou=(e,t)=>{e.failed&&xe({type:"error",verboseMessage:e.shortMessage,verboseInfo:t,result:e})};var iu=(e,t)=>{it(t)&&(ou(e,t),Fy(e,t))},Fy=(e,t)=>{let r=`(done in ${si(e.durationMs)})`;xe({type:"duration",verboseMessage:r,verboseInfo:t,result:e})};var ht=(e,t,{reject:r})=>{if(iu(e,t),e.failed&&r)throw e;return e};import{readFileSync as Ru}from"fs";var cu=(e,t)=>Ke(e)?"asyncGenerator":du(e)?"generator":sn(e)?"fileUrl":Gy(e)?"filePath":Hy(e)?"webStream":he(e,{checkOpen:!1})?"native":V(e)?"uint8Array":zy(e)?"asyncIterable":qy(e)?"iterable":li(e)?lu({transform:e},t):By(e)?jy(e,t):"native",jy=(e,t)=>ti(e.transform,{checkOpen:!1})?Ny(e,t):li(e.transform)?lu(e,t):Uy(e,t),Ny=(e,t)=>(uu(e,t,"Duplex stream"),"duplex"),lu=(e,t)=>(uu(e,t,"web TransformStream"),"webTransform"),uu=({final:e,binary:t,objectMode:r},n,o)=>{su(e,`${n}.final`,o),su(t,`${n}.binary`,o),ai(r,`${n}.objectMode`)},su=(e,t,r)=>{if(e!==void 0)throw new TypeError(`The \`${t}\` option can only be defined when using a generator, not a ${r}.`)},Uy=({transform:e,final:t,binary:r,objectMode:n},o)=>{if(e!==void 0&&!au(e))throw new TypeError(`The \`${o}.transform\` option must be a generator, a Duplex stream or a web TransformStream.`);if(ti(t,{checkOpen:!1}))throw new TypeError(`The \`${o}.final\` option must not be a Duplex stream.`);if(li(t))throw new TypeError(`The \`${o}.final\` option must not be a web TransformStream.`);if(t!==void 0&&!au(t))throw new TypeError(`The \`${o}.final\` option must be a generator.`);return ai(r,`${o}.binary`),ai(n,`${o}.objectMode`),Ke(e)||Ke(t)?"asyncGenerator":"generator"},ai=(e,t)=>{if(e!==void 0&&typeof e!="boolean")throw new TypeError(`The \`${t}\` option must use a boolean.`)},au=e=>Ke(e)||du(e),Ke=e=>Object.prototype.toString.call(e)==="[object AsyncGeneratorFunction]",du=e=>Object.prototype.toString.call(e)==="[object GeneratorFunction]",By=e=>j(e)&&(e.transform!==void 0||e.final!==void 0),sn=e=>Object.prototype.toString.call(e)==="[object URL]",mu=e=>sn(e)&&e.protocol!=="file:",Gy=e=>j(e)&&Object.keys(e).length>0&&Object.keys(e).every(t=>Vy.has(t))&&ci(e.file),Vy=new Set(["file","append"]),ci=e=>typeof e=="string",pu=(e,t)=>e==="native"&&typeof t=="string"&&!Wy.has(t),Wy=new Set(["ipc","ignore","inherit","overlapped","pipe"]),fu=e=>Object.prototype.toString.call(e)==="[object ReadableStream]",an=e=>Object.prototype.toString.call(e)==="[object WritableStream]",Hy=e=>fu(e)||an(e),li=e=>fu(e?.readable)&&an(e?.writable),zy=e=>hu(e)&&typeof e[Symbol.asyncIterator]=="function",qy=e=>hu(e)&&typeof e[Symbol.iterator]=="function",hu=e=>typeof e=="object"&&e!==null,ce=new Set(["generator","asyncGenerator","duplex","webTransform"]),cn=new Set(["fileUrl","filePath","fileNumber"]),ui=new Set(["fileUrl","filePath"]),gu=new Set([...ui,"webStream","nodeStream"]),bu=new Set(["webTransform","duplex"]),Ue={generator:"a generator",asyncGenerator:"an async generator",fileUrl:"a file URL",filePath:"a file path string",fileNumber:"a file descriptor number",webStream:"a web stream",nodeStream:"a Node.js stream",webTransform:"a web TransformStream",duplex:"a Duplex stream",native:"any value",iterable:"an iterable",asyncIterable:"an async iterable",string:"a string",uint8Array:"a Uint8Array"};var di=(e,t,r,n)=>n==="output"?Yy(e,t,r):Ky(e,t,r),Yy=(e,t,r)=>{let n=t!==0&&r[t-1].value.readableObjectMode;return{writableObjectMode:n,readableObjectMode:e??n}},Ky=(e,t,r)=>{let n=t===0?e===!0:r[t-1].value.readableObjectMode,o=t!==r.length-1&&(e??n);return{writableObjectMode:n,readableObjectMode:o}},yu=(e,t)=>{let r=e.findLast(({type:n})=>ce.has(n));return r===void 0?!1:t==="input"?r.value.writableObjectMode:r.value.readableObjectMode};var xu=(e,t,r,n)=>[...e.filter(({type:o})=>!ce.has(o)),...Jy(e,t,r,n)],Jy=(e,t,r,{encoding:n})=>{let o=e.filter(({type:s})=>ce.has(s)),i=Array.from({length:o.length});for(let[s,a]of Object.entries(o))i[s]=Xy({stdioItem:a,index:Number(s),newTransforms:i,optionName:t,direction:r,encoding:n});return t0(i,r)},Xy=({stdioItem:e,stdioItem:{type:t},index:r,newTransforms:n,optionName:o,direction:i,encoding:s})=>t==="duplex"?Zy({stdioItem:e,optionName:o}):t==="webTransform"?Qy({stdioItem:e,index:r,newTransforms:n,direction:i}):e0({stdioItem:e,index:r,newTransforms:n,direction:i,encoding:s}),Zy=({stdioItem:e,stdioItem:{value:{transform:t,transform:{writableObjectMode:r,readableObjectMode:n},objectMode:o=n}},optionName:i})=>{if(o&&!n)throw new TypeError(`The \`${i}.objectMode\` option can only be \`true\` if \`new Duplex({objectMode: true})\` is used.`);if(!o&&n)throw new TypeError(`The \`${i}.objectMode\` option cannot be \`false\` if \`new Duplex({objectMode: true})\` is used.`);return{...e,value:{transform:t,writableObjectMode:r,readableObjectMode:n}}},Qy=({stdioItem:e,stdioItem:{value:t},index:r,newTransforms:n,direction:o})=>{let{transform:i,objectMode:s}=j(t)?t:{transform:t},{writableObjectMode:a,readableObjectMode:c}=di(s,r,n,o);return{...e,value:{transform:i,writableObjectMode:a,readableObjectMode:c}}},e0=({stdioItem:e,stdioItem:{value:t},index:r,newTransforms:n,direction:o,encoding:i})=>{let{transform:s,final:a,binary:c=!1,preserveNewlines:u=!1,objectMode:l}=j(t)?t:{transform:t},d=c||te.has(i),{writableObjectMode:m,readableObjectMode:p}=di(l,r,n,o);return{...e,value:{transform:s,final:a,binary:d,preserveNewlines:u,writableObjectMode:m,readableObjectMode:p}}},t0=(e,t)=>t==="input"?e.reverse():e;import mi from"process";var wu=(e,t,r)=>{let n=e.map(o=>r0(o,t));if(n.includes("input")&&n.includes("output"))throw new TypeError(`The \`${r}\` option must not be an array of both readable and writable values.`);return n.find(Boolean)??i0},r0=({type:e,value:t},r)=>n0[r]??Su[e](t),n0=["input","output","output"],gt=()=>{},pi=()=>"input",Su={generator:gt,asyncGenerator:gt,fileUrl:gt,filePath:gt,iterable:pi,asyncIterable:pi,uint8Array:pi,webStream:e=>an(e)?"output":"input",nodeStream(e){return Ye(e,{checkOpen:!1})?ei(e,{checkOpen:!1})?void 0:"input":"output"},webTransform:gt,duplex:gt,native(e){let t=o0(e);if(t!==void 0)return t;if(he(e,{checkOpen:!1}))return Su.nodeStream(e)}},o0=e=>{if([0,mi.stdin].includes(e))return"input";if([1,2,mi.stdout,mi.stderr].includes(e))return"output"},i0="output";var _u=(e,t)=>t&&!e.includes("ipc")?[...e,"ipc"]:e;var Eu=({stdio:e,ipc:t,buffer:r,...n},o,i)=>{let s=s0(e,n).map((a,c)=>$u(a,c));return i?c0(s,r,o):_u(s,t)},s0=(e,t)=>{if(e===void 0)return ae.map(n=>t[n]);if(a0(t))throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${ae.map(n=>`\`${n}\``).join(", ")}`);if(typeof e=="string")return[e,e,e];if(!Array.isArray(e))throw new TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof e}\``);let r=Math.max(e.length,ae.length);return Array.from({length:r},(n,o)=>e[o])},a0=e=>ae.some(t=>e[t]!==void 0),$u=(e,t)=>Array.isArray(e)?e.map(r=>$u(r,t)):e??(t>=ae.length?"ignore":"pipe"),c0=(e,t,r)=>e.map((n,o)=>!t[o]&&o!==0&&!st(r,o)&&l0(n)?"ignore":n),l0=e=>e==="pipe"||Array.isArray(e)&&e.every(t=>t==="pipe");import{readFileSync as u0}from"fs";import d0 from"tty";var Ou=({stdioItem:e,stdioItem:{type:t},isStdioArray:r,fdNumber:n,direction:o,isSync:i})=>!r||t!=="native"?e:i?m0({stdioItem:e,fdNumber:n,direction:o}):h0({stdioItem:e,fdNumber:n}),m0=({stdioItem:e,stdioItem:{value:t,optionName:r},fdNumber:n,direction:o})=>{let i=p0({value:t,optionName:r,fdNumber:n,direction:o});if(i!==void 0)return i;if(he(t,{checkOpen:!1}))throw new TypeError(`The \`${r}: Stream\` option cannot both be an array and include a stream with synchronous methods.`);return e},p0=({value:e,optionName:t,fdNumber:r,direction:n})=>{let o=f0(e,r);if(o!==void 0){if(n==="output")return{type:"fileNumber",value:o,optionName:t};if(d0.isatty(o))throw new TypeError(`The \`${t}: ${kr(e)}\` option is invalid: it cannot be a TTY with synchronous methods.`);return{type:"uint8Array",value:Ie(u0(o)),optionName:t}}},f0=(e,t)=>{if(e==="inherit")return t;if(typeof e=="number")return e;let r=yr.indexOf(e);if(r!==-1)return r},h0=({stdioItem:e,stdioItem:{value:t,optionName:r},fdNumber:n})=>t==="inherit"?{type:"nodeStream",value:Cu(n,t,r),optionName:r}:typeof t=="number"?{type:"nodeStream",value:Cu(t,t,r),optionName:r}:he(t,{checkOpen:!1})?{type:"nodeStream",value:t,optionName:r}:e,Cu=(e,t,r)=>{let n=yr[e];if(n===void 0)throw new TypeError(`The \`${r}: ${t}\` option is invalid: no such standard stream.`);return n};var vu=({input:e,inputFile:t},r)=>r===0?[...g0(e),...y0(t)]:[],g0=e=>e===void 0?[]:[{type:b0(e),value:e,optionName:"input"}],b0=e=>{if(Ye(e,{checkOpen:!1}))return"nodeStream";if(typeof e=="string")return"string";if(V(e))return"uint8Array";throw new Error("The `input` option must be a string, a Uint8Array or a Node.js Readable stream.")},y0=e=>e===void 0?[]:[{...x0(e),optionName:"inputFile"}],x0=e=>{if(sn(e))return{type:"fileUrl",value:e};if(ci(e))return{type:"filePath",value:{file:e}};throw new Error("The `inputFile` option must be a file path string or a file URL.")};var Tu=e=>e.filter((t,r)=>e.every((n,o)=>t.value!==n.value||r>=o||t.type==="generator"||t.type==="asyncGenerator")),Au=({stdioItem:{type:e,value:t,optionName:r},direction:n,fileDescriptors:o,isSync:i})=>{let s=w0(o,e);if(s.length!==0){if(i){S0({otherStdioItems:s,type:e,value:t,optionName:r,direction:n});return}if(gu.has(e))return Iu({otherStdioItems:s,type:e,value:t,optionName:r,direction:n});bu.has(e)&&E0({otherStdioItems:s,type:e,value:t,optionName:r})}},w0=(e,t)=>e.flatMap(({direction:r,stdioItems:n})=>n.filter(o=>o.type===t).map((o=>({...o,direction:r})))),S0=({otherStdioItems:e,type:t,value:r,optionName:n,direction:o})=>{ui.has(t)&&Iu({otherStdioItems:e,type:t,value:r,optionName:n,direction:o})},Iu=({otherStdioItems:e,type:t,value:r,optionName:n,direction:o})=>{let i=e.filter(a=>_0(a,r));if(i.length===0)return;let s=i.find(a=>a.direction!==o);return Du(s,n,t),o==="output"?i[0].stream:void 0},_0=({type:e,value:t},r)=>e==="filePath"?t.file===r.file:e==="fileUrl"?t.href===r.href:t===r,E0=({otherStdioItems:e,type:t,value:r,optionName:n})=>{let o=e.find(({value:{transform:i}})=>i===r.transform);Du(o,n,t)},Du=(e,t,r)=>{if(e!==void 0)throw new TypeError(`The \`${e.optionName}\` and \`${t}\` options must not target ${Ue[r]} that is the same.`)};var ln=(e,t,r,n)=>{let i=Eu(t,r,n).map((a,c)=>$0({stdioOption:a,fdNumber:c,options:t,isSync:n})),s=R0({initialFileDescriptors:i,addProperties:e,options:t,isSync:n});return t.stdio=s.map(({stdioItems:a})=>L0(a)),s},$0=({stdioOption:e,fdNumber:t,options:r,isSync:n})=>{let o=xr(t),{stdioItems:i,isStdioArray:s}=C0({stdioOption:e,fdNumber:t,options:r,optionName:o}),a=wu(i,t,o),c=i.map(d=>Ou({stdioItem:d,isStdioArray:s,fdNumber:t,direction:a,isSync:n})),u=xu(c,o,a,r),l=yu(u,a);return D0(u,l),{direction:a,objectMode:l,stdioItems:u}},C0=({stdioOption:e,fdNumber:t,options:r,optionName:n})=>{let i=[...(Array.isArray(e)?e:[e]).map(c=>O0(c,n)),...vu(r,t)],s=Tu(i),a=s.length>1;return v0(s,a,n),A0(s),{stdioItems:s,isStdioArray:a}},O0=(e,t)=>({type:cu(e,t),value:e,optionName:t}),v0=(e,t,r)=>{if(e.length===0)throw new TypeError(`The \`${r}\` option must not be an empty array.`);if(t){for(let{value:n,optionName:o}of e)if(T0.has(n))throw new Error(`The \`${o}\` option must not include \`${n}\`.`)}},T0=new Set(["ignore","ipc"]),A0=e=>{for(let t of e)I0(t)},I0=({type:e,value:t,optionName:r})=>{if(mu(t))throw new TypeError(`The \`${r}: URL\` option must use the \`file:\` scheme.
|
|
135
|
-
For example, you can use the \`pathToFileURL()\` method of the \`url\` core module.`);if(
|
|
136
|
-
`){let
|
|
62
|
+
${e}`};var si=(e,t,r)=>{r.cwd=Vp(r.cwd);let[i,n,s]=Up(e,t,r),{command:o,args:a,options:c}=Yp.default._parse(i,n,s),d=Ra(c),p=g_(d);return Dp(p),zp(p),Bp(p),ip(p),Rp(p),p.shell=Gn(p.shell),p.env=__(p),p.killSignal=Qc(p.killSignal),p.forceKillAfterDelay=tp(p.forceKillAfterDelay),p.lines=p.lines.map((u,l)=>u&&!oe.has(p.encoding)&&p.buffer[l]),Kp.platform==="win32"&&f_.basename(o,".exe")==="cmd"&&a.unshift("/q"),{file:o,commandArguments:a,options:p}},g_=({extendEnv:e=!0,preferLocal:t=!1,cwd:r,localDir:i=r,encoding:n="utf8",reject:s=!0,cleanup:o=!0,all:a=!1,windowsHide:c=!0,killSignal:d="SIGTERM",forceKillAfterDelay:p=!0,gracefulCancel:u=!1,ipcInput:l,ipc:m=l!==void 0||u,serialization:h="advanced",...f})=>({...f,extendEnv:e,preferLocal:t,cwd:r,localDirectory:i,encoding:n,reject:s,cleanup:o,all:a,windowsHide:c,killSignal:d,forceKillAfterDelay:p,gracefulCancel:u,ipcInput:l,ipc:m,serialization:h}),__=({env:e,extendEnv:t,preferLocal:r,node:i,localDirectory:n,nodePath:s})=>{let o=t?{...Kp.env,...e}:e;return r||i?Bc({env:o,cwd:n,execPath:s,preferLocal:r,addExecPath:i}):o};var oi=(e,t,r)=>r.shell&&t.length>0?[[e,...t].join(" "),[],r]:[e,t,r];import{inspect as Q_}from"util";function $t(e){if(typeof e=="string")return b_(e);if(!(ArrayBuffer.isView(e)&&e.BYTES_PER_ELEMENT===1))throw new Error("Input must be a string or a Uint8Array");return x_(e)}var b_=e=>e.at(-1)===Jp?e.slice(0,e.at(-2)===Xp?-2:-1):e,x_=e=>e.at(-1)===w_?e.subarray(0,e.at(-2)===k_?-2:-1):e,Jp=`
|
|
63
|
+
`,w_=Jp.codePointAt(0),Xp="\r",k_=Xp.codePointAt(0);import{on as K_}from"events";import{finished as Y_}from"stream/promises";function be(e,{checkOpen:t=!0}={}){return e!==null&&typeof e=="object"&&(e.writable||e.readable||!t||e.writable===void 0&&e.readable===void 0)&&typeof e.pipe=="function"}function _s(e,{checkOpen:t=!0}={}){return be(e,{checkOpen:t})&&(e.writable||!t)&&typeof e.write=="function"&&typeof e.end=="function"&&typeof e.writable=="boolean"&&typeof e.writableObjectMode=="boolean"&&typeof e.destroy=="function"&&typeof e.destroyed=="boolean"}function nt(e,{checkOpen:t=!0}={}){return be(e,{checkOpen:t})&&(e.readable||!t)&&typeof e.read=="function"&&typeof e.readable=="boolean"&&typeof e.readableObjectMode=="boolean"&&typeof e.destroy=="function"&&typeof e.destroyed=="boolean"}function bs(e,t){return _s(e,t)&&nt(e,t)}var S_=Object.getPrototypeOf(Object.getPrototypeOf(async function*(){}).prototype),xs=class{#t;#r;#e=!1;#i=void 0;constructor(t,r){this.#t=t,this.#r=r}next(){let t=()=>this.#s();return this.#i=this.#i?this.#i.then(t,t):t(),this.#i}return(t){let r=()=>this.#n(t);return this.#i?this.#i.then(r,r):r()}async#s(){if(this.#e)return{done:!0,value:void 0};let t;try{t=await this.#t.read()}catch(r){throw this.#i=void 0,this.#e=!0,this.#t.releaseLock(),r}return t.done&&(this.#i=void 0,this.#e=!0,this.#t.releaseLock()),t}async#n(t){if(this.#e)return{done:!0,value:t};if(this.#e=!0,!this.#r){let r=this.#t.cancel(t);return this.#t.releaseLock(),await r,{done:!0,value:t}}return this.#t.releaseLock(),{done:!0,value:t}}},ws=Symbol();function Qp(){return this[ws].next()}Object.defineProperty(Qp,"name",{value:"next"});function Zp(e){return this[ws].return(e)}Object.defineProperty(Zp,"name",{value:"return"});var v_=Object.create(S_,{next:{enumerable:!0,configurable:!0,writable:!0,value:Qp},return:{enumerable:!0,configurable:!0,writable:!0,value:Zp}});function ks({preventCancel:e=!1}={}){let t=this.getReader(),r=new xs(t,e),i=Object.create(v_);return i[ws]=r,i}var ed=e=>{if(nt(e,{checkOpen:!1})&&Xt.on!==void 0)return $_(e);if(typeof e?.[Symbol.asyncIterator]=="function")return e;if(q_.call(e)==="[object ReadableStream]")return ks.call(e);throw new TypeError("The first argument must be a Readable, a ReadableStream, or an async iterable.")},{toString:q_}=Object.prototype,$_=async function*(e){let t=new AbortController,r={};C_(e,t,r);try{for await(let[i]of Xt.on(e,"data",{signal:t.signal}))yield i}catch(i){if(r.error!==void 0)throw r.error;if(!t.signal.aborted)throw i}finally{e.destroy()}},C_=async(e,t,r)=>{try{await Xt.finished(e,{cleanup:!0,readable:!0,writable:!1,error:!1})}catch(i){r.error=i}finally{t.abort()}},Xt={};var Ct=async(e,{init:t,convertChunk:r,getSize:i,truncateChunk:n,addChunk:s,getFinalChunk:o,finalize:a},{maxBuffer:c=Number.POSITIVE_INFINITY}={})=>{let d=ed(e),p=t();p.length=0;try{for await(let u of d){let l=E_(u),m=r[l](u,p);id({convertedChunk:m,state:p,getSize:i,truncateChunk:n,addChunk:s,maxBuffer:c})}return A_({state:p,convertChunk:r,getSize:i,truncateChunk:n,addChunk:s,getFinalChunk:o,maxBuffer:c}),a(p)}catch(u){let l=typeof u=="object"&&u!==null?u:new Error(u);throw l.bufferedData=a(p),l}},A_=({state:e,getSize:t,truncateChunk:r,addChunk:i,getFinalChunk:n,maxBuffer:s})=>{let o=n(e);o!==void 0&&id({convertedChunk:o,state:e,getSize:t,truncateChunk:r,addChunk:i,maxBuffer:s})},id=({convertedChunk:e,state:t,getSize:r,truncateChunk:i,addChunk:n,maxBuffer:s})=>{let o=r(e),a=t.length+o;if(a<=s){td(e,t,n,a);return}let c=i(e,s-t.length);throw c!==void 0&&td(c,t,n,s),new qe},td=(e,t,r,i)=>{t.contents=r(e,t,i),t.length=i},E_=e=>{let t=typeof e;if(t==="string")return"string";if(t!=="object"||e===null)return"others";if(globalThis.Buffer?.isBuffer(e))return"buffer";let r=rd.call(e);return r==="[object ArrayBuffer]"?"arrayBuffer":r==="[object DataView]"?"dataView":Number.isInteger(e.byteLength)&&Number.isInteger(e.byteOffset)&&rd.call(e.buffer)==="[object ArrayBuffer]"?"typedArray":"others"},{toString:rd}=Object.prototype,qe=class extends Error{name="MaxBufferError";constructor(){super("maxBuffer exceeded")}};var Me=e=>e,Qt=()=>{},ai=({contents:e})=>e,ci=e=>{throw new Error(`Streams in object mode are not supported: ${String(e)}`)},pi=e=>e.length;async function di(e,t){return Ct(e,I_,t)}var T_=()=>({contents:[]}),P_=()=>1,O_=(e,{contents:t})=>(t.push(e),t),I_={init:T_,convertChunk:{string:Me,buffer:Me,arrayBuffer:Me,dataView:Me,typedArray:Me,others:Me},getSize:P_,truncateChunk:Qt,addChunk:O_,getFinalChunk:Qt,finalize:ai};async function ui(e,t){return Ct(e,N_,t)}var R_=()=>({contents:new ArrayBuffer(0)}),j_=e=>D_.encode(e),D_=new TextEncoder,nd=e=>new Uint8Array(e),sd=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength),L_=(e,t)=>e.slice(0,t),M_=(e,{contents:t,length:r},i)=>{let n=cd()?U_(t,i):F_(t,i);return new Uint8Array(n).set(e,r),n},F_=(e,t)=>{if(t<=e.byteLength)return e;let r=new ArrayBuffer(ad(t));return new Uint8Array(r).set(new Uint8Array(e),0),r},U_=(e,t)=>{if(t<=e.maxByteLength)return e.resize(t),e;let r=new ArrayBuffer(t,{maxByteLength:ad(t)});return new Uint8Array(r).set(new Uint8Array(e),0),r},ad=e=>od**Math.ceil(Math.log(e)/Math.log(od)),od=2,B_=({contents:e,length:t})=>cd()?e:e.slice(0,t),cd=()=>"resize"in ArrayBuffer.prototype,N_={init:R_,convertChunk:{string:j_,buffer:nd,arrayBuffer:nd,dataView:sd,typedArray:sd,others:ci},getSize:pi,truncateChunk:L_,addChunk:M_,getFinalChunk:Qt,finalize:B_};async function mi(e,t){return Ct(e,H_,t)}var G_=()=>({contents:"",textDecoder:new TextDecoder}),li=(e,{textDecoder:t})=>t.decode(e,{stream:!0}),z_=(e,{contents:t})=>t+e,V_=(e,t)=>e.slice(0,t),W_=({textDecoder:e})=>{let t=e.decode();return t===""?void 0:t},H_={init:G_,convertChunk:{string:Me,buffer:li,arrayBuffer:li,dataView:li,typedArray:li,others:ci},getSize:pi,truncateChunk:V_,addChunk:z_,getFinalChunk:W_,finalize:ai};Object.assign(Xt,{on:K_,finished:Y_});var pd=({error:e,stream:t,readableObjectMode:r,lines:i,encoding:n,fdNumber:s})=>{if(!(e instanceof qe))throw e;if(s==="all")return e;let o=J_(r,i,n);throw e.maxBufferInfo={fdNumber:s,unit:o},t.destroy(),e},J_=(e,t,r)=>e?"objects":t?"lines":r==="buffer"?"bytes":"characters",dd=(e,t,r)=>{if(t.length!==r)return;let i=new qe;throw i.maxBufferInfo={fdNumber:"ipc"},i},ud=(e,t)=>{let{streamName:r,threshold:i,unit:n}=X_(e,t);return`Command's ${r} was larger than ${i} ${n}`},X_=(e,t)=>{if(e?.maxBufferInfo===void 0)return{streamName:"output",threshold:t[1],unit:"bytes"};let{maxBufferInfo:{fdNumber:r,unit:i}}=e;delete e.maxBufferInfo;let n=Le(t,r);return r==="ipc"?{streamName:"IPC output",threshold:n,unit:"messages"}:{streamName:Tr(r),threshold:n,unit:i}},ld=(e,t,r)=>e?.code==="ENOBUFS"&&t!==null&&t.some(i=>i!==null&&i.length>hi(r)),md=(e,t,r)=>{if(!t)return e;let i=hi(r);return e.length>i?e.slice(0,i):e},hi=([,e])=>e;var yd=({stdio:e,all:t,ipcOutput:r,originalError:i,signal:n,signalDescription:s,exitCode:o,escapedCommand:a,timedOut:c,isCanceled:d,isGracefullyCanceled:p,isMaxBuffer:u,isForcefullyTerminated:l,forceKillAfterDelay:m,killSignal:h,maxBuffer:f,timeout:x,cwd:_})=>{let v=i?.code,C=Z_({originalError:i,timedOut:c,timeout:x,isMaxBuffer:u,maxBuffer:f,errorCode:v,signal:n,signalDescription:s,exitCode:o,isCanceled:d,isGracefullyCanceled:p,isForcefullyTerminated:l,forceKillAfterDelay:m,killSignal:h}),E=tb(i,_),w=E===void 0?"":`
|
|
64
|
+
${E}`,L=`${C}: ${a}${w}`,O=t===void 0?[e[2],e[1]]:[t],R=[L,...O,...e.slice(3),r.map(F=>rb(F)).join(`
|
|
65
|
+
`)].map(F=>Vt($t(ib(F)))).filter(Boolean).join(`
|
|
66
|
+
|
|
67
|
+
`);return{originalMessage:E,shortMessage:L,message:R}},Z_=({originalError:e,timedOut:t,timeout:r,isMaxBuffer:i,maxBuffer:n,errorCode:s,signal:o,signalDescription:a,exitCode:c,isCanceled:d,isGracefullyCanceled:p,isForcefullyTerminated:u,forceKillAfterDelay:l,killSignal:m})=>{let h=eb(u,l);return t?`Command timed out after ${r} milliseconds${h}`:p?o===void 0?`Command was gracefully canceled with exit code ${c}`:u?`Command was gracefully canceled${h}`:`Command was gracefully canceled with ${o} (${a})`:d?`Command was canceled${h}`:i?`${ud(e,n)}${h}`:s!==void 0?`Command failed with ${s}${h}`:u?`Command was killed with ${m} (${zr(m)})${h}`:o!==void 0?`Command was killed with ${o} (${a})`:c!==void 0?`Command failed with exit code ${c}`:"Command failed"},eb=(e,t)=>e?` and was forcefully terminated after ${t} milliseconds`:"",tb=(e,t)=>{if(e instanceof ge)return;let r=zc(e)?e.originalMessage:String(e?.message??e),i=Vt(Hp(r,t));return i===""?void 0:i},rb=e=>typeof e=="string"?e:Q_(e),ib=e=>Array.isArray(e)?e.map(t=>$t(hd(t))).filter(Boolean).join(`
|
|
68
|
+
`):hd(e),hd=e=>typeof e=="string"?e:H(e)?Ar(e):"";var yi=({command:e,escapedCommand:t,stdio:r,all:i,ipcOutput:n,options:{cwd:s},startTime:o})=>fd({command:e,escapedCommand:t,cwd:s,durationMs:Xn(o),failed:!1,timedOut:!1,isCanceled:!1,isGracefullyCanceled:!1,isTerminated:!1,isMaxBuffer:!1,isForcefullyTerminated:!1,exitCode:0,stdout:r[1],stderr:r[2],all:i,stdio:r,ipcOutput:n,pipedFrom:[]}),At=({error:e,command:t,escapedCommand:r,fileDescriptors:i,options:n,startTime:s,isSync:o})=>Zt({error:e,command:t,escapedCommand:r,startTime:s,timedOut:!1,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:!1,isForcefullyTerminated:!1,stdio:Array.from({length:i.length}),ipcOutput:[],options:n,isSync:o}),Zt=({error:e,command:t,escapedCommand:r,startTime:i,timedOut:n,isCanceled:s,isGracefullyCanceled:o,isMaxBuffer:a,isForcefullyTerminated:c,exitCode:d,signal:p,stdio:u,all:l,ipcOutput:m,options:{timeoutDuration:h,timeout:f=h,forceKillAfterDelay:x,killSignal:_,cwd:v,maxBuffer:C},isSync:E})=>{let{exitCode:w,signal:L,signalDescription:O}=sb(d,p),{originalMessage:R,shortMessage:F,message:N}=yd({stdio:u,all:l,ipcOutput:m,originalError:e,signal:L,signalDescription:O,exitCode:w,escapedCommand:r,timedOut:n,isCanceled:s,isGracefullyCanceled:o,isMaxBuffer:a,isForcefullyTerminated:c,forceKillAfterDelay:x,killSignal:_,maxBuffer:C,timeout:f,cwd:v}),S=Nc(e,N,E);return Object.assign(S,nb({error:S,command:t,escapedCommand:r,startTime:i,timedOut:n,isCanceled:s,isGracefullyCanceled:o,isMaxBuffer:a,isForcefullyTerminated:c,exitCode:w,signal:L,signalDescription:O,stdio:u,all:l,ipcOutput:m,cwd:v,originalMessage:R,shortMessage:F})),S},nb=({error:e,command:t,escapedCommand:r,startTime:i,timedOut:n,isCanceled:s,isGracefullyCanceled:o,isMaxBuffer:a,isForcefullyTerminated:c,exitCode:d,signal:p,signalDescription:u,stdio:l,all:m,ipcOutput:h,cwd:f,originalMessage:x,shortMessage:_})=>fd({shortMessage:_,originalMessage:x,command:t,escapedCommand:r,cwd:f,durationMs:Xn(i),failed:!0,timedOut:n,isCanceled:s,isGracefullyCanceled:o,isTerminated:p!==void 0,isMaxBuffer:a,isForcefullyTerminated:c,exitCode:d,signal:p,signalDescription:u,code:e.cause?.code,stdout:l[1],stderr:l[2],all:m,stdio:l,ipcOutput:h,pipedFrom:[]}),fd=e=>Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0)),sb=(e,t)=>{let r=e===null?void 0:e,i=t===null?void 0:t,n=i===void 0?void 0:zr(t);return{exitCode:r,signal:i,signalDescription:n}};var gd=e=>Number.isFinite(e)?e:0;function ob(e){return{days:Math.trunc(e/864e5),hours:Math.trunc(e/36e5%24),minutes:Math.trunc(e/6e4%60),seconds:Math.trunc(e/1e3%60),milliseconds:Math.trunc(e%1e3),microseconds:Math.trunc(gd(e*1e3)%1e3),nanoseconds:Math.trunc(gd(e*1e6)%1e3)}}function ab(e){return{days:e/86400000n,hours:e/3600000n%24n,minutes:e/60000n%60n,seconds:e/1000n%60n,milliseconds:e%1000n,microseconds:0n,nanoseconds:0n}}function Ss(e){switch(typeof e){case"number":{if(Number.isFinite(e))return ob(e);break}case"bigint":return ab(e)}throw new TypeError("Expected a finite number or bigint")}var cb=e=>e===0||e===0n,pb=(e,t)=>t===1||t===1n?e:`${e}s`,db=1e-7,ub=24n*60n*60n*1000n;function vs(e,t){let r=typeof e=="bigint";if(!r&&!Number.isFinite(e))throw new TypeError("Expected a finite number or bigint");t={...t};let i=e<0?"-":"";e=e<0?-e:e,t.colonNotation&&(t.compact=!1,t.formatSubMilliseconds=!1,t.separateMilliseconds=!1,t.verbose=!1),t.compact&&(t.unitCount=1,t.secondsDecimalDigits=0,t.millisecondsDecimalDigits=0);let n=[],s=(p,u)=>{let l=Math.floor(p*10**u+db);return(Math.round(l)/10**u).toFixed(u)},o=(p,u,l,m)=>{if(!((n.length===0||!t.colonNotation)&&cb(p)&&!(t.colonNotation&&l==="m"))){if(m??=String(p),t.colonNotation){let h=m.includes(".")?m.split(".")[0].length:m.length,f=n.length>0?2:1;m="0".repeat(Math.max(0,f-h))+m}else m+=t.verbose?" "+pb(u,p):l;n.push(m)}},a=Ss(e),c=BigInt(a.days);if(t.hideYearAndDays?o(BigInt(c)*24n+BigInt(a.hours),"hour","h"):(t.hideYear?o(c,"day","d"):(o(c/365n,"year","y"),o(c%365n,"day","d")),o(Number(a.hours),"hour","h")),o(Number(a.minutes),"minute","m"),!t.hideSeconds)if(t.separateMilliseconds||t.formatSubMilliseconds||!t.colonNotation&&e<1e3&&!t.subSecondsAsDecimals){let p=Number(a.seconds),u=Number(a.milliseconds),l=Number(a.microseconds),m=Number(a.nanoseconds);if(o(p,"second","s"),t.formatSubMilliseconds)o(u,"millisecond","ms"),o(l,"microsecond","\xB5s"),o(m,"nanosecond","ns");else{let h=u+l/1e3+m/1e6,f=typeof t.millisecondsDecimalDigits=="number"?t.millisecondsDecimalDigits:0,x=h>=1?Math.round(h):Math.ceil(h),_=f?h.toFixed(f):x;o(Number.parseFloat(_),"millisecond","ms",_)}}else{let p=(r?Number(e%ub):e)/1e3%60,u=typeof t.secondsDecimalDigits=="number"?t.secondsDecimalDigits:1,l=s(p,u),m=t.keepDecimalsOnWholeSeconds?l:l.replace(/\.0+$/,"");o(Number.parseFloat(m),"second","s",m)}if(n.length===0)return i+"0"+(t.verbose?" milliseconds":"ms");let d=t.colonNotation?":":" ";return typeof t.unitCount=="number"&&(n=n.slice(0,Math.max(t.unitCount,1))),i+n.join(d)}var _d=(e,t)=>{e.failed&&ke({type:"error",verboseMessage:e.shortMessage,verboseInfo:t,result:e})};var bd=(e,t)=>{bt(t)&&(_d(e,t),lb(e,t))},lb=(e,t)=>{let r=`(done in ${vs(e.durationMs)})`;ke({type:"duration",verboseMessage:r,verboseInfo:t,result:e})};var Et=(e,t,{reject:r})=>{if(bd(e,t),e.failed&&r)throw e;return e};import{readFileSync as Wd}from"fs";var kd=(e,t)=>st(e)?"asyncGenerator":qd(e)?"generator":fi(e)?"fileUrl":gb(e)?"filePath":xb(e)?"webStream":be(e,{checkOpen:!1})?"native":H(e)?"uint8Array":wb(e)?"asyncIterable":kb(e)?"iterable":Cs(e)?Sd({transform:e},t):fb(e)?mb(e,t):"native",mb=(e,t)=>bs(e.transform,{checkOpen:!1})?hb(e,t):Cs(e.transform)?Sd(e,t):yb(e,t),hb=(e,t)=>(vd(e,t,"Duplex stream"),"duplex"),Sd=(e,t)=>(vd(e,t,"web TransformStream"),"webTransform"),vd=({final:e,binary:t,objectMode:r},i,n)=>{xd(e,`${i}.final`,n),xd(t,`${i}.binary`,n),qs(r,`${i}.objectMode`)},xd=(e,t,r)=>{if(e!==void 0)throw new TypeError(`The \`${t}\` option can only be defined when using a generator, not a ${r}.`)},yb=({transform:e,final:t,binary:r,objectMode:i},n)=>{if(e!==void 0&&!wd(e))throw new TypeError(`The \`${n}.transform\` option must be a generator, a Duplex stream or a web TransformStream.`);if(bs(t,{checkOpen:!1}))throw new TypeError(`The \`${n}.final\` option must not be a Duplex stream.`);if(Cs(t))throw new TypeError(`The \`${n}.final\` option must not be a web TransformStream.`);if(t!==void 0&&!wd(t))throw new TypeError(`The \`${n}.final\` option must be a generator.`);return qs(r,`${n}.binary`),qs(i,`${n}.objectMode`),st(e)||st(t)?"asyncGenerator":"generator"},qs=(e,t)=>{if(e!==void 0&&typeof e!="boolean")throw new TypeError(`The \`${t}\` option must use a boolean.`)},wd=e=>st(e)||qd(e),st=e=>Object.prototype.toString.call(e)==="[object AsyncGeneratorFunction]",qd=e=>Object.prototype.toString.call(e)==="[object GeneratorFunction]",fb=e=>V(e)&&(e.transform!==void 0||e.final!==void 0),fi=e=>Object.prototype.toString.call(e)==="[object URL]",$d=e=>fi(e)&&e.protocol!=="file:",gb=e=>V(e)&&Object.keys(e).length>0&&Object.keys(e).every(t=>_b.has(t))&&$s(e.file),_b=new Set(["file","append"]),$s=e=>typeof e=="string",Cd=(e,t)=>e==="native"&&typeof t=="string"&&!bb.has(t),bb=new Set(["ipc","ignore","inherit","overlapped","pipe"]),Ad=e=>Object.prototype.toString.call(e)==="[object ReadableStream]",gi=e=>Object.prototype.toString.call(e)==="[object WritableStream]",xb=e=>Ad(e)||gi(e),Cs=e=>Ad(e?.readable)&&gi(e?.writable),wb=e=>Ed(e)&&typeof e[Symbol.asyncIterator]=="function",kb=e=>Ed(e)&&typeof e[Symbol.iterator]=="function",Ed=e=>typeof e=="object"&&e!==null,le=new Set(["generator","asyncGenerator","duplex","webTransform"]),_i=new Set(["fileUrl","filePath","fileNumber"]),As=new Set(["fileUrl","filePath"]),Td=new Set([...As,"webStream","nodeStream"]),Pd=new Set(["webTransform","duplex"]),We={generator:"a generator",asyncGenerator:"an async generator",fileUrl:"a file URL",filePath:"a file path string",fileNumber:"a file descriptor number",webStream:"a web stream",nodeStream:"a Node.js stream",webTransform:"a web TransformStream",duplex:"a Duplex stream",native:"any value",iterable:"an iterable",asyncIterable:"an async iterable",string:"a string",uint8Array:"a Uint8Array"};var Es=(e,t,r,i)=>i==="output"?Sb(e,t,r):vb(e,t,r),Sb=(e,t,r)=>{let i=t!==0&&r[t-1].value.readableObjectMode;return{writableObjectMode:i,readableObjectMode:e??i}},vb=(e,t,r)=>{let i=t===0?e===!0:r[t-1].value.readableObjectMode,n=t!==r.length-1&&(e??i);return{writableObjectMode:i,readableObjectMode:n}},Od=(e,t)=>{let r=e.findLast(({type:i})=>le.has(i));return r===void 0?!1:t==="input"?r.value.writableObjectMode:r.value.readableObjectMode};var Id=(e,t,r,i)=>[...e.filter(({type:n})=>!le.has(n)),...qb(e,t,r,i)],qb=(e,t,r,{encoding:i})=>{let n=e.filter(({type:o})=>le.has(o)),s=Array.from({length:n.length});for(let[o,a]of Object.entries(n))s[o]=$b({stdioItem:a,index:Number(o),newTransforms:s,optionName:t,direction:r,encoding:i});return Tb(s,r)},$b=({stdioItem:e,stdioItem:{type:t},index:r,newTransforms:i,optionName:n,direction:s,encoding:o})=>t==="duplex"?Cb({stdioItem:e,optionName:n}):t==="webTransform"?Ab({stdioItem:e,index:r,newTransforms:i,direction:s}):Eb({stdioItem:e,index:r,newTransforms:i,direction:s,encoding:o}),Cb=({stdioItem:e,stdioItem:{value:{transform:t,transform:{writableObjectMode:r,readableObjectMode:i},objectMode:n=i}},optionName:s})=>{if(n&&!i)throw new TypeError(`The \`${s}.objectMode\` option can only be \`true\` if \`new Duplex({objectMode: true})\` is used.`);if(!n&&i)throw new TypeError(`The \`${s}.objectMode\` option cannot be \`false\` if \`new Duplex({objectMode: true})\` is used.`);return{...e,value:{transform:t,writableObjectMode:r,readableObjectMode:i}}},Ab=({stdioItem:e,stdioItem:{value:t},index:r,newTransforms:i,direction:n})=>{let{transform:s,objectMode:o}=V(t)?t:{transform:t},{writableObjectMode:a,readableObjectMode:c}=Es(o,r,i,n);return{...e,value:{transform:s,writableObjectMode:a,readableObjectMode:c}}},Eb=({stdioItem:e,stdioItem:{value:t},index:r,newTransforms:i,direction:n,encoding:s})=>{let{transform:o,final:a,binary:c=!1,preserveNewlines:d=!1,objectMode:p}=V(t)?t:{transform:t},u=c||oe.has(s),{writableObjectMode:l,readableObjectMode:m}=Es(p,r,i,n);return{...e,value:{transform:o,final:a,binary:u,preserveNewlines:d,writableObjectMode:l,readableObjectMode:m}}},Tb=(e,t)=>t==="input"?e.reverse():e;import Ts from"process";var Rd=(e,t,r)=>{let i=e.map(n=>Pb(n,t));if(i.includes("input")&&i.includes("output"))throw new TypeError(`The \`${r}\` option must not be an array of both readable and writable values.`);return i.find(Boolean)??Rb},Pb=({type:e,value:t},r)=>Ob[r]??jd[e](t),Ob=["input","output","output"],Tt=()=>{},Ps=()=>"input",jd={generator:Tt,asyncGenerator:Tt,fileUrl:Tt,filePath:Tt,iterable:Ps,asyncIterable:Ps,uint8Array:Ps,webStream:e=>gi(e)?"output":"input",nodeStream(e){return nt(e,{checkOpen:!1})?_s(e,{checkOpen:!1})?void 0:"input":"output"},webTransform:Tt,duplex:Tt,native(e){let t=Ib(e);if(t!==void 0)return t;if(be(e,{checkOpen:!1}))return jd.nodeStream(e)}},Ib=e=>{if([0,Ts.stdin].includes(e))return"input";if([1,2,Ts.stdout,Ts.stderr].includes(e))return"output"},Rb="output";var Dd=(e,t)=>t&&!e.includes("ipc")?[...e,"ipc"]:e;var Ld=({stdio:e,ipc:t,buffer:r,...i},n,s)=>{let o=jb(e,i).map((a,c)=>Md(a,c));return s?Lb(o,r,n):Dd(o,t)},jb=(e,t)=>{if(e===void 0)return ue.map(i=>t[i]);if(Db(t))throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${ue.map(i=>`\`${i}\``).join(", ")}`);if(typeof e=="string")return[e,e,e];if(!Array.isArray(e))throw new TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof e}\``);let r=Math.max(e.length,ue.length);return Array.from({length:r},(i,n)=>e[n])},Db=e=>ue.some(t=>e[t]!==void 0),Md=(e,t)=>Array.isArray(e)?e.map(r=>Md(r,t)):e??(t>=ue.length?"ignore":"pipe"),Lb=(e,t,r)=>e.map((i,n)=>!t[n]&&n!==0&&!xt(r,n)&&Mb(i)?"ignore":i),Mb=e=>e==="pipe"||Array.isArray(e)&&e.every(t=>t==="pipe");import{readFileSync as Fb}from"fs";import Ub from"tty";var Ud=({stdioItem:e,stdioItem:{type:t},isStdioArray:r,fdNumber:i,direction:n,isSync:s})=>!r||t!=="native"?e:s?Bb({stdioItem:e,fdNumber:i,direction:n}):zb({stdioItem:e,fdNumber:i}),Bb=({stdioItem:e,stdioItem:{value:t,optionName:r},fdNumber:i,direction:n})=>{let s=Nb({value:t,optionName:r,fdNumber:i,direction:n});if(s!==void 0)return s;if(be(t,{checkOpen:!1}))throw new TypeError(`The \`${r}: Stream\` option cannot both be an array and include a stream with synchronous methods.`);return e},Nb=({value:e,optionName:t,fdNumber:r,direction:i})=>{let n=Gb(e,r);if(n!==void 0){if(i==="output")return{type:"fileNumber",value:n,optionName:t};if(Ub.isatty(n))throw new TypeError(`The \`${t}: ${Hr(e)}\` option is invalid: it cannot be a TTY with synchronous methods.`);return{type:"uint8Array",value:De(Fb(n)),optionName:t}}},Gb=(e,t)=>{if(e==="inherit")return t;if(typeof e=="number")return e;let r=Er.indexOf(e);if(r!==-1)return r},zb=({stdioItem:e,stdioItem:{value:t,optionName:r},fdNumber:i})=>t==="inherit"?{type:"nodeStream",value:Fd(i,t,r),optionName:r}:typeof t=="number"?{type:"nodeStream",value:Fd(t,t,r),optionName:r}:be(t,{checkOpen:!1})?{type:"nodeStream",value:t,optionName:r}:e,Fd=(e,t,r)=>{let i=Er[e];if(i===void 0)throw new TypeError(`The \`${r}: ${t}\` option is invalid: no such standard stream.`);return i};var Bd=({input:e,inputFile:t},r)=>r===0?[...Vb(e),...Hb(t)]:[],Vb=e=>e===void 0?[]:[{type:Wb(e),value:e,optionName:"input"}],Wb=e=>{if(nt(e,{checkOpen:!1}))return"nodeStream";if(typeof e=="string")return"string";if(H(e))return"uint8Array";throw new Error("The `input` option must be a string, a Uint8Array or a Node.js Readable stream.")},Hb=e=>e===void 0?[]:[{...Kb(e),optionName:"inputFile"}],Kb=e=>{if(fi(e))return{type:"fileUrl",value:e};if($s(e))return{type:"filePath",value:{file:e}};throw new Error("The `inputFile` option must be a file path string or a file URL.")};var Nd=e=>e.filter((t,r)=>e.every((i,n)=>t.value!==i.value||r>=n||t.type==="generator"||t.type==="asyncGenerator")),Gd=({stdioItem:{type:e,value:t,optionName:r},direction:i,fileDescriptors:n,isSync:s})=>{let o=Yb(n,e);if(o.length!==0){if(s){Jb({otherStdioItems:o,type:e,value:t,optionName:r,direction:i});return}if(Td.has(e))return zd({otherStdioItems:o,type:e,value:t,optionName:r,direction:i});Pd.has(e)&&Qb({otherStdioItems:o,type:e,value:t,optionName:r})}},Yb=(e,t)=>e.flatMap(({direction:r,stdioItems:i})=>i.filter(n=>n.type===t).map((n=>({...n,direction:r})))),Jb=({otherStdioItems:e,type:t,value:r,optionName:i,direction:n})=>{As.has(t)&&zd({otherStdioItems:e,type:t,value:r,optionName:i,direction:n})},zd=({otherStdioItems:e,type:t,value:r,optionName:i,direction:n})=>{let s=e.filter(a=>Xb(a,r));if(s.length===0)return;let o=s.find(a=>a.direction!==n);return Vd(o,i,t),n==="output"?s[0].stream:void 0},Xb=({type:e,value:t},r)=>e==="filePath"?t.file===r.file:e==="fileUrl"?t.href===r.href:t===r,Qb=({otherStdioItems:e,type:t,value:r,optionName:i})=>{let n=e.find(({value:{transform:s}})=>s===r.transform);Vd(n,i,t)},Vd=(e,t,r)=>{if(e!==void 0)throw new TypeError(`The \`${e.optionName}\` and \`${t}\` options must not target ${We[r]} that is the same.`)};var bi=(e,t,r,i)=>{let s=Ld(t,r,i).map((a,c)=>Zb({stdioOption:a,fdNumber:c,options:t,isSync:i})),o=ax({initialFileDescriptors:s,addProperties:e,options:t,isSync:i});return t.stdio=o.map(({stdioItems:a})=>dx(a)),o},Zb=({stdioOption:e,fdNumber:t,options:r,isSync:i})=>{let n=Tr(t),{stdioItems:s,isStdioArray:o}=ex({stdioOption:e,fdNumber:t,options:r,optionName:n}),a=Rd(s,t,n),c=s.map(u=>Ud({stdioItem:u,isStdioArray:o,fdNumber:t,direction:a,isSync:i})),d=Id(c,n,a,r),p=Od(d,a);return ox(d,p),{direction:a,objectMode:p,stdioItems:d}},ex=({stdioOption:e,fdNumber:t,options:r,optionName:i})=>{let s=[...(Array.isArray(e)?e:[e]).map(c=>tx(c,i)),...Bd(r,t)],o=Nd(s),a=o.length>1;return rx(o,a,i),nx(o),{stdioItems:o,isStdioArray:a}},tx=(e,t)=>({type:kd(e,t),value:e,optionName:t}),rx=(e,t,r)=>{if(e.length===0)throw new TypeError(`The \`${r}\` option must not be an empty array.`);if(t){for(let{value:i,optionName:n}of e)if(ix.has(i))throw new Error(`The \`${n}\` option must not include \`${i}\`.`)}},ix=new Set(["ignore","ipc"]),nx=e=>{for(let t of e)sx(t)},sx=({type:e,value:t,optionName:r})=>{if($d(t))throw new TypeError(`The \`${r}: URL\` option must use the \`file:\` scheme.
|
|
69
|
+
For example, you can use the \`pathToFileURL()\` method of the \`url\` core module.`);if(Cd(e,t))throw new TypeError(`The \`${r}: { file: '...' }\` option must be used instead of \`${r}: '...'\`.`)},ox=(e,t)=>{if(!t)return;let r=e.find(({type:i})=>_i.has(i));if(r!==void 0)throw new TypeError(`The \`${r.optionName}\` option cannot use both files and transforms in objectMode.`)},ax=({initialFileDescriptors:e,addProperties:t,options:r,isSync:i})=>{let n=[];try{for(let s of e)n.push(cx({fileDescriptor:s,fileDescriptors:n,addProperties:t,options:r,isSync:i}));return n}catch(s){throw Os(n),s}},cx=({fileDescriptor:{direction:e,objectMode:t,stdioItems:r},fileDescriptors:i,addProperties:n,options:s,isSync:o})=>{let a=r.map(c=>px({stdioItem:c,addProperties:n,direction:e,options:s,fileDescriptors:i,isSync:o}));return{direction:e,objectMode:t,stdioItems:a}},px=({stdioItem:e,addProperties:t,direction:r,options:i,fileDescriptors:n,isSync:s})=>{let o=Gd({stdioItem:e,direction:r,fileDescriptors:n,isSync:s});return o!==void 0?{...e,stream:o}:{...e,...t[r][e.type](e,i)}},Os=e=>{for(let{stdioItems:t}of e)for(let{stream:r}of t)r!==void 0&&!fe(r)&&r.destroy()},dx=e=>{if(e.length>1)return e.some(({value:i})=>i==="overlapped")?"overlapped":"pipe";let[{type:t,value:r}]=e;return t==="native"?r:"pipe"};var Kd=(e,t)=>bi(lx,e,t,!0),$e=({type:e,optionName:t})=>{Yd(t,We[e])},ux=({optionName:e,value:t})=>((t==="ipc"||t==="overlapped")&&Yd(e,`"${t}"`),{}),Yd=(e,t)=>{throw new TypeError(`The \`${e}\` option cannot be ${t} with synchronous methods.`)},Hd={generator(){},asyncGenerator:$e,webStream:$e,nodeStream:$e,webTransform:$e,duplex:$e,asyncIterable:$e,native:ux},lx={input:{...Hd,fileUrl:({value:e})=>({contents:[De(Wd(e))]}),filePath:({value:{file:e}})=>({contents:[De(Wd(e))]}),fileNumber:$e,iterable:({value:e})=>({contents:[...e]}),string:({value:e})=>({contents:[e]}),uint8Array:({value:e})=>({contents:[e]})},output:{...Hd,fileUrl:({value:e})=>({path:e}),filePath:({value:{file:e,append:t}})=>({path:e,append:t}),fileNumber:({value:e})=>({path:e}),iterable:$e,string:$e,uint8Array:$e}};var Fe=(e,{stripFinalNewline:t},r)=>Is(t,r)&&e!==void 0&&!Array.isArray(e)?$t(e):e,Is=(e,t)=>t==="all"?e[1]||e[2]:e[t];import{Transform as Ix,getDefaultHighWaterMark as ou}from"stream";var xi=(e,t,r,i)=>e||r?void 0:Xd(t,i),js=(e,t,r)=>r?e.flatMap(i=>Jd(i,t)):Jd(e,t),Jd=(e,t)=>{let{transform:r,final:i}=Xd(t,{});return[...r(e),...i()]},Xd=(e,t)=>(t.previousChunks="",{transform:mx.bind(void 0,t,e),final:yx.bind(void 0,t)}),mx=function*(e,t,r){if(typeof r!="string"){yield r;return}let{previousChunks:i}=e,n=-1;for(let s=0;s<r.length;s+=1)if(r[s]===`
|
|
70
|
+
`){let o=hx(r,s,t,e),a=r.slice(n+1,s+1-o);i.length>0&&(a=Rs(i,a),i=""),yield a,n=s}n!==r.length-1&&(i=Rs(i,r.slice(n+1))),e.previousChunks=i},hx=(e,t,r,i)=>r?0:(i.isWindowsNewline=t!==0&&e[t-1]==="\r",i.isWindowsNewline?2:1),yx=function*({previousChunks:e}){e.length>0&&(yield e)},Qd=({binary:e,preserveNewlines:t,readableObjectMode:r,state:i})=>e||t||r?void 0:{transform:fx.bind(void 0,i)},fx=function*({isWindowsNewline:e=!1},t){let{unixNewline:r,windowsNewline:i,LF:n,concatBytes:s}=typeof t=="string"?gx:bx;if(t.at(-1)===n){yield t;return}yield s(t,e?i:r)},Rs=(e,t)=>`${e}${t}`,gx={windowsNewline:`\r
|
|
137
71
|
`,unixNewline:`
|
|
138
72
|
`,LF:`
|
|
139
|
-
`,concatBytes:
|
|
73
|
+
`,concatBytes:Rs},_x=(e,t)=>{let r=new Uint8Array(e.length+t.length);return r.set(e,0),r.set(t,e.length),r},bx={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:_x};import{Buffer as xx}from"buffer";var Zd=(e,t)=>e?void 0:wx.bind(void 0,t),wx=function*(e,t){if(typeof t!="string"&&!H(t)&&!xx.isBuffer(t))throw new TypeError(`The \`${e}\` option's transform must use "objectMode: true" to receive as input: ${typeof t}.`);yield t},eu=(e,t)=>e?kx.bind(void 0,t):Sx.bind(void 0,t),kx=function*(e,t){tu(e,t),yield t},Sx=function*(e,t){if(tu(e,t),typeof t!="string"&&!H(t))throw new TypeError(`The \`${e}\` option's function must yield a string or an Uint8Array, not ${typeof t}.`);yield t},tu=(e,t)=>{if(t==null)throw new TypeError(`The \`${e}\` option's function must not call \`yield ${t}\`.
|
|
140
74
|
Instead, \`yield\` should either be called with a value, or not be called at all. For example:
|
|
141
|
-
if (condition) { yield value; }`)};import{Buffer as K0}from"buffer";import{StringDecoder as J0}from"string_decoder";var dn=(e,t,r)=>{if(r)return;if(e)return{transform:X0.bind(void 0,new TextEncoder)};let n=new J0(t);return{transform:Z0.bind(void 0,n),final:Q0.bind(void 0,n)}},X0=function*(e,t){K0.isBuffer(t)?yield Ie(t):typeof t=="string"?yield e.encode(t):yield t},Z0=function*(e,t){yield V(t)?e.write(t):t},Q0=function*(e){let t=e.end();t!==""&&(yield t)};import{callbackify as Gu}from"util";var yi=Gu(async(e,t,r,n)=>{t.currentIterable=e(...r);try{for await(let o of t.currentIterable)n.push(o)}finally{delete t.currentIterable}}),mn=async function*(e,t,r){if(r===t.length){yield e;return}let{transform:n=tx}=t[r];for await(let o of n(e))yield*mn(o,t,r+1)},Vu=async function*(e){for(let[t,{final:r}]of Object.entries(e))yield*ex(r,Number(t),e)},ex=async function*(e,t,r){if(e!==void 0)for await(let n of e())yield*mn(n,r,t+1)},Wu=Gu(async({currentIterable:e},t)=>{if(e!==void 0){await(t?e.throw(t):e.return());return}if(t)throw t}),tx=function*(e){yield e};var xi=(e,t,r,n)=>{try{for(let o of e(...t))r.push(o);n()}catch(o){n(o)}},Hu=(e,t)=>[...t.flatMap(r=>[...Je(r,e,0)]),...Ut(e)],Je=function*(e,t,r){if(r===t.length){yield e;return}let{transform:n=nx}=t[r];for(let o of n(e))yield*Je(o,t,r+1)},Ut=function*(e){for(let[t,{final:r}]of Object.entries(e))yield*rx(r,Number(t),e)},rx=function*(e,t,r){if(e!==void 0)for(let n of e())yield*Je(n,r,t+1)},nx=function*(e){yield e};var wi=({value:e,value:{transform:t,final:r,writableObjectMode:n,readableObjectMode:o},optionName:i},{encoding:s})=>{let a={},c=qu(e,s,i),u=Ke(t),l=Ke(r),d=u?yi.bind(void 0,mn,a):xi.bind(void 0,Je),m=u||l?yi.bind(void 0,Vu,a):xi.bind(void 0,Ut),p=u||l?Wu.bind(void 0,a):void 0;return{stream:new ox({writableObjectMode:n,writableHighWaterMark:zu(n),readableObjectMode:o,readableHighWaterMark:zu(o),transform(g,w,x){d([g,c,0],this,x)},flush(g){m([c],this,g)},destroy:p})}},pn=(e,t,r,n)=>{let o=t.filter(({type:s})=>s==="generator"),i=n?o.reverse():o;for(let{value:s,optionName:a}of i){let c=qu(s,r,a);e=Hu(c,e)}return e},qu=({transform:e,final:t,binary:r,writableObjectMode:n,readableObjectMode:o,preserveNewlines:i},s,a)=>{let c={};return[{transform:Nu(n,a)},dn(r,s,n),un(r,i,n,c),{transform:e,final:t},{transform:Uu(o,a)},ju({binary:r,preserveNewlines:i,readableObjectMode:o,state:c})].filter(Boolean)};var Yu=(e,t)=>{for(let r of ix(e))sx(e,r,t)},ix=e=>new Set(Object.entries(e).filter(([,{direction:t}])=>t==="input").map(([t])=>Number(t))),sx=(e,t,r)=>{let{stdioItems:n}=e[t],o=n.filter(({contents:a})=>a!==void 0);if(o.length===0)return;if(t!==0){let[{type:a,optionName:c}]=o;throw new TypeError(`Only the \`stdin\` option, not \`${c}\`, can be ${Ue[a]} with synchronous methods.`)}let s=o.map(({contents:a})=>a).map(a=>ax(a,n));r.input=It(s)},ax=(e,t)=>{let r=pn(e,t,"utf8",!0);return cx(r),It(r)},cx=e=>{let t=e.find(r=>typeof r!="string"&&!V(r));if(t!==void 0)throw new TypeError(`The \`stdin\` option is invalid: when passing objects as input, a transform must be used to serialize them to strings or Uint8Arrays: ${t}.`)};import{writeFileSync as mx,appendFileSync as px}from"fs";var fn=({stdioItems:e,encoding:t,verboseInfo:r,fdNumber:n})=>n!=="all"&&st(r,n)&&!te.has(t)&&lx(n)&&(e.some(({type:o,value:i})=>o==="native"&&ux.has(i))||e.every(({type:o})=>ce.has(o))),lx=e=>e===1||e===2,ux=new Set(["pipe","overlapped"]),Ku=async(e,t,r,n)=>{for await(let o of e)dx(t)||Xu(o,r,n)},Ju=(e,t,r)=>{for(let n of e)Xu(n,t,r)},dx=e=>e._readableState.pipes.length>0,Xu=(e,t,r)=>{let n=Cr(e);xe({type:"output",verboseMessage:n,fdNumber:t,verboseInfo:r})};var Zu=({fileDescriptors:e,syncResult:{output:t},options:r,isMaxBuffer:n,verboseInfo:o})=>{if(t===null)return{output:Array.from({length:3})};let i={},s=new Set([]);return{output:t.map((c,u)=>fx({result:c,fileDescriptors:e,fdNumber:u,state:i,outputFiles:s,isMaxBuffer:n,verboseInfo:o},r)),...i}},fx=({result:e,fileDescriptors:t,fdNumber:r,state:n,outputFiles:o,isMaxBuffer:i,verboseInfo:s},{buffer:a,encoding:c,lines:u,stripFinalNewline:l,maxBuffer:d})=>{if(e===null)return;let m=Ql(e,i,d),p=Ie(m),{stdioItems:f,objectMode:g}=t[r],w=hx([p],f,c,n),{serializedResult:x,finalResult:C=x}=gx({chunks:w,objectMode:g,encoding:c,lines:u,stripFinalNewline:l,fdNumber:r});bx({serializedResult:x,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:f,objectMode:g});let v=a[r]?C:void 0;try{return n.error===void 0&&yx(x,f,o),v}catch(A){return n.error=A,v}},hx=(e,t,r,n)=>{try{return pn(e,t,r,!1)}catch(o){return n.error=o,e}},gx=({chunks:e,objectMode:t,encoding:r,lines:n,stripFinalNewline:o,fdNumber:i})=>{if(t)return{serializedResult:e};if(r==="buffer")return{serializedResult:It(e)};let s=pa(e,r);return n[i]?{serializedResult:s,finalResult:bi(s,!o[i],t)}:{serializedResult:s}},bx=({serializedResult:e,fdNumber:t,state:r,verboseInfo:n,encoding:o,stdioItems:i,objectMode:s})=>{if(!fn({stdioItems:i,encoding:o,verboseInfo:n,fdNumber:t}))return;let a=bi(e,!1,s);try{Ju(a,t,n)}catch(c){r.error??=c}},yx=(e,t,r)=>{for(let{path:n,append:o}of t.filter(({type:i})=>cn.has(i))){let i=typeof n=="string"?n:n.toString();o||r.has(i)?px(n,e):(r.add(i),mx(n,e))}};var Qu=([,e,t],r)=>{if(r.all)return e===void 0?t:t===void 0?e:Array.isArray(e)?Array.isArray(t)?[...e,...t]:[...e,Me(t,r,"all")]:Array.isArray(t)?[Me(e,r,"all"),...t]:V(e)&&V(t)?Oo([e,t]):`${e}${t}`};import{once as Si}from"events";var ed=async(e,t)=>{let[r,n]=await xx(e);return t.isForcefullyTerminated??=!1,[r,n]},xx=async e=>{let[t,r]=await Promise.allSettled([Si(e,"spawn"),Si(e,"exit")]);return t.status==="rejected"?[]:r.status==="rejected"?td(e):r.value},td=async e=>{try{return await Si(e,"exit")}catch{return td(e)}},rd=async e=>{let[t,r]=await e;if(!wx(t,r)&&_i(t,r))throw new pe;return[t,r]},wx=(e,t)=>e===void 0&&t===void 0,_i=(e,t)=>e!==0||t!==null;var nd=({error:e,status:t,signal:r,output:n},{maxBuffer:o})=>{let i=Sx(e,t,r),s=i?.code==="ETIMEDOUT",a=Zl(i,n,o);return{resultError:i,exitCode:t,signal:r,timedOut:s,isMaxBuffer:a}},Sx=(e,t,r)=>e!==void 0?e:_i(t,r)?new pe:void 0;var od=(e,t,r)=>{let{file:n,commandArguments:o,command:i,escapedCommand:s,startTime:a,verboseInfo:c,options:u,fileDescriptors:l}=Ex(e,t,r),d=Ox({file:n,commandArguments:o,options:u,command:i,escapedCommand:s,verboseInfo:c,fileDescriptors:l,startTime:a});return ht(d,c,u)},Ex=(e,t,r)=>{let{command:n,escapedCommand:o,startTime:i,verboseInfo:s}=vr(e,t,r),a=$x(r),{file:c,commandArguments:u,options:l}=Yr(e,t,a);Cx(l);let d=Pu(l,s);return{file:c,commandArguments:u,command:n,escapedCommand:o,startTime:i,verboseInfo:s,options:l,fileDescriptors:d}},$x=e=>e.node&&!e.ipc?{...e,ipc:!1}:e,Cx=({ipc:e,ipcInput:t,detached:r,cancelSignal:n})=>{t&&hn("ipcInput"),e&&hn("ipc: true"),r&&hn("detached: true"),n&&hn("cancelSignal")},hn=e=>{throw new TypeError(`The "${e}" option cannot be used with synchronous methods.`)},Ox=({file:e,commandArguments:t,options:r,command:n,escapedCommand:o,verboseInfo:i,fileDescriptors:s,startTime:a})=>{let c=vx({file:e,commandArguments:t,options:r,command:n,escapedCommand:o,fileDescriptors:s,startTime:a});if(c.failed)return c;let{resultError:u,exitCode:l,signal:d,timedOut:m,isMaxBuffer:p}=nd(c,r),{output:f,error:g=u}=Zu({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:i}),w=f.map((C,v)=>Me(C,r,v)),x=Me(Qu(f,r),r,"all");return Ax({error:g,exitCode:l,signal:d,timedOut:m,isMaxBuffer:p,stdio:w,all:x,options:r,command:n,escapedCommand:o,startTime:a})},vx=({file:e,commandArguments:t,options:r,command:n,escapedCommand:o,fileDescriptors:i,startTime:s})=>{try{Yu(i,r);let a=Tx(r);return _x(...Kr(e,t,a))}catch(a){return ft({error:a,command:n,escapedCommand:o,fileDescriptors:i,options:r,startTime:s,isSync:!0})}},Tx=({encoding:e,maxBuffer:t,...r})=>({...r,encoding:"buffer",maxBuffer:nn(t)}),Ax=({error:e,exitCode:t,signal:r,timedOut:n,isMaxBuffer:o,stdio:i,all:s,options:a,command:c,escapedCommand:u,startTime:l})=>e===void 0?on({command:c,escapedCommand:u,stdio:i,all:s,ipcOutput:[],options:a,startTime:l}):Nt({error:e,command:c,escapedCommand:u,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:o,isForcefullyTerminated:!1,exitCode:t,signal:r,stdio:i,all:s,ipcOutput:[],options:a,startTime:l,isSync:!0});import{setMaxListeners as gS}from"events";import{spawn as bS}from"child_process";import ld from"process";import{once as Ei,on as Ix}from"events";var id=({anyProcess:e,channel:t,isSubprocess:r,ipc:n},{reference:o=!0,filter:i}={})=>(lt({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:Gr(e)}),Dx({anyProcess:e,channel:t,isSubprocess:r,filter:i,reference:o})),Dx=async({anyProcess:e,channel:t,isSubprocess:r,filter:n,reference:o})=>{jr(t,o);let i=Ne(e,t,r),s=new AbortController;try{return await Promise.race([Rx(i,n,s),Mx(i,r,s),Px(i,r,s)])}catch(a){throw ut(e),a}finally{s.abort(),Nr(t,o)}},Rx=async(e,t,{signal:r})=>{if(t===void 0){let[n]=await Ei(e,"message",{signal:r});return n}for await(let[n]of Ix(e,"message",{signal:r}))if(t(n))return n},Mx=async(e,t,{signal:r})=>{await Ei(e,"disconnect",{signal:r}),Hc(t)},Px=async(e,t,{signal:r})=>{let[n]=await Ei(e,"strict:error",{signal:r});throw Lr(n,t)};import{once as ad,on as Lx}from"events";var cd=({anyProcess:e,channel:t,isSubprocess:r,ipc:n},{reference:o=!0}={})=>$i({anyProcess:e,channel:t,isSubprocess:r,ipc:n,shouldAwait:!r,reference:o}),$i=({anyProcess:e,channel:t,isSubprocess:r,ipc:n,shouldAwait:o,reference:i})=>{lt({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:Gr(e)}),jr(t,i);let s=Ne(e,t,r),a=new AbortController,c={};return kx(e,s,a),Fx({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),jx({anyProcess:e,channel:t,ipcEmitter:s,isSubprocess:r,shouldAwait:o,controller:a,state:c,reference:i})},kx=async(e,t,r)=>{try{await ad(t,"disconnect",{signal:r.signal}),r.abort()}catch{}},Fx=async({ipcEmitter:e,isSubprocess:t,controller:r,state:n})=>{try{let[o]=await ad(e,"strict:error",{signal:r.signal});n.error=Lr(o,t),r.abort()}catch{}},jx=async function*({anyProcess:e,channel:t,ipcEmitter:r,isSubprocess:n,shouldAwait:o,controller:i,state:s,reference:a}){try{for await(let[c]of Lx(r,"message",{signal:i.signal}))sd(s),yield c}catch{sd(s)}finally{i.abort(),Nr(t,a),n||ut(e),o&&await e}},sd=({error:e})=>{if(e)throw e};var ud=(e,{ipc:t})=>{Object.assign(e,md(e,!1,t))},dd=()=>{let e=ld,t=!0,r=ld.channel!==void 0;return{...md(e,t,r),getCancelSignal:yl.bind(void 0,{anyProcess:e,channel:e.channel,isSubprocess:t,ipc:r})}},md=(e,t,r)=>({sendMessage:zr.bind(void 0,{anyProcess:e,channel:e.channel,isSubprocess:t,ipc:r}),getOneMessage:id.bind(void 0,{anyProcess:e,channel:e.channel,isSubprocess:t,ipc:r}),getEachMessage:cd.bind(void 0,{anyProcess:e,channel:e.channel,isSubprocess:t,ipc:r})});import{ChildProcess as Nx}from"child_process";import{PassThrough as Ux,Readable as Bx,Writable as Gx,Duplex as Vx}from"stream";var pd=({error:e,command:t,escapedCommand:r,fileDescriptors:n,options:o,startTime:i,verboseInfo:s})=>{fi(n);let a=new Nx;Wx(a,n),Object.assign(a,{readable:Hx,writable:zx,duplex:qx});let c=ft({error:e,command:t,escapedCommand:r,fileDescriptors:n,options:o,startTime:i,isSync:!1}),u=Yx(c,s,o);return{subprocess:a,promise:u}},Wx=(e,t)=>{let r=Bt(),n=Bt(),o=Bt(),i=Array.from({length:t.length-3},Bt),s=Bt(),a=[r,n,o,...i];Object.assign(e,{stdin:r,stdout:n,stderr:o,all:s,stdio:a})},Bt=()=>{let e=new Ux;return e.end(),e},Hx=()=>new Bx({read(){}}),zx=()=>new Gx({write(){}}),qx=()=>new Vx({read(){},write(){}}),Yx=async(e,t,r)=>ht(e,t,r);import{createReadStream as fd,createWriteStream as hd}from"fs";import{Buffer as Kx}from"buffer";import{Readable as Gt,Writable as Jx,Duplex as Xx}from"stream";var bd=(e,t)=>ln(Zx,e,t,!1),Vt=({type:e,optionName:t})=>{throw new TypeError(`The \`${t}\` option cannot be ${Ue[e]}.`)},gd={fileNumber:Vt,generator:wi,asyncGenerator:wi,nodeStream:({value:e})=>({stream:e}),webTransform({value:{transform:e,writableObjectMode:t,readableObjectMode:r}}){let n=t||r;return{stream:Xx.fromWeb(e,{objectMode:n})}},duplex:({value:{transform:e}})=>({stream:e}),native(){}},Zx={input:{...gd,fileUrl:({value:e})=>({stream:fd(e)}),filePath:({value:{file:e}})=>({stream:fd(e)}),webStream:({value:e})=>({stream:Gt.fromWeb(e)}),iterable:({value:e})=>({stream:Gt.from(e)}),asyncIterable:({value:e})=>({stream:Gt.from(e)}),string:({value:e})=>({stream:Gt.from(e)}),uint8Array:({value:e})=>({stream:Gt.from(Kx.from(e))})},output:{...gd,fileUrl:({value:e})=>({stream:hd(e)}),filePath:({value:{file:e,append:t}})=>({stream:hd(e,t?{flags:"a"}:{})}),webStream:({value:e})=>({stream:Jx.fromWeb(e)}),iterable:Vt,asyncIterable:Vt,string:Vt,uint8Array:Vt}};import{on as Qx,once as yd}from"events";import{PassThrough as ew,getDefaultHighWaterMark as tw}from"stream";import{finished as Sd}from"stream/promises";function Xe(e){if(!Array.isArray(e))throw new TypeError(`Expected an array, got \`${typeof e}\`.`);for(let o of e)Oi(o);let t=e.some(({readableObjectMode:o})=>o),r=rw(e,t),n=new Ci({objectMode:t,writableHighWaterMark:r,readableHighWaterMark:r});for(let o of e)n.add(o);return n}var rw=(e,t)=>{if(e.length===0)return tw(t);let r=e.filter(({readableObjectMode:n})=>n===t).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},Ci=class extends ew{#t=new Set([]);#r=new Set([]);#e=new Set([]);#n;#i=Symbol("unpipe");#o=new WeakMap;add(t){if(Oi(t),this.#t.has(t))return;this.#t.add(t),this.#n??=nw(this,this.#t,this.#i);let r=sw({passThroughStream:this,stream:t,streams:this.#t,ended:this.#r,aborted:this.#e,onFinished:this.#n,unpipeEvent:this.#i});this.#o.set(t,r),t.pipe(this,{end:!1})}async remove(t){if(Oi(t),!this.#t.has(t))return!1;let r=this.#o.get(t);return r===void 0?!1:(this.#o.delete(t),t.unpipe(this),await r,!0)}},nw=async(e,t,r)=>{gn(e,xd);let n=new AbortController;try{await Promise.race([ow(e,n),iw(e,t,r,n)])}finally{n.abort(),gn(e,-xd)}},ow=async(e,{signal:t})=>{try{await Sd(e,{signal:t,cleanup:!0})}catch(r){throw _d(e,r),r}},iw=async(e,t,r,{signal:n})=>{for await(let[o]of Qx(e,"unpipe",{signal:n}))t.has(o)&&o.emit(r)},Oi=e=>{if(typeof e?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof e}\`.`)},sw=async({passThroughStream:e,stream:t,streams:r,ended:n,aborted:o,onFinished:i,unpipeEvent:s})=>{gn(e,wd);let a=new AbortController;try{await Promise.race([aw(i,t,a),cw({passThroughStream:e,stream:t,streams:r,ended:n,aborted:o,controller:a}),lw({stream:t,streams:r,ended:n,aborted:o,unpipeEvent:s,controller:a})])}finally{a.abort(),gn(e,-wd)}r.size>0&&r.size===n.size+o.size&&(n.size===0&&o.size>0?vi(e):uw(e))},aw=async(e,t,{signal:r})=>{try{await e,r.aborted||vi(t)}catch(n){r.aborted||_d(t,n)}},cw=async({passThroughStream:e,stream:t,streams:r,ended:n,aborted:o,controller:{signal:i}})=>{try{await Sd(t,{signal:i,cleanup:!0,readable:!0,writable:!1}),r.has(t)&&n.add(t)}catch(s){if(i.aborted||!r.has(t))return;Ed(s)?o.add(t):$d(e,s)}},lw=async({stream:e,streams:t,ended:r,aborted:n,unpipeEvent:o,controller:{signal:i}})=>{if(await yd(e,o,{signal:i}),!e.readable)return yd(i,"abort",{signal:i});t.delete(e),r.delete(e),n.delete(e)},uw=e=>{e.writable&&e.end()},_d=(e,t)=>{Ed(t)?vi(e):$d(e,t)},Ed=e=>e?.code==="ERR_STREAM_PREMATURE_CLOSE",vi=e=>{(e.readable||e.writable)&&e.destroy()},$d=(e,t)=>{e.destroyed||(e.once("error",dw),e.destroy(t))},dw=()=>{},gn=(e,t)=>{let r=e.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&e.setMaxListeners(r+t)},xd=2,wd=1;import{finished as Cd}from"stream/promises";var bt=(e,t)=>{e.pipe(t),mw(e,t),pw(e,t)},mw=async(e,t)=>{if(!(me(e)||me(t))){try{await Cd(e,{cleanup:!0,readable:!0,writable:!1})}catch{}Ti(t)}},Ti=e=>{e.writable&&e.end()},pw=async(e,t)=>{if(!(me(e)||me(t))){try{await Cd(t,{cleanup:!0,readable:!1,writable:!0})}catch{}Ai(e)}},Ai=e=>{e.readable&&e.destroy()};var Od=(e,t,r)=>{let n=new Map;for(let[o,{stdioItems:i,direction:s}]of Object.entries(t)){for(let{stream:a}of i.filter(({type:c})=>ce.has(c)))fw(e,a,s,o);for(let{stream:a}of i.filter(({type:c})=>!ce.has(c)))gw({subprocess:e,stream:a,direction:s,fdNumber:o,pipeGroups:n,controller:r})}for(let[o,i]of n.entries()){let s=i.length===1?i[0]:Xe(i);bt(s,o)}},fw=(e,t,r,n)=>{r==="output"?bt(e.stdio[n],t):bt(t,e.stdio[n]);let o=hw[n];o!==void 0&&(e[o]=t),e.stdio[n]=t},hw=["stdin","stdout","stderr"],gw=({subprocess:e,stream:t,direction:r,fdNumber:n,pipeGroups:o,controller:i})=>{if(t===void 0)return;bw(t,i);let[s,a]=r==="output"?[t,e.stdio[n]]:[e.stdio[n],t],c=o.get(s)??[];o.set(s,[...c,a])},bw=(e,{signal:t})=>{me(e)&&qe(e,yw,t)},yw=2;import{addAbortListener as Sw}from"events";var Ze=[];Ze.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Ze.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Ze.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var bn=e=>!!e&&typeof e=="object"&&typeof e.removeListener=="function"&&typeof e.emit=="function"&&typeof e.reallyExit=="function"&&typeof e.listeners=="function"&&typeof e.kill=="function"&&typeof e.pid=="number"&&typeof e.on=="function",Ii=Symbol.for("signal-exit emitter"),Di=globalThis,xw=Object.defineProperty.bind(Object),Ri=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(Di[Ii])return Di[Ii];xw(Di,Ii,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(t,r){this.listeners[t].push(r)}removeListener(t,r){let n=this.listeners[t],o=n.indexOf(r);o!==-1&&(o===0&&n.length===1?n.length=0:n.splice(o,1))}emit(t,r,n){if(this.emitted[t])return!1;this.emitted[t]=!0;let o=!1;for(let i of this.listeners[t])o=i(r,n)===!0||o;return t==="exit"&&(o=this.emit("afterExit",r,n)||o),o}},yn=class{},ww=e=>({onExit(t,r){return e.onExit(t,r)},load(){return e.load()},unload(){return e.unload()}}),Mi=class extends yn{onExit(){return()=>{}}load(){}unload(){}},Pi=class extends yn{#t=Li.platform==="win32"?"SIGINT":"SIGHUP";#r=new Ri;#e;#n;#i;#o={};#s=!1;constructor(t){super(),this.#e=t,this.#o={};for(let r of Ze)this.#o[r]=()=>{let n=this.#e.listeners(r),{count:o}=this.#r,i=t;if(typeof i.__signal_exit_emitter__=="object"&&typeof i.__signal_exit_emitter__.count=="number"&&(o+=i.__signal_exit_emitter__.count),n.length===o){this.unload();let s=this.#r.emit("exit",null,r),a=r==="SIGHUP"?this.#t:r;s||t.kill(t.pid,a)}};this.#i=t.reallyExit,this.#n=t.emit}onExit(t,r){if(!bn(this.#e))return()=>{};this.#s===!1&&this.load();let n=r?.alwaysLast?"afterExit":"exit";return this.#r.on(n,t),()=>{this.#r.removeListener(n,t),this.#r.listeners.exit.length===0&&this.#r.listeners.afterExit.length===0&&this.unload()}}load(){if(!this.#s){this.#s=!0,this.#r.count+=1;for(let t of Ze)try{let r=this.#o[t];r&&this.#e.on(t,r)}catch{}this.#e.emit=(t,...r)=>this.#c(t,...r),this.#e.reallyExit=t=>this.#a(t)}}unload(){this.#s&&(this.#s=!1,Ze.forEach(t=>{let r=this.#o[t];if(!r)throw new Error("Listener not defined for signal: "+t);try{this.#e.removeListener(t,r)}catch{}}),this.#e.emit=this.#n,this.#e.reallyExit=this.#i,this.#r.count-=1)}#a(t){return bn(this.#e)?(this.#e.exitCode=t||0,this.#r.emit("exit",this.#e.exitCode,null),this.#i.call(this.#e,this.#e.exitCode)):0}#c(t,...r){let n=this.#n;if(t==="exit"&&bn(this.#e)){typeof r[0]=="number"&&(this.#e.exitCode=r[0]);let o=n.call(this.#e,t,...r);return this.#r.emit("exit",this.#e.exitCode,null),o}else return n.call(this.#e,t,...r)}},Li=globalThis.process,{onExit:vd,load:RI,unload:MI}=ww(bn(Li)?new Pi(Li):new Mi);var Td=(e,{cleanup:t,detached:r},{signal:n})=>{if(!t||r)return;let o=vd(()=>{e.kill()});Sw(n,()=>{o()})};var Id=({source:e,sourcePromise:t,boundOptions:r,createNested:n},...o)=>{let i=Or(),{destination:s,destinationStream:a,destinationError:c,from:u,unpipeSignal:l}=_w(r,n,o),{sourceStream:d,sourceError:m}=$w(e,u),{options:p,fileDescriptors:f}=Se.get(e);return{sourcePromise:t,sourceStream:d,sourceOptions:p,sourceError:m,destination:s,destinationStream:a,destinationError:c,unpipeSignal:l,fileDescriptors:f,startTime:i}},_w=(e,t,r)=>{try{let{destination:n,pipeOptions:{from:o,to:i,unpipeSignal:s}={}}=Ew(e,t,...r),a=Fr(n,i);return{destination:n,destinationStream:a,from:o,unpipeSignal:s}}catch(n){return{destinationError:n}}},Ew=(e,t,r,...n)=>{if(Array.isArray(r))return{destination:t(Ad,e)(r,...n),pipeOptions:e};if(typeof r=="string"||r instanceof URL||$o(r)){if(Object.keys(e).length>0)throw new TypeError('Please use .pipe("file", ..., options) or .pipe(execa("file", ..., options)) instead of .pipe(options)("file", ...).');let[o,i,s]=gr(r,...n);return{destination:t(Ad)(o,i,s),pipeOptions:s}}if(Se.has(r)){if(Object.keys(e).length>0)throw new TypeError("Please use .pipe(options)`command` or .pipe($(options)`command`) instead of .pipe(options)($`command`).");return{destination:r,pipeOptions:n[0]}}throw new TypeError(`The first argument must be a template string, an options object, or an Execa subprocess: ${r}`)},Ad=({options:e})=>({options:{...e,stdin:"pipe",piped:!0}}),$w=(e,t)=>{try{return{sourceStream:dt(e,t)}}catch(r){return{sourceError:r}}};var Rd=({sourceStream:e,sourceError:t,destinationStream:r,destinationError:n,fileDescriptors:o,sourceOptions:i,startTime:s})=>{let a=Cw({sourceStream:e,sourceError:t,destinationStream:r,destinationError:n});if(a!==void 0)throw ki({error:a,fileDescriptors:o,sourceOptions:i,startTime:s})},Cw=({sourceStream:e,sourceError:t,destinationStream:r,destinationError:n})=>{if(t!==void 0&&n!==void 0)return n;if(n!==void 0)return Ai(e),n;if(t!==void 0)return Ti(r),t},ki=({error:e,fileDescriptors:t,sourceOptions:r,startTime:n})=>ft({error:e,command:Dd,escapedCommand:Dd,fileDescriptors:t,options:r,startTime:n,isSync:!1}),Dd="source.pipe(destination)";var Md=async e=>{let[{status:t,reason:r,value:n=r},{status:o,reason:i,value:s=i}]=await e;if(s.pipedFrom.includes(n)||s.pipedFrom.push(n),o==="rejected")throw s;if(t==="rejected")throw n;return s};import{finished as Ow}from"stream/promises";var Pd=(e,t,r)=>{let n=xn.has(t)?Tw(e,t):vw(e,t);return qe(e,Iw,r.signal),qe(t,Dw,r.signal),Aw(t),n},vw=(e,t)=>{let r=Xe([e]);return bt(r,t),xn.set(t,r),r},Tw=(e,t)=>{let r=xn.get(t);return r.add(e),r},Aw=async e=>{try{await Ow(e,{cleanup:!0,readable:!1,writable:!0})}catch{}xn.delete(e)},xn=new WeakMap,Iw=2,Dw=1;import{aborted as Rw}from"util";var Ld=(e,t)=>e===void 0?[]:[Mw(e,t)],Mw=async(e,{sourceStream:t,mergedStream:r,fileDescriptors:n,sourceOptions:o,startTime:i})=>{await Rw(e,t),await r.remove(t);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw ki({error:s,fileDescriptors:n,sourceOptions:o,startTime:i})};var wn=(e,...t)=>{if(j(t[0]))return wn.bind(void 0,{...e,boundOptions:{...e.boundOptions,...t[0]}});let{destination:r,...n}=Id(e,...t),o=Pw({...n,destination:r});return o.pipe=wn.bind(void 0,{...e,source:r,sourcePromise:o,boundOptions:{}}),o},Pw=async({sourcePromise:e,sourceStream:t,sourceOptions:r,sourceError:n,destination:o,destinationStream:i,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:u})=>{let l=Lw(e,o);Rd({sourceStream:t,sourceError:n,destinationStream:i,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:u});let d=new AbortController;try{let m=Pd(t,i,d);return await Promise.race([Md(l),...Ld(a,{sourceStream:t,mergedStream:m,sourceOptions:r,fileDescriptors:c,startTime:u})])}finally{d.abort()}},Lw=(e,t)=>Promise.allSettled([e,t]);import{setImmediate as Gw}from"timers/promises";import{on as kw}from"events";import{getDefaultHighWaterMark as Fw}from"stream";var Sn=({subprocessStdout:e,subprocess:t,binary:r,shouldEncode:n,encoding:o,preserveNewlines:i})=>{let s=new AbortController;return jw(t,s),Fd({stream:e,controller:s,binary:r,shouldEncode:!e.readableObjectMode&&n,encoding:o,shouldSplit:!e.readableObjectMode,preserveNewlines:i})},jw=async(e,t)=>{try{await e}catch{}finally{t.abort()}},Fi=({stream:e,onStreamEnd:t,lines:r,encoding:n,stripFinalNewline:o,allMixed:i})=>{let s=new AbortController;Nw(t,s,e);let a=e.readableObjectMode&&!i;return Fd({stream:e,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!o})},Nw=async(e,t,r)=>{try{await e}catch{r.destroy()}finally{t.abort()}},Fd=({stream:e,controller:t,binary:r,shouldEncode:n,encoding:o,shouldSplit:i,preserveNewlines:s})=>{let a=kw(e,"data",{signal:t.signal,highWaterMark:kd,highWatermark:kd});return Uw({onStdoutChunk:a,controller:t,binary:r,shouldEncode:n,encoding:o,shouldSplit:i,preserveNewlines:s})},ji=Fw(!0),kd=ji,Uw=async function*({onStdoutChunk:e,controller:t,binary:r,shouldEncode:n,encoding:o,shouldSplit:i,preserveNewlines:s}){let a=Bw({binary:r,shouldEncode:n,encoding:o,shouldSplit:i,preserveNewlines:s});try{for await(let[c]of e)yield*Je(c,a,0)}catch(c){if(!t.signal.aborted)throw c}finally{yield*Ut(a)}},Bw=({binary:e,shouldEncode:t,encoding:r,shouldSplit:n,preserveNewlines:o})=>[dn(e,r,!t),un(e,o,!n,{})].filter(Boolean);var jd=async({stream:e,onStreamEnd:t,fdNumber:r,encoding:n,buffer:o,maxBuffer:i,lines:s,allMixed:a,stripFinalNewline:c,verboseInfo:u,streamInfo:l})=>{let d=Vw({stream:e,onStreamEnd:t,fdNumber:r,encoding:n,allMixed:a,verboseInfo:u,streamInfo:l});if(!o){await Promise.all([Ww(e),d]);return}let m=hi(c,r),p=Fi({stream:e,onStreamEnd:t,lines:s,encoding:n,stripFinalNewline:m,allMixed:a}),[f]=await Promise.all([Hw({stream:e,iterable:p,fdNumber:r,encoding:n,maxBuffer:i,lines:s}),d]);return f},Vw=async({stream:e,onStreamEnd:t,fdNumber:r,encoding:n,allMixed:o,verboseInfo:i,streamInfo:{fileDescriptors:s}})=>{if(!fn({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:i,fdNumber:r}))return;let a=Fi({stream:e,onStreamEnd:t,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:o});await Ku(a,e,r,i)},Ww=async e=>{await Gw(),e.readableFlowing===null&&e.resume()},Hw=async({stream:e,stream:{readableObjectMode:t},iterable:r,fdNumber:n,encoding:o,maxBuffer:i,lines:s})=>{try{return t||s?await Qr(r,{maxBuffer:i}):o==="buffer"?new Uint8Array(await en(r,{maxBuffer:i})):await rn(r,{maxBuffer:i})}catch(a){return Nd(Kl({error:a,stream:e,readableObjectMode:t,lines:s,encoding:o,fdNumber:n}))}},Ni=async e=>{try{return await e}catch(t){return Nd(t)}},Nd=({bufferedData:e})=>da(e)?new Uint8Array(e):e;import{finished as zw}from"stream/promises";var Wt=async(e,t,r,{isSameDirection:n,stopOnExit:o=!1}={})=>{let i=qw(e,r),s=new AbortController;try{await Promise.race([...o?[r.exitPromise]:[],zw(e,{cleanup:!0,signal:s.signal})])}catch(a){i.stdinCleanedUp||Jw(a,t,r,n)}finally{s.abort()}},qw=(e,{originalStreams:[t],subprocess:r})=>{let n={stdinCleanedUp:!1};return e===t&&Yw(e,r,n),n},Yw=(e,t,r)=>{let{_destroy:n}=e;e._destroy=(...o)=>{Kw(t,r),n.call(e,...o)}},Kw=({exitCode:e,signalCode:t},r)=>{(e!==null||t!==null)&&(r.stdinCleanedUp=!0)},Jw=(e,t,r,n)=>{if(!Xw(e,t,r,n))throw e},Xw=(e,t,r,n=!0)=>r.propagating?Ud(e)||_n(e):(r.propagating=!0,Ui(r,t)===n?Ud(e):_n(e)),Ui=({fileDescriptors:e},t)=>t!=="all"&&e[t].direction==="input",_n=e=>e?.code==="ERR_STREAM_PREMATURE_CLOSE",Ud=e=>e?.code==="EPIPE";var Bd=({subprocess:e,encoding:t,buffer:r,maxBuffer:n,lines:o,stripFinalNewline:i,verboseInfo:s,streamInfo:a})=>e.stdio.map((c,u)=>Bi({stream:c,fdNumber:u,encoding:t,buffer:r[u],maxBuffer:n[u],lines:o[u],allMixed:!1,stripFinalNewline:i,verboseInfo:s,streamInfo:a})),Bi=async({stream:e,fdNumber:t,encoding:r,buffer:n,maxBuffer:o,lines:i,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:u})=>{if(!e)return;let l=Wt(e,t,u);if(Ui(u,t)){await l;return}let[d]=await Promise.all([jd({stream:e,onStreamEnd:l,fdNumber:t,encoding:r,buffer:n,maxBuffer:o,lines:i,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:u}),l]);return d};var Gd=({stdout:e,stderr:t},{all:r})=>r&&(e||t)?Xe([e,t].filter(Boolean)):void 0,Vd=({subprocess:e,encoding:t,buffer:r,maxBuffer:n,lines:o,stripFinalNewline:i,verboseInfo:s,streamInfo:a})=>Bi({...Zw(e,r),fdNumber:"all",encoding:t,maxBuffer:n[1]+n[2],lines:o[1]||o[2],allMixed:Qw(e),stripFinalNewline:i,verboseInfo:s,streamInfo:a}),Zw=({stdout:e,stderr:t,all:r},[,n,o])=>{let i=n||o;return i?n?o?{stream:r,buffer:i}:{stream:e,buffer:i}:{stream:t,buffer:i}:{stream:r,buffer:i}},Qw=({all:e,stdout:t,stderr:r})=>e&&t&&r&&t.readableObjectMode!==r.readableObjectMode;import{once as eS}from"events";var Wd=e=>st(e,"ipc"),Hd=(e,t)=>{let r=Cr(e);xe({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:t})};var zd=async({subprocess:e,buffer:t,maxBuffer:r,ipc:n,ipcOutput:o,verboseInfo:i})=>{if(!n)return o;let s=Wd(i),a=De(t,"ipc"),c=De(r,"ipc");for await(let u of $i({anyProcess:e,channel:e.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(Jl(e,o,c),o.push(u)),s&&Hd(u,i);return o},qd=async(e,t)=>(await Promise.allSettled([e]),t);var Yd=async({subprocess:e,options:{encoding:t,buffer:r,maxBuffer:n,lines:o,timeoutDuration:i,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:u,ipc:l,ipcInput:d},context:m,verboseInfo:p,fileDescriptors:f,originalStreams:g,onInternalError:w,controller:x})=>{let C=ed(e,m),v={originalStreams:g,fileDescriptors:f,subprocess:e,exitPromise:C,propagating:!1},A=Bd({subprocess:e,encoding:t,buffer:r,maxBuffer:n,lines:o,stripFinalNewline:u,verboseInfo:p,streamInfo:v}),E=Vd({subprocess:e,encoding:t,buffer:r,maxBuffer:n,lines:o,stripFinalNewline:u,verboseInfo:p,streamInfo:v}),R=[],M=zd({subprocess:e,buffer:r,maxBuffer:n,ipc:l,ipcOutput:R,verboseInfo:p}),L=tS(g,e,v),k=rS(f,v);try{return await Promise.race([Promise.all([{},rd(C),Promise.all(A),E,M,Tl(e,d),...L,...k]),w,nS(e,x),...El(e,i,m,x),...Wc({subprocess:e,cancelSignal:s,gracefulCancel:a,context:m,controller:x}),...Sl({subprocess:e,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:m,controller:x})])}catch(Q){return m.terminationReason??="other",Promise.all([{error:Q},C,Promise.all(A.map(N=>Ni(N))),Ni(E),qd(M,R),Promise.allSettled(L),Promise.allSettled(k)])}},tS=(e,t,r)=>e.map((n,o)=>n===t.stdio[o]?void 0:Wt(n,o,r)),rS=(e,t)=>e.flatMap(({stdioItems:r},n)=>r.filter(({value:o,stream:i=o})=>he(i,{checkOpen:!1})&&!me(i)).map(({type:o,value:i,stream:s=i})=>Wt(s,n,t,{isSameDirection:ce.has(o),stopOnExit:o==="native"}))),nS=async(e,{signal:t})=>{let[r]=await eS(e,"error",{signal:t});throw r};var Kd=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),Ht=(e,t,r)=>{let n=e[r];n.has(t)||n.set(t,[]);let o=n.get(t),i=we();return o.push(i),{resolve:i.resolve.bind(i),promises:o}},yt=async({resolve:e,promises:t},r)=>{e();let[n]=await Promise.race([Promise.allSettled([!0,r]),Promise.all([!1,...t])]);return!n};import{Readable as oS}from"stream";import{callbackify as iS}from"util";import{finished as Jd}from"stream/promises";var Gi=async e=>{if(e!==void 0)try{await Vi(e)}catch{}},Xd=async e=>{if(e!==void 0)try{await Wi(e)}catch{}},Vi=async e=>{await Jd(e,{cleanup:!0,readable:!1,writable:!0})},Wi=async e=>{await Jd(e,{cleanup:!0,readable:!0,writable:!1})},En=async(e,t)=>{if(await e,t)throw t},$n=(e,t,r)=>{r&&!_n(r)?e.destroy(r):t&&e.destroy()};var Zd=({subprocess:e,concurrentStreams:t,encoding:r},{from:n,binary:o=!0,preserveNewlines:i=!0}={})=>{let s=o||te.has(r),{subprocessStdout:a,waitReadableDestroy:c}=Hi(e,n,t),{readableEncoding:u,readableObjectMode:l,readableHighWaterMark:d}=zi(a,s),{read:m,onStdoutDataDone:p}=qi({subprocessStdout:a,subprocess:e,binary:s,encoding:r,preserveNewlines:i}),f=new oS({read:m,destroy:iS(Ki.bind(void 0,{subprocessStdout:a,subprocess:e,waitReadableDestroy:c})),highWaterMark:d,objectMode:l,encoding:u});return Yi({subprocessStdout:a,onStdoutDataDone:p,readable:f,subprocess:e}),f},Hi=(e,t,r)=>{let n=dt(e,t),o=Ht(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:o}},zi=({readableEncoding:e,readableObjectMode:t,readableHighWaterMark:r},n)=>n?{readableEncoding:e,readableObjectMode:t,readableHighWaterMark:r}:{readableEncoding:e,readableObjectMode:!0,readableHighWaterMark:ji},qi=({subprocessStdout:e,subprocess:t,binary:r,encoding:n,preserveNewlines:o})=>{let i=we(),s=Sn({subprocessStdout:e,subprocess:t,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:o});return{read(){sS(this,s,i)},onStdoutDataDone:i}},sS=async(e,t,r)=>{try{let{value:n,done:o}=await t.next();o?r.resolve():e.push(n)}catch{}},Yi=async({subprocessStdout:e,onStdoutDataDone:t,readable:r,subprocess:n,subprocessStdin:o})=>{try{await Wi(e),await n,await Gi(o),await t,r.readable&&r.push(null)}catch(i){await Gi(o),Qd(r,i)}},Ki=async({subprocessStdout:e,subprocess:t,waitReadableDestroy:r},n)=>{await yt(r,t)&&(Qd(e,n),await En(t,n))},Qd=(e,t)=>{$n(e,e.readable,t)};import{Writable as aS}from"stream";import{callbackify as em}from"util";var tm=({subprocess:e,concurrentStreams:t},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:o,waitWritableDestroy:i}=Ji(e,r,t),s=new aS({...Xi(n,e,o),destroy:em(Qi.bind(void 0,{subprocessStdin:n,subprocess:e,waitWritableFinal:o,waitWritableDestroy:i})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return Zi(n,s),s},Ji=(e,t,r)=>{let n=Fr(e,t),o=Ht(r,n,"writableFinal"),i=Ht(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:o,waitWritableDestroy:i}},Xi=(e,t,r)=>({write:cS.bind(void 0,e),final:em(lS.bind(void 0,e,t,r))}),cS=(e,t,r,n)=>{e.write(t,r)?n():e.once("drain",n)},lS=async(e,t,r)=>{await yt(r,t)&&(e.writable&&e.end(),await t)},Zi=async(e,t,r)=>{try{await Vi(e),t.writable&&t.end()}catch(n){await Xd(r),rm(t,n)}},Qi=async({subprocessStdin:e,subprocess:t,waitWritableFinal:r,waitWritableDestroy:n},o)=>{await yt(r,t),await yt(n,t)&&(rm(e,o),await En(t,o))},rm=(e,t)=>{$n(e,e.writable,t)};import{Duplex as uS}from"stream";import{callbackify as dS}from"util";var nm=({subprocess:e,concurrentStreams:t,encoding:r},{from:n,to:o,binary:i=!0,preserveNewlines:s=!0}={})=>{let a=i||te.has(r),{subprocessStdout:c,waitReadableDestroy:u}=Hi(e,n,t),{subprocessStdin:l,waitWritableFinal:d,waitWritableDestroy:m}=Ji(e,o,t),{readableEncoding:p,readableObjectMode:f,readableHighWaterMark:g}=zi(c,a),{read:w,onStdoutDataDone:x}=qi({subprocessStdout:c,subprocess:e,binary:a,encoding:r,preserveNewlines:s}),C=new uS({read:w,...Xi(l,e,d),destroy:dS(mS.bind(void 0,{subprocessStdout:c,subprocessStdin:l,subprocess:e,waitReadableDestroy:u,waitWritableFinal:d,waitWritableDestroy:m})),readableHighWaterMark:g,writableHighWaterMark:l.writableHighWaterMark,readableObjectMode:f,writableObjectMode:l.writableObjectMode,encoding:p});return Yi({subprocessStdout:c,onStdoutDataDone:x,readable:C,subprocess:e,subprocessStdin:l}),Zi(l,C,c),C},mS=async({subprocessStdout:e,subprocessStdin:t,subprocess:r,waitReadableDestroy:n,waitWritableFinal:o,waitWritableDestroy:i},s)=>{await Promise.all([Ki({subprocessStdout:e,subprocess:r,waitReadableDestroy:n},s),Qi({subprocessStdin:t,subprocess:r,waitWritableFinal:o,waitWritableDestroy:i},s)])};var es=(e,t,{from:r,binary:n=!1,preserveNewlines:o=!1}={})=>{let i=n||te.has(t),s=dt(e,r),a=Sn({subprocessStdout:s,subprocess:e,binary:i,shouldEncode:!0,encoding:t,preserveNewlines:o});return pS(a,s,e)},pS=async function*(e,t,r){try{yield*e}finally{t.readable&&t.destroy(),await r}};var om=(e,{encoding:t})=>{let r=Kd();e.readable=Zd.bind(void 0,{subprocess:e,concurrentStreams:r,encoding:t}),e.writable=tm.bind(void 0,{subprocess:e,concurrentStreams:r}),e.duplex=nm.bind(void 0,{subprocess:e,concurrentStreams:r,encoding:t}),e.iterable=es.bind(void 0,e,t),e[Symbol.asyncIterator]=es.bind(void 0,e,t,{})};var im=(e,t)=>{for(let[r,n]of hS){let o=n.value.bind(t);Reflect.defineProperty(e,r,{...n,value:o})}},fS=(async()=>{})().constructor.prototype,hS=["then","catch","finally"].map(e=>[e,Reflect.getOwnPropertyDescriptor(fS,e)]);var sm=(e,t,r,n)=>{let{file:o,commandArguments:i,command:s,escapedCommand:a,startTime:c,verboseInfo:u,options:l,fileDescriptors:d}=yS(e,t,r),{subprocess:m,promise:p}=wS({file:o,commandArguments:i,options:l,startTime:c,verboseInfo:u,command:s,escapedCommand:a,fileDescriptors:d});return m.pipe=wn.bind(void 0,{source:m,sourcePromise:p,boundOptions:{},createNested:n}),im(m,p),Se.set(m,{options:l,fileDescriptors:d}),m},yS=(e,t,r)=>{let{command:n,escapedCommand:o,startTime:i,verboseInfo:s}=vr(e,t,r),{file:a,commandArguments:c,options:u}=Yr(e,t,r),l=xS(u),d=bd(l,s);return{file:a,commandArguments:c,command:n,escapedCommand:o,startTime:i,verboseInfo:s,options:l,fileDescriptors:d}},xS=({timeout:e,signal:t,...r})=>{if(t!==void 0)throw new TypeError('The "signal" option has been renamed to "cancelSignal" instead.');return{...r,timeoutDuration:e}},wS=({file:e,commandArguments:t,options:r,startTime:n,verboseInfo:o,command:i,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=bS(...Kr(e,t,r))}catch(f){return pd({error:f,command:i,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:o})}let u=new AbortController;gS(Number.POSITIVE_INFINITY,u.signal);let l=[...c.stdio];Od(c,a,u),Td(c,r,u);let d={},m=we();c.kill=Gc.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:m,context:d,controller:u}),c.all=Gd(c,r),om(c,r),ud(c,r);let p=SS({subprocess:c,options:r,startTime:n,verboseInfo:o,fileDescriptors:a,originalStreams:l,command:i,escapedCommand:s,context:d,onInternalError:m,controller:u});return{subprocess:c,promise:p}},SS=async({subprocess:e,options:t,startTime:r,verboseInfo:n,fileDescriptors:o,originalStreams:i,command:s,escapedCommand:a,context:c,onInternalError:u,controller:l})=>{let[d,[m,p],f,g,w]=await Yd({subprocess:e,options:t,context:c,verboseInfo:n,fileDescriptors:o,originalStreams:i,onInternalError:u,controller:l});l.abort(),u.resolve();let x=f.map((A,E)=>Me(A,t,E)),C=Me(g,t,"all"),v=_S({errorInfo:d,exitCode:m,signal:p,stdio:x,all:C,ipcOutput:w,context:c,options:t,command:s,escapedCommand:a,startTime:r});return ht(v,n,t)},_S=({errorInfo:e,exitCode:t,signal:r,stdio:n,all:o,ipcOutput:i,context:s,options:a,command:c,escapedCommand:u,startTime:l})=>"error"in e?Nt({error:e.error,command:c,escapedCommand:u,timedOut:s.terminationReason==="timeout",isCanceled:s.terminationReason==="cancel"||s.terminationReason==="gracefulCancel",isGracefullyCanceled:s.terminationReason==="gracefulCancel",isMaxBuffer:e.error instanceof _e,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:t,signal:r,stdio:n,all:o,ipcOutput:i,options:a,startTime:l,isSync:!1}):on({command:c,escapedCommand:u,stdio:n,all:o,ipcOutput:i,options:a,startTime:l});var Cn=(e,t)=>{let r=Object.fromEntries(Object.entries(t).map(([n,o])=>[n,ES(n,e[n],o)]));return{...e,...r}},ES=(e,t,r)=>$S.has(e)&&j(t)&&j(r)?{...t,...r}:r,$S=new Set(["env",...Io]);var Be=(e,t,r,n)=>{let o=(s,a,c)=>Be(s,a,r,c),i=(...s)=>CS({mapArguments:e,deepOptions:r,boundOptions:t,setBoundExeca:n,createNested:o},...s);return n!==void 0&&n(i,o,t),i},CS=({mapArguments:e,deepOptions:t={},boundOptions:r={},setBoundExeca:n,createNested:o},i,...s)=>{if(j(i))return o(e,Cn(r,i),n);let{file:a,commandArguments:c,options:u,isSync:l}=OS({mapArguments:e,firstArgument:i,nextArguments:s,deepOptions:t,boundOptions:r});return l?od(a,c,u):sm(a,c,u,o)},OS=({mapArguments:e,firstArgument:t,nextArguments:r,deepOptions:n,boundOptions:o})=>{let i=ba(t)?ya(t,r):[t,...r],[s,a,c]=gr(...i),u=Cn(Cn(n,o),c),{file:l=s,commandArguments:d=a,options:m=u,isSync:p=!1}=e({file:s,commandArguments:a,options:u});return{file:l,commandArguments:d,options:m,isSync:p}};var am=({file:e,commandArguments:t})=>lm(e,t),cm=({file:e,commandArguments:t})=>({...lm(e,t),isSync:!0}),lm=(e,t)=>{if(t.length>0)throw new TypeError(`The command and its arguments must be passed as a single string: ${e} ${t}.`);let[r,...n]=vS(e);return{file:r,commandArguments:n}},vS=e=>{if(typeof e!="string")throw new TypeError(`The command must be a string: ${String(e)}.`);let t=e.trim();if(t==="")return[];let r=[];for(let n of t.split(TS)){let o=r.at(-1);o&&o.endsWith("\\")?r[r.length-1]=`${o.slice(0,-1)} ${n}`:r.push(n)}return r},TS=/ +/g;var um=(e,t,r)=>{e.sync=t(AS,r),e.s=e.sync},dm=({options:e})=>mm(e),AS=({options:e})=>({...mm(e),isSync:!0}),mm=e=>({options:{...IS(e),...e}}),IS=({input:e,inputFile:t,stdio:r})=>e===void 0&&t===void 0&&r===void 0?{stdin:"inherit"}:{},pm={preferLocal:!0};var le=Be(()=>({})),_M=Be(()=>({isSync:!0})),On=Be(am),EM=Be(cm),$M=Be(Cl),CM=Be(dm,{},pm,um),{sendMessage:OM,getOneMessage:vM,getEachMessage:TM,getCancelSignal:AM}=dd();async function W(e,t,r){return le("docker",["compose",...e],{cwd:t,...r})}async function X(e,t,r){let n=["compose","exec","-T"];if(r)for(let[i,s]of Object.entries(r))n.push("-e",`${i}=${s}`);n.push("web","bin/rails",e);let{stdout:o}=await le("docker",n,{cwd:t});return o.split(`
|
|
142
|
-
`).filter(
|
|
143
|
-
`).trim()}async function
|
|
144
|
-
`).some(
|
|
145
|
-
`),
|
|
146
|
-
`)
|
|
147
|
-
`))
|
|
148
|
-
|
|
149
|
-
`)
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
`)
|
|
153
|
-
`)
|
|
154
|
-
`)
|
|
155
|
-
`)
|
|
156
|
-
`)
|
|
157
|
-
|
|
158
|
-
`)
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
`
|
|
163
|
-
${
|
|
164
|
-
`),
|
|
165
|
-
`),
|
|
166
|
-
`),"
|
|
167
|
-
`),
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
75
|
+
if (condition) { yield value; }`)};import{Buffer as vx}from"buffer";import{StringDecoder as qx}from"string_decoder";var wi=(e,t,r)=>{if(r)return;if(e)return{transform:$x.bind(void 0,new TextEncoder)};let i=new qx(t);return{transform:Cx.bind(void 0,i),final:Ax.bind(void 0,i)}},$x=function*(e,t){vx.isBuffer(t)?yield De(t):typeof t=="string"?yield e.encode(t):yield t},Cx=function*(e,t){yield H(t)?e.write(t):t},Ax=function*(e){let t=e.end();t!==""&&(yield t)};import{callbackify as ru}from"util";var Ds=ru(async(e,t,r,i)=>{t.currentIterable=e(...r);try{for await(let n of t.currentIterable)i.push(n)}finally{delete t.currentIterable}}),ki=async function*(e,t,r){if(r===t.length){yield e;return}let{transform:i=Tx}=t[r];for await(let n of i(e))yield*ki(n,t,r+1)},iu=async function*(e){for(let[t,{final:r}]of Object.entries(e))yield*Ex(r,Number(t),e)},Ex=async function*(e,t,r){if(e!==void 0)for await(let i of e())yield*ki(i,r,t+1)},nu=ru(async({currentIterable:e},t)=>{if(e!==void 0){await(t?e.throw(t):e.return());return}if(t)throw t}),Tx=function*(e){yield e};var Ls=(e,t,r,i)=>{try{for(let n of e(...t))r.push(n);i()}catch(n){i(n)}},su=(e,t)=>[...t.flatMap(r=>[...ot(r,e,0)]),...er(e)],ot=function*(e,t,r){if(r===t.length){yield e;return}let{transform:i=Ox}=t[r];for(let n of i(e))yield*ot(n,t,r+1)},er=function*(e){for(let[t,{final:r}]of Object.entries(e))yield*Px(r,Number(t),e)},Px=function*(e,t,r){if(e!==void 0)for(let i of e())yield*ot(i,r,t+1)},Ox=function*(e){yield e};var Ms=({value:e,value:{transform:t,final:r,writableObjectMode:i,readableObjectMode:n},optionName:s},{encoding:o})=>{let a={},c=au(e,o,s),d=st(t),p=st(r),u=d?Ds.bind(void 0,ki,a):Ls.bind(void 0,ot),l=d||p?Ds.bind(void 0,iu,a):Ls.bind(void 0,er),m=d||p?nu.bind(void 0,a):void 0;return{stream:new Ix({writableObjectMode:i,writableHighWaterMark:ou(i),readableObjectMode:n,readableHighWaterMark:ou(n),transform(f,x,_){u([f,c,0],this,_)},flush(f){l([c],this,f)},destroy:m})}},Si=(e,t,r,i)=>{let n=t.filter(({type:o})=>o==="generator"),s=i?n.reverse():n;for(let{value:o,optionName:a}of s){let c=au(o,r,a);e=su(c,e)}return e},au=({transform:e,final:t,binary:r,writableObjectMode:i,readableObjectMode:n,preserveNewlines:s},o,a)=>{let c={};return[{transform:Zd(i,a)},wi(r,o,i),xi(r,s,i,c),{transform:e,final:t},{transform:eu(n,a)},Qd({binary:r,preserveNewlines:s,readableObjectMode:n,state:c})].filter(Boolean)};var cu=(e,t)=>{for(let r of Rx(e))jx(e,r,t)},Rx=e=>new Set(Object.entries(e).filter(([,{direction:t}])=>t==="input").map(([t])=>Number(t))),jx=(e,t,r)=>{let{stdioItems:i}=e[t],n=i.filter(({contents:a})=>a!==void 0);if(n.length===0)return;if(t!==0){let[{type:a,optionName:c}]=n;throw new TypeError(`Only the \`stdin\` option, not \`${c}\`, can be ${We[a]} with synchronous methods.`)}let o=n.map(({contents:a})=>a).map(a=>Dx(a,i));r.input=zt(o)},Dx=(e,t)=>{let r=Si(e,t,"utf8",!0);return Lx(r),zt(r)},Lx=e=>{let t=e.find(r=>typeof r!="string"&&!H(r));if(t!==void 0)throw new TypeError(`The \`stdin\` option is invalid: when passing objects as input, a transform must be used to serialize them to strings or Uint8Arrays: ${t}.`)};import{writeFileSync as Bx,appendFileSync as Nx}from"fs";var vi=({stdioItems:e,encoding:t,verboseInfo:r,fdNumber:i})=>i!=="all"&&xt(r,i)&&!oe.has(t)&&Mx(i)&&(e.some(({type:n,value:s})=>n==="native"&&Fx.has(s))||e.every(({type:n})=>le.has(n))),Mx=e=>e===1||e===2,Fx=new Set(["pipe","overlapped"]),pu=async(e,t,r,i)=>{for await(let n of e)Ux(t)||uu(n,r,i)},du=(e,t,r)=>{for(let i of e)uu(i,t,r)},Ux=e=>e._readableState.pipes.length>0,uu=(e,t,r)=>{let i=Dr(e);ke({type:"output",verboseMessage:i,fdNumber:t,verboseInfo:r})};var lu=({fileDescriptors:e,syncResult:{output:t},options:r,isMaxBuffer:i,verboseInfo:n})=>{if(t===null)return{output:Array.from({length:3})};let s={},o=new Set([]);return{output:t.map((c,d)=>Gx({result:c,fileDescriptors:e,fdNumber:d,state:s,outputFiles:o,isMaxBuffer:i,verboseInfo:n},r)),...s}},Gx=({result:e,fileDescriptors:t,fdNumber:r,state:i,outputFiles:n,isMaxBuffer:s,verboseInfo:o},{buffer:a,encoding:c,lines:d,stripFinalNewline:p,maxBuffer:u})=>{if(e===null)return;let l=md(e,s,u),m=De(l),{stdioItems:h,objectMode:f}=t[r],x=zx([m],h,c,i),{serializedResult:_,finalResult:v=_}=Vx({chunks:x,objectMode:f,encoding:c,lines:d,stripFinalNewline:p,fdNumber:r});Wx({serializedResult:_,fdNumber:r,state:i,verboseInfo:o,encoding:c,stdioItems:h,objectMode:f});let C=a[r]?v:void 0;try{return i.error===void 0&&Hx(_,h,n),C}catch(E){return i.error=E,C}},zx=(e,t,r,i)=>{try{return Si(e,t,r,!1)}catch(n){return i.error=n,e}},Vx=({chunks:e,objectMode:t,encoding:r,lines:i,stripFinalNewline:n,fdNumber:s})=>{if(t)return{serializedResult:e};if(r==="buffer")return{serializedResult:zt(e)};let o=Ca(e,r);return i[s]?{serializedResult:o,finalResult:js(o,!n[s],t)}:{serializedResult:o}},Wx=({serializedResult:e,fdNumber:t,state:r,verboseInfo:i,encoding:n,stdioItems:s,objectMode:o})=>{if(!vi({stdioItems:s,encoding:n,verboseInfo:i,fdNumber:t}))return;let a=js(e,!1,o);try{du(a,t,i)}catch(c){r.error??=c}},Hx=(e,t,r)=>{for(let{path:i,append:n}of t.filter(({type:s})=>_i.has(s))){let s=typeof i=="string"?i:i.toString();n||r.has(s)?Nx(i,e):(r.add(s),Bx(i,e))}};var mu=([,e,t],r)=>{if(r.all)return e===void 0?t:t===void 0?e:Array.isArray(e)?Array.isArray(t)?[...e,...t]:[...e,Fe(t,r,"all")]:Array.isArray(t)?[Fe(e,r,"all"),...t]:H(e)&&H(t)?zn([e,t]):`${e}${t}`};import{once as Fs}from"events";var hu=async(e,t)=>{let[r,i]=await Kx(e);return t.isForcefullyTerminated??=!1,[r,i]},Kx=async e=>{let[t,r]=await Promise.allSettled([Fs(e,"spawn"),Fs(e,"exit")]);return t.status==="rejected"?[]:r.status==="rejected"?yu(e):r.value},yu=async e=>{try{return await Fs(e,"exit")}catch{return yu(e)}},fu=async e=>{let[t,r]=await e;if(!Yx(t,r)&&Us(t,r))throw new ge;return[t,r]},Yx=(e,t)=>e===void 0&&t===void 0,Us=(e,t)=>e!==0||t!==null;var gu=({error:e,status:t,signal:r,output:i},{maxBuffer:n})=>{let s=Jx(e,t,r),o=s?.code==="ETIMEDOUT",a=ld(s,i,n);return{resultError:s,exitCode:t,signal:r,timedOut:o,isMaxBuffer:a}},Jx=(e,t,r)=>e!==void 0?e:Us(t,r)?new ge:void 0;var _u=(e,t,r)=>{let{file:i,commandArguments:n,command:s,escapedCommand:o,startTime:a,verboseInfo:c,options:d,fileDescriptors:p}=Qx(e,t,r),u=tw({file:i,commandArguments:n,options:d,command:s,escapedCommand:o,verboseInfo:c,fileDescriptors:p,startTime:a});return Et(u,c,d)},Qx=(e,t,r)=>{let{command:i,escapedCommand:n,startTime:s,verboseInfo:o}=Mr(e,t,r),a=Zx(r),{file:c,commandArguments:d,options:p}=si(e,t,a);ew(p);let u=Kd(p,o);return{file:c,commandArguments:d,command:i,escapedCommand:n,startTime:s,verboseInfo:o,options:p,fileDescriptors:u}},Zx=e=>e.node&&!e.ipc?{...e,ipc:!1}:e,ew=({ipc:e,ipcInput:t,detached:r,cancelSignal:i})=>{t&&qi("ipcInput"),e&&qi("ipc: true"),r&&qi("detached: true"),i&&qi("cancelSignal")},qi=e=>{throw new TypeError(`The "${e}" option cannot be used with synchronous methods.`)},tw=({file:e,commandArguments:t,options:r,command:i,escapedCommand:n,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let c=rw({file:e,commandArguments:t,options:r,command:i,escapedCommand:n,fileDescriptors:o,startTime:a});if(c.failed)return c;let{resultError:d,exitCode:p,signal:u,timedOut:l,isMaxBuffer:m}=gu(c,r),{output:h,error:f=d}=lu({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:m,verboseInfo:s}),x=h.map((v,C)=>Fe(v,r,C)),_=Fe(mu(h,r),r,"all");return nw({error:f,exitCode:p,signal:u,timedOut:l,isMaxBuffer:m,stdio:x,all:_,options:r,command:i,escapedCommand:n,startTime:a})},rw=({file:e,commandArguments:t,options:r,command:i,escapedCommand:n,fileDescriptors:s,startTime:o})=>{try{cu(s,r);let a=iw(r);return Xx(...oi(e,t,a))}catch(a){return At({error:a,command:i,escapedCommand:n,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},iw=({encoding:e,maxBuffer:t,...r})=>({...r,encoding:"buffer",maxBuffer:hi(t)}),nw=({error:e,exitCode:t,signal:r,timedOut:i,isMaxBuffer:n,stdio:s,all:o,options:a,command:c,escapedCommand:d,startTime:p})=>e===void 0?yi({command:c,escapedCommand:d,stdio:s,all:o,ipcOutput:[],options:a,startTime:p}):Zt({error:e,command:c,escapedCommand:d,timedOut:i,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:n,isForcefullyTerminated:!1,exitCode:t,signal:r,stdio:s,all:o,ipcOutput:[],options:a,startTime:p,isSync:!0});import{setMaxListeners as V0}from"events";import{spawn as W0}from"child_process";import Su from"process";import{once as Bs,on as sw}from"events";var bu=({anyProcess:e,channel:t,isSubprocess:r,ipc:i},{reference:n=!0,filter:s}={})=>(St({methodName:"getOneMessage",isSubprocess:r,ipc:i,isConnected:Zr(e)}),ow({anyProcess:e,channel:t,isSubprocess:r,filter:s,reference:n})),ow=async({anyProcess:e,channel:t,isSubprocess:r,filter:i,reference:n})=>{Yr(t,n);let s=Ve(e,t,r),o=new AbortController;try{return await Promise.race([aw(s,i,o),cw(s,r,o),pw(s,r,o)])}catch(a){throw vt(e),a}finally{o.abort(),Jr(t,n)}},aw=async(e,t,{signal:r})=>{if(t===void 0){let[i]=await Bs(e,"message",{signal:r});return i}for await(let[i]of sw(e,"message",{signal:r}))if(t(i))return i},cw=async(e,t,{signal:r})=>{await Bs(e,"disconnect",{signal:r}),sp(t)},pw=async(e,t,{signal:r})=>{let[i]=await Bs(e,"strict:error",{signal:r});throw Wr(i,t)};import{once as wu,on as dw}from"events";var ku=({anyProcess:e,channel:t,isSubprocess:r,ipc:i},{reference:n=!0}={})=>Ns({anyProcess:e,channel:t,isSubprocess:r,ipc:i,shouldAwait:!r,reference:n}),Ns=({anyProcess:e,channel:t,isSubprocess:r,ipc:i,shouldAwait:n,reference:s})=>{St({methodName:"getEachMessage",isSubprocess:r,ipc:i,isConnected:Zr(e)}),Yr(t,s);let o=Ve(e,t,r),a=new AbortController,c={};return uw(e,o,a),lw({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),mw({anyProcess:e,channel:t,ipcEmitter:o,isSubprocess:r,shouldAwait:n,controller:a,state:c,reference:s})},uw=async(e,t,r)=>{try{await wu(t,"disconnect",{signal:r.signal}),r.abort()}catch{}},lw=async({ipcEmitter:e,isSubprocess:t,controller:r,state:i})=>{try{let[n]=await wu(e,"strict:error",{signal:r.signal});i.error=Wr(n,t),r.abort()}catch{}},mw=async function*({anyProcess:e,channel:t,ipcEmitter:r,isSubprocess:i,shouldAwait:n,controller:s,state:o,reference:a}){try{for await(let[c]of dw(r,"message",{signal:s.signal}))xu(o),yield c}catch{xu(o)}finally{s.abort(),Jr(t,a),i||vt(e),n&&await e}},xu=({error:e})=>{if(e)throw e};var vu=(e,{ipc:t})=>{Object.assign(e,$u(e,!1,t))},qu=()=>{let e=Su,t=!0,r=Su.channel!==void 0;return{...$u(e,t,r),getCancelSignal:Op.bind(void 0,{anyProcess:e,channel:e.channel,isSubprocess:t,ipc:r})}},$u=(e,t,r)=>({sendMessage:ii.bind(void 0,{anyProcess:e,channel:e.channel,isSubprocess:t,ipc:r}),getOneMessage:bu.bind(void 0,{anyProcess:e,channel:e.channel,isSubprocess:t,ipc:r}),getEachMessage:ku.bind(void 0,{anyProcess:e,channel:e.channel,isSubprocess:t,ipc:r})});import{ChildProcess as hw}from"child_process";import{PassThrough as yw,Readable as fw,Writable as gw,Duplex as _w}from"stream";var Cu=({error:e,command:t,escapedCommand:r,fileDescriptors:i,options:n,startTime:s,verboseInfo:o})=>{Os(i);let a=new hw;bw(a,i),Object.assign(a,{readable:xw,writable:ww,duplex:kw});let c=At({error:e,command:t,escapedCommand:r,fileDescriptors:i,options:n,startTime:s,isSync:!1}),d=Sw(c,o,n);return{subprocess:a,promise:d}},bw=(e,t)=>{let r=tr(),i=tr(),n=tr(),s=Array.from({length:t.length-3},tr),o=tr(),a=[r,i,n,...s];Object.assign(e,{stdin:r,stdout:i,stderr:n,all:o,stdio:a})},tr=()=>{let e=new yw;return e.end(),e},xw=()=>new fw({read(){}}),ww=()=>new gw({write(){}}),kw=()=>new _w({read(){},write(){}}),Sw=async(e,t,r)=>Et(e,t,r);import{createReadStream as Au,createWriteStream as Eu}from"fs";import{Buffer as vw}from"buffer";import{Readable as rr,Writable as qw,Duplex as $w}from"stream";var Pu=(e,t)=>bi(Cw,e,t,!1),ir=({type:e,optionName:t})=>{throw new TypeError(`The \`${t}\` option cannot be ${We[e]}.`)},Tu={fileNumber:ir,generator:Ms,asyncGenerator:Ms,nodeStream:({value:e})=>({stream:e}),webTransform({value:{transform:e,writableObjectMode:t,readableObjectMode:r}}){let i=t||r;return{stream:$w.fromWeb(e,{objectMode:i})}},duplex:({value:{transform:e}})=>({stream:e}),native(){}},Cw={input:{...Tu,fileUrl:({value:e})=>({stream:Au(e)}),filePath:({value:{file:e}})=>({stream:Au(e)}),webStream:({value:e})=>({stream:rr.fromWeb(e)}),iterable:({value:e})=>({stream:rr.from(e)}),asyncIterable:({value:e})=>({stream:rr.from(e)}),string:({value:e})=>({stream:rr.from(e)}),uint8Array:({value:e})=>({stream:rr.from(vw.from(e))})},output:{...Tu,fileUrl:({value:e})=>({stream:Eu(e)}),filePath:({value:{file:e,append:t}})=>({stream:Eu(e,t?{flags:"a"}:{})}),webStream:({value:e})=>({stream:qw.fromWeb(e)}),iterable:ir,asyncIterable:ir,string:ir,uint8Array:ir}};import{on as Aw,once as Ou}from"events";import{PassThrough as Ew,getDefaultHighWaterMark as Tw}from"stream";import{finished as ju}from"stream/promises";function at(e){if(!Array.isArray(e))throw new TypeError(`Expected an array, got \`${typeof e}\`.`);for(let n of e)zs(n);let t=e.some(({readableObjectMode:n})=>n),r=Pw(e,t),i=new Gs({objectMode:t,writableHighWaterMark:r,readableHighWaterMark:r});for(let n of e)i.add(n);return i}var Pw=(e,t)=>{if(e.length===0)return Tw(t);let r=e.filter(({readableObjectMode:i})=>i===t).map(({readableHighWaterMark:i})=>i);return Math.max(...r)},Gs=class extends Ew{#t=new Set([]);#r=new Set([]);#e=new Set([]);#i;#s=Symbol("unpipe");#n=new WeakMap;add(t){if(zs(t),this.#t.has(t))return;this.#t.add(t),this.#i??=Ow(this,this.#t,this.#s);let r=jw({passThroughStream:this,stream:t,streams:this.#t,ended:this.#r,aborted:this.#e,onFinished:this.#i,unpipeEvent:this.#s});this.#n.set(t,r),t.pipe(this,{end:!1})}async remove(t){if(zs(t),!this.#t.has(t))return!1;let r=this.#n.get(t);return r===void 0?!1:(this.#n.delete(t),t.unpipe(this),await r,!0)}},Ow=async(e,t,r)=>{$i(e,Iu);let i=new AbortController;try{await Promise.race([Iw(e,i),Rw(e,t,r,i)])}finally{i.abort(),$i(e,-Iu)}},Iw=async(e,{signal:t})=>{try{await ju(e,{signal:t,cleanup:!0})}catch(r){throw Du(e,r),r}},Rw=async(e,t,r,{signal:i})=>{for await(let[n]of Aw(e,"unpipe",{signal:i}))t.has(n)&&n.emit(r)},zs=e=>{if(typeof e?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof e}\`.`)},jw=async({passThroughStream:e,stream:t,streams:r,ended:i,aborted:n,onFinished:s,unpipeEvent:o})=>{$i(e,Ru);let a=new AbortController;try{await Promise.race([Dw(s,t,a),Lw({passThroughStream:e,stream:t,streams:r,ended:i,aborted:n,controller:a}),Mw({stream:t,streams:r,ended:i,aborted:n,unpipeEvent:o,controller:a})])}finally{a.abort(),$i(e,-Ru)}r.size>0&&r.size===i.size+n.size&&(i.size===0&&n.size>0?Vs(e):Fw(e))},Dw=async(e,t,{signal:r})=>{try{await e,r.aborted||Vs(t)}catch(i){r.aborted||Du(t,i)}},Lw=async({passThroughStream:e,stream:t,streams:r,ended:i,aborted:n,controller:{signal:s}})=>{try{await ju(t,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(t)&&i.add(t)}catch(o){if(s.aborted||!r.has(t))return;Lu(o)?n.add(t):Mu(e,o)}},Mw=async({stream:e,streams:t,ended:r,aborted:i,unpipeEvent:n,controller:{signal:s}})=>{if(await Ou(e,n,{signal:s}),!e.readable)return Ou(s,"abort",{signal:s});t.delete(e),r.delete(e),i.delete(e)},Fw=e=>{e.writable&&e.end()},Du=(e,t)=>{Lu(t)?Vs(e):Mu(e,t)},Lu=e=>e?.code==="ERR_STREAM_PREMATURE_CLOSE",Vs=e=>{(e.readable||e.writable)&&e.destroy()},Mu=(e,t)=>{e.destroyed||(e.once("error",Uw),e.destroy(t))},Uw=()=>{},$i=(e,t)=>{let r=e.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&e.setMaxListeners(r+t)},Iu=2,Ru=1;import{finished as Fu}from"stream/promises";var Pt=(e,t)=>{e.pipe(t),Bw(e,t),Nw(e,t)},Bw=async(e,t)=>{if(!(fe(e)||fe(t))){try{await Fu(e,{cleanup:!0,readable:!0,writable:!1})}catch{}Ws(t)}},Ws=e=>{e.writable&&e.end()},Nw=async(e,t)=>{if(!(fe(e)||fe(t))){try{await Fu(t,{cleanup:!0,readable:!1,writable:!0})}catch{}Hs(e)}},Hs=e=>{e.readable&&e.destroy()};var Uu=(e,t,r)=>{let i=new Map;for(let[n,{stdioItems:s,direction:o}]of Object.entries(t)){for(let{stream:a}of s.filter(({type:c})=>le.has(c)))Gw(e,a,o,n);for(let{stream:a}of s.filter(({type:c})=>!le.has(c)))Vw({subprocess:e,stream:a,direction:o,fdNumber:n,pipeGroups:i,controller:r})}for(let[n,s]of i.entries()){let o=s.length===1?s[0]:at(s);Pt(o,n)}},Gw=(e,t,r,i)=>{r==="output"?Pt(e.stdio[i],t):Pt(t,e.stdio[i]);let n=zw[i];n!==void 0&&(e[n]=t),e.stdio[i]=t},zw=["stdin","stdout","stderr"],Vw=({subprocess:e,stream:t,direction:r,fdNumber:i,pipeGroups:n,controller:s})=>{if(t===void 0)return;Ww(t,s);let[o,a]=r==="output"?[t,e.stdio[i]]:[e.stdio[i],t],c=n.get(o)??[];n.set(o,[...c,a])},Ww=(e,{signal:t})=>{fe(e)&&it(e,Hw,t)},Hw=2;import{addAbortListener as Jw}from"events";var ct=[];ct.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&ct.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&ct.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var Ci=e=>!!e&&typeof e=="object"&&typeof e.removeListener=="function"&&typeof e.emit=="function"&&typeof e.reallyExit=="function"&&typeof e.listeners=="function"&&typeof e.kill=="function"&&typeof e.pid=="number"&&typeof e.on=="function",Ks=Symbol.for("signal-exit emitter"),Ys=globalThis,Kw=Object.defineProperty.bind(Object),Js=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(Ys[Ks])return Ys[Ks];Kw(Ys,Ks,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(t,r){this.listeners[t].push(r)}removeListener(t,r){let i=this.listeners[t],n=i.indexOf(r);n!==-1&&(n===0&&i.length===1?i.length=0:i.splice(n,1))}emit(t,r,i){if(this.emitted[t])return!1;this.emitted[t]=!0;let n=!1;for(let s of this.listeners[t])n=s(r,i)===!0||n;return t==="exit"&&(n=this.emit("afterExit",r,i)||n),n}},Ai=class{},Yw=e=>({onExit(t,r){return e.onExit(t,r)},load(){return e.load()},unload(){return e.unload()}}),Xs=class extends Ai{onExit(){return()=>{}}load(){}unload(){}},Qs=class extends Ai{#t=Zs.platform==="win32"?"SIGINT":"SIGHUP";#r=new Js;#e;#i;#s;#n={};#o=!1;constructor(t){super(),this.#e=t,this.#n={};for(let r of ct)this.#n[r]=()=>{let i=this.#e.listeners(r),{count:n}=this.#r,s=t;if(typeof s.__signal_exit_emitter__=="object"&&typeof s.__signal_exit_emitter__.count=="number"&&(n+=s.__signal_exit_emitter__.count),i.length===n){this.unload();let o=this.#r.emit("exit",null,r),a=r==="SIGHUP"?this.#t:r;o||t.kill(t.pid,a)}};this.#s=t.reallyExit,this.#i=t.emit}onExit(t,r){if(!Ci(this.#e))return()=>{};this.#o===!1&&this.load();let i=r?.alwaysLast?"afterExit":"exit";return this.#r.on(i,t),()=>{this.#r.removeListener(i,t),this.#r.listeners.exit.length===0&&this.#r.listeners.afterExit.length===0&&this.unload()}}load(){if(!this.#o){this.#o=!0,this.#r.count+=1;for(let t of ct)try{let r=this.#n[t];r&&this.#e.on(t,r)}catch{}this.#e.emit=(t,...r)=>this.#c(t,...r),this.#e.reallyExit=t=>this.#a(t)}}unload(){this.#o&&(this.#o=!1,ct.forEach(t=>{let r=this.#n[t];if(!r)throw new Error("Listener not defined for signal: "+t);try{this.#e.removeListener(t,r)}catch{}}),this.#e.emit=this.#i,this.#e.reallyExit=this.#s,this.#r.count-=1)}#a(t){return Ci(this.#e)?(this.#e.exitCode=t||0,this.#r.emit("exit",this.#e.exitCode,null),this.#s.call(this.#e,this.#e.exitCode)):0}#c(t,...r){let i=this.#i;if(t==="exit"&&Ci(this.#e)){typeof r[0]=="number"&&(this.#e.exitCode=r[0]);let n=i.call(this.#e,t,...r);return this.#r.emit("exit",this.#e.exitCode,null),n}else return i.call(this.#e,t,...r)}},Zs=globalThis.process,{onExit:Bu,load:vO,unload:qO}=Yw(Ci(Zs)?new Qs(Zs):new Xs);var Nu=(e,{cleanup:t,detached:r},{signal:i})=>{if(!t||r)return;let n=Bu(()=>{e.kill()});Jw(i,()=>{n()})};var zu=({source:e,sourcePromise:t,boundOptions:r,createNested:i},...n)=>{let s=Lr(),{destination:o,destinationStream:a,destinationError:c,from:d,unpipeSignal:p}=Xw(r,i,n),{sourceStream:u,sourceError:l}=Zw(e,d),{options:m,fileDescriptors:h}=ve.get(e);return{sourcePromise:t,sourceStream:u,sourceOptions:m,sourceError:l,destination:o,destinationStream:a,destinationError:c,unpipeSignal:p,fileDescriptors:h,startTime:s}},Xw=(e,t,r)=>{try{let{destination:i,pipeOptions:{from:n,to:s,unpipeSignal:o}={}}=Qw(e,t,...r),a=Kr(i,s);return{destination:i,destinationStream:a,from:n,unpipeSignal:o}}catch(i){return{destinationError:i}}},Qw=(e,t,r,...i)=>{if(Array.isArray(r))return{destination:t(Gu,e)(r,...i),pipeOptions:e};if(typeof r=="string"||r instanceof URL||Nn(r)){if(Object.keys(e).length>0)throw new TypeError('Please use .pipe("file", ..., options) or .pipe(execa("file", ..., options)) instead of .pipe(options)("file", ...).');let[n,s,o]=Cr(r,...i);return{destination:t(Gu)(n,s,o),pipeOptions:o}}if(ve.has(r)){if(Object.keys(e).length>0)throw new TypeError("Please use .pipe(options)`command` or .pipe($(options)`command`) instead of .pipe(options)($`command`).");return{destination:r,pipeOptions:i[0]}}throw new TypeError(`The first argument must be a template string, an options object, or an Execa subprocess: ${r}`)},Gu=({options:e})=>({options:{...e,stdin:"pipe",piped:!0}}),Zw=(e,t)=>{try{return{sourceStream:qt(e,t)}}catch(r){return{sourceError:r}}};var Wu=({sourceStream:e,sourceError:t,destinationStream:r,destinationError:i,fileDescriptors:n,sourceOptions:s,startTime:o})=>{let a=e0({sourceStream:e,sourceError:t,destinationStream:r,destinationError:i});if(a!==void 0)throw eo({error:a,fileDescriptors:n,sourceOptions:s,startTime:o})},e0=({sourceStream:e,sourceError:t,destinationStream:r,destinationError:i})=>{if(t!==void 0&&i!==void 0)return i;if(i!==void 0)return Hs(e),i;if(t!==void 0)return Ws(r),t},eo=({error:e,fileDescriptors:t,sourceOptions:r,startTime:i})=>At({error:e,command:Vu,escapedCommand:Vu,fileDescriptors:t,options:r,startTime:i,isSync:!1}),Vu="source.pipe(destination)";var Hu=async e=>{let[{status:t,reason:r,value:i=r},{status:n,reason:s,value:o=s}]=await e;if(o.pipedFrom.includes(i)||o.pipedFrom.push(i),n==="rejected")throw o;if(t==="rejected")throw i;return o};import{finished as t0}from"stream/promises";var Ku=(e,t,r)=>{let i=Ei.has(t)?i0(e,t):r0(e,t);return it(e,s0,r.signal),it(t,o0,r.signal),n0(t),i},r0=(e,t)=>{let r=at([e]);return Pt(r,t),Ei.set(t,r),r},i0=(e,t)=>{let r=Ei.get(t);return r.add(e),r},n0=async e=>{try{await t0(e,{cleanup:!0,readable:!1,writable:!0})}catch{}Ei.delete(e)},Ei=new WeakMap,s0=2,o0=1;import{aborted as a0}from"util";var Yu=(e,t)=>e===void 0?[]:[c0(e,t)],c0=async(e,{sourceStream:t,mergedStream:r,fileDescriptors:i,sourceOptions:n,startTime:s})=>{await a0(e,t),await r.remove(t);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw eo({error:o,fileDescriptors:i,sourceOptions:n,startTime:s})};var Ti=(e,...t)=>{if(V(t[0]))return Ti.bind(void 0,{...e,boundOptions:{...e.boundOptions,...t[0]}});let{destination:r,...i}=zu(e,...t),n=p0({...i,destination:r});return n.pipe=Ti.bind(void 0,{...e,source:r,sourcePromise:n,boundOptions:{}}),n},p0=async({sourcePromise:e,sourceStream:t,sourceOptions:r,sourceError:i,destination:n,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:d})=>{let p=d0(e,n);Wu({sourceStream:t,sourceError:i,destinationStream:s,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:d});let u=new AbortController;try{let l=Ku(t,s,u);return await Promise.race([Hu(p),...Yu(a,{sourceStream:t,mergedStream:l,sourceOptions:r,fileDescriptors:c,startTime:d})])}finally{u.abort()}},d0=(e,t)=>Promise.allSettled([e,t]);import{setImmediate as g0}from"timers/promises";import{on as u0}from"events";import{getDefaultHighWaterMark as l0}from"stream";var Pi=({subprocessStdout:e,subprocess:t,binary:r,shouldEncode:i,encoding:n,preserveNewlines:s})=>{let o=new AbortController;return m0(t,o),Xu({stream:e,controller:o,binary:r,shouldEncode:!e.readableObjectMode&&i,encoding:n,shouldSplit:!e.readableObjectMode,preserveNewlines:s})},m0=async(e,t)=>{try{await e}catch{}finally{t.abort()}},to=({stream:e,onStreamEnd:t,lines:r,encoding:i,stripFinalNewline:n,allMixed:s})=>{let o=new AbortController;h0(t,o,e);let a=e.readableObjectMode&&!s;return Xu({stream:e,controller:o,binary:i==="buffer",shouldEncode:!a,encoding:i,shouldSplit:!a&&r,preserveNewlines:!n})},h0=async(e,t,r)=>{try{await e}catch{r.destroy()}finally{t.abort()}},Xu=({stream:e,controller:t,binary:r,shouldEncode:i,encoding:n,shouldSplit:s,preserveNewlines:o})=>{let a=u0(e,"data",{signal:t.signal,highWaterMark:Ju,highWatermark:Ju});return y0({onStdoutChunk:a,controller:t,binary:r,shouldEncode:i,encoding:n,shouldSplit:s,preserveNewlines:o})},ro=l0(!0),Ju=ro,y0=async function*({onStdoutChunk:e,controller:t,binary:r,shouldEncode:i,encoding:n,shouldSplit:s,preserveNewlines:o}){let a=f0({binary:r,shouldEncode:i,encoding:n,shouldSplit:s,preserveNewlines:o});try{for await(let[c]of e)yield*ot(c,a,0)}catch(c){if(!t.signal.aborted)throw c}finally{yield*er(a)}},f0=({binary:e,shouldEncode:t,encoding:r,shouldSplit:i,preserveNewlines:n})=>[wi(e,r,!t),xi(e,n,!i,{})].filter(Boolean);var Qu=async({stream:e,onStreamEnd:t,fdNumber:r,encoding:i,buffer:n,maxBuffer:s,lines:o,allMixed:a,stripFinalNewline:c,verboseInfo:d,streamInfo:p})=>{let u=_0({stream:e,onStreamEnd:t,fdNumber:r,encoding:i,allMixed:a,verboseInfo:d,streamInfo:p});if(!n){await Promise.all([b0(e),u]);return}let l=Is(c,r),m=to({stream:e,onStreamEnd:t,lines:o,encoding:i,stripFinalNewline:l,allMixed:a}),[h]=await Promise.all([x0({stream:e,iterable:m,fdNumber:r,encoding:i,maxBuffer:s,lines:o}),u]);return h},_0=async({stream:e,onStreamEnd:t,fdNumber:r,encoding:i,allMixed:n,verboseInfo:s,streamInfo:{fileDescriptors:o}})=>{if(!vi({stdioItems:o[r]?.stdioItems,encoding:i,verboseInfo:s,fdNumber:r}))return;let a=to({stream:e,onStreamEnd:t,lines:!0,encoding:i,stripFinalNewline:!0,allMixed:n});await pu(a,e,r,s)},b0=async e=>{await g0(),e.readableFlowing===null&&e.resume()},x0=async({stream:e,stream:{readableObjectMode:t},iterable:r,fdNumber:i,encoding:n,maxBuffer:s,lines:o})=>{try{return t||o?await di(r,{maxBuffer:s}):n==="buffer"?new Uint8Array(await ui(r,{maxBuffer:s})):await mi(r,{maxBuffer:s})}catch(a){return Zu(pd({error:a,stream:e,readableObjectMode:t,lines:o,encoding:n,fdNumber:i}))}},io=async e=>{try{return await e}catch(t){return Zu(t)}},Zu=({bufferedData:e})=>qa(e)?new Uint8Array(e):e;import{finished as w0}from"stream/promises";var nr=async(e,t,r,{isSameDirection:i,stopOnExit:n=!1}={})=>{let s=k0(e,r),o=new AbortController;try{await Promise.race([...n?[r.exitPromise]:[],w0(e,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||q0(a,t,r,i)}finally{o.abort()}},k0=(e,{originalStreams:[t],subprocess:r})=>{let i={stdinCleanedUp:!1};return e===t&&S0(e,r,i),i},S0=(e,t,r)=>{let{_destroy:i}=e;e._destroy=(...n)=>{v0(t,r),i.call(e,...n)}},v0=({exitCode:e,signalCode:t},r)=>{(e!==null||t!==null)&&(r.stdinCleanedUp=!0)},q0=(e,t,r,i)=>{if(!$0(e,t,r,i))throw e},$0=(e,t,r,i=!0)=>r.propagating?el(e)||Oi(e):(r.propagating=!0,no(r,t)===i?el(e):Oi(e)),no=({fileDescriptors:e},t)=>t!=="all"&&e[t].direction==="input",Oi=e=>e?.code==="ERR_STREAM_PREMATURE_CLOSE",el=e=>e?.code==="EPIPE";var tl=({subprocess:e,encoding:t,buffer:r,maxBuffer:i,lines:n,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>e.stdio.map((c,d)=>so({stream:c,fdNumber:d,encoding:t,buffer:r[d],maxBuffer:i[d],lines:n[d],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),so=async({stream:e,fdNumber:t,encoding:r,buffer:i,maxBuffer:n,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:d})=>{if(!e)return;let p=nr(e,t,d);if(no(d,t)){await p;return}let[u]=await Promise.all([Qu({stream:e,onStreamEnd:p,fdNumber:t,encoding:r,buffer:i,maxBuffer:n,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:d}),p]);return u};var rl=({stdout:e,stderr:t},{all:r})=>r&&(e||t)?at([e,t].filter(Boolean)):void 0,il=({subprocess:e,encoding:t,buffer:r,maxBuffer:i,lines:n,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>so({...C0(e,r),fdNumber:"all",encoding:t,maxBuffer:i[1]+i[2],lines:n[1]||n[2],allMixed:A0(e),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),C0=({stdout:e,stderr:t,all:r},[,i,n])=>{let s=i||n;return s?i?n?{stream:r,buffer:s}:{stream:e,buffer:s}:{stream:t,buffer:s}:{stream:r,buffer:s}},A0=({all:e,stdout:t,stderr:r})=>e&&t&&r&&t.readableObjectMode!==r.readableObjectMode;import{once as E0}from"events";var nl=e=>xt(e,"ipc"),sl=(e,t)=>{let r=Dr(e);ke({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:t})};var ol=async({subprocess:e,buffer:t,maxBuffer:r,ipc:i,ipcOutput:n,verboseInfo:s})=>{if(!i)return n;let o=nl(s),a=Le(t,"ipc"),c=Le(r,"ipc");for await(let d of Ns({anyProcess:e,channel:e.channel,isSubprocess:!1,ipc:i,shouldAwait:!1,reference:!0}))a&&(dd(e,n,c),n.push(d)),o&&sl(d,s);return n},al=async(e,t)=>(await Promise.allSettled([e]),t);var cl=async({subprocess:e,options:{encoding:t,buffer:r,maxBuffer:i,lines:n,timeoutDuration:s,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:d,ipc:p,ipcInput:u},context:l,verboseInfo:m,fileDescriptors:h,originalStreams:f,onInternalError:x,controller:_})=>{let v=hu(e,l),C={originalStreams:f,fileDescriptors:h,subprocess:e,exitPromise:v,propagating:!1},E=tl({subprocess:e,encoding:t,buffer:r,maxBuffer:i,lines:n,stripFinalNewline:d,verboseInfo:m,streamInfo:C}),w=il({subprocess:e,encoding:t,buffer:r,maxBuffer:i,lines:n,stripFinalNewline:d,verboseInfo:m,streamInfo:C}),L=[],O=ol({subprocess:e,buffer:r,maxBuffer:i,ipc:p,ipcOutput:L,verboseInfo:m}),R=T0(f,e,C),F=P0(h,C);try{return await Promise.race([Promise.all([{},fu(v),Promise.all(E),w,O,Np(e,u),...R,...F]),x,O0(e,_),...Lp(e,s,l,_),...np({subprocess:e,cancelSignal:o,gracefulCancel:a,context:l,controller:_}),...jp({subprocess:e,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:l,controller:_})])}catch(N){return l.terminationReason??="other",Promise.all([{error:N},v,Promise.all(E.map(S=>io(S))),io(w),al(O,L),Promise.allSettled(R),Promise.allSettled(F)])}},T0=(e,t,r)=>e.map((i,n)=>i===t.stdio[n]?void 0:nr(i,n,r)),P0=(e,t)=>e.flatMap(({stdioItems:r},i)=>r.filter(({value:n,stream:s=n})=>be(s,{checkOpen:!1})&&!fe(s)).map(({type:n,value:s,stream:o=s})=>nr(o,i,t,{isSameDirection:le.has(n),stopOnExit:n==="native"}))),O0=async(e,{signal:t})=>{let[r]=await E0(e,"error",{signal:t});throw r};var pl=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),sr=(e,t,r)=>{let i=e[r];i.has(t)||i.set(t,[]);let n=i.get(t),s=Se();return n.push(s),{resolve:s.resolve.bind(s),promises:n}},Ot=async({resolve:e,promises:t},r)=>{e();let[i]=await Promise.race([Promise.allSettled([!0,r]),Promise.all([!1,...t])]);return!i};import{Readable as I0}from"stream";import{callbackify as R0}from"util";import{finished as dl}from"stream/promises";var oo=async e=>{if(e!==void 0)try{await ao(e)}catch{}},ul=async e=>{if(e!==void 0)try{await co(e)}catch{}},ao=async e=>{await dl(e,{cleanup:!0,readable:!1,writable:!0})},co=async e=>{await dl(e,{cleanup:!0,readable:!0,writable:!1})},Ii=async(e,t)=>{if(await e,t)throw t},Ri=(e,t,r)=>{r&&!Oi(r)?e.destroy(r):t&&e.destroy()};var ll=({subprocess:e,concurrentStreams:t,encoding:r},{from:i,binary:n=!0,preserveNewlines:s=!0}={})=>{let o=n||oe.has(r),{subprocessStdout:a,waitReadableDestroy:c}=po(e,i,t),{readableEncoding:d,readableObjectMode:p,readableHighWaterMark:u}=uo(a,o),{read:l,onStdoutDataDone:m}=lo({subprocessStdout:a,subprocess:e,binary:o,encoding:r,preserveNewlines:s}),h=new I0({read:l,destroy:R0(ho.bind(void 0,{subprocessStdout:a,subprocess:e,waitReadableDestroy:c})),highWaterMark:u,objectMode:p,encoding:d});return mo({subprocessStdout:a,onStdoutDataDone:m,readable:h,subprocess:e}),h},po=(e,t,r)=>{let i=qt(e,t),n=sr(r,i,"readableDestroy");return{subprocessStdout:i,waitReadableDestroy:n}},uo=({readableEncoding:e,readableObjectMode:t,readableHighWaterMark:r},i)=>i?{readableEncoding:e,readableObjectMode:t,readableHighWaterMark:r}:{readableEncoding:e,readableObjectMode:!0,readableHighWaterMark:ro},lo=({subprocessStdout:e,subprocess:t,binary:r,encoding:i,preserveNewlines:n})=>{let s=Se(),o=Pi({subprocessStdout:e,subprocess:t,binary:r,shouldEncode:!r,encoding:i,preserveNewlines:n});return{read(){j0(this,o,s)},onStdoutDataDone:s}},j0=async(e,t,r)=>{try{let{value:i,done:n}=await t.next();n?r.resolve():e.push(i)}catch{}},mo=async({subprocessStdout:e,onStdoutDataDone:t,readable:r,subprocess:i,subprocessStdin:n})=>{try{await co(e),await i,await oo(n),await t,r.readable&&r.push(null)}catch(s){await oo(n),ml(r,s)}},ho=async({subprocessStdout:e,subprocess:t,waitReadableDestroy:r},i)=>{await Ot(r,t)&&(ml(e,i),await Ii(t,i))},ml=(e,t)=>{Ri(e,e.readable,t)};import{Writable as D0}from"stream";import{callbackify as hl}from"util";var yl=({subprocess:e,concurrentStreams:t},{to:r}={})=>{let{subprocessStdin:i,waitWritableFinal:n,waitWritableDestroy:s}=yo(e,r,t),o=new D0({...fo(i,e,n),destroy:hl(_o.bind(void 0,{subprocessStdin:i,subprocess:e,waitWritableFinal:n,waitWritableDestroy:s})),highWaterMark:i.writableHighWaterMark,objectMode:i.writableObjectMode});return go(i,o),o},yo=(e,t,r)=>{let i=Kr(e,t),n=sr(r,i,"writableFinal"),s=sr(r,i,"writableDestroy");return{subprocessStdin:i,waitWritableFinal:n,waitWritableDestroy:s}},fo=(e,t,r)=>({write:L0.bind(void 0,e),final:hl(M0.bind(void 0,e,t,r))}),L0=(e,t,r,i)=>{e.write(t,r)?i():e.once("drain",i)},M0=async(e,t,r)=>{await Ot(r,t)&&(e.writable&&e.end(),await t)},go=async(e,t,r)=>{try{await ao(e),t.writable&&t.end()}catch(i){await ul(r),fl(t,i)}},_o=async({subprocessStdin:e,subprocess:t,waitWritableFinal:r,waitWritableDestroy:i},n)=>{await Ot(r,t),await Ot(i,t)&&(fl(e,n),await Ii(t,n))},fl=(e,t)=>{Ri(e,e.writable,t)};import{Duplex as F0}from"stream";import{callbackify as U0}from"util";var gl=({subprocess:e,concurrentStreams:t,encoding:r},{from:i,to:n,binary:s=!0,preserveNewlines:o=!0}={})=>{let a=s||oe.has(r),{subprocessStdout:c,waitReadableDestroy:d}=po(e,i,t),{subprocessStdin:p,waitWritableFinal:u,waitWritableDestroy:l}=yo(e,n,t),{readableEncoding:m,readableObjectMode:h,readableHighWaterMark:f}=uo(c,a),{read:x,onStdoutDataDone:_}=lo({subprocessStdout:c,subprocess:e,binary:a,encoding:r,preserveNewlines:o}),v=new F0({read:x,...fo(p,e,u),destroy:U0(B0.bind(void 0,{subprocessStdout:c,subprocessStdin:p,subprocess:e,waitReadableDestroy:d,waitWritableFinal:u,waitWritableDestroy:l})),readableHighWaterMark:f,writableHighWaterMark:p.writableHighWaterMark,readableObjectMode:h,writableObjectMode:p.writableObjectMode,encoding:m});return mo({subprocessStdout:c,onStdoutDataDone:_,readable:v,subprocess:e,subprocessStdin:p}),go(p,v,c),v},B0=async({subprocessStdout:e,subprocessStdin:t,subprocess:r,waitReadableDestroy:i,waitWritableFinal:n,waitWritableDestroy:s},o)=>{await Promise.all([ho({subprocessStdout:e,subprocess:r,waitReadableDestroy:i},o),_o({subprocessStdin:t,subprocess:r,waitWritableFinal:n,waitWritableDestroy:s},o)])};var bo=(e,t,{from:r,binary:i=!1,preserveNewlines:n=!1}={})=>{let s=i||oe.has(t),o=qt(e,r),a=Pi({subprocessStdout:o,subprocess:e,binary:s,shouldEncode:!0,encoding:t,preserveNewlines:n});return N0(a,o,e)},N0=async function*(e,t,r){try{yield*e}finally{t.readable&&t.destroy(),await r}};var _l=(e,{encoding:t})=>{let r=pl();e.readable=ll.bind(void 0,{subprocess:e,concurrentStreams:r,encoding:t}),e.writable=yl.bind(void 0,{subprocess:e,concurrentStreams:r}),e.duplex=gl.bind(void 0,{subprocess:e,concurrentStreams:r,encoding:t}),e.iterable=bo.bind(void 0,e,t),e[Symbol.asyncIterator]=bo.bind(void 0,e,t,{})};var bl=(e,t)=>{for(let[r,i]of z0){let n=i.value.bind(t);Reflect.defineProperty(e,r,{...i,value:n})}},G0=(async()=>{})().constructor.prototype,z0=["then","catch","finally"].map(e=>[e,Reflect.getOwnPropertyDescriptor(G0,e)]);var xl=(e,t,r,i)=>{let{file:n,commandArguments:s,command:o,escapedCommand:a,startTime:c,verboseInfo:d,options:p,fileDescriptors:u}=H0(e,t,r),{subprocess:l,promise:m}=Y0({file:n,commandArguments:s,options:p,startTime:c,verboseInfo:d,command:o,escapedCommand:a,fileDescriptors:u});return l.pipe=Ti.bind(void 0,{source:l,sourcePromise:m,boundOptions:{},createNested:i}),bl(l,m),ve.set(l,{options:p,fileDescriptors:u}),l},H0=(e,t,r)=>{let{command:i,escapedCommand:n,startTime:s,verboseInfo:o}=Mr(e,t,r),{file:a,commandArguments:c,options:d}=si(e,t,r),p=K0(d),u=Pu(p,o);return{file:a,commandArguments:c,command:i,escapedCommand:n,startTime:s,verboseInfo:o,options:p,fileDescriptors:u}},K0=({timeout:e,signal:t,...r})=>{if(t!==void 0)throw new TypeError('The "signal" option has been renamed to "cancelSignal" instead.');return{...r,timeoutDuration:e}},Y0=({file:e,commandArguments:t,options:r,startTime:i,verboseInfo:n,command:s,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=W0(...oi(e,t,r))}catch(h){return Cu({error:h,command:s,escapedCommand:o,fileDescriptors:a,options:r,startTime:i,verboseInfo:n})}let d=new AbortController;V0(Number.POSITIVE_INFINITY,d.signal);let p=[...c.stdio];Uu(c,a,d),Nu(c,r,d);let u={},l=Se();c.kill=rp.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:l,context:u,controller:d}),c.all=rl(c,r),_l(c,r),vu(c,r);let m=J0({subprocess:c,options:r,startTime:i,verboseInfo:n,fileDescriptors:a,originalStreams:p,command:s,escapedCommand:o,context:u,onInternalError:l,controller:d});return{subprocess:c,promise:m}},J0=async({subprocess:e,options:t,startTime:r,verboseInfo:i,fileDescriptors:n,originalStreams:s,command:o,escapedCommand:a,context:c,onInternalError:d,controller:p})=>{let[u,[l,m],h,f,x]=await cl({subprocess:e,options:t,context:c,verboseInfo:i,fileDescriptors:n,originalStreams:s,onInternalError:d,controller:p});p.abort(),d.resolve();let _=h.map((E,w)=>Fe(E,t,w)),v=Fe(f,t,"all"),C=X0({errorInfo:u,exitCode:l,signal:m,stdio:_,all:v,ipcOutput:x,context:c,options:t,command:o,escapedCommand:a,startTime:r});return Et(C,i,t)},X0=({errorInfo:e,exitCode:t,signal:r,stdio:i,all:n,ipcOutput:s,context:o,options:a,command:c,escapedCommand:d,startTime:p})=>"error"in e?Zt({error:e.error,command:c,escapedCommand:d,timedOut:o.terminationReason==="timeout",isCanceled:o.terminationReason==="cancel"||o.terminationReason==="gracefulCancel",isGracefullyCanceled:o.terminationReason==="gracefulCancel",isMaxBuffer:e.error instanceof qe,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:t,signal:r,stdio:i,all:n,ipcOutput:s,options:a,startTime:p,isSync:!1}):yi({command:c,escapedCommand:d,stdio:i,all:n,ipcOutput:s,options:a,startTime:p});var ji=(e,t)=>{let r=Object.fromEntries(Object.entries(t).map(([i,n])=>[i,Q0(i,e[i],n)]));return{...e,...r}},Q0=(e,t,r)=>Z0.has(e)&&V(t)&&V(r)?{...t,...r}:r,Z0=new Set(["env",...Kn]);var He=(e,t,r,i)=>{let n=(o,a,c)=>He(o,a,r,c),s=(...o)=>ek({mapArguments:e,deepOptions:r,boundOptions:t,setBoundExeca:i,createNested:n},...o);return i!==void 0&&i(s,n,t),s},ek=({mapArguments:e,deepOptions:t={},boundOptions:r={},setBoundExeca:i,createNested:n},s,...o)=>{if(V(s))return n(e,ji(r,s),i);let{file:a,commandArguments:c,options:d,isSync:p}=tk({mapArguments:e,firstArgument:s,nextArguments:o,deepOptions:t,boundOptions:r});return p?_u(a,c,d):xl(a,c,d,n)},tk=({mapArguments:e,firstArgument:t,nextArguments:r,deepOptions:i,boundOptions:n})=>{let s=Pa(t)?Oa(t,r):[t,...r],[o,a,c]=Cr(...s),d=ji(ji(i,n),c),{file:p=o,commandArguments:u=a,options:l=d,isSync:m=!1}=e({file:o,commandArguments:a,options:d});return{file:p,commandArguments:u,options:l,isSync:m}};var wl=({file:e,commandArguments:t})=>Sl(e,t),kl=({file:e,commandArguments:t})=>({...Sl(e,t),isSync:!0}),Sl=(e,t)=>{if(t.length>0)throw new TypeError(`The command and its arguments must be passed as a single string: ${e} ${t}.`);let[r,...i]=rk(e);return{file:r,commandArguments:i}},rk=e=>{if(typeof e!="string")throw new TypeError(`The command must be a string: ${String(e)}.`);let t=e.trim();if(t==="")return[];let r=[];for(let i of t.split(ik)){let n=r.at(-1);n&&n.endsWith("\\")?r[r.length-1]=`${n.slice(0,-1)} ${i}`:r.push(i)}return r},ik=/ +/g;var vl=(e,t,r)=>{e.sync=t(nk,r),e.s=e.sync},ql=({options:e})=>$l(e),nk=({options:e})=>({...$l(e),isSync:!0}),$l=e=>({options:{...sk(e),...e}}),sk=({input:e,inputFile:t,stdio:r})=>e===void 0&&t===void 0&&r===void 0?{stdin:"inherit"}:{},Cl={preferLocal:!0};var me=He(()=>({})),hj=He(()=>({isSync:!0})),Di=He(wl),yj=He(kl),fj=He(Fp),gj=He(ql,{},Cl,vl),{sendMessage:_j,getOneMessage:bj,getEachMessage:xj,getCancelSignal:wj}=qu();async function K(e,t,r){return me("docker",["compose",...e],{cwd:t,...r})}async function Q(e,t,r){let i=["compose","exec","-T"];if(r)for(let[s,o]of Object.entries(r))i.push("-e",`${s}=${o}`);i.push("web","bin/rails",e);let{stdout:n}=await me("docker",i,{cwd:t});return n.split(`
|
|
76
|
+
`).filter(s=>!s.startsWith("[")).join(`
|
|
77
|
+
`).trim()}async function Al(e,t){let{stdout:r}=await me("docker",["compose","ps",e,"--format","{{.State}}"],{cwd:t});return r.split(`
|
|
78
|
+
`).some(i=>i.trim()==="running")}async function I(e,t,r={}){let{service:i="web",tty:n=!0,env:s}=r,o=["compose","exec"];if(n||o.push("-T"),s)for(let[a,c]of Object.entries(s))o.push("-e",`${a}=${c}`);o.push(i,...e),await me("docker",o,{cwd:t,stdio:"inherit"})}async function Li(e,t){await me("docker",["compose","logs","-f",e],{cwd:t,stdio:"inherit"})}var xo=`http://localhost:${3e3}`,Ke=class extends Error{};function El(){return process.env.XDG_CONFIG_HOME?It.join(process.env.XDG_CONFIG_HOME,"spree"):It.join(ok.homedir(),".config","spree")}function pt(){return It.join(El(),"config.json")}function wo(e){return e?.code==="ENOENT"}function ar(){let e;try{e=Ue.readFileSync(pt(),"utf-8")}catch(t){if(wo(t))return{profiles:{}};throw t}try{let t=JSON.parse(e);return{...t,profiles:t.profiles??{}}}catch{let t=`${pt()}.bak`;try{Ue.renameSync(pt(),t)}catch{}return process.stderr.write(`${or.default.yellow(`warning: ${pt()} was not valid JSON; moved it to ${t} and starting fresh.`)}
|
|
79
|
+
`),{profiles:{}}}}function ko(e){Ue.mkdirSync(El(),{recursive:!0,mode:448}),Tl(pt(),`${JSON.stringify(e,null,2)}
|
|
80
|
+
`)}function Tl(e,t){Ue.writeFileSync(e,t,{mode:384}),Ue.chmodSync(e,384)}function Mi(e){return It.join(e,".spree","credentials.json")}function ak(e){let t;try{t=Ue.readFileSync(Mi(e),"utf-8")}catch(r){if(wo(r))return null;throw r}try{return JSON.parse(t)}catch{return null}}function ck(e,t){let r=Mi(e),i=It.dirname(r);Ue.mkdirSync(i,{recursive:!0,mode:448}),pk(It.join(i,".gitignore")),Tl(r,`${JSON.stringify(t,null,2)}
|
|
81
|
+
`)}function pk(e){let t="";try{t=Ue.readFileSync(e,"utf-8")}catch(i){if(!wo(i))throw i}t.split(`
|
|
82
|
+
`).some(i=>i.trim()==="*")||Ue.writeFileSync(e,t&&!t.endsWith(`
|
|
83
|
+
`)?`${t}
|
|
84
|
+
*
|
|
85
|
+
`:`${t}*
|
|
86
|
+
`)}function Fi(e){return e.slice(0,12)}async function dk(e,t){process.stderr.write(`${or.default.dim("No credentials found \u2014 minting a read-only API key via the dev stack...")}
|
|
87
|
+
`);let r;try{r=await Q("spree:cli:create_api_key",e,{NAME:"@spree/cli (auto)",KEY_TYPE:"secret",SCOPES:"read_all"})}catch(s){let o=s instanceof Error?s.message.split(`
|
|
88
|
+
`)[0]:String(s);throw new Ke(`Could not mint an API key via the dev stack. Is it running? Start it with \`spree dev\`.
|
|
89
|
+
${or.default.dim(o)}`)}let i=r.match(/sk_[A-Za-z0-9_-]+/);if(!i)throw new Ke("Could not mint an API key via the dev stack. Is it running? Start it with `spree dev`.");let n={baseUrl:`http://localhost:${t}`,token:i[0],scopes:["read_all"],mintedAt:new Date().toISOString()};return ck(e,n),process.stderr.write(`${or.default.dim("Saved to .spree/credentials.json (scopes: read_all)")}
|
|
90
|
+
`),n}async function cr(e,t={}){let{allowMint:r=!0,cwd:i=process.cwd()}=t,n=ar(),s=e.baseUrl,o=e.apiKey,a;if(o&&(a={apiKey:o,source:"flags"}),!a&&e.profile){let p=n.profiles[e.profile];if(!p)throw new Ke(`Unknown profile "${e.profile}". Run \`spree auth login --profile ${e.profile}\` to create it.`);a={baseUrl:p.baseUrl,apiKey:p.token,source:"profile",profileName:e.profile}}if(!a&&process.env.SPREE_API_KEY&&(a={baseUrl:process.env.SPREE_BASE_URL,apiKey:process.env.SPREE_API_KEY,source:"env"}),!a){let p,u=0;try{let l=g(i);p=l.projectDir,u=l.port}catch{}if(p){let l=`http://localhost:${u}`,m=!s||s.replace(/\/$/,"")===l,h=ak(p);!h&&r&&m&&(h=await dk(p,u)),h&&(a={baseUrl:h.baseUrl,apiKey:h.token,source:"project",scopes:h.scopes})}}if(!a&&n.defaultProfile){let p=n.profiles[n.defaultProfile];p&&(a={baseUrl:p.baseUrl,apiKey:p.token,source:"profile",profileName:n.defaultProfile})}let c=s??a?.baseUrl,d=a?.apiKey;if(!c&&(a?.source==="flags"||a?.source==="env")&&(c=xo),!c||!d)throw new Ke(["No Admin API credentials found. Provide them via one of (host and key resolve together per source):"," - flags: --api-key <sk_...> (host defaults to "+xo+"; pass --base-url for a remote store)"," - env: SPREE_API_KEY (host defaults to "+xo+"; set SPREE_BASE_URL for a remote store)"," - project: run inside a Spree project with the dev stack up (auto-mints a read-only key)"," - profile: spree auth login --profile <name>"].join(`
|
|
91
|
+
`));return{baseUrl:c,apiKey:d,source:a?.source??"flags",profileName:a?.profileName,tokenPrefix:Fi(d),scopes:a?.scopes}}function pr(e,t="json"){if(e!=null){if(t==="table"){let r=mk(e);if(r){(0,So.printTable)(r.map(Pl));return}let i=Pl(e);(0,So.printTable)(Object.entries(i).map(([n,s])=>({field:n,value:s})));return}process.stdout.isTTY?process.stdout.write(`${lk(JSON.stringify(e,null,2))}
|
|
92
|
+
`):process.stdout.write(`${JSON.stringify(e)}
|
|
93
|
+
`)}}var uk=/("(?:\\.|[^"\\])*"(\s*:)?)|\b(true|false|null)\b|(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)/g;function lk(e){return e.replace(uk,(t,r,i,n,s)=>r!==void 0?i?ae.default.cyan(r.slice(0,-i.length))+i:ae.default.green(r):n!==void 0?ae.default.yellow(n):s!==void 0?ae.default.yellow(s):t)}function mk(e){return Array.isArray(e)?e:e&&typeof e=="object"&&Array.isArray(e.data)?e.data:null}function Pl(e){let t={};for(let[r,i]of Object.entries(e))i===null||["string","number","boolean"].includes(typeof i)?t[r]=i:Array.isArray(i)?t[r]=`[${i.length}]`:t[r]="{\u2026}";return t}function dt(e,t={}){if(e instanceof et){let i=e.details?`
|
|
94
|
+
${JSON.stringify({details:e.details},null,2)}`:"";process.stderr.write(`${ae.default.red(`${e.code}:`)} ${e.message}${i}
|
|
95
|
+
`);let n=e.details?.required_scope;typeof n=="string"&&process.stderr.write(`${ae.default.dim(`Hint: this key lacks \`${n}\`. Create one that has it and use it:`)}
|
|
96
|
+
${ae.default.dim(` spree api-key create --type secret --scopes ${n}`)}
|
|
97
|
+
${ae.default.dim(" then pass it via --api-key <sk_...> or export SPREE_API_KEY=<sk_...>")}
|
|
98
|
+
`),process.exit(1)}if(e instanceof Ke&&(process.stderr.write(`${ae.default.red("error:")} ${e.message}
|
|
99
|
+
`),process.exit(2)),e instanceof TypeError&&/fetch failed/i.test(e.message)){let i=e.cause,n=i instanceof Error?i.message:i?String(i):"",s=t.baseUrl?` (${t.baseUrl})`:"";process.stderr.write(`${ae.default.red("error:")} could not reach the server${s}${n?`: ${n}`:""}
|
|
100
|
+
`),process.stderr.write(`${ae.default.dim("Hint: check the URL, or run `spree api status` to diagnose reachability and credentials.")}
|
|
101
|
+
`),process.exit(2)}let r=e instanceof Error?e.message:String(e);process.stderr.write(`${ae.default.red("error:")} ${r}
|
|
102
|
+
`),process.exit(2)}function Il(e){let t=new Map;for(let i of e.query??[]){let n=i.indexOf("=");if(n<=0)throw new Error(`Invalid -q expression "${i}" \u2014 expected key=value (e.g. -q status_eq=active)`);let s=i.slice(0,n),o=i.slice(n+1),a=t.get(s);a?a.push(o):t.set(s,[o])}let r={};for(let[i,n]of t)n.length>1?r[`q[${i}][]`]=n:r[`q[${i}]`]=n[0];return e.sort&&(r.sort=e.sort),e.page!==void 0&&(r.page=Ol(e.page,"--page")),e.limit!==void 0&&(r.limit=Ol(e.limit,"--limit")),e.expand&&(r.expand=e.expand),e.fields&&(r.fields=e.fields),r}function Ol(e,t){if(!/^[1-9]\d*$/.test(e))throw new Error(`Invalid ${t} "${e}" \u2014 expected a positive integer`);return Number(e)}function dr(e){let t=e.startsWith("/")?e:`/${e}`,r="/api/v3/admin";return t===r?"/":t.startsWith(`${r}/`)?t.slice(r.length):t}var Rt=B(X(),1);async function ur(e,t){let r=kr({baseUrl:e,secretKey:t,retry:!1});try{return{status:"connected",storeName:(await r.request("GET","/store",{}))?.name}}catch(i){return i instanceof et?i.status===401?{status:"unauthorized",message:i.message}:i.status===403?{status:"forbidden"}:{status:"unreachable",message:`server responded HTTP ${i.status}: ${i.message}`}:{status:"unreachable",message:i instanceof Error?i.message:String(i)}}}function Ui(e){return e.status==="unauthorized"||e.status==="unreachable"}function Bi(e){return{connected:Rt.default.green(`connected${e.storeName?` (${e.storeName})`:""}`),forbidden:Rt.default.green("connected")+Rt.default.dim(" (key valid; lacks read_settings for store details)"),unauthorized:Rt.default.red("key rejected (401)"),unreachable:Rt.default.red(`unreachable \u2014 ${e.message}`)}[e.status]}var Rl={info:{title:"Admin API",contact:{name:"Spree Commerce",url:"https://spreecommerce.org",email:"hello@spreecommerce.org"},description:`Spree Admin API v3 - Administrative API for managing products, orders, and store settings.
|
|
103
|
+
|
|
104
|
+
## Authentication
|
|
105
|
+
|
|
106
|
+
The Admin API requires a secret API key passed in the \`x-spree-api-key\` header.
|
|
107
|
+
Secret API keys can be generated in the Spree admin dashboard.
|
|
108
|
+
|
|
109
|
+
## Response Format
|
|
110
|
+
|
|
111
|
+
All responses are JSON. List endpoints return paginated responses with \`data\` and \`meta\` keys.
|
|
112
|
+
Single resource endpoints return a flat JSON object.
|
|
113
|
+
|
|
114
|
+
## Resource IDs
|
|
115
|
+
|
|
116
|
+
Every resource is identified by an opaque string ID (e.g. \`prod_86Rf07xd4z\`,
|
|
117
|
+
\`variant_k5nR8xLq\`, \`or_UkLWZg9DAJ\`). Use these IDs everywhere \u2014 URL paths,
|
|
118
|
+
request bodies, and Ransack filters all accept them directly.
|
|
119
|
+
|
|
120
|
+
## Error Handling
|
|
121
|
+
|
|
122
|
+
Errors return a consistent format:
|
|
123
|
+
\`\`\`json
|
|
124
|
+
{
|
|
125
|
+
"error": {
|
|
126
|
+
"code": "validation_error",
|
|
127
|
+
"message": "Validation failed",
|
|
128
|
+
"details": { "name": ["can't be blank"] }
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
\`\`\`
|
|
132
|
+
`,version:"v3"},paths:{"/api/v3/admin/auth/login":{post:{summary:"Login",tags:["Authentication"],security:[{api_key:[]}],description:`Authenticates an admin user and returns a short-lived JWT access token.
|
|
133
|
+
The rotatable refresh token is set in an HttpOnly cookie \u2014 it is not
|
|
134
|
+
included in the response body.
|
|
135
|
+
|
|
136
|
+
The \`provider\` field selects the authentication method. When omitted it
|
|
137
|
+
defaults to \`email\`, the built-in email/password login.
|
|
138
|
+
|
|
139
|
+
To authenticate against a third-party identity provider (Okta, Azure AD,
|
|
140
|
+
Google Workspace SSO, a custom JWT issuer, SAML, etc.), send
|
|
141
|
+
\`{ "provider": "<your_key>", ... }\` with the fields that provider
|
|
142
|
+
requires. The endpoint returns the same JWT regardless of which provider
|
|
143
|
+
authenticated the request. See
|
|
144
|
+
[Custom API Authentication](https://spreecommerce.org/docs/developer/how-to/custom-api-authentication)
|
|
145
|
+
for the list of configured providers and their required fields.
|
|
146
|
+
`,parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}}],responses:{"200":{description:"login successful",content:{"application/json":{schema:{$ref:"#/components/schemas/AuthResponse"}}}},"401":{description:"invalid credentials",content:{"application/json":{schema:{$ref:"#/components/schemas/ErrorResponse"}}}}},requestBody:{content:{"application/json":{schema:{oneOf:[{title:"EmailPasswordLogin",description:"Built-in email/password authentication (default when `provider` is omitted).",type:"object",properties:{provider:{type:"string",enum:["email"],default:"email"},email:{type:"string",format:"email"},password:{type:"string"}},required:["email","password"]},{title:"ProviderLogin",description:`Provider-dispatched login. The \`provider\` key selects a configured
|
|
147
|
+
authentication provider; the remaining fields are forwarded to it.
|
|
148
|
+
Required fields depend on the provider \u2014 see
|
|
149
|
+
[Custom API Authentication](https://spreecommerce.org/docs/developer/how-to/custom-api-authentication).
|
|
150
|
+
`,type:"object",properties:{provider:{type:"string",description:"Registered provider key (anything other than `email`).",not:{enum:["email"]}}},required:["provider"],additionalProperties:!0}]}}}}}},"/api/v3/admin/auth/refresh":{post:{summary:"Refresh token",tags:["Authentication"],security:[{api_key:[]}],description:`Exchanges the HttpOnly refresh-token cookie for a new access JWT and a
|
|
151
|
+
rotated refresh token cookie. No request body or Authorization header
|
|
152
|
+
is required \u2014 the cookie alone authenticates the call.
|
|
153
|
+
`,parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}}],responses:{"200":{description:"refresh successful",content:{"application/json":{schema:{$ref:"#/components/schemas/AuthResponse"}}}},"401":{description:"missing or invalid refresh-token cookie",content:{"application/json":{schema:{$ref:"#/components/schemas/ErrorResponse"}}}}}}},"/api/v3/admin/auth/logout":{post:{summary:"Logout",tags:["Authentication"],security:[{api_key:[]}],description:"Revokes the refresh-token cookie, effectively logging the admin out.",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}}],responses:{"204":{description:"logout successful"}}}},"/api/v3/admin/me":{get:{summary:"Get current admin user and permissions",tags:["Authentication"],security:[{api_key:[],bearer_auth:[]}],description:"Returns the current admin user profile and a serialized list of permissions (CanCanCan rules). The SPA uses these to drive UI permission checks.",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}}],responses:{"200":{description:"current admin user and permissions",content:{"application/json":{schema:{$ref:"#/components/schemas/MeResponse"}}}},"401":{description:"unauthorized",content:{"application/json":{schema:{$ref:"#/components/schemas/ErrorResponse"}}}}}}},"/api/v3/admin/allowed_origins":{get:{summary:"List allowed origins",tags:["Allowed Origins"],security:[{api_key:[],bearer_auth:[]}],description:"Returns the CORS allowlist for the current store. Each entry is a\nbare `scheme://host[:port]` permitted to call the admin API from a\nbrowser. Backs the `Rack::Cors` allowlist and the CSRF boundary of\nthe admin cookie session (see\n`docs/plans/5.5-admin-auth-cookie-refresh.md`).\n\n\n**Required scope:** `read_settings` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}},{name:"page",in:"query",required:!1,description:"Page number",schema:{type:"integer"}},{name:"limit",in:"query",required:!1,description:"Number of records per page",schema:{type:"integer"}},{name:"q[origin_cont]",in:"query",required:!1,description:"Filter by origin (contains)",schema:{type:"string"}},{name:"sort",in:"query",required:!1,description:"Sort by field. Prefix with `-` for descending (e.g., `-created_at`).",schema:{type:"string"}},{name:"fields",in:"query",required:!1,description:"Comma-separated list of fields to include. id is always included.",schema:{type:"string"}}],responses:{"200":{description:"allowed origins found",content:{"application/json":{schema:{type:"object",properties:{data:{type:"array",items:{$ref:"#/components/schemas/AllowedOrigin"}},meta:{$ref:"#/components/schemas/PaginationMeta"}},required:["data","meta"]}}}},"401":{description:"unauthorized",content:{"application/json":{schema:{$ref:"#/components/schemas/ErrorResponse"}}}}}},post:{summary:"Create an allowed origin",tags:["Allowed Origins"],security:[{api_key:[],bearer_auth:[]}],description:"Adds an origin to the admin CORS allowlist. The value must be a bare\n`scheme://host[:port]` (no path, query, or fragment) and use `http` or\n`https`.\n\n\n**Required scope:** `write_settings` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}}],responses:{"201":{description:"allowed origin created",content:{"application/json":{schema:{$ref:"#/components/schemas/AllowedOrigin"}}}},"422":{description:"validation error",content:{"application/json":{schema:{$ref:"#/components/schemas/ErrorResponse"}}}}},requestBody:{content:{"application/json":{schema:{type:"object",properties:{origin:{type:"string"}},required:["origin"]}}}}}},"/api/v3/admin/allowed_origins/{id}":{parameters:[{name:"id",in:"path",required:!0,description:"Allowed origin ID",schema:{type:"string"}}],get:{summary:"Get an allowed origin",tags:["Allowed Origins"],security:[{api_key:[],bearer_auth:[]}],description:"Returns a single allowed origin by prefixed ID.\n\n**Required scope:** `read_settings` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}},{name:"fields",in:"query",required:!1,description:"Comma-separated list of fields to include. id is always included.",schema:{type:"string"}}],responses:{"200":{description:"allowed origin found",content:{"application/json":{schema:{$ref:"#/components/schemas/AllowedOrigin"}}}},"404":{description:"allowed origin not found",content:{"application/json":{schema:{$ref:"#/components/schemas/ErrorResponse"}}}}}},patch:{summary:"Update an allowed origin",tags:["Allowed Origins"],security:[{api_key:[],bearer_auth:[]}],description:"Updates an existing allowed origin.\n\n**Required scope:** `write_settings` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}}],responses:{"200":{description:"allowed origin updated",content:{"application/json":{schema:{$ref:"#/components/schemas/AllowedOrigin"}}}},"422":{description:"validation error",content:{"application/json":{schema:{$ref:"#/components/schemas/ErrorResponse"}}}}},requestBody:{content:{"application/json":{schema:{type:"object",properties:{origin:{type:"string"}}}}}}},delete:{summary:"Delete an allowed origin",tags:["Allowed Origins"],security:[{api_key:[],bearer_auth:[]}],description:`Removes an origin from the admin CORS allowlist. After deletion the
|
|
154
|
+
admin SPA running at that origin will no longer be able to call the
|
|
155
|
+
admin API from a browser.
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
**Required scope:** \`write_settings\` (for API-key authentication).`,parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}}],responses:{"204":{description:"allowed origin deleted"}}}},"/api/v3/admin/api_keys":{get:{summary:"List API keys",tags:["API Keys"],security:[{api_key:[],bearer_auth:[]}],description:"Returns publishable and secret API keys for the current store. Secret keys are listed by `token_prefix` only \u2014 the plaintext token is delivered exactly once on create.\n\n**Required scope:** `read_api_keys` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}}],responses:{"200":{description:"API keys found",content:{"application/json":{}}}}},post:{summary:"Create an API key",tags:["API Keys"],security:[{api_key:[],bearer_auth:[]}],description:"Creates a publishable or secret API key. The plaintext token is included in the response **once** for secret keys; publishable keys expose their token on every read since they are intended for client-side use.\n\n**Required scope:** `write_api_keys` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}}],responses:{"201":{description:"secret key created \u2014 plaintext token returned once",content:{"application/json":{}}},"422":{description:"validation error",content:{"application/json":{}}}},requestBody:{content:{"application/json":{schema:{type:"object",required:["name","key_type"],properties:{name:{type:"string"},key_type:{type:"string",enum:["publishable","secret"]},scopes:{type:"array",items:{type:"string"}}}}}}}}},"/api/v3/admin/api_keys/{id}":{get:{summary:"Show an API key",tags:["API Keys"],security:[{api_key:[],bearer_auth:[]}],description:"**Required scope:** `read_api_keys` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}},{name:"id",in:"path",required:!0,schema:{type:"string"}}],responses:{"200":{description:"API key found",content:{"application/json":{}}}}},delete:{summary:"Delete an API key",tags:["API Keys"],security:[{api_key:[],bearer_auth:[]}],description:"**Required scope:** `write_api_keys` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}},{name:"id",in:"path",required:!0,schema:{type:"string"}}],responses:{"204":{description:"API key deleted"}}}},"/api/v3/admin/api_keys/{id}/revoke":{patch:{summary:"Revoke an API key",tags:["API Keys"],security:[{api_key:[],bearer_auth:[]}],description:"Marks the key revoked. Future requests using its token will fail; the row is preserved for audit.\n\n**Required scope:** `write_api_keys` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}},{name:"id",in:"path",required:!0,schema:{type:"string"}}],responses:{"200":{description:"API key revoked",content:{"application/json":{}}}}}},"/api/v3/admin/channels":{get:{summary:"List channels",tags:["Channels"],security:[{api_key:[],bearer_auth:[]}],description:"Returns the channels configured for the current store.\n\n**Required scope:** `read_settings` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}},{name:"page",in:"query",required:!1,schema:{type:"integer"}},{name:"limit",in:"query",required:!1,schema:{type:"integer"}}],responses:{"200":{description:"channels found",content:{"application/json":{schema:{type:"object",properties:{data:{type:"array",items:{$ref:"#/components/schemas/Channel"}},meta:{$ref:"#/components/schemas/PaginationMeta"}},required:["data","meta"]}}}}}},post:{summary:"Create a channel",tags:["Channels"],security:[{api_key:[],bearer_auth:[]}],description:"Creates a new channel on the current store. `code` is normalized to a\nURL-safe slug (`Point of Sale` \u2192 `point-of-sale`); when omitted it's\nderived from `name`.\n\n\n**Required scope:** `write_settings` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}}],responses:{"201":{description:"channel created",content:{"application/json":{}}}},requestBody:{content:{"application/json":{schema:{type:"object",required:["name"],properties:{name:{type:"string"},code:{type:"string",description:"Slug \u2014 auto-derived from `name` when blank."},active:{type:"boolean",default:!0}}}}}}}},"/api/v3/admin/channels/{id}":{parameters:[{name:"id",in:"path",required:!0,schema:{type:"string"}}],get:{summary:"Get a channel",tags:["Channels"],security:[{api_key:[],bearer_auth:[]}],description:"**Required scope:** `read_settings` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}}],responses:{"200":{description:"channel found",content:{"application/json":{}}}}},patch:{summary:"Update a channel",tags:["Channels"],security:[{api_key:[],bearer_auth:[]}],description:"**Required scope:** `write_settings` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}}],responses:{"200":{description:"channel updated",content:{"application/json":{}}}},requestBody:{content:{"application/json":{schema:{type:"object",properties:{name:{type:"string"},code:{type:"string"},active:{type:"boolean"}}}}}}},delete:{summary:"Delete a channel",tags:["Channels"],security:[{api_key:[],bearer_auth:[]}],description:"**Required scope:** `write_settings` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}}],responses:{"204":{description:"channel deleted"}}}},"/api/v3/admin/channels/{id}/add_products":{parameters:[{name:"id",in:"path",required:!0,schema:{type:"string"}}],post:{summary:"Publish products on a channel",tags:["Channels"],security:[{api_key:[],bearer_auth:[]}],description:`Publishes the listed products on this channel. Idempotent \u2014 re-publishing
|
|
159
|
+
an already-published product updates its publication window. Products from
|
|
160
|
+
sibling stores are silently dropped.
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
**Required scope:** \`write_products\` (for API-key authentication).`,parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}}],responses:{"200":{description:"products published",content:{"application/json":{schema:{type:"object",properties:{product_count:{type:"integer"}}}}}}},requestBody:{content:{"application/json":{schema:{type:"object",required:["product_ids"],properties:{product_ids:{type:"array",items:{type:"string"}},published_at:{type:"string",format:"date-time",nullable:!0,description:"When the publications go live. `null` means immediately."},unpublished_at:{type:"string",format:"date-time",nullable:!0,description:"When the publications come down. `null` means never."}}}}}}}},"/api/v3/admin/channels/{id}/remove_products":{parameters:[{name:"id",in:"path",required:!0,schema:{type:"string"}}],post:{summary:"Unpublish products from a channel",tags:["Channels"],security:[{api_key:[],bearer_auth:[]}],description:"Unpublishes the listed products from this channel.\n\n**Required scope:** `write_products` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}}],responses:{"200":{description:"products unpublished",content:{"application/json":{schema:{type:"object",properties:{product_count:{type:"integer"}}}}}}},requestBody:{content:{"application/json":{schema:{type:"object",required:["product_ids"],properties:{product_ids:{type:"array",items:{type:"string"}}}}}}}}},"/api/v3/admin/custom_field_definitions":{get:{summary:"List custom field definitions",tags:["Custom Fields"],security:[{api_key:[],bearer_auth:[]}],description:"Returns all defined custom fields. Filter by `?q[resource_type_eq]=Spree::Product` to narrow to one parent type.\n\n**Required scope:** `read_settings` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}},{name:"expand",in:"query",required:!1,description:"Comma-separated associations to expand. Use dot notation for nested expand (max 4 levels).",schema:{type:"string"}},{name:"fields",in:"query",required:!1,description:"Comma-separated list of fields to include (e.g., key,label,field_type). id is always included.",schema:{type:"string"}}],responses:{"200":{description:"definitions returned",content:{"application/json":{}}}}},post:{summary:"Create a custom field definition",tags:["Custom Fields"],security:[{api_key:[],bearer_auth:[]}],description:"**Required scope:** `write_settings` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}}],responses:{"201":{description:"definition created",content:{"application/json":{}}}},requestBody:{content:{"application/json":{schema:{type:"object",required:["key","field_type","resource_type"],properties:{namespace:{type:"string",description:"Defaults to `custom`"},key:{type:"string"},label:{type:"string",description:"Human-readable name; defaults to titleized `key`"},field_type:{type:"string",description:"Custom field type identifier (one of the registered field-type class names)."},resource_type:{type:"string",description:"Owner class, e.g. `Spree::Product`"},storefront_visible:{type:"boolean",description:"When false, definition is admin-only (was `display_on: back_end`)"}}}}}}}},"/api/v3/admin/custom_field_definitions/{id}":{get:{summary:"Show a custom field definition",tags:["Custom Fields"],security:[{api_key:[],bearer_auth:[]}],description:"**Required scope:** `read_settings` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}},{name:"id",in:"path",required:!0,schema:{type:"string"}},{name:"expand",in:"query",required:!1,description:"Comma-separated associations to expand. Use dot notation for nested expand (max 4 levels).",schema:{type:"string"}},{name:"fields",in:"query",required:!1,description:"Comma-separated list of fields to include (e.g., key,label,field_type). id is always included.",schema:{type:"string"}}],responses:{"200":{description:"definition found",content:{"application/json":{}}}}},patch:{summary:"Update a custom field definition",tags:["Custom Fields"],security:[{api_key:[],bearer_auth:[]}],description:"**Required scope:** `write_settings` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}},{name:"id",in:"path",required:!0,schema:{type:"string"}}],responses:{"200":{description:"definition updated",content:{"application/json":{}}}},requestBody:{content:{"application/json":{schema:{type:"object",properties:{label:{type:"string"},storefront_visible:{type:"boolean"}}}}}}},delete:{summary:"Delete a custom field definition",tags:["Custom Fields"],security:[{api_key:[],bearer_auth:[]}],description:"Deletes the definition and cascades to all custom field values referencing it.\n\n**Required scope:** `write_settings` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}},{name:"id",in:"path",required:!0,schema:{type:"string"}}],responses:{"204":{description:"definition deleted"}}}},"/api/v3/admin/customer_groups":{get:{summary:"List customer groups",tags:["Customer Groups"],security:[{api_key:[],bearer_auth:[]}],description:"Returns the customer groups configured for the current store. Groups\nsegment customers for targeted promotions (see the `customer_group`\npromotion rule) and reporting. The list endpoint never embeds the\nmember list \u2014 fetch a single group with `?expand=customers` if you\nneed them inline, or query `/admin/customers?customer_group_id_in=\u2026`\nfor paginated membership.\n\n\n**Required scope:** `read_customers` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}},{name:"page",in:"query",required:!1,description:"Page number",schema:{type:"integer"}},{name:"limit",in:"query",required:!1,description:"Number of records per page",schema:{type:"integer"}},{name:"q[name_cont]",in:"query",required:!1,description:"Filter by name (contains)",schema:{type:"string"}},{name:"sort",in:"query",required:!1,description:"Sort by field. Prefix with `-` for descending (e.g., `-created_at`).",schema:{type:"string"}},{name:"fields",in:"query",required:!1,description:"Comma-separated list of fields to include. id is always included.",schema:{type:"string"}}],responses:{"200":{description:"customer groups found",content:{"application/json":{schema:{type:"object",properties:{data:{type:"array",items:{$ref:"#/components/schemas/CustomerGroup"}},meta:{$ref:"#/components/schemas/PaginationMeta"}},required:["data","meta"]}}}},"401":{description:"unauthorized",content:{"application/json":{schema:{$ref:"#/components/schemas/ErrorResponse"}}}}}},post:{summary:"Create a customer group",tags:["Customer Groups"],security:[{api_key:[],bearer_auth:[]}],description:"Creates a customer group in the current store. `customer_ids` is\noptional; when present, customers are attached at create time.\nPass prefixed IDs (e.g. `cus_\u2026`) \u2014 the server decodes them\nautomatically.\n\n\n**Required scope:** `write_customers` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}}],responses:{"201":{description:"customer group created",content:{"application/json":{schema:{$ref:"#/components/schemas/CustomerGroup"}}}},"422":{description:"validation error",content:{"application/json":{schema:{$ref:"#/components/schemas/ErrorResponse"}}}}},requestBody:{content:{"application/json":{schema:{type:"object",required:["name"],properties:{name:{type:"string"},description:{type:"string",nullable:!0},customer_ids:{type:"array",items:{type:"string"}}}}}}}}},"/api/v3/admin/customer_groups/{id}":{parameters:[{name:"id",in:"path",required:!0,description:"Customer group prefixed ID",schema:{type:"string"}}],get:{summary:"Get a customer group",tags:["Customer Groups"],security:[{api_key:[],bearer_auth:[]}],description:`Returns a single customer group. Pass \`?expand=customers\` to embed
|
|
164
|
+
the full member list inline (recommended only for single-record
|
|
165
|
+
reads \u2014 embed cost scales with membership size).
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
**Required scope:** \`read_customers\` (for API-key authentication).`,parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}},{name:"expand",in:"query",required:!1,description:"Comma-separated associations to embed. Supported: `customers`.",schema:{type:"string"}},{name:"fields",in:"query",required:!1,description:"Comma-separated list of fields to include. id is always included.",schema:{type:"string"}}],responses:{"200":{description:"customer group with embedded customers",content:{"application/json":{schema:{$ref:"#/components/schemas/CustomerGroup"}}}},"404":{description:"customer group not found",content:{"application/json":{schema:{$ref:"#/components/schemas/ErrorResponse"}}}}}},patch:{summary:"Update a customer group",tags:["Customer Groups"],security:[{api_key:[],bearer_auth:[]}],description:"Updates name, description, or membership. `customer_ids` is a\nfull-set replacement \u2014 the server reconciles the membership to\nmatch the array, adding new IDs and removing ones not present.\nSend `customer_ids: []` to clear all members.\n\n\n**Required scope:** `write_customers` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}}],responses:{"200":{description:"customer group updated",content:{"application/json":{schema:{$ref:"#/components/schemas/CustomerGroup"}}}},"422":{description:"validation error",content:{"application/json":{schema:{$ref:"#/components/schemas/ErrorResponse"}}}}},requestBody:{content:{"application/json":{schema:{type:"object",properties:{name:{type:"string"},description:{type:"string",nullable:!0},customer_ids:{type:"array",items:{type:"string"}}}}}}}},delete:{summary:"Delete a customer group",tags:["Customer Groups"],security:[{api_key:[],bearer_auth:[]}],description:"Soft-deletes the group. Member users are not deleted; their `customer_group_users` rows are dropped.\n\n**Required scope:** `write_customers` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}}],responses:{"204":{description:"customer group deleted"}}}},"/api/v3/admin/customers/{customer_id}/addresses":{get:{summary:"List customer addresses",tags:["Customers"],security:[{api_key:[],bearer_auth:[]}],description:"Returns the customer's saved addresses.\n\n**Required scope:** `read_customers` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}},{name:"customer_id",in:"path",required:!0,schema:{type:"string"}},{name:"expand",in:"query",required:!1,description:"Comma-separated associations to expand (e.g., country, state). Use dot notation for nested expand (max 4 levels).",schema:{type:"string"}},{name:"fields",in:"query",required:!1,description:"Comma-separated list of fields to include (e.g., first_name,last_name,address1,city). id is always included.",schema:{type:"string"}}],responses:{"200":{description:"addresses found",content:{"application/json":{}}}}},post:{summary:"Create a customer address",tags:["Customers"],security:[{api_key:[],bearer_auth:[]}],description:"Adds a new address to the customer's address book. Pass `is_default_billing: true` or `is_default_shipping: true` to set as the default \u2014 the previous default loses its flag in the same transaction.\n\n**Required scope:** `write_customers` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}},{name:"customer_id",in:"path",required:!0,schema:{type:"string"}}],responses:{"201":{description:"address created",content:{"application/json":{}}}},requestBody:{content:{"application/json":{schema:{type:"object",properties:{first_name:{type:"string"},last_name:{type:"string"},address1:{type:"string"},address2:{type:"string"},city:{type:"string"},postal_code:{type:"string"},country_iso:{type:"string",description:"ISO-2 country code (e.g. US)"},state_abbr:{type:"string",description:"State/province abbreviation (e.g. NY)"},phone:{type:"string"},company:{type:"string"},label:{type:"string"},is_default_billing:{type:"boolean"},is_default_shipping:{type:"boolean"}}}}}}}},"/api/v3/admin/customers/{customer_id}/addresses/{id}":{patch:{summary:"Update a customer address",tags:["Customers"],security:[{api_key:[],bearer_auth:[]}],description:"Updates a customer address.\n\n**Required scope:** `write_customers` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}},{name:"customer_id",in:"path",required:!0,schema:{type:"string"}},{name:"id",in:"path",required:!0,schema:{type:"string"}}],responses:{"200":{description:"address updated",content:{"application/json":{}}}},requestBody:{content:{"application/json":{schema:{type:"object",properties:{city:{type:"string"},is_default_billing:{type:"boolean"},is_default_shipping:{type:"boolean"}}}}}}},delete:{summary:"Delete a customer address",tags:["Customers"],security:[{api_key:[],bearer_auth:[]}],description:"Deletes the address. If it was a default, the customer loses that default (no auto-promotion).\n\n**Required scope:** `write_customers` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}},{name:"customer_id",in:"path",required:!0,schema:{type:"string"}},{name:"id",in:"path",required:!0,schema:{type:"string"}}],responses:{"204":{description:"address deleted"}}}},"/api/v3/admin/customers/{customer_id}/credit_cards":{get:{summary:"List customer credit cards",tags:["Customers"],security:[{api_key:[],bearer_auth:[]}],description:"Returns the customer's saved credit cards. Useful for off-session admin charges via `POST /admin/orders/:id/payments { source_id }`.\n\n**Required scope:** `read_customers` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}},{name:"customer_id",in:"path",required:!0,schema:{type:"string"}},{name:"expand",in:"query",required:!1,description:"Comma-separated associations to expand (e.g., payment_method). Use dot notation for nested expand (max 4 levels).",schema:{type:"string"}},{name:"fields",in:"query",required:!1,description:"Comma-separated list of fields to include (e.g., brand,last4,month,year). id is always included.",schema:{type:"string"}}],responses:{"200":{description:"credit cards found",content:{"application/json":{}}}}}},"/api/v3/admin/customers/{customer_id}/credit_cards/{id}":{get:{summary:"Show a customer credit card",tags:["Customers"],security:[{api_key:[],bearer_auth:[]}],description:"Returns a saved credit card by ID.\n\n**Required scope:** `read_customers` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}},{name:"customer_id",in:"path",required:!0,schema:{type:"string"}},{name:"id",in:"path",required:!0,schema:{type:"string"}},{name:"expand",in:"query",required:!1,description:"Comma-separated associations to expand (e.g., payment_method). Use dot notation for nested expand (max 4 levels).",schema:{type:"string"}},{name:"fields",in:"query",required:!1,description:"Comma-separated list of fields to include (e.g., brand,last4,month,year). id is always included.",schema:{type:"string"}}],responses:{"200":{description:"credit card found",content:{"application/json":{}}}}},delete:{summary:"Delete a customer credit card",tags:["Customers"],security:[{api_key:[],bearer_auth:[]}],description:"Deletes a saved credit card.\n\n**Required scope:** `write_customers` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}},{name:"customer_id",in:"path",required:!0,schema:{type:"string"}},{name:"id",in:"path",required:!0,schema:{type:"string"}}],responses:{"204":{description:"credit card deleted"}}}},"/api/v3/admin/customers/{customer_id}/store_credits":{get:{summary:"List customer store credits",tags:["Customers"],security:[{api_key:[],bearer_auth:[]}],description:"Returns store credits issued to the customer.\n\n**Required scope:** `read_store_credits` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}},{name:"customer_id",in:"path",required:!0,schema:{type:"string"}},{name:"expand",in:"query",required:!1,description:"Comma-separated associations to expand (e.g., category, store, created_by). Use dot notation for nested expand (max 4 levels).",schema:{type:"string"}},{name:"fields",in:"query",required:!1,description:"Comma-separated list of fields to include (e.g., amount,amount_used,memo,currency). id is always included.",schema:{type:"string"}}],responses:{"200":{description:"store credits found",content:{"application/json":{}}}}},post:{summary:"Issue a store credit to a customer",tags:["Customers"],security:[{api_key:[],bearer_auth:[]}],description:"`created_by` is set automatically from the authenticated admin.\n\n**Required scope:** `write_store_credits` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}},{name:"customer_id",in:"path",required:!0,schema:{type:"string"}}],responses:{"201":{description:"store credit created",content:{"application/json":{}}}},requestBody:{content:{"application/json":{schema:{type:"object",required:["amount","currency","category_id"],properties:{amount:{type:"number"},currency:{type:"string"},category_id:{type:"string",description:"StoreCreditCategory ID"},memo:{type:"string"}}}}}}}},"/api/v3/admin/customers/{customer_id}/store_credits/{id}":{patch:{summary:"Update a store credit",tags:["Customers"],security:[{api_key:[],bearer_auth:[]}],description:"Update memo / category / amount. The amount can only be changed if `amount_used == 0`.\n\n**Required scope:** `write_store_credits` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}},{name:"customer_id",in:"path",required:!0,schema:{type:"string"}},{name:"id",in:"path",required:!0,schema:{type:"string"}}],responses:{"200":{description:"store credit updated",content:{"application/json":{}}}},requestBody:{content:{"application/json":{schema:{type:"object",properties:{amount:{type:"number"},category_id:{type:"string"},memo:{type:"string"}}}}}}},delete:{summary:"Delete a store credit",tags:["Customers"],security:[{api_key:[],bearer_auth:[]}],description:"Deletes an unused store credit (amount_used == 0). Returns 422 otherwise.\n\n**Required scope:** `write_store_credits` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}},{name:"customer_id",in:"path",required:!0,schema:{type:"string"}},{name:"id",in:"path",required:!0,schema:{type:"string"}}],responses:{"204":{description:"store credit deleted"}}}},"/api/v3/admin/customers":{get:{summary:"List customers",tags:["Customers"],security:[{api_key:[],bearer_auth:[]}],description:"Returns a paginated list of customers. Supports Ransack search/filters.\n\n**Required scope:** `read_customers` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}},{name:"page",in:"query",required:!1,schema:{type:"integer"}},{name:"limit",in:"query",required:!1,schema:{type:"integer"}},{name:"q[search]",in:"query",required:!1,description:"Email + name full-text-ish search",schema:{type:"string"}},{name:"expand",in:"query",required:!1,description:"Comma-separated associations to expand (e.g., addresses, store_credits). Use dot notation for nested expand (max 4 levels).",schema:{type:"string"}},{name:"fields",in:"query",required:!1,description:"Comma-separated list of fields to include (e.g., email,first_name,last_name). id is always included.",schema:{type:"string"}}],responses:{"200":{description:"customers found",content:{"application/json":{}}}}},post:{summary:"Create a customer",tags:["Customers"],security:[{api_key:[],bearer_auth:[]}],description:"Creates a customer. No welcome email is sent automatically.\n\n**Required scope:** `write_customers` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}}],responses:{"201":{description:"customer created",content:{"application/json":{}}}},requestBody:{content:{"application/json":{schema:{type:"object",required:["email"],properties:{email:{type:"string"},first_name:{type:"string"},last_name:{type:"string"},phone:{type:"string"},accepts_email_marketing:{type:"boolean"},internal_note:{type:"string"},tags:{type:"array",items:{type:"string"}},metadata:{type:"object"}}}}}}}},"/api/v3/admin/customers/{id}":{get:{summary:"Show a customer",tags:["Customers"],security:[{api_key:[],bearer_auth:[]}],description:"Returns full customer details including computed order stats (orders_count, total_spent, last_order_completed_at).\n\n**Required scope:** `read_customers` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}},{name:"id",in:"path",required:!0,description:"Customer ID",schema:{type:"string"}},{name:"expand",in:"query",required:!1,description:"Comma-separated associations: addresses, orders, store_credits, default_billing_address, default_shipping_address",schema:{type:"string"}},{name:"fields",in:"query",required:!1,description:"Comma-separated list of fields to include (e.g., email,first_name,last_name). id is always included.",schema:{type:"string"}}],responses:{"200":{description:"customer found",content:{"application/json":{}}}}},patch:{summary:"Update a customer",tags:["Customers"],security:[{api_key:[],bearer_auth:[]}],description:"Updates customer attributes. `tags` replaces the full set.\n\n**Required scope:** `write_customers` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}},{name:"id",in:"path",required:!0,schema:{type:"string"}}],responses:{"200":{description:"customer updated",content:{"application/json":{}}}},requestBody:{content:{"application/json":{schema:{type:"object",properties:{email:{type:"string"},first_name:{type:"string"},last_name:{type:"string"},phone:{type:"string"},accepts_email_marketing:{type:"boolean"},internal_note:{type:"string"},tags:{type:"array",items:{type:"string"}},metadata:{type:"object"}}}}}}},delete:{summary:"Delete a customer",tags:["Customers"],security:[{api_key:[],bearer_auth:[]}],description:"Deletes a customer. Returns 422 if the customer has any orders.\n\n**Required scope:** `write_customers` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}},{name:"id",in:"path",required:!0,schema:{type:"string"}}],responses:{"204":{description:"customer deleted"}}}},"/api/v3/admin/customers/bulk_add_to_groups":{post:{summary:"Bulk-add customers to groups",tags:["Customers"],security:[{api_key:[],bearer_auth:[]}],description:"Attaches each customer in `ids` to every group in `customer_group_ids`.\nIdempotent \u2014 customers already in a group are skipped server-side.\nGroups from sibling stores are silently ignored. Returns counts of\ncustomers and groups that were processed (post store-scoping).\n\n\n**Required scope:** `write_customers` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}}],responses:{"200":{description:"customers added to groups",content:{"application/json":{schema:{type:"object",properties:{customer_count:{type:"integer"},customer_group_count:{type:"integer"}}}}}}},requestBody:{content:{"application/json":{schema:{type:"object",required:["ids","customer_group_ids"],properties:{ids:{type:"array",items:{type:"string"}},customer_group_ids:{type:"array",items:{type:"string"}}}}}}}}},"/api/v3/admin/customers/bulk_remove_from_groups":{post:{summary:"Bulk-remove customers from groups",tags:["Customers"],security:[{api_key:[],bearer_auth:[]}],description:"Detaches each customer in `ids` from every group in `customer_group_ids`.\nNo-op for non-members. Groups from sibling stores are silently ignored.\n\n\n**Required scope:** `write_customers` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}}],responses:{"200":{description:"customers removed from groups",content:{"application/json":{schema:{type:"object",properties:{customer_count:{type:"integer"},customer_group_count:{type:"integer"}}}}}}},requestBody:{content:{"application/json":{schema:{type:"object",required:["ids","customer_group_ids"],properties:{ids:{type:"array",items:{type:"string"}},customer_group_ids:{type:"array",items:{type:"string"}}}}}}}}},"/api/v3/admin/customers/bulk_add_tags":{post:{summary:"Bulk-add tags to customers",tags:["Customers"],security:[{api_key:[],bearer_auth:[]}],description:"Adds each tag name in `tags` to every customer in `ids`. Tags are\nupserted by name; re-adding an existing tag is a no-op.\n\n\n**Required scope:** `write_customers` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}}],responses:{"200":{description:"tags added",content:{"application/json":{schema:{type:"object",properties:{customer_count:{type:"integer"},tag_count:{type:"integer"}}}}}}},requestBody:{content:{"application/json":{schema:{type:"object",required:["ids","tags"],properties:{ids:{type:"array",items:{type:"string"}},tags:{type:"array",items:{type:"string"}}}}}}}}},"/api/v3/admin/customers/bulk_remove_tags":{post:{summary:"Bulk-remove tags from customers",tags:["Customers"],security:[{api_key:[],bearer_auth:[]}],description:"Removes each tag name in `tags` from every customer in `ids`. No-op\nfor customers that don't carry the tag.\n\n\n**Required scope:** `write_customers` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}}],responses:{"200":{description:"tags removed",content:{"application/json":{schema:{type:"object",properties:{customer_count:{type:"integer"},tag_count:{type:"integer"}}}}}}},requestBody:{content:{"application/json":{schema:{type:"object",required:["ids","tags"],properties:{ids:{type:"array",items:{type:"string"}},tags:{type:"array",items:{type:"string"}}}}}}}}},"/api/v3/admin/exports":{get:{summary:"List exports",tags:["Exports"],security:[{api_key:[],bearer_auth:[]}],description:"Returns CSV exports queued or completed for the current store. Polled by the admin SPA to detect when an export finishes (`done: true`).\n\n**Required scope:** the read scope of the exported resource \u2014 `read_products` for product exports, `read_customers` for customer exports, etc. (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}}],responses:{"200":{description:"exports found",content:{"application/json":{}}}}},post:{summary:"Create an export",tags:["Exports"],security:[{api_key:[],bearer_auth:[]}],description:'Queues a CSV export. The `type` selects the dataset; `search_params` is an\noptional Ransack query (same shape used by the `q[...]` params on list endpoints)\nthat filters which records are exported. Pass `record_selection: "all"` to\nclear the filter server-side and export everything in scope.\n\nGeneration is asynchronous. Poll `GET /admin/exports/{id}` until `done` is `true`,\nthen redirect the browser to `download_url` to fetch the file.\n\n\n**Required scope:** the read scope of the exported resource \u2014 `read_products` for product exports, `read_customers` for customer exports, etc. (for API-key authentication).',parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}}],responses:{"201":{description:"export queued",content:{"application/json":{}}}},requestBody:{content:{"application/json":{schema:{type:"object",required:["type"],properties:{type:{type:"string",enum:["Spree::Exports::Products","Spree::Exports::Orders","Spree::Exports::Customers","Spree::Exports::ProductTranslations","Spree::Exports::GiftCards","Spree::Exports::CouponCodes","Spree::Exports::NewsletterSubscribers"]},record_selection:{type:"string",enum:["filtered","all"],description:'Set to "all" to ignore search_params and export everything in scope.'},search_params:{type:"object",description:"Ransack query hash. Same predicates accepted by the list endpoint.",additionalProperties:!0}}}}}}}},"/api/v3/admin/exports/{id}":{get:{summary:"Show an export",tags:["Exports"],security:[{api_key:[],bearer_auth:[]}],description:"Returns export status. While `done` is `false`, the SPA continues polling.\n\n**Required scope:** the read scope of the exported resource \u2014 `read_products` for product exports, `read_customers` for customer exports, etc. (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}},{name:"id",in:"path",required:!0,schema:{type:"string"}}],responses:{"200":{description:"export found",content:{"application/json":{}}}}},delete:{summary:"Delete an export",tags:["Exports"],security:[{api_key:[],bearer_auth:[]}],description:"Removes the export and purges its attachment.\n\n**Required scope:** the read scope of the exported resource \u2014 `read_products` for product exports, `read_customers` for customer exports, etc. (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}},{name:"id",in:"path",required:!0,schema:{type:"string"}}],responses:{"204":{description:"export deleted"}}}},"/api/v3/admin/exports/{id}/download":{get:{summary:"Download an export",tags:["Exports"],security:[{api_key:[],bearer_auth:[]}],description:"Streams the exported CSV with `Content-Disposition: attachment`. Returns 422 with `code: export_not_ready` while `done` is still `false`. The endpoint is JWT/API-key protected, so SPA clients must fetch it (with `Authorization` header) and trigger the browser download via a Blob URL \u2014 a top-level navigation cannot carry the JWT.\n\n**Required scope:** the read scope of the exported resource \u2014 `read_products` for product exports, `read_customers` for customer exports, etc. (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}},{name:"id",in:"path",required:!0,schema:{type:"string"}}],responses:{"200":{description:"CSV file",content:{"application/json":{},"text/csv":{schema:{type:"string",format:"binary"}}}}}}},"/api/v3/admin/orders/{order_id}/fulfillments":{get:{summary:"List fulfillments",tags:["Fulfillments"],security:[{api_key:[],bearer_auth:[]}],description:"Returns all shipments for an order.\n\n**Required scope:** `read_fulfillments` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}},{name:"order_id",in:"path",required:!0,description:"Order ID",schema:{type:"string"}},{name:"expand",in:"query",required:!1,description:"Comma-separated associations to expand (e.g., inventory_units, stock_location, shipping_rates). Use dot notation for nested expand (max 4 levels).",schema:{type:"string"}},{name:"fields",in:"query",required:!1,description:"Comma-separated list of fields to include (e.g., number,status,tracking,cost). id is always included.",schema:{type:"string"}}],responses:{"200":{description:"fulfillments found",content:{"application/json":{}}}}}},"/api/v3/admin/orders/{order_id}/fulfillments/{id}":{get:{summary:"Show a shipment",tags:["Fulfillments"],security:[{api_key:[],bearer_auth:[]}],description:"Returns details of a specific shipment.\n\n**Required scope:** `read_fulfillments` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}},{name:"order_id",in:"path",required:!0,description:"Order ID",schema:{type:"string"}},{name:"id",in:"path",required:!0,description:"Fulfillment ID",schema:{type:"string"}},{name:"expand",in:"query",required:!1,description:"Comma-separated associations to expand (e.g., inventory_units, stock_location, shipping_rates). Use dot notation for nested expand (max 4 levels).",schema:{type:"string"}},{name:"fields",in:"query",required:!1,description:"Comma-separated list of fields to include (e.g., number,status,tracking,cost). id is always included.",schema:{type:"string"}}],responses:{"200":{description:"shipment found",content:{"application/json":{}}}}},patch:{summary:"Update a shipment",tags:["Fulfillments"],security:[{api_key:[],bearer_auth:[]}],description:"Updates a shipment (tracking, shipping rate).\n\n**Required scope:** `write_fulfillments` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}},{name:"order_id",in:"path",required:!0,description:"Order ID",schema:{type:"string"}},{name:"id",in:"path",required:!0,description:"Fulfillment ID",schema:{type:"string"}}],responses:{"200":{description:"shipment updated",content:{"application/json":{}}}},requestBody:{content:{"application/json":{schema:{type:"object",properties:{tracking:{type:"string"},selected_shipping_rate_id:{type:"string"}}}}}}}},"/api/v3/admin/orders/{order_id}/fulfillments/{id}/fulfill":{patch:{summary:"Fulfill a fulfillment",tags:["Fulfillments"],security:[{api_key:[],bearer_auth:[]}],description:"Marks a fulfillment as fulfilled.\n\n**Required scope:** `write_fulfillments` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}},{name:"order_id",in:"path",required:!0,description:"Order ID",schema:{type:"string"}},{name:"id",in:"path",required:!0,description:"Fulfillment ID",schema:{type:"string"}}],responses:{"200":{description:"fulfillment fulfilled",content:{"application/json":{}}}}}},"/api/v3/admin/orders/{order_id}/fulfillments/{id}/cancel":{patch:{summary:"Cancel a fulfillment",tags:["Fulfillments"],security:[{api_key:[],bearer_auth:[]}],description:"Cancels a fulfillment.\n\n**Required scope:** `write_fulfillments` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}},{name:"order_id",in:"path",required:!0,description:"Order ID",schema:{type:"string"}},{name:"id",in:"path",required:!0,description:"Fulfillment ID",schema:{type:"string"}}],responses:{"200":{description:"fulfillment canceled",content:{"application/json":{}}}}}},"/api/v3/admin/orders/{order_id}/fulfillments/{id}/resume":{patch:{summary:"Resume a fulfillment",tags:["Fulfillments"],security:[{api_key:[],bearer_auth:[]}],description:"Resumes a canceled fulfillment.\n\n**Required scope:** `write_fulfillments` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}},{name:"order_id",in:"path",required:!0,description:"Order ID",schema:{type:"string"}},{name:"id",in:"path",required:!0,description:"Fulfillment ID",schema:{type:"string"}}],responses:{"200":{description:"fulfillment resumed",content:{"application/json":{}}}}}},"/api/v3/admin/orders/{order_id}/fulfillments/{id}/split":{patch:{summary:"Split a fulfillment",tags:["Fulfillments"],security:[{api_key:[],bearer_auth:[]}],description:"Transfers items from this shipment to a new shipment at a different stock location.\n\n**Required scope:** `write_fulfillments` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}},{name:"order_id",in:"path",required:!0,description:"Order ID",schema:{type:"string"}},{name:"id",in:"path",required:!0,description:"Fulfillment ID",schema:{type:"string"}}],responses:{"200":{description:"fulfillment split",content:{"application/json":{}}}},requestBody:{content:{"application/json":{schema:{type:"object",required:["variant_id","quantity"],properties:{variant_id:{type:"string",description:"Variant ID"},quantity:{type:"integer"},stock_location_id:{type:"string",description:"Target stock location ID"}}}}}}}},"/api/v3/admin/gift_card_batches":{get:{summary:"List gift card batches",tags:["Gift Cards"],security:[{api_key:[],bearer_auth:[]}],description:"Returns the gift card batches issued by the current store. Each batch\ngroups the cards generated together for a campaign or bulk-issuance\n\u2014 the cards themselves live under `/admin/gift_cards` and reference\nthe batch via `gift_card_batch_id`.\n\n\n**Required scope:** `read_gift_cards` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}},{name:"page",in:"query",required:!1,description:"Page number",schema:{type:"integer"}},{name:"limit",in:"query",required:!1,description:"Records per page",schema:{type:"integer"}},{name:"q[prefix_cont]",in:"query",required:!1,description:"Filter by prefix (contains)",schema:{type:"string"}},{name:"sort",in:"query",required:!1,description:"Sort by field. Prefix with `-` for descending.",schema:{type:"string"}}],responses:{"200":{description:"gift card batches found",content:{"application/json":{schema:{type:"object",properties:{data:{type:"array",items:{$ref:"#/components/schemas/GiftCardBatch"}},meta:{$ref:"#/components/schemas/PaginationMeta"}},required:["data","meta"]}}}}}},post:{summary:"Create a gift card batch",tags:["Gift Cards"],security:[{api_key:[],bearer_auth:[]}],description:"Issues a batch of gift cards in a single call. The server generates\n`codes_count` cards inline for small batches (configurable via\n`Spree.config.gift_card_batch_web_limit`, default 500) or enqueues\na background job for larger ones. Each card's code is the batch\n`prefix` followed by random hex.\n\n\n**Required scope:** `write_gift_cards` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}}],responses:{"201":{description:"gift card batch created",content:{"application/json":{schema:{$ref:"#/components/schemas/GiftCardBatch"}}}},"422":{description:"validation error",content:{"application/json":{schema:{$ref:"#/components/schemas/ErrorResponse"}}}}},requestBody:{content:{"application/json":{schema:{type:"object",required:["prefix","amount","codes_count"],properties:{prefix:{type:"string",description:"Lowercased and prepended to every generated code."},amount:{type:"string",description:"Decimal amount per card, greater than zero."},currency:{type:"string",description:"ISO 4217 currency code. Defaults to the store currency."},codes_count:{type:"integer",description:"Number of cards to generate. Capped at `gift_card_batch_limit`."},expires_at:{type:"string",nullable:!0}}}}}}}},"/api/v3/admin/gift_card_batches/{id}":{parameters:[{name:"id",in:"path",required:!0,description:"Gift card batch prefixed ID",schema:{type:"string"}}],get:{summary:"Get a gift card batch",tags:["Gift Cards"],security:[{api_key:[],bearer_auth:[]}],description:"Returns a single batch.\n\n**Required scope:** `read_gift_cards` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}}],responses:{"200":{description:"gift card batch found",content:{"application/json":{schema:{$ref:"#/components/schemas/GiftCardBatch"}}}},"404":{description:"gift card batch not found",content:{"application/json":{schema:{$ref:"#/components/schemas/ErrorResponse"}}}}}}},"/api/v3/admin/gift_cards":{get:{summary:"List gift cards",tags:["Gift Cards"],security:[{api_key:[],bearer_auth:[]}],description:"Returns the gift cards issued by the current store. Filter by\n`q[code_cont]` for code search, `q[user_id_eq]` for cards issued\nto a specific customer, or `q[state_eq]` for status filtering.\n\n\n**Required scope:** `read_gift_cards` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}},{name:"page",in:"query",required:!1,description:"Page number",schema:{type:"integer"}},{name:"limit",in:"query",required:!1,description:"Number of records per page",schema:{type:"integer"}},{name:"q[code_cont]",in:"query",required:!1,description:"Filter by gift card code (contains)",schema:{type:"string"}},{name:"q[state_eq]",in:"query",required:!1,description:"Filter by status (active, redeemed, partially_redeemed, canceled)",schema:{type:"string"}},{name:"sort",in:"query",required:!1,description:"Sort by field. Prefix with `-` for descending (e.g., `-created_at`).",schema:{type:"string"}},{name:"fields",in:"query",required:!1,description:"Comma-separated list of fields to include. id is always included.",schema:{type:"string"}}],responses:{"200":{description:"gift cards found",content:{"application/json":{schema:{type:"object",properties:{data:{type:"array",items:{$ref:"#/components/schemas/GiftCard"}},meta:{$ref:"#/components/schemas/PaginationMeta"}},required:["data","meta"]}}}},"401":{description:"unauthorized",content:{"application/json":{schema:{$ref:"#/components/schemas/ErrorResponse"}}}}}},post:{summary:"Create a gift card",tags:["Gift Cards"],security:[{api_key:[],bearer_auth:[]}],description:"Issues a gift card scoped to the current store. The code is\nauto-generated when omitted. `currency` defaults to the store's\nconfigured currency. Pass `user_id` (prefixed ID) to attach the\ncard to a specific customer.\n\n\n**Required scope:** `write_gift_cards` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}}],responses:{"201":{description:"gift card created",content:{"application/json":{schema:{$ref:"#/components/schemas/GiftCard"}}}},"422":{description:"validation error",content:{"application/json":{schema:{$ref:"#/components/schemas/ErrorResponse"}}}}},requestBody:{content:{"application/json":{schema:{type:"object",required:["amount"],properties:{amount:{type:"string",description:"Decimal amount, greater than zero."},currency:{type:"string",description:"ISO 4217 currency code. Defaults to the store currency."},code:{type:"string",description:"Optional caller-supplied code. Auto-generated when omitted."},expires_at:{type:"string",description:"ISO 8601 date.",nullable:!0},user_id:{type:"string",description:"Optional customer prefixed ID.",nullable:!0}}}}}}}},"/api/v3/admin/gift_cards/{id}":{parameters:[{name:"id",in:"path",required:!0,description:"Gift card prefixed ID",schema:{type:"string"}}],get:{summary:"Get a gift card",tags:["Gift Cards"],security:[{api_key:[],bearer_auth:[]}],description:"Returns a single gift card.\n\n**Required scope:** `read_gift_cards` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}},{name:"fields",in:"query",required:!1,description:"Comma-separated list of fields to include. id is always included.",schema:{type:"string"}}],responses:{"200":{description:"gift card found",content:{"application/json":{schema:{$ref:"#/components/schemas/GiftCard"}}}},"404":{description:"gift card not found",content:{"application/json":{schema:{$ref:"#/components/schemas/ErrorResponse"}}}}}},patch:{summary:"Update a gift card",tags:["Gift Cards"],security:[{api_key:[],bearer_auth:[]}],description:`Updates an active gift card's editable attributes. Redeemed or
|
|
169
|
+
partially-redeemed cards cannot be edited.
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
**Required scope:** \`write_gift_cards\` (for API-key authentication).`,parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}}],responses:{"200":{description:"gift card updated",content:{"application/json":{schema:{$ref:"#/components/schemas/GiftCard"}}}}},requestBody:{content:{"application/json":{schema:{type:"object",properties:{amount:{type:"string"},expires_at:{type:"string",nullable:!0},user_id:{type:"string",nullable:!0}}}}}}},delete:{summary:"Delete a gift card",tags:["Gift Cards"],security:[{api_key:[],bearer_auth:[]}],description:`Deletes an unused gift card. Cards that have been redeemed or
|
|
173
|
+
partially redeemed cannot be deleted and return 422.
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
**Required scope:** \`write_gift_cards\` (for API-key authentication).`,parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}}],responses:{"204":{description:"gift card deleted"},"422":{description:"redeemed gift card cannot be deleted",content:{"application/json":{}}}}}},"/api/v3/admin/markets":{get:{summary:"List markets",tags:["Markets"],security:[{api_key:[],bearer_auth:[]}],description:"Returns the markets configured for the current store. Markets are\nstore-scoped and ordered by `position` (an `acts_as_list` column \u2014\nupdate the order via `PATCH /markets/{id}` with `position`).\n\n\n**Required scope:** `read_settings` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}},{name:"page",in:"query",required:!1,schema:{type:"integer"}},{name:"limit",in:"query",required:!1,schema:{type:"integer"}},{name:"q[name_cont]",in:"query",required:!1,schema:{type:"string"}},{name:"sort",in:"query",required:!1,schema:{type:"string"}},{name:"expand",in:"query",required:!1,description:"Comma-separated associations to embed. Supported: `countries`.",schema:{type:"string"}}],responses:{"200":{description:"markets found",content:{"application/json":{schema:{type:"object",properties:{data:{type:"array",items:{$ref:"#/components/schemas/Market"}},meta:{$ref:"#/components/schemas/PaginationMeta"}},required:["data","meta"]}}}}}},post:{summary:"Create a market",tags:["Markets"],security:[{api_key:[],bearer_auth:[]}],description:'Creates a new market for the current store.\n\n- `country_isos` accepts 2-letter ISO country codes (e.g. `["DE", "FR"]`);\n the market must contain at least one country. Unknown codes are\n silently dropped.\n- `supported_locales` accepts an array of locale codes; the\n `default_locale` is always implicitly included.\n- Setting `default: true` automatically demotes the previous default\n market in the store.\n\n\n**Required scope:** `write_settings` (for API-key authentication).',parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}}],responses:{"201":{description:"market created",content:{"application/json":{schema:{$ref:"#/components/schemas/Market"}}}},"422":{description:"validation error",content:{"application/json":{schema:{$ref:"#/components/schemas/ErrorResponse"}}}}},requestBody:{content:{"application/json":{schema:{type:"object",properties:{name:{type:"string"},currency:{type:"string",description:"ISO 4217 currency code."},default_locale:{type:"string",description:"IETF locale tag used as the market default."},supported_locales:{type:"array",items:{type:"string"},description:"Locale codes available in this market. The default is always implicitly included."},tax_inclusive:{type:"boolean",default:!1,description:"Display prices with tax included."},default:{type:"boolean",default:!1,description:"Setting to true demotes the previous default."},position:{type:"integer",description:"Sort order within the store; lower = first."},country_isos:{type:"array",items:{type:"string"},description:"2-letter ISO country codes assigned to this market. At least one is required."}},required:["name","currency","default_locale","country_isos"]}}}}}},"/api/v3/admin/markets/{id}":{parameters:[{name:"id",in:"path",required:!0,schema:{type:"string"}}],get:{summary:"Get a market",tags:["Markets"],security:[{api_key:[],bearer_auth:[]}],description:"**Required scope:** `read_settings` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}},{name:"expand",in:"query",required:!1,schema:{type:"string"}}],responses:{"200":{description:"market found",content:{"application/json":{schema:{$ref:"#/components/schemas/Market"}}}},"404":{description:"market not found",content:{"application/json":{schema:{$ref:"#/components/schemas/ErrorResponse"}}}}}},patch:{summary:"Update a market",tags:["Markets"],security:[{api_key:[],bearer_auth:[]}],description:"Updates an existing market. Pass `country_isos` to replace the\nmarket's country list (full-set update), `supported_locales` to\nreplace the supported locales, or `position` to reorder the market\nwithin the store.\n\nSetting `default: true` automatically demotes the previous default.\n\n\n**Required scope:** `write_settings` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}}],responses:{"200":{description:"market updated",content:{"application/json":{schema:{$ref:"#/components/schemas/Market"}}}},"422":{description:"validation error",content:{"application/json":{schema:{$ref:"#/components/schemas/ErrorResponse"}}}}},requestBody:{content:{"application/json":{schema:{type:"object",properties:{name:{type:"string"},currency:{type:"string"},default_locale:{type:"string"},supported_locales:{type:"array",items:{type:"string"}},tax_inclusive:{type:"boolean"},default:{type:"boolean"},position:{type:"integer"},country_isos:{type:"array",items:{type:"string"}}}}}}}},delete:{summary:"Delete a market",tags:["Markets"],security:[{api_key:[],bearer_auth:[]}],description:"Soft-deletes the market (sets `deleted_at`). The default market and\nthe last remaining market in a store cannot be deleted \u2014 both return\n422 with a `validation_error`.\n\n\n**Required scope:** `write_settings` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}}],responses:{"204":{description:"market deleted"},"422":{description:"cannot delete default or last market",content:{"application/json":{}}}}}},"/api/v3/admin/option_types":{get:{summary:"List option types",tags:["Option Types"],security:[{api_key:[],bearer_auth:[]}],description:"Returns a paginated list of option types.\n\n**Required scope:** `read_products` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}},{name:"page",in:"query",required:!1,description:"Page number",schema:{type:"integer"}},{name:"limit",in:"query",required:!1,description:"Number of records per page",schema:{type:"integer"}},{name:"q[name_cont]",in:"query",required:!1,description:"Filter by name (contains)",schema:{type:"string"}},{name:"expand",in:"query",required:!1,description:"Comma-separated associations to expand (e.g., option_values). Use dot notation for nested expand (max 4 levels).",schema:{type:"string"}},{name:"fields",in:"query",required:!1,description:"Comma-separated list of fields to include (e.g., name,label,position). id is always included.",schema:{type:"string"}}],responses:{"200":{description:"option types found",content:{"application/json":{schema:{type:"object",properties:{data:{type:"array",items:{$ref:"#/components/schemas/OptionType"}},meta:{$ref:"#/components/schemas/PaginationMeta"}},required:["data","meta"]}}}},"401":{description:"unauthorized",content:{"application/json":{schema:{$ref:"#/components/schemas/ErrorResponse"}}}}}},post:{summary:"Create an option type",tags:["Option Types"],security:[{api_key:[],bearer_auth:[]}],description:`Creates a new option type. Supports nested option values.
|
|
177
|
+
|
|
178
|
+
Option values can be provided inline and will be created or updated by name.
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
**Required scope:** \`write_products\` (for API-key authentication).`,parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}}],responses:{"201":{description:"option type created",content:{"application/json":{schema:{$ref:"#/components/schemas/OptionType"}}}},"422":{description:"validation error",content:{"application/json":{schema:{$ref:"#/components/schemas/ErrorResponse"}}}}},requestBody:{content:{"application/json":{schema:{type:"object",properties:{name:{type:"string"},label:{type:"string"},position:{type:"integer"},filterable:{type:"boolean"},option_values:{type:"array",items:{type:"object",properties:{name:{type:"string"},label:{type:"string"},position:{type:"integer"}}}}},required:["name","label"]}}}}}},"/api/v3/admin/option_types/{id}":{get:{summary:"Get an option type",tags:["Option Types"],security:[{api_key:[],bearer_auth:[]}],description:"Returns a single option type by ID, including its option values.\n\n**Required scope:** `read_products` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}},{name:"id",in:"path",required:!0,description:"Option type ID",schema:{type:"string"}},{name:"expand",in:"query",required:!1,description:"Comma-separated associations to expand (e.g., option_values). Use dot notation for nested expand (max 4 levels).",schema:{type:"string"}},{name:"fields",in:"query",required:!1,description:"Comma-separated list of fields to include (e.g., name,label,position). id is always included.",schema:{type:"string"}}],responses:{"200":{description:"option type found",content:{"application/json":{schema:{$ref:"#/components/schemas/OptionType"}}}},"404":{description:"option type not found",content:{"application/json":{schema:{$ref:"#/components/schemas/ErrorResponse"}}}}}},patch:{summary:"Update an option type",tags:["Option Types"],security:[{api_key:[],bearer_auth:[]}],description:"Updates an option type. Supports updating nested option values.\n\n**Required scope:** `write_products` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}},{name:"id",in:"path",required:!0,description:"Option type ID",schema:{type:"string"}}],responses:{"200":{description:"option type updated",content:{"application/json":{schema:{$ref:"#/components/schemas/OptionType"}}}},"422":{description:"validation error",content:{"application/json":{schema:{$ref:"#/components/schemas/ErrorResponse"}}}}},requestBody:{content:{"application/json":{schema:{type:"object",properties:{name:{type:"string"},label:{type:"string"},position:{type:"integer"},filterable:{type:"boolean"},option_values:{type:"array",items:{type:"object",properties:{id:{type:"string",description:"Existing option value ID to update"},name:{type:"string"},label:{type:"string"},position:{type:"integer"}}}}}}}}}},delete:{summary:"Delete an option type",tags:["Option Types"],security:[{api_key:[],bearer_auth:[]}],description:"Deletes an option type.\n\n**Required scope:** `write_products` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}},{name:"id",in:"path",required:!0,description:"Option type ID",schema:{type:"string"}}],responses:{"204":{description:"option type deleted"}}}},"/api/v3/admin/orders/{order_id}/gift_cards":{post:{summary:"Apply a gift card to an order",tags:["Orders"],security:[{api_key:[],bearer_auth:[]}],description:"Applies a gift card by code to the order. Returns the gift card.\n\n**Required scope:** `write_gift_cards` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}},{name:"order_id",in:"path",required:!0,description:"Order ID",schema:{type:"string"}}],responses:{"201":{description:"gift card applied",content:{"application/json":{}}}},requestBody:{content:{"application/json":{schema:{type:"object",required:["code"],properties:{code:{type:"string",description:"Gift card code"}}}}}}}},"/api/v3/admin/orders/{order_id}/gift_cards/{id}":{delete:{summary:"Remove a gift card from an order",tags:["Orders"],security:[{api_key:[],bearer_auth:[]}],description:"Removes the gift card from the order.\n\n**Required scope:** `write_gift_cards` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}},{name:"order_id",in:"path",required:!0,description:"Order ID",schema:{type:"string"}},{name:"id",in:"path",required:!0,description:"Gift card ID",schema:{type:"string"}}],responses:{"204":{description:"gift card removed"}}}},"/api/v3/admin/orders/{order_id}/items":{get:{summary:"List order items",tags:["Orders"],security:[{api_key:[],bearer_auth:[]}],description:"Returns all line items for an order.\n\n**Required scope:** `read_orders` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}},{name:"order_id",in:"path",required:!0,description:"Order ID",schema:{type:"string"}},{name:"expand",in:"query",required:!1,description:"Comma-separated associations to expand (e.g., variant, variant.product). Use dot notation for nested expand (max 4 levels).",schema:{type:"string"}},{name:"fields",in:"query",required:!1,description:"Comma-separated list of fields to include (e.g., quantity,price,total). id is always included.",schema:{type:"string"}}],responses:{"200":{description:"items found",content:{"application/json":{}}}}},post:{summary:"Add an item",tags:["Orders"],security:[{api_key:[],bearer_auth:[]}],description:"Adds a new line item to the order.\n\n**Required scope:** `write_orders` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}},{name:"order_id",in:"path",required:!0,description:"Order ID",schema:{type:"string"}}],responses:{"201":{description:"item added",content:{"application/json":{}}}},requestBody:{content:{"application/json":{schema:{type:"object",required:["variant_id"],properties:{variant_id:{type:"string",description:"Prefixed variant ID"},quantity:{type:"integer",default:1}}}}}}}},"/api/v3/admin/orders/{order_id}/items/{id}":{get:{summary:"Show an item",tags:["Orders"],security:[{api_key:[],bearer_auth:[]}],description:"Returns details of a specific line item.\n\n**Required scope:** `read_orders` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}},{name:"order_id",in:"path",required:!0,description:"Order ID",schema:{type:"string"}},{name:"id",in:"path",required:!0,description:"Item ID",schema:{type:"string"}},{name:"expand",in:"query",required:!1,description:"Comma-separated associations to expand (e.g., variant, variant.product). Use dot notation for nested expand (max 4 levels).",schema:{type:"string"}},{name:"fields",in:"query",required:!1,description:"Comma-separated list of fields to include (e.g., quantity,price,total). id is always included.",schema:{type:"string"}}],responses:{"200":{description:"item found",content:{"application/json":{}}}}},patch:{summary:"Update an item",tags:["Orders"],security:[{api_key:[],bearer_auth:[]}],description:"Updates an order item quantity or metadata.\n\n**Required scope:** `write_orders` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}},{name:"order_id",in:"path",required:!0,description:"Order ID",schema:{type:"string"}},{name:"id",in:"path",required:!0,description:"Item ID",schema:{type:"string"}}],responses:{"200":{description:"item updated",content:{"application/json":{}}}},requestBody:{content:{"application/json":{schema:{type:"object",properties:{quantity:{type:"integer"}}}}}}},delete:{summary:"Remove an item",tags:["Orders"],security:[{api_key:[],bearer_auth:[]}],description:"Removes an item from the order.\n\n**Required scope:** `write_orders` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}},{name:"order_id",in:"path",required:!0,description:"Order ID",schema:{type:"string"}},{name:"id",in:"path",required:!0,description:"Item ID",schema:{type:"string"}}],responses:{"204":{description:"line item removed"}}}},"/api/v3/admin/orders/{order_id}/store_credits":{post:{summary:"Apply customer's store credit to an order",tags:["Orders"],security:[{api_key:[],bearer_auth:[]}],description:"Applies the order customer's available store credit. When `amount` is omitted, applies up to the order outstanding balance.\n\n**Required scope:** `write_store_credits` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}},{name:"order_id",in:"path",required:!0,description:"Order ID",schema:{type:"string"}}],responses:{"201":{description:"store credit applied",content:{"application/json":{}}}},requestBody:{content:{"application/json":{schema:{type:"object",properties:{amount:{type:"number",description:"Optional explicit amount; defaults to order outstanding balance"}}}}}}},delete:{summary:"Remove store credit from an order",tags:["Orders"],security:[{api_key:[],bearer_auth:[]}],description:"Removes any applied store credit from the order.\n\n**Required scope:** `write_store_credits` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}},{name:"order_id",in:"path",required:!0,description:"Order ID",schema:{type:"string"}}],responses:{"204":{description:"store credit removed"}}}},"/api/v3/admin/orders":{get:{summary:"List orders",tags:["Orders"],security:[{api_key:[],bearer_auth:[]}],description:"Returns a paginated list of orders for the current store.\n\n**Required scope:** `read_orders` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}},{name:"page",in:"query",required:!1,description:"Page number",schema:{type:"integer"}},{name:"limit",in:"query",required:!1,description:"Number of records per page",schema:{type:"integer"}},{name:"sort",in:"query",required:!1,description:"Sort field (e.g., created_at, -created_at, completed_at)",schema:{type:"string"}},{name:"q[state_eq]",in:"query",required:!1,description:"Filter by state (cart, address, delivery, payment, confirm, complete, canceled)",schema:{type:"string"}},{name:"q[email_cont]",in:"query",required:!1,description:"Filter by email (contains)",schema:{type:"string"}},{name:"q[number_eq]",in:"query",required:!1,description:"Filter by order number",schema:{type:"string"}},{name:"q[completed_at_gt]",in:"query",required:!1,description:"Filter by completed after date",schema:{type:"string"}},{name:"expand",in:"query",required:!1,description:"Comma-separated associations to expand (e.g., items, fulfillments, payments, customer, discounts, billing_address, shipping_address). Use dot notation for nested expand (max 4 levels).",schema:{type:"string"}},{name:"fields",in:"query",required:!1,description:"Comma-separated list of fields to include (e.g., number,total,status,completed_at). id is always included.",schema:{type:"string"}}],responses:{"200":{description:"orders found",content:{"application/json":{}}},"401":{description:"unauthorized",content:{"application/json":{schema:{$ref:"#/components/schemas/ErrorResponse"}}}}}},post:{summary:"Create a draft order",tags:["Orders"],security:[{api_key:[],bearer_auth:[]}],description:`Creates a new draft order in one shot. Customer, items, addresses, currency,
|
|
182
|
+
market, channel, locale, notes, metadata, and a coupon code can all be
|
|
183
|
+
provided inline.
|
|
184
|
+
|
|
185
|
+
Setting \`preferred_stock_location_id\` pins the order's preferred fulfillment
|
|
186
|
+
location \u2014 Order Routing's built-in \`PreferredLocation\` rule consumes it
|
|
187
|
+
when picking which stock location ships each shipment.
|
|
188
|
+
|
|
189
|
+
Invalid coupon codes are non-fatal \u2014 the order is created and the failure
|
|
190
|
+
is reported on the service result (not in the API response body for now).
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
**Required scope:** \`write_orders\` (for API-key authentication).`,parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}}],responses:{"201":{description:"order created with preferred_stock_location_id",content:{"application/json":{}}}},requestBody:{content:{"application/json":{schema:{type:"object",properties:{email:{type:"string"},customer_id:{type:"string",description:"Customer ID. Alias: user_id (legacy)."},use_customer_default_address:{type:"boolean",description:"When true with customer_id, copies the customer's saved billing/shipping addresses onto the order."},currency:{type:"string"},market_id:{type:"string",description:"Market ID"},channel_id:{type:"string",description:"Channel ID. Defaults to the store primary channel when omitted."},preferred_stock_location_id:{type:"string",description:"Stock Location ID to prefer for fulfillment. Order Routing's built-in PreferredLocation rule reads this and ranks the location first; routing falls back to the next rule when the preferred location can't cover the cart."},locale:{type:"string"},customer_note:{type:"string",description:"Public, customer-visible note"},internal_note:{type:"string",description:"Staff-only note"},metadata:{type:"object",description:"Arbitrary key/value metadata"},shipping_address:{type:"object",properties:{first_name:{type:"string"},last_name:{type:"string"},address1:{type:"string"},city:{type:"string"},postal_code:{type:"string"},country_iso:{type:"string"},state_abbr:{type:"string"},phone:{type:"string"}}},shipping_address_id:{type:"string",description:"Existing customer address ID"},billing_address:{type:"object",properties:{first_name:{type:"string"},last_name:{type:"string"},address1:{type:"string"},city:{type:"string"},postal_code:{type:"string"},country_iso:{type:"string"},state_abbr:{type:"string"},phone:{type:"string"}}},billing_address_id:{type:"string",description:"Existing customer address ID"},items:{type:"array",items:{type:"object",required:["variant_id","quantity"],properties:{variant_id:{type:"string",description:"Variant ID"},quantity:{type:"integer"},metadata:{type:"object"}}}},coupon_code:{type:"string",description:"Optional. Applied non-fatally; invalid codes do not block creation."}}}}}}}},"/api/v3/admin/orders/{id}":{get:{summary:"Show an order",tags:["Orders"],security:[{api_key:[],bearer_auth:[]}],description:"Returns full order details including admin-only fields.\n\n**Required scope:** `read_orders` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}},{name:"id",in:"path",required:!0,description:"Order ID (e.g., or_xxx)",schema:{type:"string"}},{name:"expand",in:"query",required:!1,description:"Comma-separated associations to expand (e.g., items, fulfillments, payments, customer, discounts, billing_address, shipping_address). Use dot notation for nested expand (max 4 levels).",schema:{type:"string"}},{name:"fields",in:"query",required:!1,description:"Comma-separated list of fields to include (e.g., number,total,status,completed_at). id is always included.",schema:{type:"string"}}],responses:{"200":{description:"order found",content:{"application/json":{}}},"404":{description:"order not found",content:{"application/json":{schema:{$ref:"#/components/schemas/ErrorResponse"}}}}}},patch:{summary:"Update an order",tags:["Orders"],security:[{api_key:[],bearer_auth:[]}],description:"Updates an order. Supports updating email, addresses, special instructions, and line items.\n\n**Required scope:** `write_orders` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}},{name:"id",in:"path",required:!0,description:"Order ID",schema:{type:"string"}}],responses:{"200":{description:"order updated",content:{"application/json":{}}}},requestBody:{content:{"application/json":{schema:{type:"object",properties:{email:{type:"string"},special_instructions:{type:"string"},internal_note:{type:"string"},channel_id:{type:"string",description:"Channel ID"},preferred_stock_location_id:{type:"string",description:"Stock Location ID to prefer for fulfillment. Re-runs Order Routing's PreferredLocation rule on subsequent shipment rebuilds."},ship_address:{type:"object",properties:{firstname:{type:"string"},lastname:{type:"string"},address1:{type:"string"},city:{type:"string"},zipcode:{type:"string"},country_iso:{type:"string"},state_abbr:{type:"string"},phone:{type:"string"}}},bill_address:{type:"object",properties:{firstname:{type:"string"},lastname:{type:"string"},address1:{type:"string"},city:{type:"string"},zipcode:{type:"string"},country_iso:{type:"string"},state_abbr:{type:"string"},phone:{type:"string"}}},items:{type:"array",items:{type:"object",required:["variant_id"],properties:{variant_id:{type:"string",description:"Variant ID"},quantity:{type:"integer"},metadata:{type:"object"}}}}}}}}}},delete:{summary:"Delete a draft order",tags:["Orders"],security:[{api_key:[],bearer_auth:[]}],description:"Deletes a draft order. Completed orders cannot be deleted.\n\n**Required scope:** `write_orders` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}},{name:"id",in:"path",required:!0,description:"Order ID",schema:{type:"string"}}],responses:{"204":{description:"order deleted"}}}},"/api/v3/admin/orders/{id}/complete":{patch:{summary:"Complete an order",tags:["Orders"],security:[{api_key:[],bearer_auth:[]}],description:"Completes an order in the `confirm` state, marking it as placed.\n\nSet `notify_customer: true` to send the order confirmation email.\n\n\n**Required scope:** `write_orders` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}},{name:"id",in:"path",required:!0,description:"Order ID",schema:{type:"string"}}],responses:{"200":{description:"order completed",content:{"application/json":{}}},"422":{description:"order cannot be completed",content:{"application/json":{schema:{$ref:"#/components/schemas/ErrorResponse"}}}}},requestBody:{content:{"application/json":{schema:{type:"object",properties:{notify_customer:{type:"boolean",description:"Send the order confirmation email after completion."}}}}}}}},"/api/v3/admin/orders/{id}/cancel":{patch:{summary:"Cancel an order",tags:["Orders"],security:[{api_key:[],bearer_auth:[]}],description:"Cancels a completed order.\n\n**Required scope:** `write_orders` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}},{name:"id",in:"path",required:!0,description:"Order ID",schema:{type:"string"}}],responses:{"200":{description:"order canceled",content:{"application/json":{}}}}}},"/api/v3/admin/orders/{id}/approve":{patch:{summary:"Approve an order",tags:["Orders"],security:[{api_key:[],bearer_auth:[]}],description:"Approves an order (e.g., for fraud review).\n\n**Required scope:** `write_orders` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}},{name:"id",in:"path",required:!0,description:"Order ID",schema:{type:"string"}}],responses:{"200":{description:"order approved",content:{"application/json":{}}}}}},"/api/v3/admin/orders/{id}/resume":{patch:{summary:"Resume a canceled order",tags:["Orders"],security:[{api_key:[],bearer_auth:[]}],description:"Resumes a previously canceled order.\n\n**Required scope:** `write_orders` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}},{name:"id",in:"path",required:!0,description:"Order ID",schema:{type:"string"}}],responses:{"200":{description:"order resumed",content:{"application/json":{}}}}}},"/api/v3/admin/orders/{id}/resend_confirmation":{post:{summary:"Resend confirmation email",tags:["Orders"],security:[{api_key:[],bearer_auth:[]}],description:"Publishes the order.completed event to trigger confirmation email delivery.\n\n**Required scope:** `write_orders` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}},{name:"id",in:"path",required:!0,description:"Order ID",schema:{type:"string"}}],responses:{"200":{description:"confirmation resent",content:{"application/json":{}}}}}},"/api/v3/admin/payment_methods":{get:{summary:"List payment methods",tags:["Payment Methods"],security:[{api_key:[],bearer_auth:[]}],description:"Returns the store's configured payment methods. Use `source_required: true` to know which methods need a saved source.\n\n**Required scope:** `read_settings` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}},{name:"expand",in:"query",required:!1,description:"Comma-separated associations to expand. Use dot notation for nested expand (max 4 levels).",schema:{type:"string"}},{name:"fields",in:"query",required:!1,description:"Comma-separated list of fields to include (e.g., name,type,active). id is always included.",schema:{type:"string"}}],responses:{"200":{description:"payment methods found",content:{"application/json":{}}}}}},"/api/v3/admin/payment_methods/types":{get:{summary:"List available payment provider types",tags:["Payment Methods"],security:[{api_key:[],bearer_auth:[]}],description:'Returns the registered Spree::PaymentMethod subclasses that can be used to create new payment methods. Useful for populating a "Provider" dropdown in admin UIs.\n\n**Required scope:** `read_settings` (for API-key authentication).',parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}}],responses:{"200":{description:"provider types found",content:{"application/json":{}}}}}},"/api/v3/admin/payment_methods/{id}":{get:{summary:"Show a payment method",tags:["Payment Methods"],security:[{api_key:[],bearer_auth:[]}],description:"Returns a payment method by ID.\n\n**Required scope:** `read_settings` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}},{name:"id",in:"path",required:!0,schema:{type:"string"}},{name:"expand",in:"query",required:!1,description:"Comma-separated associations to expand. Use dot notation for nested expand (max 4 levels).",schema:{type:"string"}},{name:"fields",in:"query",required:!1,description:"Comma-separated list of fields to include (e.g., name,type,active). id is always included.",schema:{type:"string"}}],responses:{"200":{description:"payment method found",content:{"application/json":{}}}}}},"/api/v3/admin/orders/{order_id}/payments":{get:{summary:"List payments",tags:["Payments"],security:[{api_key:[],bearer_auth:[]}],description:"Returns all payments for an order.\n\n**Required scope:** `read_payments` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}},{name:"order_id",in:"path",required:!0,description:"Order ID",schema:{type:"string"}},{name:"expand",in:"query",required:!1,description:"Comma-separated associations to expand (e.g., payment_method, source). Use dot notation for nested expand (max 4 levels).",schema:{type:"string"}},{name:"fields",in:"query",required:!1,description:"Comma-separated list of fields to include (e.g., amount,status,number,response_code). id is always included.",schema:{type:"string"}}],responses:{"200":{description:"payments found",content:{"application/json":{}}}}},post:{summary:"Create a payment",tags:["Payments"],security:[{api_key:[],bearer_auth:[]}],description:"Creates a new payment for the order.\n\n**Required scope:** `write_payments` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}},{name:"order_id",in:"path",required:!0,description:"Order ID",schema:{type:"string"}}],responses:{"201":{description:"payment created",content:{"application/json":{}}}},requestBody:{content:{"application/json":{schema:{type:"object",required:["payment_method_id"],properties:{payment_method_id:{type:"string",description:"Payment method ID"},amount:{type:"number"},source_id:{type:"string",description:"Payment source ID"}}}}}}}},"/api/v3/admin/orders/{order_id}/payments/{id}":{get:{summary:"Show a payment",tags:["Payments"],security:[{api_key:[],bearer_auth:[]}],description:"Returns details of a specific payment.\n\n**Required scope:** `read_payments` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}},{name:"order_id",in:"path",required:!0,description:"Order ID",schema:{type:"string"}},{name:"id",in:"path",required:!0,description:"Payment ID",schema:{type:"string"}},{name:"expand",in:"query",required:!1,description:"Comma-separated associations to expand (e.g., payment_method, source). Use dot notation for nested expand (max 4 levels).",schema:{type:"string"}},{name:"fields",in:"query",required:!1,description:"Comma-separated list of fields to include (e.g., amount,status,number,response_code). id is always included.",schema:{type:"string"}}],responses:{"200":{description:"payment found",content:{"application/json":{}}}}}},"/api/v3/admin/orders/{order_id}/payments/{id}/capture":{patch:{summary:"Capture a payment",tags:["Payments"],security:[{api_key:[],bearer_auth:[]}],description:"Captures a pending payment.\n\n**Required scope:** `write_payments` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}},{name:"order_id",in:"path",required:!0,description:"Order ID",schema:{type:"string"}},{name:"id",in:"path",required:!0,description:"Payment ID",schema:{type:"string"}}],responses:{"200":{description:"payment captured",content:{"application/json":{}}},"422":{description:"capture failed",content:{"application/json":{schema:{$ref:"#/components/schemas/ErrorResponse"}}}}}}},"/api/v3/admin/orders/{order_id}/payments/{id}/void":{patch:{summary:"Void a payment",tags:["Payments"],security:[{api_key:[],bearer_auth:[]}],description:"Voids a payment.\n\n**Required scope:** `write_payments` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}},{name:"order_id",in:"path",required:!0,description:"Order ID",schema:{type:"string"}},{name:"id",in:"path",required:!0,description:"Payment ID",schema:{type:"string"}}],responses:{"200":{description:"payment voided",content:{"application/json":{}}}}}},"/api/v3/admin/price_lists":{get:{summary:"List price lists",tags:["Pricing"],security:[{api_key:[],bearer_auth:[]}],description:"Returns the price lists configured for the current store.\n\n**Required scope:** `read_products` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}},{name:"page",in:"query",required:!1,schema:{type:"integer"}},{name:"limit",in:"query",required:!1,schema:{type:"integer"}},{name:"q[name_cont]",in:"query",required:!1,schema:{type:"string"}},{name:"q[status_eq]",in:"query",required:!1,schema:{type:"string"}},{name:"sort",in:"query",required:!1,schema:{type:"string"}},{name:"expand",in:"query",required:!1,description:"Comma-separated associations to embed. Supported: `price_rules`.",schema:{type:"string"}}],responses:{"200":{description:"price lists found",content:{"application/json":{schema:{type:"object",properties:{data:{type:"array",items:{$ref:"#/components/schemas/PriceList"}},meta:{$ref:"#/components/schemas/PaginationMeta"}},required:["data","meta"]}}}}}},post:{summary:"Create a price list",tags:["Pricing"],security:[{api_key:[],bearer_auth:[]}],description:"Creates a new draft price list.\n\n**Required scope:** `write_products` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}}],responses:{"201":{description:"price list created (server-to-server \u2014 rules + prices, no product_ids)",content:{"application/json":{schema:{$ref:"#/components/schemas/PriceList"}}}},"422":{description:"validation error",content:{"application/json":{schema:{$ref:"#/components/schemas/ErrorResponse"}}}}},requestBody:{content:{"application/json":{schema:{type:"object",required:["name"],properties:{name:{type:"string"},description:{type:"string",nullable:!0},starts_at:{type:"string",nullable:!0},ends_at:{type:"string",nullable:!0},match_policy:{type:"string",enum:["all","any"]},position:{type:"integer"},product_ids:{type:"array",items:{type:"string"},description:"Prefixed product ids to seed the list with."},rules:{type:"array",description:"STI-typed price rules to attach on create. Existing rules on the same payload via PATCH reconcile by id.",items:{type:"object",required:["type"],properties:{type:{type:"string"},preferences:{type:"object",additionalProperties:!0}}}},prices:{type:"array",description:"Server-to-server alternative to `product_ids`: ship the exact per-variant prices the list should contain. Each row upserts on the unique key `(variant_id, currency, price_list_id)`. Mix-and-match with `product_ids` is supported but typically unnecessary \u2014 `prices` alone tells the server which variants belong to the list and what the override amount is.",items:{type:"object",required:["variant_id","currency"],properties:{variant_id:{type:"string"},currency:{type:"string"},amount:{type:"string",nullable:!0},compare_at_amount:{type:"string",nullable:!0}}}}}}}}}}},"/api/v3/admin/price_lists/{id}":{parameters:[{name:"id",in:"path",required:!0,schema:{type:"string"}}],get:{summary:"Get a price list",tags:["Pricing"],security:[{api_key:[],bearer_auth:[]}],description:"**Required scope:** `read_products` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}},{name:"expand",in:"query",required:!1,schema:{type:"string"}}],responses:{"200":{description:"price list found",content:{"application/json":{schema:{$ref:"#/components/schemas/PriceList"}}}},"404":{description:"price list not found",content:{"application/json":{schema:{$ref:"#/components/schemas/ErrorResponse"}}}}}},patch:{summary:"Update a price list",tags:["Pricing"],security:[{api_key:[],bearer_auth:[]}],description:`Updates a price list. The optional \`rules:\` array reconciles nested
|
|
194
|
+
STI-typed price rules in a single round-trip \u2014 existing rules update
|
|
195
|
+
by \`id\`, new rules build, missing rules destroy. Mirrors the
|
|
196
|
+
promotion editor's "save the whole thing on Save" pattern.
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
**Required scope:** \`write_products\` (for API-key authentication).`,parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}}],responses:{"200":{description:"price list updated with nested rules",content:{"application/json":{schema:{$ref:"#/components/schemas/PriceList"}}}}},requestBody:{content:{"application/json":{schema:{type:"object",properties:{name:{type:"string"},description:{type:"string",nullable:!0},starts_at:{type:"string",nullable:!0},ends_at:{type:"string",nullable:!0},match_policy:{type:"string",enum:["all","any"]},position:{type:"integer"},product_ids:{type:"array",items:{type:"string"},description:"Prefixed product ids \u2014 reconciles list membership (adds + removes)."},rules:{type:"array",items:{type:"object",required:["type"],properties:{id:{type:"string",nullable:!0},type:{type:"string"},preferences:{type:"object",additionalProperties:!0}}}},prices:{type:"array",description:"Individual price overrides (the spreadsheet payload). Each row updates by `id` if shipped, otherwise upserts on the unique key `(variant_id, currency, price_list_id)`.",items:{type:"object",oneOf:[{required:["id"]},{required:["variant_id","currency"]}],properties:{id:{type:"string"},variant_id:{type:"string"},currency:{type:"string"},amount:{type:"string",nullable:!0},compare_at_amount:{type:"string",nullable:!0}}}}}}}}}},delete:{summary:"Delete a price list",tags:["Pricing"],security:[{api_key:[],bearer_auth:[]}],description:"Soft-deletes the price list. Associated prices are removed asynchronously.\n\n**Required scope:** `write_products` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}}],responses:{"204":{description:"price list deleted"}}}},"/api/v3/admin/price_lists/{id}/activate":{parameters:[{name:"id",in:"path",required:!0,schema:{type:"string"}}],patch:{summary:"Activate a price list",tags:["Pricing"],security:[{api_key:[],bearer_auth:[]}],description:"Transitions a draft / inactive list to `active`. If `starts_at` is\nin the future the list is marked `scheduled` instead, matching the\nlegacy admin behaviour.\n\n\n**Required scope:** `write_products` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}}],responses:{"200":{description:"price list activated",content:{"application/json":{schema:{$ref:"#/components/schemas/PriceList"}}}}}}},"/api/v3/admin/price_lists/{id}/deactivate":{parameters:[{name:"id",in:"path",required:!0,schema:{type:"string"}}],patch:{summary:"Deactivate a price list",tags:["Pricing"],security:[{api_key:[],bearer_auth:[]}],description:"**Required scope:** `write_products` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}}],responses:{"200":{description:"price list deactivated",content:{"application/json":{schema:{$ref:"#/components/schemas/PriceList"}}}}}}},"/api/v3/admin/prices":{get:{summary:"List prices",tags:["Pricing"],security:[{api_key:[],bearer_auth:[]}],description:"Generic prices endpoint covering both base prices and price-list\noverrides. Filter with Ransack: `q[price_list_id_eq]=\u2026`,\n`q[currency_eq]=USD`, `q[price_list_id_null]=true` (base prices only).\n\nThe admin spreadsheet uses this with server-side pagination so it\nscales past the metadata-PATCH path on `/price_lists/:id`.\n\n\n**Required scope:** `read_products` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}},{name:"page",in:"query",required:!1,schema:{type:"integer"}},{name:"limit",in:"query",required:!1,schema:{type:"integer"}},{name:"q[price_list_id_eq]",in:"query",required:!1,schema:{type:"string"}},{name:"q[price_list_id_null]",in:"query",required:!1,schema:{type:"boolean"}},{name:"q[currency_eq]",in:"query",required:!1,schema:{type:"string"}},{name:"q[variant_id_eq]",in:"query",required:!1,schema:{type:"string"}},{name:"sort",in:"query",required:!1,description:"Comma-separated sort keys. Supports e.g. `variant_product_name,variant_id`.",schema:{type:"string"}},{name:"expand",in:"query",required:!1,description:"Comma-separated associations to embed. Supported: `variant`.",schema:{type:"string"}}],responses:{"200":{description:"prices found",content:{"application/json":{schema:{type:"object",properties:{data:{type:"array",items:{$ref:"#/components/schemas/Price"}},meta:{$ref:"#/components/schemas/PaginationMeta"}},required:["data","meta"]}}}}}},post:{summary:"Create a price",tags:["Pricing"],security:[{api_key:[],bearer_auth:[]}],description:"Creates a single price. Omit `price_list_id` to create a base price.\nFor more than a handful of rows, prefer `POST /admin/prices/bulk_upsert`.\n\n\n**Required scope:** `write_products` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}}],responses:{"201":{description:"price created",content:{"application/json":{schema:{$ref:"#/components/schemas/Price"}}}}},requestBody:{content:{"application/json":{schema:{type:"object",required:["variant_id","currency"],properties:{variant_id:{type:"string"},currency:{type:"string"},amount:{type:"string",nullable:!0},compare_at_amount:{type:"string",nullable:!0},price_list_id:{type:"string",nullable:!0}}}}}}}},"/api/v3/admin/prices/{id}":{parameters:[{name:"id",in:"path",required:!0,schema:{type:"string"}}],get:{summary:"Get a price",tags:["Pricing"],security:[{api_key:[],bearer_auth:[]}],description:"**Required scope:** `read_products` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}}],responses:{"200":{description:"price found",content:{"application/json":{schema:{$ref:"#/components/schemas/Price"}}}},"404":{description:"price not found",content:{"application/json":{schema:{$ref:"#/components/schemas/ErrorResponse"}}}}}},patch:{summary:"Update a price",tags:["Pricing"],security:[{api_key:[],bearer_auth:[]}],description:"**Required scope:** `write_products` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}}],responses:{"200":{description:"price updated",content:{"application/json":{schema:{$ref:"#/components/schemas/Price"}}}}},requestBody:{content:{"application/json":{schema:{type:"object",properties:{amount:{type:"string",nullable:!0},compare_at_amount:{type:"string",nullable:!0}}}}}}},delete:{summary:"Delete a price",tags:["Pricing"],security:[{api_key:[],bearer_auth:[]}],description:"Soft-deletes the price (acts_as_paranoid).\n\n**Required scope:** `write_products` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}}],responses:{"204":{description:"price deleted"}}}},"/api/v3/admin/prices/bulk_upsert":{post:{summary:"Bulk-upsert prices",tags:["Pricing"],security:[{api_key:[],bearer_auth:[]}],description:`Upserts a batch of prices in a single SQL round trip.
|
|
200
|
+
|
|
201
|
+
Each row either:
|
|
202
|
+
* targets an existing price by \`id\`, OR
|
|
203
|
+
* matches on the unique key \`(variant_id, currency, price_list_id)\` \u2014
|
|
204
|
+
updating the existing row if one exists, creating one otherwise.
|
|
205
|
+
|
|
206
|
+
Model callbacks (e.g. PriceHistory) are bypassed; this is a
|
|
207
|
+
bulk-write fast path for the admin spreadsheet. The response
|
|
208
|
+
carries \`price_count\` \u2014 the number of rows touched.
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
**Required scope:** \`write_products\` (for API-key authentication).`,parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}}],responses:{"200":{description:"prices upserted",content:{"application/json":{schema:{type:"object",properties:{price_count:{type:"integer"}}}}}},"422":{description:"missing prices key",content:{"application/json":{schema:{$ref:"#/components/schemas/ErrorResponse"}}}}},requestBody:{content:{"application/json":{schema:{type:"object",required:["prices"],properties:{prices:{type:"array",items:{type:"object",required:["variant_id","currency"],properties:{id:{type:"string",nullable:!0},variant_id:{type:"string"},currency:{type:"string"},price_list_id:{type:"string",nullable:!0},amount:{type:"string",nullable:!0},compare_at_amount:{type:"string",nullable:!0}}}}}}}}}}},"/api/v3/admin/prices/bulk_destroy":{delete:{summary:"Bulk-delete prices",tags:["Pricing"],security:[{api_key:[],bearer_auth:[]}],description:"Soft-deletes each price in `ids`. Returns the count actually destroyed.\n\n**Required scope:** `write_products` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}}],responses:{"200":{description:"prices deleted",content:{"application/json":{schema:{type:"object",properties:{price_count:{type:"integer"}}}}}}},requestBody:{content:{"application/json":{schema:{type:"object",required:["ids"],properties:{ids:{type:"array",items:{type:"string"}}}}}}}}},"/api/v3/admin/products/{product_id}/custom_fields":{get:{summary:"List product custom fields",tags:["Products"],security:[{api_key:[],bearer_auth:[]}],description:"Returns the product's custom field values.\n\n**Required scope:** `read_products` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}},{name:"product_id",in:"path",required:!0,schema:{type:"string"}},{name:"expand",in:"query",required:!1,description:"Comma-separated associations to expand (e.g., custom_field_definition). Use dot notation for nested expand (max 4 levels).",schema:{type:"string"}},{name:"fields",in:"query",required:!1,description:"Comma-separated list of fields to include (e.g., key,value,namespace). id is always included.",schema:{type:"string"}}],responses:{"200":{description:"custom fields found",content:{"application/json":{}}}}},post:{summary:"Create a product custom field",tags:["Products"],security:[{api_key:[],bearer_auth:[]}],description:"Sets a custom field value on the product. Requires an existing CustomFieldDefinition; pass its prefixed `cfdef_\u2026` id.\n\n**Required scope:** `write_products` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}},{name:"product_id",in:"path",required:!0,schema:{type:"string"}}],responses:{"201":{description:"custom field created",content:{"application/json":{}}},"422":{description:"duplicate definition for the same product",content:{"application/json":{}}}},requestBody:{content:{"application/json":{schema:{type:"object",required:["custom_field_definition_id","value"],properties:{custom_field_definition_id:{type:"string",description:"Prefixed `cfdef_\u2026` id"},value:{description:"Value matching the definition's `field_type`"}}}}}}}},"/api/v3/admin/products/{product_id}/custom_fields/{id}":{get:{summary:"Show a product custom field",tags:["Products"],security:[{api_key:[],bearer_auth:[]}],description:"**Required scope:** `read_products` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}},{name:"product_id",in:"path",required:!0,schema:{type:"string"}},{name:"id",in:"path",required:!0,schema:{type:"string"}},{name:"expand",in:"query",required:!1,description:"Comma-separated associations to expand (e.g., custom_field_definition). Use dot notation for nested expand (max 4 levels).",schema:{type:"string"}},{name:"fields",in:"query",required:!1,description:"Comma-separated list of fields to include (e.g., key,value,namespace). id is always included.",schema:{type:"string"}}],responses:{"200":{description:"custom field found",content:{"application/json":{}}}}},patch:{summary:"Update a product custom field",tags:["Products"],security:[{api_key:[],bearer_auth:[]}],description:"Updates the custom field's `value`. The linked definition cannot be changed \u2014 delete and recreate to switch.\n\n**Required scope:** `write_products` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}},{name:"product_id",in:"path",required:!0,schema:{type:"string"}},{name:"id",in:"path",required:!0,schema:{type:"string"}}],responses:{"200":{description:"custom field updated",content:{"application/json":{}}}},requestBody:{content:{"application/json":{schema:{type:"object",required:["value"],properties:{value:{description:"New value"}}}}}}},delete:{summary:"Delete a product custom field",tags:["Products"],security:[{api_key:[],bearer_auth:[]}],description:"**Required scope:** `write_products` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}},{name:"product_id",in:"path",required:!0,schema:{type:"string"}},{name:"id",in:"path",required:!0,schema:{type:"string"}}],responses:{"204":{description:"custom field deleted"}}}},"/api/v3/admin/products":{get:{summary:"List products",tags:["Products"],security:[{api_key:[],bearer_auth:[]}],description:"Returns a paginated list of products for the current store.\n\n**Required scope:** `read_products` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}},{name:"page",in:"query",required:!1,description:"Page number",schema:{type:"integer"}},{name:"limit",in:"query",required:!1,description:"Number of records per page",schema:{type:"integer"}},{name:"sort",in:"query",required:!1,description:"Sort field (e.g., name, -name, price, -price, best_selling)",schema:{type:"string"}},{name:"expand",in:"query",required:!1,description:"Comma-separated associations to expand (e.g., variants, media, option_types, categories). Use dot notation for nested expand (max 4 levels).",schema:{type:"string"}},{name:"fields",in:"query",required:!1,description:"Comma-separated list of fields to include (e.g., name,slug,price,status). id is always included.",schema:{type:"string"}},{name:"q[name_cont]",in:"query",required:!1,description:"Filter by name (contains)",schema:{type:"string"}},{name:"q[status_eq]",in:"query",required:!1,description:"Filter by status",schema:{type:"string"}}],responses:{"200":{description:"products found",content:{"application/json":{schema:{type:"object",properties:{data:{type:"array",items:{$ref:"#/components/schemas/Product"}},meta:{$ref:"#/components/schemas/PaginationMeta"}},required:["data","meta"]}}}},"401":{description:"unauthorized",content:{"application/json":{schema:{$ref:"#/components/schemas/ErrorResponse"}}}}}},post:{summary:"Create a product",tags:["Products"],security:[{api_key:[],bearer_auth:[]}],description:`Creates a new product. Supports nested variants with prices and option types.
|
|
212
|
+
|
|
213
|
+
Option types and values are auto-created if they don't exist.
|
|
214
|
+
Prices are upserted by currency. Stock items are upserted by stock location.
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
**Required scope:** \`write_products\` (for API-key authentication).`,parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}}],responses:{"201":{description:"product created",content:{"application/json":{schema:{$ref:"#/components/schemas/Product"}}}},"422":{description:"validation error",content:{"application/json":{schema:{$ref:"#/components/schemas/ErrorResponse"}}}}},requestBody:{content:{"application/json":{schema:{type:"object",properties:{name:{type:"string"},description:{type:"string"},slug:{type:"string"},status:{type:"string",enum:["draft","active","archived"]},tax_category_id:{type:"string",description:"Tax category ID"},category_ids:{type:"array",items:{type:"string"},description:"Array of category IDs"},tags:{type:"array",items:{type:"string"}},variants:{type:"array",description:"Array of variant payloads. Variants can declare multiple option pairs via `options:` and per-currency prices via `prices:`. Stock counts go in `stock_items:` (per stock location).",items:{type:"object",properties:{sku:{type:"string"},options:{type:"array",description:"One pair per option type the variant participates in (e.g. size + color). Option types and values are auto-created if missing.",items:{type:"object",required:["name","value"],properties:{name:{type:"string"},value:{type:"string"}}}},prices:{type:"array",description:"Per-currency prices. Upserted by currency.",items:{type:"object",required:["currency","amount"],properties:{currency:{type:"string"},amount:{type:"number"},compare_at_amount:{type:"number"}}}},stock_items:{type:"array",description:"Per-stock-location inventory. Upserted by stock_location_id.",items:{type:"object",required:["stock_location_id","count_on_hand"],properties:{stock_location_id:{type:"string",description:"Stock location ID (e.g. sloc_xxx)"},count_on_hand:{type:"integer"},backorderable:{type:"boolean"}}}}}}}},required:["name"]}}}}}},"/api/v3/admin/products/{id}":{get:{summary:"Get a product",tags:["Products"],security:[{api_key:[],bearer_auth:[]}],description:"Returns a single product by ID.\n\n**Required scope:** `read_products` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}},{name:"id",in:"path",required:!0,description:"Product ID (e.g., prod_xxx)",schema:{type:"string"}},{name:"expand",in:"query",required:!1,description:"Comma-separated associations to expand (e.g., variants, media, option_types, categories). Use dot notation for nested expand (max 4 levels).",schema:{type:"string"}},{name:"fields",in:"query",required:!1,description:"Comma-separated list of fields to include (e.g., name,slug,price,status). id is always included.",schema:{type:"string"}}],responses:{"200":{description:"product found",content:{"application/json":{schema:{$ref:"#/components/schemas/Product"}}}},"404":{description:"product not found",content:{"application/json":{schema:{$ref:"#/components/schemas/ErrorResponse"}}}}}},patch:{summary:"Update a product",tags:["Products"],security:[{api_key:[],bearer_auth:[]}],description:"Updates a product. Only provided fields are updated.\n\n**Required scope:** `write_products` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}},{name:"id",in:"path",required:!0,description:"Product ID",schema:{type:"string"}}],responses:{"200":{description:"product updated",content:{"application/json":{schema:{$ref:"#/components/schemas/Product"}}}},"422":{description:"validation error",content:{"application/json":{schema:{$ref:"#/components/schemas/ErrorResponse"}}}}},requestBody:{content:{"application/json":{schema:{type:"object",properties:{name:{type:"string"},description:{type:"string"},slug:{type:"string"},status:{type:"string",enum:["draft","active","archived"]},tax_category_id:{type:"string",description:"Tax category ID"},category_ids:{type:"array",items:{type:"string"},description:"Array of category IDs"},tags:{type:"array",items:{type:"string"}},variants:{type:"array",description:"Array of variant payloads. Variants can declare multiple option pairs via `options:` and per-currency prices via `prices:`. Stock counts go in `stock_items:` (per stock location).",items:{type:"object",properties:{sku:{type:"string"},options:{type:"array",description:"One pair per option type the variant participates in (e.g. size + color). Option types and values are auto-created if missing.",items:{type:"object",required:["name","value"],properties:{name:{type:"string"},value:{type:"string"}}}},prices:{type:"array",description:"Per-currency prices. Upserted by currency.",items:{type:"object",required:["currency","amount"],properties:{currency:{type:"string"},amount:{type:"number"},compare_at_amount:{type:"number"}}}},stock_items:{type:"array",description:"Per-stock-location inventory. Upserted by stock_location_id.",items:{type:"object",required:["stock_location_id","count_on_hand"],properties:{stock_location_id:{type:"string",description:"Stock location ID (e.g. sloc_xxx)"},count_on_hand:{type:"integer"},backorderable:{type:"boolean"}}}}}}}}}}}}},delete:{summary:"Delete a product",tags:["Products"],security:[{api_key:[],bearer_auth:[]}],description:"Soft-deletes a product.\n\n**Required scope:** `write_products` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}},{name:"id",in:"path",required:!0,description:"Product ID",schema:{type:"string"}}],responses:{"204":{description:"product deleted"}}}},"/api/v3/admin/products/bulk_status_update":{post:{summary:"Bulk-update product status",tags:["Products"],security:[{api_key:[],bearer_auth:[]}],description:"Sets `status` on each product in `ids`. Reindexes the affected products\nfor search. Cross-store IDs are silently dropped. Returns counts.\n\n\n**Required scope:** `write_products` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}}],responses:{"200":{description:"cross-store products silently dropped",content:{"application/json":{schema:{type:"object",properties:{product_count:{type:"integer"},status:{type:"string"}}}}}},"422":{description:"invalid status",content:{"application/json":{schema:{$ref:"#/components/schemas/ErrorResponse"}}}}},requestBody:{content:{"application/json":{schema:{type:"object",required:["ids","status"],properties:{ids:{type:"array",items:{type:"string"}},status:{type:"string",enum:["draft","active","archived"]}}}}}}}},"/api/v3/admin/products/bulk_add_to_categories":{post:{summary:"Bulk-add products to categories",tags:["Products"],security:[{api_key:[],bearer_auth:[]}],description:"Attaches each product in `ids` to every category (taxon) in `category_ids`.\nCategories from sibling stores are silently ignored.\n\n\n**Required scope:** `write_products` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}}],responses:{"200":{description:"products added to categories",content:{"application/json":{schema:{type:"object",properties:{product_count:{type:"integer"},category_count:{type:"integer"}}}}}}},requestBody:{content:{"application/json":{schema:{type:"object",required:["ids","category_ids"],properties:{ids:{type:"array",items:{type:"string"}},category_ids:{type:"array",items:{type:"string"}}}}}}}}},"/api/v3/admin/products/bulk_remove_from_categories":{post:{summary:"Bulk-remove products from categories",tags:["Products"],security:[{api_key:[],bearer_auth:[]}],description:"Detaches each product in `ids` from every category in `category_ids`.\n\n**Required scope:** `write_products` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}}],responses:{"200":{description:"products removed from categories",content:{"application/json":{}}}},requestBody:{content:{"application/json":{schema:{type:"object",required:["ids","category_ids"],properties:{ids:{type:"array",items:{type:"string"}},category_ids:{type:"array",items:{type:"string"}}}}}}}}},"/api/v3/admin/products/bulk_add_to_channels":{post:{summary:"Bulk-add products to channels",tags:["Products"],security:[{api_key:[],bearer_auth:[]}],description:"Publishes each product in `ids` on every channel in `channel_ids`. Idempotent \u2014\nre-publishing on an existing channel is a no-op. Channels from sibling stores\nare silently ignored.\n\n\n**Required scope:** `write_products` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}}],responses:{"200":{description:"products published on channels",content:{"application/json":{schema:{type:"object",properties:{product_count:{type:"integer"},channel_count:{type:"integer"}}}}}}},requestBody:{content:{"application/json":{schema:{type:"object",required:["ids","channel_ids"],properties:{ids:{type:"array",items:{type:"string"}},channel_ids:{type:"array",items:{type:"string"}}}}}}}}},"/api/v3/admin/products/bulk_remove_from_channels":{post:{summary:"Bulk-remove products from channels",tags:["Products"],security:[{api_key:[],bearer_auth:[]}],description:"Unpublishes each product in `ids` from every channel in `channel_ids`.\n\n**Required scope:** `write_products` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}}],responses:{"200":{description:"products unpublished from channels",content:{"application/json":{schema:{type:"object",properties:{product_count:{type:"integer"},channel_count:{type:"integer"},removed:{type:"integer"}}}}}}},requestBody:{content:{"application/json":{schema:{type:"object",required:["ids","channel_ids"],properties:{ids:{type:"array",items:{type:"string"}},channel_ids:{type:"array",items:{type:"string"}}}}}}}}},"/api/v3/admin/products/bulk_add_tags":{post:{summary:"Bulk-add tags to products",tags:["Products"],security:[{api_key:[],bearer_auth:[]}],description:"Adds each tag name in `tags` to every product in `ids`. Tags are upserted by name.\n\n**Required scope:** `write_products` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}}],responses:{"200":{description:"tags added",content:{"application/json":{schema:{type:"object",properties:{product_count:{type:"integer"},tag_count:{type:"integer"}}}}}}},requestBody:{content:{"application/json":{schema:{type:"object",required:["ids","tags"],properties:{ids:{type:"array",items:{type:"string"}},tags:{type:"array",items:{type:"string"}}}}}}}}},"/api/v3/admin/products/bulk_remove_tags":{post:{summary:"Bulk-remove tags from products",tags:["Products"],security:[{api_key:[],bearer_auth:[]}],description:"Removes each tag in `tags` from every product in `ids`.\n\n**Required scope:** `write_products` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}}],responses:{"200":{description:"tags removed",content:{"application/json":{}}}},requestBody:{content:{"application/json":{schema:{type:"object",required:["ids","tags"],properties:{ids:{type:"array",items:{type:"string"}},tags:{type:"array",items:{type:"string"}}}}}}}}},"/api/v3/admin/products/bulk_destroy":{delete:{summary:"Bulk-delete products",tags:["Products"],security:[{api_key:[],bearer_auth:[]}],description:"Soft-deletes each product in `ids`. Returns the count actually destroyed.\n\n**Required scope:** `write_products` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}}],responses:{"200":{description:"products deleted",content:{"application/json":{schema:{type:"object",properties:{product_count:{type:"integer"}}}}}}},requestBody:{content:{"application/json":{schema:{type:"object",required:["ids"],properties:{ids:{type:"array",items:{type:"string"}}}}}}}}},"/api/v3/admin/promotions/{promotion_id}/coupon_codes":{parameters:[{name:"promotion_id",in:"path",required:!0,schema:{type:"string"}}],get:{summary:"List coupon codes for a promotion",tags:["Promotions"],security:[{api_key:[],bearer_auth:[]}],description:"Returns the auto-generated coupon codes for a multi-code promotion. Single-code promotions store the code on the promotion itself; this endpoint returns an empty list for them.\n\n**Required scope:** `read_promotions` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}}],responses:{"200":{description:"coupon codes found",content:{"application/json":{}}}}}},"/api/v3/admin/promotions/{promotion_id}/promotion_actions":{parameters:[{name:"promotion_id",in:"path",required:!0,schema:{type:"string"}}],get:{summary:"List actions for a promotion",tags:["Promotions"],security:[{api_key:[],bearer_auth:[]}],description:"**Required scope:** `read_promotions` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}}],responses:{"200":{description:"actions found",content:{"application/json":{}}}}},post:{summary:"Create an action on a promotion",tags:["Promotions"],security:[{api_key:[],bearer_auth:[]}],description:"Adds a new action to a promotion. The `type` is the wire shorthand from `GET /promotion_actions/types` (e.g. `free_shipping`, `create_item_adjustments`). Fully-qualified Ruby class names are also accepted for backward compatibility.\n\n**Required scope:** `write_promotions` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}}],responses:{"201":{description:"action created",content:{"application/json":{}}},"422":{description:"unknown action type",content:{"application/json":{}}}},requestBody:{content:{"application/json":{schema:{type:"object",properties:{type:{type:"string"},preferences:{type:"object",additionalProperties:!0}},required:["type"]}}}}}},"/api/v3/admin/promotions/{promotion_id}/promotion_actions/{id}":{parameters:[{name:"promotion_id",in:"path",required:!0,schema:{type:"string"}},{name:"id",in:"path",required:!0,schema:{type:"string"}}],delete:{summary:"Delete an action from a promotion",tags:["Promotions"],security:[{api_key:[],bearer_auth:[]}],description:"**Required scope:** `write_promotions` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}}],responses:{"204":{description:"action deleted"}}}},"/api/v3/admin/promotions/{promotion_id}/promotion_rules":{parameters:[{name:"promotion_id",in:"path",required:!0,schema:{type:"string"}}],get:{summary:"List rules for a promotion",tags:["Promotions"],security:[{api_key:[],bearer_auth:[]}],description:"**Required scope:** `read_promotions` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}}],responses:{"200":{description:"rules found",content:{"application/json":{}}}}},post:{summary:"Create a rule on a promotion",tags:["Promotions"],security:[{api_key:[],bearer_auth:[]}],description:"Adds a new rule to a promotion. The `type` is the wire shorthand from `GET /promotion_rules/types` (e.g. `currency`, `item_total`, `product`). Fully-qualified Ruby class names are also accepted for backward compatibility.\n\n**Required scope:** `write_promotions` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}}],responses:{"201":{description:"rule created with preferences",content:{"application/json":{}}},"422":{description:"unknown rule type",content:{"application/json":{}}}},requestBody:{content:{"application/json":{schema:{type:"object",properties:{type:{type:"string"},preferences:{type:"object",additionalProperties:!0}},required:["type"]}}}}}},"/api/v3/admin/promotions/{promotion_id}/promotion_rules/{id}":{parameters:[{name:"promotion_id",in:"path",required:!0,schema:{type:"string"}},{name:"id",in:"path",required:!0,schema:{type:"string"}}],patch:{summary:"Update a rule's preferences",tags:["Promotions"],security:[{api_key:[],bearer_auth:[]}],description:"**Required scope:** `write_promotions` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}}],responses:{"200":{description:"rule updated",content:{"application/json":{}}}},requestBody:{content:{"application/json":{schema:{type:"object",properties:{preferences:{type:"object",additionalProperties:!0}}}}}}},delete:{summary:"Delete a rule from a promotion",tags:["Promotions"],security:[{api_key:[],bearer_auth:[]}],description:"**Required scope:** `write_promotions` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}}],responses:{"204":{description:"rule deleted"}}}},"/api/v3/admin/promotions":{get:{summary:"List promotions",tags:["Promotions"],security:[{api_key:[],bearer_auth:[]}],description:"Returns the store's promotions, including manual coupon and automatic promotions.\n\n**Required scope:** `read_promotions` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}}],responses:{"200":{description:"promotions found",content:{"application/json":{}}}}},post:{summary:"Create a promotion",tags:["Promotions"],security:[{api_key:[],bearer_auth:[]}],description:"Creates a new promotion. `code` is required for single-code coupon promotions;\npass `multi_codes: true` with `number_of_codes` to auto-generate a batch.\n\nRules and actions can be created in the same request by passing arrays of\n`{ type, preferences, ... }` rows. The server reconciles to the desired set:\nnew rows are built, existing rows (by `id`) are updated, omitted rows are removed.\n\n\n**Required scope:** `write_promotions` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}}],responses:{"201":{description:"promotion created with rules and actions",content:{"application/json":{}}},"422":{description:"invalid params",content:{"application/json":{}}}},requestBody:{content:{"application/json":{schema:{type:"object",properties:{name:{type:"string"},code:{type:"string",nullable:!0},description:{type:"string",nullable:!0},starts_at:{type:"string",format:"date-time",nullable:!0},expires_at:{type:"string",format:"date-time",nullable:!0},usage_limit:{type:"integer",nullable:!0},match_policy:{type:"string",enum:["all","any"]},kind:{type:"string",enum:["coupon_code","automatic"]},multi_codes:{type:"boolean"},number_of_codes:{type:"integer",nullable:!0},code_prefix:{type:"string",nullable:!0},promotion_category_id:{type:"string",nullable:!0},rules:{type:"array",items:{type:"object",properties:{type:{type:"string"},preferences:{type:"object",additionalProperties:!0},product_ids:{type:"array",items:{type:"string"}},category_ids:{type:"array",items:{type:"string"}},customer_ids:{type:"array",items:{type:"string"}}},required:["type"]}},actions:{type:"array",items:{type:"object",properties:{type:{type:"string"},preferences:{type:"object",additionalProperties:!0},calculator:{type:"object",properties:{type:{type:"string"},preferences:{type:"object",additionalProperties:!0}}}},required:["type"]}}},required:["name"]}}}}}},"/api/v3/admin/promotions/{id}":{get:{summary:"Show a promotion",tags:["Promotions"],security:[{api_key:[],bearer_auth:[]}],description:"**Required scope:** `read_promotions` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}},{name:"id",in:"path",required:!0,schema:{type:"string"}}],responses:{"200":{description:"promotion found",content:{"application/json":{}}}}},patch:{summary:"Update a promotion",tags:["Promotions"],security:[{api_key:[],bearer_auth:[]}],description:"Updates a promotion. The `rules` and `actions` arrays are treated as\na *desired set* \u2014 rows with `id` update in place, rows without `id` are\nbuilt fresh, and any existing row not present in the array is destroyed.\nPass `rules: []` or `actions: []` to clear them.\n\n\n**Required scope:** `write_promotions` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}},{name:"id",in:"path",required:!0,schema:{type:"string"}}],responses:{"200":{description:"rules and actions cleared with empty arrays",content:{"application/json":{}}}},requestBody:{content:{"application/json":{schema:{type:"object",properties:{name:{type:"string"},description:{type:"string",nullable:!0},code:{type:"string",nullable:!0},starts_at:{type:"string",format:"date-time",nullable:!0},expires_at:{type:"string",format:"date-time",nullable:!0},usage_limit:{type:"integer",nullable:!0},match_policy:{type:"string",enum:["all","any"]},kind:{type:"string",enum:["coupon_code","automatic"]},promotion_category_id:{type:"string",nullable:!0},rules:{type:"array",items:{type:"object",properties:{id:{type:"string",nullable:!0,description:"Pass to update an existing rule; omit to build a new one"},type:{type:"string"},preferences:{type:"object",additionalProperties:!0},product_ids:{type:"array",items:{type:"string"}},category_ids:{type:"array",items:{type:"string"}},customer_ids:{type:"array",items:{type:"string"}}},required:["type"]}},actions:{type:"array",items:{type:"object",properties:{id:{type:"string",nullable:!0},type:{type:"string"},preferences:{type:"object",additionalProperties:!0},calculator:{type:"object",properties:{type:{type:"string"},preferences:{type:"object",additionalProperties:!0}}}},required:["type"]}}}}}}}},delete:{summary:"Delete a promotion",tags:["Promotions"],security:[{api_key:[],bearer_auth:[]}],description:"**Required scope:** `write_promotions` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}},{name:"id",in:"path",required:!0,schema:{type:"string"}}],responses:{"204":{description:"promotion deleted"}}}},"/api/v3/admin/promotion_actions/types":{get:{summary:"List available promotion action types",tags:["Promotions"],security:[{api_key:[],bearer_auth:[]}],description:'Returns the registered Spree::PromotionAction subclasses with their preference schemas. Used by admin UIs to populate the "Add action" picker and render generic preference forms.\n\n**Required scope:** `read_promotions` (for API-key authentication).',parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}}],responses:{"200":{description:"action types found",content:{"application/json":{}}}}}},"/api/v3/admin/promotion_rules/types":{get:{summary:"List available promotion rule types",tags:["Promotions"],security:[{api_key:[],bearer_auth:[]}],description:"Returns the registered Spree::PromotionRule subclasses with their preference schemas.\n\n**Required scope:** `read_promotions` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}}],responses:{"200":{description:"rule types found",content:{"application/json":{}}}}}},"/api/v3/admin/orders/{order_id}/refunds":{get:{summary:"List refunds",tags:["Refunds"],security:[{api_key:[],bearer_auth:[]}],description:"Returns all refunds for an order.\n\n**Required scope:** `read_refunds` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}},{name:"order_id",in:"path",required:!0,description:"Order ID",schema:{type:"string"}},{name:"expand",in:"query",required:!1,description:"Comma-separated associations to expand (e.g., payment, refund_reason). Use dot notation for nested expand (max 4 levels).",schema:{type:"string"}},{name:"fields",in:"query",required:!1,description:"Comma-separated list of fields to include (e.g., amount,reason,transaction_id). id is always included.",schema:{type:"string"}}],responses:{"200":{description:"refunds found",content:{"application/json":{}}}}},post:{summary:"Create a refund",tags:["Refunds"],security:[{api_key:[],bearer_auth:[]}],description:"Creates a refund for a payment on the order. The refund is automatically processed via the payment gateway.\n\n**Required scope:** `write_refunds` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}},{name:"order_id",in:"path",required:!0,description:"Order ID",schema:{type:"string"}}],responses:{"201":{description:"refund created",content:{"application/json":{}}}},requestBody:{content:{"application/json":{schema:{type:"object",required:["payment_id","amount"],properties:{payment_id:{type:"string",description:"Payment ID"},amount:{type:"number"},refund_reason_id:{type:"string",description:"Refund reason ID"}}}}}}}},"/api/v3/admin/store_credit_categories":{get:{summary:"List store credit categories",tags:["Settings"],security:[{api_key:[],bearer_auth:[]}],description:`Returns the configured store credit categories. Categories classify
|
|
218
|
+
store credits (e.g., "Goodwill", "Gift Card", "Refund") and surface
|
|
219
|
+
in the admin UI as a dropdown when issuing or editing a store
|
|
220
|
+
credit. Category names matching \`Spree::Config[:non_expiring_credit_types]\`
|
|
221
|
+
are flagged via \`non_expiring: true\`.
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
**Required scope:** \`read_settings\` (for API-key authentication).`,parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}},{name:"page",in:"query",required:!1,description:"Page number",schema:{type:"integer"}},{name:"limit",in:"query",required:!1,description:"Number of records per page",schema:{type:"integer"}},{name:"q[name_cont]",in:"query",required:!1,description:"Filter by name (contains)",schema:{type:"string"}},{name:"sort",in:"query",required:!1,description:"Sort by field. Prefix with `-` for descending (e.g., `-created_at`).",schema:{type:"string"}},{name:"fields",in:"query",required:!1,description:"Comma-separated list of fields to include. id is always included.",schema:{type:"string"}}],responses:{"200":{description:"store credit categories found",content:{"application/json":{schema:{type:"object",properties:{data:{type:"array",items:{$ref:"#/components/schemas/StoreCreditCategory"}},meta:{$ref:"#/components/schemas/PaginationMeta"}},required:["data","meta"]}}}},"401":{description:"unauthorized",content:{"application/json":{schema:{$ref:"#/components/schemas/ErrorResponse"}}}}}}},"/api/v3/admin/store_credit_categories/{id}":{parameters:[{name:"id",in:"path",required:!0,description:"Store credit category ID",schema:{type:"string"}}],get:{summary:"Get a store credit category",tags:["Settings"],security:[{api_key:[],bearer_auth:[]}],description:"Returns a single store credit category by prefixed ID.\n\n**Required scope:** `read_settings` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}},{name:"fields",in:"query",required:!1,description:"Comma-separated list of fields to include. id is always included.",schema:{type:"string"}}],responses:{"200":{description:"store credit category found",content:{"application/json":{schema:{$ref:"#/components/schemas/StoreCreditCategory"}}}},"404":{description:"store credit category not found",content:{"application/json":{schema:{$ref:"#/components/schemas/ErrorResponse"}}}}}}},"/api/v3/admin/store":{get:{summary:"Get the current store",tags:["Settings"],security:[{api_key:[],bearer_auth:[]}],description:"Returns the current store configuration. The store is resolved from the request context (host or admin selection); there is no `id` parameter.\n\n**Required scope:** `read_settings` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}}],responses:{"200":{description:"current store",content:{"application/json":{schema:{$ref:"#/components/schemas/Store"}}}},"401":{description:"unauthorized",content:{"application/json":{schema:{$ref:"#/components/schemas/ErrorResponse"}}}}}},patch:{summary:"Update the current store",tags:["Settings"],security:[{api_key:[],bearer_auth:[]}],description:"Updates the current store configuration.\n\n**Required scope:** `write_settings` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}}],responses:{"200":{description:"store updated",content:{"application/json":{schema:{$ref:"#/components/schemas/Store"}}}},"422":{description:"validation error",content:{"application/json":{schema:{$ref:"#/components/schemas/ErrorResponse"}}}}},requestBody:{content:{"application/json":{schema:{type:"object",properties:{name:{type:"string"},preferred_admin_locale:{type:"string"},preferred_timezone:{type:"string"},preferred_weight_unit:{type:"string"},preferred_unit_system:{type:"string"}}}}}}}},"/api/v3/admin/tags":{get:{summary:"List tags",tags:["Settings"],security:[{api_key:[],bearer_auth:[]}],description:"Returns tag names for a given taggable type. Used for autocomplete in tag inputs on products, orders, and customers.",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}},{name:"taggable_type",in:"query",required:!0,description:"Taggable type (`Spree::Product`, `Spree::Order`, or `Spree::User`)",schema:{type:"string"}},{name:"q",in:"query",required:!1,description:"Optional case-insensitive substring filter",schema:{type:"string"}}],responses:{"200":{description:"tags found",content:{"application/json":{}}},"422":{description:"invalid taggable type",content:{"application/json":{}}}}}},"/api/v3/admin/admin_users":{get:{summary:"List staff",tags:["Staff"],security:[{api_key:[],bearer_auth:[]}],description:"Returns admin users with at least one role assignment on the current store.\n\n**Required scope:** `read_settings` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}}],responses:{"200":{description:"staff found",content:{"application/json":{}}}}}},"/api/v3/admin/admin_users/{id}":{get:{summary:"Show a staff member",tags:["Staff"],security:[{api_key:[],bearer_auth:[]}],description:"**Required scope:** `read_settings` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}},{name:"id",in:"path",required:!0,schema:{type:"string"}}],responses:{"200":{description:"staff member found",content:{"application/json":{}}}}},patch:{summary:"Update a staff member",tags:["Staff"],security:[{api_key:[],bearer_auth:[]}],description:"Updates name fields and reassigns roles for the current store. `role_ids` is a complete replacement \u2014 roles not in the array are removed for this store.\n\n**Required scope:** `write_settings` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}},{name:"id",in:"path",required:!0,schema:{type:"string"}}],responses:{"200":{description:"staff member updated",content:{"application/json":{}}}},requestBody:{content:{"application/json":{schema:{type:"object",properties:{first_name:{type:"string"},last_name:{type:"string"},role_ids:{type:"array",items:{type:"string"}}}}}}}},delete:{summary:"Remove a staff member from this store",tags:["Staff"],security:[{api_key:[],bearer_auth:[]}],description:"Removes the user's role assignments on the current store. The account is preserved \u2014 the user keeps access to any other stores.\n\n**Required scope:** `write_settings` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}},{name:"id",in:"path",required:!0,schema:{type:"string"}}],responses:{"204":{description:"staff removed from store"}}}},"/api/v3/admin/invitations":{get:{summary:"List invitations",tags:["Staff"],security:[{api_key:[],bearer_auth:[]}],description:"Returns invitations for the current store, including pending and accepted.\n\n**Required scope:** `read_settings` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}}],responses:{"200":{description:"invitations found",content:{"application/json":{}}}}},post:{summary:"Create an invitation",tags:["Staff"],security:[{api_key:[],bearer_auth:[]}],description:"Invites a teammate by email. The invitation is scoped to the current store and carries the chosen role; on accept, a `RoleUser` is created via the invitation's `after_accept` callback.\n\n**Required scope:** `write_settings` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}}],responses:{"201":{description:"invitation created",content:{"application/json":{}}}},requestBody:{content:{"application/json":{schema:{type:"object",required:["email","role_id"],properties:{email:{type:"string"},role_id:{type:"string"}}}}}}}},"/api/v3/admin/invitations/{id}":{delete:{summary:"Revoke an invitation",tags:["Staff"],security:[{api_key:[],bearer_auth:[]}],description:"**Required scope:** `write_settings` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}},{name:"id",in:"path",required:!0,schema:{type:"string"}}],responses:{"204":{description:"invitation revoked"}}}},"/api/v3/admin/invitations/{id}/resend":{patch:{summary:"Resend an invitation",tags:["Staff"],security:[{api_key:[],bearer_auth:[]}],description:"Issues a fresh token and dispatches the invitation email again.\n\n**Required scope:** `write_settings` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}},{name:"id",in:"path",required:!0,schema:{type:"string"}}],responses:{"200":{description:"invitation resent",content:{"application/json":{}}}}}},"/api/v3/admin/roles":{get:{summary:"List roles",tags:["Staff"],security:[{api_key:[],bearer_auth:[]}],description:"Returns the roles available for staff role pickers. Roles are global, not per-store.\n\n**Required scope:** `read_settings` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}}],responses:{"200":{description:"roles found",content:{"application/json":{}}}}}},"/api/v3/admin/stock_locations":{get:{summary:"List stock locations",tags:["Stock Locations"],security:[{api_key:[],bearer_auth:[]}],description:"Returns the configured stock locations. Stock locations are global\n(shared across stores). Filter with Ransack predicates such as\n`q[active_eq]`, `q[kind_eq]`, `q[pickup_enabled_eq]`, or\n`q[name_cont]`.\n\nPickup-related attributes (`kind`, `pickup_enabled`,\n`pickup_stock_policy`, `pickup_ready_in_minutes`,\n`pickup_instructions`) drive merchant pickup support at checkout \u2014\ncustomers can collect orders from any active location with\n`pickup_enabled: true`.\n\n\n**Required scope:** `read_stock` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}},{name:"page",in:"query",required:!1,description:"Page number",schema:{type:"integer"}},{name:"limit",in:"query",required:!1,description:"Number of records per page",schema:{type:"integer"}},{name:"q[name_cont]",in:"query",required:!1,description:"Filter by name (contains)",schema:{type:"string"}},{name:"q[active_eq]",in:"query",required:!1,description:"Filter by active status",schema:{type:"boolean"}},{name:"q[kind_eq]",in:"query",required:!1,description:"Filter by kind (built-in: 'warehouse', 'store', 'fulfillment_center')",schema:{type:"string"}},{name:"q[pickup_enabled_eq]",in:"query",required:!1,description:"Filter by pickup-enabled flag",schema:{type:"boolean"}},{name:"sort",in:"query",required:!1,description:"Sort by field. Prefix with `-` for descending (e.g., `-created_at`).",schema:{type:"string"}},{name:"fields",in:"query",required:!1,description:"Comma-separated list of fields to include. id is always included.",schema:{type:"string"}}],responses:{"200":{description:"stock locations found",content:{"application/json":{schema:{type:"object",properties:{data:{type:"array",items:{$ref:"#/components/schemas/StockLocation"}},meta:{$ref:"#/components/schemas/PaginationMeta"}},required:["data","meta"]}}}},"401":{description:"unauthorized",content:{"application/json":{schema:{$ref:"#/components/schemas/ErrorResponse"}}}}}},post:{summary:"Create a stock location",tags:["Stock Locations"],security:[{api_key:[],bearer_auth:[]}],description:`Creates a new stock location.
|
|
225
|
+
|
|
226
|
+
Setting \`default: true\` automatically demotes the previous default
|
|
227
|
+
location.
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
**Required scope:** \`write_stock\` (for API-key authentication).`,parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}}],responses:{"201":{description:"stock location created",content:{"application/json":{schema:{$ref:"#/components/schemas/StockLocation"}}}},"422":{description:"validation error",content:{"application/json":{schema:{$ref:"#/components/schemas/ErrorResponse"}}}}},requestBody:{content:{"application/json":{schema:{type:"object",properties:{name:{type:"string"},admin_name:{type:"string",nullable:!0,description:"Internal name shown only in the admin"},active:{type:"boolean"},default:{type:"boolean",description:"Setting to true demotes the previous default."},kind:{type:"string",enum:["warehouse","store","fulfillment_center"],description:"Categorizes the location."},propagate_all_variants:{type:"boolean"},backorderable_default:{type:"boolean"},address1:{type:"string",nullable:!0},address2:{type:"string",nullable:!0},city:{type:"string",nullable:!0},zipcode:{type:"string",nullable:!0},phone:{type:"string",nullable:!0},company:{type:"string",nullable:!0},country_iso:{type:"string",nullable:!0,description:'ISO-3166 alpha-2 country code (e.g. "US").'},state_abbr:{type:"string",nullable:!0,description:'State / province abbreviation (e.g. "NY"). Resolved against the selected country.'},state_name:{type:"string",nullable:!0,description:"Free-text state for countries without a states list."},pickup_enabled:{type:"boolean"},pickup_stock_policy:{type:"string",enum:["local","any"],description:"'local' = items at this location only; 'any' = transfer-eligible (ship-to-store)."},pickup_ready_in_minutes:{type:"number",nullable:!0,minimum:0},pickup_instructions:{type:"string",nullable:!0}},required:["name"]}}}}}},"/api/v3/admin/stock_locations/{id}":{parameters:[{name:"id",in:"path",required:!0,description:"Stock location ID",schema:{type:"string"}}],get:{summary:"Get a stock location",tags:["Stock Locations"],security:[{api_key:[],bearer_auth:[]}],description:"Returns a single stock location by prefixed ID.\n\n**Required scope:** `read_stock` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}},{name:"fields",in:"query",required:!1,description:"Comma-separated list of fields to include. id is always included.",schema:{type:"string"}}],responses:{"200":{description:"stock location found",content:{"application/json":{schema:{$ref:"#/components/schemas/StockLocation"}}}},"404":{description:"stock location not found",content:{"application/json":{schema:{$ref:"#/components/schemas/ErrorResponse"}}}}}},patch:{summary:"Update a stock location",tags:["Stock Locations"],security:[{api_key:[],bearer_auth:[]}],description:`Updates an existing stock location. Same address-field conventions as
|
|
231
|
+
the create endpoint.
|
|
232
|
+
|
|
233
|
+
Setting \`default: true\` automatically demotes the previous default.
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
**Required scope:** \`write_stock\` (for API-key authentication).`,parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}}],responses:{"200":{description:"stock location updated",content:{"application/json":{schema:{$ref:"#/components/schemas/StockLocation"}}}},"422":{description:"validation error",content:{"application/json":{schema:{$ref:"#/components/schemas/ErrorResponse"}}}}},requestBody:{content:{"application/json":{schema:{type:"object",properties:{name:{type:"string"},admin_name:{type:"string",nullable:!0},active:{type:"boolean"},default:{type:"boolean"},kind:{type:"string",enum:["warehouse","store","fulfillment_center"]},propagate_all_variants:{type:"boolean"},backorderable_default:{type:"boolean"},address1:{type:"string",nullable:!0},address2:{type:"string",nullable:!0},city:{type:"string",nullable:!0},zipcode:{type:"string",nullable:!0},phone:{type:"string",nullable:!0},company:{type:"string",nullable:!0},country_iso:{type:"string",nullable:!0},state_abbr:{type:"string",nullable:!0},state_name:{type:"string",nullable:!0},pickup_enabled:{type:"boolean"},pickup_stock_policy:{type:"string",enum:["local","any"]},pickup_ready_in_minutes:{type:"number",nullable:!0,minimum:0},pickup_instructions:{type:"string",nullable:!0}}}}}}},delete:{summary:"Delete a stock location",tags:["Stock Locations"],security:[{api_key:[],bearer_auth:[]}],description:"Soft-deletes the stock location (sets `deleted_at`). Existing\nfulfillments that referenced it keep the historical record via\n`Spree::StockLocation.with_deleted`.\n\n\n**Required scope:** `write_stock` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}}],responses:{"204":{description:"stock location deleted"}}}},"/api/v3/admin/products/{product_id}/variants":{get:{summary:"List product variants",tags:["Variants"],security:[{api_key:[],bearer_auth:[]}],description:"Returns a paginated list of variants for a product, including the master variant.\n\n**Required scope:** `read_products` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}},{name:"product_id",in:"path",required:!0,description:"Product ID",schema:{type:"string"}},{name:"page",in:"query",required:!1,description:"Page number",schema:{type:"integer"}},{name:"limit",in:"query",required:!1,description:"Number of records per page",schema:{type:"integer"}},{name:"expand",in:"query",required:!1,description:"Comma-separated associations to expand (e.g., images, prices, stock_items, option_values). Use dot notation for nested expand (max 4 levels).",schema:{type:"string"}},{name:"fields",in:"query",required:!1,description:"Comma-separated list of fields to include (e.g., sku,price,stock). id is always included.",schema:{type:"string"}}],responses:{"200":{description:"variants found",content:{"application/json":{}}}}},post:{summary:"Create a variant",tags:["Variants"],security:[{api_key:[],bearer_auth:[]}],description:`Creates a new variant for a product. Supports nested prices and stock items.
|
|
237
|
+
|
|
238
|
+
Option types and values are auto-created if they don't exist.
|
|
239
|
+
Prices are upserted by currency. Stock items are upserted by stock location.
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
**Required scope:** \`write_products\` (for API-key authentication).`,parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}},{name:"product_id",in:"path",required:!0,description:"Product ID",schema:{type:"string"}}],responses:{"201":{description:"variant created",content:{"application/json":{}}},"422":{description:"validation error",content:{"application/json":{schema:{$ref:"#/components/schemas/ErrorResponse"}}}}},requestBody:{content:{"application/json":{schema:{type:"object",properties:{sku:{type:"string"},price:{type:"number"},compare_at_price:{type:"number"},cost_price:{type:"number"},cost_currency:{type:"string"},weight:{type:"number"},height:{type:"number"},width:{type:"number"},depth:{type:"number"},weight_unit:{type:"string"},dimensions_unit:{type:"string"},track_inventory:{type:"boolean"},tax_category_id:{type:"string"},options:{type:"array",description:"One pair per option type the variant participates in (e.g. size + color). Option types and values are auto-created if missing.",items:{type:"object",required:["name","value"],properties:{name:{type:"string"},value:{type:"string"}}}},position:{type:"integer"},barcode:{type:"string"},prices:{type:"array",description:"Per-currency prices. Upserted by currency.",items:{type:"object",required:["currency","amount"],properties:{currency:{type:"string"},amount:{type:"number"},compare_at_amount:{type:"number"}}}},stock_items:{type:"array",description:"Per-stock-location inventory. Upserted by stock_location_id.",items:{type:"object",required:["stock_location_id","count_on_hand"],properties:{stock_location_id:{type:"string",description:"Stock location ID (e.g. sloc_xxx)"},count_on_hand:{type:"integer"},backorderable:{type:"boolean"}}}}}}}}}}},"/api/v3/admin/products/{product_id}/variants/{id}":{get:{summary:"Get a variant",tags:["Variants"],security:[{api_key:[],bearer_auth:[]}],description:"Returns a single variant by ID.\n\n**Required scope:** `read_products` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}},{name:"product_id",in:"path",required:!0,description:"Product ID",schema:{type:"string"}},{name:"id",in:"path",required:!0,description:"Variant ID",schema:{type:"string"}},{name:"expand",in:"query",required:!1,description:"Comma-separated associations to expand (e.g., images, prices, stock_items, option_values). Use dot notation for nested expand (max 4 levels).",schema:{type:"string"}},{name:"fields",in:"query",required:!1,description:"Comma-separated list of fields to include (e.g., sku,price,stock). id is always included.",schema:{type:"string"}}],responses:{"200":{description:"variant found",content:{"application/json":{}}},"404":{description:"variant not found",content:{"application/json":{schema:{$ref:"#/components/schemas/ErrorResponse"}}}}}},patch:{summary:"Update a variant",tags:["Variants"],security:[{api_key:[],bearer_auth:[]}],description:"Updates a variant. Only provided fields are updated.\n\n**Required scope:** `write_products` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}},{name:"product_id",in:"path",required:!0,description:"Product ID",schema:{type:"string"}},{name:"id",in:"path",required:!0,description:"Variant ID",schema:{type:"string"}}],responses:{"200":{description:"variant updated",content:{"application/json":{}}}},requestBody:{content:{"application/json":{schema:{type:"object",properties:{sku:{type:"string"},price:{type:"number"},compare_at_price:{type:"number"},cost_price:{type:"number"},cost_currency:{type:"string"},weight:{type:"number"},height:{type:"number"},width:{type:"number"},depth:{type:"number"},weight_unit:{type:"string"},dimensions_unit:{type:"string"},track_inventory:{type:"boolean"},tax_category_id:{type:"string"},options:{type:"array",items:{type:"object",properties:{name:{type:"string"},value:{type:"string"}}}},total_on_hand:{type:"integer"},position:{type:"integer"},barcode:{type:"string"},prices:{type:"array",items:{type:"object",properties:{currency:{type:"string"},amount:{type:"number"},compare_at_amount:{type:"number"}},required:["currency","amount"]}},stock_items:{type:"array",items:{type:"object",properties:{stock_location_id:{type:"string"},count_on_hand:{type:"integer"},backorderable:{type:"boolean"}}}}}}}}}},delete:{summary:"Delete a variant",tags:["Variants"],security:[{api_key:[],bearer_auth:[]}],description:"Soft-deletes a variant.\n\n**Required scope:** `write_products` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}},{name:"product_id",in:"path",required:!0,description:"Product ID",schema:{type:"string"}},{name:"id",in:"path",required:!0,description:"Variant ID",schema:{type:"string"}}],responses:{"204":{description:"variant deleted"}}}},"/api/v3/admin/webhook_endpoints/{webhook_endpoint_id}/deliveries":{parameters:[{name:"webhook_endpoint_id",in:"path",required:!0,description:"Parent webhook endpoint ID",schema:{type:"string"}}],get:{summary:"List webhook deliveries",tags:["Webhooks"],security:[{api_key:[],bearer_auth:[]}],description:`Returns delivery attempts for the given endpoint, most recent first.
|
|
243
|
+
Each row carries the original request payload, the response code
|
|
244
|
+
(when the receiver replied), the execution time, and any transport
|
|
245
|
+
error \u2014 everything needed to audit failures and decide whether to
|
|
246
|
+
redeliver.
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
**Required scope:** \`read_webhooks\` (for API-key authentication).`,parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}},{name:"page",in:"query",required:!1,description:"Page number",schema:{type:"integer"}},{name:"limit",in:"query",required:!1,description:"Number of records per page",schema:{type:"integer"}},{name:"q[event_name_eq]",in:"query",required:!1,description:"Filter by event name (exact)",schema:{type:"string"}},{name:"q[success_eq]",in:"query",required:!1,description:"Filter by success flag",schema:{type:"boolean"}},{name:"sort",in:"query",required:!1,description:"Sort by field. Prefix with `-` for descending (e.g., `-delivered_at`).",schema:{type:"string"}},{name:"fields",in:"query",required:!1,description:"Comma-separated list of fields to include. id is always included.",schema:{type:"string"}}],responses:{"200":{description:"deliveries found",content:{"application/json":{}}},"404":{description:"parent webhook endpoint not found",content:{"application/json":{schema:{$ref:"#/components/schemas/ErrorResponse"}}}}}}},"/api/v3/admin/webhook_endpoints/{webhook_endpoint_id}/deliveries/{id}":{parameters:[{name:"webhook_endpoint_id",in:"path",required:!0,description:"Parent webhook endpoint ID",schema:{type:"string"}},{name:"id",in:"path",required:!0,description:"Webhook delivery ID",schema:{type:"string"}}],get:{summary:"Get a webhook delivery",tags:["Webhooks"],security:[{api_key:[],bearer_auth:[]}],description:`Returns a single delivery attempt with the full request payload and
|
|
250
|
+
the response body the receiver returned. Use this for ad-hoc debug
|
|
251
|
+
of failed deliveries.
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
**Required scope:** \`read_webhooks\` (for API-key authentication).`,parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}},{name:"fields",in:"query",required:!1,description:"Comma-separated list of fields to include. id is always included.",schema:{type:"string"}}],responses:{"200":{description:"delivery found",content:{"application/json":{}}},"404":{description:"delivery not found",content:{"application/json":{schema:{$ref:"#/components/schemas/ErrorResponse"}}}}}}},"/api/v3/admin/webhook_endpoints/{webhook_endpoint_id}/deliveries/{id}/redeliver":{parameters:[{name:"webhook_endpoint_id",in:"path",required:!0,description:"Parent webhook endpoint ID",schema:{type:"string"}},{name:"id",in:"path",required:!0,description:"Webhook delivery ID to redeliver",schema:{type:"string"}}],post:{summary:"Redeliver a webhook delivery",tags:["Webhooks"],security:[{api_key:[],bearer_auth:[]}],description:`Creates a new delivery row with the same payload + event_name and
|
|
255
|
+
queues it. The original row is preserved for audit history.
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
**Required scope:** \`write_webhooks\` (for API-key authentication).`,parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}}],responses:{"201":{description:"redelivery queued",content:{"application/json":{}}}}}},"/api/v3/admin/webhook_endpoints":{get:{summary:"List webhook endpoints",tags:["Webhooks"],security:[{api_key:[],bearer_auth:[]}],description:"Returns outbound webhook subscriptions for the current store. Each\nendpoint receives a signed POST when any subscribed event fires.\n`secret_key` is `null` on list reads \u2014 the plaintext is delivered\nexactly once on create.\n\n\n**Required scope:** `read_webhooks` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}},{name:"page",in:"query",required:!1,description:"Page number",schema:{type:"integer"}},{name:"limit",in:"query",required:!1,description:"Number of records per page",schema:{type:"integer"}},{name:"q[name_cont]",in:"query",required:!1,description:"Filter by name (contains)",schema:{type:"string"}},{name:"q[url_cont]",in:"query",required:!1,description:"Filter by URL (contains)",schema:{type:"string"}},{name:"sort",in:"query",required:!1,description:"Sort by field. Prefix with `-` for descending (e.g., `-created_at`).",schema:{type:"string"}},{name:"fields",in:"query",required:!1,description:"Comma-separated list of fields to include. id is always included.",schema:{type:"string"}}],responses:{"200":{description:"webhook endpoints found",content:{"application/json":{}}},"401":{description:"unauthorized",content:{"application/json":{schema:{$ref:"#/components/schemas/ErrorResponse"}}}}}},post:{summary:"Create a webhook endpoint",tags:["Webhooks"],security:[{api_key:[],bearer_auth:[]}],description:"Creates a new outbound webhook subscription. The plaintext\n`secret_key` is returned **once** in this response \u2014 persist it\nimmediately to verify incoming webhook signatures. Subsequent reads\nreturn `null` for the secret. Pass an empty `subscriptions` array or\nomit it to receive every event.\n\n\n**Required scope:** `write_webhooks` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}}],responses:{"201":{description:"webhook endpoint created \u2014 secret_key returned once",content:{"application/json":{}}},"422":{description:"validation error",content:{"application/json":{schema:{$ref:"#/components/schemas/ErrorResponse"}}}}},requestBody:{content:{"application/json":{schema:{type:"object",required:["url"],properties:{name:{type:"string"},url:{type:"string"},active:{type:"boolean"},subscriptions:{type:"array",items:{type:"string"}}}}}}}}},"/api/v3/admin/webhook_endpoints/{id}":{parameters:[{name:"id",in:"path",required:!0,description:"Webhook endpoint ID",schema:{type:"string"}}],get:{summary:"Get a webhook endpoint",tags:["Webhooks"],security:[{api_key:[],bearer_auth:[]}],description:"Returns a single webhook endpoint by prefixed ID.\n\n**Required scope:** `read_webhooks` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}},{name:"fields",in:"query",required:!1,description:"Comma-separated list of fields to include. id is always included.",schema:{type:"string"}}],responses:{"200":{description:"webhook endpoint found",content:{"application/json":{}}},"404":{description:"webhook endpoint not found",content:{"application/json":{schema:{$ref:"#/components/schemas/ErrorResponse"}}}}}},patch:{summary:"Update a webhook endpoint",tags:["Webhooks"],security:[{api_key:[],bearer_auth:[]}],description:"Updates name, URL, active flag, or the event subscription list.\nToggling `active` here is equivalent to calling `disable`/`enable`\nwithout an audit reason.\n\n\n**Required scope:** `write_webhooks` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}}],responses:{"200":{description:"webhook endpoint updated",content:{"application/json":{}}},"422":{description:"validation error",content:{"application/json":{schema:{$ref:"#/components/schemas/ErrorResponse"}}}}},requestBody:{content:{"application/json":{schema:{type:"object",properties:{name:{type:"string"},url:{type:"string"},active:{type:"boolean"},subscriptions:{type:"array",items:{type:"string"}}}}}}}},delete:{summary:"Delete a webhook endpoint",tags:["Webhooks"],security:[{api_key:[],bearer_auth:[]}],description:"Soft-deletes the endpoint and stops future deliveries.\n\n**Required scope:** `write_webhooks` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}}],responses:{"204":{description:"webhook endpoint deleted"}}}},"/api/v3/admin/webhook_endpoints/{id}/send_test":{parameters:[{name:"id",in:"path",required:!0,description:"Webhook endpoint ID",schema:{type:"string"}}],post:{summary:"Send a test delivery",tags:["Webhooks"],security:[{api_key:[],bearer_auth:[]}],description:`Creates a \`webhook.test\` delivery record and queues it. Use this to
|
|
259
|
+
verify the endpoint is reachable and your signature verification
|
|
260
|
+
accepts Spree's payloads.
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
**Required scope:** \`write_webhooks\` (for API-key authentication).`,parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}}],responses:{"201":{description:"test delivery queued",content:{"application/json":{}}}}}},"/api/v3/admin/webhook_endpoints/{id}/enable":{parameters:[{name:"id",in:"path",required:!0,description:"Webhook endpoint ID",schema:{type:"string"}}],patch:{summary:"Re-enable a webhook endpoint",tags:["Webhooks"],security:[{api_key:[],bearer_auth:[]}],description:"Re-enables an endpoint that was manually or automatically disabled.\n\n**Required scope:** `write_webhooks` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}}],responses:{"200":{description:"webhook endpoint enabled",content:{"application/json":{}}}}}},"/api/v3/admin/webhook_endpoints/{id}/disable":{parameters:[{name:"id",in:"path",required:!0,description:"Webhook endpoint ID",schema:{type:"string"}}],patch:{summary:"Disable a webhook endpoint",tags:["Webhooks"],security:[{api_key:[],bearer_auth:[]}],description:`Manually pauses an endpoint. Unlike auto-disable (triggered after
|
|
264
|
+
repeated delivery failures), no notification email is sent.
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
**Required scope:** \`write_webhooks\` (for API-key authentication).`,parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}}],responses:{"200":{description:"webhook endpoint disabled",content:{"application/json":{}}}},requestBody:{content:{"application/json":{schema:{type:"object",properties:{reason:{type:"string"}}}}}}}}},components:{schemas:{PaginationMeta:{type:"object",properties:{page:{type:"integer"},limit:{type:"integer"},count:{type:"integer",description:"Total number of records"},pages:{type:"integer",description:"Total number of pages"},from:{type:"integer",description:"Index of first record on this page"},to:{type:"integer",description:"Index of last record on this page"},in:{type:"integer",description:"Number of records on this page"},previous:{type:"integer",nullable:!0,description:"Previous page number"},next:{type:"integer",nullable:!0,description:"Next page number"}},required:["page","limit","count","pages","from","to","in"]},ErrorResponse:{type:"object",properties:{error:{type:"object",properties:{code:{type:"string"},message:{type:"string"},details:{type:"object",description:"Field-specific validation errors",nullable:!0}},required:["code","message"]}},required:["error"]},AuthResponse:{type:"object",properties:{token:{type:"string",description:"JWT access token"},user:{$ref:"#/components/schemas/AdminUser"}},required:["token","user"]},PermissionRule:{type:"object",description:"A single permission rule (CanCanCan rule). Rules are applied in order, last-matching-wins.",properties:{allow:{type:"boolean",description:"true for `can`, false for `cannot`"},actions:{type:"array",items:{type:"string"},description:'Action names, e.g. ["read", "update"] or ["manage"]'},subjects:{type:"array",items:{type:"string"},description:'Subject class names, e.g. ["Spree::Product"] or ["all"]'},has_conditions:{type:"boolean",description:"True if the server-side rule has per-record conditions. The SPA shows the action optimistically and handles 403 from the API."}},required:["allow","actions","subjects","has_conditions"]},MeResponse:{type:"object",description:"Current admin user profile and serialized permissions",properties:{user:{$ref:"#/components/schemas/AdminUser"},permissions:{type:"array",items:{$ref:"#/components/schemas/PermissionRule"}}},required:["user","permissions"]},CheckoutRequirement:{type:"object",properties:{step:{type:"string",description:"Checkout step this requirement belongs to"},field:{type:"string",description:"Field that needs to be satisfied"},message:{type:"string",description:"Human-readable requirement message"}},required:["step","field","message"]},CartWarning:{type:"object",description:"A warning about a cart issue (e.g., item removed due to stock change)",properties:{code:{type:"string",description:"Machine-readable warning code"},message:{type:"string",description:"Human-readable warning message"},line_item_id:{type:"string",nullable:!0,description:"Prefixed line item ID (when applicable)"},variant_id:{type:"string",nullable:!0,description:"Prefixed variant ID (when applicable)"}},required:["code","message"]},FulfillmentManifestItem:{type:"object",description:"An item within a fulfillment \u2014 which line item and how many units are in this fulfillment",properties:{item_id:{type:"string",description:"Line item ID"},variant_id:{type:"string",description:"Variant ID"},quantity:{type:"integer",description:"Quantity in this fulfillment"}},required:["item_id","variant_id","quantity"]},AdminUserRoleAssignment:{type:"object",description:"A role assignment for the current store on a staff member",properties:{id:{type:"string",description:"Prefixed role ID"},name:{type:"string",description:"Role name"}},required:["id","name"]},PreferenceField:{type:"object",description:"A single configurable preference on a payment method, promotion rule/action, or calculator. The frontend uses `type` + `default` to render a sensible input.",properties:{key:{type:"string"},type:{type:"string",description:"string | text | password | integer | decimal | boolean | array | hash"},default:{description:"Default value (any JSON type), null when there is no default",nullable:!0}},required:["key","type"]},PromotionActionCalculator:{type:"object",description:"The action's nested calculator (when the action carries one \u2014 null for actions like `free_shipping`)",properties:{type:{type:"string",description:"Wire shorthand for the calculator subclass"},label:{type:"string"},preferences:{type:"object",additionalProperties:!0},preference_schema:{type:"array",items:{$ref:"#/components/schemas/PreferenceField"}}},required:["type","label","preferences","preference_schema"]},PromotionActionLineItem:{type:"object",description:"One row in a `create_line_items` action \u2014 the variant added to the order and how many",properties:{variant_id:{type:"string"},quantity:{type:"integer"}},required:["variant_id","quantity"]},Address:{type:"object",properties:{id:{type:"string"},first_name:{type:"string",nullable:!0},last_name:{type:"string",nullable:!0},full_name:{type:"string"},address1:{type:"string",nullable:!0},address2:{type:"string",nullable:!0},postal_code:{type:"string",nullable:!0},city:{type:"string",nullable:!0},phone:{type:"string",nullable:!0},company:{type:"string",nullable:!0},country_name:{type:"string"},country_iso:{type:"string"},state_text:{type:"string",nullable:!0},state_abbr:{type:"string",nullable:!0},quick_checkout:{type:"boolean"},is_default_billing:{type:"boolean"},is_default_shipping:{type:"boolean"},state_name:{type:"string",nullable:!0},label:{type:"string",nullable:!0},metadata:{type:"object"},created_at:{type:"string"},updated_at:{type:"string"},customer_id:{type:"string",nullable:!0}},required:["id","first_name","last_name","full_name","address1","address2","postal_code","city","phone","company","country_name","country_iso","state_text","state_abbr","quick_checkout","is_default_billing","is_default_shipping","state_name","label","metadata","created_at","updated_at","customer_id"],"x-typelizer":!0},Adjustment:{type:"object",properties:{id:{type:"string"},label:{type:"string"},display_amount:{type:"string"},included:{type:"boolean"},created_at:{type:"string"},updated_at:{type:"string"},amount:{type:"string"},order_id:{type:"string",nullable:!0}},required:["id","label","display_amount","included","created_at","updated_at","amount","order_id"],"x-typelizer":!0},AdminUser:{type:"object",properties:{id:{type:"string"},email:{type:"string"},first_name:{type:"string",nullable:!0},last_name:{type:"string",nullable:!0},full_name:{type:"string",nullable:!0},created_at:{type:"string"},updated_at:{type:"string"},roles:{type:"array",items:{$ref:"#/components/schemas/AdminUserRoleAssignment"}}},required:["id","email","first_name","last_name","full_name","created_at","updated_at","roles"],"x-typelizer":!0},AllowedOrigin:{type:"object",properties:{id:{type:"string"},origin:{type:"string"},created_at:{type:"string"},updated_at:{type:"string"}},required:["id","origin","created_at","updated_at"],"x-typelizer":!0},ApiKey:{type:"object",properties:{id:{type:"string"},name:{type:"string"},key_type:{type:"string"},token_prefix:{type:"string",nullable:!0},scopes:{type:"array",items:{type:"string"}},created_at:{type:"string"},updated_at:{type:"string"},revoked_at:{type:"string",nullable:!0},last_used_at:{type:"string",nullable:!0},plaintext_token:{type:"string",nullable:!0},created_by_email:{type:"string",nullable:!0}},required:["id","name","key_type","token_prefix","scopes","created_at","updated_at","revoked_at","last_used_at","plaintext_token","created_by_email"],"x-typelizer":!0},Category:{type:"object",properties:{id:{type:"string"},name:{type:"string"},permalink:{type:"string"},position:{type:"number"},depth:{type:"number"},meta_title:{type:"string",nullable:!0},meta_description:{type:"string",nullable:!0},meta_keywords:{type:"string",nullable:!0},children_count:{type:"number"},parent_id:{type:"string",nullable:!0},description:{type:"string"},description_html:{type:"string"},image_url:{type:"string",nullable:!0},square_image_url:{type:"string",nullable:!0},is_root:{type:"boolean"},is_child:{type:"boolean"},is_leaf:{type:"boolean"},parent:{$ref:"#/components/schemas/Category"},children:{type:"array",items:{$ref:"#/components/schemas/Category"}},ancestors:{type:"array",items:{$ref:"#/components/schemas/Category"}},custom_fields:{type:"array",items:{$ref:"#/components/schemas/CustomField"}},metadata:{type:"object"},pretty_name:{type:"string"},lft:{type:"number"},rgt:{type:"number"},created_at:{type:"string"},updated_at:{type:"string"}},required:["id","name","permalink","position","depth","meta_title","meta_description","meta_keywords","children_count","parent_id","description","description_html","image_url","square_image_url","is_root","is_child","is_leaf","metadata","pretty_name","lft","rgt","created_at","updated_at"],"x-typelizer":!0},Channel:{type:"object",properties:{id:{type:"string"},name:{type:"string"},code:{type:"string"},active:{type:"boolean"},default:{type:"boolean"},preferred_order_routing_strategy:{type:"string",nullable:!0},created_at:{type:"string"},updated_at:{type:"string"}},required:["id","name","code","active","default","preferred_order_routing_strategy","created_at","updated_at"],"x-typelizer":!0},Country:{type:"object",properties:{iso:{type:"string"},iso3:{type:"string"},name:{type:"string"},states_required:{type:"boolean"},zipcode_required:{type:"boolean"},states:{type:"array",items:{$ref:"#/components/schemas/State"}},market:{allOf:[{$ref:"#/components/schemas/Market"}],nullable:!0},created_at:{type:"object"},updated_at:{type:"object"}},required:["iso","iso3","name","states_required","zipcode_required","created_at","updated_at"],"x-typelizer":!0},CouponCode:{type:"object",properties:{id:{type:"string"},code:{type:"string"},state:{type:"string",nullable:!0},created_at:{type:"string"},updated_at:{type:"string"},promotion_id:{type:"string"},order_id:{type:"string",nullable:!0}},required:["id","code","state","created_at","updated_at","promotion_id","order_id"],"x-typelizer":!0},CreditCard:{type:"object",properties:{id:{type:"string"},brand:{type:"string"},last4:{type:"string"},month:{type:"number"},year:{type:"number"},name:{type:"string",nullable:!0},default:{type:"boolean"},gateway_payment_profile_id:{type:"string",nullable:!0},customer_id:{type:"string",nullable:!0},payment_method_id:{type:"string",nullable:!0},metadata:{type:"object"},created_at:{type:"string"},updated_at:{type:"string"}},required:["id","brand","last4","month","year","name","default","gateway_payment_profile_id","customer_id","payment_method_id","metadata","created_at","updated_at"],"x-typelizer":!0},CustomFieldDefinition:{type:"object",properties:{id:{type:"string"},namespace:{type:"string"},key:{type:"string"},label:{type:"string"},field_type:{type:"string",enum:["short_text","long_text","rich_text","number","boolean","json"]},resource_type:{type:"string"},storefront_visible:{type:"boolean"},created_at:{type:"string"},updated_at:{type:"string"}},required:["id","namespace","key","label","field_type","resource_type","storefront_visible","created_at","updated_at"],"x-typelizer":!0},CustomField:{type:"object",properties:{id:{type:"string"},label:{type:"string"},type:{type:"string",deprecated:!0},field_type:{type:"string",enum:["short_text","long_text","rich_text","number","boolean","json"]},key:{type:"string"},value:{type:"object"},created_at:{type:"string"},updated_at:{type:"string"},storefront_visible:{type:"boolean"},custom_field_definition_id:{type:"string"}},required:["id","label","type","field_type","key","value","created_at","updated_at","storefront_visible","custom_field_definition_id"],"x-typelizer":!0},CustomerGroup:{type:"object",properties:{id:{type:"string"},name:{type:"string"},description:{type:"string",nullable:!0},customers_count:{type:"number"},created_at:{type:"string"},updated_at:{type:"string"},customers:{type:"array",items:{$ref:"#/components/schemas/Customer"}}},required:["id","name","description","customers_count","created_at","updated_at"],"x-typelizer":!0},Customer:{type:"object",properties:{id:{type:"string"},email:{type:"string"},first_name:{type:"string",nullable:!0},last_name:{type:"string",nullable:!0},phone:{type:"string",nullable:!0},accepts_email_marketing:{type:"boolean"},full_name:{type:"string"},available_store_credit_total:{type:"string"},display_available_store_credit_total:{type:"string"},addresses:{type:"array",items:{$ref:"#/components/schemas/Address"}},default_billing_address:{allOf:[{$ref:"#/components/schemas/Address"}],nullable:!0},default_shipping_address:{allOf:[{$ref:"#/components/schemas/Address"}],nullable:!0},login:{type:"string",nullable:!0},metadata:{type:"object"},last_sign_in_at:{type:"string",nullable:!0},current_sign_in_at:{type:"string",nullable:!0},created_at:{type:"string"},updated_at:{type:"string"},sign_in_count:{type:"number"},failed_attempts:{type:"number"},last_sign_in_ip:{type:"string",nullable:!0},current_sign_in_ip:{type:"string",nullable:!0},tags:{type:"array",items:{type:"string"}},internal_note_html:{type:"string",nullable:!0},default_billing_address_id:{type:"string",nullable:!0},default_shipping_address_id:{type:"string",nullable:!0},orders_count:{type:"number"},total_spent:{type:"string"},display_total_spent:{type:"string"},last_order_completed_at:{type:"string",nullable:!0},orders:{type:"array",items:{$ref:"#/components/schemas/Order"}},store_credits:{type:"array",items:{$ref:"#/components/schemas/StoreCredit"}},customer_groups:{type:"array",items:{$ref:"#/components/schemas/CustomerGroup"}}},required:["id","email","first_name","last_name","phone","accepts_email_marketing","full_name","available_store_credit_total","display_available_store_credit_total","login","metadata","last_sign_in_at","current_sign_in_at","created_at","updated_at","sign_in_count","failed_attempts","last_sign_in_ip","current_sign_in_ip","tags","internal_note_html","default_billing_address_id","default_shipping_address_id","orders_count","total_spent","display_total_spent","last_order_completed_at"],"x-typelizer":!0},DeliveryMethod:{type:"object",properties:{id:{type:"string"},name:{type:"string"},code:{type:"string",nullable:!0},created_at:{type:"string"},updated_at:{type:"string"}},required:["id","name","code","created_at","updated_at"],"x-typelizer":!0},DeliveryRate:{type:"object",properties:{id:{type:"string"},delivery_method_id:{type:"string"},name:{type:"string"},selected:{type:"boolean"},cost:{type:"string"},total:{type:"string"},additional_tax_total:{type:"string"},included_tax_total:{type:"string"},tax_total:{type:"string"},display_cost:{type:"string"},display_total:{type:"string"},display_additional_tax_total:{type:"string"},display_included_tax_total:{type:"string"},display_tax_total:{type:"string"},delivery_method:{$ref:"#/components/schemas/DeliveryMethod"},created_at:{type:"string"},updated_at:{type:"string"}},required:["id","delivery_method_id","name","selected","cost","total","additional_tax_total","included_tax_total","tax_total","display_cost","display_total","display_additional_tax_total","display_included_tax_total","display_tax_total","created_at","updated_at"],"x-typelizer":!0},DigitalLink:{type:"object",properties:{id:{type:"string"},access_counter:{type:"number"},filename:{type:"string"},content_type:{type:"string"},download_url:{type:"string"},authorizable:{type:"boolean"},expired:{type:"boolean"},access_limit_exceeded:{type:"boolean"},created_at:{type:"string"},updated_at:{type:"string"}},required:["id","access_counter","filename","content_type","download_url","authorizable","expired","access_limit_exceeded","created_at","updated_at"],"x-typelizer":!0},Discount:{type:"object",properties:{id:{type:"string"},promotion_id:{type:"string"},name:{type:"string"},description:{type:"string",nullable:!0},code:{type:"string",nullable:!0},amount:{type:"string"},display_amount:{type:"string"},created_at:{type:"string"},updated_at:{type:"string"}},required:["id","promotion_id","name","description","code","amount","display_amount","created_at","updated_at"],"x-typelizer":!0},Export:{type:"object",properties:{id:{type:"string"},number:{type:"string"},type:{type:"string",nullable:!0},format:{type:"string",nullable:!0},created_at:{type:"string"},updated_at:{type:"string"},user_id:{type:"string",nullable:!0},done:{type:"boolean"},filename:{type:"string",nullable:!0},byte_size:{type:"number",nullable:!0},download_url:{type:"string",nullable:!0}},required:["id","number","type","format","created_at","updated_at","user_id","done","filename","byte_size","download_url"],"x-typelizer":!0},Fulfillment:{type:"object",properties:{id:{type:"string"},number:{type:"string"},tracking:{type:"string",nullable:!0},tracking_url:{type:"string",nullable:!0},cost:{type:"string"},display_cost:{type:"string"},total:{type:"string"},display_total:{type:"string"},discount_total:{type:"string"},display_discount_total:{type:"string"},additional_tax_total:{type:"string"},display_additional_tax_total:{type:"string"},included_tax_total:{type:"string"},display_included_tax_total:{type:"string"},tax_total:{type:"string"},display_tax_total:{type:"string"},status:{type:"string"},fulfillment_type:{type:"string"},fulfilled_at:{type:"string",nullable:!0},items:{type:"array",items:{$ref:"#/components/schemas/FulfillmentManifestItem"}},delivery_method:{$ref:"#/components/schemas/DeliveryMethod"},stock_location:{$ref:"#/components/schemas/StockLocation"},delivery_rates:{type:"array",items:{$ref:"#/components/schemas/DeliveryRate"}},metadata:{type:"object"},adjustment_total:{type:"string"},pre_tax_amount:{type:"string"},created_at:{type:"string"},updated_at:{type:"string"},order_id:{type:"string",nullable:!0},stock_location_id:{type:"string",nullable:!0},order:{$ref:"#/components/schemas/Order"},adjustments:{type:"array",items:{$ref:"#/components/schemas/Adjustment"}}},required:["id","number","tracking","tracking_url","cost","display_cost","total","display_total","discount_total","display_discount_total","additional_tax_total","display_additional_tax_total","included_tax_total","display_included_tax_total","tax_total","display_tax_total","status","fulfillment_type","fulfilled_at","items","metadata","adjustment_total","pre_tax_amount","created_at","updated_at","order_id","stock_location_id"],"x-typelizer":!0},GiftCardBatch:{type:"object",properties:{id:{type:"string"},codes_count:{type:"number"},currency:{type:"string",nullable:!0},prefix:{type:"string",nullable:!0},created_at:{type:"string"},updated_at:{type:"string"},amount:{type:"string",nullable:!0},expires_at:{type:"string",nullable:!0},created_by_id:{type:"string",nullable:!0}},required:["id","codes_count","currency","prefix","created_at","updated_at","amount","expires_at","created_by_id"],"x-typelizer":!0},GiftCard:{type:"object",properties:{id:{type:"string"},code:{type:"string"},status:{type:"string"},currency:{type:"string"},amount:{type:"string"},amount_used:{type:"string"},amount_authorized:{type:"string"},amount_remaining:{type:"string"},display_amount:{type:"string"},display_amount_used:{type:"string"},display_amount_remaining:{type:"string"},expires_at:{type:"string",nullable:!0},redeemed_at:{type:"string",nullable:!0},expired:{type:"boolean"},active:{type:"boolean"},created_at:{type:"string"},updated_at:{type:"string"},customer_id:{type:"string",nullable:!0},created_by_id:{type:"string",nullable:!0},customer:{$ref:"#/components/schemas/Customer"},created_by:{$ref:"#/components/schemas/AdminUser"},gift_card_batch:{$ref:"#/components/schemas/GiftCardBatch"},orders:{type:"array",items:{$ref:"#/components/schemas/Order"}}},required:["id","code","status","currency","amount","amount_used","amount_authorized","amount_remaining","display_amount","display_amount_used","display_amount_remaining","expires_at","redeemed_at","expired","active","created_at","updated_at","customer_id","created_by_id"],"x-typelizer":!0},Invitation:{type:"object",properties:{id:{type:"string"},email:{type:"string"},status:{type:"string"},created_at:{type:"string"},updated_at:{type:"string"},expires_at:{type:"string"},role_id:{type:"string"},role_name:{type:"string"},inviter_email:{type:"string"},acceptance_url:{type:"string"},invitee_exists:{type:"boolean"},store:{type:"object"}},required:["id","email","status","created_at","updated_at","expires_at","role_id","role_name","inviter_email","acceptance_url","invitee_exists","store"],"x-typelizer":!0},LineItem:{type:"object",properties:{id:{type:"string"},variant_id:{type:"string"},quantity:{type:"number"},currency:{type:"string"},name:{type:"string"},slug:{type:"string"},options_text:{type:"string"},price:{type:"string"},display_price:{type:"string"},total:{type:"string"},display_total:{type:"string"},adjustment_total:{type:"string"},display_adjustment_total:{type:"string"},additional_tax_total:{type:"string"},display_additional_tax_total:{type:"string"},included_tax_total:{type:"string"},display_included_tax_total:{type:"string"},discount_total:{type:"string"},display_discount_total:{type:"string"},pre_tax_amount:{type:"string"},display_pre_tax_amount:{type:"string"},discounted_amount:{type:"string"},display_discounted_amount:{type:"string"},display_compare_at_amount:{type:"string",nullable:!0},compare_at_amount:{type:"string",nullable:!0},thumbnail_url:{type:"string",nullable:!0},option_values:{type:"array",items:{$ref:"#/components/schemas/OptionValue"}},digital_links:{type:"array",items:{$ref:"#/components/schemas/DigitalLink"}},metadata:{type:"object"},created_at:{type:"string"},updated_at:{type:"string"},cost_price:{type:"string",nullable:!0},tax_category_id:{type:"string",nullable:!0},variant:{$ref:"#/components/schemas/Variant"},tax_category:{$ref:"#/components/schemas/TaxCategory"},adjustments:{type:"array",items:{$ref:"#/components/schemas/Adjustment"}}},required:["id","variant_id","quantity","currency","name","slug","options_text","price","display_price","total","display_total","adjustment_total","display_adjustment_total","additional_tax_total","display_additional_tax_total","included_tax_total","display_included_tax_total","discount_total","display_discount_total","pre_tax_amount","display_pre_tax_amount","discounted_amount","display_discounted_amount","display_compare_at_amount","compare_at_amount","thumbnail_url","option_values","digital_links","metadata","created_at","updated_at","cost_price","tax_category_id"],"x-typelizer":!0},Market:{type:"object",properties:{id:{type:"string"},name:{type:"string"},currency:{type:"string"},default_locale:{type:"string"},tax_inclusive:{type:"boolean"},default:{type:"boolean"},country_isos:{type:"array",items:{type:"string"}},supported_locales:{type:"array",items:{type:"string"}},countries:{type:"array",items:{$ref:"#/components/schemas/Country"}},created_at:{type:"string"},updated_at:{type:"string"}},required:["id","name","currency","default_locale","tax_inclusive","default","country_isos","supported_locales","created_at","updated_at"],"x-typelizer":!0},Media:{type:"object",properties:{id:{type:"string"},product_id:{type:"string",nullable:!0},variant_ids:{type:"array",items:{type:"string"}},position:{type:"number"},alt:{type:"string",nullable:!0},media_type:{type:"string"},focal_point_x:{type:"number",nullable:!0},focal_point_y:{type:"number",nullable:!0},external_video_url:{type:"string",nullable:!0},original_url:{type:"string",nullable:!0},mini_url:{type:"string",nullable:!0},small_url:{type:"string",nullable:!0},medium_url:{type:"string",nullable:!0},large_url:{type:"string",nullable:!0},xlarge_url:{type:"string",nullable:!0},og_image_url:{type:"string",nullable:!0},created_at:{type:"string"},updated_at:{type:"string"},viewable_id:{type:"string"},download_url:{type:"string",nullable:!0},metadata:{type:"object"},viewable_type:{type:"string"}},required:["id","product_id","variant_ids","position","alt","media_type","focal_point_x","focal_point_y","external_video_url","original_url","mini_url","small_url","medium_url","large_url","xlarge_url","og_image_url","created_at","updated_at","viewable_id","download_url","metadata","viewable_type"],"x-typelizer":!0},OptionType:{type:"object",properties:{id:{type:"string"},name:{type:"string"},label:{type:"string"},position:{type:"number"},kind:{type:"string"},metadata:{type:"object"},filterable:{type:"boolean"},created_at:{type:"string"},updated_at:{type:"string"},option_values:{type:"array",items:{$ref:"#/components/schemas/OptionValue"}}},required:["id","name","label","position","kind","metadata","filterable","created_at","updated_at"],"x-typelizer":!0},OptionValue:{type:"object",properties:{id:{type:"string"},option_type_id:{type:"string"},name:{type:"string"},label:{type:"string"},position:{type:"number"},color_code:{type:"string",nullable:!0},option_type_name:{type:"string"},option_type_label:{type:"string"},image_url:{type:"string",nullable:!0},metadata:{type:"object"},created_at:{type:"string"},updated_at:{type:"string"},option_type:{$ref:"#/components/schemas/OptionType"}},required:["id","option_type_id","name","label","position","color_code","option_type_name","option_type_label","image_url","metadata","created_at","updated_at"],"x-typelizer":!0},Order:{type:"object",properties:{id:{type:"string"},market_id:{type:"string",nullable:!0},channel_id:{type:"string",nullable:!0},number:{type:"string"},email:{type:"string"},customer_note:{type:"string",nullable:!0},currency:{type:"string"},locale:{type:"string",nullable:!0},total_quantity:{type:"number"},item_total:{type:"string"},display_item_total:{type:"string"},adjustment_total:{type:"string"},display_adjustment_total:{type:"string"},discount_total:{type:"string"},display_discount_total:{type:"string"},tax_total:{type:"string"},display_tax_total:{type:"string"},included_tax_total:{type:"string"},display_included_tax_total:{type:"string"},additional_tax_total:{type:"string"},display_additional_tax_total:{type:"string"},total:{type:"string"},display_total:{type:"string"},gift_card_total:{type:"string"},display_gift_card_total:{type:"string"},amount_due:{type:"string"},display_amount_due:{type:"string"},delivery_total:{type:"string"},display_delivery_total:{type:"string"},fulfillment_status:{type:"string",nullable:!0},payment_status:{type:"string",nullable:!0},completed_at:{type:"string",nullable:!0},store_credit_total:{type:"string"},display_store_credit_total:{type:"string"},covered_by_store_credit:{type:"boolean"},discounts:{type:"array",items:{$ref:"#/components/schemas/Discount"}},items:{type:"array",items:{$ref:"#/components/schemas/LineItem"}},fulfillments:{type:"array",items:{$ref:"#/components/schemas/Fulfillment"}},payments:{type:"array",items:{$ref:"#/components/schemas/Payment"}},billing_address:{allOf:[{$ref:"#/components/schemas/Address"}],nullable:!0},shipping_address:{allOf:[{$ref:"#/components/schemas/Address"}],nullable:!0},gift_card:{allOf:[{$ref:"#/components/schemas/GiftCard"}],nullable:!0},market:{allOf:[{$ref:"#/components/schemas/Market"}],nullable:!0},status:{type:"string"},last_ip_address:{type:"string",nullable:!0},considered_risky:{type:"boolean"},confirmation_delivered:{type:"boolean"},store_owner_notification_delivered:{type:"boolean"},payment_total:{type:"string"},display_payment_total:{type:"string"},metadata:{type:"object"},canceled_at:{type:"string",nullable:!0},approved_at:{type:"string",nullable:!0},created_at:{type:"string"},updated_at:{type:"string"},preferred_stock_location_id:{type:"string",nullable:!0},tags:{type:"array",items:{type:"string"}},internal_note:{type:"string",nullable:!0},approver_id:{type:"string",nullable:!0},canceler_id:{type:"string",nullable:!0},created_by_id:{type:"string",nullable:!0},customer_id:{type:"string",nullable:!0},channel:{$ref:"#/components/schemas/Channel"},preferred_stock_location:{$ref:"#/components/schemas/StockLocation"},payment_methods:{type:"array",items:{$ref:"#/components/schemas/PaymentMethod"}},customer:{$ref:"#/components/schemas/Customer"},approver:{$ref:"#/components/schemas/Customer"},canceler:{$ref:"#/components/schemas/Customer"},created_by:{$ref:"#/components/schemas/Customer"},adjustments:{type:"array",items:{$ref:"#/components/schemas/Adjustment"}},return_authorizations:{type:"array",items:{$ref:"#/components/schemas/ReturnAuthorization"}},reimbursements:{type:"array",items:{$ref:"#/components/schemas/Reimbursement"}}},required:["id","market_id","channel_id","number","email","customer_note","currency","locale","total_quantity","item_total","display_item_total","adjustment_total","display_adjustment_total","discount_total","display_discount_total","tax_total","display_tax_total","included_tax_total","display_included_tax_total","additional_tax_total","display_additional_tax_total","total","display_total","gift_card_total","display_gift_card_total","amount_due","display_amount_due","delivery_total","display_delivery_total","fulfillment_status","payment_status","completed_at","store_credit_total","display_store_credit_total","covered_by_store_credit","gift_card","market","status","last_ip_address","considered_risky","confirmation_delivered","store_owner_notification_delivered","payment_total","display_payment_total","metadata","canceled_at","approved_at","created_at","updated_at","preferred_stock_location_id","tags","internal_note","approver_id","canceler_id","created_by_id","customer_id"],"x-typelizer":!0},PaymentMethod:{type:"object",properties:{id:{type:"string"},name:{type:"string"},description:{type:"string",nullable:!0},type:{type:"string"},session_required:{type:"boolean"},source_required:{type:"boolean"},metadata:{type:"object"},active:{type:"boolean"},auto_capture:{type:"boolean",nullable:!0},storefront_visible:{type:"boolean"},position:{type:"number"},created_at:{type:"string"},updated_at:{type:"string"},preferences:{type:"object"},preference_schema:{type:"object"}},required:["id","name","description","type","session_required","source_required","metadata","active","auto_capture","storefront_visible","position","created_at","updated_at","preferences","preference_schema"],"x-typelizer":!0},Payment:{type:"object",properties:{id:{type:"string"},payment_method_id:{type:"string"},response_code:{type:"string",nullable:!0},number:{type:"string"},amount:{type:"string"},display_amount:{type:"string"},status:{type:"string"},source_type:{type:"string",nullable:!0,enum:["credit_card","store_credit","payment_source"]},source_id:{type:"string",nullable:!0},source:{anyOf:[{$ref:"#/components/schemas/CreditCard"},{$ref:"#/components/schemas/StoreCredit"},{$ref:"#/components/schemas/PaymentSource"}],nullable:!0},payment_method:{$ref:"#/components/schemas/PaymentMethod"},metadata:{type:"object"},avs_response:{type:"string",nullable:!0},cvv_response_code:{type:"string",nullable:!0},cvv_response_message:{type:"string",nullable:!0},created_at:{type:"string"},updated_at:{type:"string"},captured_amount:{type:"string"},order_id:{type:"string",nullable:!0},order:{$ref:"#/components/schemas/Order"},refunds:{type:"array",items:{$ref:"#/components/schemas/Refund"}}},required:["id","payment_method_id","response_code","number","amount","display_amount","status","source_type","source_id","source","metadata","avs_response","cvv_response_code","cvv_response_message","created_at","updated_at","captured_amount","order_id"],"x-typelizer":!0},PaymentSource:{type:"object",properties:{id:{type:"string"},gateway_payment_profile_id:{type:"string",nullable:!0},metadata:{type:"object"},created_at:{type:"string"},updated_at:{type:"string"}},required:["id","gateway_payment_profile_id","metadata","created_at","updated_at"],"x-typelizer":!0},PriceHistory:{type:"object",properties:{id:{type:"string"},amount:{type:"string"},amount_in_cents:{type:"number"},currency:{type:"string"},display_amount:{type:"string"},recorded_at:{type:"string"},variant_id:{type:"string"},price_id:{type:"string"},compare_at_amount:{type:"string",nullable:!0},created_at:{type:"string"}},required:["id","amount","amount_in_cents","currency","display_amount","recorded_at","variant_id","price_id","compare_at_amount","created_at"],"x-typelizer":!0},PriceList:{type:"object",properties:{id:{type:"string"},name:{type:"string"},description:{type:"string",nullable:!0},status:{type:"string"},position:{type:"number"},match_policy:{type:"string"},starts_at:{type:"string",nullable:!0},ends_at:{type:"string",nullable:!0},deleted_at:{type:"string",nullable:!0},created_at:{type:"string"},updated_at:{type:"string"},currently_active:{type:"boolean"},products_count:{type:"number"},prices_count:{type:"number"},product_ids:{type:"array",items:{type:"string"}},price_rules:{type:"array",items:{$ref:"#/components/schemas/PriceRule"}}},required:["id","name","description","status","position","match_policy","starts_at","ends_at","deleted_at","created_at","updated_at","currently_active","products_count","prices_count","product_ids"],"x-typelizer":!0},PriceRule:{type:"object",properties:{id:{type:"string"},created_at:{type:"string"},updated_at:{type:"string"},type:{type:"string"},price_list_id:{type:"string"},preferences:{type:"object"},preference_schema:{type:"array",items:{$ref:"#/components/schemas/PreferenceField"}},label:{type:"string"},description:{type:"string",nullable:!0},markets:{type:"array",items:{$ref:"#/components/schemas/Market"}},customer_groups:{type:"array",items:{$ref:"#/components/schemas/CustomerGroup"}},customers:{type:"array",items:{$ref:"#/components/schemas/Customer"}}},required:["id","created_at","updated_at","type","price_list_id","preferences","preference_schema","label","description"],"x-typelizer":!0},Price:{type:"object",properties:{id:{type:"string"},amount:{type:"string",nullable:!0},amount_in_cents:{type:"number",nullable:!0},compare_at_amount:{type:"string",nullable:!0},compare_at_amount_in_cents:{type:"number",nullable:!0},currency:{type:"string",nullable:!0},display_amount:{type:"string",nullable:!0},display_compare_at_amount:{type:"string",nullable:!0},price_list_id:{type:"string",nullable:!0},variant_id:{type:"string",nullable:!0},created_at:{type:"string"},updated_at:{type:"string"},variant:{$ref:"#/components/schemas/Variant"}},required:["id","amount","amount_in_cents","compare_at_amount","compare_at_amount_in_cents","currency","display_amount","display_compare_at_amount","price_list_id","variant_id","created_at","updated_at"],"x-typelizer":!0},ProductPublication:{type:"object",properties:{id:{type:"string"},published_at:{type:"string",nullable:!0},unpublished_at:{type:"string",nullable:!0},product_id:{type:"string"},channel_id:{type:"string"},created_at:{type:"string"},updated_at:{type:"string"}},required:["id","published_at","unpublished_at","product_id","channel_id","created_at","updated_at"],"x-typelizer":!0},Product:{type:"object",properties:{id:{type:"string"},name:{type:"string"},slug:{type:"string"},meta_title:{type:"string",nullable:!0},meta_description:{type:"string",nullable:!0},meta_keywords:{type:"string",nullable:!0},variant_count:{type:"number"},available_on:{type:"string",nullable:!0},purchasable:{type:"boolean"},in_stock:{type:"boolean"},backorderable:{type:"boolean"},available:{type:"boolean"},description:{type:"string",nullable:!0},description_html:{type:"string",nullable:!0},default_variant_id:{type:"string"},thumbnail_url:{type:"string",nullable:!0},tags:{type:"array",items:{type:"string"}},price:{allOf:[{$ref:"#/components/schemas/Price"}],nullable:!0},original_price:{allOf:[{$ref:"#/components/schemas/Price"}],nullable:!0},primary_media:{$ref:"#/components/schemas/Media"},media:{type:"array",items:{$ref:"#/components/schemas/Media"}},variants:{type:"array",items:{$ref:"#/components/schemas/Variant"}},default_variant:{$ref:"#/components/schemas/Variant"},option_types:{type:"array",items:{$ref:"#/components/schemas/OptionType"}},option_values:{type:"array",items:{$ref:"#/components/schemas/OptionValue"}},categories:{type:"array",items:{$ref:"#/components/schemas/Category"}},custom_fields:{type:"array",items:{$ref:"#/components/schemas/CustomField"}},prior_price:{allOf:[{$ref:"#/components/schemas/PriceHistory"}],nullable:!0},status:{type:"string"},metadata:{type:"object"},deleted_at:{type:"string",nullable:!0},created_at:{type:"string"},updated_at:{type:"string"},tax_category_id:{type:"string",nullable:!0},product_publications:{type:"array",items:{$ref:"#/components/schemas/ProductPublication"}},channels:{type:"array",items:{$ref:"#/components/schemas/Channel"}}},required:["id","name","slug","meta_title","meta_description","meta_keywords","variant_count","available_on","purchasable","in_stock","backorderable","available","description","description_html","default_variant_id","thumbnail_url","tags","price","original_price","status","metadata","deleted_at","created_at","updated_at","tax_category_id"],"x-typelizer":!0},PromotionAction:{type:"object",properties:{id:{type:"string"},created_at:{type:"string"},updated_at:{type:"string"},type:{type:"string"},promotion_id:{type:"string"},preferences:{type:"object"},preference_schema:{type:"array",items:{$ref:"#/components/schemas/PreferenceField"}},label:{type:"string"},calculator:{allOf:[{$ref:"#/components/schemas/PromotionActionCalculator"}],nullable:!0},line_items:{type:"array",items:{$ref:"#/components/schemas/PromotionActionLineItem"},nullable:!0}},required:["id","created_at","updated_at","type","promotion_id","preferences","preference_schema","label","calculator","line_items"],"x-typelizer":!0},PromotionRule:{type:"object",properties:{id:{type:"string"},created_at:{type:"string"},updated_at:{type:"string"},type:{type:"string"},promotion_id:{type:"string"},preferences:{type:"object"},preference_schema:{type:"array",items:{$ref:"#/components/schemas/PreferenceField"}},label:{type:"string"},product_ids:{type:"array",items:{type:"string"},nullable:!0},category_ids:{type:"array",items:{type:"string"},nullable:!0},customer_ids:{type:"array",items:{type:"string"},nullable:!0},products:{type:"array",items:{$ref:"#/components/schemas/Product"}},categories:{type:"array",items:{$ref:"#/components/schemas/Category"}},customers:{type:"array",items:{$ref:"#/components/schemas/Customer"}},customer_groups:{type:"array",items:{$ref:"#/components/schemas/CustomerGroup"}},countries:{type:"array",items:{$ref:"#/components/schemas/Country"}}},required:["id","created_at","updated_at","type","promotion_id","preferences","preference_schema","label","product_ids","category_ids","customer_ids"],"x-typelizer":!0},Promotion:{type:"object",properties:{id:{type:"string"},name:{type:"string"},description:{type:"string",nullable:!0},code:{type:"string",nullable:!0},starts_at:{type:"string",nullable:!0},expires_at:{type:"string",nullable:!0},usage_limit:{type:"number",nullable:!0},match_policy:{type:"string",enum:["all","any"]},path:{type:"string",nullable:!0},kind:{type:"string",enum:["coupon_code","automatic"]},multi_codes:{type:"boolean"},number_of_codes:{type:"number",nullable:!0},code_prefix:{type:"string",nullable:!0},promotion_category_id:{type:"string",nullable:!0},metadata:{type:"object"},created_at:{type:"string"},updated_at:{type:"string"},action_ids:{type:"array",items:{type:"string"}},rule_ids:{type:"array",items:{type:"string"}}},required:["id","name","description","code","starts_at","expires_at","usage_limit","match_policy","path","kind","multi_codes","number_of_codes","code_prefix","promotion_category_id","metadata","created_at","updated_at","action_ids","rule_ids"],"x-typelizer":!0},Refund:{type:"object",properties:{id:{type:"string"},transaction_id:{type:"string",nullable:!0},amount:{type:"string",nullable:!0},payment_id:{type:"string",nullable:!0},refund_reason_id:{type:"string",nullable:!0},reimbursement_id:{type:"string",nullable:!0},metadata:{type:"object"},created_at:{type:"string"},updated_at:{type:"string"},payment:{$ref:"#/components/schemas/Payment"},reimbursement:{$ref:"#/components/schemas/Reimbursement"}},required:["id","transaction_id","amount","payment_id","refund_reason_id","reimbursement_id","metadata","created_at","updated_at"],"x-typelizer":!0},Reimbursement:{type:"object",properties:{id:{type:"string"},number:{type:"string"},reimbursement_status:{type:"string",nullable:!0},total:{type:"string",nullable:!0},order_id:{type:"string",nullable:!0},customer_return_id:{type:"string",nullable:!0},created_at:{type:"string"},updated_at:{type:"string"},order:{$ref:"#/components/schemas/Order"}},required:["id","number","reimbursement_status","total","order_id","customer_return_id","created_at","updated_at"],"x-typelizer":!0},ReturnAuthorization:{type:"object",properties:{id:{type:"string"},number:{type:"string"},status:{type:"string"},order_id:{type:"string",nullable:!0},stock_location_id:{type:"string",nullable:!0},return_authorization_reason_id:{type:"string",nullable:!0},created_at:{type:"string"},updated_at:{type:"string"},order:{$ref:"#/components/schemas/Order"},stock_location:{$ref:"#/components/schemas/StockLocation"}},required:["id","number","status","order_id","stock_location_id","return_authorization_reason_id","created_at","updated_at"],"x-typelizer":!0},Role:{type:"object",properties:{id:{type:"string"},name:{type:"string"},created_at:{type:"string"},updated_at:{type:"string"}},required:["id","name","created_at","updated_at"],"x-typelizer":!0},State:{type:"object",properties:{abbr:{type:"string"},name:{type:"string"},created_at:{type:"object"},updated_at:{type:"object"}},required:["abbr","name","created_at","updated_at"],"x-typelizer":!0},StockItem:{type:"object",properties:{id:{type:"string"},count_on_hand:{type:"number"},backorderable:{type:"boolean"},stock_location_id:{type:"string",nullable:!0},variant_id:{type:"string",nullable:!0},metadata:{type:"object"},created_at:{type:"string"},updated_at:{type:"string"},allocated_count:{type:"number"},available_count:{type:"number"},stock_location:{$ref:"#/components/schemas/StockLocation"},variant:{$ref:"#/components/schemas/Variant"}},required:["id","count_on_hand","backorderable","stock_location_id","variant_id","metadata","created_at","updated_at","allocated_count","available_count"],"x-typelizer":!0},StockLocation:{type:"object",properties:{id:{type:"string"},state_abbr:{type:"string",nullable:!0},name:{type:"string"},address1:{type:"string",nullable:!0},city:{type:"string",nullable:!0},zipcode:{type:"string",nullable:!0},country_iso:{type:"string",nullable:!0},country_name:{type:"string",nullable:!0},state_text:{type:"string",nullable:!0},admin_name:{type:"string",nullable:!0},address2:{type:"string",nullable:!0},state_name:{type:"string",nullable:!0},phone:{type:"string",nullable:!0},company:{type:"string",nullable:!0},active:{type:"boolean"},default:{type:"boolean"},backorderable_default:{type:"boolean"},propagate_all_variants:{type:"boolean"},kind:{type:"string"},pickup_enabled:{type:"boolean"},pickup_stock_policy:{type:"string"},pickup_ready_in_minutes:{type:"number",nullable:!0},pickup_instructions:{type:"string",nullable:!0},created_at:{type:"string"},updated_at:{type:"string"}},required:["id","state_abbr","name","address1","city","zipcode","country_iso","country_name","state_text","admin_name","address2","state_name","phone","company","active","default","backorderable_default","propagate_all_variants","kind","pickup_enabled","pickup_stock_policy","pickup_ready_in_minutes","pickup_instructions","created_at","updated_at"],"x-typelizer":!0},StockReservation:{type:"object",properties:{id:{type:"string"},stock_item_id:{type:"string"},line_item_id:{type:"string"},order_id:{type:"string"},variant_id:{type:"string",nullable:!0},stock_location_id:{type:"string",nullable:!0},quantity:{type:"number"},expires_at:{type:"string"},active:{type:"boolean"},created_at:{type:"string"},updated_at:{type:"string"}},required:["id","stock_item_id","line_item_id","order_id","variant_id","stock_location_id","quantity","expires_at","active","created_at","updated_at"],"x-typelizer":!0},StockTransfer:{type:"object",properties:{id:{type:"string"},number:{type:"string"},reference:{type:"string",nullable:!0},metadata:{type:"object"},created_at:{type:"string"},updated_at:{type:"string"},source_location_id:{type:"string",nullable:!0},destination_location_id:{type:"string",nullable:!0},source_location:{$ref:"#/components/schemas/StockLocation"},destination_location:{$ref:"#/components/schemas/StockLocation"}},required:["id","number","reference","metadata","created_at","updated_at","source_location_id","destination_location_id"],"x-typelizer":!0},StoreCreditCategory:{type:"object",properties:{id:{type:"string"},name:{type:"string"},created_at:{type:"string"},updated_at:{type:"string"},non_expiring:{type:"boolean"}},required:["id","name","created_at","updated_at","non_expiring"],"x-typelizer":!0},StoreCredit:{type:"object",properties:{id:{type:"string"},amount:{type:"string"},amount_used:{type:"string"},amount_remaining:{type:"string"},display_amount:{type:"string"},display_amount_used:{type:"string"},display_amount_remaining:{type:"string"},currency:{type:"string"},memo:{type:"string",nullable:!0},metadata:{type:"object"},created_at:{type:"string"},updated_at:{type:"string"},customer_id:{type:"string",nullable:!0},created_by_id:{type:"string",nullable:!0},category_id:{type:"string",nullable:!0},category_name:{type:"string",nullable:!0}},required:["id","amount","amount_used","amount_remaining","display_amount","display_amount_used","display_amount_remaining","currency","memo","metadata","created_at","updated_at","customer_id","created_by_id","category_id","category_name"],"x-typelizer":!0},Store:{type:"object",properties:{id:{type:"string"},metadata:{type:"object"},name:{type:"string"},default_currency:{type:"string"},default_locale:{type:"string"},mail_from_address:{type:"string",nullable:!0},customer_support_email:{type:"string",nullable:!0},new_order_notifications_email:{type:"string",nullable:!0},preferred_send_consumer_transactional_emails:{type:"boolean"},preferred_admin_locale:{type:"string",nullable:!0},preferred_timezone:{type:"string"},preferred_weight_unit:{type:"string"},preferred_unit_system:{type:"string"},created_at:{type:"string"},updated_at:{type:"string"},url:{type:"string"},supported_currencies:{type:"array",items:{type:"string"}},supported_locales:{type:"array",items:{type:"string"}},logo_url:{type:"string",nullable:!0},mailer_logo_url:{type:"string",nullable:!0}},required:["id","metadata","name","default_currency","default_locale","mail_from_address","customer_support_email","new_order_notifications_email","preferred_send_consumer_transactional_emails","preferred_admin_locale","preferred_timezone","preferred_weight_unit","preferred_unit_system","created_at","updated_at","url","supported_currencies","supported_locales","logo_url","mailer_logo_url"],"x-typelizer":!0},TaxCategory:{type:"object",properties:{id:{type:"string"},name:{type:"string"},tax_code:{type:"string",nullable:!0},description:{type:"string",nullable:!0},is_default:{type:"boolean"},created_at:{type:"string"},updated_at:{type:"string"}},required:["id","name","tax_code","description","is_default","created_at","updated_at"],"x-typelizer":!0},Variant:{type:"object",properties:{id:{type:"string"},product_id:{type:"string"},sku:{type:"string",nullable:!0},options_text:{type:"string"},track_inventory:{type:"boolean"},media_count:{type:"number"},thumbnail_url:{type:"string",nullable:!0},purchasable:{type:"boolean"},in_stock:{type:"boolean"},backorderable:{type:"boolean"},weight:{type:"number",nullable:!0},height:{type:"number",nullable:!0},width:{type:"number",nullable:!0},depth:{type:"number",nullable:!0},price:{$ref:"#/components/schemas/Price"},original_price:{allOf:[{$ref:"#/components/schemas/Price"}],nullable:!0},primary_media:{$ref:"#/components/schemas/Media"},media:{type:"array",items:{$ref:"#/components/schemas/Media"}},option_values:{type:"array",items:{$ref:"#/components/schemas/OptionValue"}},custom_fields:{type:"array",items:{$ref:"#/components/schemas/CustomField"}},prior_price:{allOf:[{$ref:"#/components/schemas/PriceHistory"}],nullable:!0},metadata:{type:"object"},position:{type:"number"},cost_price:{type:"string",nullable:!0},cost_currency:{type:"string",nullable:!0},barcode:{type:"string",nullable:!0},weight_unit:{type:"string",nullable:!0},dimensions_unit:{type:"string",nullable:!0},deleted_at:{type:"string",nullable:!0},created_at:{type:"string"},updated_at:{type:"string"},tax_category_id:{type:"string",nullable:!0},available_stock:{type:"number",nullable:!0},reserved_quantity:{type:"number"},total_on_hand:{type:"number",nullable:!0},product_name:{type:"string"},prices:{type:"array",items:{$ref:"#/components/schemas/Price"}},stock_items:{type:"array",items:{$ref:"#/components/schemas/StockItem"}}},required:["id","product_id","sku","options_text","track_inventory","media_count","thumbnail_url","purchasable","in_stock","backorderable","weight","height","width","depth","price","original_price","option_values","metadata","position","cost_price","cost_currency","barcode","weight_unit","dimensions_unit","deleted_at","created_at","updated_at","tax_category_id","available_stock","reserved_quantity","total_on_hand","product_name"],"x-typelizer":!0},WebhookDelivery:{type:"object",properties:{id:{type:"string"},event_name:{type:"string"},event_id:{type:"string",nullable:!0},response_code:{type:"number",nullable:!0},execution_time:{type:"number",nullable:!0},error_type:{type:"string",nullable:!0},request_errors:{type:"string",nullable:!0},response_body:{type:"string",nullable:!0},success:{type:"boolean",nullable:!0},payload:{type:"object"},created_at:{type:"string"},updated_at:{type:"string"},delivered_at:{type:"string",nullable:!0},webhook_endpoint_id:{type:"string"},webhook_endpoint_url:{type:"string"}},required:["id","event_name","event_id","response_code","execution_time","error_type","request_errors","response_body","success","payload","created_at","updated_at","delivered_at","webhook_endpoint_id","webhook_endpoint_url"],"x-typelizer":!0},WebhookEndpoint:{type:"object",properties:{id:{type:"string"},name:{type:"string",nullable:!0},url:{type:"string"},active:{type:"boolean"},subscriptions:{type:"array",items:{type:"string"}},disabled_reason:{type:"string",nullable:!0},created_at:{type:"string"},updated_at:{type:"string"},disabled_at:{type:"string",nullable:!0},secret_key:{type:"string",nullable:!0},last_delivery_at:{type:"string",nullable:!0},recent_delivery_count:{type:"number"},recent_failure_count:{type:"number"},total_delivery_count:{type:"number"},successful_delivery_count:{type:"number"},failed_delivery_count:{type:"number"}},required:["id","name","url","active","subscriptions","disabled_reason","created_at","updated_at","disabled_at","secret_key","last_delivery_at","recent_delivery_count","recent_failure_count","total_delivery_count","successful_delivery_count","failed_delivery_count"],"x-typelizer":!0}}}};var Dl=new Set(["get","post","put","patch","delete"]);function Ni(){return Rl}function yk(e){let t=e.description?.match(/\*\*Required scope:\*\* (.+?) \(for API-key authentication\)\./);return t?t[1].replaceAll("`",""):"\u2014"}function Ll(e,t={}){let r=[];for(let[i,n]of Object.entries(e.paths)){let s=i.replace("/api/v3/admin","")||"/";for(let[o,a]of Object.entries(n)){if(!Dl.has(o))continue;if(t.resource){let d=s.split("/")[1]??"";if(d!==t.resource&&!d.startsWith(t.resource))continue}let c=a.summary??"";t.search&&!`${o} ${s} ${c}`.toLowerCase().includes(t.search.toLowerCase())||r.push({method:o.toUpperCase(),path:s,scope:yk(a),summary:c})}}return r}function Ml(e,t){let r=t.trim().split(/\s+/),i=r.length>1?r[0].toLowerCase():void 0,n=r.length>1?r[1]:r[0],s=dr(n),o=jl(e,i,a=>a===s);return o.length>0?o:jl(e,i,a=>fk(a,s))}function jl(e,t,r){let i=[];for(let[n,s]of Object.entries(e.paths)){let o=n.replace("/api/v3/admin","")||"/";if(r(o))for(let[a,c]of Object.entries(s))Dl.has(a)&&(t&&a!==t||i.push({method:a.toUpperCase(),path:o,summary:c.summary,description:c.description,parameters:jt(c.parameters,e),requestBody:jt(c.requestBody,e),responses:jt(c.responses,e)}))}return i}function fk(e,t){if(e===t)return!0;let r=e.split("/"),i=t.split("/");return r.length!==i.length?!1:r.every((n,s)=>n.startsWith("{")&&n.endsWith("}")?i[s].length>0:n===i[s])}var gk=8;function jt(e,t,r=[]){if(Array.isArray(e))return e.map(o=>jt(o,t,r));if(!e||typeof e!="object")return e;let i=e,n=i.$ref;if(typeof n=="string"){let o=n.replace("#/components/schemas/","");return r.includes(o)||r.length>=gk||!(o in t.components.schemas)?{$ref:n}:jt(t.components.schemas[o],t,[...r,o])}let s={};for(let[o,a]of Object.entries(i))s[o]=jt(a,t,r);return s}function _k(e,t){return[...t,e]}function Nl(e){return e.option("--profile <name>","use a saved profile (see `spree auth`)").option("--base-url <url>","store URL (overrides profile/env/project)").option("--api-key <key>","secret API key (prefer SPREE_API_KEY \u2014 flags leak into shell history)").option("--store-id <id>","X-Spree-Store-Id for hosts serving multiple stores")}function Gl(){return new Zo("--format <format>","output format").choices(["json","table"]).default("json")}function Fl(e){return Nl(e).addOption(Gl())}async function Ul(e){let t=await cr({baseUrl:e.baseUrl,apiKey:e.apiKey,profile:e.profile});return{client:kr({baseUrl:t.baseUrl,secretKey:t.apiKey,...e.storeId?{storeId:e.storeId}:{}}),credentials:t}}function zl(e){let t=e.command("api").description("Call the Admin API directly (generic get/post/patch/delete)");t.addHelpText("after",["","Examples:"," spree api get /products -q status_eq=active --limit 10",` spree api post /products -d '{"name":"Classic Tee"}'`," spree api get /orders/ord_x8k2J9aQ --expand items,payments","","Discover the surface (offline, no server needed):"," spree api endpoints --search <term> # find endpoints + required scopes",' spree api schema "POST /orders" # request/response schema for one operation'," spree completion zsh # tab-completion for paths, filters, scopes"].join(`
|
|
268
|
+
`)),Fl(t.command("get <path>").description("GET an Admin API path, e.g. `spree api get /products -q status_eq=active`").option("-q, --query <expr>","Ransack predicate key=value (repeatable)",_k,[]).option("--sort <fields>","sort, e.g. -created_at").option("--page <n>","page number").option("--limit <n>","page size (max 100)").option("--expand <relations>","expand relations, e.g. variants,variants.prices").option("--fields <fields>","sparse fields, e.g. id,name")).action(async(r,i)=>{let n;try{let s=Il(i),{client:o,credentials:a}=await Ul(i);n=a.baseUrl;let c=await o.request("GET",dr(r),{params:s});pr(c,i.format)}catch(s){dt(s,{baseUrl:n})}});for(let r of["post","patch","delete"])Fl(t.command(`${r} <path>`).description(`${r.toUpperCase()} an Admin API path`).option("-d, --data <json>","request body: inline JSON, @file, or '-' for stdin")).action(async(i,n)=>{let s;try{let o=await Sa(n.data),{client:a,credentials:c}=await Ul(n);s=c.baseUrl;let d=await a.request(r.toUpperCase(),dr(i),{...o===Un?{}:{body:o}});pr(d,n.format)}catch(o){dt(o,{baseUrl:s})}});t.command("endpoints").description("List Admin API endpoints with their required scopes").option("--resource <name>","filter by first path segment, e.g. orders").option("--search <term>","filter by method, path, or summary").addOption(Gl()).action(r=>{let i=Ll(Ni(),{resource:r.resource,search:r.search});if(i.length===0){process.stderr.write(`No endpoints match.
|
|
269
|
+
`),process.exitCode=1;return}if(r.format==="table"){(0,Bl.printTable)(i.map(n=>({Method:n.method,Path:n.path,Scope:n.scope,Summary:n.summary})));return}pr(i,"json")}),t.command("schema <operation>").description('Show the request/response schema for an operation, e.g. `spree api schema "POST /products"`').action(r=>{let i=Ml(Ni(),r);if(i.length===0){process.stderr.write(`No operation matches "${r}". Try \`spree api endpoints --search ${r.split(/\s+/).pop()}\`.
|
|
270
|
+
`),process.exitCode=1;return}let n=/\s/.test(r.trim());pr(n&&i.length===1?i[0]:i,"json")}),Nl(t.command("status").description("Show resolved credentials, server reachability, and the bundled spec version")).action(async r=>{try{let i=await cr({baseUrl:r.baseUrl,apiKey:r.apiKey,profile:r.profile},{allowMint:!1}),n=await ur(i.baseUrl,i.apiKey),s=Ni(),o=Bi(n),a=[`${Ye.default.bold("Base URL:")} ${i.baseUrl}`,`${Ye.default.bold("Credentials:")} ${i.source}${i.profileName?` (${i.profileName})`:""}, key ${i.tokenPrefix}${Ye.default.dim("\u2026")}`];i.scopes?.length&&a.push(`${Ye.default.bold("Scopes:")} ${i.scopes.join(", ")}`),a.push(`${Ye.default.bold("Server:")} ${o}`),a.push(`${Ye.default.bold("Bundled spec:")} ${s.info?.version??"unknown"} ${Ye.default.dim("(spree api endpoints/schema reflect this snapshot, not the live server)")}`),process.stdout.write(`${a.join(`
|
|
271
|
+
`)}
|
|
272
|
+
`),Ui(n)&&(process.exitCode=1)}catch(i){dt(i,{baseUrl:r.baseUrl})}})}import{styleText as Eo}from"util";import{stdout as Po,stdin as am}from"process";import*as Je from"readline";import Rk from"readline";var Vl=(()=>{let e=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return t=>{let r=0;for(e.lastIndex=0;e.test(t);)r+=1;return t.length-r}})(),Wl=e=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,Hl=e=>e===8987||e===9001||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12441&&e<=12543||e>=12549&&e<=12591||e>=12593&&e<=12686||e>=12688&&e<=12771||e>=12783&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=19903||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e>=131072&&e<=196605||e>=196608&&e<=262141;var bk=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,xk=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,Kl=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu,wk=/\t{1,1000}/y,Yl=new RegExp("[\\u{1F1E6}-\\u{1F1FF}]{2}|\\u{1F3F4}[\\u{E0061}-\\u{E007A}]{2}[\\u{E0030}-\\u{E0039}\\u{E0061}-\\u{E007A}]{1,3}\\u{E007F}|(?:\\p{Emoji}\\uFE0F\\u20E3?|\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|\\p{Emoji_Presentation})(?:\\u200D(?:\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|\\p{Emoji_Presentation}|\\p{Emoji}\\uFE0F\\u20E3?))*","yu"),kk=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,Sk=new RegExp("\\p{M}+","gu"),vk={limit:1/0,ellipsis:""},Jl=(e,t={},r={})=>{let i=t.limit??1/0,n=t.ellipsis??"",s=t?.ellipsisWidth??(n?Jl(n,vk,r).width:0),o=0,a=r.controlWidth??0,c=r.tabWidth??8,d=r.emojiWidth??2,p=2,u=r.regularWidth??1,l=r.wideWidth??p,m=[[kk,u],[bk,o],[xk,a],[wk,c],[Yl,d],[Kl,l]],h=0,f=0,x=e.length,_=0,v=!1,C=x,E=Math.max(0,i-s),w=0,L=0,O=0,R=0;e:for(;;){if(L>w||f>=x&&f>h){let F=e.slice(w,L)||e.slice(h,f);_=0;for(let N of F.replaceAll(Sk,"")){let S=N.codePointAt(0)||0;if(Wl(S)?R=p:Hl(S)?R=l:R=u,O+R>E&&(C=Math.min(C,Math.max(w,h)+_)),O+R>i){v=!0;break e}_+=N.length,O+=R}w=L=0}if(f>=x)break e;for(let F=0,N=m.length;F<N;F++){let[S,Te]=m[F];if(S.lastIndex=f,S.test(e)){if(_=S===Kl?Vl(e.slice(f,S.lastIndex)):S===Yl?1:S.lastIndex-f,R=_*Te,O+R>E&&(C=Math.min(C,f+Math.floor((E-O)/Te))),O+R>i){v=!0;break e}O+=R,w=h,L=f,f=h=S.lastIndex;continue e}}f+=1}return{width:v?E:O,index:v?C:x,truncated:v,ellipsed:v&&i>=s}},Xl=Jl;var qk={limit:1/0,ellipsis:"",ellipsisWidth:0},$k=(e,t={})=>Xl(e,qk,t).width,ie=$k;var Gi="\x1B",rm="\x9B",Ck=39,qo="\x07",im="[",Ak="]",nm="m",$o=`${Ak}8;;`,Ql=new RegExp(`(?:\\${im}(?<code>\\d+)m|\\${$o}(?<uri>.*)${qo})`,"y"),Zl=e=>{if(e>=30&&e<=37||e>=90&&e<=97)return 39;if(e>=40&&e<=47||e>=100&&e<=107)return 49;if(e===1||e===2)return 22;if(e===3)return 23;if(e===4)return 24;if(e===7)return 27;if(e===8)return 28;if(e===9)return 29;if(e===0)return 0},em=e=>`${Gi}${im}${e}${nm}`,tm=e=>`${Gi}${$o}${e}${qo}`,vo=(e,t,r)=>{let i=t[Symbol.iterator](),n=!1,s=!1,o=e.at(-1),a=o===void 0?0:ie(o),c=i.next(),d=i.next(),p=0;for(;!c.done;){let u=c.value,l=ie(u);a+l<=r?e[e.length-1]+=u:(e.push(u),a=0),(u===Gi||u===rm)&&(n=!0,s=t.startsWith($o,p+1)),n?s?u===qo&&(n=!1,s=!1):u===nm&&(n=!1):(a+=l,a===r&&!d.done&&(e.push(""),a=0)),c=d,d=i.next(),p+=u.length}o=e.at(-1),!a&&o!==void 0&&o.length&&e.length>1&&(e[e.length-2]+=e.pop())},Ek=e=>{let t=e.split(" "),r=t.length;for(;r&&!ie(t[r-1]);)r--;return r===t.length?e:t.slice(0,r).join(" ")+t.slice(r).join("")},Tk=(e,t,r={})=>{if(r.trim!==!1&&e.trim()==="")return"";let i="",n,s,o=e.split(" "),a=[""],c=0;for(let u=0;u<o.length;u++){let l=o[u];if(r.trim!==!1){let h=a.at(-1)??"",f=h.trimStart();h.length!==f.length&&(a[a.length-1]=f,c=ie(f))}u!==0&&(c>=t&&(r.wordWrap===!1||r.trim===!1)&&(a.push(""),c=0),(c||r.trim===!1)&&(a[a.length-1]+=" ",c++));let m=ie(l);if(r.hard&&m>t){let h=t-c,f=1+Math.floor((m-h-1)/t);Math.floor((m-1)/t)<f&&a.push(""),vo(a,l,t),c=ie(a.at(-1)??"");continue}if(c+m>t&&c&&m){if(r.wordWrap===!1&&c<t){vo(a,l,t),c=ie(a.at(-1)??"");continue}a.push(""),c=0}if(c+m>t&&r.wordWrap===!1){vo(a,l,t),c=ie(a.at(-1)??"");continue}a[a.length-1]+=l,c+=m}r.trim!==!1&&(a=a.map(u=>Ek(u)));let d=a.join(`
|
|
273
|
+
`),p=!1;for(let u=0;u<d.length;u++){let l=d[u];if(i+=l,p)p=!1;else if(p=l>="\uD800"&&l<="\uDBFF",p)continue;if(l===Gi||l===rm){Ql.lastIndex=u+1;let h=Ql.exec(d)?.groups;if(h?.code!==void 0){let f=Number.parseFloat(h.code);n=f===Ck?void 0:f}else h?.uri!==void 0&&(s=h.uri.length===0?void 0:h.uri)}if(d[u+1]===`
|
|
274
|
+
`){s&&(i+=tm(""));let m=n?Zl(n):void 0;n&&m&&(i+=em(m))}else l===`
|
|
275
|
+
`&&(n&&Zl(n)&&(i+=em(n)),s&&(i+=tm(s)))}return i},Pk=/\r?\n/;function Ce(e,t,r){return String(e).normalize().split(Pk).map(i=>Tk(i,t,r)).join(`
|
|
276
|
+
`)}var te=B(Ao(),1);import{ReadStream as om}from"tty";function Vi(e,t,r){if(!r.some(o=>!o.disabled))return e;let i=e+t,n=Math.max(r.length-1,0),s=i<0?n:i>n?0:i;return r[s].disabled?Vi(s,t<0?-1:1,r):s}var jk=["up","down","left","right","space","enter","cancel"],Dk=["January","February","March","April","May","June","July","August","September","October","November","December"],Z={actions:new Set(jk),aliases:new Map([["k","up"],["j","down"],["h","left"],["l","right"],["","cancel"],["escape","cancel"]]),messages:{cancel:"Canceled",error:"Something went wrong"},withGuide:!0,date:{monthNames:[...Dk],messages:{required:"Please enter a valid date",invalidMonth:"There are only 12 months in a year",invalidDay:(e,t)=>`There are only ${e} days in ${t}`,afterMin:e=>`Date must be on or after ${e.toISOString().slice(0,10)}`,beforeMax:e=>`Date must be on or before ${e.toISOString().slice(0,10)}`}}};function Oo(e,t){if(typeof e=="string")return Z.aliases.get(e)===t;for(let r of e)if(r!==void 0&&Oo(r,t))return!0;return!1}function Lk(e,t){if(e===t)return;let r=e.split(`
|
|
277
|
+
`),i=t.split(`
|
|
278
|
+
`),n=Math.max(r.length,i.length),s=[];for(let o=0;o<n;o++)r[o]!==i[o]&&s.push(o);return{lines:s,numLinesBefore:r.length,numLinesAfter:i.length,numLines:n}}var Mk=globalThis.process.platform.startsWith("win"),To=Symbol("clack:cancel");function Y(e){return e===To}function zi(e,t){let r=e;r.isTTY&&r.setRawMode(t)}function cm({input:e=am,output:t=Po,overwrite:r=!0,hideCursor:i=!0}={}){let n=Je.createInterface({input:e,output:t,prompt:"",tabSize:1});Je.emitKeypressEvents(e,n),e instanceof om&&e.isTTY&&e.setRawMode(!0);let s=(o,{name:a,sequence:c})=>{let d=String(o);if(Oo([d,a,c],"cancel")){i&&t.write(te.cursor.show),process.exit(0);return}if(!r)return;Je.moveCursor(t,a==="return"?0:-1,a==="return"?-1:0,()=>{Je.clearLine(t,1,()=>{e.once("keypress",s)})})};return i&&t.write(te.cursor.hide),e.once("keypress",s),()=>{e.off("keypress",s),i&&t.write(te.cursor.show),e instanceof om&&e.isTTY&&!Mk&&e.setRawMode(!1),n.terminal=!1,n.close()}}var lr=e=>"columns"in e&&typeof e.columns=="number"?e.columns:80,Io=e=>"rows"in e&&typeof e.rows=="number"?e.rows:20;function mr(e,t,r,i=r,n){let s=lr(e??Po);return Ce(t,s-r.length,{hard:!0,trim:!1}).split(`
|
|
279
|
+
`).map((o,a)=>{let c=n?n(o,a):o;return`${a===0?i:r}${c}`}).join(`
|
|
280
|
+
`)}var Ji=class{input;output;_abortSignal;rl;opts;_render;_track=!1;_prevFrame="";_subscribers=new Map;_cursor=0;state="initial";error="";value;userInput="";constructor(e,t=!0){let{input:r=am,output:i=Po,render:n,signal:s,...o}=e;this.opts=o,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=n.bind(this),this._track=t,this._abortSignal=s,this.input=r,this.output=i}unsubscribe(){this._subscribers.clear()}setSubscriber(e,t){let r=this._subscribers.get(e)??[];r.push(t),this._subscribers.set(e,r)}on(e,t){this.setSubscriber(e,{cb:t})}once(e,t){this.setSubscriber(e,{cb:t,once:!0})}emit(e,...t){let r=this._subscribers.get(e)??[],i=[];for(let n of r)n.cb(...t),n.once&&i.push(()=>r.splice(r.indexOf(n),1));for(let n of i)n()}prompt(){return new Promise(e=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state="cancel",this.close(),e(To);this._abortSignal.addEventListener("abort",()=>{this.state="cancel",this.close()},{once:!0})}this.rl=Rk.createInterface({input:this.input,tabSize:2,prompt:"",escapeCodeTimeout:50,terminal:!0}),this.rl.prompt(),this.opts.initialUserInput!==void 0&&this._setUserInput(this.opts.initialUserInput,!0),this.input.on("keypress",this.onKeypress),zi(this.input,!0),this.output.on("resize",this.render),this.render(),this.once("submit",()=>{this.output.write(te.cursor.show),this.output.off("resize",this.render),zi(this.input,!1),e(this.value)}),this.once("cancel",()=>{this.output.write(te.cursor.show),this.output.off("resize",this.render),zi(this.input,!1),e(To)})})}_isActionKey(e,t){return e===" "}_shouldSubmit(e,t){return!0}_setValue(e){this.value=e,this.emit("value",this.value)}_setUserInput(e,t){this.userInput=e??"",this.emit("userInput",this.userInput),t&&this._track&&this.rl&&(this.rl.write(this.userInput),this._cursor=this.rl.cursor)}_clearUserInput(){this.rl?.write(null,{ctrl:!0,name:"u"}),this._setUserInput("")}onKeypress(e,t){if(this._track&&t.name!=="return"&&(t.name&&this._isActionKey(e,t)&&this.rl?.write(null,{ctrl:!0,name:"h"}),this._cursor=this.rl?.cursor??0,this._setUserInput(this.rl?.line)),this.state==="error"&&(this.state="active"),t?.name&&(!this._track&&Z.aliases.has(t.name)&&this.emit("cursor",Z.aliases.get(t.name)),Z.actions.has(t.name)&&this.emit("cursor",t.name)),e&&(e.toLowerCase()==="y"||e.toLowerCase()==="n")&&this.emit("confirm",e.toLowerCase()==="y"),this.emit("key",e?.toLowerCase(),t),t?.name==="return"&&this._shouldSubmit(e,t)){if(this.opts.validate){let r=this.opts.validate(this.value);r&&(this.error=r instanceof Error?r.message:r,this.state="error",this.rl?.write(this.userInput))}this.state!=="error"&&(this.state="submit")}Oo([e,t?.name,t?.sequence],"cancel")&&(this.state="cancel"),(this.state==="submit"||this.state==="cancel")&&this.emit("finalize"),this.render(),(this.state==="submit"||this.state==="cancel")&&this.close()}close(){this.input.unpipe(),this.input.removeListener("keypress",this.onKeypress),this.output.write(`
|
|
281
|
+
`),zi(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let e=Ce(this._prevFrame,process.stdout.columns,{hard:!0,trim:!1}).split(`
|
|
282
|
+
`).length-1;this.output.write(te.cursor.move(-999,e*-1))}render(){let e=Ce(this._render(this)??"",process.stdout.columns,{hard:!0,trim:!1});if(e!==this._prevFrame){if(this.state==="initial")this.output.write(te.cursor.hide);else{let t=Lk(this._prevFrame,e),r=Io(this.output);if(this.restoreCursor(),t){let i=Math.max(0,t.numLinesAfter-r),n=Math.max(0,t.numLinesBefore-r),s=t.lines.find(o=>o>=i);if(s===void 0){this._prevFrame=e;return}if(t.lines.length===1){this.output.write(te.cursor.move(0,s-n)),this.output.write(te.erase.lines(1));let o=e.split(`
|
|
283
|
+
`);this.output.write(o[s]),this._prevFrame=e,this.output.write(te.cursor.move(0,o.length-s-1));return}else if(t.lines.length>1){if(i<n)s=i;else{let a=s-n;a>0&&this.output.write(te.cursor.move(0,a))}this.output.write(te.erase.down());let o=e.split(`
|
|
284
|
+
`).slice(s);this.output.write(o.join(`
|
|
285
|
+
`)),this._prevFrame=e;return}}this.output.write(te.erase.down())}this.output.write(e),this.state==="initial"&&(this.state="active"),this._prevFrame=e}}};var Wi=class extends Ji{get cursor(){return this.value?0:1}get _value(){return this.cursor===0}constructor(t){super(t,!1),this.value=!!t.initialValue,this.on("userInput",()=>{this.value=this._value}),this.on("confirm",r=>{this.output.write(te.cursor.move(0,-1)),this.value=r,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}};var Hi=class extends Ji{_mask="\u2022";get cursor(){return this._cursor}get masked(){return this.userInput.replaceAll(/./g,this._mask)}get userInputWithCursor(){if(this.state==="submit"||this.state==="cancel")return this.masked;let t=this.userInput;if(this.cursor>=t.length)return`${this.masked}${Eo(["inverse","hidden"],"_")}`;let r=this.masked,i=r.slice(0,this.cursor),n=r.slice(this.cursor);return`${i}${Eo("inverse",n[0])}${n.slice(1)}`}clear(){this._clearUserInput()}constructor({mask:t,...r}){super(r),this._mask=t??"\u2022",this.on("userInput",i=>{this._setValue(i)})}},Ki=class extends Ji{options;cursor=0;get _selectedValue(){return this.options[this.cursor]}changeValue(){this.value=this._selectedValue.value}constructor(t){super(t,!1),this.options=t.options;let r=this.options.findIndex(({value:n})=>n===t.initialValue),i=r===-1?0:r;this.cursor=this.options[i].disabled?Vi(i,1,this.options):i,this.changeValue(),this.on("cursor",n=>{switch(n){case"left":case"up":this.cursor=Vi(this.cursor,-1,this.options);break;case"down":case"right":this.cursor=Vi(this.cursor,1,this.options);break}this.changeValue()})}};var Yi=class extends Ji{get userInputWithCursor(){if(this.state==="submit")return this.userInput;let t=this.userInput;if(this.cursor>=t.length)return`${this.userInput}\u2588`;let r=t.slice(0,this.cursor),[i,...n]=t.slice(this.cursor);return`${r}${Eo("inverse",i)}${n.join("")}`}get cursor(){return this._cursor}constructor(t){super({...t,initialUserInput:t.initialUserInput??t.initialValue}),this.on("userInput",r=>{this._setValue(r)}),this.on("finalize",()=>{this.value||(this.value=t.defaultValue),this.value===void 0&&(this.value="")})}};import{styleText as y,stripVTControlCharacters as w1}from"util";import he from"process";var hr=B(Ao(),1);import{existsSync as $1,lstatSync as C1,readdirSync as A1}from"fs";import{dirname as T1,join as P1}from"path";function Fk(){return he.platform!=="win32"?he.env.TERM!=="linux":!!he.env.CI||!!he.env.WT_SESSION||!!he.env.TERMINUS_SUBLIME||he.env.ConEmuTask==="{cmd::Cmder}"||he.env.TERM_PROGRAM==="Terminus-Sublime"||he.env.TERM_PROGRAM==="vscode"||he.env.TERM==="xterm-256color"||he.env.TERM==="alacritty"||he.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var Ro=Fk(),Uk=()=>process.env.CI==="true";var j=(e,t)=>Ro?e:t,Bk=j("\u25C6","*"),dm=j("\u25A0","x"),um=j("\u25B2","x"),Zi=j("\u25C7","o"),O1=j("\u250C","T"),$=j("\u2502","|"),Xe=j("\u2514","\u2014"),I1=j("\u2510","T"),R1=j("\u2518","\u2014"),jo=j("\u25CF",">"),Qi=j("\u25CB"," "),j1=j("\u25FB","[\u2022]"),D1=j("\u25FC","[+]"),L1=j("\u25FB","[ ]"),Nk=j("\u25AA","\u2022"),pm=j("\u2500","-"),Gk=j("\u256E","+"),zk=j("\u251C","+"),Vk=j("\u256F","+"),Wk=j("\u2570","+"),M1=j("\u256D","+"),Hk=j("\u25CF","\u2022"),Kk=j("\u25C6","*"),Yk=j("\u25B2","!"),Jk=j("\u25A0","x"),en=e=>{switch(e){case"initial":case"active":return y("cyan",Bk);case"cancel":return y("red",dm);case"error":return y("yellow",um);case"submit":return y("green",Zi)}},Xk=e=>{switch(e){case"initial":case"active":return y("cyan",$);case"cancel":return y("red",$);case"error":return y("yellow",$);case"submit":return y("green",$)}},Qk=(e,t,r,i,n)=>{let s=t,o=0;for(let a=r;a<i;a++){let c=e[a];if(s=s-c.length,o++,s<=n)break}return{lineCount:s,removals:o}},Zk=({cursor:e,options:t,style:r,output:i=process.stdout,maxItems:n=Number.POSITIVE_INFINITY,columnPadding:s=0,rowPadding:o=4})=>{let a=lr(i)-s,c=Io(i),d=y("dim","..."),p=Math.max(c-o,0),u=Math.max(Math.min(n,p),5),l=0;e>=u-3&&(l=Math.max(Math.min(e-u+3,t.length-u),0));let m=u<t.length&&l>0,h=u<t.length&&l+u<t.length,f=Math.min(l+u,t.length),x=[],_=0;m&&_++,h&&_++;let v=l+(m?1:0),C=f-(h?1:0);for(let w=v;w<C;w++){let L=Ce(r(t[w],w===e),a,{hard:!0,trim:!1}).split(`
|
|
286
|
+
`);x.push(L),_+=L.length}if(_>p){let w=0,L=0,O=_,R=e-v,F=(N,S)=>Qk(x,O,N,S,p);m?({lineCount:O,removals:w}=F(0,R),O>p&&({lineCount:O,removals:L}=F(R+1,x.length))):({lineCount:O,removals:L}=F(R+1,x.length),O>p&&({lineCount:O,removals:w}=F(0,R))),w>0&&(m=!0,x.splice(0,w)),L>0&&(h=!0,x.splice(x.length-L,L))}let E=[];m&&E.push(d);for(let w of x)for(let L of w)E.push(L);return h&&E.push(d),E};var ut=e=>{let t=e.active??"Yes",r=e.inactive??"No";return new Wi({active:t,inactive:r,signal:e.signal,input:e.input,output:e.output,initialValue:e.initialValue??!0,render(){let i=e.withGuide??Z.withGuide,n=`${en(this.state)} `,s=i?`${y("gray",$)} `:"",o=mr(e.output,e.message,s,n),a=`${i?`${y("gray",$)}
|
|
287
|
+
`:""}${o}
|
|
288
|
+
`,c=this.value?t:r;switch(this.state){case"submit":{let d=i?`${y("gray",$)} `:"";return`${a}${d}${y("dim",c)}`}case"cancel":{let d=i?`${y("gray",$)} `:"";return`${a}${d}${y(["strikethrough","dim"],c)}${i?`
|
|
289
|
+
${y("gray",$)}`:""}`}default:{let d=i?`${y("cyan",$)} `:"",p=i?y("cyan",Xe):"";return`${a}${d}${this.value?`${y("green",jo)} ${t}`:`${y("dim",Qi)} ${y("dim",t)}`}${e.vertical?i?`
|
|
290
|
+
${y("cyan",$)} `:`
|
|
291
|
+
`:` ${y("dim","/")} `}${this.value?`${y("dim",Qi)} ${y("dim",r)}`:`${y("green",jo)} ${r}`}
|
|
292
|
+
${p}
|
|
293
|
+
`}}}}).prompt()};var P={message:(e=[],{symbol:t=y("gray",$),secondarySymbol:r=y("gray",$),output:i=process.stdout,spacing:n=1,withGuide:s}={})=>{let o=[],a=s??Z.withGuide,c=a?r:"",d=a?`${t} `:"",p=a?`${r} `:"";for(let l=0;l<n;l++)o.push(c);let u=Array.isArray(e)?e:e.split(`
|
|
294
|
+
`);if(u.length>0){let[l,...m]=u;l.length>0?o.push(`${d}${l}`):o.push(a?t:"");for(let h of m)h.length>0?o.push(`${p}${h}`):o.push(a?r:"")}i.write(`${o.join(`
|
|
295
|
+
`)}
|
|
296
|
+
`)},info:(e,t)=>{P.message(e,{...t,symbol:y("blue",Hk)})},success:(e,t)=>{P.message(e,{...t,symbol:y("green",Kk)})},step:(e,t)=>{P.message(e,{...t,symbol:y("green",Zi)})},warn:(e,t)=>{P.message(e,{...t,symbol:y("yellow",Yk)})},warning:(e,t)=>{P.warn(e,t)},error:(e,t)=>{P.message(e,{...t,symbol:y("red",Jk)})}},G=(e="",t)=>{let r=t?.output??process.stdout,i=t?.withGuide??Z.withGuide?`${y("gray",Xe)} `:"";r.write(`${i}${y("red",e)}
|
|
297
|
+
|
|
298
|
+
`)};var lm=(e="",t)=>{let r=t?.output??process.stdout,i=t?.withGuide??Z.withGuide?`${y("gray",$)}
|
|
299
|
+
${y("gray",Xe)} `:"";r.write(`${i}${e}
|
|
300
|
+
|
|
301
|
+
`)};var eS=e=>y("dim",e),tS=(e,t,r)=>{let i={hard:!0,trim:!1},n=Ce(e,t,i).split(`
|
|
302
|
+
`),s=n.reduce((c,d)=>Math.max(ie(d),c),0),o=n.map(r).reduce((c,d)=>Math.max(ie(d),c),0),a=t-(o-s);return Ce(e,a,i)},ee=(e="",t="",r)=>{let i=r?.output??he.stdout,n=r?.withGuide??Z.withGuide,s=r?.format??eS,o=["",...tS(e,lr(i)-6,s).split(`
|
|
303
|
+
`).map(s),""],a=ie(t),c=Math.max(o.reduce((l,m)=>{let h=ie(m);return h>l?h:l},0),a)+2,d=o.map(l=>`${y("gray",$)} ${l}${" ".repeat(c-ie(l))}${y("gray",$)}`).join(`
|
|
304
|
+
`),p=n?`${y("gray",$)}
|
|
305
|
+
`:"",u=n?zk:Wk;i.write(`${p}${y("green",Zi)} ${y("reset",t)} ${y("gray",pm.repeat(Math.max(c-a-1,1))+Gk)}
|
|
306
|
+
${d}
|
|
307
|
+
${y("gray",u+pm.repeat(c+2)+Vk)}
|
|
308
|
+
`)},tn=e=>new Hi({validate:e.validate,mask:e.mask??Nk,signal:e.signal,input:e.input,output:e.output,render(){let t=e.withGuide??Z.withGuide,r=`${t?`${y("gray",$)}
|
|
309
|
+
`:""}${en(this.state)} ${e.message}
|
|
310
|
+
`,i=this.userInputWithCursor,n=this.masked;switch(this.state){case"error":{let s=t?`${y("yellow",$)} `:"",o=t?`${y("yellow",Xe)} `:"",a=n??"";return e.clearOnError&&this.clear(),`${r.trim()}
|
|
311
|
+
${s}${a}
|
|
312
|
+
${o}${y("yellow",this.error)}
|
|
313
|
+
`}case"submit":{let s=t?`${y("gray",$)} `:"",o=n?y("dim",n):"";return`${r}${s}${o}`}case"cancel":{let s=t?`${y("gray",$)} `:"",o=n?y(["strikethrough","dim"],n):"";return`${r}${s}${o}${n&&t?`
|
|
314
|
+
${y("gray",$)}`:""}`}default:{let s=t?`${y("cyan",$)} `:"",o=t?y("cyan",Xe):"";return`${r}${s}${i}
|
|
315
|
+
${o}
|
|
316
|
+
`}}}}).prompt();var rS=e=>y("magenta",e),z=({indicator:e="dots",onCancel:t,output:r=process.stdout,cancelMessage:i,errorMessage:n,frames:s=Ro?["\u25D2","\u25D0","\u25D3","\u25D1"]:["\u2022","o","O","0"],delay:o=Ro?80:120,signal:a,...c}={})=>{let d=Uk(),p,u,l=!1,m=!1,h="",f,x=performance.now(),_=lr(r),v=c?.styleFrame??rS,C=U=>{let ne=U>1?n??Z.messages.error:i??Z.messages.cancel;m=U===1,l&&(Pe(ne,U),m&&typeof t=="function"&&t())},E=()=>C(2),w=()=>C(1),L=()=>{process.on("uncaughtExceptionMonitor",E),process.on("unhandledRejection",E),process.on("SIGINT",w),process.on("SIGTERM",w),process.on("exit",C),a&&a.addEventListener("abort",w)},O=()=>{process.removeListener("uncaughtExceptionMonitor",E),process.removeListener("unhandledRejection",E),process.removeListener("SIGINT",w),process.removeListener("SIGTERM",w),process.removeListener("exit",C),a&&a.removeEventListener("abort",w)},R=()=>{if(f===void 0)return;d&&r.write(`
|
|
317
|
+
`);let U=Ce(f,_,{hard:!0,trim:!1}).split(`
|
|
318
|
+
`);U.length>1&&r.write(hr.cursor.up(U.length-1)),r.write(hr.cursor.to(0)),r.write(hr.erase.down())},F=U=>U.replace(/\.+$/,""),N=U=>{let ne=(performance.now()-U)/1e3,Oe=Math.floor(ne/60),Ie=Math.floor(ne%60);return Oe>0?`[${Oe}m ${Ie}s]`:`[${Ie}s]`},S=c.withGuide??Z.withGuide,Te=(U="")=>{l=!0,p=cm({output:r}),h=F(U),x=performance.now(),S&&r.write(`${y("gray",$)}
|
|
319
|
+
`);let ne=0,Oe=0;L(),u=setInterval(()=>{if(d&&h===f)return;R(),f=h;let Ie=v(s[ne]),fr;if(d)fr=`${Ie} ${h}...`;else if(e==="timer")fr=`${Ie} ${h} ${N(x)}`;else{let Qm=".".repeat(Math.floor(Oe)).slice(0,3);fr=`${Ie} ${h}${Qm}`}let Xm=Ce(fr,_,{hard:!0,trim:!1});r.write(Xm),ne=ne+1<s.length?ne+1:0,Oe=Oe<4?Oe+.125:0},o)},Pe=(U="",ne=0,Oe=!1)=>{if(!l)return;l=!1,clearInterval(u),R();let Ie=ne===0?y("green",Zi):ne===1?y("red",dm):y("red",um);h=U??h,Oe||(e==="timer"?r.write(`${Ie} ${h} ${N(x)}
|
|
320
|
+
`):r.write(`${Ie} ${h}
|
|
321
|
+
`)),O(),p()};return{start:Te,stop:(U="")=>Pe(U,0),message:(U="")=>{h=F(U??h)},cancel:(U="")=>Pe(U,1),error:(U="")=>Pe(U,2),clear:()=>Pe("",0,!0),get isCancelled(){return m}}},F1={light:j("\u2500","-"),heavy:j("\u2501","="),block:j("\u2588","#")};var Xi=(e,t)=>e.includes(`
|
|
322
|
+
`)?e.split(`
|
|
323
|
+
`).map(r=>t(r)).join(`
|
|
324
|
+
`):t(e),mm=e=>{let t=(r,i)=>{let n=r.label??String(r.value);switch(i){case"disabled":return`${y("gray",Qi)} ${Xi(n,s=>y("gray",s))}${r.hint?` ${y("dim",`(${r.hint??"disabled"})`)}`:""}`;case"selected":return`${Xi(n,s=>y("dim",s))}`;case"active":return`${y("green",jo)} ${n}${r.hint?` ${y("dim",`(${r.hint})`)}`:""}`;case"cancelled":return`${Xi(n,s=>y(["strikethrough","dim"],s))}`;default:return`${y("dim",Qi)} ${Xi(n,s=>y("dim",s))}`}};return new Ki({options:e.options,signal:e.signal,input:e.input,output:e.output,initialValue:e.initialValue,render(){let r=e.withGuide??Z.withGuide,i=`${en(this.state)} `,n=`${Xk(this.state)} `,s=mr(e.output,e.message,n,i),o=`${r?`${y("gray",$)}
|
|
325
|
+
`:""}${s}
|
|
326
|
+
`;switch(this.state){case"submit":{let a=r?`${y("gray",$)} `:"",c=mr(e.output,t(this.options[this.cursor],"selected"),a);return`${o}${c}`}case"cancel":{let a=r?`${y("gray",$)} `:"",c=mr(e.output,t(this.options[this.cursor],"cancelled"),a);return`${o}${c}${r?`
|
|
327
|
+
${y("gray",$)}`:""}`}default:{let a=r?`${y("cyan",$)} `:"",c=r?y("cyan",Xe):"",d=o.split(`
|
|
328
|
+
`).length,p=r?2:1;return`${o}${a}${Zk({output:e.output,cursor:this.cursor,options:this.options,maxItems:e.maxItems,columnPadding:a.length,rowPadding:d+p,style:(u,l)=>t(u,u.disabled?"disabled":l?"active":"inactive")}).join(`
|
|
329
|
+
${a}`)}
|
|
330
|
+
${c}
|
|
331
|
+
`}}}}).prompt()};var U1=`${y("gray",$)} `;var lt=e=>new Yi({validate:e.validate,placeholder:e.placeholder,defaultValue:e.defaultValue,initialValue:e.initialValue,output:e.output,signal:e.signal,input:e.input,render(){let t=e?.withGuide??Z.withGuide,r=`${`${t?`${y("gray",$)}
|
|
332
|
+
`:""}${en(this.state)} `}${e.message}
|
|
333
|
+
`,i=e.placeholder?y("inverse",e.placeholder[0])+y("dim",e.placeholder.slice(1)):y(["inverse","hidden"],"_"),n=this.userInput?this.userInputWithCursor:i,s=this.value??"";switch(this.state){case"error":{let o=this.error?` ${y("yellow",this.error)}`:"",a=t?`${y("yellow",$)} `:"",c=t?y("yellow",Xe):"";return`${r.trim()}
|
|
334
|
+
${a}${n}
|
|
335
|
+
${c}${o}
|
|
336
|
+
`}case"submit":{let o=s?` ${y("dim",s)}`:"",a=t?y("gray",$):"";return`${r}${a}${o}`}case"cancel":{let o=s?` ${y(["strikethrough","dim"],s)}`:"",a=t?y("gray",$):"";return`${r}${a}${o}${s.trim()?`
|
|
337
|
+
${a}`:""}`}default:{let o=t?`${y("cyan",$)} `:"",a=t?y("cyan",Xe):"";return`${r}${o}${n}
|
|
338
|
+
${a}
|
|
339
|
+
`}}}}).prompt();var hm=B(Nt(),1),Be=B(X(),1);function ym(e){let t=e.command("api-key").description("Manage API keys");t.command("create").description("Create an API key").option("--name <name>","key name").option("--type <type>","key type: publishable or secret").option("--scopes <scopes>","comma-separated scopes for secret keys (e.g. read_all or read_orders,write_products)").action(async r=>{let i=g(),n=r.name,s=r.type,o=r.scopes;if(!n){let m=await lt({message:"Key name:",placeholder:"My Storefront",validate(h){if(!h)return"Name is required"}});Y(m)&&(G("Cancelled."),process.exit(0)),n=m}if(!s){let m=await mm({message:"Key type:",options:[{value:"publishable",label:"Publishable (for storefronts)"},{value:"secret",label:"Secret (for server-to-server)"}]});Y(m)&&(G("Cancelled."),process.exit(0)),s=m}if(s!=="publishable"&&s!=="secret")throw new Error('Key type must be "publishable" or "secret".');if(s==="secret"&&!o){let m=await lt({message:"Scopes (comma-separated):",placeholder:"read_all",initialValue:"read_all",validate(h){if(!h)return"Secret keys require at least one scope"}});Y(m)&&(G("Cancelled."),process.exit(0)),o=m}let a=z();a.start("Creating API key...");let c=await Q("spree:cli:create_api_key",i.projectDir,{NAME:n,KEY_TYPE:s,...s==="secret"&&o?{SCOPES:o}:{}}),d=s==="publishable"?"pk_":"sk_",p=c.match(new RegExp(`${d}[A-Za-z0-9_-]+`)),u=p?p[0]:c.trim();a.stop("API key created.");let l=[`${Be.default.bold("Name:")} ${n}`,`${Be.default.bold("Type:")} ${s}`,`${Be.default.bold("Token:")} ${Be.default.cyan(u)}`];s==="secret"&&(l.push(`${Be.default.bold("Scopes:")} ${o}`),l.push(""),l.push(Be.default.yellow("Save this token now \u2014 secret keys cannot be retrieved later."))),ee(l.join(`
|
|
340
|
+
`),"API Key")}),t.command("list").description("List API keys").action(async()=>{let r=g(),i=z();i.start("Fetching API keys...");let n=await Q("spree:cli:list_api_keys",r.projectDir);i.stop("");let s=n.trim().split(`
|
|
341
|
+
`).filter(Boolean);if(s.length===0){P.info("No API keys found.");return}let o=s.map(a=>{let[c,d,p,u,l,m]=a.split("|");return{ID:c??"",Name:d??"",Type:p??"",Token:u??"",Created:l??"",Status:m==="active"?Be.default.green(m):Be.default.red(m??"")}});(0,hm.printTable)(o)}),t.command("revoke").description("Revoke an API key").argument("<id>","ID of the key to revoke (from api-key list)").action(async r=>{let i=g(),n=z();n.start("Revoking API key...");let o=(await Q("spree:cli:revoke_api_key",i.projectDir,{ID:r})).trim();n.stop(`API key "${o}" revoked.`)})}var fm=B(Nt(),1),J=B(X(),1);function gm(e){let t=e.command("auth").description("Manage Admin API credentials (profiles in ~/.config/spree)");t.command("login").description("Save a secret API key as a named profile").option("--profile <name>","profile name","default").option("--base-url <url>","store URL, e.g. https://store.example.com").action(async r=>{process.stdin.isTTY||(process.stderr.write(`${J.default.red("error:")} \`spree auth login\` is interactive. For non-interactive use, set SPREE_BASE_URL + SPREE_API_KEY (or pass --base-url/--api-key to \`spree api\`).
|
|
342
|
+
`),process.exit(2));let i=r.baseUrl;if(!i){let d=await lt({message:"Store URL:",placeholder:"https://store.example.com",validate(p){if(!p)return"URL is required";if(!/^https?:\/\//.test(p))return"Must start with http:// or https://"}});Y(d)&&(G("Cancelled."),process.exit(130)),i=d}i=i.replace(/\/$/,"");let n=await tn({message:"Secret API key (sk_...):",validate(d){if(!d)return"Key is required";if(!d.startsWith("sk_"))return"Admin API keys start with sk_"}});Y(n)&&(G("Cancelled."),process.exit(130));let s=n,o=z();o.start("Validating credentials...");let a=await ur(i,s);a.status==="unauthorized"&&(o.stop(J.default.red("The server rejected this key (401). Check the key and try again.")),process.exit(2)),a.status==="unreachable"&&(o.stop(J.default.red(`Could not reach ${i}: ${a.message}`)),process.exit(2)),o.stop(a.storeName?`Connected to ${J.default.bold(a.storeName)}.`:"Credentials accepted (key lacks read_settings, so the store name is hidden \u2014 that is fine).");let c=ar();c.profiles[r.profile]={baseUrl:i,token:s},c.defaultProfile||=r.profile,ko(c),ee([`${J.default.bold("Profile:")} ${r.profile}${c.defaultProfile===r.profile?J.default.dim(" (default)"):""}`,`${J.default.bold("Base URL:")} ${i}`,`${J.default.bold("Key:")} ${Fi(s)}${J.default.dim("\u2026")}`,"",J.default.dim(`Saved to ${pt()}`)].join(`
|
|
343
|
+
`),"Logged in")}),t.command("status").description("Show which credentials `spree api` would use, and verify them").option("--profile <name>","check a specific profile").action(async r=>{let i;try{i=await cr({profile:r.profile},{allowMint:!1})}catch(a){dt(a)}let n=z();n.start("Checking server...");let s=await ur(i.baseUrl,i.apiKey);n.stop("");let o=Bi(s);ee([`${J.default.bold("Source:")} ${i.source}${i.profileName?` (${i.profileName})`:""}`,`${J.default.bold("Base URL:")} ${i.baseUrl}`,`${J.default.bold("Key:")} ${i.tokenPrefix}${J.default.dim("\u2026")}`,...i.scopes?[`${J.default.bold("Scopes:")} ${i.scopes.join(", ")}`]:[],`${J.default.bold("Server:")} ${o}`].join(`
|
|
344
|
+
`),"Auth status"),Ui(s)&&(process.exitCode=1)}),t.command("logout").description("Remove a saved profile (or the project credentials)").option("--profile <name>","profile to remove","default").option("--project","remove .spree/credentials.json from the current project instead").action(async r=>{if(r.project){let n;try{n=g().projectDir}catch(o){dt(o)}(await import("fs")).rmSync(Mi(n),{force:!0}),P.success("Removed project credentials. The next `spree api` call mints a fresh read-only key.");return}let i=ar();if(!i.profiles[r.profile]){let n=Object.keys(i.profiles),s=n.length?` Saved profiles: ${n.join(", ")}.`:" No profiles are saved.";process.stderr.write(`${J.default.red("error:")} no profile named "${r.profile}".${s}
|
|
345
|
+
`),process.exit(2)}delete i.profiles[r.profile],i.defaultProfile===r.profile&&(i.defaultProfile=Object.keys(i.profiles)[0]),ko(i),P.success(`Removed profile "${r.profile}". The key itself stays active \u2014 revoke it with \`spree api-key revoke\` or in the admin.`)}),t.command("list").description("List saved profiles").action(()=>{let r=ar(),i=Object.keys(r.profiles);if(i.length===0){P.info("No profiles saved. Run `spree auth login` to add one.");return}(0,fm.printTable)(i.map(n=>({Profile:r.defaultProfile===n?`${n} *`:n,"Base URL":r.profiles[n].baseUrl,Key:`${Fi(r.profiles[n].token)}\u2026`})))})}import _m from"fs";import bm from"path";var Qe=B(X(),1);function xm(e){e.command("build").description("Rebuild the dev image (after Dockerfile / .ruby-version changes)").option("--reset-bundle","also wipe the bundle_cache volume to re-seed gems").option("--yes","skip confirmation prompts (for CI)").action(async t=>{let r=g();if(gt(r.projectDir)&&(G(["This project uses SPREE_PATH for monorepo development.",`Use ${Qe.default.bold("pnpm server:build")} from the monorepo root instead of ${Qe.default.bold("spree build")}.`,"It builds against the edge compose overlay the running stack was started with."].join(`
|
|
346
|
+
`)),process.exit(1)),iS(r.projectDir)||(console.error(`
|
|
347
|
+
${Qe.default.red("Error:")} docker-compose.yml has no \`build:\` section. Run ${Qe.default.bold("spree eject")} first to switch to a build-from-source stack.
|
|
348
|
+
`),process.exit(1)),t.resetBundle){if(!t.yes){let n=await ut({message:"Wipe the bundle_cache volume? Any gems added via `spree bundle add` since the last image build will be lost.",initialValue:!1});(Y(n)||!n)&&(G("Build cancelled."),process.exit(0))}let i=z();i.start("Wiping bundle_cache volume...");try{await K(["down"],r.projectDir,{stdio:"ignore"});let s=`${await nS(r.projectDir)}_bundle_cache`;await sS(s,r.projectDir)?(await me("docker",["volume","rm",s],{cwd:r.projectDir,stdio:"ignore"}),i.stop("bundle_cache volume wiped.")):i.stop(`bundle_cache volume not present (looked for ${s}).`)}catch(n){throw i.stop("Failed to wipe bundle_cache volume."),n}}console.log(`
|
|
349
|
+
${Qe.default.bold("Rebuilding dev image...")}
|
|
350
|
+
`),await K(["build","web","worker"],r.projectDir,{stdio:"inherit"}),ee([`Image rebuilt. Start the stack with ${Qe.default.bold("spree dev")}.`,t.resetBundle?`On next boot, gems will re-seed into a fresh ${Qe.default.dim("bundle_cache")} volume.`:""].filter(Boolean).join(`
|
|
351
|
+
`),"Build complete")})}function iS(e){let t=bm.join(e,"docker-compose.yml");return _m.existsSync(t)?/^\s*build\s*:/m.test(_m.readFileSync(t,"utf-8")):!1}async function nS(e){try{let{stdout:t}=await me("docker",["compose","config","--format","json"],{cwd:e}),r=JSON.parse(t);if(r.name)return r.name}catch{}return bm.basename(e).toLowerCase().replace(/[^a-z0-9_-]/g,"")}async function sS(e,t){try{return await me("docker",["volume","inspect",e],{cwd:t,stdio:"ignore"}),!0}catch{return!1}}var wm=B(X(),1);function km(e){e.command("bundle").description("Run a bundler command (`bundle \u2026`) inside the web container").argument("<args...>","arguments to pass to bundle").allowUnknownOption(!0).passThroughOptions(!0).action(async t=>{let r=g();if(await Al("web",r.projectDir)){await I(["bundle",...t],r.projectDir);return}gt(r.projectDir)&&(G(["The web container is not running, and this is a monorepo edge project.",`Run ${wm.default.bold("pnpm server:dev")} from the monorepo root \u2014 the edge stack heals gem drift on boot.`].join(`
|
|
352
|
+
`)),process.exit(1)),P.info("web container is not running \u2014 using a one-off container (`docker compose run`) instead."),await K(["run","--rm","web","bundle",...t],r.projectDir,{stdio:"inherit"})})}var Sm=["/admin_users","/allowed_origins","/api_keys","/auth","/channels","/custom_field_definitions","/customer_groups","/customers","/exports","/gift_card_batches","/gift_cards","/invitations","/markets","/me","/option_types","/orders","/payment_methods","/price_lists","/prices","/products","/promotion_actions","/promotion_rules","/promotions","/roles","/stock_locations","/store","/store_credit_categories","/tags","/webhook_endpoints"];var vm=["bash","zsh","fish"],aS=["eq","not_eq","cont","not_cont","start","end","in","not_in","gt","gteq","lt","lteq","null","not_null","present","blank"],cS=["get","post","patch","delete","endpoints","schema","status"],pS=["read_all","write_all","read_orders","write_orders","read_products","write_products","read_promotions","write_promotions","read_customers","write_customers","read_payments","write_payments","read_fulfillments","write_fulfillments","read_refunds","write_refunds","read_gift_cards","write_gift_cards","read_store_credits","write_store_credits","read_stock","write_stock","read_categories","write_categories","read_settings","write_settings","read_webhooks","write_webhooks","read_api_keys","write_api_keys","read_dashboard"];function dS(e){let[t,r,...i]=e,n=e[e.length-1]??"",s=e[e.length-2]??"";if(e.length<=1)return rn(["api","auth",...uS],n);if((s==="-q"||s==="--query")&&n.includes("_")&&!n.includes("=")){let o=n.slice(0,n.lastIndexOf("_")+1);return aS.map(a=>`${o}${a}=`)}if(s==="--scopes"){let o=n.includes(",")?n.slice(n.lastIndexOf(",")+1):n,a=n.slice(0,n.length-o.length);return rn(pS,o).map(c=>a+c)}if(t==="api"){if(e.length===2)return rn(cS,n);if(["get","post","patch","delete","schema"].includes(r)&&i.length<=1)return rn(Sm,n)}return[]}var uS=["api-key","dev","console","migrate"];function rn(e,t){return t?e.filter(r=>r.startsWith(t)):e}function lS(e){return e==="fish"?`# spree fish completion \u2014 eval "$(spree completion fish)"
|
|
353
|
+
function __spree_complete
|
|
354
|
+
set -l tokens (commandline -opc) (commandline -ct)
|
|
355
|
+
spree __complete $tokens[2..-1]
|
|
356
|
+
end
|
|
357
|
+
complete -c spree -f -a '(__spree_complete)'
|
|
358
|
+
`:e==="zsh"?`# spree zsh completion \u2014 eval "$(spree completion zsh)"
|
|
359
|
+
_spree() {
|
|
360
|
+
local -a completions
|
|
361
|
+
completions=(\${(f)"$(spree __complete \${words[2,$CURRENT]})"})
|
|
362
|
+
compadd -- $completions
|
|
363
|
+
}
|
|
364
|
+
compdef _spree spree
|
|
365
|
+
`:`# spree bash completion \u2014 eval "$(spree completion bash)"
|
|
366
|
+
_spree() {
|
|
367
|
+
local words=("\${COMP_WORDS[@]:1:$COMP_CWORD}")
|
|
368
|
+
COMPREPLY=( $(spree __complete "\${words[@]}") )
|
|
369
|
+
}
|
|
370
|
+
complete -F _spree spree
|
|
371
|
+
`}function qm(e){e.command("completion <shell>").description("Output a shell completion script (bash, zsh, or fish)").action(t=>{if(!vm.includes(t)){process.stderr.write(`Unsupported shell "${t}". Choose one of: ${vm.join(", ")}.
|
|
372
|
+
`),process.exitCode=2;return}process.stdout.write(lS(t))}),e.command("__complete",{hidden:!0}).allowUnknownOption().argument("[words...]").action(t=>{for(let r of dS(t??[]))process.stdout.write(`${r}
|
|
373
|
+
`)})}function $m(e){e.command("console").description("Open Rails console").action(async()=>{let t=g();await I(["bin/rails","console"],t.projectDir)})}function Cm(e){e.command("db:reset").description("Drop, create, migrate, and seed the dev database (destructive)").option("--yes","skip the confirmation prompt (for CI)").action(async t=>{let r=g();if(!t.yes){let i=await ut({message:"This will drop the spree_development database. Continue?",initialValue:!1});(Y(i)||!i)&&(G("Cancelled."),process.exit(0))}await I(["bin/rails","db:drop","db:create","spree:install:migrations","db:migrate","db:seed"],r.projectDir)}),e.command("db:console").description("Open a psql session against the dev database").action(async()=>{let t=g();await I(["psql","-U","postgres","spree_development"],t.projectDir,{service:"postgres"})})}var Ae=B(X(),1);function Am(e){e.command("dev").description("Run the app in the foreground \u2014 streams web + worker logs; Ctrl+C stops them").action(async()=>{let t=g();gt(t.projectDir)&&(G(["This project uses SPREE_PATH for monorepo development.",`Use ${Ae.default.bold("pnpm server:dev")} from the monorepo root instead of ${Ae.default.bold("spree dev")}.`,"It loads the edge compose overlay and sets SPREE_PATH so the Spree gems resolve to the monorepo source."].join(`
|
|
374
|
+
`)),process.exit(1)),ee(["",Ae.default.bold("Admin Dashboard"),` ${Ae.default.cyan(`http://localhost:${t.port}/admin`)}`,` Email: ${vr}`,` Password: ${qr}`,"",Ae.default.bold("Store API"),` ${Ae.default.cyan(`http://localhost:${t.port}/api/v3/store`)}`,""].join(`
|
|
375
|
+
`),"Spree Commerce"),P.info(`Starting services \u2014 web + worker logs stream below. ${Ae.default.bold("Ctrl+C")} stops them (databases keep running; ${Ae.default.bold("spree stop")} shuts everything down).
|
|
376
|
+
`);let r=()=>{};process.on("SIGINT",r);let i;try{i=await K(["up","web","worker"],t.projectDir,{stdio:"inherit",reject:!1})}finally{process.off("SIGINT",r)}let n=i.exitCode??0;n!==0&&n!==130&&(G(`docker compose exited with code ${n} \u2014 see the output above.`),process.exit(n)),lm(`Web + worker stopped. Databases keep running \u2014 ${Ae.default.bold("spree stop")} shuts everything down.`)})}import yr from"fs";import Do from"path";var ce=B(X(),1);function Em(e){e.command("eject").description("Switch to the dev compose: bind-mount ./backend with hot reload").action(async()=>{let t=g(),r=Do.join(t.projectDir,"backend");yr.existsSync(r)||(console.error(`
|
|
377
|
+
${ce.default.red("Error:")} No backend/ directory found.
|
|
378
|
+
`),process.exit(1));let i=Do.join(t.projectDir,"docker-compose.dev.yml");yr.existsSync(i)||(console.error(`
|
|
379
|
+
${ce.default.red("Error:")} No docker-compose.dev.yml found.
|
|
380
|
+
`),process.exit(1));let n=yr.readFileSync(i,"utf-8");n.includes("- .:/rails")&&(n=n.replace("- .:/rails","- ./backend:/rails"),yr.writeFileSync(i,n)),yr.writeFileSync(Do.join(t.projectDir,"docker-compose.yml"),n),console.log(`
|
|
381
|
+
${ce.default.bold("Switching to dev compose (bind-mounts ./backend)...")}
|
|
382
|
+
`),await K(["up","-d"],t.projectDir,{stdio:"inherit"}),console.log(`
|
|
383
|
+
${ce.default.bold("Preparing the development database...")}
|
|
384
|
+
`),await I(["bin/rails","db:prepare"],t.projectDir,{tty:!1}),ee([`Backend is now bind-mounted from ${ce.default.bold("./backend")} \u2014 edits are live.`,"",`The dev stack uses its own ${ce.default.bold("spree_development")} database (just`,`created and seeded). Load demo products with ${ce.default.bold("spree sample-data")}.`,"","You can now customize:",` ${ce.default.dim("backend/app/")} \u2014 models, controllers, services (instant reload)`,` ${ce.default.dim("backend/config/")} \u2014 Rails configuration (instant reload)`,` ${ce.default.dim("backend/Gemfile")} \u2014 add gems via ${ce.default.bold("spree bundle add <gem>")}`,"",`Rebuild only on Dockerfile / .ruby-version changes: ${ce.default.bold("spree build")}`].join(`
|
|
385
|
+
`),"Ejected!")})}function Tm(e){e.command("exec").description("Run an arbitrary command inside the web container").argument("<command...>","command and arguments to run").allowUnknownOption(!0).passThroughOptions(!0).action(async t=>{let r=g();await I(t,r.projectDir)})}var mS=new Set(["migration","controller","scaffold","scaffold_controller","mailer","job","channel","helper","resource","integration_test","system_test","task","generator","benchmark"]);function Pm(e){e.command("generate").alias("g").description("Run a generator (Spree generators auto-prefixed; Rails built-ins forwarded as-is)").argument("<name>","generator name (`model`, `model_decorator`, `migration`, \u2026)").argument("[args...]","arguments to pass to the generator").allowUnknownOption(!0).passThroughOptions(!0).action(async(t,r)=>{let i=g(),n=t.includes(":")||mS.has(t)?t:`spree:${t}`;await I(["bin/rails","g",n,...r],i.projectDir)})}import Lo from"fs";import{platform as hS}from"os";import yS from"path";var mt=B(X(),1);var fS=3e3,Om=12e4;function Im(e){e.command("init").description("First-run setup: start services, configure API key, load sample data").option("--no-sample-data","skip loading sample data").option("--no-open","skip opening browser").action(async t=>{let r=g();P.step("Pulling latest images..."),await K(["pull"],r.projectDir,{stdio:"inherit"});let i=z();i.start("Starting Docker services..."),await K(["up","-d"],r.projectDir),i.stop("Docker services started."),i.start("Waiting for Spree to be ready..."),await gS(r.port),i.stop("Spree is ready."),i.start("Seeding database..."),await Q("db:seed",r.projectDir),i.stop("Database seeded."),i.start("Configuring API key...");let n=await _S(r.projectDir);bS(r.projectDir,n),i.stop(`API key: ${mt.default.cyan(n)}`),t.sampleData&&(i.start("Loading sample data..."),await Q("spree:load_sample_data",r.projectDir),i.stop("Sample data loaded.")),i.start("Indexing products for search..."),await Q("spree:search:reindex",r.projectDir),i.stop("Search index ready."),ee(["",mt.default.bold("Admin Dashboard"),` ${mt.default.cyan(`http://localhost:${r.port}/admin`)}`,` Email: ${vr}`,` Password: ${qr}`,"",mt.default.bold("Store API"),` ${mt.default.cyan(`http://localhost:${r.port}/api/v3/store`)}`,` API Key: ${mt.default.cyan(n)}`,""].join(`
|
|
386
|
+
`),"Your Spree store is ready!"),t.open&&await xS(`http://localhost:${r.port}/admin`),P.info(`Streaming logs (Ctrl+C to stop)...
|
|
387
|
+
`),await Li("web",r.projectDir)})}async function gS(e){let t=`http://localhost:${e}/up`,r=Date.now();for(;Date.now()-r<Om;){try{if((await fetch(t)).ok)return}catch{}await new Promise(i=>setTimeout(i,fS))}throw new Error(`Spree did not become healthy within ${Om/1e3}s`)}async function _S(e){let t=await Q("spree:cli:ensure_api_key",e),r=t.match(/pk_[A-Za-z0-9_-]+/);if(!r)throw new Error(`Could not extract API key from Rails output: ${t}`);return r[0]}function bS(e,t){let r=yS.join(e,"apps","storefront",".env.local");if(!Lo.existsSync(r))return;let i=Lo.readFileSync(r,"utf-8");Lo.writeFileSync(r,i.replace(/SPREE_PUBLISHABLE_KEY=.*/,`SPREE_PUBLISHABLE_KEY=${t}`))}async function xS(e){let t=hS(),r=t==="darwin"?"open":t==="win32"?"start":"xdg-open";try{await Di(`${r} ${e}`,{stdio:"ignore"})}catch{}}function Rm(e){e.command("logs").description("Stream service logs").argument("[service]","service name (web or worker)","web").action(async t=>{let r=g();await Li(t,r.projectDir)})}var nn=B(X(),1);function jm(e){e.command("migrate").description("Install pending Spree migrations from gems, then run them (`spree:install:migrations` + `db:migrate`)").argument("[args...]","extra args forwarded to db:migrate").allowUnknownOption(!0).passThroughOptions(!0).action(async t=>{let r=g();console.log(`
|
|
388
|
+
${nn.default.bold("\u2192 Installing pending Spree migrations from gems...")}`),await I(["bin/rails","spree:install:migrations"],r.projectDir),console.log(`
|
|
389
|
+
${nn.default.bold("\u2192 Running db:migrate...")}`),await I(["bin/rails","db:migrate",...t],r.projectDir),ee(`Run ${nn.default.bold("spree migrate:status")} to inspect the migration log.`,"Migrations up to date")}),e.command("migrate:rollback").description("Roll back the last migration (`STEP=n` to roll back n steps)").argument("[args...]","extra args forwarded to db:rollback (e.g. STEP=2)").allowUnknownOption(!0).passThroughOptions(!0).action(async t=>{let r=g();await I(["bin/rails","db:rollback",...t],r.projectDir)}),e.command("migrate:status").description("Show migration status (`bin/rails db:migrate:status`)").action(async()=>{let t=g();await I(["bin/rails","db:migrate:status"],t.projectDir)})}import{platform as wS}from"os";function Dm(e){e.command("open").description("Open the admin dashboard in the browser").action(async()=>{let r=`http://localhost:${g().port}/admin`,i=wS();await Di(`${i==="darwin"?"open":i==="win32"?"start":"xdg-open"} ${r}`)})}function Lm(e){e.command("rails").description("Run a Rails command (`bin/rails \u2026`) inside the web container").argument("<args...>","arguments to pass to bin/rails").allowUnknownOption(!0).passThroughOptions(!0).action(async t=>{let r=g();await I(["bin/rails",...t],r.projectDir)})}function Mm(e){e.command("rake").description("Run a rake task (`bin/rake \u2026`) inside the web container").argument("<args...>","task name and arguments").allowUnknownOption(!0).passThroughOptions(!0).action(async t=>{let r=g();await I(["bin/rake",...t],r.projectDir)})}function Fm(e){e.command("restart").description("Restart web + worker in place (does not reload Gemfile or compose changes)").action(async()=>{let t=g(),r=z();r.start("Restarting web + worker...");try{await K(["restart","web","worker"],t.projectDir),r.stop("Services restarted.")}catch(i){throw r.stop("Restart failed."),i}})}function Um(e){e.command("routes").description("Show Rails routes (`bin/rails routes`)").argument("[args...]","arguments to pass to bin/rails routes").allowUnknownOption(!0).passThroughOptions(!0).action(async t=>{let r=g();await I(["bin/rails","routes",...t],r.projectDir)})}function Bm(e){e.command("sample-data").description("Load sample data (products, categories, images)").action(async()=>{let t=g(),r=z();r.start("Loading sample data..."),await Q("spree:load_sample_data",t.projectDir),r.stop("Sample data loaded.")})}function Nm(e){e.command("seed").description("Seed the database").action(async()=>{let t=g(),r=z();r.start("Seeding database..."),await Q("db:seed",t.projectDir),r.stop("Database seeded.")})}function Gm(e){e.command("stop").description("Stop services").action(async()=>{let t=g(),r=z();r.start("Stopping services..."),await K(["stop"],t.projectDir),r.stop("Services stopped.")})}function zm(e){e.command("task").description("Run a Spree rake task (auto-prefixes `spree:`)").argument("<name>","task name (without `spree:` prefix)").argument("[args...]","arguments to pass to the task").allowUnknownOption(!0).passThroughOptions(!0).action(async(t,r)=>{let i=g();await I(["bin/rake",`spree:${t}`,...r],i.projectDir)})}function Vm(e){e.command("update").description("Pull latest image and recreate containers").action(async()=>{let t=g();P.step("Pulling latest images..."),await K(["pull"],t.projectDir,{stdio:"inherit"});let r=z();r.start("Recreating containers..."),await K(["up","-d"],t.projectDir),r.stop("Containers recreated."),P.success("Update complete! Migrations will run automatically on startup."),P.info("Run `spree logs` to follow the startup progress.")})}import Wm from"fs";import kS from"path";var Ee=B(X(),1);function Hm(e){e.command("upgrade").description("Walk through a Spree version upgrade (bundle + migrate + spree:upgrade)").option("--plan","print the plan via spree:upgrade DRY_RUN=1; skip bundle + migrate").option("--step <id>","run a single rake step by id (skips bundle + migrate)").option("--to <version>","explicit target version (auto-detected from installed gem otherwise)").option("--yes","skip prompts on automated steps").action(async t=>{let r=g();t.plan||t.step||(await SS(r.projectDir,t),await qS(r.projectDir,t)),await $S(r.projectDir,t),t.plan||AS(r.projectDir)})}async function SS(e,t){if(!t.yes){let i=await ut({message:"Run `bundle update` to bump Spree gems?",initialValue:!0});if(Y(i)&&(G("Upgrade aborted."),process.exit(0)),!i){P.info("Skipping `bundle update`.");return}}let r=await vS(e);if(r.length===0)throw new Error('No Spree gems detected in Gemfile.lock. Confirm the project has `gem "spree"` (or `spree_core`/`spree_admin`) in its Gemfile.');P.step(Ee.default.bold(`bundle update ${r.join(" ")}`)),await I(["bundle","update",...r],e)}async function vS(e){let{stdout:t}=await me("docker",["compose","exec","-T","web","sh","-c","bundle list --name-only 2>/dev/null | grep '^spree' || true"],{cwd:e});return t.split(`
|
|
390
|
+
`).map(r=>r.trim()).filter(r=>r.length>0&&r.startsWith("spree"))}async function qS(e,t){if(!t.yes){let r=await ut({message:"Install + run pending migrations?",initialValue:!0});if(Y(r)&&(G("Upgrade aborted."),process.exit(0)),!r){P.info("Skipping migrations.");return}}P.step(Ee.default.bold("spree:install:migrations + db:migrate")),await I(["bin/rails","spree:install:migrations","db:migrate"],e)}async function $S(e,t){let r={};t.plan&&(r.DRY_RUN="1"),t.step&&(r.STEP=t.step),t.to&&(r.TO=t.to),P.step(Ee.default.bold("spree:upgrade")),await I(["bin/rake","spree:upgrade"],e,{env:r})}function CS(e){let t="Update @spree/sdk in any storefront or integration consuming the API",r=kS.join(e,"apps","storefront","package.json");if(!Wm.existsSync(r))return t;try{let i=JSON.parse(Wm.readFileSync(r,"utf-8")),n=i.dependencies?.["@spree/sdk"]??i.devDependencies?.["@spree/sdk"];return n?`Update @spree/sdk in apps/storefront (currently ${n}) to the release matching the new Spree version`:t}catch{return t}}function AS(e){ee([`The manifest only ran ${Ee.default.bold("rake-automatable")} steps.`,"","Don't forget the manual parts from the upgrade doc:",` ${Ee.default.dim("- Schedule Spree::StockReservations::ExpireJob (cron)")}`,` ${Ee.default.dim(`- ${CS(e)}`)}`,` ${Ee.default.dim("- Review behavior changes (cart, availability, payment-method types)")}`,` ${Ee.default.dim("- Audit custom decorators against renamed APIs")}`,"",`Full checklist: ${Ee.default.cyan("https://spreecommerce.org/docs/developer/upgrades")}`].join(`
|
|
391
|
+
`),"Next steps")}var Km=B(X(),1);function Ym(e){e.command("user").description("Manage admin users").command("create").description("Create an admin user").option("--email <email>","admin email").option("--password <password>","admin password").action(async r=>{let i=g(),n=r.email,s=r.password;if(!n){let a=await lt({message:"Admin email:",placeholder:"admin@example.com",validate(c){if(!c)return"Email is required";if(!c.includes("@"))return"Invalid email"}});Y(a)&&(G("Cancelled."),process.exit(0)),n=a}if(!s){let a=await tn({message:"Admin password:",validate(c){if(!c||c.length<6)return"Password must be at least 6 characters"}});Y(a)&&(G("Cancelled."),process.exit(0)),s=a}let o=z();o.start("Creating admin user..."),await Q("spree:cli:create_admin",i.projectDir,{EMAIL:n,PASSWORD:s}),o.stop("Admin user created."),P.success(`Email: ${Km.default.cyan(n)}`)})}var D=new Qo().name("spree").description("CLI for managing Spree Commerce projects").version("2.0.0").enablePositionalOptions().showSuggestionAfterError(!0).showHelpAfterError("(run `spree --help` for usage)").exitOverride(e=>{(e.code.startsWith("commander.help")||e.code==="commander.version")&&process.exit(0),process.exit(2)});Im(D);Am(D);Gm(D);Fm(D);Vm(D);Rm(D);Em(D);xm(D);Pm(D);jm(D);Cm(D);Um(D);Hm(D);Tm(D);Lm(D);km(D);Mm(D);zm(D);$m(D);Ym(D);ym(D);Dm(D);Nm(D);Bm(D);zl(D);gm(D);qm(D);async function ES(){try{await D.parseAsync()}catch(e){e instanceof Error&&"code"in e&&(e.code==="commander.helpDisplayed"||e.code==="commander.version")&&process.exit(0),e instanceof Error&&"code"in e&&String(e.code).startsWith("commander.")&&process.exit(2);let t=e instanceof Error&&e.constructor.name==="CredentialError"?2:1,r=e instanceof Error?e.message:"An unexpected error occurred.";console.error(`
|
|
392
|
+
${Jm.default.red("Error:")} ${r}
|
|
393
|
+
`),process.exit(t)}}ES();
|