@commercelayer/cli-core 4.12.1 → 5.0.0-oclif3.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.
Files changed (83) hide show
  1. package/lib/index.d.mts +593 -0
  2. package/lib/index.d.ts +593 -0
  3. package/lib/index.js +11 -0
  4. package/lib/index.mjs +11 -0
  5. package/package.json +21 -28
  6. package/lib/cjs/api.d.ts +0 -41
  7. package/lib/cjs/api.js +0 -107
  8. package/lib/cjs/application.d.ts +0 -34
  9. package/lib/cjs/application.js +0 -36
  10. package/lib/cjs/color.d.ts +0 -107
  11. package/lib/cjs/color.js +0 -116
  12. package/lib/cjs/command.d.ts +0 -21
  13. package/lib/cjs/command.js +0 -95
  14. package/lib/cjs/config.d.ts +0 -92
  15. package/lib/cjs/config.js +0 -182
  16. package/lib/cjs/filter.d.ts +0 -10
  17. package/lib/cjs/filter.js +0 -81
  18. package/lib/cjs/help.d.ts +0 -17
  19. package/lib/cjs/help.js +0 -103
  20. package/lib/cjs/index.d.ts +0 -19
  21. package/lib/cjs/index.js +0 -46
  22. package/lib/cjs/inflector.d.ts +0 -26
  23. package/lib/cjs/inflector.js +0 -255
  24. package/lib/cjs/jsonapi.d.ts +0 -2
  25. package/lib/cjs/jsonapi.js +0 -38
  26. package/lib/cjs/output.d.ts +0 -28
  27. package/lib/cjs/output.js +0 -83
  28. package/lib/cjs/raw.d.ts +0 -12
  29. package/lib/cjs/raw.js +0 -49
  30. package/lib/cjs/schema.d.ts +0 -2
  31. package/lib/cjs/schema.js +0 -20
  32. package/lib/cjs/style.d.ts +0 -14
  33. package/lib/cjs/style.js +0 -39
  34. package/lib/cjs/symbol.d.ts +0 -2
  35. package/lib/cjs/symbol.js +0 -28
  36. package/lib/cjs/text.d.ts +0 -6
  37. package/lib/cjs/text.js +0 -23
  38. package/lib/cjs/token.d.ts +0 -58
  39. package/lib/cjs/token.js +0 -177
  40. package/lib/cjs/update.d.ts +0 -7
  41. package/lib/cjs/update.js +0 -22
  42. package/lib/cjs/util.d.ts +0 -9
  43. package/lib/cjs/util.js +0 -59
  44. package/lib/esm/api.d.ts +0 -41
  45. package/lib/esm/api.js +0 -93
  46. package/lib/esm/application.d.ts +0 -34
  47. package/lib/esm/application.js +0 -26
  48. package/lib/esm/color.d.ts +0 -107
  49. package/lib/esm/color.js +0 -110
  50. package/lib/esm/command.d.ts +0 -21
  51. package/lib/esm/command.js +0 -90
  52. package/lib/esm/config.d.ts +0 -92
  53. package/lib/esm/config.js +0 -180
  54. package/lib/esm/filter.d.ts +0 -10
  55. package/lib/esm/filter.js +0 -71
  56. package/lib/esm/help.d.ts +0 -17
  57. package/lib/esm/help.js +0 -100
  58. package/lib/esm/index.d.ts +0 -19
  59. package/lib/esm/index.js +0 -26
  60. package/lib/esm/inflector.d.ts +0 -26
  61. package/lib/esm/inflector.js +0 -253
  62. package/lib/esm/jsonapi.d.ts +0 -2
  63. package/lib/esm/jsonapi.js +0 -42
  64. package/lib/esm/output.d.ts +0 -28
  65. package/lib/esm/output.js +0 -72
  66. package/lib/esm/raw.d.ts +0 -12
  67. package/lib/esm/raw.js +0 -42
  68. package/lib/esm/schema.d.ts +0 -2
  69. package/lib/esm/schema.js +0 -14
  70. package/lib/esm/style.d.ts +0 -14
  71. package/lib/esm/style.js +0 -19
  72. package/lib/esm/symbol.d.ts +0 -2
  73. package/lib/esm/symbol.js +0 -25
  74. package/lib/esm/text.d.ts +0 -6
  75. package/lib/esm/text.js +0 -13
  76. package/lib/esm/token.d.ts +0 -58
  77. package/lib/esm/token.js +0 -166
  78. package/lib/esm/update.d.ts +0 -7
  79. package/lib/esm/update.js +0 -16
  80. package/lib/esm/util.d.ts +0 -9
  81. package/lib/esm/util.js +0 -51
  82. package/lib/tsconfig.esm.tsbuildinfo +0 -1
  83. package/lib/tsconfig.tsbuildinfo +0 -1
