@commercelayer/cli-core 5.0.5 → 5.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.d.mts CHANGED
@@ -49,7 +49,7 @@ declare const request: {
49
49
  resource: string;
50
50
  accessToken: string;
51
51
  operation: Operation;
52
- }, data: any, id?: string | undefined) => Promise<any>;
52
+ }, data: any, id?: string) => Promise<any>;
53
53
  readDataFile: (file: string) => any;
54
54
  rateLimitDelay: (options?: DelayOptions) => number;
55
55
  };
@@ -254,6 +254,7 @@ type DocConfig = {
254
254
  cleanups_resources: string;
255
255
  webhooks_events: string;
256
256
  tags_resources: string;
257
+ links_resources: string;
257
258
  };
258
259
  type TagsConfig = {
259
260
  max_resource_tags: number;
@@ -266,6 +267,10 @@ type ProvisioningConfig = {
266
267
  scope: string;
267
268
  applications: readonly string[];
268
269
  };
270
+ type LinksConfig = {
271
+ default_domain: 'c11r.link';
272
+ linkable_resources: readonly string[];
273
+ };
269
274
  type Config = {
270
275
  api: ApiConfig;
271
276
  application: ApplicationConfig;
@@ -277,6 +282,7 @@ type Config = {
277
282
  doc: DocConfig;
278
283
  tags: TagsConfig;
279
284
  provisioning: ProvisioningConfig;
285
+ links: LinksConfig;
280
286
  };
281
287
  declare const config: Config;
282
288
 
@@ -301,6 +307,7 @@ declare const findLongStringFlag: (args: string[], name: string) => {
301
307
  single: boolean;
302
308
  } | undefined;
303
309
  declare const fixDashedFlagValue: (argv: string[], flag: any, name?: string, parsed?: any) => string[];
310
+ declare const checkISODateTimeValue: (value?: string) => Date;
304
311
 
305
312
  type command_KeyVal = KeyVal;
306
313
  type command_KeyValArray = KeyValArray;
@@ -310,12 +317,13 @@ type command_KeyValSort = KeyValSort;
310
317
  type command_KeyValString = KeyValString;
311
318
  type command_ResAttributes = ResAttributes;
312
319
  declare const command_allFlags: typeof allFlags;
320
+ declare const command_checkISODateTimeValue: typeof checkISODateTimeValue;
313
321
  declare const command_commandFlags: typeof commandFlags;
314
322
  declare const command_findLongStringFlag: typeof findLongStringFlag;
315
323
  declare const command_fixDashedFlagValue: typeof fixDashedFlagValue;
316
324
  declare const command_fixValueType: typeof fixValueType;
317
325
  declare namespace command {
318
- export { type command_KeyVal as KeyVal, type command_KeyValArray as KeyValArray, type command_KeyValObj as KeyValObj, type command_KeyValRel as KeyValRel, type command_KeyValSort as KeyValSort, type command_KeyValString as KeyValString, type command_ResAttributes as ResAttributes, command_allFlags as allFlags, command_commandFlags as commandFlags, command_findLongStringFlag as findLongStringFlag, command_fixDashedFlagValue as fixDashedFlagValue, command_fixValueType as fixValueType };
326
+ export { type command_KeyVal as KeyVal, type command_KeyValArray as KeyValArray, type command_KeyValObj as KeyValObj, type command_KeyValRel as KeyValRel, type command_KeyValSort as KeyValSort, type command_KeyValString as KeyValString, type command_ResAttributes as ResAttributes, command_allFlags as allFlags, command_checkISODateTimeValue as checkISODateTimeValue, command_commandFlags as commandFlags, command_findLongStringFlag as findLongStringFlag, command_fixDashedFlagValue as fixDashedFlagValue, command_fixValueType as fixValueType };
319
327
  }
320
328
 
321
329
  /** Print a formatted object */
package/lib/index.d.ts CHANGED
@@ -49,7 +49,7 @@ declare const request: {
49
49
  resource: string;
50
50
  accessToken: string;
51
51
  operation: Operation;
52
- }, data: any, id?: string | undefined) => Promise<any>;
52
+ }, data: any, id?: string) => Promise<any>;
53
53
  readDataFile: (file: string) => any;
54
54
  rateLimitDelay: (options?: DelayOptions) => number;
55
55
  };
@@ -254,6 +254,7 @@ type DocConfig = {
254
254
  cleanups_resources: string;
255
255
  webhooks_events: string;
256
256
  tags_resources: string;
257
+ links_resources: string;
257
258
  };
