@commercelayer/cli-core 6.0.0-beta.8 → 6.0.0-oclif4.10

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/lib/index.mjs CHANGED
@@ -1,9 +1,9 @@
1
- var xe=Object.defineProperty;var h=(e,t)=>{for(var r in t)xe(e,r,{get:t[r],enumerable:!0})};var Z={};h(Z,{Operation:()=>L,baseURL:()=>qe,execMode:()=>Ee,extractDomain:()=>Re,humanizeResource:()=>Se,isResourceCacheable:()=>Y,liveEnvironment:()=>Ie,request:()=>Oe,requestDataFile:()=>D,requestRateLimitDelay:()=>X,requestRaw:()=>j,response:()=>Ke,responseDenormalize:()=>P});var M=["in_progress","pending","completed","interrupted"],ve=["addresses","bundles","coupons","customer_addresses","customer_payment_sources","customer_subscriptions","customers","gift_cards","line_items","line_item_options","orders","price_tiers","prices","shipping_categories","sku_lists","sku_list_items","sku_options","skus","stock_items","stock_transfers","tags","tax_categories"],we=["addresses","authorizations","bundles","captures","coupons","customer_addresses","customer_payment_sources","customer_subscriptions","customers","gift_cards","line_items","line_item_options","orders","payment_methods","price_tiers","prices","refunds","returns","shipments","shipping_categories","shipping_methods","sku_lists","sku_list_items","sku_options","skus","stock_items","stock_transfers","tags","tax_categories","transactions","voids"],ke=["bundles","gift_cards","prices","promotions","sku_lists","sku_options","skus","stock_items"],Te=["addresses","bundles","customers","coupons","gift_cards","line_items","line_item_options","orders","returns","skus","sku_options","promotions","external_promotions","fixed_amount_promotions","fixed_price_promotions","free_gift_promotions","free_shipping_promotions","percentage_discount_promotions"],Ae=["orders","skus","sku_lists"],b={erl_oauth_limit_live:30,erl_average_limit_cachable_live:1e3,erl_average_limit_cachable_test:500,erl_burst_limit_cachable_live:250,erl_burst_limit_cachable_test:125,erl_average_limit_uncachable_live:200,erl_average_limit_uncachable_test:100,erl_burst_limit_uncachable_live:50,erl_burst_limit_uncachable_test:25},$e={api:{default_domain:"commercelayer.io",default_app_domain:"commercelayer.app",default_stg_domain:"commercelayer.co",token_expiration_mins:240,token_encoding_algorithm:"HS512",token_owner_types:["Customer","User"],requests_max_num_burst:b.erl_burst_limit_uncachable_live,requests_max_num_burst_cacheable:b.erl_burst_limit_cachable_live,requests_max_num_burst_test:b.erl_burst_limit_uncachable_test,requests_max_num_burst_test_cacheable:b.erl_burst_limit_cachable_test,requests_max_num_avg:b.erl_average_limit_uncachable_live,requests_max_num_avg_cacheable:b.erl_average_limit_cachable_live,requests_max_num_avg_test:b.erl_average_limit_uncachable_test,requests_max_num_avg_test_cacheable:b.erl_average_limit_cachable_test,requests_max_num_oauth:b.erl_oauth_limit_live,requests_max_secs_burst:10,requests_max_secs_oauth:60,requests_max_secs_avg:60,page_max_size:25,page_default_size:10},application:{kinds:["dashboard","user","metrics","contentful","bundles","customers","datocms","exports","external","gift_cards","imports","integration","inventory","orders","price_lists","promotions","resources","returns","sales_channel","sanity","shipments","skus","sku_lists","stock_transfers","subscriptions","tags","webapp","webhooks","zapier"],login_scopes:["market","stock_location","store"]},imports:{max_size:1e4,statuses:M,types:ve,max_queue_length:10,attachment_expiration:5},exports:{max_size:5e3,statuses:M,types:we,max_queue_length:10,attachment_expiration:5},cleanups:{max_size:1e4,statuses:M,types:ke,max_queue_length:10},webhooks:{retry_number:5},cli:{applications:["integration","sales_channel","user"]},doc:{core:"https://docs.commercelayer.io/core/",core_api_reference:"https://docs.commercelayer.io/developers/v/api-reference",core_how_tos:"https://docs.commercelayer.io/core/v/how-tos/",core_raste_limits:"https://docs.commercelayer.io/core/rate-limits",core_filtering_data:"https://docs.commercelayer.io/core/filtering-data#list-of-predicates",metrics:"https://docs.commercelayer.io/metrics/",metrics_api_reference:"https://docs.commercelayer.io/metrics/v/api-reference-m/",provisioning:"https://docs.commercelayer.io/provisioning/",provisioning_api_reference:"https://docs.commercelayer.io/provisioning/v/api-reference-p/",imports_resources:"https://docs.commercelayer.io/api/importing-resources#supported-resources",exports_resources:"https://docs.commercelayer.io/core/exporting-resources#supported-resources",cleanups_resources:"https://docs.commercelayer.io/core/cleaning-resources#supported-resources",webhooks_events:"https://docs.commercelayer.io/api/real-time-webhooks#supported-events",tags_resources:"https://docs.commercelayer.io/core/v/api-reference/tags#taggable-resources",links_resources:"https://docs.commercelayer.io/core/v/api-reference/links"},tags:{max_resource_tags:10,taggable_resources:Te,tag_name_max_length:25,tag_name_pattern:/^[0-9A-Za-z_-]{1,25}$/},provisioning:{default_subdomain:"provisioning",scope:"provisioning-api",applications:["user"]},metrics:{default_path:"metrics",scope:"metrics-api",applications:["integration","webapp"]},links:{default_domain:"c11r.link",linkable_resources:Ae}},u=$e;import{readFileSync as Ce}from"fs";var j=async(e,t,r)=>await(await fetch(new URL(`/api/${e.resource}`+(r?`/${r}`:""),e.baseUrl),{method:e.operation,headers:{"Content-Type":"application/vnd.api+json",Accept:"application/vnd.api+json",Authorization:`Bearer ${e.accessToken}`},body:JSON.stringify(t)}).then(n=>{if(n.ok)return n;throw new Error(n.statusText)})).json(),D=e=>{let t,r;try{t=Ce(e,"utf-8")}catch{throw new Error(`Unable to find or open the data file ${$.msg.error(e)}`)}try{r=JSON.parse(t)}catch{throw new Error(`Unable to parse the data file ${$.msg.error(e)}: invalid JSON format`)}return r.data?r:{data:r}},L=(r=>(r.Create="POST",r.Update="PATCH",r))(L||{});var J=(e,t)=>t.find(r=>e.id===r.id&&e.type===r.type),E=(e,t)=>{let r={id:e.id,type:e.type,...e.attributes};return e.relationships&&Object.keys(e.relationships).forEach(s=>{let n=e.relationships[s].data;n?Array.isArray(n)?r[s]=n.map(i=>E(J(i,t),t)):r[s]=E(J(n,t),t):n===null&&(r[s]=null)}),r},P=e=>{let t;e.links&&delete e.links;let r=e.data,s=e.included;return Array.isArray(r)?t=r.map(n=>E(n,s)):t=E(r,s),t};var p={uncountableWords:["equipment","information","rice","money","species","series","fish","sheep","moose","deer","news"],pluralRules:[[/(m)an$/gi,"$1en"],[/(pe)rson$/gi,"$1ople"],[/(child)$/gi,"$1ren"],[/^(ox)$/gi,"$1en"],[/(ax|test)is$/gi,"$1es"],[/(octop|vir)us$/gi,"$1i"],[/(alias|status)$/gi,"$1es"],[/(bu)s$/gi,"$1ses"],[/(buffal|tomat|potat)o$/gi,"$1oes"],[/([ti])um$/gi,"$1a"],[/sis$/gi,"ses"],[/(?:([^f])fe|([lr])f)$/gi,"$1$2ves"],[/(hive)$/gi,"$1s"],[/([^aeiouy]|qu)y$/gi,"$1ies"],[/(x|ch|ss|sh)$/gi,"$1es"],[/(matr|vert|ind)ix|ex$/gi,"$1ices"],[/([m|l])ouse$/gi,"$1ice"],[/(quiz)$/gi,"$1zes"],[/s$/gi,"s"],[/$/gi,"s"]],singularRules:[[/(m)en$/gi,"$1an"],[/(pe)ople$/gi,"$1rson"],[/(child)ren$/gi,"$1"],[/([ti])a$/gi,"$1um"],[/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/gi,"$1$2sis"],[/(hive)s$/gi,"$1"],[/(tive)s$/gi,"$1"],[/(curve)s$/gi,"$1"],[/([lr])ves$/gi,"$1f"],[/([^fo])ves$/gi,"$1fe"],[/([^aeiouy]|qu)ies$/gi,"$1y"],[/(s)eries$/gi,"$1eries"],[/(m)ovies$/gi,"$1ovie"],[/(x|ch|ss|sh)es$/gi,"$1"],[/([m|l])ice$/gi,"$1ouse"],[/(bus)es$/gi,"$1"],[/(o)es$/gi,"$1"],[/(shoe)s$/gi,"$1"],[/(cris|ax|test)es$/gi,"$1is"],[/(octop|vir)i$/gi,"$1us"],[/(alias|status)es$/gi,"$1"],[/^(ox)en/gi,"$1"],[/(vert|ind)ices$/gi,"$1ex"],[/(matr)ices$/gi,"$1ix"],[/(quiz)zes$/gi,"$1"],[/s$/gi,""]],nonTitlecasedWords:["and","or","nor","a","an","the","so","but","to","of","at","by","from","into","on","onto","off","out","in","over","with","for"],idSuffix:/(_ids|_id)$/g,underbar:/_/g,spaceOrUnderbar:/[ _]/g,uppercase:/([A-Z])/g,underbarPrefix:/^_/,applyRules:function(e,t,r,s){if(s)e=s;else if(!r.includes(e.toLowerCase())){for(let i=0;i<t.length;i++)if(e.match(t[i][0])){e=e.replace(t[i][0],t[i][1]);break}}return e},pluralize:function(e,t){return p.applyRules(e,p.pluralRules,p.uncountableWords,t)},singularize:function(e,t){return p.applyRules(e,p.singularRules,p.uncountableWords,t)},camelize:function(e,t){let r=e.split("/");for(let s=0;s<r.length;s++){let n=r[s].split("_"),i=t&&s+1===r.length?1:0;for(let a=i;a<n.length;a++)n[a]=n[a].charAt(0).toUpperCase()+n[a].substring(1);r[s]=n.join("")}if(e=r.join("::"),t){let s=e.charAt(0).toLowerCase(),n=e.slice(1);e=s+n}return e},underscore:function(e){let t=e.split("::");for(let r=0;r<t.length;r++)t[r]=t[r].replace(p.uppercase,"_$1"),t[r]=t[r].replace(p.underbarPrefix,"");return e=t.join("/").toLowerCase(),e},humanize:function(e,t){return e=e.toLowerCase(),e=e.replace(p.idSuffix,""),e=e.replace(p.underbar," "),t||(e=p.capitalize(e)),e},capitalize:function(e){return e=e.toLowerCase(),e=e.substring(0,1).toUpperCase()+e.substring(1),e},dasherize:function(e){return e=e.replace(p.spaceOrUnderbar,"-"),e},camel2words:function(e,t){t?(e=p.camelize(e),e=p.underscore(e)):e=e.toLowerCase(),e=e.replace(p.underbar," ");let r=e.split(" ");for(let s=0;s<r.length;s++){let n=r[s].split("-");for(let i=0;i<n.length;i++)p.nonTitlecasedWords.includes(n[i].toLowerCase())||(n[i]=p.capitalize(n[i]));r[s]=n.join("-")}return e=r.join(" "),e=e.substring(0,1).toUpperCase()+e.substring(1),e},demodulize:function(e){let t=e.split("::");return e=t[t.length-1],e},tableize:function(e){return e=p.pluralize(p.underscore(e)),e},classify:function(e){return e=p.singularize(p.camelize(e)),e},foreignKey:function(e,t){return e=p.underscore(p.demodulize(e))+(t?"":"_")+"id",e},ordinalize:function(e){let t=e.split(" ");for(let r=0;r<t.length;r++){let s=parseInt(t[r]);if(Number.isNaN(s)){let n=t[r].substring(t[r].length-2),i=t[r].substring(t[r].length-1),a="th";n!=="11"&&n!=="12"&&n!=="13"&&(i==="1"?a="st":i==="2"?a="nd":i==="3"&&(a="rd")),t[r]+=a}}return e=t.join(" "),e}},k=p;var qe=(e="core",t,r)=>`https://${(["core","metrics"].includes(e)&&t||e).toLowerCase()}.${r||u.api.default_domain}`,Re=e=>{if(e)return e.substring(e.indexOf(".")+1)},Ee=e=>e===!0||e==="live"?"live":"test",Se=(e,t)=>{let r=e.replace(/_/g," ");return t&&(r=k.singularize(r)),r};var ze=["bundles","imports","markets","prices","price_lists","promotions","buy_x_pay_y_promotions","external_promotions","fixed_amount_promotions","fixed_price_promotions","free_gift_promotions","free_shipping_promotions","percentage_discount_promotions","skus","sku_options","stock_items","stock_locations"],Y=(e,t)=>ze.includes(e||"")&&(t||"GET").toUpperCase()==="GET",Ie=e=>e==="live",X=e=>{let t=e?.environment||"test",r=e?.parallelRequests||1,s=Y(e?.resourceType,e?.method),n,i;t==="live"?(n=s?u.api.requests_max_num_burst_cacheable:u.api.requests_max_num_burst,i=s?u.api.requests_max_num_avg_cacheable:u.api.requests_max_num_avg):(n=s?u.api.requests_max_num_burst_test_cacheable:u.api.requests_max_num_burst_test,i=s?u.api.requests_max_num_avg_test_cacheable:u.api.requests_max_num_avg_test);let a=u.api.requests_max_secs_burst/n,m=u.api.requests_max_secs_avg/i,_=r*a,w=r*m,f=e?.totalRequests,c=0;return f&&f>0?f>n&&(f>i?c=w:c=_):c=Math.max(_,w),c=c*1e3,e?.minimumDelay&&(c=Math.max(e.minimumDelay,c)),e?.securityDelay&&(c+=e.securityDelay),c=Math.ceil(c),c};var Oe={raw:j,readDataFile:D,rateLimitDelay:X},Ke={denormalize:P};var ee={};h(ee,{appKey:()=>Be,appKeyMatch:()=>je,appKeyValid:()=>Me,arrayScope:()=>Q,isProvisioningApp:()=>De});var Be=()=>Date.now().toString(36),Me=e=>e.key!==void 0&&e.key!=="",je=(e,t)=>{let r=e!==void 0,s=t!==void 0;return!r&&!s||r&&s&&e.key===t.key},Q=e=>{if(!e)return[];if(Array.isArray(e))return e;let t=e.replace(/[ ,;]/g,"|").split("|");return Array.isArray(t)?t:[t]},De=e=>Q(e.scope).includes(u.provisioning.scope)||e.api==="provisioning";var te={};h(te,{allFlags:()=>Pe,checkISODateTimeValue:()=>Fe,commandFlags:()=>Le,findLongStringFlag:()=>Ue,fixDashedFlagValue:()=>We,fixValueType:()=>Ve});var Le=(e,t)=>{let r={...e};if(t)for(let s of t)delete r[s];return r},Pe=e=>({...e.flags,...e.baseFlags}),Ve=e=>{let t=e;return t==="null"?t=null:Number(t)==t?t=Number(t):t=t==="true"?!0:t==="false"?!1:t,t},Ue=(e,t)=>{let r=t.startsWith("--")?t:`--${t}`,s,n=e.findIndex(a=>a.startsWith(r)),i=!1;if(n>-1){let a=e[n];if(a.includes("=")){let m=a.split("=");s=m.length===2?m[1]:"",i=!0}else s=e[n+1];return{value:s,index:n,single:i}}else return},We=(e,t,r,s)=>{let n="____",i=t.name||r,a=t.char;if(!i&&!a)return e;let m=i?i.startsWith("--")?i:`--${i}`:void 0,_=a?t.char.startsWith("-")?a:`-${a}`:void 0,w=e.findIndex(A=>_&&A.startsWith(_)||m&&A.startsWith(m));if(w<0)return e;let f=e[w],c="",G="";if(_&&f.startsWith(_))c=f.replace(_,"").trim(),f=_;else if(m&&f.startsWith(m))c=f.replace(m,"").trim(),f=m;else return e;if(c.startsWith("=")?(c=c.slice(1),G=f+"="):c||(c=e[++w]),c.startsWith("-")||c.startsWith(n)){let A=c.startsWith(`${n}`)?c.replace(`${n}`,""):c.replace("-",`${n}-`);if(e[w]=G+A,c.startsWith(n)&&s){let R=i?i.replace("--",""):void 0,O=Object.entries(s.flags).find(([B,be])=>be===c);O&&(!R||R===O[0])&&(s.flags[O[0]]=A);let K=Object.values(s.raw).find(B=>B.type==="flag"&&B.input===c);K&&(!R||R===K.flag)&&(K.input=A)}}return e},Fe=e=>{if(!e)throw Error("Date is empty");try{let t=Date.parse(e);if(Number.isNaN(t))throw new Error("Invalid date");return new Date(t)}catch{throw new Error("Error parsing date: "+e)}};var oe={};h(oe,{center:()=>He,cleanDate:()=>Je,formatError:()=>Xe,formatOutput:()=>ie,localeDate:()=>Ye,maxLength:()=>Ge,printCSV:()=>ne,printJSON:()=>se,printObject:()=>re});import{inspect as Ne}from"util";var re=(e,t)=>Ne(e,{showHidden:!1,depth:null,colors:t?.color===void 0?!0:t.color,sorted:t?.sort===void 0?!1:t?.sort,maxArrayLength:1/0,breakLength:t?.width||120}),se=(e,t)=>JSON.stringify(e,null,t?.unformatted?void 0:t?.tabSize||4),ne=(e,t)=>{if(!e||e.length===0)return"";let r=Object.keys(e[0]).filter(n=>["id","type"].includes(n)?t?.fields.includes(n):!0),s=r.map(n=>n.toUpperCase().replace(/_/g," ")).join(";")+`
2
- `;return e.forEach(n=>{s+=r.map(i=>n[i]).join(";")+`
3
- `}),s},He=(e,t)=>e.padStart(e.length+Math.floor((t-e.length)/2)," ").padEnd(t," "),Ge=(e,t)=>e.reduce((r,s)=>{let n=Array.isArray(s[t])?s[t].join():s[t];return Math.max(r,String(n).length)},0),Je=e=>e?e.replace("T"," ").replace("Z","").substring(0,e.lastIndexOf(".")):"",Ye=e=>e?new Date(Date.parse(e)).toLocaleString():"",ie=(e,t,{color:r=!0}={})=>{if(!e)return"";if(typeof e=="string")return e;if(t){if(t.csv)return ne(e,t);if(t.json)return se(e,{unformatted:t.unformatted})}return re(e,{color:r})},Xe=(e,t)=>ie(e.errors||e,t);var $={};h($,{api:()=>ht,bg:()=>_t,black:()=>at,blackBright:()=>ct,blue:()=>nt,blueBright:()=>q,bold:()=>U,cli:()=>bt,cyan:()=>pt,cyanBright:()=>C,dim:()=>dt,green:()=>rt,greenBright:()=>V,grey:()=>lt,hidden:()=>et,italic:()=>T,magenta:()=>ut,magentaBright:()=>mt,msg:()=>yt,red:()=>tt,redBright:()=>ae,reset:()=>Ze,style:()=>l,table:()=>xt,type:()=>ft,underline:()=>gt,visible:()=>Qe,white:()=>it,whiteBright:()=>ot,yellow:()=>st,yellowBright:()=>v});import o from"chalk";var Ze=o.reset,Qe=o.visible,et=o.hidden,tt=o.red,ae=o.redBright,rt=o.green,V=o.greenBright,st=o.yellow,v=o.yellowBright,nt=o.blue,q=o.blueBright,it=o.white,ot=o.whiteBright,at=o.black,ct=o.blackBright,lt=o.grey,pt=o.cyan,C=o.cyanBright,ut=o.magenta,mt=o.magentaBright,U=o.bold,dt=o.dim,gt=o.underline,T=o.italic,_t={white:o.bgWhite,whiteBright:o.bgWhiteBright,black:o.bgBlack,blackBright:o.bgBlackBright,grey:o.bgGrey,red:o.bgRed,redBright:o.bgRedBright,green:o.bgGreen,greenBright:o.bgGreenBright,yellow:o.bgYellow,yellowBright:o.bgYellowBright,blue:o.bgBlue,blueBright:o.bgBlueBright,magenta:o.bgMagenta,magentaBright:o.bgMagentaBright,cyan:o.bgCyan,cyanBright:o.bgCyanBright},l={organization:v.bold,application:v.bold,slug:v,id:U,token:q,resource:U,attribute:T,trigger:C,kind:C,live:V,test:v,execMode:e=>e==="live"?l.live:l.test,success:V,warning:v,error:ae,arg:T,flag:T,command:T,value:T,alias:C,plugin:q,title:q,path:T,datetime:C,number:v},ft={datetime:l.datetime,number:l.number,path:l.path},ht={organization:l.organization,application:l.application,slug:l.slug,id:l.id,token:l.token,resource:l.resource,attribute:l.attribute,trigger:l.trigger,kind:l.kind,live:l.live,test:l.test},yt={success:l.success,warning:l.warning,error:l.error},bt={arg:l.arg,flag:l.flag,command:l.command,value:l.value,alias:l.alias,plugin:l.plugin},xt={header:v.bold,key:q};var pe={};h(pe,{buildAssertionPayload:()=>Lt,decodeAccessToken:()=>le,generateAccessToken:()=>Kt,getAccessToken:()=>Bt,getTokenEnvironment:()=>Dt,isAccessTokenExpiring:()=>jt,revokeAccessToken:()=>Mt});import N from"jsonwebtoken";import{authenticate as F,revoke as Ot}from"@commercelayer/js-auth";var ce={};h(ce,{dotNotationToObject:()=>W,generateGroupUID:()=>zt,log:()=>Et,resetConsole:()=>Rt,sleep:()=>qt,specialFolder:()=>St,userAgent:()=>It});import{format as vt,inspect as wt}from"util";import{sep as kt,dirname as Tt}from"path";import{homedir as At}from"os";import{existsSync as $t,mkdirSync as Ct}from"fs";var qt=async e=>new Promise(t=>setTimeout(t,e)),Rt=()=>{process.stdout.write("\x1B[?25h\x1B[?7h")},Et=(e="",...t)=>{e=typeof e=="string"?e:wt(e),process.stdout.write(vt(e,...t)+`
4
- `)},St=(e,t=!1)=>{let r=["desktop","home"],s=e.toLowerCase().split(/[\\\/]/g)[0];if(r.includes(s)){let i=At();s==="desktop"&&(i+=`${kt}Desktop`),e=e.replace(s,i)}let n=Tt(e);return t&&!$t(n)&&Ct(n,{recursive:!0}),e},zt=()=>{let e=Math.trunc(Math.random()*46656),t=Math.trunc(Math.random()*46656),r=("000"+e.toString(36)).slice(-3),s=("000"+t.toString(36)).slice(-3);return r+s},It=e=>`${e.name.replace(/@commercelayer\/cli-plugin/,"CLI")}/${e.version}`,W=(e,t)=>{let r=t||{};return Object.entries(e).forEach(([s,n])=>{let i=s.split("."),a=i[i.length-1],m=r;i.forEach(_=>{_===a?m[_]=n:m=m[_]||(m[_]={})})}),t&&Object.assign(t,r),r};var le=e=>{let t=N.decode(e);if(t===null)throw new Error("Error decoding access token");return t},Kt=(e,t,r)=>{let n={...e,exp:Math.floor(Date.now()/1e3)+r*60,rand:Math.random()},i=u.api.token_encoding_algorithm,a=N.sign(n,t,{algorithm:i,noTimestamp:!0}),m=N.verify(a,t,{algorithms:[i]});return{accessToken:a,info:m,expMinutes:r}},Bt=async e=>{let t,r=e.scope?Array.isArray(e.scope)?e.scope.map(n=>n.trim()).join(","):e.scope:"",s={clientId:e.clientId,clientSecret:e.clientSecret,slug:e.slug,domain:e.domain,scope:r};if(e.email&&e.password?(s.username=e.email,s.password=e.password,t=await F("password",s)):e.assertion?(s.assertion=e.assertion,t=await F("urn:ietf:params:oauth:grant-type:jwt-bearer",s)):t=await F("client_credentials",s),t){if(t.errors)throw new Error(`Unable to get access token: ${t.errors[0].detail}`)}else throw new Error("Unable to get access token");return t},Mt=async(e,t)=>{let r=await Ot({...e,token:t});if(r.errors)throw new Error(r.errors[0].detail)},jt=e=>{let r=Math.floor(Date.now()/1e3),s=Math.floor(new Date(e.expires).getTime()/1e3);return r>=s-30},Dt=e=>(typeof e=="string"?le(e):e).test?"test":"live";var Lt=(e,t,r)=>{let s="https://commercelayer.io/claims",n={[s]:{owner:{type:e,id:t}}};if(r&&Object.keys(r).length>0){let i=W(r);n[s].custom_claim=i}return n};var ue={};h(ue,{checkUpdate:()=>Ut});import S from"chalk";import Pt from"update-notifier-cjs";var Vt=1,Ut=e=>{let t=Pt({pkg:e,updateCheckInterval:36e5*Vt});t.update&&t.notify({isGlobal:!1,message:`-= ${S.bgWhite.black.bold(` ${e.description} `)} =-
1
+ var xe=Object.defineProperty;var h=(e,t)=>{for(var r in t)xe(e,r,{get:t[r],enumerable:!0})};var Z={};h(Z,{Operation:()=>P,baseURL:()=>qe,execMode:()=>Ee,extractDomain:()=>Re,humanizeResource:()=>Se,isResourceCacheable:()=>Y,liveEnvironment:()=>Ie,request:()=>Oe,requestDataFile:()=>L,requestRateLimitDelay:()=>X,requestRaw:()=>D,response:()=>Ke,responseDenormalize:()=>j});var M=["in_progress","pending","completed","interrupted"],ve=["addresses","bundles","coupons","customer_addresses","customer_payment_sources","customer_subscriptions","customers","gift_cards","line_items","line_item_options","orders","price_tiers","prices","shipping_categories","sku_lists","sku_list_items","sku_options","skus","stock_items","stock_transfers","tags","tax_categories"],we=["addresses","authorizations","bundles","captures","coupons","customer_addresses","customer_payment_sources","customer_subscriptions","customers","gift_cards","line_items","line_item_options","orders","payment_methods","price_tiers","prices","refunds","returns","shipments","shipping_categories","shipping_methods","sku_lists","sku_list_items","sku_options","skus","stock_items","stock_transfers","tags","tax_categories","transactions","voids"],ke=["bundles","gift_cards","prices","promotions","sku_lists","sku_options","skus","stock_items"],Te=["addresses","bundles","customers","coupons","gift_cards","line_items","line_item_options","orders","returns","skus","sku_options","promotions","external_promotions","fixed_amount_promotions","fixed_price_promotions","free_gift_promotions","free_shipping_promotions","percentage_discount_promotions"],Ae=["orders","skus","sku_lists"],b={erl_oauth_limit_live:30,erl_average_limit_cachable_live:1e3,erl_average_limit_cachable_test:500,erl_burst_limit_cachable_live:250,erl_burst_limit_cachable_test:125,erl_average_limit_uncachable_live:200,erl_average_limit_uncachable_test:100,erl_burst_limit_uncachable_live:50,erl_burst_limit_uncachable_test:25},$e={api:{default_domain:"commercelayer.io",default_app_domain:"commercelayer.app",default_stg_domain:"commercelayer.co",token_expiration_mins:240,token_encoding_algorithm:"HS512",token_owner_types:["Customer","User"],requests_max_num_burst:b.erl_burst_limit_uncachable_live,requests_max_num_burst_cacheable:b.erl_burst_limit_cachable_live,requests_max_num_burst_test:b.erl_burst_limit_uncachable_test,requests_max_num_burst_test_cacheable:b.erl_burst_limit_cachable_test,requests_max_num_avg:b.erl_average_limit_uncachable_live,requests_max_num_avg_cacheable:b.erl_average_limit_cachable_live,requests_max_num_avg_test:b.erl_average_limit_uncachable_test,requests_max_num_avg_test_cacheable:b.erl_average_limit_cachable_test,requests_max_num_oauth:b.erl_oauth_limit_live,requests_max_secs_burst:10,requests_max_secs_oauth:60,requests_max_secs_avg:60,page_max_size:25,page_default_size:10},application:{kinds:["dashboard","user","metrics","contentful","bundles","customers","datocms","exports","external","gift_cards","imports","integration","inventory","orders","price_lists","promotions","resources","returns","sales_channel","sanity","shipments","skus","sku_lists","stock_transfers","subscriptions","tags","webapp","webhooks","zapier"],login_scopes:["market","stock_location","store"]},imports:{max_size:1e4,statuses:M,types:ve,max_queue_length:10,attachment_expiration:5},exports:{max_size:5e3,statuses:M,types:we,max_queue_length:10,attachment_expiration:5},cleanups:{max_size:1e4,statuses:M,types:ke,max_queue_length:10},webhooks:{retry_number:5},cli:{applications:["integration","sales_channel","user"]},doc:{core:"https://docs.commercelayer.io/core/",core_api_reference:"https://docs.commercelayer.io/developers/v/api-reference",core_how_tos:"https://docs.commercelayer.io/core/v/how-tos/",core_raste_limits:"https://docs.commercelayer.io/core/rate-limits",core_filtering_data:"https://docs.commercelayer.io/core/filtering-data#list-of-predicates",metrics:"https://docs.commercelayer.io/metrics/",metrics_api_reference:"https://docs.commercelayer.io/metrics/v/api-reference-m/",provisioning:"https://docs.commercelayer.io/provisioning/",provisioning_api_reference:"https://docs.commercelayer.io/provisioning/v/api-reference-p/",imports_resources:"https://docs.commercelayer.io/api/importing-resources#supported-resources",exports_resources:"https://docs.commercelayer.io/core/exporting-resources#supported-resources",cleanups_resources:"https://docs.commercelayer.io/core/cleaning-resources#supported-resources",webhooks_events:"https://docs.commercelayer.io/api/real-time-webhooks#supported-events",tags_resources:"https://docs.commercelayer.io/core/v/api-reference/tags#taggable-resources",links_resources:"https://docs.commercelayer.io/core/v/api-reference/links"},tags:{max_resource_tags:10,taggable_resources:Te,tag_name_max_length:25,tag_name_pattern:/^[0-9A-Za-z_-]{1,25}$/},provisioning:{default_subdomain:"provisioning",scope:"provisioning-api",applications:["user"]},metrics:{default_path:"metrics",scope:"metrics-api",applications:["integration","webapp"]},links:{default_domain:"c11r.link",linkable_resources:Ae}},u=$e;var p={uncountableWords:["equipment","information","rice","money","species","series","fish","sheep","moose","deer","news"],pluralRules:[[/(m)an$/gi,"$1en"],[/(pe)rson$/gi,"$1ople"],[/(child)$/gi,"$1ren"],[/^(ox)$/gi,"$1en"],[/(ax|test)is$/gi,"$1es"],[/(octop|vir)us$/gi,"$1i"],[/(alias|status)$/gi,"$1es"],[/(bu)s$/gi,"$1ses"],[/(buffal|tomat|potat)o$/gi,"$1oes"],[/([ti])um$/gi,"$1a"],[/sis$/gi,"ses"],[/(?:([^f])fe|([lr])f)$/gi,"$1$2ves"],[/(hive)$/gi,"$1s"],[/([^aeiouy]|qu)y$/gi,"$1ies"],[/(x|ch|ss|sh)$/gi,"$1es"],[/(matr|vert|ind)ix|ex$/gi,"$1ices"],[/([m|l])ouse$/gi,"$1ice"],[/(quiz)$/gi,"$1zes"],[/s$/gi,"s"],[/$/gi,"s"]],singularRules:[[/(m)en$/gi,"$1an"],[/(pe)ople$/gi,"$1rson"],[/(child)ren$/gi,"$1"],[/([ti])a$/gi,"$1um"],[/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/gi,"$1$2sis"],[/(hive)s$/gi,"$1"],[/(tive)s$/gi,"$1"],[/(curve)s$/gi,"$1"],[/([lr])ves$/gi,"$1f"],[/([^fo])ves$/gi,"$1fe"],[/([^aeiouy]|qu)ies$/gi,"$1y"],[/(s)eries$/gi,"$1eries"],[/(m)ovies$/gi,"$1ovie"],[/(x|ch|ss|sh)es$/gi,"$1"],[/([m|l])ice$/gi,"$1ouse"],[/(bus)es$/gi,"$1"],[/(o)es$/gi,"$1"],[/(shoe)s$/gi,"$1"],[/(cris|ax|test)es$/gi,"$1is"],[/(octop|vir)i$/gi,"$1us"],[/(alias|status)es$/gi,"$1"],[/^(ox)en/gi,"$1"],[/(vert|ind)ices$/gi,"$1ex"],[/(matr)ices$/gi,"$1ix"],[/(quiz)zes$/gi,"$1"],[/s$/gi,""]],nonTitlecasedWords:["and","or","nor","a","an","the","so","but","to","of","at","by","from","into","on","onto","off","out","in","over","with","for"],idSuffix:/(_ids|_id)$/g,underbar:/_/g,spaceOrUnderbar:/[ _]/g,uppercase:/([A-Z])/g,underbarPrefix:/^_/,applyRules:(e,t,r,s)=>{if(s)e=s;else if(!r.includes(e.toLowerCase())){for(let n=0;n<t.length;n++)if(e.match(t[n][0])){e=e.replace(t[n][0],t[n][1]);break}}return e},pluralize:(e,t)=>p.applyRules(e,p.pluralRules,p.uncountableWords,t),singularize:(e,t)=>p.applyRules(e,p.singularRules,p.uncountableWords,t),camelize:(e,t)=>{let r=e.split("/");for(let s=0;s<r.length;s++){let i=r[s].split("_"),n=t&&s+1===r.length?1:0;for(let a=n;a<i.length;a++)i[a]=i[a].charAt(0).toUpperCase()+i[a].substring(1);r[s]=i.join("")}if(e=r.join("::"),t){let s=e.charAt(0).toLowerCase(),i=e.slice(1);e=s+i}return e},underscore:e=>{let t=e.split("::");for(let r=0;r<t.length;r++)t[r]=t[r].replace(p.uppercase,"_$1"),t[r]=t[r].replace(p.underbarPrefix,"");return e=t.join("/").toLowerCase(),e},humanize:(e,t)=>(e=e.toLowerCase(),e=e.replace(p.idSuffix,""),e=e.replace(p.underbar," "),t||(e=p.capitalize(e)),e),capitalize:e=>(e=e.toLowerCase(),e=e.substring(0,1).toUpperCase()+e.substring(1),e),dasherize:e=>(e=e.replace(p.spaceOrUnderbar,"-"),e),camel2words:(e,t)=>{t?(e=p.camelize(e),e=p.underscore(e)):e=e.toLowerCase(),e=e.replace(p.underbar," ");let r=e.split(" ");for(let s=0;s<r.length;s++){let i=r[s].split("-");for(let n=0;n<i.length;n++)p.nonTitlecasedWords.includes(i[n].toLowerCase())||(i[n]=p.capitalize(i[n]));r[s]=i.join("-")}return e=r.join(" "),e=e.substring(0,1).toUpperCase()+e.substring(1),e},demodulize:e=>{let t=e.split("::");return e=t[t.length-1],e},tableize:e=>(e=p.pluralize(p.underscore(e)),e),classify:e=>(e=p.singularize(p.camelize(e)),e),foreignKey:(e,t)=>(e=p.underscore(p.demodulize(e))+(t?"":"_")+"id",e),ordinalize:e=>{let t=e.split(" ");for(let r=0;r<t.length;r++){let s=parseInt(t[r],10);if(Number.isNaN(s)){let i=t[r].substring(t[r].length-2),n=t[r].substring(t[r].length-1),a="th";i!=="11"&&i!=="12"&&i!=="13"&&(n==="1"?a="st":n==="2"?a="nd":n==="3"&&(a="rd")),t[r]+=a}}return e=t.join(" "),e}},k=p;var J=(e,t)=>t.find(r=>e.id===r.id&&e.type===r.type),E=(e,t)=>{let r={id:e.id,type:e.type,...e.attributes};return e.relationships&&Object.keys(e.relationships).forEach(s=>{let i=e.relationships[s].data;i?Array.isArray(i)?r[s]=i.map(n=>E(J(n,t),t)):r[s]=E(J(i,t),t):i===null&&(r[s]=null)}),r},j=e=>{let t;e.links&&delete e.links;let r=e.data,s=e.included;return Array.isArray(r)?t=r.map(i=>E(i,s)):t=E(r,s),t};import{readFileSync as Ce}from"fs";var D=async(e,t,r)=>await(await fetch(new URL(`/api/${e.resource}`+(r?`/${r}`:""),e.baseUrl),{method:e.operation,headers:{"Content-Type":"application/vnd.api+json",Accept:"application/vnd.api+json",Authorization:`Bearer ${e.accessToken}`},body:JSON.stringify(t)}).then(i=>{if(i.ok)return i;throw new Error(i.statusText)})).json(),L=e=>{let t,r;try{t=Ce(e,"utf-8")}catch{throw new Error(`Unable to find or open the data file ${$.msg.error(e)}`)}try{r=JSON.parse(t)}catch{throw new Error(`Unable to parse the data file ${$.msg.error(e)}: invalid JSON format`)}return r.data?r:{data:r}},P=(r=>(r.Create="POST",r.Update="PATCH",r))(P||{});var qe=(e="core",t,r)=>`https://${(["core","metrics"].includes(e)&&t||e).toLowerCase()}.${r||u.api.default_domain}`,Re=e=>{if(e)return e.substring(e.indexOf(".")+1)},Ee=e=>e===!0||e==="live"?"live":"test",Se=(e,t)=>{let r=e.replace(/_/g," ");return t&&(r=k.singularize(r)),r};var ze=["bundles","imports","markets","prices","price_lists","promotions","buy_x_pay_y_promotions","external_promotions","fixed_amount_promotions","fixed_price_promotions","free_gift_promotions","free_shipping_promotions","percentage_discount_promotions","skus","sku_options","stock_items","stock_locations"],Y=(e,t)=>ze.includes(e||"")&&(t||"GET").toUpperCase()==="GET",Ie=e=>e==="live",X=e=>{let t=e?.environment||"test",r=e?.parallelRequests||1,s=Y(e?.resourceType,e?.method),i,n;t==="live"?(i=s?u.api.requests_max_num_burst_cacheable:u.api.requests_max_num_burst,n=s?u.api.requests_max_num_avg_cacheable:u.api.requests_max_num_avg):(i=s?u.api.requests_max_num_burst_test_cacheable:u.api.requests_max_num_burst_test,n=s?u.api.requests_max_num_avg_test_cacheable:u.api.requests_max_num_avg_test);let a=u.api.requests_max_secs_burst/i,m=u.api.requests_max_secs_avg/n,_=r*a,w=r*m,f=e?.totalRequests,c=0;return f&&f>0?f>i&&(f>n?c=w:c=_):c=Math.max(_,w),c=c*1e3,e?.minimumDelay&&(c=Math.max(e.minimumDelay,c)),e?.securityDelay&&(c+=e.securityDelay),c=Math.ceil(c),c};var Oe={raw:D,readDataFile:L,rateLimitDelay:X},Ke={denormalize:j};var ee={};h(ee,{appKey:()=>Be,appKeyMatch:()=>je,appKeyValid:()=>Me,arrayScope:()=>Q,isProvisioningApp:()=>De});var Be=()=>Date.now().toString(36),Me=e=>e.key!==void 0&&e.key!=="",je=(e,t)=>{let r=e!==void 0,s=t!==void 0;return!r&&!s||r&&s&&e.key===t.key},Q=e=>{if(!e)return[];if(Array.isArray(e))return e;let t=e.replace(/[ ,;]/g,"|").split("|");return Array.isArray(t)?t:[t]},De=e=>Q(e.scope).includes(u.provisioning.scope)||e.api==="provisioning";var te={};h(te,{allFlags:()=>Pe,checkISODateTimeValue:()=>Fe,commandFlags:()=>Le,findLongStringFlag:()=>Ue,fixDashedFlagValue:()=>We,fixValueType:()=>Ve});var Le=(e,t)=>{let r={...e};if(t)for(let s of t)delete r[s];return r},Pe=e=>({...e.flags,...e.baseFlags}),Ve=e=>{let t=e;return t==="null"?t=null:Number(t)==t?t=Number(t):t=t==="true"?!0:t==="false"?!1:t,t},Ue=(e,t)=>{let r=t.startsWith("--")?t:`--${t}`,s,i=e.findIndex(a=>a.startsWith(r)),n=!1;if(i>-1){let a=e[i];if(a.includes("=")){let m=a.split("=");s=m.length===2?m[1]:"",n=!0}else s=e[i+1];return{value:s,index:i,single:n}}else return},We=(e,t,r,s)=>{let i="____",n=t.name||r,a=t.char;if(!n&&!a)return e;let m=n?n.startsWith("--")?n:`--${n}`:void 0,_=a?t.char.startsWith("-")?a:`-${a}`:void 0,w=e.findIndex(A=>_&&A.startsWith(_)||m&&A.startsWith(m));if(w<0)return e;let f=e[w],c="",G="";if(_&&f.startsWith(_))c=f.replace(_,"").trim(),f=_;else if(m&&f.startsWith(m))c=f.replace(m,"").trim(),f=m;else return e;if(c.startsWith("=")?(c=c.slice(1),G=f+"="):c||(c=e[++w]),c.startsWith("-")||c.startsWith(i)){let A=c.startsWith(`${i}`)?c.replace(`${i}`,""):c.replace("-",`${i}-`);if(e[w]=G+A,c.startsWith(i)&&s){let R=n?n.replace("--",""):void 0,O=Object.entries(s.flags).find(([B,be])=>be===c);O&&(!R||R===O[0])&&(s.flags[O[0]]=A);let K=Object.values(s.raw).find(B=>B.type==="flag"&&B.input===c);K&&(!R||R===K.flag)&&(K.input=A)}}return e},Fe=e=>{if(!e)throw Error("Date is empty");try{let t=Date.parse(e);if(Number.isNaN(t))throw new Error("Invalid date");return new Date(t)}catch{throw new Error("Error parsing date: "+e)}};var oe={};h(oe,{center:()=>He,cleanDate:()=>Je,formatError:()=>Xe,formatOutput:()=>ne,localeDate:()=>Ye,maxLength:()=>Ge,printCSV:()=>ie,printJSON:()=>se,printObject:()=>re});import{inspect as Ne}from"util";var re=(e,t)=>Ne(e,{showHidden:!1,depth:null,colors:t?.color===void 0?!0:t.color,sorted:t?.sort===void 0?!1:t?.sort,maxArrayLength:1/0,breakLength:t?.width||120}),se=(e,t)=>JSON.stringify(e,null,t?.unformatted?void 0:t?.tabSize||4),ie=(e,t)=>{if(!e||e.length===0)return"";let r=Object.keys(e[0]).filter(i=>["id","type"].includes(i)?t?.fields.includes(i):!0),s=r.map(i=>i.toUpperCase().replace(/_/g," ")).join(";")+`
2
+ `;return e.forEach(i=>{s+=r.map(n=>i[n]).join(";")+`
3
+ `}),s},He=(e,t)=>e.padStart(e.length+Math.floor((t-e.length)/2)," ").padEnd(t," "),Ge=(e,t)=>e.reduce((r,s)=>{let i=Array.isArray(s[t])?s[t].join():s[t];return Math.max(r,String(i).length)},0),Je=e=>e?e.replace("T"," ").replace("Z","").substring(0,e.lastIndexOf(".")):"",Ye=e=>e?new Date(Date.parse(e)).toLocaleString():"",ne=(e,t,{color:r=!0}={})=>{if(!e)return"";if(typeof e=="string")return e;if(t){if(t.csv)return ie(e,t);if(t.json)return se(e,{unformatted:t.unformatted})}return re(e,{color:r})},Xe=(e,t)=>ne(e.errors||e,t);var $={};h($,{api:()=>ht,bg:()=>_t,black:()=>at,blackBright:()=>ct,blue:()=>it,blueBright:()=>q,bold:()=>U,cli:()=>bt,cyan:()=>pt,cyanBright:()=>C,dim:()=>dt,green:()=>rt,greenBright:()=>V,grey:()=>lt,hidden:()=>et,italic:()=>T,magenta:()=>ut,magentaBright:()=>mt,msg:()=>yt,red:()=>tt,redBright:()=>ae,reset:()=>Ze,style:()=>l,table:()=>xt,type:()=>ft,underline:()=>gt,visible:()=>Qe,white:()=>nt,whiteBright:()=>ot,yellow:()=>st,yellowBright:()=>v});import o from"chalk";var Ze=o.reset,Qe=o.visible,et=o.hidden,tt=o.red,ae=o.redBright,rt=o.green,V=o.greenBright,st=o.yellow,v=o.yellowBright,it=o.blue,q=o.blueBright,nt=o.white,ot=o.whiteBright,at=o.black,ct=o.blackBright,lt=o.grey,pt=o.cyan,C=o.cyanBright,ut=o.magenta,mt=o.magentaBright,U=o.bold,dt=o.dim,gt=o.underline,T=o.italic,_t={white:o.bgWhite,whiteBright:o.bgWhiteBright,black:o.bgBlack,blackBright:o.bgBlackBright,grey:o.bgGrey,red:o.bgRed,redBright:o.bgRedBright,green:o.bgGreen,greenBright:o.bgGreenBright,yellow:o.bgYellow,yellowBright:o.bgYellowBright,blue:o.bgBlue,blueBright:o.bgBlueBright,magenta:o.bgMagenta,magentaBright:o.bgMagentaBright,cyan:o.bgCyan,cyanBright:o.bgCyanBright},l={organization:v.bold,application:v.bold,slug:v,id:U,token:q,resource:U,attribute:T,trigger:C,kind:C,live:V,test:v,execMode:e=>e==="live"?l.live:l.test,success:V,warning:v,error:ae,arg:T,flag:T,command:T,value:T,alias:C,plugin:q,title:q,path:T,datetime:C,number:v},ft={datetime:l.datetime,number:l.number,path:l.path},ht={organization:l.organization,application:l.application,slug:l.slug,id:l.id,token:l.token,resource:l.resource,attribute:l.attribute,trigger:l.trigger,kind:l.kind,live:l.live,test:l.test},yt={success:l.success,warning:l.warning,error:l.error},bt={arg:l.arg,flag:l.flag,command:l.command,value:l.value,alias:l.alias,plugin:l.plugin},xt={header:v.bold,key:q};var ue={};h(ue,{apply:()=>kt,available:()=>le,documentation:()=>wt,filters:()=>pe,list:()=>ce});var vt=[{predicate:"*_eq",description:"The attribute is equal to the filter value"},{predicate:"*_eq_or_null",description:"The attribute is equal to the filter value, including null values"},{predicate:"*_not_eq",description:"The attribute is not equal to the filter value"},{predicate:"*_not_eq_or_null",description:"The attribute is not equal to the filter value, including null values"},{predicate:"*_matches",description:'The attribute matches the filter value with "LIKE" operator'},{predicate:"*_does_not_match",description:'The attribute does not match the filter value with "LIKE" operator'},{predicate:"*_matches_any",description:'The attribute matches all of the filter values (comma-separated) with "LIKE" operator'},{predicate:"*_matches_all",description:'The attribute matches all of the filter values (comma-separated) with "LIKE" operator'},{predicate:"*_does_not_match_any",description:'The attribute does not match any of the filter values (comma-separated) with "LIKE" operator'},{predicate:"*_does_not_match_all",description:'The attribute matches none of the filter values (comma-separated) with "LIKE" operator'},{predicate:"*_lt",description:"The attribute is less than the filter value"},{predicate:"*_lteq",description:"The attribute is less than or equal to the filter value"},{predicate:"*_gt",description:"The attribute is greater than the filter value"},{predicate:"*_gteq",description:"The attribute is greater than or equal to the filter value"},{predicate:"*_present",description:"The attribute is not null and not empty"},{predicate:"*_blank",description:"The attribute is null or empty"},{predicate:"*_null",description:"The attribute is null"},{predicate:"*_not_null",description:"The attribute is not null"},{predicate:"*_in",description:"The attribute matches any of the filter values (comma-separated)"},{predicate:"*_in_or_null",description:"The attribute matches any of the filter values (comma-separated), including null values"},{predicate:"*_not_in",description:"The attribute matches none of the filter values (comma-separated)"},{predicate:"*_not_in_or_null",description:"The attribute matches none of the filter values (comma-separated), including null values"},{predicate:"*_lt_any",description:"The attribute is less than any of the filter values (comma-separated)"},{predicate:"*_lteq_any",description:"The attribute is less than or equal to any of the filter values (comma-separated)"},{predicate:"*_gt_any",description:"The attribute is greater than any of the filter values (comma-separated)"},{predicate:"*_gteq_any",description:"The attribute is greater than or qual to any of the filter values (comma-separated)"},{predicate:"*_lt_all",description:"The attribute is less than all of the filter values (comma-separated)"},{predicate:"*_lteq_all",description:"The attribute is less than or equal to all of the filter values (comma-separated)"},{predicate:"*_gt_all",description:"The attribute is greater than all of the filter values (comma-separated)"},{predicate:"*_gteq_all",description:"The attribute is greater or equal to all of the filter values (comma-separated)"},{predicate:"*_not_eq_all",description:"The attribute is equal to none of the filter values (comma-separated)"},{predicate:"*_start",description:"The attribute starts with the filter value (comma-separated)"},{predicate:"*_not_start",description:"The attribute does not start with the filter value (comma-separated)"},{predicate:"*_start_any",description:"The attribute starts with any of the filter values (comma-separated)"},{predicate:"*_start_all",description:"The attribute starts with all of the filter values (comma-separated)"},{predicate:"*_not_start_any",description:"The attribute does not start with any of the filter values (comma-separated)"},{predicate:"*_not_start_all",description:"The attribute starts with none of the filter values (comma-separated)"},{predicate:"*_end",description:"The attribute ends with the filter value"},{predicate:"*_not_end",description:"The attribute does not end with the filter value"},{predicate:"*_end_any",description:"The attribute ends with any of the filter values (comma-separated)"},{predicate:"*_end_all",description:"The attribute ends with all of the filter values (comma-separated)"},{predicate:"*_not_end_any",description:"The attribute does not end with any of the filter values (comma-separated)"},{predicate:"*_not_end_all",description:"The attribute ends with none of the filter values (comma-separated)"},{predicate:"*_cont",description:"The attribute contains the filter value"},{predicate:"*_not_cont",description:"The attribute does not contains the filter value"},{predicate:"*_cont_any",description:"The attribute contains any of the filter values (comma-separated)"},{predicate:"*_cont_all",description:"The attribute contains all of the filter values (comma-separated)"},{predicate:"*_not_cont_all",description:"The attribute contains none of the filter values (comma-separated)"},{predicate:"*_jcont",description:"The attribute contains a portion of the JSON used as filter value (works with object only)"},{predicate:"*_true",description:"The attribute is true"},{predicate:"*_false",description:"The attribute is false"}],wt=u.doc.core_filtering_data,ce=()=>pe().map(e=>e.predicate.replace(/^\*/g,"")),le=e=>{let t=e.startsWith("_")?e:`_${e}`;return ce().some(r=>t.endsWith(r))},kt=(e,...t)=>{if(!le(e))throw new Error("Unknown filter: "+e);let r="";for(let s of t)r+=(r.length===0?"":"_or_")+s;return r+=e.startsWith("_")?e:`_${e}`,r},pe=()=>[...vt];import{CommandHelp as Rt,Help as Et}from"@oclif/core";var de={};h(de,{camelize:()=>qt,capitalize:()=>S,dasherize:()=>Tt,pluralize:()=>$t,singularize:()=>Ct,symbols:()=>x,underscorize:()=>At});var me={};h(me,{symbols:()=>x});var x={check:{small:"\u2714",bkgGreen:"\u2705",squareRoot:"\u221A"},cross:{small:"\u2718",red:"\u274C"},clock:{stopwatch:"\u23F1"},arrow:{down:"\u2193"},selection:{fisheye:"\u25C9"}};x.check.heavy=x.check.small;x.check.whiteHeavy=x.check.bkgGreen;x.cross.heavyBallot=x.cross.small;var S=e=>e&&k.capitalize(e),Tt=e=>e&&(e=e.toLocaleLowerCase(),e.replace(/[ _]/g,"-")),At=e=>e&&(e=e.toLocaleLowerCase(),e.replace(/[ -]/g,"_")),$t=(e,t)=>k.pluralize(e,t),Ct=(e,t)=>k.singularize(e,t),qt=(e,t)=>k.camelize(e,t);var y=!1,W=class extends Rt{examples(t){return y&&console.log("---------- command.examples"),super.examples(t)}},z=class extends Et{async showHelp(t){return y&&console.log("---------- showHelp"),super.showHelp(t)}async showRootHelp(){return y&&console.log("---------- showRootHelp"),super.showRootHelp()}async showTopicHelp(t){return y&&console.log("---------- showTopicHelp"),super.showTopicHelp(t)}async showCommandHelp(t){y&&console.log("---------- showCommandHelp"),await super.showCommandHelp(t)}formatRoot(){return y&&console.log("---------- formatRoot"),super.formatRoot()}formatTopic(t){return y&&console.log("---------- formatTopic"),super.formatTopic(t)}formatTopics(t){y&&console.log("---------- formatTopics");let r=t.filter(s=>!s.hidden).map(s=>(s.description=S(s.description),s));return super.formatTopics(r)}formatCommands(t){return y&&console.log("---------- formatCommands"),super.formatCommands(t).split(`
4
+ `).map(r=>{let s=0;return r.split(" ").map(i=>(i||"").trim()!==""&&++s===2?S(i):i).join(" ")}).join(`
5
+ `)}formatCommand(t){return y&&console.log("---------- formatCommand"),super.formatCommand(t)}getCommandHelpClass(t){return y&&console.log("---------- getCommandHelpClass"),new W(t,this.config,this.opts)}};var ge={};h(ge,{download:()=>St});var St=async e=>{let r=`https://data.${u.api.default_app_domain}/schemas/`,i=`openapi${e?"_"+e.replace(/\./g,"-"):""}.json`,n=r+i;return await(await fetch(n)).json()};var he={};h(he,{buildAssertionPayload:()=>Xt,decodeAccessToken:()=>fe,generateAccessToken:()=>Nt,getAccessToken:()=>Ht,getTokenEnvironment:()=>Yt,isAccessTokenExpiring:()=>Jt,revokeAccessToken:()=>Gt});import{authenticate as N,revoke as Ft}from"@commercelayer/js-auth";import H from"jsonwebtoken";var _e={};h(_e,{dotNotationToObject:()=>F,generateGroupUID:()=>Ut,log:()=>Pt,resetConsole:()=>Lt,sleep:()=>Dt,specialFolder:()=>Vt,userAgent:()=>Wt});import{existsSync as zt,mkdirSync as It}from"fs";import{homedir as Ot}from"os";import{dirname as Kt,sep as Bt}from"path";import{format as Mt,inspect as jt}from"util";var Dt=async e=>new Promise(t=>setTimeout(t,e)),Lt=()=>{process.stdout.write("\x1B[?25h\x1B[?7h")},Pt=(e="",...t)=>{e=typeof e=="string"?e:jt(e),process.stdout.write(Mt(e,...t)+`
6
+ `)},Vt=(e,t=!1)=>{let r=["desktop","home"],s=e.toLowerCase().split(/[\\/]/g)[0];if(r.includes(s)){let n=Ot();s==="desktop"&&(n+=`${Bt}Desktop`),e=e.replace(s,n)}let i=Kt(e);return t&&!zt(i)&&It(i,{recursive:!0}),e},Ut=()=>{let e=Math.trunc(Math.random()*46656),t=Math.trunc(Math.random()*46656),r=("000"+e.toString(36)).slice(-3),s=("000"+t.toString(36)).slice(-3);return r+s},Wt=e=>`${e.name.replace(/@commercelayer\/cli-plugin/,"CLI")}/${e.version}`,F=(e,t)=>{let r=t||{};return Object.entries(e).forEach(([s,i])=>{let n=s.split("."),a=n[n.length-1],m=r;n.forEach(_=>{_===a?m[_]=i:m=m[_]||(m[_]={})})}),t&&Object.assign(t,r),r};var fe=e=>{let t=H.decode(e);if(t===null)throw new Error("Error decoding access token");return t},Nt=(e,t,r)=>{let i={...e,exp:Math.floor(Date.now()/1e3)+r*60,rand:Math.random()},n=u.api.token_encoding_algorithm,a=H.sign(i,t,{algorithm:n,noTimestamp:!0}),m=H.verify(a,t,{algorithms:[n]});return{accessToken:a,info:m,expMinutes:r}},Ht=async e=>{let t,r=e.scope?Array.isArray(e.scope)?e.scope.map(i=>i.trim()).join(","):e.scope:"",s={clientId:e.clientId,clientSecret:e.clientSecret,slug:e.slug,domain:e.domain,scope:r};if(e.email&&e.password?(s.username=e.email,s.password=e.password,t=await N("password",s)):e.assertion?(s.assertion=e.assertion,t=await N("urn:ietf:params:oauth:grant-type:jwt-bearer",s)):t=await N("client_credentials",s),t){if(t.errors)throw new Error(`Unable to get access token: ${t.errors[0].detail}`)}else throw new Error("Unable to get access token");return t},Gt=async(e,t)=>{let r=await Ft({...e,token:t});if(r.errors)throw new Error(r.errors[0].detail)},Jt=e=>{let r=Math.floor(Date.now()/1e3),s=Math.floor(new Date(e.expires).getTime()/1e3);return r>=s-30},Yt=e=>(typeof e=="string"?fe(e):e).test?"test":"live";var Xt=(e,t,r)=>{let s="https://commercelayer.io/claims",i={[s]:{owner:{type:e,id:t}}};if(r&&Object.keys(r).length>0){let n=F(r);i[s].custom_claim=n}return i};var ye={};h(ye,{checkUpdate:()=>er});import I from"chalk";import Zt from"update-notifier-cjs";var Qt=1,er=e=>{let t=Zt({pkg:e,updateCheckInterval:36e5*Qt});t.update&&t.notify({isGlobal:!1,message:`-= ${I.bgWhite.black.bold(` ${e.description} `)} =-
5
7
 
6
- New version available: ${S.dim("{currentVersion}")} -> ${S.green("{latestVersion}")}
7
- Run ${S.cyanBright("commercelayer plugins:update")} to update`})};import{CommandHelp as Jt,Help as Yt}from"@oclif/core";var de={};h(de,{camelize:()=>Gt,capitalize:()=>z,dasherize:()=>Wt,pluralize:()=>Nt,singularize:()=>Ht,symbols:()=>x,underscorize:()=>Ft});var me={};h(me,{symbols:()=>x});var x={check:{small:"\u2714",bkgGreen:"\u2705",squareRoot:"\u221A"},cross:{small:"\u2718",red:"\u274C"},clock:{stopwatch:"\u23F1"},arrow:{down:"\u2193"},selection:{fisheye:"\u25C9"}};x.check.heavy=x.check.small;x.check.whiteHeavy=x.check.bkgGreen;x.cross.heavyBallot=x.cross.small;var z=e=>e&&k.capitalize(e),Wt=e=>e&&(e=e.toLocaleLowerCase(),e.replace(/[ _]/g,"-")),Ft=e=>e&&(e=e.toLocaleLowerCase(),e.replace(/[ -]/g,"_")),Nt=(e,t)=>k.pluralize(e,t),Ht=(e,t)=>k.singularize(e,t),Gt=(e,t)=>k.camelize(e,t);var y=!1,H=class extends Jt{examples(t){return y&&console.log("---------- command.examples"),super.examples(t)}},I=class extends Yt{async showHelp(t){return y&&console.log("---------- showHelp"),super.showHelp(t)}async showRootHelp(){return y&&console.log("---------- showRootHelp"),super.showRootHelp()}async showTopicHelp(t){return y&&console.log("---------- showTopicHelp"),super.showTopicHelp(t)}async showCommandHelp(t){y&&console.log("---------- showCommandHelp"),await super.showCommandHelp(t)}formatRoot(){return y&&console.log("---------- formatRoot"),super.formatRoot()}formatTopic(t){return y&&console.log("---------- formatTopic"),super.formatTopic(t)}formatTopics(t){y&&console.log("---------- formatTopics");let r=t.filter(s=>!s.hidden).map(s=>(s.description=z(s.description),s));return super.formatTopics(r)}formatCommands(t){return y&&console.log("---------- formatCommands"),super.formatCommands(t).split(`
8
- `).map(r=>{let s=0;return r.split(" ").map(n=>(n||"").trim()!==""&&++s===2?z(n):n).join(" ")}).join(`
9
- `)}formatCommand(t){return y&&console.log("---------- formatCommand"),super.formatCommand(t)}getCommandHelpClass(t){return y&&console.log("---------- getCommandHelpClass"),new H(t,this.config,this.opts)}};var ge={};h(ge,{download:()=>Xt});var Xt=async e=>{let r=`https://data.${u.api.default_app_domain}/schemas/`,n=`openapi${e?"_"+e.replace(/\./g,"-"):""}.json`,i=r+n;return await(await fetch(i)).json()};var ye={};h(ye,{apply:()=>er,available:()=>fe,documentation:()=>Qt,filters:()=>he,list:()=>_e});var Zt=[{predicate:"*_eq",description:"The attribute is equal to the filter value"},{predicate:"*_eq_or_null",description:"The attribute is equal to the filter value, including null values"},{predicate:"*_not_eq",description:"The attribute is not equal to the filter value"},{predicate:"*_not_eq_or_null",description:"The attribute is not equal to the filter value, including null values"},{predicate:"*_matches",description:'The attribute matches the filter value with "LIKE" operator'},{predicate:"*_does_not_match",description:'The attribute does not match the filter value with "LIKE" operator'},{predicate:"*_matches_any",description:'The attribute matches all of the filter values (comma-separated) with "LIKE" operator'},{predicate:"*_matches_all",description:'The attribute matches all of the filter values (comma-separated) with "LIKE" operator'},{predicate:"*_does_not_match_any",description:'The attribute does not match any of the filter values (comma-separated) with "LIKE" operator'},{predicate:"*_does_not_match_all",description:'The attribute matches none of the filter values (comma-separated) with "LIKE" operator'},{predicate:"*_lt",description:"The attribute is less than the filter value"},{predicate:"*_lteq",description:"The attribute is less than or equal to the filter value"},{predicate:"*_gt",description:"The attribute is greater than the filter value"},{predicate:"*_gteq",description:"The attribute is greater than or equal to the filter value"},{predicate:"*_present",description:"The attribute is not null and not empty"},{predicate:"*_blank",description:"The attribute is null or empty"},{predicate:"*_null",description:"The attribute is null"},{predicate:"*_not_null",description:"The attribute is not null"},{predicate:"*_in",description:"The attribute matches any of the filter values (comma-separated)"},{predicate:"*_in_or_null",description:"The attribute matches any of the filter values (comma-separated), including null values"},{predicate:"*_not_in",description:"The attribute matches none of the filter values (comma-separated)"},{predicate:"*_not_in_or_null",description:"The attribute matches none of the filter values (comma-separated), including null values"},{predicate:"*_lt_any",description:"The attribute is less than any of the filter values (comma-separated)"},{predicate:"*_lteq_any",description:"The attribute is less than or equal to any of the filter values (comma-separated)"},{predicate:"*_gt_any",description:"The attribute is greater than any of the filter values (comma-separated)"},{predicate:"*_gteq_any",description:"The attribute is greater than or qual to any of the filter values (comma-separated)"},{predicate:"*_lt_all",description:"The attribute is less than all of the filter values (comma-separated)"},{predicate:"*_lteq_all",description:"The attribute is less than or equal to all of the filter values (comma-separated)"},{predicate:"*_gt_all",description:"The attribute is greater than all of the filter values (comma-separated)"},{predicate:"*_gteq_all",description:"The attribute is greater or equal to all of the filter values (comma-separated)"},{predicate:"*_not_eq_all",description:"The attribute is equal to none of the filter values (comma-separated)"},{predicate:"*_start",description:"The attribute starts with the filter value (comma-separated)"},{predicate:"*_not_start",description:"The attribute does not start with the filter value (comma-separated)"},{predicate:"*_start_any",description:"The attribute starts with any of the filter values (comma-separated)"},{predicate:"*_start_all",description:"The attribute starts with all of the filter values (comma-separated)"},{predicate:"*_not_start_any",description:"The attribute does not start with any of the filter values (comma-separated)"},{predicate:"*_not_start_all",description:"The attribute starts with none of the filter values (comma-separated)"},{predicate:"*_end",description:"The attribute ends with the filter value"},{predicate:"*_not_end",description:"The attribute does not end with the filter value"},{predicate:"*_end_any",description:"The attribute ends with any of the filter values (comma-separated)"},{predicate:"*_end_all",description:"The attribute ends with all of the filter values (comma-separated)"},{predicate:"*_not_end_any",description:"The attribute does not end with any of the filter values (comma-separated)"},{predicate:"*_not_end_all",description:"The attribute ends with none of the filter values (comma-separated)"},{predicate:"*_cont",description:"The attribute contains the filter value"},{predicate:"*_not_cont",description:"The attribute does not contains the filter value"},{predicate:"*_cont_any",description:"The attribute contains any of the filter values (comma-separated)"},{predicate:"*_cont_all",description:"The attribute contains all of the filter values (comma-separated)"},{predicate:"*_not_cont_all",description:"The attribute contains none of the filter values (comma-separated)"},{predicate:"*_jcont",description:"The attribute contains a portion of the JSON used as filter value (works with object only)"},{predicate:"*_true",description:"The attribute is true"},{predicate:"*_false",description:"The attribute is false"}],Qt=u.doc.core_filtering_data,_e=()=>he().map(e=>e.predicate.replace(/^\*/g,"")),fe=e=>{let t=e.startsWith("_")?e:`_${e}`;return _e().some(r=>t.endsWith(r))},er=(e,...t)=>{if(!fe(e))throw new Error("Unknown filter: "+e);let r="";for(let s of t)r+=(r.length===0?"":"_or_")+s;return r+=e.startsWith("_")?e:`_${e}`,r},he=()=>[...Zt];export{Z as clApi,ee as clApplication,$ as clColor,te as clCommand,u as clConfig,ye as clFilter,I as clHelp,oe as clOutput,ge as clSchema,me as clSymbol,de as clText,pe as clToken,ue as clUpdate,ce as clUtil};
8
+ New version available: ${I.dim("{currentVersion}")} -> ${I.green("{latestVersion}")}
9
+ Run ${I.cyanBright("commercelayer plugins:update")} to update`})};export{Z as clApi,ee as clApplication,$ as clColor,te as clCommand,u as clConfig,ue as clFilter,z as clHelp,oe as clOutput,ge as clSchema,me as clSymbol,de as clText,he as clToken,ye as clUpdate,_e as clUtil};
package/package.json CHANGED
@@ -1,34 +1,27 @@
1
1
  {
2
2
  "name": "@commercelayer/cli-core",
3
- "version": "6.0.0-beta.8",
3
+ "description": "Commerce Layer Javascript CLI core lib",
4
+ "version": "6.0.0-oclif4.10",
4
5
  "author": "Pierluigi Viti <pierluigi@commercelayer.io>",
5
6
  "license": "MIT",
6
- "description": "Commerce Layer Javascript CLI core lib",
7
+ "repository": "github:commercelayer/commercelayer-cli-core",
7
8
  "main": "lib/index.js",
8
9
  "types": "lib/index.d.ts",
9
10
  "module": "lib/index.mjs",
10
11
  "exports": {
11
- ".": {
12
- "import": {
13
- "types": "./lib/index.d.mts",
14
- "default": "./lib/index.mjs"
15
- },
16
- "require": {
17
- "types": "./lib/index.d.ts",
18
- "default": "./lib/index.js"
19
- }
20
- }
12
+ "types": "./lib/index.d.ts",
13
+ "require": "./lib/index.js",
14
+ "import": "./lib/index.mjs"
21
15
  },
22
16
  "scripts": {
23
- "lint": "eslint ./src --ext .ts",
24
- "lintspec": "eslint ./specs/ --ext .spec.ts",
25
- "lint:fix": "eslint src --fix",
26
17
  "build": "tsup",
27
18
  "start": "tsx src/index.ts",
28
- "test": "jest --passWithNoTests",
19
+ "test": "vitest run",
29
20
  "test-local": "tsx test/spot.ts",
30
- "coverage": "jest --coverage",
31
- "release": "pnpm upgrade && pnpm lint && pnpm build"
21
+ "coverage": "vitest run --coverage",
22
+ "lint": "biome check --enforce-assist=true",
23
+ "check": "biome check --enforce-assist=true --write",
24
+ "release": "pnpm upgrade && pnpm lint && pnpm build && pnpm test"
32
25
  },
33
26
  "keywords": [
34
27
  "ecommerce",
@@ -38,39 +31,30 @@
38
31
  "lib/**/*"
39
32
  ],
40
33
  "engines": {
41
- "node": ">=20"
34
+ "node": ">=22"
42
35
  },
43
36
  "devDependencies": {
44
- "@babel/preset-env": "^7.29.2",
45
- "@babel/preset-typescript": "^7.28.5",
46
- "@commercelayer/eslint-config-ts": "^2.6.0",
47
- "@oclif/core": "^4.0.18",
37
+ "@biomejs/biome": "^2.4.9",
48
38
  "@semantic-release/changelog": "^6.0.3",
49
39
  "@semantic-release/git": "^10.0.1",
50
- "@types/jest": "^30.0.0",
51
40
  "@types/jsonwebtoken": "^9.0.10",
52
- "@types/node": "^24.12.0",
53
- "@typescript-eslint/eslint-plugin": "^7.18.0",
41
+ "@types/node": "^25.5.0",
42
+ "@vitest/coverage-v8": "^4.1.2",
54
43
  "dotenv": "^17.3.1",
55
- "eslint": "^8.57.1",
56
- "jest": "^30.3.0",
57
- "oclif": "^4.22.92",
44
+ "oclif": "^4.22.96",
58
45
  "semantic-release": "^25.0.3",
59
46
  "tsup": "^8.5.1",
60
47
  "tsx": "^4.21.0",
61
- "typescript": "^5.9.3"
48
+ "typescript": "^5.9.3",
49
+ "vitest": "^4.1.2"
62
50
  },
63
51
  "dependencies": {
64
52
  "@commercelayer/js-auth": "^7.3.0",
65
- "@oclif/core": "^4.9.0",
66
- "chalk": "^5.6.2",
53
+ "@oclif/core": "^4.10.3",
54
+ "chalk": "^4.1.2",
67
55
  "jsonwebtoken": "^9.0.3",
68
56
  "update-notifier-cjs": "^5.1.7"
69
57
  },
70
- "peerDependencies": {
71
- "@oclif/core": "^4"
72
- },
73
- "repository": "github:commercelayer/commercelayer-cli-core",
74
58
  "publishConfig": {
75
59
  "access": "public"
76
60
  }