package/lib/index.mjs ADDED
@@ -0,0 +1,11 @@
1
+ var ye=Object.defineProperty;var _=(e,t)=>{for(var r in t)ye(e,r,{get:t[r],enumerable:!0})};var Y={};_(Y,{Operation:()=>P,baseURL:()=>$e,execMode:()=>qe,extractDomain:()=>Ce,humanizeResource:()=>Re,isResourceCacheable:()=>G,liveEnvironment:()=>Ee,request:()=>ze,requestDataFile:()=>L,requestRateLimitDelay:()=>J,requestRaw:()=>K,response:()=>Ie,responseDenormalize:()=>U});var O=["in_progress","pending","completed","interrupted"],xe=["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","tags","tax_categories"],ve=["addresses","bundles","coupons","customer_subscriptions","customers","gift_cards","line_items","orders","payment_methods","price_tiers","prices","shipments","shipping_categories","shipping_methods","sku_lists","sku_list_items","sku_options","skus","stock_items","tax_categories","transactions","authorizations","captures","voids","refunds"],Te=["bundles","gift_cards","prices","promotions","sku_lists","sku_options","skus","stock_items"],we=["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"],y={erl_oauth_limit_live:30,erl_burst_limit_uncachable_live:50,erl_burst_limit_uncachable_test:25,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_average_limit_cachable_live:1e3,erl_average_limit_cachable_test:500},ke={api:{default_domain:"commercelayer.io",default_app_domain:"commercelayer.app",default_stg_domain:"commercelayer.co",token_expiration_mins:60*4,token_encoding_algorithm:"HS512",requests_max_num_burst:y.erl_burst_limit_uncachable_live,requests_max_num_burst_cacheable:y.erl_burst_limit_cachable_live,requests_max_num_burst_test:y.erl_burst_limit_uncachable_test,requests_max_num_burst_test_cacheable:y.erl_burst_limit_cachable_test,requests_max_num_avg:y.erl_average_limit_uncachable_live,requests_max_num_avg_cacheable:y.erl_average_limit_cachable_live,requests_max_num_avg_test:y.erl_average_limit_uncachable_test,requests_max_num_avg_test_cacheable:y.erl_average_limit_cachable_test,requests_max_num_oauth:y.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:["integration","sales_channel","webapp","user"],login_scopes:["market","stock_location"]},imports:{max_size:1e4,statuses:O,types:xe,max_queue_length:10,attachment_expiration:5},exports:{max_size:1e4,statuses:O,types:ve,max_queue_length:10,attachment_expiration:5},cleanups:{max_size:1e4,statuses:O,types:Te,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"},tags:{max_resource_tags:10,taggable_resources:we,tag_name_max_length:25,tag_name_pattern:/^[0-9A-Za-z_-]{1,25}$/},provisioning:{default_subdomain:"provisioning",scope:"provisioning-api",applications:["user"]}},u=ke;import{readFileSync as Ae}from"fs";var K=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=Ae(e,"utf-8")}catch{throw new Error(`Unable to find or open the data file ${A.msg.error(e)}`)}try{r=JSON.parse(t)}catch{throw new Error(`Unable to parse the data file ${A.msg.error(e)}: invalid JSON format`)}return r.data?r:{data:r}},P=(r=>(r.Create="POST",r.Update="PATCH",r))(P||{});var N=(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(N(n,t),t)):r[s]=E(N(i,t),t):i===null&&(r[s]=null)}),r},U=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};var $e=(e="core",t,r)=>`https://${(e==="core"&&t||e).toLowerCase()}.${r||u.api.default_domain}`,Ce=e=>{if(e)return e.substring(e.indexOf(".")+1)},qe=e=>e===!0||e==="live"?"live":"test",Re=e=>e.replace(/_/g," ");var Se=["bundles","imports","markets","prices","price_lists","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"],G=(e,t)=>Se.includes(e||"")&&(t||"GET").toUpperCase()==="GET",Ee=e=>e==="live",J=e=>{let t=e?.environment||"test",r=e?.parallelRequests||1,s=G(e?.resourceType,e?.method),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;t!=="live"&&(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,b=r*a,T=r*m,f=e?.totalRequests,c=0;return f?f>i&&(f>n?c=T:c=b):c=Math.max(b,T),c=c*1e3,e?.minimumDelay&&(c=Math.max(e.minimumDelay,c)),e?.securityDelay&&(c+=e.securityDelay),c=Math.ceil(c),c};var ze={raw:K,readDataFile:L,rateLimitDelay:J},Ie={denormalize:U};var Z={};_(Z,{appKey:()=>Be,appKeyMatch:()=>De,appKeyValid:()=>Me,arrayScope:()=>X,isProvisioningApp:()=>Oe});var Be=()=>Date.now().toString(36),Me=e=>e.key!==void 0&&e.key!=="",De=(e,t)=>{let r=e!==void 0,s=t!==void 0;return!r&&!s||r&&s&&e.key===t.key},X=e=>e?Array.isArray(e)?e:[e]:[],Oe=e=>X(e.scope).includes(u.provisioning.scope)||e.api==="provisioning";var Q={};_(Q,{allFlags:()=>Le,commandFlags:()=>Ke,findLongStringFlag:()=>Ue,fixDashedFlagValue:()=>je,fixValueType:()=>Pe});var Ke=(e,t)=>{let r={...e};if(t)for(let s of t)delete r[s];return r},Le=e=>({...e.flags,...e.baseFlags});var Pe=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},je=(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,b=a?t.char.startsWith("-")?a:`-${a}`:void 0,T=e.findIndex(k=>b&&k.startsWith(b)||m&&k.startsWith(m));if(T<0)return e;let f=e[T],c="",H="";if(b&&f.startsWith(b))c=f.replace(b,"").trim(),f=b;else if(m&&f.startsWith(m))c=f.replace(m,"").trim(),f=m;else return e;if(c.startsWith("=")?(c=c.slice(1),H=f+"="):c||(c=e[++T]),c.startsWith("-")||c.startsWith(i)){let k=c.startsWith(`${i}`)?c.replace(`${i}`,""):c.replace("-",`${i}-`);if(e[T]=H+k,c.startsWith(i)&&s){let S=n?n.replace("--",""):void 0,B=Object.entries(s.flags).find(([D,be])=>be===c);B&&(!S||S===B[0])&&(s.flags[B[0]]=k);let M=Object.values(s.raw).find(D=>D.type==="flag"&&D.input===c);M&&(!S||S===M.flag)&&(M.input=k)}}return e};var ie={};_(ie,{center:()=>Fe,cleanDate:()=>He,formatError:()=>Ge,formatOutput:()=>se,localeDate:()=>Ne,maxLength:()=>Ve,printCSV:()=>re,printJSON:()=>te,printObject:()=>ee});import{inspect as We}from"util";var ee=(e,t)=>We(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}),te=(e,t)=>JSON.stringify(e,null,t?.unformatted?void 0:t?.tabSize||4),re=(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},Fe=(e,t)=>e.padStart(e.length+Math.floor((t-e.length)/2)," ").padEnd(t," "),Ve=(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),He=e=>e.replace("T"," ").replace("Z","").substring(0,e.lastIndexOf(".")),Ne=e=>e?new Date(Date.parse(e)).toLocaleString():"",se=(e,t,{color:r=!0}={})=>{if(!e)return"";if(typeof e=="string")return e;if(t){if(t.csv)return re(e,t);if(t.json)return te(e,{unformatted:t.unformatted})}return ee(e,{color:r})},Ge=(e,t)=>se(e.errors||e,t);var A={};_(A,{api:()=>gt,bg:()=>mt,black:()=>it,blackBright:()=>nt,blue:()=>tt,blueBright:()=>C,bold:()=>W,cli:()=>ft,cyan:()=>at,cyanBright:()=>$,dim:()=>pt,green:()=>Qe,greenBright:()=>j,grey:()=>ot,hidden:()=>Xe,italic:()=>w,magenta:()=>ct,magentaBright:()=>lt,msg:()=>_t,red:()=>Ze,redBright:()=>ne,reset:()=>Je,style:()=>l,table:()=>ht,type:()=>dt,underline:()=>ut,visible:()=>Ye,white:()=>rt,whiteBright:()=>st,yellow:()=>et,yellowBright:()=>v});import o from"chalk";var Je=o.reset,Ye=o.visible,Xe=o.hidden,Ze=o.red,ne=o.redBright,Qe=o.green,j=o.greenBright,et=o.yellow,v=o.yellowBright,tt=o.blue,C=o.blueBright,rt=o.white,st=o.whiteBright,it=o.black,nt=o.blackBright,ot=o.grey,at=o.cyan,$=o.cyanBright,ct=o.magenta,lt=o.magentaBright,W=o.bold,pt=o.dim,ut=o.underline,w=o.italic,mt={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:W,token:C,resource:W,attribute:w,trigger:$,kind:$,live:j,test:v,execMode:e=>e==="live"?l.live:l.test,success:j,warning:v,error:ne,arg:w,flag:w,command:w,value:w,alias:$,plugin:C,title:C,path:w,datetime:$,number:v},dt={datetime:l.datetime,number:l.number,path:l.path},gt={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},_t={success:l.success,warning:l.warning,error:l.error},ft={arg:l.arg,flag:l.flag,command:l.command,value:l.value,alias:l.alias,plugin:l.plugin},ht={header:v.bold,key:C};var ce={};_(ce,{decodeAccessToken:()=>ae,generateAccessToken:()=>yt,getAccessToken:()=>xt,getTokenEnvironment:()=>wt,isAccessTokenExpiring:()=>Tt,revokeAccessToken:()=>vt});import F from"jsonwebtoken";import{authenticate as oe,revoke as bt}from"@commercelayer/js-auth";var ae=e=>{let t=F.decode(e);if(t===null)throw new Error("Error decoding access token");return t},yt=(e,t,r)=>{let i={...e,exp:Math.floor(Date.now()/1e3)+r*60,rand:Math.random()},n=u.api.token_encoding_algorithm,a=F.sign(i,t,{algorithm:n,noTimestamp:!0}),m=F.verify(a,t,{algorithms:[n]});return{accessToken:a,info:m,expMinutes:r}},xt=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 oe("password",s)):t=await oe("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},vt=async(e,t)=>{let r=await bt({...e,token:t});if(r.errors)throw new Error(r.errors[0].detail)},Tt=e=>{let r=Math.floor(Date.now()/1e3),s=Math.floor(new Date(e.expires).getTime()/1e3);return r>=s-30},wt=e=>(typeof e=="string"?ae(e):e).test?"test":"live";var le={};_(le,{checkUpdate:()=>$t});import z from"chalk";import kt from"update-notifier-cjs";var At=1,$t=e=>{let t=kt({pkg:e,updateCheckInterval:36e5*At});t.update&&t.notify({isGlobal:!1,message:`-= ${z.bgWhite.black.bold(` ${e.description} `)} =-
4
+
5
+ New version available: ${z.dim("{currentVersion}")} -> ${z.green("{latestVersion}")}
6
+ Run ${z.cyanBright("commercelayer plugins:update")} to update`})};var pe={};_(pe,{generateGroupUID:()=>Kt,log:()=>Dt,resetConsole:()=>Mt,sleep:()=>Bt,specialFolder:()=>Ot,userAgent:()=>Lt});import{format as Ct,inspect as qt}from"util";import{sep as Rt,dirname as St}from"path";import{homedir as Et}from"os";import{existsSync as zt,mkdirSync as It}from"fs";var Bt=async e=>new Promise(t=>setTimeout(t,e)),Mt=()=>{process.stdout.write("\x1B[?25h\x1B[?7h")},Dt=(e="",...t)=>{e=typeof e=="string"?e:qt(e),process.stdout.write(Ct(e,...t)+`
7
+ `)},Ot=(e,t=!1)=>{let r=["desktop","home"],s=e.toLowerCase().split(/[\\\/]/g)[0];if(r.includes(s)){let n=Et();s==="desktop"&&(n+=`${Rt}Desktop`),e=e.replace(s,n)}let i=St(e);return t&&!zt(i)&&It(i,{recursive:!0}),e},Kt=()=>{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},Lt=e=>`${e.name.replace(/@commercelayer\/cli-plugin/,"CLI")}/${e.version}`;import{CommandHelp as Wt,Help as Ft}from"@oclif/core";var me={};_(me,{camelize:()=>jt,capitalize:()=>R,pluralize:()=>Pt,singularize:()=>Ut,symbols:()=>x});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 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: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 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: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 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: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 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}},q=p;var ue={};_(ue,{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 R=e=>e&&q.capitalize(e),Pt=(e,t)=>q.pluralize(e,t),Ut=(e,t)=>q.singularize(e,t),jt=(e,t)=>q.camelize(e,t);var h=!1,V=class extends Wt{examples(t){return h&&console.log("---------- command.examples"),super.examples(t)}},I=class extends Ft{async showHelp(t){return h&&console.log("---------- showHelp"),super.showHelp(t)}async showRootHelp(){return h&&console.log("---------- showRootHelp"),super.showRootHelp()}async showTopicHelp(t){return h&&console.log("---------- showTopicHelp"),super.showTopicHelp(t)}async showCommandHelp(t){h&&console.log("---------- showCommandHelp");let r=t.id,s=r?r.split(":").length:1,i=this.sortedTopics.filter(m=>m.name.startsWith(r+":")&&m.name.split(":").length===s+1),n=this.sortedCommands.filter(m=>m.id.startsWith(r+":")&&m.id.split(":").length===s+1),a=t.description&&this.render(t.description).split(`
8
+ `)[0];a&&console.log(`${R(a)}
9
+ `),console.log(this.formatCommand(t)),console.log(""),i.length>0&&(console.log(this.formatTopics(i)),console.log("")),n.length>0&&(console.log(this.formatCommands(n)),console.log(""))}formatRoot(){return h&&console.log("---------- formatRoot"),super.formatRoot()}formatTopic(t){return h&&console.log("---------- formatTopic"),super.formatTopic(t)}formatTopics(t){h&&console.log("---------- formatTopics");let r=t.filter(s=>!s.hidden).map(s=>(s.description=R(s.description),s));return super.formatTopics(r)}formatCommands(t){return h&&console.log("---------- formatCommands"),super.formatCommands(t).split(`
10
+ `).map(r=>{let s=0;return r.split(" ").map(i=>(i||"").trim()!==""&&++s===2?R(i):i).join(" ")}).join(`
11
+ `)}formatCommand(t){return h&&console.log("---------- formatCommand"),super.formatCommand(t)}getCommandHelpClass(t){return h&&console.log("---------- getCommandHelpClass"),new V(t,this.config,this.opts)}};var de={};_(de,{download:()=>Vt});var Vt=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={};_(he,{apply:()=>Gt,available:()=>_e,documentation:()=>Nt,filters:()=>fe,list:()=>ge});var Ht=[{predicate:"*_eq",description:"The attribute is equal to the filter value"},{predicate:"*_not_eq",description:"The attribute is not equal to the filter value"},{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:"*_not_in",description:"The attribute matches none of the filter values (comma-separated)"},{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"}],Nt=u.doc.core_filtering_data,ge=()=>fe().map(e=>e.predicate.replace(/^\*/g,"")),_e=e=>{let t=e.startsWith("_")?e:`_${e}`;return ge().some(r=>t.endsWith(r))},Gt=(e,...t)=>{if(!_e(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},fe=()=>[...Ht];export{Y as clApi,Z as clApplication,A as clColor,Q as clCommand,u as clConfig,he as clFilter,I as clHelp,ie as clOutput,de as clSchema,ue as clSymbol,me as clText,ce as clToken,le as clUpdate,pe as clUtil};
package/package.json CHANGED
@@ -1,38 +1,39 @@
1
1
  {
2
2
  "name": "@commercelayer/cli-core",
3
- "version": "4.12.1",
3
+ "version": "5.0.0-oclif3.10",
4
+ "author": "Pierluigi Viti <pierluigi@commercelayer.io>",
5
+ "license": "MIT",
6
+ "description": "Commerce Layer Javascript CLI core lib",
4
7
  "main": "lib/cjs/index.js",
5
8
  "types": "lib/cjs/index.d.ts",
6
9
  "module": "lib/esm/index.js",
10
+ "exports": {
11
+ "require": "./lib/cjs/index.js",
12
+ "import": "./lib/esm/index.js"
13
+ },
7
14
  "scripts": {
8
15
  "lint": "eslint ./src --ext .ts",
9
16
  "lintspec": "eslint ./specs/ --ext .spec.ts",
10
17
  "lint:fix": "eslint src --fix",
11
- "build": "rm -rf lib && tsc -b tsconfig.json tsconfig.esm.json --verbose",
18
+ "build": "tsup",
12
19
  "start": "ts-node src/index.ts",
13
- "prepare": "npm run build",
14
20
  "test": "jest --passWithNoTests",
15
21
  "test-local": "ts-node test/spot.ts",
16
- "coverage": "jest --coverage",
17
- "size": "size-limit",
18
- "analyze": "size-limit --why"
22
+ "coverage": "jest --coverage"
19
23
  },
20
24
  "keywords": [
21
25
  "ecommerce",
22
26
  "jamstack",
23
27
  "commercelayer"
24
28
  ],
25
- "author": "Pierluigi Viti <pierluigi@commercelayer.io>",
26
- "license": "MIT",
27
- "description": "Commerce Layer Javascript CLI core lib",
28
29
  "files": [
29
30
  "lib/**/*"
30
31
  ],
31
32
  "engines": {
32
- "node": "^16.13.0 || >=18.0.0"
33
+ "node": ">=20"
33
34
  },
34
35
  "devDependencies": {
35
- "@babel/preset-env": "^7.24.3",
36
+ "@babel/preset-env": "^7.24.4",
36
37
  "@babel/preset-typescript": "^7.24.1",
37
38
  "@commercelayer/eslint-config-ts": "^1.4.5",
38
39
  "@semantic-release/changelog": "^6.0.3",
@@ -40,21 +41,20 @@
40
41
  "@size-limit/preset-small-lib": "^6.0.4",
41
42
  "@types/jest": "^29.5.12",
42
43
  "@types/jsonwebtoken": "^9.0.6",
43
- "@types/node": "^20.11.30",
44
- "@typescript-eslint/eslint-plugin": "^6.21.0",
44
+ "@types/node": "^20.12.6",
45
+ "@typescript-eslint/eslint-plugin": "^7.6.0",
45
46
  "dotenv": "^16.4.5",
46
47
  "eslint": "^8.57.0",
47
48
  "jest": "^29.7.0",
48
- "minimize-js": "^1.4.0",
49
- "oclif": "^4.7.0",
50
- "semantic-release": "^23.0.6",
49
+ "oclif": "^4.7.7",
50
+ "semantic-release": "^23.0.7",
51
51
  "ts-node": "^10.9.2",
52
- "typescript": "^5.4.3"
52
+ "tsup": "^8.0.2",
53
+ "typescript": "^5.4.4"
53
54
  },
54
55
  "dependencies": {
55
- "@commercelayer/js-auth": "^5.2.1",
56
- "@oclif/core": "^2.15.0",
57
- "axios": "1.6.8",
56
+ "@commercelayer/js-auth": "^6.0.0",
57
+ "@oclif/core": "^3.26.2",
58
58
  "chalk": "^4.1.2",
59
59
  "jsonwebtoken": "^9.0.2",
60
60
  "update-notifier-cjs": "^5.1.6"
@@ -62,12 +62,5 @@
62
62
  "repository": "github:commercelayer/commercelayer-cli-core",
63
63
  "publishConfig": {
64
64
  "access": "public"
65
- },
66
- "size-limit": [
67
- {
68
- "path": "lib",
69
- "limit": "350 kB",
70
- "webpack": false
71
- }
72
- ]
65
+ }
73
66
  }
package/lib/cjs/api.d.ts DELETED
@@ -1,41 +0,0 @@
1
- import type { Method } from 'axios';
2
- import { rawRequest, readDataFile, Operation } from './raw';
3
- import { denormalize } from './jsonapi';
4
- type ApiMode = 'test' | 'live';
5
- type ApiType = 'core' | 'provisioning' | 'metrics';
6
- export type { ApiMode, ApiType };
7
- /** Build base URL */
8
- declare const baseURL: (slug?: string, domain?: string, provisioning?: boolean) => string;
9
- /** Extract domain name from URL */
10
- declare const extractDomain: (baseUrl: string) => string | undefined;
11
- /** Decode API execution mode */
12
- declare const execMode: (liveFlag: string | boolean | undefined) => ApiMode;
13
- declare const humanizeResource: (type: string) => string;
14
- export { baseURL, extractDomain, execMode, humanizeResource };
15
- export declare const isResourceCacheable: (resource?: string, method?: Method) => boolean;
16
- export type DelayOptions = {
17
- environment?: ApiMode;
18
- parallelRequests?: number;
19
- totalRequests?: number;
20
- minimumDelay?: number;
21
- securityDelay?: number;
22
- resourceType?: string;
23
- method?: Method;
24
- };
25
- export declare const liveEnvironment: (env: ApiMode) => boolean;
26
- export declare const requestRateLimitDelay: (options?: DelayOptions) => number;
27
- export { rawRequest as requestRaw, readDataFile as requestDataFile, Operation };
28
- export { denormalize as responseDenormalize };
29
- export declare const request: {
30
- raw: (config: {
31
- baseUrl: string;
32
- resource: string;
33
- accessToken: string;
34
- operation: Operation;
35
- }, data: any, id?: string | undefined) => Promise<any>;
36
- readDataFile: (file: string) => any;
37
- rateLimitDelay: (options?: DelayOptions) => number;
38
- };
39
- export declare const response: {
40
- denormalize: (response: any) => any;
41
- };
package/lib/cjs/api.js DELETED
@@ -1,107 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.response = exports.request = exports.responseDenormalize = exports.Operation = exports.requestDataFile = exports.requestRaw = exports.requestRateLimitDelay = exports.liveEnvironment = exports.isResourceCacheable = exports.humanizeResource = exports.execMode = exports.extractDomain = exports.baseURL = void 0;
7
- const config_1 = __importDefault(require("./config"));
8
- const raw_1 = require("./raw");
9
- Object.defineProperty(exports, "requestRaw", { enumerable: true, get: function () { return raw_1.rawRequest; } });
10
- Object.defineProperty(exports, "requestDataFile", { enumerable: true, get: function () { return raw_1.readDataFile; } });
11
- Object.defineProperty(exports, "Operation", { enumerable: true, get: function () { return raw_1.Operation; } });
12
- const jsonapi_1 = require("./jsonapi");
13
- Object.defineProperty(exports, "responseDenormalize", { enumerable: true, get: function () { return jsonapi_1.denormalize; } });
14
- /** Build base URL */
15
- const baseURL = (slug, domain, provisioning) => {
16
- const subdomain = provisioning ? 'provisioning' : (slug || '');
17
- return `https://${subdomain.toLowerCase()}.${domain || config_1.default.api.default_domain}`;
18
- };
19
- exports.baseURL = baseURL;
20
- /** Extract domain name from URL */
21
- const extractDomain = (baseUrl) => {
22
- if (!baseUrl)
23
- return undefined;
24
- return baseUrl.substring(baseUrl.indexOf('.') + 1);
25
- };
26
- exports.extractDomain = extractDomain;
27
- /** Decode API execution mode */
28
- const execMode = (liveFlag) => {
29
- return ((liveFlag === true) || (liveFlag === 'live')) ? 'live' : 'test';
30
- };
31
- exports.execMode = execMode;
32
- const humanizeResource = (type) => {
33
- return type.replace(/_/g, ' ');
34
- };
35
- exports.humanizeResource = humanizeResource;
36
- const CACHEABLE_RESOURCES = [
37
- 'bundles',
38
- 'imports',
39
- 'markets',
40
- 'prices',
41
- 'price_lists',
42
- 'promotions',
43
- 'external_promotions',
44
- 'fixed_amount_promotions',
45
- 'fixed_price_promotions',
46
- 'free_gift_promotions',
47
- 'free_shipping_promotions',
48
- 'percentage_discount_promotions',
49
- 'skus',
50
- 'sku_options',
51
- 'stock_items',
52
- 'stock_locations'
53
- ];
54
- const isResourceCacheable = (resource, method) => {
55
- return CACHEABLE_RESOURCES.includes(resource || '') && ((method || 'get').toLowerCase() === 'get');
56
- };
57
- exports.isResourceCacheable = isResourceCacheable;
58
- const liveEnvironment = (env) => {
59
- return (env === 'live');
60
- };
61
- exports.liveEnvironment = liveEnvironment;
62
- const requestRateLimitDelay = (options) => {
63
- const env = (options === null || options === void 0 ? void 0 : options.environment) || 'test';
64
- const parallelRequests = (options === null || options === void 0 ? void 0 : options.parallelRequests) || 1;
65
- const resourceCacheable = (0, exports.isResourceCacheable)(options === null || options === void 0 ? void 0 : options.resourceType, options === null || options === void 0 ? void 0 : options.method);
66
- let requestsMaxNumBurst = resourceCacheable ? config_1.default.api.requests_max_num_burst_cacheable : config_1.default.api.requests_max_num_burst;
67
- let requestsMaxNumAvg = resourceCacheable ? config_1.default.api.requests_max_num_avg_cacheable : config_1.default.api.requests_max_num_avg;
68
- // Test env allows half number of requests than live
69
- if (env !== 'live') {
70
- requestsMaxNumBurst = resourceCacheable ? config_1.default.api.requests_max_num_burst_test_cacheable : config_1.default.api.requests_max_num_burst_test;
71
- requestsMaxNumAvg = resourceCacheable ? config_1.default.api.requests_max_num_avg_test_cacheable : config_1.default.api.requests_max_num_avg_test;
72
- }
73
- const unitDelayBurst = config_1.default.api.requests_max_secs_burst / requestsMaxNumBurst;
74
- const unitDelayAvg = config_1.default.api.requests_max_secs_avg / requestsMaxNumAvg;
75
- const delayBurst = parallelRequests * unitDelayBurst;
76
- const delayAvg = parallelRequests * unitDelayAvg;
77
- // If the total number of requests is known the delay can be optimized
78
- const totalRequests = options === null || options === void 0 ? void 0 : options.totalRequests;
79
- let delay = 0;
80
- if (totalRequests) {
81
- if (totalRequests > requestsMaxNumBurst) {
82
- if (totalRequests > requestsMaxNumAvg)
83
- delay = delayAvg;
84
- else
85
- delay = delayBurst;
86
- }
87
- }
88
- else
89
- delay = Math.max(delayBurst, delayAvg);
90
- // Msec delay
91
- delay = delay * 1000;
92
- if (options === null || options === void 0 ? void 0 : options.minimumDelay)
93
- delay = Math.max(options.minimumDelay, delay);
94
- if (options === null || options === void 0 ? void 0 : options.securityDelay)
95
- delay += options.securityDelay;
96
- delay = Math.ceil(delay);
97
- return delay;
98
- };
99
- exports.requestRateLimitDelay = requestRateLimitDelay;
100
- exports.request = {
101
- raw: raw_1.rawRequest,
102
- readDataFile: raw_1.readDataFile,
103
- rateLimitDelay: exports.requestRateLimitDelay
104
- };
105
- exports.response = {
106
- denormalize: jsonapi_1.denormalize
107
- };
@@ -1,34 +0,0 @@
1
- import type { ApiMode, ApiType } from "./api";
2
- import type { AuthScope } from "./token";
3
- interface AppKey {
4
- key: string;
5
- mode: ApiMode;
6
- id?: string;
7
- alias?: string;
8
- }
9
- interface AppAuth {
10
- slug?: string;
11
- domain?: string;
12
- clientId: string;
13
- clientSecret?: string;
14
- scope?: AuthScope;
15
- email?: string;
16
- password?: string;
17
- api?: ApiType;
18
- }
19
- interface AppInfo extends AppKey, AppAuth {
20
- organization?: string;
21
- kind: string;
22
- name: string;
23
- baseUrl?: string;
24
- }
25
- export type { AppKey, AppAuth, AppInfo };
26
- /** Build application key */
27
- declare const appKey: () => string;
28
- /** Check application key */
29
- declare const appKeyValid: (appKey: AppKey) => boolean;
30
- /** Check if two application keys are equal */
31
- declare const appKeyMatch: (app1?: AppKey, app2?: AppKey) => boolean;
32
- declare const arrayScope: (scope?: AuthScope) => string[];
33
- declare const isProvisioningApp: (app: AppAuth) => boolean;
34
- export { appKey, appKeyValid, appKeyMatch, arrayScope, isProvisioningApp };
@@ -1,36 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.isProvisioningApp = exports.arrayScope = exports.appKeyMatch = exports.appKeyValid = exports.appKey = void 0;
7
- const config_1 = __importDefault(require("./config"));
8
- /** Build application key */
9
- const appKey = () => {
10
- return Date.now().toString(36);
11
- };
12
- exports.appKey = appKey;
13
- /** Check application key */
14
- const appKeyValid = (appKey) => {
15
- return (appKey.key !== undefined) && (appKey.key !== '');
16
- };
17
- exports.appKeyValid = appKeyValid;
18
- /** Check if two application keys are equal */
19
- const appKeyMatch = (app1, app2) => {
20
- const a1 = app1 !== undefined;
21
- const a2 = app2 !== undefined;
22
- return (!a1 && !a2) || (a1 && a2 && (app1.key === app2.key));
23
- };
24
- exports.appKeyMatch = appKeyMatch;
25
- const arrayScope = (scope) => {
26
- if (!scope)
27
- return [];
28
- else
29
- return Array.isArray(scope) ? scope : [scope];
30
- };
31
- exports.arrayScope = arrayScope;
32
- const isProvisioningApp = (app) => {
33
- const scope = arrayScope(app.scope);
34
- return scope.includes(config_1.default.provisioning.scope) || (app.api === 'provisioning');
35
- };
36
- exports.isProvisioningApp = isProvisioningApp;
@@ -1,107 +0,0 @@
1
- import chalk from 'chalk';
2
- import type { ApiMode } from './api';
3
- export declare const reset: chalk.Chalk;
4
- export declare const visible: chalk.Chalk;
5
- export declare const hidden: chalk.Chalk;
6
- export declare const red: chalk.Chalk;
7
- export declare const redBright: chalk.Chalk;
8
- export declare const green: chalk.Chalk;
9
- export declare const greenBright: chalk.Chalk;
10
- export declare const yellow: chalk.Chalk;
11
- export declare const yellowBright: chalk.Chalk;
12
- export declare const blue: chalk.Chalk;
13
- export declare const blueBright: chalk.Chalk;
14
- export declare const white: chalk.Chalk;
15
- export declare const whiteBright: chalk.Chalk;
16
- export declare const black: chalk.Chalk;
17
- export declare const blackBright: chalk.Chalk;
18
- export declare const grey: chalk.Chalk;
19
- export declare const cyan: chalk.Chalk;
20
- export declare const cyanBright: chalk.Chalk;
21
- export declare const magenta: chalk.Chalk;
22
- export declare const magentaBright: chalk.Chalk;
23
- export declare const bold: chalk.Chalk;
24
- export declare const dim: chalk.Chalk;
25
- export declare const underline: chalk.Chalk;
26
- export declare const italic: chalk.Chalk;
27
- export declare const bg: {
28
- white: chalk.Chalk;
29
- whiteBright: chalk.Chalk;
30
- black: chalk.Chalk;
31
- blackBright: chalk.Chalk;
32
- grey: chalk.Chalk;
33
- red: chalk.Chalk;
34
- redBright: chalk.Chalk;
35
- green: chalk.Chalk;
36
- greenBright: chalk.Chalk;
37
- yellow: chalk.Chalk;
38
- yellowBright: chalk.Chalk;
39
- blue: chalk.Chalk;
40
- blueBright: chalk.Chalk;
41
- magenta: chalk.Chalk;
42
- magentaBright: chalk.Chalk;
43
- cyan: chalk.Chalk;
44
- cyanBright: chalk.Chalk;
45
- };
46
- export declare const style: {
47
- organization: chalk.Chalk;
48
- application: chalk.Chalk;
49
- slug: chalk.Chalk;
50
- id: chalk.Chalk;
51
- token: chalk.Chalk;
52
- resource: chalk.Chalk;
53
- attribute: chalk.Chalk;
54
- trigger: chalk.Chalk;
55
- kind: chalk.Chalk;
56
- live: chalk.Chalk;
57
- test: chalk.Chalk;
58
- execMode: (mode: ApiMode) => chalk.Chalk;
59
- success: chalk.Chalk;
60
- warning: chalk.Chalk;
61
- error: chalk.Chalk;
62
- arg: chalk.Chalk;
63
- flag: chalk.Chalk;
64
- command: chalk.Chalk;
65
- value: chalk.Chalk;
66
- alias: chalk.Chalk;
67
- plugin: chalk.Chalk;
68
- title: chalk.Chalk;
69
- path: chalk.Chalk;
70
- datetime: chalk.Chalk;
71
- number: chalk.Chalk;
72
- };
73
- export declare const type: {
74
- datetime: chalk.Chalk;
75
- number: chalk.Chalk;
76
- path: chalk.Chalk;
77
- };
78
- export declare const api: {
79
- organization: chalk.Chalk;
80
- application: chalk.Chalk;
81
- slug: chalk.Chalk;
82
- id: chalk.Chalk;
83
- token: chalk.Chalk;
84
- resource: chalk.Chalk;
85
- attribute: chalk.Chalk;
86
- trigger: chalk.Chalk;
87
- kind: chalk.Chalk;
88
- live: chalk.Chalk;
89
- test: chalk.Chalk;
90
- };
91
- export declare const msg: {
92
- success: chalk.Chalk;
93
- warning: chalk.Chalk;
94
- error: chalk.Chalk;
95
- };
96
- export declare const cli: {
97
- arg: chalk.Chalk;
98
- flag: chalk.Chalk;
99
- command: chalk.Chalk;
100
- value: chalk.Chalk;
101
- alias: chalk.Chalk;
102
- plugin: chalk.Chalk;
103
- };
104
- export declare const table: {
105
- header: chalk.Chalk;
106
- key: chalk.Chalk;
107
- };
package/lib/cjs/color.js DELETED
@@ -1,116 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.table = exports.cli = exports.msg = exports.api = exports.type = exports.style = exports.bg = exports.italic = exports.underline = exports.dim = exports.bold = exports.magentaBright = exports.magenta = exports.cyanBright = exports.cyan = exports.grey = exports.blackBright = exports.black = exports.whiteBright = exports.white = exports.blueBright = exports.blue = exports.yellowBright = exports.yellow = exports.greenBright = exports.green = exports.redBright = exports.red = exports.hidden = exports.visible = exports.reset = void 0;
7
- const chalk_1 = __importDefault(require("chalk"));
8
- exports.reset = chalk_1.default.reset;
9
- exports.visible = chalk_1.default.visible;
10
- exports.hidden = chalk_1.default.hidden;
11
- exports.red = chalk_1.default.red;
12
- exports.redBright = chalk_1.default.redBright;
13
- exports.green = chalk_1.default.green;
14
- exports.greenBright = chalk_1.default.greenBright;
15
- exports.yellow = chalk_1.default.yellow;
16
- exports.yellowBright = chalk_1.default.yellowBright;
17
- exports.blue = chalk_1.default.blue;
18
- exports.blueBright = chalk_1.default.blueBright;
19
- exports.white = chalk_1.default.white;
20
- exports.whiteBright = chalk_1.default.whiteBright;
21
- exports.black = chalk_1.default.black;
22
- exports.blackBright = chalk_1.default.blackBright;
23
- exports.grey = chalk_1.default.grey;
24
- exports.cyan = chalk_1.default.cyan;
25
- exports.cyanBright = chalk_1.default.cyanBright;
26
- exports.magenta = chalk_1.default.magenta;
27
- exports.magentaBright = chalk_1.default.magentaBright;
28
- exports.bold = chalk_1.default.bold;
29
- exports.dim = chalk_1.default.dim;
30
- exports.underline = chalk_1.default.underline;
31
- exports.italic = chalk_1.default.italic;
32
- exports.bg = {
33
- white: chalk_1.default.bgWhite,
34
- whiteBright: chalk_1.default.bgWhiteBright,
35
- black: chalk_1.default.bgBlack,
36
- blackBright: chalk_1.default.bgBlackBright,
37
- grey: chalk_1.default.bgGrey,
38
- red: chalk_1.default.bgRed,
39
- redBright: chalk_1.default.bgRedBright,
40
- green: chalk_1.default.bgGreen,
41
- greenBright: chalk_1.default.bgGreenBright,
42
- yellow: chalk_1.default.bgYellow,
43
- yellowBright: chalk_1.default.bgYellowBright,
44
- blue: chalk_1.default.bgBlue,
45
- blueBright: chalk_1.default.bgBlueBright,
46
- magenta: chalk_1.default.bgMagenta,
47
- magentaBright: chalk_1.default.bgMagentaBright,
48
- cyan: chalk_1.default.bgCyan,
49
- cyanBright: chalk_1.default.bgCyanBright
50
- };
51
- exports.style = {
52
- organization: exports.yellowBright.bold,
53
- application: exports.yellowBright.bold,
54
- slug: exports.yellowBright,
55
- id: exports.bold,
56
- token: exports.blueBright,
57
- resource: exports.bold,
58
- attribute: exports.italic,
59
- trigger: exports.cyanBright,
60
- kind: exports.cyanBright,
61
- live: exports.greenBright,
62
- test: exports.yellowBright,
63
- execMode: (mode) => { return (mode === 'live') ? exports.style.live : exports.style.test; },
64
- success: exports.greenBright,
65
- warning: exports.yellowBright,
66
- error: exports.redBright,
67
- arg: exports.italic,
68
- flag: exports.italic,
69
- command: exports.italic,
70
- value: exports.italic,
71
- alias: exports.cyanBright,
72
- plugin: exports.blueBright,
73
- title: exports.blueBright,
74
- path: exports.italic,
75
- datetime: exports.cyanBright,
76
- number: exports.yellowBright,
77
- };
78
- /* Aliases */
79
- exports.type = {
80
- datetime: exports.style.datetime,
81
- number: exports.style.number,
82
- path: exports.style.path
83
- };
84
- /* Aliases */
85
- exports.api = {
86
- organization: exports.style.organization,
87
- application: exports.style.application,
88
- slug: exports.style.slug,
89
- id: exports.style.id,
90
- token: exports.style.token,
91
- resource: exports.style.resource,
92
- attribute: exports.style.attribute,
93
- trigger: exports.style.trigger,
94
- kind: exports.style.kind,
95
- live: exports.style.live,
96
- test: exports.style.test,
97
- };
98
- /* Aliases */
99
- exports.msg = {
100
- success: exports.style.success,
101
- warning: exports.style.warning,
102
- error: exports.style.error,
103
- };
104
- /* Aliases */
105
- exports.cli = {
106
- arg: exports.style.arg,
107
- flag: exports.style.flag,
108
- command: exports.style.command,
109
- value: exports.style.value,
110
- alias: exports.style.alias,
111
- plugin: exports.style.plugin
112
- };
113
- exports.table = {
114
- header: exports.yellowBright.bold,
115
- key: exports.blueBright
116
- };
@@ -1,21 +0,0 @@
1
- /** Copy command flags excluding a subset */
2
- declare const commandFlags: <T extends object>(flags: T, exclude?: string[]) => T;
3
- export { commandFlags };
4
- export type KeyVal = Record<string, string | number | boolean | undefined | null>;
5
- export type KeyValString = Record<string, string>;
6
- export type KeyValArray = Record<string, string[]>;
7
- export type KeyValRel = Record<string, {
8
- readonly type: string;
9
- readonly id: string;
10
- }>;
11
- export type KeyValObj = Record<string, any>;
12
- export type KeyValSort = Record<string, 'asc' | 'desc'>;
13
- export type ResAttributes = KeyValObj;
14
- declare const fixValueType: (val: string) => string | number | boolean | null | undefined;
15
- declare const findLongStringFlag: (args: string[], name: string) => {
16
- value: string;
17
- index: number;
18
- single: boolean;
19
- } | undefined;
20
- declare const fixDashedFlagValue: (argv: string[], flag: any, name?: string, parsed?: any) => string[];
21
- export { fixValueType, findLongStringFlag, fixDashedFlagValue };