258
259
  type TagsConfig = {
259
260
  max_resource_tags: number;
@@ -266,6 +267,10 @@ type ProvisioningConfig = {
266
267
  scope: string;
267
268
  applications: readonly string[];
268
269
  };
270
+ type LinksConfig = {
271
+ default_domain: 'c11r.link';
272
+ linkable_resources: readonly string[];
273
+ };
269
274
  type Config = {
270
275
  api: ApiConfig;
271
276
  application: ApplicationConfig;
@@ -277,6 +282,7 @@ type Config = {
277
282
  doc: DocConfig;
278
283
  tags: TagsConfig;
279
284
  provisioning: ProvisioningConfig;
285
+ links: LinksConfig;
280
286
  };
281
287
  declare const config: Config;
282
288
 
@@ -301,6 +307,7 @@ declare const findLongStringFlag: (args: string[], name: string) => {
301
307
  single: boolean;
302
308
  } | undefined;
303
309
  declare const fixDashedFlagValue: (argv: string[], flag: any, name?: string, parsed?: any) => string[];
310
+ declare const checkISODateTimeValue: (value?: string) => Date;
304
311
 
305
312
  type command_KeyVal = KeyVal;
306
313
  type command_KeyValArray = KeyValArray;
@@ -310,12 +317,13 @@ type command_KeyValSort = KeyValSort;
310
317
  type command_KeyValString = KeyValString;
311
318
  type command_ResAttributes = ResAttributes;
312
319
  declare const command_allFlags: typeof allFlags;
320
+ declare const command_checkISODateTimeValue: typeof checkISODateTimeValue;
313
321
  declare const command_commandFlags: typeof commandFlags;
314
322
  declare const command_findLongStringFlag: typeof findLongStringFlag;
315
323
  declare const command_fixDashedFlagValue: typeof fixDashedFlagValue;
316
324
  declare const command_fixValueType: typeof fixValueType;
317
325
  declare namespace command {
318
- export { type command_KeyVal as KeyVal, type command_KeyValArray as KeyValArray, type command_KeyValObj as KeyValObj, type command_KeyValRel as KeyValRel, type command_KeyValSort as KeyValSort, type command_KeyValString as KeyValString, type command_ResAttributes as ResAttributes, command_allFlags as allFlags, command_commandFlags as commandFlags, command_findLongStringFlag as findLongStringFlag, command_fixDashedFlagValue as fixDashedFlagValue, command_fixValueType as fixValueType };
326
+ export { type command_KeyVal as KeyVal, type command_KeyValArray as KeyValArray, type command_KeyValObj as KeyValObj, type command_KeyValRel as KeyValRel, type command_KeyValSort as KeyValSort, type command_KeyValString as KeyValString, type command_ResAttributes as ResAttributes, command_allFlags as allFlags, command_checkISODateTimeValue as checkISODateTimeValue, command_commandFlags as commandFlags, command_findLongStringFlag as findLongStringFlag, command_fixDashedFlagValue as fixDashedFlagValue, command_fixValueType as fixValueType };
319
327
  }
320
328
 
321
329
  /** Print a formatted object */
package/lib/index.js CHANGED
@@ -1,11 +1,11 @@
1
- "use strict";var Re=Object.create;var I=Object.defineProperty;var Se=Object.getOwnPropertyDescriptor;var ze=Object.getOwnPropertyNames;var Ee=Object.getPrototypeOf,Ie=Object.prototype.hasOwnProperty;var g=(e,t)=>{for(var r in t)I(e,r,{get:t[r],enumerable:!0})},pe=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of ze(t))!Ie.call(e,i)&&i!==r&&I(e,i,{get:()=>t[i],enumerable:!(s=Se(t,i))||s.enumerable});return e};var B=(e,t,r)=>(r=e!=null?Re(Ee(e)):{},pe(t||!e||!e.__esModule?I(r,"default",{value:e,enumerable:!0}):r,e)),Be=e=>pe(I({},"__esModule",{value:!0}),e);var Zt={};g(Zt,{clApi:()=>J,clApplication:()=>Y,clColor:()=>k,clCommand:()=>X,clConfig:()=>u,clFilter:()=>ce,clHelp:()=>z,clOutput:()=>Z,clSchema:()=>ae,clSymbol:()=>ie,clText:()=>ne,clToken:()=>te,clUpdate:()=>re,clUtil:()=>se});module.exports=Be(Zt);var J={};g(J,{Operation:()=>N,baseURL:()=>Pe,execMode:()=>je,extractDomain:()=>Ue,humanizeResource:()=>We,isResourceCacheable:()=>de,liveEnvironment:()=>Ve,request:()=>He,requestDataFile:()=>H,requestRateLimitDelay:()=>ge,requestRaw:()=>V,response:()=>Ne,responseDenormalize:()=>G});var F=["in_progress","pending","completed","interrupted"],Me=["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"],De=["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","shipments","shipping_categories","shipping_methods","sku_lists","sku_list_items","sku_options","skus","stock_items","stock_transfers","tags","tax_categories","transactions","voids"],Oe=["bundles","gift_cards","prices","promotions","sku_lists","sku_options","skus","stock_items"],Le=["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"],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},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: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:["integration","sales_channel","webapp","user"],login_scopes:["market","stock_location"]},imports:{max_size:1e4,statuses:F,types:Me,max_queue_length:10,attachment_expiration:5},exports:{max_size:1e4,statuses:F,types:De,max_queue_length:10,attachment_expiration:5},cleanups:{max_size:1e4,statuses:F,types:Oe,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:Le,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;var ue=require("fs");var V=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(),H=e=>{let t,r;try{t=(0,ue.readFileSync)(e,"utf-8")}catch{throw new Error(`Unable to find or open the data file ${k.msg.error(e)}`)}try{r=JSON.parse(t)}catch{throw new Error(`Unable to parse the data file ${k.msg.error(e)}: invalid JSON format`)}return r.data?r:{data:r}},N=(r=>(r.Create="POST",r.Update="PATCH",r))(N||{});var me=(e,t)=>t.find(r=>e.id===r.id&&e.type===r.type),M=(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=>M(me(n,t),t)):r[s]=M(me(i,t),t):i===null&&(r[s]=null)}),r},G=e=>{let t;e.links&&delete e.links;let r=e.data,s=e.included;return Array.isArray(r)?t=r.map(i=>M(i,s)):t=M(r,s),t};var Pe=(e="core",t,r)=>`https://${(e==="core"&&t||e).toLowerCase()}.${r||u.api.default_domain}`,Ue=e=>{if(e)return e.substring(e.indexOf(".")+1)},je=e=>e===!0||e==="live"?"live":"test",We=e=>e.replace(/_/g," ");var Fe=["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"],de=(e,t)=>Fe.includes(e||"")&&(t||"GET").toUpperCase()==="GET",Ve=e=>e==="live",ge=e=>{let t=e?.environment||"test",r=e?.parallelRequests||1,s=de(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,h=r*a,v=r*m,_=e?.totalRequests,c=0;return _&&_>0?_>i&&(_>n?c=v:c=h):c=Math.max(h,v),c=c*1e3,e?.minimumDelay&&(c=Math.max(e.minimumDelay,c)),e?.securityDelay&&(c+=e.securityDelay),c=Math.ceil(c),c};var He={raw:V,readDataFile:H,rateLimitDelay:ge},Ne={denormalize:G};var Y={};g(Y,{appKey:()=>Ge,appKeyMatch:()=>Ye,appKeyValid:()=>Je,arrayScope:()=>_e,isProvisioningApp:()=>Xe});var Ge=()=>Date.now().toString(36),Je=e=>e.key!==void 0&&e.key!=="",Ye=(e,t)=>{let r=e!==void 0,s=t!==void 0;return!r&&!s||r&&s&&e.key===t.key},_e=e=>{if(!e)return[];if(Array.isArray(e))return e;let t=e.replace(/[ ,;]/g,"_").split("_");return Array.isArray(t)?t:[t]},Xe=e=>_e(e.scope).includes(u.provisioning.scope)||e.api==="provisioning";var X={};g(X,{allFlags:()=>Qe,commandFlags:()=>Ze,findLongStringFlag:()=>tt,fixDashedFlagValue:()=>rt,fixValueType:()=>et});var Ze=(e,t)=>{let r={...e};if(t)for(let s of t)delete r[s];return r},Qe=e=>({...e.flags,...e.baseFlags});var et=e=>{let t=e;return t==="null"?t=null:Number(t)==t?t=Number(t):t=t==="true"?!0:t==="false"?!1:t,t},tt=(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},rt=(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,h=a?t.char.startsWith("-")?a:`-${a}`:void 0,v=e.findIndex(w=>h&&w.startsWith(h)||m&&w.startsWith(m));if(v<0)return e;let _=e[v],c="",le="";if(h&&_.startsWith(h))c=_.replace(h,"").trim(),_=h;else if(m&&_.startsWith(m))c=_.replace(m,"").trim(),_=m;else return e;if(c.startsWith("=")?(c=c.slice(1),le=_+"="):c||(c=e[++v]),c.startsWith("-")||c.startsWith(i)){let w=c.startsWith(`${i}`)?c.replace(`${i}`,""):c.replace("-",`${i}-`);if(e[v]=le+w,c.startsWith(i)&&s){let E=n?n.replace("--",""):void 0,U=Object.entries(s.flags).find(([W,qe])=>qe===c);U&&(!E||E===U[0])&&(s.flags[U[0]]=w);let j=Object.values(s.raw).find(W=>W.type==="flag"&&W.input===c);j&&(!E||E===j.flag)&&(j.input=w)}}return e};var Z={};g(Z,{center:()=>st,cleanDate:()=>nt,formatError:()=>at,formatOutput:()=>xe,localeDate:()=>ot,maxLength:()=>it,printCSV:()=>ye,printJSON:()=>be,printObject:()=>he});var fe=require("util"),he=(e,t)=>(0,fe.inspect)(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}),be=(e,t)=>JSON.stringify(e,null,t?.unformatted?void 0:t?.tabSize||4),ye=(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(";")+`
1
+ "use strict";var Re=Object.create;var I=Object.defineProperty;var Ee=Object.getOwnPropertyDescriptor;var Se=Object.getOwnPropertyNames;var ze=Object.getPrototypeOf,Ie=Object.prototype.hasOwnProperty;var g=(e,t)=>{for(var r in t)I(e,r,{get:t[r],enumerable:!0})},pe=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Se(t))!Ie.call(e,i)&&i!==r&&I(e,i,{get:()=>t[i],enumerable:!(s=Ee(t,i))||s.enumerable});return e};var B=(e,t,r)=>(r=e!=null?Re(ze(e)):{},pe(t||!e||!e.__esModule?I(r,"default",{value:e,enumerable:!0}):r,e)),Be=e=>pe(I({},"__esModule",{value:!0}),e);var er={};g(er,{clApi:()=>J,clApplication:()=>Y,clColor:()=>w,clCommand:()=>X,clConfig:()=>u,clFilter:()=>ce,clHelp:()=>S,clOutput:()=>Z,clSchema:()=>ae,clSymbol:()=>ie,clText:()=>ne,clToken:()=>te,clUpdate:()=>re,clUtil:()=>se});module.exports=Be(er);var J={};g(J,{Operation:()=>H,baseURL:()=>Ue,execMode:()=>We,extractDomain:()=>je,humanizeResource:()=>Fe,isResourceCacheable:()=>de,liveEnvironment:()=>Ne,request:()=>He,requestDataFile:()=>N,requestRateLimitDelay:()=>ge,requestRaw:()=>V,response:()=>Ge,responseDenormalize:()=>G});var F=["in_progress","pending","completed","interrupted"],De=["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"],Me=["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","shipments","shipping_categories","shipping_methods","sku_lists","sku_list_items","sku_options","skus","stock_items","stock_transfers","tags","tax_categories","transactions","voids"],Le=["bundles","gift_cards","prices","promotions","sku_lists","sku_options","skus","stock_items"],Oe=["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"],Ke=["orders","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},Pe={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: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:["integration","sales_channel","webapp","user"],login_scopes:["market","stock_location"]},imports:{max_size:1e4,statuses:F,types:De,max_queue_length:10,attachment_expiration:5},exports:{max_size:1e4,statuses:F,types:Me,max_queue_length:10,attachment_expiration:5},cleanups:{max_size:1e4,statuses:F,types:Le,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:Oe,tag_name_max_length:25,tag_name_pattern:/^[0-9A-Za-z_-]{1,25}$/},provisioning:{default_subdomain:"provisioning",scope:"provisioning-api",applications:["user"]},links:{linkable_resources:Ke,default_domain:"c11r.link"}},u=Pe;var ue=require("fs");var V=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(),N=e=>{let t,r;try{t=(0,ue.readFileSync)(e,"utf-8")}catch{throw new Error(`Unable to find or open the data file ${w.msg.error(e)}`)}try{r=JSON.parse(t)}catch{throw new Error(`Unable to parse the data file ${w.msg.error(e)}: invalid JSON format`)}return r.data?r:{data:r}},H=(r=>(r.Create="POST",r.Update="PATCH",r))(H||{});var me=(e,t)=>t.find(r=>e.id===r.id&&e.type===r.type),D=(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=>D(me(n,t),t)):r[s]=D(me(i,t),t):i===null&&(r[s]=null)}),r},G=e=>{let t;e.links&&delete e.links;let r=e.data,s=e.included;return Array.isArray(r)?t=r.map(i=>D(i,s)):t=D(r,s),t};var Ue=(e="core",t,r)=>`https://${(e==="core"&&t||e).toLowerCase()}.${r||u.api.default_domain}`,je=e=>{if(e)return e.substring(e.indexOf(".")+1)},We=e=>e===!0||e==="live"?"live":"test",Fe=e=>e.replace(/_/g," ");var Ve=["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"],de=(e,t)=>Ve.includes(e||"")&&(t||"GET").toUpperCase()==="GET",Ne=e=>e==="live",ge=e=>{let t=e?.environment||"test",r=e?.parallelRequests||1,s=de(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,h=r*a,v=r*m,_=e?.totalRequests,c=0;return _&&_>0?_>i&&(_>n?c=v:c=h):c=Math.max(h,v),c=c*1e3,e?.minimumDelay&&(c=Math.max(e.minimumDelay,c)),e?.securityDelay&&(c+=e.securityDelay),c=Math.ceil(c),c};var He={raw:V,readDataFile:N,rateLimitDelay:ge},Ge={denormalize:G};var Y={};g(Y,{appKey:()=>Je,appKeyMatch:()=>Xe,appKeyValid:()=>Ye,arrayScope:()=>_e,isProvisioningApp:()=>Ze});var Je=()=>Date.now().toString(36),Ye=e=>e.key!==void 0&&e.key!=="",Xe=(e,t)=>{let r=e!==void 0,s=t!==void 0;return!r&&!s||r&&s&&e.key===t.key},_e=e=>{if(!e)return[];if(Array.isArray(e))return e;let t=e.replace(/[ ,;]/g,"_").split("_");return Array.isArray(t)?t:[t]},Ze=e=>_e(e.scope).includes(u.provisioning.scope)||e.api==="provisioning";var X={};g(X,{allFlags:()=>et,checkISODateTimeValue:()=>it,commandFlags:()=>Qe,findLongStringFlag:()=>rt,fixDashedFlagValue:()=>st,fixValueType:()=>tt});var Qe=(e,t)=>{let r={...e};if(t)for(let s of t)delete r[s];return r},et=e=>({...e.flags,...e.baseFlags});var tt=e=>{let t=e;return t==="null"?t=null:Number(t)==t?t=Number(t):t=t==="true"?!0:t==="false"?!1:t,t},rt=(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},st=(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,h=a?t.char.startsWith("-")?a:`-${a}`:void 0,v=e.findIndex(T=>h&&T.startsWith(h)||m&&T.startsWith(m));if(v<0)return e;let _=e[v],c="",le="";if(h&&_.startsWith(h))c=_.replace(h,"").trim(),_=h;else if(m&&_.startsWith(m))c=_.replace(m,"").trim(),_=m;else return e;if(c.startsWith("=")?(c=c.slice(1),le=_+"="):c||(c=e[++v]),c.startsWith("-")||c.startsWith(i)){let T=c.startsWith(`${i}`)?c.replace(`${i}`,""):c.replace("-",`${i}-`);if(e[v]=le+T,c.startsWith(i)&&s){let z=n?n.replace("--",""):void 0,U=Object.entries(s.flags).find(([W,qe])=>qe===c);U&&(!z||z===U[0])&&(s.flags[U[0]]=T);let j=Object.values(s.raw).find(W=>W.type==="flag"&&W.input===c);j&&(!z||z===j.flag)&&(j.input=T)}}return e},it=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 Z={};g(Z,{center:()=>nt,cleanDate:()=>at,formatError:()=>lt,formatOutput:()=>xe,localeDate:()=>ct,maxLength:()=>ot,printCSV:()=>ye,printJSON:()=>be,printObject:()=>he});var fe=require("util"),he=(e,t)=>(0,fe.inspect)(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}),be=(e,t)=>JSON.stringify(e,null,t?.unformatted?void 0:t?.tabSize||4),ye=(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
2
  `;return e.forEach(i=>{s+=r.map(n=>i[n]).join(";")+`
3
- `}),s},st=(e,t)=>e.padStart(e.length+Math.floor((t-e.length)/2)," ").padEnd(t," "),it=(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),nt=e=>e.replace("T"," ").replace("Z","").substring(0,e.lastIndexOf(".")),ot=e=>e?new Date(Date.parse(e)).toLocaleString():"",xe=(e,t,{color:r=!0}={})=>{if(!e)return"";if(typeof e=="string")return e;if(t){if(t.csv)return ye(e,t);if(t.json)return be(e,{unformatted:t.unformatted})}return he(e,{color:r})},at=(e,t)=>xe(e.errors||e,t);var k={};g(k,{api:()=>Ct,bg:()=>At,black:()=>ht,blackBright:()=>bt,blue:()=>gt,blueBright:()=>$,bold:()=>ee,cli:()=>Rt,cyan:()=>xt,cyanBright:()=>A,dim:()=>wt,green:()=>mt,greenBright:()=>Q,grey:()=>yt,hidden:()=>pt,italic:()=>T,magenta:()=>vt,magentaBright:()=>Tt,msg:()=>qt,red:()=>ut,redBright:()=>ve,reset:()=>ct,style:()=>l,table:()=>St,type:()=>$t,underline:()=>kt,visible:()=>lt,white:()=>_t,whiteBright:()=>ft,yellow:()=>dt,yellowBright:()=>x});var o=B(require("chalk")),ct=o.default.reset,lt=o.default.visible,pt=o.default.hidden,ut=o.default.red,ve=o.default.redBright,mt=o.default.green,Q=o.default.greenBright,dt=o.default.yellow,x=o.default.yellowBright,gt=o.default.blue,$=o.default.blueBright,_t=o.default.white,ft=o.default.whiteBright,ht=o.default.black,bt=o.default.blackBright,yt=o.default.grey,xt=o.default.cyan,A=o.default.cyanBright,vt=o.default.magenta,Tt=o.default.magentaBright,ee=o.default.bold,wt=o.default.dim,kt=o.default.underline,T=o.default.italic,At={white:o.default.bgWhite,whiteBright:o.default.bgWhiteBright,black:o.default.bgBlack,blackBright:o.default.bgBlackBright,grey:o.default.bgGrey,red:o.default.bgRed,redBright:o.default.bgRedBright,green:o.default.bgGreen,greenBright:o.default.bgGreenBright,yellow:o.default.bgYellow,yellowBright:o.default.bgYellowBright,blue:o.default.bgBlue,blueBright:o.default.bgBlueBright,magenta:o.default.bgMagenta,magentaBright:o.default.bgMagentaBright,cyan:o.default.bgCyan,cyanBright:o.default.bgCyanBright},l={organization:x.bold,application:x.bold,slug:x,id:ee,token:$,resource:ee,attribute:T,trigger:A,kind:A,live:Q,test:x,execMode:e=>e==="live"?l.live:l.test,success:Q,warning:x,error:ve,arg:T,flag:T,command:T,value:T,alias:A,plugin:$,title:$,path:T,datetime:A,number:x},$t={datetime:l.datetime,number:l.number,path:l.path},Ct={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},qt={success:l.success,warning:l.warning,error:l.error},Rt={arg:l.arg,flag:l.flag,command:l.command,value:l.value,alias:l.alias,plugin:l.plugin},St={header:x.bold,key:$};var te={};g(te,{decodeAccessToken:()=>Te,generateAccessToken:()=>zt,getAccessToken:()=>Et,getTokenEnvironment:()=>Mt,isAccessTokenExpiring:()=>Bt,revokeAccessToken:()=>It});var D=B(require("jsonwebtoken"));var C=require("@commercelayer/js-auth"),Te=e=>{let t=D.default.decode(e);if(t===null)throw new Error("Error decoding access token");return t},zt=(e,t,r)=>{let i={...e,exp:Math.floor(Date.now()/1e3)+r*60,rand:Math.random()},n=u.api.token_encoding_algorithm,a=D.default.sign(i,t,{algorithm:n,noTimestamp:!0}),m=D.default.verify(a,t,{algorithms:[n]});return{accessToken:a,info:m,expMinutes:r}},Et=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(0,C.authenticate)("password",s)):t=await(0,C.authenticate)("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},It=async(e,t)=>{let r=await(0,C.revoke)({...e,token:t});if(r.errors)throw new Error(r.errors[0].detail)},Bt=e=>{let r=Math.floor(Date.now()/1e3),s=Math.floor(new Date(e.expires).getTime()/1e3);return r>=s-30},Mt=e=>(typeof e=="string"?Te(e):e).test?"test":"live";var re={};g(re,{checkUpdate:()=>Ot});var q=B(require("chalk")),we=B(require("update-notifier-cjs")),Dt=1,Ot=e=>{let t=(0,we.default)({pkg:e,updateCheckInterval:36e5*Dt});t.update&&t.notify({isGlobal:!1,message:`-= ${q.default.bgWhite.black.bold(` ${e.description} `)} =-
3
+ `}),s},nt=(e,t)=>e.padStart(e.length+Math.floor((t-e.length)/2)," ").padEnd(t," "),ot=(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),at=e=>e?e.replace("T"," ").replace("Z","").substring(0,e.lastIndexOf(".")):"",ct=e=>e?new Date(Date.parse(e)).toLocaleString():"",xe=(e,t,{color:r=!0}={})=>{if(!e)return"";if(typeof e=="string")return e;if(t){if(t.csv)return ye(e,t);if(t.json)return be(e,{unformatted:t.unformatted})}return he(e,{color:r})},lt=(e,t)=>xe(e.errors||e,t);var w={};g(w,{api:()=>Rt,bg:()=>Ct,black:()=>yt,blackBright:()=>xt,blue:()=>ft,blueBright:()=>$,bold:()=>ee,cli:()=>St,cyan:()=>kt,cyanBright:()=>A,dim:()=>At,green:()=>gt,greenBright:()=>Q,grey:()=>vt,hidden:()=>mt,italic:()=>k,magenta:()=>Tt,magentaBright:()=>wt,msg:()=>Et,red:()=>dt,redBright:()=>ve,reset:()=>pt,style:()=>l,table:()=>zt,type:()=>qt,underline:()=>$t,visible:()=>ut,white:()=>ht,whiteBright:()=>bt,yellow:()=>_t,yellowBright:()=>x});var o=B(require("chalk")),pt=o.default.reset,ut=o.default.visible,mt=o.default.hidden,dt=o.default.red,ve=o.default.redBright,gt=o.default.green,Q=o.default.greenBright,_t=o.default.yellow,x=o.default.yellowBright,ft=o.default.blue,$=o.default.blueBright,ht=o.default.white,bt=o.default.whiteBright,yt=o.default.black,xt=o.default.blackBright,vt=o.default.grey,kt=o.default.cyan,A=o.default.cyanBright,Tt=o.default.magenta,wt=o.default.magentaBright,ee=o.default.bold,At=o.default.dim,$t=o.default.underline,k=o.default.italic,Ct={white:o.default.bgWhite,whiteBright:o.default.bgWhiteBright,black:o.default.bgBlack,blackBright:o.default.bgBlackBright,grey:o.default.bgGrey,red:o.default.bgRed,redBright:o.default.bgRedBright,green:o.default.bgGreen,greenBright:o.default.bgGreenBright,yellow:o.default.bgYellow,yellowBright:o.default.bgYellowBright,blue:o.default.bgBlue,blueBright:o.default.bgBlueBright,magenta:o.default.bgMagenta,magentaBright:o.default.bgMagentaBright,cyan:o.default.bgCyan,cyanBright:o.default.bgCyanBright},l={organization:x.bold,application:x.bold,slug:x,id:ee,token:$,resource:ee,attribute:k,trigger:A,kind:A,live:Q,test:x,execMode:e=>e==="live"?l.live:l.test,success:Q,warning:x,error:ve,arg:k,flag:k,command:k,value:k,alias:A,plugin:$,title:$,path:k,datetime:A,number:x},qt={datetime:l.datetime,number:l.number,path:l.path},Rt={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},Et={success:l.success,warning:l.warning,error:l.error},St={arg:l.arg,flag:l.flag,command:l.command,value:l.value,alias:l.alias,plugin:l.plugin},zt={header:x.bold,key:$};var te={};g(te,{decodeAccessToken:()=>ke,generateAccessToken:()=>It,getAccessToken:()=>Bt,getTokenEnvironment:()=>Lt,isAccessTokenExpiring:()=>Mt,revokeAccessToken:()=>Dt});var M=B(require("jsonwebtoken"));var C=require("@commercelayer/js-auth"),ke=e=>{let t=M.default.decode(e);if(t===null)throw new Error("Error decoding access token");return t},It=(e,t,r)=>{let i={...e,exp:Math.floor(Date.now()/1e3)+r*60,rand:Math.random()},n=u.api.token_encoding_algorithm,a=M.default.sign(i,t,{algorithm:n,noTimestamp:!0}),m=M.default.verify(a,t,{algorithms:[n]});return{accessToken:a,info:m,expMinutes:r}},Bt=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(0,C.authenticate)("password",s)):t=await(0,C.authenticate)("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},Dt=async(e,t)=>{let r=await(0,C.revoke)({...e,token:t});if(r.errors)throw new Error(r.errors[0].detail)},Mt=e=>{let r=Math.floor(Date.now()/1e3),s=Math.floor(new Date(e.expires).getTime()/1e3);return r>=s-30},Lt=e=>(typeof e=="string"?ke(e):e).test?"test":"live";var re={};g(re,{checkUpdate:()=>Kt});var q=B(require("chalk")),Te=B(require("update-notifier-cjs")),Ot=1,Kt=e=>{let t=(0,Te.default)({pkg:e,updateCheckInterval:36e5*Ot});t.update&&t.notify({isGlobal:!1,message:`-= ${q.default.bgWhite.black.bold(` ${e.description} `)} =-
4
4
 
5
5
  New version available: ${q.default.dim("{currentVersion}")} -> ${q.default.green("{latestVersion}")}
6
- Run ${q.default.cyanBright("commercelayer plugins:update")} to update`})};var se={};g(se,{generateGroupUID:()=>jt,log:()=>Pt,resetConsole:()=>Kt,sleep:()=>Lt,specialFolder:()=>Ut,userAgent:()=>Wt});var O=require("util"),L=require("path"),ke=require("os"),K=require("fs"),Lt=async e=>new Promise(t=>setTimeout(t,e)),Kt=()=>{process.stdout.write("\x1B[?25h\x1B[?7h")},Pt=(e="",...t)=>{e=typeof e=="string"?e:(0,O.inspect)(e),process.stdout.write((0,O.format)(e,...t)+`
7
- `)},Ut=(e,t=!1)=>{let r=["desktop","home"],s=e.toLowerCase().split(/[\\\/]/g)[0];if(r.includes(s)){let n=(0,ke.homedir)();s==="desktop"&&(n+=`${L.sep}Desktop`),e=e.replace(s,n)}let i=(0,L.dirname)(e);return t&&!(0,K.existsSync)(i)&&(0,K.mkdirSync)(i,{recursive:!0}),e},jt=()=>{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}`;var P=require("@oclif/core");var ne={};g(ne,{camelize:()=>Nt,capitalize:()=>S,dasherize:()=>Ft,pluralize:()=>Vt,singularize:()=>Ht,symbols:()=>y});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}},R=p;var ie={};g(ie,{symbols:()=>y});var y={check:{small:"\u2714",bkgGreen:"\u2705",squareRoot:"\u221A"},cross:{small:"\u2718",red:"\u274C"},clock:{stopwatch:"\u23F1"},arrow:{down:"\u2193"},selection:{fisheye:"\u25C9"}};y.check.heavy=y.check.small;y.check.whiteHeavy=y.check.bkgGreen;y.cross.heavyBallot=y.cross.small;var S=e=>e&&R.capitalize(e),Ft=e=>e&&(e=e.toLocaleLowerCase(),e.replace(/ _/g,"-")),Vt=(e,t)=>R.pluralize(e,t),Ht=(e,t)=>R.singularize(e,t),Nt=(e,t)=>R.camelize(e,t);var f=!1,oe=class extends P.CommandHelp{examples(t){return f&&console.log("---------- command.examples"),super.examples(t)}},z=class extends P.Help{async showHelp(t){return f&&console.log("---------- showHelp"),super.showHelp(t)}async showRootHelp(){return f&&console.log("---------- showRootHelp"),super.showRootHelp()}async showTopicHelp(t){return f&&console.log("---------- showTopicHelp"),super.showTopicHelp(t)}async showCommandHelp(t){f&&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(`${S(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 f&&console.log("---------- formatRoot"),super.formatRoot()}formatTopic(t){return f&&console.log("---------- formatTopic"),super.formatTopic(t)}formatTopics(t){f&&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 f&&console.log("---------- formatCommands"),super.formatCommands(t).split(`
10
- `).map(r=>{let s=0;return r.split(" ").map(i=>(i||"").trim()!==""&&++s===2?S(i):i).join(" ")}).join(`
11
- `)}formatCommand(t){return f&&console.log("---------- formatCommand"),super.formatCommand(t)}getCommandHelpClass(t){return f&&console.log("---------- getCommandHelpClass"),new oe(t,this.config,this.opts)}};var ae={};g(ae,{download:()=>Gt});var Gt=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 ce={};g(ce,{apply:()=>Xt,available:()=>$e,documentation:()=>Yt,filters:()=>Ce,list:()=>Ae});var Jt=[{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"}],Yt=u.doc.core_filtering_data,Ae=()=>Ce().map(e=>e.predicate.replace(/^\*/g,"")),$e=e=>{let t=e.startsWith("_")?e:`_${e}`;return Ae().some(r=>t.endsWith(r))},Xt=(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},Ce=()=>[...Jt];0&&(module.exports={clApi,clApplication,clColor,clCommand,clConfig,clFilter,clHelp,clOutput,clSchema,clSymbol,clText,clToken,clUpdate,clUtil});
6
+ Run ${q.default.cyanBright("commercelayer plugins:update")} to update`})};var se={};g(se,{generateGroupUID:()=>Ft,log:()=>jt,resetConsole:()=>Ut,sleep:()=>Pt,specialFolder:()=>Wt,userAgent:()=>Vt});var L=require("util"),O=require("path"),we=require("os"),K=require("fs"),Pt=async e=>new Promise(t=>setTimeout(t,e)),Ut=()=>{process.stdout.write("\x1B[?25h\x1B[?7h")},jt=(e="",...t)=>{e=typeof e=="string"?e:(0,L.inspect)(e),process.stdout.write((0,L.format)(e,...t)+`
7
+ `)},Wt=(e,t=!1)=>{let r=["desktop","home"],s=e.toLowerCase().split(/[\\\/]/g)[0];if(r.includes(s)){let n=(0,we.homedir)();s==="desktop"&&(n+=`${O.sep}Desktop`),e=e.replace(s,n)}let i=(0,O.dirname)(e);return t&&!(0,K.existsSync)(i)&&(0,K.mkdirSync)(i,{recursive:!0}),e},Ft=()=>{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},Vt=e=>`${e.name.replace(/@commercelayer\/cli-plugin/,"CLI")}/${e.version}`;var P=require("@oclif/core");var ne={};g(ne,{camelize:()=>Jt,capitalize:()=>E,dasherize:()=>Nt,pluralize:()=>Ht,singularize:()=>Gt,symbols:()=>y});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}},R=p;var ie={};g(ie,{symbols:()=>y});var y={check:{small:"\u2714",bkgGreen:"\u2705",squareRoot:"\u221A"},cross:{small:"\u2718",red:"\u274C"},clock:{stopwatch:"\u23F1"},arrow:{down:"\u2193"},selection:{fisheye:"\u25C9"}};y.check.heavy=y.check.small;y.check.whiteHeavy=y.check.bkgGreen;y.cross.heavyBallot=y.cross.small;var E=e=>e&&R.capitalize(e),Nt=e=>e&&(e=e.toLocaleLowerCase(),e.replace(/ _/g,"-")),Ht=(e,t)=>R.pluralize(e,t),Gt=(e,t)=>R.singularize(e,t),Jt=(e,t)=>R.camelize(e,t);var f=!1,oe=class extends P.CommandHelp{examples(t){return f&&console.log("---------- command.examples"),super.examples(t)}},S=class extends P.Help{async showHelp(t){return f&&console.log("---------- showHelp"),super.showHelp(t)}async showRootHelp(){return f&&console.log("---------- showRootHelp"),super.showRootHelp()}async showTopicHelp(t){return f&&console.log("---------- showTopicHelp"),super.showTopicHelp(t)}async showCommandHelp(t){f&&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(`${E(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 f&&console.log("---------- formatRoot"),super.formatRoot()}formatTopic(t){return f&&console.log("---------- formatTopic"),super.formatTopic(t)}formatTopics(t){f&&console.log("---------- formatTopics");let r=t.filter(s=>!s.hidden).map(s=>(s.description=E(s.description),s));return super.formatTopics(r)}formatCommands(t){return f&&console.log("---------- formatCommands"),super.formatCommands(t).split(`
10
+ `).map(r=>{let s=0;return r.split(" ").map(i=>(i||"").trim()!==""&&++s===2?E(i):i).join(" ")}).join(`
11
+ `)}formatCommand(t){return f&&console.log("---------- formatCommand"),super.formatCommand(t)}getCommandHelpClass(t){return f&&console.log("---------- getCommandHelpClass"),new oe(t,this.config,this.opts)}};var ae={};g(ae,{download:()=>Yt});var Yt=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 ce={};g(ce,{apply:()=>Qt,available:()=>$e,documentation:()=>Zt,filters:()=>Ce,list:()=>Ae});var Xt=[{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"}],Zt=u.doc.core_filtering_data,Ae=()=>Ce().map(e=>e.predicate.replace(/^\*/g,"")),$e=e=>{let t=e.startsWith("_")?e:`_${e}`;return Ae().some(r=>t.endsWith(r))},Qt=(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},Ce=()=>[...Xt];0&&(module.exports={clApi,clApplication,clColor,clCommand,clConfig,clFilter,clHelp,clOutput,clSchema,clSymbol,clText,clToken,clUpdate,clUtil});
package/lib/index.mjs CHANGED
@@ -1,11 +1,11 @@
1
- var ye=Object.defineProperty;var f=(e,t)=>{for(var r in t)ye(e,r,{get:t[r],enumerable:!0})};var Y={};f(Y,{Operation:()=>P,baseURL:()=>$e,execMode:()=>qe,extractDomain:()=>Ce,humanizeResource:()=>Re,isResourceCacheable:()=>G,liveEnvironment:()=>ze,request:()=>Ee,requestDataFile:()=>K,requestRateLimitDelay:()=>J,requestRaw:()=>L,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","stock_transfers","tags","tax_categories"],ve=["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","shipments","shipping_categories","shipping_methods","sku_lists","sku_list_items","sku_options","skus","stock_items","stock_transfers","tags","tax_categories","transactions","voids"],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_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},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 L=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(),K=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),z=(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=>z(N(n,t),t)):r[s]=z(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=>z(i,s)):t=z(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","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"],G=(e,t)=>Se.includes(e||"")&&(t||"GET").toUpperCase()==="GET",ze=e=>e==="live",J=e=>{let t=e?.environment||"test",r=e?.parallelRequests||1,s=G(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,b=r*a,T=r*m,_=e?.totalRequests,c=0;return _&&_>0?_>i&&(_>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 Ee={raw:L,readDataFile:K,rateLimitDelay:J},Ie={denormalize:U};var Z={};f(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=>{if(!e)return[];if(Array.isArray(e))return e;let t=e.replace(/[ ,;]/g,"_").split("_");return Array.isArray(t)?t:[t]},Oe=e=>X(e.scope).includes(u.provisioning.scope)||e.api==="provisioning";var Q={};f(Q,{allFlags:()=>Ke,commandFlags:()=>Le,findLongStringFlag:()=>Ue,fixDashedFlagValue:()=>je,fixValueType:()=>Pe});var Le=(e,t)=>{let r={...e};if(t)for(let s of t)delete r[s];return r},Ke=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 _=e[T],c="",H="";if(b&&_.startsWith(b))c=_.replace(b,"").trim(),_=b;else if(m&&_.startsWith(m))c=_.replace(m,"").trim(),_=m;else return e;if(c.startsWith("=")?(c=c.slice(1),H=_+"="):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={};f(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(";")+`
1
+ var ye=Object.defineProperty;var f=(e,t)=>{for(var r in t)ye(e,r,{get:t[r],enumerable:!0})};var Y={};f(Y,{Operation:()=>P,baseURL:()=>Ce,execMode:()=>Re,extractDomain:()=>qe,humanizeResource:()=>Ee,isResourceCacheable:()=>G,liveEnvironment:()=>ze,request:()=>Ie,requestDataFile:()=>K,requestRateLimitDelay:()=>J,requestRaw:()=>O,response:()=>Be,responseDenormalize:()=>U});var L=["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","stock_transfers","tags","tax_categories"],ve=["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","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"],we=["orders","sku_lists"],y={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},Ae={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:L,types:xe,max_queue_length:10,attachment_expiration:5},exports:{max_size:1e4,statuses:L,types:ve,max_queue_length:10,attachment_expiration:5},cleanups:{max_size:1e4,statuses:L,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"]},links:{linkable_resources:we,default_domain:"c11r.link"}},u=Ae;import{readFileSync as $e}from"fs";var O=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(),K=e=>{let t,r;try{t=$e(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 H=(e,t)=>t.find(r=>e.id===r.id&&e.type===r.type),S=(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=>S(H(n,t),t)):r[s]=S(H(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=>S(i,s)):t=S(r,s),t};var Ce=(e="core",t,r)=>`https://${(e==="core"&&t||e).toLowerCase()}.${r||u.api.default_domain}`,qe=e=>{if(e)return e.substring(e.indexOf(".")+1)},Re=e=>e===!0||e==="live"?"live":"test",Ee=e=>e.replace(/_/g," ");var Se=["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"],G=(e,t)=>Se.includes(e||"")&&(t||"GET").toUpperCase()==="GET",ze=e=>e==="live",J=e=>{let t=e?.environment||"test",r=e?.parallelRequests||1,s=G(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,b=r*a,k=r*m,_=e?.totalRequests,c=0;return _&&_>0?_>i&&(_>n?c=k:c=b):c=Math.max(b,k),c=c*1e3,e?.minimumDelay&&(c=Math.max(e.minimumDelay,c)),e?.securityDelay&&(c+=e.securityDelay),c=Math.ceil(c),c};var Ie={raw:O,readDataFile:K,rateLimitDelay:J},Be={denormalize:U};var Z={};f(Z,{appKey:()=>De,appKeyMatch:()=>Le,appKeyValid:()=>Me,arrayScope:()=>X,isProvisioningApp:()=>Oe});var De=()=>Date.now().toString(36),Me=e=>e.key!==void 0&&e.key!=="",Le=(e,t)=>{let r=e!==void 0,s=t!==void 0;return!r&&!s||r&&s&&e.key===t.key},X=e=>{if(!e)return[];if(Array.isArray(e))return e;let t=e.replace(/[ ,;]/g,"_").split("_");return Array.isArray(t)?t:[t]},Oe=e=>X(e.scope).includes(u.provisioning.scope)||e.api==="provisioning";var Q={};f(Q,{allFlags:()=>Pe,checkISODateTimeValue:()=>Fe,commandFlags:()=>Ke,findLongStringFlag:()=>je,fixDashedFlagValue:()=>We,fixValueType:()=>Ue});var Ke=(e,t)=>{let r={...e};if(t)for(let s of t)delete r[s];return r},Pe=e=>({...e.flags,...e.baseFlags});var Ue=e=>{let t=e;return t==="null"?t=null:Number(t)==t?t=Number(t):t=t==="true"?!0:t==="false"?!1:t,t},je=(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,b=a?t.char.startsWith("-")?a:`-${a}`:void 0,k=e.findIndex(w=>b&&w.startsWith(b)||m&&w.startsWith(m));if(k<0)return e;let _=e[k],c="",N="";if(b&&_.startsWith(b))c=_.replace(b,"").trim(),_=b;else if(m&&_.startsWith(m))c=_.replace(m,"").trim(),_=m;else return e;if(c.startsWith("=")?(c=c.slice(1),N=_+"="):c||(c=e[++k]),c.startsWith("-")||c.startsWith(i)){let w=c.startsWith(`${i}`)?c.replace(`${i}`,""):c.replace("-",`${i}-`);if(e[k]=N+w,c.startsWith(i)&&s){let E=n?n.replace("--",""):void 0,B=Object.entries(s.flags).find(([M,be])=>be===c);B&&(!E||E===B[0])&&(s.flags[B[0]]=w);let D=Object.values(s.raw).find(M=>M.type==="flag"&&M.input===c);D&&(!E||E===D.flag)&&(D.input=w)}}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 ie={};f(ie,{center:()=>Ne,cleanDate:()=>Ge,formatError:()=>Ye,formatOutput:()=>se,localeDate:()=>Je,maxLength:()=>He,printCSV:()=>re,printJSON:()=>te,printObject:()=>ee});import{inspect as Ve}from"util";var ee=(e,t)=>Ve(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
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={};f(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={};f(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={};f(le,{checkUpdate:()=>$t});import E 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:`-= ${E.bgWhite.black.bold(` ${e.description} `)} =-
3
+ `}),s},Ne=(e,t)=>e.padStart(e.length+Math.floor((t-e.length)/2)," ").padEnd(t," "),He=(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),Ge=e=>e?e.replace("T"," ").replace("Z","").substring(0,e.lastIndexOf(".")):"",Je=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})},Ye=(e,t)=>se(e.errors||e,t);var A={};f(A,{api:()=>ft,bg:()=>gt,black:()=>ot,blackBright:()=>at,blue:()=>st,blueBright:()=>C,bold:()=>W,cli:()=>bt,cyan:()=>lt,cyanBright:()=>$,dim:()=>mt,green:()=>tt,greenBright:()=>j,grey:()=>ct,hidden:()=>Qe,italic:()=>T,magenta:()=>pt,magentaBright:()=>ut,msg:()=>ht,red:()=>et,redBright:()=>ne,reset:()=>Xe,style:()=>l,table:()=>yt,type:()=>_t,underline:()=>dt,visible:()=>Ze,white:()=>it,whiteBright:()=>nt,yellow:()=>rt,yellowBright:()=>v});import o from"chalk";var Xe=o.reset,Ze=o.visible,Qe=o.hidden,et=o.red,ne=o.redBright,tt=o.green,j=o.greenBright,rt=o.yellow,v=o.yellowBright,st=o.blue,C=o.blueBright,it=o.white,nt=o.whiteBright,ot=o.black,at=o.blackBright,ct=o.grey,lt=o.cyan,$=o.cyanBright,pt=o.magenta,ut=o.magentaBright,W=o.bold,mt=o.dim,dt=o.underline,T=o.italic,gt={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:T,trigger:$,kind:$,live:j,test:v,execMode:e=>e==="live"?l.live:l.test,success:j,warning:v,error:ne,arg:T,flag:T,command:T,value:T,alias:$,plugin:C,title:C,path:T,datetime:$,number:v},_t={datetime:l.datetime,number:l.number,path:l.path},ft={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},ht={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},yt={header:v.bold,key:C};var ce={};f(ce,{decodeAccessToken:()=>ae,generateAccessToken:()=>vt,getAccessToken:()=>kt,getTokenEnvironment:()=>At,isAccessTokenExpiring:()=>wt,revokeAccessToken:()=>Tt});import F from"jsonwebtoken";import{authenticate as oe,revoke as xt}from"@commercelayer/js-auth";var ae=e=>{let t=F.decode(e);if(t===null)throw new Error("Error decoding access token");return t},vt=(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}},kt=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},Tt=async(e,t)=>{let r=await xt({...e,token:t});if(r.errors)throw new Error(r.errors[0].detail)},wt=e=>{let r=Math.floor(Date.now()/1e3),s=Math.floor(new Date(e.expires).getTime()/1e3);return r>=s-30},At=e=>(typeof e=="string"?ae(e):e).test?"test":"live";var le={};f(le,{checkUpdate:()=>qt});import z from"chalk";import $t from"update-notifier-cjs";var Ct=1,qt=e=>{let t=$t({pkg:e,updateCheckInterval:36e5*Ct});t.update&&t.notify({isGlobal:!1,message:`-= ${z.bgWhite.black.bold(` ${e.description} `)} =-
4
4
 
5
- New version available: ${E.dim("{currentVersion}")} -> ${E.green("{latestVersion}")}
6
- Run ${E.cyanBright("commercelayer plugins:update")} to update`})};var pe={};f(pe,{generateGroupUID:()=>Lt,log:()=>Dt,resetConsole:()=>Mt,sleep:()=>Bt,specialFolder:()=>Ot,userAgent:()=>Kt});import{format as Ct,inspect as qt}from"util";import{sep as Rt,dirname as St}from"path";import{homedir as zt}from"os";import{existsSync as Et,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=zt();s==="desktop"&&(n+=`${Rt}Desktop`),e=e.replace(s,n)}let i=St(e);return t&&!Et(i)&&It(i,{recursive:!0}),e},Lt=()=>{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},Kt=e=>`${e.name.replace(/@commercelayer\/cli-plugin/,"CLI")}/${e.version}`;import{CommandHelp as Ft,Help as Vt}from"@oclif/core";var me={};f(me,{camelize:()=>Wt,capitalize:()=>R,dasherize:()=>Pt,pluralize:()=>Ut,singularize:()=>jt,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={};f(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=>e&&(e=e.toLocaleLowerCase(),e.replace(/ _/g,"-")),Ut=(e,t)=>q.pluralize(e,t),jt=(e,t)=>q.singularize(e,t),Wt=(e,t)=>q.camelize(e,t);var h=!1,V=class extends Ft{examples(t){return h&&console.log("---------- command.examples"),super.examples(t)}},I=class extends Vt{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(`
5
+ New version available: ${z.dim("{currentVersion}")} -> ${z.green("{latestVersion}")}
6
+ Run ${z.cyanBright("commercelayer plugins:update")} to update`})};var pe={};f(pe,{generateGroupUID:()=>Pt,log:()=>Ot,resetConsole:()=>Lt,sleep:()=>Mt,specialFolder:()=>Kt,userAgent:()=>Ut});import{format as Rt,inspect as Et}from"util";import{sep as St,dirname as zt}from"path";import{homedir as It}from"os";import{existsSync as Bt,mkdirSync as Dt}from"fs";var Mt=async e=>new Promise(t=>setTimeout(t,e)),Lt=()=>{process.stdout.write("\x1B[?25h\x1B[?7h")},Ot=(e="",...t)=>{e=typeof e=="string"?e:Et(e),process.stdout.write(Rt(e,...t)+`
7
+ `)},Kt=(e,t=!1)=>{let r=["desktop","home"],s=e.toLowerCase().split(/[\\\/]/g)[0];if(r.includes(s)){let n=It();s==="desktop"&&(n+=`${St}Desktop`),e=e.replace(s,n)}let i=zt(e);return t&&!Bt(i)&&Dt(i,{recursive:!0}),e},Pt=()=>{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},Ut=e=>`${e.name.replace(/@commercelayer\/cli-plugin/,"CLI")}/${e.version}`;import{CommandHelp as Nt,Help as Ht}from"@oclif/core";var me={};f(me,{camelize:()=>Vt,capitalize:()=>R,dasherize:()=>jt,pluralize:()=>Wt,singularize:()=>Ft,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={};f(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),jt=e=>e&&(e=e.toLocaleLowerCase(),e.replace(/ _/g,"-")),Wt=(e,t)=>q.pluralize(e,t),Ft=(e,t)=>q.singularize(e,t),Vt=(e,t)=>q.camelize(e,t);var h=!1,V=class extends Nt{examples(t){return h&&console.log("---------- command.examples"),super.examples(t)}},I=class extends Ht{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
8
  `)[0];a&&console.log(`${R(a)}
9
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
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={};f(de,{download:()=>Ht});var Ht=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={};f(he,{apply:()=>Jt,available:()=>_e,documentation:()=>Gt,filters:()=>fe,list:()=>ge});var Nt=[{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"}],Gt=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))},Jt=(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=()=>[...Nt];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};
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={};f(de,{download:()=>Gt});var Gt=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={};f(he,{apply:()=>Xt,available:()=>_e,documentation:()=>Yt,filters:()=>fe,list:()=>ge});var Jt=[{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"}],Yt=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))},Xt=(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=()=>[...Jt];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,6 +1,6 @@
1
1
  {
2
2
  "name": "@commercelayer/cli-core",
3
- "version": "5.0.5",
3
+ "version": "5.1.1",
4
4
  "author": "Pierluigi Viti <pierluigi@commercelayer.io>",
5
5
  "license": "MIT",
6
6
  "description": "Commerce Layer Javascript CLI core lib",
@@ -34,24 +34,24 @@
34
34
  "node": ">=20"
35
35
  },
36
36
  "devDependencies": {
37
- "@babel/preset-env": "^7.24.6",
38
- "@babel/preset-typescript": "^7.24.6",
37
+ "@babel/preset-env": "^7.24.7",
38
+ "@babel/preset-typescript": "^7.24.7",
39
39
  "@commercelayer/eslint-config-ts": "^1.4.5",
40
40
  "@semantic-release/changelog": "^6.0.3",
41
41
  "@semantic-release/git": "^10.0.1",
42
42
  "@size-limit/preset-small-lib": "^6.0.4",
43
43
  "@types/jest": "^29.5.12",
44
44
  "@types/jsonwebtoken": "^9.0.6",
45
- "@types/node": "^20.14.2",
46
- "@typescript-eslint/eslint-plugin": "^7.12.0",
45
+ "@types/node": "^20.14.9",
46
+ "@typescript-eslint/eslint-plugin": "^7.14.1",
47
47
  "dotenv": "^16.4.5",
48
48
  "eslint": "^8.57.0",
49
49
  "jest": "^29.7.0",
50
- "oclif": "^4.13.0",
50
+ "oclif": "^4.13.10",
51
51
  "semantic-release": "^23.1.1",
52
52
  "tsup": "^8.1.0",
53
- "tsx": "^4.11.2",
54
- "typescript": "^5.4.5"
53
+ "tsx": "^4.15.8",
54
+ "typescript": "^5.5.2"
55
55
  },
56
56
  "dependencies": {
57
57
  "@commercelayer/js-auth": "^6.2.2",