@commercelayer/cli-core 5.6.4 → 5.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.d.mts CHANGED
@@ -174,10 +174,12 @@ type Config = {
174
174
  };
175
175
  declare const config: Config;
176
176
 
177
- /** Copy command flags excluding a subset */
177
+ /** Copy command flags excluding a subset
178
+ * @deprecated Use `filterFlags` instead
179
+ */
178
180
  declare const commandFlags: <T extends object>(flags: T, exclude?: string[]) => T;
181
+ declare const filterFlags: (flags: FlagInput, include?: string[], exclude?: string[]) => FlagInput;
179
182
  declare const allFlags: (command: Command.Class) => FlagInput;
180
-
181
183
  type KeyVal = Record<string, string | number | boolean | undefined | null>;
182
184
  type KeyValString = Record<string, string>;
183
185
  type KeyValArray = Record<string, string[]>;
@@ -207,11 +209,12 @@ type command_ResAttributes = ResAttributes;
207
209
  declare const command_allFlags: typeof allFlags;
208
210
  declare const command_checkISODateTimeValue: typeof checkISODateTimeValue;
209
211
  declare const command_commandFlags: typeof commandFlags;
212
+ declare const command_filterFlags: typeof filterFlags;
210
213
  declare const command_findLongStringFlag: typeof findLongStringFlag;
211
214
  declare const command_fixDashedFlagValue: typeof fixDashedFlagValue;
212
215
  declare const command_fixValueType: typeof fixValueType;
213
216
  declare namespace command {
214
- 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 };
217
+ 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_filterFlags as filterFlags, command_findLongStringFlag as findLongStringFlag, command_fixDashedFlagValue as fixDashedFlagValue, command_fixValueType as fixValueType };
215
218
  }
216
219
 
217
220
  type AuthScope = string | string[];
package/lib/index.d.ts CHANGED
@@ -174,10 +174,12 @@ type Config = {
174
174
  };
175
175
  declare const config: Config;
176
176
 
177
- /** Copy command flags excluding a subset */
177
+ /** Copy command flags excluding a subset
178
+ * @deprecated Use `filterFlags` instead
179
+ */
178
180
  declare const commandFlags: <T extends object>(flags: T, exclude?: string[]) => T;
181
+ declare const filterFlags: (flags: FlagInput, include?: string[], exclude?: string[]) => FlagInput;
179
182
  declare const allFlags: (command: Command.Class) => FlagInput;
180
-
181
183
  type KeyVal = Record<string, string | number | boolean | undefined | null>;
182
184
  type KeyValString = Record<string, string>;
183
185
  type KeyValArray = Record<string, string[]>;
@@ -207,11 +209,12 @@ type command_ResAttributes = ResAttributes;
207
209
  declare const command_allFlags: typeof allFlags;
208
210
  declare const command_checkISODateTimeValue: typeof checkISODateTimeValue;
209
211
  declare const command_commandFlags: typeof commandFlags;
212
+ declare const command_filterFlags: typeof filterFlags;
210
213
  declare const command_findLongStringFlag: typeof findLongStringFlag;
211
214
  declare const command_fixDashedFlagValue: typeof fixDashedFlagValue;
212
215
  declare const command_fixValueType: typeof fixValueType;
213
216
  declare namespace command {
214
- 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 };
217
+ 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_filterFlags as filterFlags, command_findLongStringFlag as findLongStringFlag, command_fixDashedFlagValue as fixDashedFlagValue, command_fixValueType as fixValueType };
215
218
  }
216
219
 
217
220
  type AuthScope = string | string[];
package/lib/index.js CHANGED
@@ -1,11 +1,11 @@
1
- "use strict";var Ee=Object.create;var O=Object.defineProperty;var Se=Object.getOwnPropertyDescriptor;var ze=Object.getOwnPropertyNames;var Oe=Object.getPrototypeOf,Ie=Object.prototype.hasOwnProperty;var _=(e,t)=>{for(var r in t)O(e,r,{get:t[r],enumerable:!0})},ue=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of ze(t))!Ie.call(e,n)&&n!==r&&O(e,n,{get:()=>t[n],enumerable:!(s=Se(t,n))||s.enumerable});return e};var I=(e,t,r)=>(r=e!=null?Ee(Oe(e)):{},ue(t||!e||!e.__esModule?O(r,"default",{value:e,enumerable:!0}):r,e)),Ke=e=>ue(O({},"__esModule",{value:!0}),e);var sr={};_(sr,{clApi:()=>J,clApplication:()=>Y,clColor:()=>k,clCommand:()=>X,clConfig:()=>m,clFilter:()=>le,clHelp:()=>S,clOutput:()=>Z,clSchema:()=>ce,clSymbol:()=>ie,clText:()=>oe,clToken:()=>se,clUpdate:()=>ne,clUtil:()=>re});module.exports=Ke(sr);var J={};_(J,{Operation:()=>H,baseURL:()=>Ve,execMode:()=>We,extractDomain:()=>Ue,humanizeResource:()=>Fe,isResourceCacheable:()=>ge,liveEnvironment:()=>He,request:()=>Ge,requestDataFile:()=>N,requestRateLimitDelay:()=>_e,requestRaw:()=>F,response:()=>Je,responseDenormalize:()=>G});var W=["in_progress","pending","completed","interrupted"],Be=["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"],je=["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"],De=["bundles","gift_cards","prices","promotions","sku_lists","sku_options","skus","stock_items"],Me=["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"],Le=["orders","skus","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},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",token_owner_types:["Customer","User"],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:["dashboard","user","metrics","contentful","bundles","customers","datocms","exports","external","gift_cards","imports","integration","inventory","orders","price_lists","promotions","resources","returns","sales_channel","sanity","shipments","skus","sku_lists","stock_transfers","subscriptions","tags","webapp","webhooks","zapier"],login_scopes:["market","stock_location","store"]},imports:{max_size:1e4,statuses:W,types:Be,max_queue_length:10,attachment_expiration:5},exports:{max_size:1e4,statuses:W,types:je,max_queue_length:10,attachment_expiration:5},cleanups:{max_size:1e4,statuses:W,types:De,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:Me,tag_name_max_length:25,tag_name_pattern:/^[0-9A-Za-z_-]{1,25}$/},provisioning:{default_subdomain:"provisioning",scope:"provisioning-api",applications:["user"]},links:{default_domain:"c11r.link",linkable_resources:Le}},m=Pe;var me=require("fs");var F=async(e,t,r)=>await(await fetch(new URL(`/api/${e.resource}`+(r?`/${r}`:""),e.baseUrl),{method:e.operation,headers:{"Content-Type":"application/vnd.api+json",Accept:"application/vnd.api+json",Authorization:`Bearer ${e.accessToken}`},body:JSON.stringify(t)}).then(n=>{if(n.ok)return n;throw new Error(n.statusText)})).json(),N=e=>{let t,r;try{t=(0,me.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}},H=(r=>(r.Create="POST",r.Update="PATCH",r))(H||{});var de=(e,t)=>t.find(r=>e.id===r.id&&e.type===r.type),K=(e,t)=>{let r={id:e.id,type:e.type,...e.attributes};return e.relationships&&Object.keys(e.relationships).forEach(s=>{let n=e.relationships[s].data;n?Array.isArray(n)?r[s]=n.map(i=>K(de(i,t),t)):r[s]=K(de(n,t),t):n===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(n=>K(n,s)):t=K(r,s),t};var Ve=(e="core",t,r)=>`https://${(e==="core"&&t||e).toLowerCase()}.${r||m.api.default_domain}`,Ue=e=>{if(e)return e.substring(e.indexOf(".")+1)},We=e=>e===!0||e==="live"?"live":"test",Fe=e=>e.replace(/_/g," ");var Ne=["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"],ge=(e,t)=>Ne.includes(e||"")&&(t||"GET").toUpperCase()==="GET",He=e=>e==="live",_e=e=>{let t=e?.environment||"test",r=e?.parallelRequests||1,s=ge(e?.resourceType,e?.method),n,i;t==="live"?(n=s?m.api.requests_max_num_burst_cacheable:m.api.requests_max_num_burst,i=s?m.api.requests_max_num_avg_cacheable:m.api.requests_max_num_avg):(n=s?m.api.requests_max_num_burst_test_cacheable:m.api.requests_max_num_burst_test,i=s?m.api.requests_max_num_avg_test_cacheable:m.api.requests_max_num_avg_test);let a=m.api.requests_max_secs_burst/n,p=m.api.requests_max_secs_avg/i,g=r*a,v=r*p,f=e?.totalRequests,c=0;return f&&f>0?f>n&&(f>i?c=v:c=g):c=Math.max(g,v),c=c*1e3,e?.minimumDelay&&(c=Math.max(e.minimumDelay,c)),e?.securityDelay&&(c+=e.securityDelay),c=Math.ceil(c),c};var Ge={raw:F,readDataFile:N,rateLimitDelay:_e},Je={denormalize:G};var Y={};_(Y,{appKey:()=>Ye,appKeyMatch:()=>Ze,appKeyValid:()=>Xe,arrayScope:()=>fe,isProvisioningApp:()=>Qe});var Ye=()=>Date.now().toString(36),Xe=e=>e.key!==void 0&&e.key!=="",Ze=(e,t)=>{let r=e!==void 0,s=t!==void 0;return!r&&!s||r&&s&&e.key===t.key},fe=e=>{if(!e)return[];if(Array.isArray(e))return e;let t=e.replace(/[ ,;]/g,"_").split("_");return Array.isArray(t)?t:[t]},Qe=e=>fe(e.scope).includes(m.provisioning.scope)||e.api==="provisioning";var X={};_(X,{allFlags:()=>tt,checkISODateTimeValue:()=>it,commandFlags:()=>et,findLongStringFlag:()=>st,fixDashedFlagValue:()=>nt,fixValueType:()=>rt});var et=(e,t)=>{let r={...e};if(t)for(let s of t)delete r[s];return r},tt=e=>({...e.flags,...e.baseFlags});var rt=e=>{let t=e;return t==="null"?t=null:Number(t)==t?t=Number(t):t=t==="true"?!0:t==="false"?!1:t,t},st=(e,t)=>{let r=t.startsWith("--")?t:`--${t}`,s,n=e.findIndex(a=>a.startsWith(r)),i=!1;if(n>-1){let a=e[n];if(a.includes("=")){let p=a.split("=");s=p.length===2?p[1]:"",i=!0}else s=e[n+1];return{value:s,index:n,single:i}}else return},nt=(e,t,r,s)=>{let n="____",i=t.name||r,a=t.char;if(!i&&!a)return e;let p=i?i.startsWith("--")?i:`--${i}`:void 0,g=a?t.char.startsWith("-")?a:`-${a}`:void 0,v=e.findIndex(w=>g&&w.startsWith(g)||p&&w.startsWith(p));if(v<0)return e;let f=e[v],c="",pe="";if(g&&f.startsWith(g))c=f.replace(g,"").trim(),f=g;else if(p&&f.startsWith(p))c=f.replace(p,"").trim(),f=p;else return e;if(c.startsWith("=")?(c=c.slice(1),pe=f+"="):c||(c=e[++v]),c.startsWith("-")||c.startsWith(n)){let w=c.startsWith(`${n}`)?c.replace(`${n}`,""):c.replace("-",`${n}-`);if(e[v]=pe+w,c.startsWith(n)&&s){let z=i?i.replace("--",""):void 0,P=Object.entries(s.flags).find(([U,Re])=>Re===c);P&&(!z||z===P[0])&&(s.flags[P[0]]=w);let V=Object.values(s.raw).find(U=>U.type==="flag"&&U.input===c);V&&(!z||z===V.flag)&&(V.input=w)}}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={};_(Z,{center:()=>ot,cleanDate:()=>ct,formatError:()=>pt,formatOutput:()=>ve,localeDate:()=>lt,maxLength:()=>at,printCSV:()=>xe,printJSON:()=>be,printObject:()=>ye});var he=require("util"),ye=(e,t)=>(0,he.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),xe=(e,t)=>{if(!e||e.length===0)return"";let r=Object.keys(e[0]).filter(n=>["id","type"].includes(n)?t?.fields.includes(n):!0),s=r.map(n=>n.toUpperCase().replace(/_/g," ")).join(";")+`
1
+ "use strict";var Ee=Object.create;var O=Object.defineProperty;var Se=Object.getOwnPropertyDescriptor;var ze=Object.getOwnPropertyNames;var Oe=Object.getPrototypeOf,Ie=Object.prototype.hasOwnProperty;var _=(e,t)=>{for(var r in t)O(e,r,{get:t[r],enumerable:!0})},ue=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of ze(t))!Ie.call(e,n)&&n!==r&&O(e,n,{get:()=>t[n],enumerable:!(s=Se(t,n))||s.enumerable});return e};var I=(e,t,r)=>(r=e!=null?Ee(Oe(e)):{},ue(t||!e||!e.__esModule?O(r,"default",{value:e,enumerable:!0}):r,e)),Ke=e=>ue(O({},"__esModule",{value:!0}),e);var nr={};_(nr,{clApi:()=>J,clApplication:()=>Y,clColor:()=>k,clCommand:()=>X,clConfig:()=>m,clFilter:()=>le,clHelp:()=>S,clOutput:()=>Z,clSchema:()=>ce,clSymbol:()=>ie,clText:()=>oe,clToken:()=>se,clUpdate:()=>ne,clUtil:()=>re});module.exports=Ke(nr);var J={};_(J,{Operation:()=>H,baseURL:()=>Ve,execMode:()=>Fe,extractDomain:()=>Ue,humanizeResource:()=>We,isResourceCacheable:()=>ge,liveEnvironment:()=>He,request:()=>Ge,requestDataFile:()=>N,requestRateLimitDelay:()=>_e,requestRaw:()=>W,response:()=>Je,responseDenormalize:()=>G});var F=["in_progress","pending","completed","interrupted"],je=["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"],Be=["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"],De=["bundles","gift_cards","prices","promotions","sku_lists","sku_options","skus","stock_items"],Me=["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"],Le=["orders","skus","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},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",token_owner_types:["Customer","User"],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:["dashboard","user","metrics","contentful","bundles","customers","datocms","exports","external","gift_cards","imports","integration","inventory","orders","price_lists","promotions","resources","returns","sales_channel","sanity","shipments","skus","sku_lists","stock_transfers","subscriptions","tags","webapp","webhooks","zapier"],login_scopes:["market","stock_location","store"]},imports:{max_size:1e4,statuses:F,types:je,max_queue_length:10,attachment_expiration:5},exports:{max_size:1e4,statuses:F,types:Be,max_queue_length:10,attachment_expiration:5},cleanups:{max_size:1e4,statuses:F,types:De,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:Me,tag_name_max_length:25,tag_name_pattern:/^[0-9A-Za-z_-]{1,25}$/},provisioning:{default_subdomain:"provisioning",scope:"provisioning-api",applications:["user"]},links:{default_domain:"c11r.link",linkable_resources:Le}},m=Pe;var me=require("fs");var W=async(e,t,r)=>await(await fetch(new URL(`/api/${e.resource}`+(r?`/${r}`:""),e.baseUrl),{method:e.operation,headers:{"Content-Type":"application/vnd.api+json",Accept:"application/vnd.api+json",Authorization:`Bearer ${e.accessToken}`},body:JSON.stringify(t)}).then(n=>{if(n.ok)return n;throw new Error(n.statusText)})).json(),N=e=>{let t,r;try{t=(0,me.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}},H=(r=>(r.Create="POST",r.Update="PATCH",r))(H||{});var de=(e,t)=>t.find(r=>e.id===r.id&&e.type===r.type),K=(e,t)=>{let r={id:e.id,type:e.type,...e.attributes};return e.relationships&&Object.keys(e.relationships).forEach(s=>{let n=e.relationships[s].data;n?Array.isArray(n)?r[s]=n.map(i=>K(de(i,t),t)):r[s]=K(de(n,t),t):n===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(n=>K(n,s)):t=K(r,s),t};var Ve=(e="core",t,r)=>`https://${(e==="core"&&t||e).toLowerCase()}.${r||m.api.default_domain}`,Ue=e=>{if(e)return e.substring(e.indexOf(".")+1)},Fe=e=>e===!0||e==="live"?"live":"test",We=e=>e.replace(/_/g," ");var Ne=["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"],ge=(e,t)=>Ne.includes(e||"")&&(t||"GET").toUpperCase()==="GET",He=e=>e==="live",_e=e=>{let t=e?.environment||"test",r=e?.parallelRequests||1,s=ge(e?.resourceType,e?.method),n,i;t==="live"?(n=s?m.api.requests_max_num_burst_cacheable:m.api.requests_max_num_burst,i=s?m.api.requests_max_num_avg_cacheable:m.api.requests_max_num_avg):(n=s?m.api.requests_max_num_burst_test_cacheable:m.api.requests_max_num_burst_test,i=s?m.api.requests_max_num_avg_test_cacheable:m.api.requests_max_num_avg_test);let a=m.api.requests_max_secs_burst/n,p=m.api.requests_max_secs_avg/i,g=r*a,v=r*p,f=e?.totalRequests,c=0;return f&&f>0?f>n&&(f>i?c=v:c=g):c=Math.max(g,v),c=c*1e3,e?.minimumDelay&&(c=Math.max(e.minimumDelay,c)),e?.securityDelay&&(c+=e.securityDelay),c=Math.ceil(c),c};var Ge={raw:W,readDataFile:N,rateLimitDelay:_e},Je={denormalize:G};var Y={};_(Y,{appKey:()=>Ye,appKeyMatch:()=>Ze,appKeyValid:()=>Xe,arrayScope:()=>fe,isProvisioningApp:()=>Qe});var Ye=()=>Date.now().toString(36),Xe=e=>e.key!==void 0&&e.key!=="",Ze=(e,t)=>{let r=e!==void 0,s=t!==void 0;return!r&&!s||r&&s&&e.key===t.key},fe=e=>{if(!e)return[];if(Array.isArray(e))return e;let t=e.replace(/[ ,;]/g,"_").split("_");return Array.isArray(t)?t:[t]},Qe=e=>fe(e.scope).includes(m.provisioning.scope)||e.api==="provisioning";var X={};_(X,{allFlags:()=>rt,checkISODateTimeValue:()=>ot,commandFlags:()=>et,filterFlags:()=>tt,findLongStringFlag:()=>nt,fixDashedFlagValue:()=>it,fixValueType:()=>st});var et=(e,t)=>{let r={...e};if(t)for(let s of t)delete r[s];return r},tt=(e,t,r)=>{let s={};return Object.entries(e).forEach(([n,i])=>{(!t||t.includes(n))&&!r?.includes(n)&&(s[n]=i)}),s},rt=e=>({...e.flags,...e.baseFlags}),st=e=>{let t=e;return t==="null"?t=null:Number(t)==t?t=Number(t):t=t==="true"?!0:t==="false"?!1:t,t},nt=(e,t)=>{let r=t.startsWith("--")?t:`--${t}`,s,n=e.findIndex(a=>a.startsWith(r)),i=!1;if(n>-1){let a=e[n];if(a.includes("=")){let p=a.split("=");s=p.length===2?p[1]:"",i=!0}else s=e[n+1];return{value:s,index:n,single:i}}else return},it=(e,t,r,s)=>{let n="____",i=t.name||r,a=t.char;if(!i&&!a)return e;let p=i?i.startsWith("--")?i:`--${i}`:void 0,g=a?t.char.startsWith("-")?a:`-${a}`:void 0,v=e.findIndex(w=>g&&w.startsWith(g)||p&&w.startsWith(p));if(v<0)return e;let f=e[v],c="",pe="";if(g&&f.startsWith(g))c=f.replace(g,"").trim(),f=g;else if(p&&f.startsWith(p))c=f.replace(p,"").trim(),f=p;else return e;if(c.startsWith("=")?(c=c.slice(1),pe=f+"="):c||(c=e[++v]),c.startsWith("-")||c.startsWith(n)){let w=c.startsWith(`${n}`)?c.replace(`${n}`,""):c.replace("-",`${n}-`);if(e[v]=pe+w,c.startsWith(n)&&s){let z=i?i.replace("--",""):void 0,P=Object.entries(s.flags).find(([U,Re])=>Re===c);P&&(!z||z===P[0])&&(s.flags[P[0]]=w);let V=Object.values(s.raw).find(U=>U.type==="flag"&&U.input===c);V&&(!z||z===V.flag)&&(V.input=w)}}return e},ot=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={};_(Z,{center:()=>at,cleanDate:()=>lt,formatError:()=>ut,formatOutput:()=>ve,localeDate:()=>pt,maxLength:()=>ct,printCSV:()=>xe,printJSON:()=>be,printObject:()=>ye});var he=require("util"),ye=(e,t)=>(0,he.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),xe=(e,t)=>{if(!e||e.length===0)return"";let r=Object.keys(e[0]).filter(n=>["id","type"].includes(n)?t?.fields.includes(n):!0),s=r.map(n=>n.toUpperCase().replace(/_/g," ")).join(";")+`
2
2
  `;return e.forEach(n=>{s+=r.map(i=>n[i]).join(";")+`
3
- `}),s},ot=(e,t)=>e.padStart(e.length+Math.floor((t-e.length)/2)," ").padEnd(t," "),at=(e,t)=>e.reduce((r,s)=>{let n=Array.isArray(s[t])?s[t].join():s[t];return Math.max(r,String(n).length)},0),ct=e=>e?e.replace("T"," ").replace("Z","").substring(0,e.lastIndexOf(".")):"",lt=e=>e?new Date(Date.parse(e)).toLocaleString():"",ve=(e,t,{color:r=!0}={})=>{if(!e)return"";if(typeof e=="string")return e;if(t){if(t.csv)return xe(e,t);if(t.json)return be(e,{unformatted:t.unformatted})}return ye(e,{color:r})},pt=(e,t)=>ve(e.errors||e,t);var k={};_(k,{api:()=>Et,bg:()=>qt,black:()=>xt,blackBright:()=>vt,blue:()=>ht,blueBright:()=>C,bold:()=>ee,cli:()=>zt,cyan:()=>wt,cyanBright:()=>$,dim:()=>$t,green:()=>_t,greenBright:()=>Q,grey:()=>Tt,hidden:()=>dt,italic:()=>T,magenta:()=>kt,magentaBright:()=>At,msg:()=>St,red:()=>gt,redBright:()=>Te,reset:()=>ut,style:()=>l,table:()=>Ot,type:()=>Rt,underline:()=>Ct,visible:()=>mt,white:()=>yt,whiteBright:()=>bt,yellow:()=>ft,yellowBright:()=>x});var o=I(require("chalk")),ut=o.default.reset,mt=o.default.visible,dt=o.default.hidden,gt=o.default.red,Te=o.default.redBright,_t=o.default.green,Q=o.default.greenBright,ft=o.default.yellow,x=o.default.yellowBright,ht=o.default.blue,C=o.default.blueBright,yt=o.default.white,bt=o.default.whiteBright,xt=o.default.black,vt=o.default.blackBright,Tt=o.default.grey,wt=o.default.cyan,$=o.default.cyanBright,kt=o.default.magenta,At=o.default.magentaBright,ee=o.default.bold,$t=o.default.dim,Ct=o.default.underline,T=o.default.italic,qt={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:C,resource:ee,attribute:T,trigger:$,kind:$,live:Q,test:x,execMode:e=>e==="live"?l.live:l.test,success:Q,warning:x,error:Te,arg:T,flag:T,command:T,value:T,alias:$,plugin:C,title:C,path:T,datetime:$,number:x},Rt={datetime:l.datetime,number:l.number,path:l.path},Et={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},St={success:l.success,warning:l.warning,error:l.error},zt={arg:l.arg,flag:l.flag,command:l.command,value:l.value,alias:l.alias,plugin:l.plugin},Ot={header:x.bold,key:C};var se={};_(se,{buildAssertionPayload:()=>Ft,decodeAccessToken:()=>ke,generateAccessToken:()=>Lt,getAccessToken:()=>Pt,getTokenEnvironment:()=>Wt,isAccessTokenExpiring:()=>Ut,revokeAccessToken:()=>Vt});var M=I(require("jsonwebtoken"));var A=require("@commercelayer/js-auth");var re={};_(re,{dotNotationToObject:()=>te,generateGroupUID:()=>Dt,log:()=>Bt,resetConsole:()=>Kt,sleep:()=>It,specialFolder:()=>jt,userAgent:()=>Mt});var B=require("util"),j=require("path"),we=require("os"),D=require("fs"),It=async e=>new Promise(t=>setTimeout(t,e)),Kt=()=>{process.stdout.write("\x1B[?25h\x1B[?7h")},Bt=(e="",...t)=>{e=typeof e=="string"?e:(0,B.inspect)(e),process.stdout.write((0,B.format)(e,...t)+`
4
- `)},jt=(e,t=!1)=>{let r=["desktop","home"],s=e.toLowerCase().split(/[\\\/]/g)[0];if(r.includes(s)){let i=(0,we.homedir)();s==="desktop"&&(i+=`${j.sep}Desktop`),e=e.replace(s,i)}let n=(0,j.dirname)(e);return t&&!(0,D.existsSync)(n)&&(0,D.mkdirSync)(n,{recursive:!0}),e},Dt=()=>{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},Mt=e=>`${e.name.replace(/@commercelayer\/cli-plugin/,"CLI")}/${e.version}`,te=(e,t)=>{let r=t||{};return Object.entries(e).forEach(([s,n])=>{let i=s.split("."),a=i[i.length-1],p=r;i.forEach(g=>{g===a?p[g]=n:p=p[g]||(p[g]={})})}),t&&Object.assign(t,r),r};var ke=e=>{let t=M.default.decode(e);if(t===null)throw new Error("Error decoding access token");return t},Lt=(e,t,r)=>{let n={...e,exp:Math.floor(Date.now()/1e3)+r*60,rand:Math.random()},i=m.api.token_encoding_algorithm,a=M.default.sign(n,t,{algorithm:i,noTimestamp:!0}),p=M.default.verify(a,t,{algorithms:[i]});return{accessToken:a,info:p,expMinutes:r}},Pt=async e=>{let t,r=e.scope?Array.isArray(e.scope)?e.scope.map(n=>n.trim()).join(","):e.scope:"",s={clientId:e.clientId,clientSecret:e.clientSecret,slug:e.slug,domain:e.domain,scope:r};if(e.email&&e.password?(s.username=e.email,s.password=e.password,t=await(0,A.authenticate)("password",s)):e.assertion?(s.assertion=e.assertion,t=await(0,A.authenticate)("urn:ietf:params:oauth:grant-type:jwt-bearer",s)):t=await(0,A.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},Vt=async(e,t)=>{let r=await(0,A.revoke)({...e,token:t});if(r.errors)throw new Error(r.errors[0].detail)},Ut=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"?ke(e):e).test?"test":"live";var Ft=(e,t,r)=>{let s="https://commercelayer.io/claims",n={[s]:{owner:{type:e,id:t}}};if(r&&Object.keys(r).length>0){let i=te(r);n[s].custom_claim=i}return n};var ne={};_(ne,{checkUpdate:()=>Ht});var q=I(require("chalk")),Ae=I(require("update-notifier-cjs")),Nt=1,Ht=e=>{let t=(0,Ae.default)({pkg:e,updateCheckInterval:36e5*Nt});t.update&&t.notify({isGlobal:!1,message:`-= ${q.default.bgWhite.black.bold(` ${e.description} `)} =-
3
+ `}),s},at=(e,t)=>e.padStart(e.length+Math.floor((t-e.length)/2)," ").padEnd(t," "),ct=(e,t)=>e.reduce((r,s)=>{let n=Array.isArray(s[t])?s[t].join():s[t];return Math.max(r,String(n).length)},0),lt=e=>e?e.replace("T"," ").replace("Z","").substring(0,e.lastIndexOf(".")):"",pt=e=>e?new Date(Date.parse(e)).toLocaleString():"",ve=(e,t,{color:r=!0}={})=>{if(!e)return"";if(typeof e=="string")return e;if(t){if(t.csv)return xe(e,t);if(t.json)return be(e,{unformatted:t.unformatted})}return ye(e,{color:r})},ut=(e,t)=>ve(e.errors||e,t);var k={};_(k,{api:()=>St,bg:()=>Rt,black:()=>vt,blackBright:()=>Tt,blue:()=>yt,blueBright:()=>C,bold:()=>ee,cli:()=>Ot,cyan:()=>kt,cyanBright:()=>$,dim:()=>Ct,green:()=>ft,greenBright:()=>Q,grey:()=>wt,hidden:()=>gt,italic:()=>T,magenta:()=>At,magentaBright:()=>$t,msg:()=>zt,red:()=>_t,redBright:()=>Te,reset:()=>mt,style:()=>l,table:()=>It,type:()=>Et,underline:()=>qt,visible:()=>dt,white:()=>bt,whiteBright:()=>xt,yellow:()=>ht,yellowBright:()=>x});var o=I(require("chalk")),mt=o.default.reset,dt=o.default.visible,gt=o.default.hidden,_t=o.default.red,Te=o.default.redBright,ft=o.default.green,Q=o.default.greenBright,ht=o.default.yellow,x=o.default.yellowBright,yt=o.default.blue,C=o.default.blueBright,bt=o.default.white,xt=o.default.whiteBright,vt=o.default.black,Tt=o.default.blackBright,wt=o.default.grey,kt=o.default.cyan,$=o.default.cyanBright,At=o.default.magenta,$t=o.default.magentaBright,ee=o.default.bold,Ct=o.default.dim,qt=o.default.underline,T=o.default.italic,Rt={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:C,resource:ee,attribute:T,trigger:$,kind:$,live:Q,test:x,execMode:e=>e==="live"?l.live:l.test,success:Q,warning:x,error:Te,arg:T,flag:T,command:T,value:T,alias:$,plugin:C,title:C,path:T,datetime:$,number:x},Et={datetime:l.datetime,number:l.number,path:l.path},St={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},zt={success:l.success,warning:l.warning,error:l.error},Ot={arg:l.arg,flag:l.flag,command:l.command,value:l.value,alias:l.alias,plugin:l.plugin},It={header:x.bold,key:C};var se={};_(se,{buildAssertionPayload:()=>Nt,decodeAccessToken:()=>ke,generateAccessToken:()=>Pt,getAccessToken:()=>Vt,getTokenEnvironment:()=>Wt,isAccessTokenExpiring:()=>Ft,revokeAccessToken:()=>Ut});var M=I(require("jsonwebtoken"));var A=require("@commercelayer/js-auth");var re={};_(re,{dotNotationToObject:()=>te,generateGroupUID:()=>Mt,log:()=>Bt,resetConsole:()=>jt,sleep:()=>Kt,specialFolder:()=>Dt,userAgent:()=>Lt});var j=require("util"),B=require("path"),we=require("os"),D=require("fs"),Kt=async e=>new Promise(t=>setTimeout(t,e)),jt=()=>{process.stdout.write("\x1B[?25h\x1B[?7h")},Bt=(e="",...t)=>{e=typeof e=="string"?e:(0,j.inspect)(e),process.stdout.write((0,j.format)(e,...t)+`
4
+ `)},Dt=(e,t=!1)=>{let r=["desktop","home"],s=e.toLowerCase().split(/[\\\/]/g)[0];if(r.includes(s)){let i=(0,we.homedir)();s==="desktop"&&(i+=`${B.sep}Desktop`),e=e.replace(s,i)}let n=(0,B.dirname)(e);return t&&!(0,D.existsSync)(n)&&(0,D.mkdirSync)(n,{recursive:!0}),e},Mt=()=>{let e=Math.trunc(Math.random()*46656),t=Math.trunc(Math.random()*46656),r=("000"+e.toString(36)).slice(-3),s=("000"+t.toString(36)).slice(-3);return r+s},Lt=e=>`${e.name.replace(/@commercelayer\/cli-plugin/,"CLI")}/${e.version}`,te=(e,t)=>{let r=t||{};return Object.entries(e).forEach(([s,n])=>{let i=s.split("."),a=i[i.length-1],p=r;i.forEach(g=>{g===a?p[g]=n:p=p[g]||(p[g]={})})}),t&&Object.assign(t,r),r};var ke=e=>{let t=M.default.decode(e);if(t===null)throw new Error("Error decoding access token");return t},Pt=(e,t,r)=>{let n={...e,exp:Math.floor(Date.now()/1e3)+r*60,rand:Math.random()},i=m.api.token_encoding_algorithm,a=M.default.sign(n,t,{algorithm:i,noTimestamp:!0}),p=M.default.verify(a,t,{algorithms:[i]});return{accessToken:a,info:p,expMinutes:r}},Vt=async e=>{let t,r=e.scope?Array.isArray(e.scope)?e.scope.map(n=>n.trim()).join(","):e.scope:"",s={clientId:e.clientId,clientSecret:e.clientSecret,slug:e.slug,domain:e.domain,scope:r};if(e.email&&e.password?(s.username=e.email,s.password=e.password,t=await(0,A.authenticate)("password",s)):e.assertion?(s.assertion=e.assertion,t=await(0,A.authenticate)("urn:ietf:params:oauth:grant-type:jwt-bearer",s)):t=await(0,A.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},Ut=async(e,t)=>{let r=await(0,A.revoke)({...e,token:t});if(r.errors)throw new Error(r.errors[0].detail)},Ft=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"?ke(e):e).test?"test":"live";var Nt=(e,t,r)=>{let s="https://commercelayer.io/claims",n={[s]:{owner:{type:e,id:t}}};if(r&&Object.keys(r).length>0){let i=te(r);n[s].custom_claim=i}return n};var ne={};_(ne,{checkUpdate:()=>Gt});var q=I(require("chalk")),Ae=I(require("update-notifier-cjs")),Ht=1,Gt=e=>{let t=(0,Ae.default)({pkg:e,updateCheckInterval:36e5*Ht});t.update&&t.notify({isGlobal:!1,message:`-= ${q.default.bgWhite.black.bold(` ${e.description} `)} =-
5
5
 
6
6
  New version available: ${q.default.dim("{currentVersion}")} -> ${q.default.green("{latestVersion}")}
7
- Run ${q.default.cyanBright("commercelayer plugins:update")} to update`})};var L=require("@oclif/core");var oe={};_(oe,{camelize:()=>Zt,capitalize:()=>E,dasherize:()=>Gt,pluralize:()=>Yt,singularize:()=>Xt,symbols:()=>b,underscorize:()=>Jt});var u={uncountableWords:["equipment","information","rice","money","species","series","fish","sheep","moose","deer","news"],pluralRules:[[/(m)an$/gi,"$1en"],[/(pe)rson$/gi,"$1ople"],[/(child)$/gi,"$1ren"],[/^(ox)$/gi,"$1en"],[/(ax|test)is$/gi,"$1es"],[/(octop|vir)us$/gi,"$1i"],[/(alias|status)$/gi,"$1es"],[/(bu)s$/gi,"$1ses"],[/(buffal|tomat|potat)o$/gi,"$1oes"],[/([ti])um$/gi,"$1a"],[/sis$/gi,"ses"],[/(?:([^f])fe|([lr])f)$/gi,"$1$2ves"],[/(hive)$/gi,"$1s"],[/([^aeiouy]|qu)y$/gi,"$1ies"],[/(x|ch|ss|sh)$/gi,"$1es"],[/(matr|vert|ind)ix|ex$/gi,"$1ices"],[/([m|l])ouse$/gi,"$1ice"],[/(quiz)$/gi,"$1zes"],[/s$/gi,"s"],[/$/gi,"s"]],singularRules:[[/(m)en$/gi,"$1an"],[/(pe)ople$/gi,"$1rson"],[/(child)ren$/gi,"$1"],[/([ti])a$/gi,"$1um"],[/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/gi,"$1$2sis"],[/(hive)s$/gi,"$1"],[/(tive)s$/gi,"$1"],[/(curve)s$/gi,"$1"],[/([lr])ves$/gi,"$1f"],[/([^fo])ves$/gi,"$1fe"],[/([^aeiouy]|qu)ies$/gi,"$1y"],[/(s)eries$/gi,"$1eries"],[/(m)ovies$/gi,"$1ovie"],[/(x|ch|ss|sh)es$/gi,"$1"],[/([m|l])ice$/gi,"$1ouse"],[/(bus)es$/gi,"$1"],[/(o)es$/gi,"$1"],[/(shoe)s$/gi,"$1"],[/(cris|ax|test)es$/gi,"$1is"],[/(octop|vir)i$/gi,"$1us"],[/(alias|status)es$/gi,"$1"],[/^(ox)en/gi,"$1"],[/(vert|ind)ices$/gi,"$1ex"],[/(matr)ices$/gi,"$1ix"],[/(quiz)zes$/gi,"$1"],[/s$/gi,""]],nonTitlecasedWords:["and","or","nor","a","an","the","so","but","to","of","at","by","from","into","on","onto","off","out","in","over","with","for"],idSuffix:/(_ids|_id)$/g,underbar:/_/g,spaceOrUnderbar:/[ _]/g,uppercase:/([A-Z])/g,underbarPrefix:/^_/,applyRules:function(e,t,r,s){if(s)e=s;else if(!r.includes(e.toLowerCase())){for(let i=0;i<t.length;i++)if(e.match(t[i][0])){e=e.replace(t[i][0],t[i][1]);break}}return e},pluralize:function(e,t){return u.applyRules(e,u.pluralRules,u.uncountableWords,t)},singularize:function(e,t){return u.applyRules(e,u.singularRules,u.uncountableWords,t)},camelize:function(e,t){let r=e.split("/");for(let s=0;s<r.length;s++){let n=r[s].split("_"),i=t&&s+1===r.length?1:0;for(let a=i;a<n.length;a++)n[a]=n[a].charAt(0).toUpperCase()+n[a].substring(1);r[s]=n.join("")}if(e=r.join("::"),t){let s=e.charAt(0).toLowerCase(),n=e.slice(1);e=s+n}return e},underscore:function(e){let t=e.split("::");for(let r=0;r<t.length;r++)t[r]=t[r].replace(u.uppercase,"_$1"),t[r]=t[r].replace(u.underbarPrefix,"");return e=t.join("/").toLowerCase(),e},humanize:function(e,t){return e=e.toLowerCase(),e=e.replace(u.idSuffix,""),e=e.replace(u.underbar," "),t||(e=u.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(u.spaceOrUnderbar,"-"),e},camel2words:function(e,t){t?(e=u.camelize(e),e=u.underscore(e)):e=e.toLowerCase(),e=e.replace(u.underbar," ");let r=e.split(" ");for(let s=0;s<r.length;s++){let n=r[s].split("-");for(let i=0;i<n.length;i++)u.nonTitlecasedWords.includes(n[i].toLowerCase())||(n[i]=u.capitalize(n[i]));r[s]=n.join("-")}return e=r.join(" "),e=e.substring(0,1).toUpperCase()+e.substring(1),e},demodulize:function(e){let t=e.split("::");return e=t[t.length-1],e},tableize:function(e){return e=u.pluralize(u.underscore(e)),e},classify:function(e){return e=u.singularize(u.camelize(e)),e},foreignKey:function(e,t){return e=u.underscore(u.demodulize(e))+(t?"":"_")+"id",e},ordinalize:function(e){let t=e.split(" ");for(let r=0;r<t.length;r++){let s=parseInt(t[r]);if(Number.isNaN(s)){let n=t[r].substring(t[r].length-2),i=t[r].substring(t[r].length-1),a="th";n!=="11"&&n!=="12"&&n!=="13"&&(i==="1"?a="st":i==="2"?a="nd":i==="3"&&(a="rd")),t[r]+=a}}return e=t.join(" "),e}},R=u;var ie={};_(ie,{symbols:()=>b});var b={check:{small:"\u2714",bkgGreen:"\u2705",squareRoot:"\u221A"},cross:{small:"\u2718",red:"\u274C"},clock:{stopwatch:"\u23F1"},arrow:{down:"\u2193"},selection:{fisheye:"\u25C9"}};b.check.heavy=b.check.small;b.check.whiteHeavy=b.check.bkgGreen;b.cross.heavyBallot=b.cross.small;var E=e=>e&&R.capitalize(e),Gt=e=>e&&(e=e.toLocaleLowerCase(),e.replace(/[ _]/g,"-")),Jt=e=>e&&(e=e.toLocaleLowerCase(),e.replace(/[ -]/g,"_")),Yt=(e,t)=>R.pluralize(e,t),Xt=(e,t)=>R.singularize(e,t),Zt=(e,t)=>R.camelize(e,t);var h=!1,ae=class extends L.CommandHelp{examples(t){return h&&console.log("---------- command.examples"),super.examples(t)}},S=class extends L.Help{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,n=this.sortedTopics.filter(p=>p.name.startsWith(r+":")&&p.name.split(":").length===s+1),i=this.sortedCommands.filter(p=>p.id.startsWith(r+":")&&p.id.split(":").length===s+1),a=t.description&&this.render(t.description).split(`
7
+ Run ${q.default.cyanBright("commercelayer plugins:update")} to update`})};var L=require("@oclif/core");var oe={};_(oe,{camelize:()=>Qt,capitalize:()=>E,dasherize:()=>Jt,pluralize:()=>Xt,singularize:()=>Zt,symbols:()=>b,underscorize:()=>Yt});var u={uncountableWords:["equipment","information","rice","money","species","series","fish","sheep","moose","deer","news"],pluralRules:[[/(m)an$/gi,"$1en"],[/(pe)rson$/gi,"$1ople"],[/(child)$/gi,"$1ren"],[/^(ox)$/gi,"$1en"],[/(ax|test)is$/gi,"$1es"],[/(octop|vir)us$/gi,"$1i"],[/(alias|status)$/gi,"$1es"],[/(bu)s$/gi,"$1ses"],[/(buffal|tomat|potat)o$/gi,"$1oes"],[/([ti])um$/gi,"$1a"],[/sis$/gi,"ses"],[/(?:([^f])fe|([lr])f)$/gi,"$1$2ves"],[/(hive)$/gi,"$1s"],[/([^aeiouy]|qu)y$/gi,"$1ies"],[/(x|ch|ss|sh)$/gi,"$1es"],[/(matr|vert|ind)ix|ex$/gi,"$1ices"],[/([m|l])ouse$/gi,"$1ice"],[/(quiz)$/gi,"$1zes"],[/s$/gi,"s"],[/$/gi,"s"]],singularRules:[[/(m)en$/gi,"$1an"],[/(pe)ople$/gi,"$1rson"],[/(child)ren$/gi,"$1"],[/([ti])a$/gi,"$1um"],[/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/gi,"$1$2sis"],[/(hive)s$/gi,"$1"],[/(tive)s$/gi,"$1"],[/(curve)s$/gi,"$1"],[/([lr])ves$/gi,"$1f"],[/([^fo])ves$/gi,"$1fe"],[/([^aeiouy]|qu)ies$/gi,"$1y"],[/(s)eries$/gi,"$1eries"],[/(m)ovies$/gi,"$1ovie"],[/(x|ch|ss|sh)es$/gi,"$1"],[/([m|l])ice$/gi,"$1ouse"],[/(bus)es$/gi,"$1"],[/(o)es$/gi,"$1"],[/(shoe)s$/gi,"$1"],[/(cris|ax|test)es$/gi,"$1is"],[/(octop|vir)i$/gi,"$1us"],[/(alias|status)es$/gi,"$1"],[/^(ox)en/gi,"$1"],[/(vert|ind)ices$/gi,"$1ex"],[/(matr)ices$/gi,"$1ix"],[/(quiz)zes$/gi,"$1"],[/s$/gi,""]],nonTitlecasedWords:["and","or","nor","a","an","the","so","but","to","of","at","by","from","into","on","onto","off","out","in","over","with","for"],idSuffix:/(_ids|_id)$/g,underbar:/_/g,spaceOrUnderbar:/[ _]/g,uppercase:/([A-Z])/g,underbarPrefix:/^_/,applyRules:function(e,t,r,s){if(s)e=s;else if(!r.includes(e.toLowerCase())){for(let i=0;i<t.length;i++)if(e.match(t[i][0])){e=e.replace(t[i][0],t[i][1]);break}}return e},pluralize:function(e,t){return u.applyRules(e,u.pluralRules,u.uncountableWords,t)},singularize:function(e,t){return u.applyRules(e,u.singularRules,u.uncountableWords,t)},camelize:function(e,t){let r=e.split("/");for(let s=0;s<r.length;s++){let n=r[s].split("_"),i=t&&s+1===r.length?1:0;for(let a=i;a<n.length;a++)n[a]=n[a].charAt(0).toUpperCase()+n[a].substring(1);r[s]=n.join("")}if(e=r.join("::"),t){let s=e.charAt(0).toLowerCase(),n=e.slice(1);e=s+n}return e},underscore:function(e){let t=e.split("::");for(let r=0;r<t.length;r++)t[r]=t[r].replace(u.uppercase,"_$1"),t[r]=t[r].replace(u.underbarPrefix,"");return e=t.join("/").toLowerCase(),e},humanize:function(e,t){return e=e.toLowerCase(),e=e.replace(u.idSuffix,""),e=e.replace(u.underbar," "),t||(e=u.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(u.spaceOrUnderbar,"-"),e},camel2words:function(e,t){t?(e=u.camelize(e),e=u.underscore(e)):e=e.toLowerCase(),e=e.replace(u.underbar," ");let r=e.split(" ");for(let s=0;s<r.length;s++){let n=r[s].split("-");for(let i=0;i<n.length;i++)u.nonTitlecasedWords.includes(n[i].toLowerCase())||(n[i]=u.capitalize(n[i]));r[s]=n.join("-")}return e=r.join(" "),e=e.substring(0,1).toUpperCase()+e.substring(1),e},demodulize:function(e){let t=e.split("::");return e=t[t.length-1],e},tableize:function(e){return e=u.pluralize(u.underscore(e)),e},classify:function(e){return e=u.singularize(u.camelize(e)),e},foreignKey:function(e,t){return e=u.underscore(u.demodulize(e))+(t?"":"_")+"id",e},ordinalize:function(e){let t=e.split(" ");for(let r=0;r<t.length;r++){let s=parseInt(t[r]);if(Number.isNaN(s)){let n=t[r].substring(t[r].length-2),i=t[r].substring(t[r].length-1),a="th";n!=="11"&&n!=="12"&&n!=="13"&&(i==="1"?a="st":i==="2"?a="nd":i==="3"&&(a="rd")),t[r]+=a}}return e=t.join(" "),e}},R=u;var ie={};_(ie,{symbols:()=>b});var b={check:{small:"\u2714",bkgGreen:"\u2705",squareRoot:"\u221A"},cross:{small:"\u2718",red:"\u274C"},clock:{stopwatch:"\u23F1"},arrow:{down:"\u2193"},selection:{fisheye:"\u25C9"}};b.check.heavy=b.check.small;b.check.whiteHeavy=b.check.bkgGreen;b.cross.heavyBallot=b.cross.small;var E=e=>e&&R.capitalize(e),Jt=e=>e&&(e=e.toLocaleLowerCase(),e.replace(/[ _]/g,"-")),Yt=e=>e&&(e=e.toLocaleLowerCase(),e.replace(/[ -]/g,"_")),Xt=(e,t)=>R.pluralize(e,t),Zt=(e,t)=>R.singularize(e,t),Qt=(e,t)=>R.camelize(e,t);var h=!1,ae=class extends L.CommandHelp{examples(t){return h&&console.log("---------- command.examples"),super.examples(t)}},S=class extends L.Help{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,n=this.sortedTopics.filter(p=>p.name.startsWith(r+":")&&p.name.split(":").length===s+1),i=this.sortedCommands.filter(p=>p.id.startsWith(r+":")&&p.id.split(":").length===s+1),a=t.description&&this.render(t.description).split(`
8
8
  `)[0];a&&console.log(`${E(a)}
9
9
  `),console.log(this.formatCommand(t)),console.log(""),n.length>0&&(console.log(this.formatTopics(n)),console.log("")),i.length>0&&(console.log(this.formatCommands(i)),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=E(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(n=>(n||"").trim()!==""&&++s===2?E(n):n).join(" ")}).join(`
11
- `)}formatCommand(t){return h&&console.log("---------- formatCommand"),super.formatCommand(t)}getCommandHelpClass(t){return h&&console.log("---------- getCommandHelpClass"),new ae(t,this.config,this.opts)}};var ce={};_(ce,{download:()=>Qt});var Qt=async e=>{let r=`https://data.${m.api.default_app_domain}/schemas/`,n=`openapi${e?"_"+e.replace(/\./g,"-"):""}.json`,i=r+n;return await(await fetch(i)).json()};var le={};_(le,{apply:()=>rr,available:()=>Ce,documentation:()=>tr,filters:()=>qe,list:()=>$e});var er=[{predicate:"*_eq",description:"The attribute is equal to the filter value"},{predicate:"*_eq_or_null",description:"The attribute is equal to the filter value, including null values"},{predicate:"*_not_eq",description:"The attribute is not equal to the filter value"},{predicate:"*_not_eq_or_null",description:"The attribute is not equal to the filter value, including null values"},{predicate:"*_matches",description:'The attribute matches the filter value with "LIKE" operator'},{predicate:"*_does_not_match",description:'The attribute does not match the filter value with "LIKE" operator'},{predicate:"*_matches_any",description:'The attribute matches all of the filter values (comma-separated) with "LIKE" operator'},{predicate:"*_matches_all",description:'The attribute matches all of the filter values (comma-separated) with "LIKE" operator'},{predicate:"*_does_not_match_any",description:'The attribute does not match any of the filter values (comma-separated) with "LIKE" operator'},{predicate:"*_does_not_match_all",description:'The attribute matches none of the filter values (comma-separated) with "LIKE" operator'},{predicate:"*_lt",description:"The attribute is less than the filter value"},{predicate:"*_lteq",description:"The attribute is less than or equal to the filter value"},{predicate:"*_gt",description:"The attribute is greater than the filter value"},{predicate:"*_gteq",description:"The attribute is greater than or equal to the filter value"},{predicate:"*_present",description:"The attribute is not null and not empty"},{predicate:"*_blank",description:"The attribute is null or empty"},{predicate:"*_null",description:"The attribute is null"},{predicate:"*_not_null",description:"The attribute is not null"},{predicate:"*_in",description:"The attribute matches any of the filter values (comma-separated)"},{predicate:"*_in_or_null",description:"The attribute matches any of the filter values (comma-separated), including null values"},{predicate:"*_not_in",description:"The attribute matches none of the filter values (comma-separated)"},{predicate:"*_not_in_or_null",description:"The attribute matches none of the filter values (comma-separated), including null values"},{predicate:"*_lt_any",description:"The attribute is less than any of the filter values (comma-separated)"},{predicate:"*_lteq_any",description:"The attribute is less than or equal to any of the filter values (comma-separated)"},{predicate:"*_gt_any",description:"The attribute is greater than any of the filter values (comma-separated)"},{predicate:"*_gteq_any",description:"The attribute is greater than or qual to any of the filter values (comma-separated)"},{predicate:"*_lt_all",description:"The attribute is less than all of the filter values (comma-separated)"},{predicate:"*_lteq_all",description:"The attribute is less than or equal to all of the filter values (comma-separated)"},{predicate:"*_gt_all",description:"The attribute is greater than all of the filter values (comma-separated)"},{predicate:"*_gteq_all",description:"The attribute is greater or equal to all of the filter values (comma-separated)"},{predicate:"*_not_eq_all",description:"The attribute is equal to none of the filter values (comma-separated)"},{predicate:"*_start",description:"The attribute starts with the filter value (comma-separated)"},{predicate:"*_not_start",description:"The attribute does not start with the filter value (comma-separated)"},{predicate:"*_start_any",description:"The attribute starts with any of the filter values (comma-separated)"},{predicate:"*_start_all",description:"The attribute starts with all of the filter values (comma-separated)"},{predicate:"*_not_start_any",description:"The attribute does not start with any of the filter values (comma-separated)"},{predicate:"*_not_start_all",description:"The attribute starts with none of the filter values (comma-separated)"},{predicate:"*_end",description:"The attribute ends with the filter value"},{predicate:"*_not_end",description:"The attribute does not end with the filter value"},{predicate:"*_end_any",description:"The attribute ends with any of the filter values (comma-separated)"},{predicate:"*_end_all",description:"The attribute ends with all of the filter values (comma-separated)"},{predicate:"*_not_end_any",description:"The attribute does not end with any of the filter values (comma-separated)"},{predicate:"*_not_end_all",description:"The attribute ends with none of the filter values (comma-separated)"},{predicate:"*_cont",description:"The attribute contains the filter value"},{predicate:"*_not_cont",description:"The attribute does not contains the filter value"},{predicate:"*_cont_any",description:"The attribute contains any of the filter values (comma-separated)"},{predicate:"*_cont_all",description:"The attribute contains all of the filter values (comma-separated)"},{predicate:"*_not_cont_all",description:"The attribute contains none of the filter values (comma-separated)"},{predicate:"*_jcont",description:"The attribute contains a portion of the JSON used as filter value (works with object only)"},{predicate:"*_true",description:"The attribute is true"},{predicate:"*_false",description:"The attribute is false"}],tr=m.doc.core_filtering_data,$e=()=>qe().map(e=>e.predicate.replace(/^\*/g,"")),Ce=e=>{let t=e.startsWith("_")?e:`_${e}`;return $e().some(r=>t.endsWith(r))},rr=(e,...t)=>{if(!Ce(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},qe=()=>[...er];0&&(module.exports={clApi,clApplication,clColor,clCommand,clConfig,clFilter,clHelp,clOutput,clSchema,clSymbol,clText,clToken,clUpdate,clUtil});
11
+ `)}formatCommand(t){return h&&console.log("---------- formatCommand"),super.formatCommand(t)}getCommandHelpClass(t){return h&&console.log("---------- getCommandHelpClass"),new ae(t,this.config,this.opts)}};var ce={};_(ce,{download:()=>er});var er=async e=>{let r=`https://data.${m.api.default_app_domain}/schemas/`,n=`openapi${e?"_"+e.replace(/\./g,"-"):""}.json`,i=r+n;return await(await fetch(i)).json()};var le={};_(le,{apply:()=>sr,available:()=>Ce,documentation:()=>rr,filters:()=>qe,list:()=>$e});var tr=[{predicate:"*_eq",description:"The attribute is equal to the filter value"},{predicate:"*_eq_or_null",description:"The attribute is equal to the filter value, including null values"},{predicate:"*_not_eq",description:"The attribute is not equal to the filter value"},{predicate:"*_not_eq_or_null",description:"The attribute is not equal to the filter value, including null values"},{predicate:"*_matches",description:'The attribute matches the filter value with "LIKE" operator'},{predicate:"*_does_not_match",description:'The attribute does not match the filter value with "LIKE" operator'},{predicate:"*_matches_any",description:'The attribute matches all of the filter values (comma-separated) with "LIKE" operator'},{predicate:"*_matches_all",description:'The attribute matches all of the filter values (comma-separated) with "LIKE" operator'},{predicate:"*_does_not_match_any",description:'The attribute does not match any of the filter values (comma-separated) with "LIKE" operator'},{predicate:"*_does_not_match_all",description:'The attribute matches none of the filter values (comma-separated) with "LIKE" operator'},{predicate:"*_lt",description:"The attribute is less than the filter value"},{predicate:"*_lteq",description:"The attribute is less than or equal to the filter value"},{predicate:"*_gt",description:"The attribute is greater than the filter value"},{predicate:"*_gteq",description:"The attribute is greater than or equal to the filter value"},{predicate:"*_present",description:"The attribute is not null and not empty"},{predicate:"*_blank",description:"The attribute is null or empty"},{predicate:"*_null",description:"The attribute is null"},{predicate:"*_not_null",description:"The attribute is not null"},{predicate:"*_in",description:"The attribute matches any of the filter values (comma-separated)"},{predicate:"*_in_or_null",description:"The attribute matches any of the filter values (comma-separated), including null values"},{predicate:"*_not_in",description:"The attribute matches none of the filter values (comma-separated)"},{predicate:"*_not_in_or_null",description:"The attribute matches none of the filter values (comma-separated), including null values"},{predicate:"*_lt_any",description:"The attribute is less than any of the filter values (comma-separated)"},{predicate:"*_lteq_any",description:"The attribute is less than or equal to any of the filter values (comma-separated)"},{predicate:"*_gt_any",description:"The attribute is greater than any of the filter values (comma-separated)"},{predicate:"*_gteq_any",description:"The attribute is greater than or qual to any of the filter values (comma-separated)"},{predicate:"*_lt_all",description:"The attribute is less than all of the filter values (comma-separated)"},{predicate:"*_lteq_all",description:"The attribute is less than or equal to all of the filter values (comma-separated)"},{predicate:"*_gt_all",description:"The attribute is greater than all of the filter values (comma-separated)"},{predicate:"*_gteq_all",description:"The attribute is greater or equal to all of the filter values (comma-separated)"},{predicate:"*_not_eq_all",description:"The attribute is equal to none of the filter values (comma-separated)"},{predicate:"*_start",description:"The attribute starts with the filter value (comma-separated)"},{predicate:"*_not_start",description:"The attribute does not start with the filter value (comma-separated)"},{predicate:"*_start_any",description:"The attribute starts with any of the filter values (comma-separated)"},{predicate:"*_start_all",description:"The attribute starts with all of the filter values (comma-separated)"},{predicate:"*_not_start_any",description:"The attribute does not start with any of the filter values (comma-separated)"},{predicate:"*_not_start_all",description:"The attribute starts with none of the filter values (comma-separated)"},{predicate:"*_end",description:"The attribute ends with the filter value"},{predicate:"*_not_end",description:"The attribute does not end with the filter value"},{predicate:"*_end_any",description:"The attribute ends with any of the filter values (comma-separated)"},{predicate:"*_end_all",description:"The attribute ends with all of the filter values (comma-separated)"},{predicate:"*_not_end_any",description:"The attribute does not end with any of the filter values (comma-separated)"},{predicate:"*_not_end_all",description:"The attribute ends with none of the filter values (comma-separated)"},{predicate:"*_cont",description:"The attribute contains the filter value"},{predicate:"*_not_cont",description:"The attribute does not contains the filter value"},{predicate:"*_cont_any",description:"The attribute contains any of the filter values (comma-separated)"},{predicate:"*_cont_all",description:"The attribute contains all of the filter values (comma-separated)"},{predicate:"*_not_cont_all",description:"The attribute contains none of the filter values (comma-separated)"},{predicate:"*_jcont",description:"The attribute contains a portion of the JSON used as filter value (works with object only)"},{predicate:"*_true",description:"The attribute is true"},{predicate:"*_false",description:"The attribute is false"}],rr=m.doc.core_filtering_data,$e=()=>qe().map(e=>e.predicate.replace(/^\*/g,"")),Ce=e=>{let t=e.startsWith("_")?e:`_${e}`;return $e().some(r=>t.endsWith(r))},sr=(e,...t)=>{if(!Ce(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},qe=()=>[...tr];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 xe=Object.defineProperty;var h=(e,t)=>{for(var r in t)xe(e,r,{get:t[r],enumerable:!0})};var Z={};h(Z,{Operation:()=>L,baseURL:()=>qe,execMode:()=>Ee,extractDomain:()=>Re,humanizeResource:()=>Se,isResourceCacheable:()=>Y,liveEnvironment:()=>Oe,request:()=>Ie,requestDataFile:()=>M,requestRateLimitDelay:()=>X,requestRaw:()=>D,response:()=>Ke,responseDenormalize:()=>P});var j=["in_progress","pending","completed","interrupted"],ve=["addresses","bundles","coupons","customer_addresses","customer_payment_sources","customer_subscriptions","customers","gift_cards","line_items","line_item_options","orders","price_tiers","prices","shipping_categories","sku_lists","sku_list_items","sku_options","skus","stock_items","stock_transfers","tags","tax_categories"],Te=["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"],we=["bundles","gift_cards","prices","promotions","sku_lists","sku_options","skus","stock_items"],ke=["addresses","bundles","customers","coupons","gift_cards","line_items","line_item_options","orders","returns","skus","sku_options","promotions","external_promotions","fixed_amount_promotions","fixed_price_promotions","free_gift_promotions","free_shipping_promotions","percentage_discount_promotions"],Ae=["orders","skus","sku_lists"],b={erl_oauth_limit_live:30,erl_average_limit_cachable_live:1e3,erl_average_limit_cachable_test:500,erl_burst_limit_cachable_live:250,erl_burst_limit_cachable_test:125,erl_average_limit_uncachable_live:200,erl_average_limit_uncachable_test:100,erl_burst_limit_uncachable_live:50,erl_burst_limit_uncachable_test:25},$e={api:{default_domain:"commercelayer.io",default_app_domain:"commercelayer.app",default_stg_domain:"commercelayer.co",token_expiration_mins:60*4,token_encoding_algorithm:"HS512",token_owner_types:["Customer","User"],requests_max_num_burst:b.erl_burst_limit_uncachable_live,requests_max_num_burst_cacheable:b.erl_burst_limit_cachable_live,requests_max_num_burst_test:b.erl_burst_limit_uncachable_test,requests_max_num_burst_test_cacheable:b.erl_burst_limit_cachable_test,requests_max_num_avg:b.erl_average_limit_uncachable_live,requests_max_num_avg_cacheable:b.erl_average_limit_cachable_live,requests_max_num_avg_test:b.erl_average_limit_uncachable_test,requests_max_num_avg_test_cacheable:b.erl_average_limit_cachable_test,requests_max_num_oauth:b.erl_oauth_limit_live,requests_max_secs_burst:10,requests_max_secs_oauth:60,requests_max_secs_avg:60,page_max_size:25,page_default_size:10},application:{kinds:["dashboard","user","metrics","contentful","bundles","customers","datocms","exports","external","gift_cards","imports","integration","inventory","orders","price_lists","promotions","resources","returns","sales_channel","sanity","shipments","skus","sku_lists","stock_transfers","subscriptions","tags","webapp","webhooks","zapier"],login_scopes:["market","stock_location","store"]},imports:{max_size:1e4,statuses:j,types:ve,max_queue_length:10,attachment_expiration:5},exports:{max_size:1e4,statuses:j,types:Te,max_queue_length:10,attachment_expiration:5},cleanups:{max_size:1e4,statuses:j,types:we,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:ke,tag_name_max_length:25,tag_name_pattern:/^[0-9A-Za-z_-]{1,25}$/},provisioning:{default_subdomain:"provisioning",scope:"provisioning-api",applications:["user"]},links:{default_domain:"c11r.link",linkable_resources:Ae}},m=$e;import{readFileSync as Ce}from"fs";var D=async(e,t,r)=>await(await fetch(new URL(`/api/${e.resource}`+(r?`/${r}`:""),e.baseUrl),{method:e.operation,headers:{"Content-Type":"application/vnd.api+json",Accept:"application/vnd.api+json",Authorization:`Bearer ${e.accessToken}`},body:JSON.stringify(t)}).then(n=>{if(n.ok)return n;throw new Error(n.statusText)})).json(),M=e=>{let t,r;try{t=Ce(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}},L=(r=>(r.Create="POST",r.Update="PATCH",r))(L||{});var J=(e,t)=>t.find(r=>e.id===r.id&&e.type===r.type),S=(e,t)=>{let r={id:e.id,type:e.type,...e.attributes};return e.relationships&&Object.keys(e.relationships).forEach(s=>{let n=e.relationships[s].data;n?Array.isArray(n)?r[s]=n.map(i=>S(J(i,t),t)):r[s]=S(J(n,t),t):n===null&&(r[s]=null)}),r},P=e=>{let t;e.links&&delete e.links;let r=e.data,s=e.included;return Array.isArray(r)?t=r.map(n=>S(n,s)):t=S(r,s),t};var qe=(e="core",t,r)=>`https://${(e==="core"&&t||e).toLowerCase()}.${r||m.api.default_domain}`,Re=e=>{if(e)return e.substring(e.indexOf(".")+1)},Ee=e=>e===!0||e==="live"?"live":"test",Se=e=>e.replace(/_/g," ");var ze=["bundles","imports","markets","prices","price_lists","promotions","buy_x_pay_y_promotions","external_promotions","fixed_amount_promotions","fixed_price_promotions","free_gift_promotions","free_shipping_promotions","percentage_discount_promotions","skus","sku_options","stock_items","stock_locations"],Y=(e,t)=>ze.includes(e||"")&&(t||"GET").toUpperCase()==="GET",Oe=e=>e==="live",X=e=>{let t=e?.environment||"test",r=e?.parallelRequests||1,s=Y(e?.resourceType,e?.method),n,i;t==="live"?(n=s?m.api.requests_max_num_burst_cacheable:m.api.requests_max_num_burst,i=s?m.api.requests_max_num_avg_cacheable:m.api.requests_max_num_avg):(n=s?m.api.requests_max_num_burst_test_cacheable:m.api.requests_max_num_burst_test,i=s?m.api.requests_max_num_avg_test_cacheable:m.api.requests_max_num_avg_test);let a=m.api.requests_max_secs_burst/n,p=m.api.requests_max_secs_avg/i,_=r*a,T=r*p,f=e?.totalRequests,c=0;return f&&f>0?f>n&&(f>i?c=T:c=_):c=Math.max(_,T),c=c*1e3,e?.minimumDelay&&(c=Math.max(e.minimumDelay,c)),e?.securityDelay&&(c+=e.securityDelay),c=Math.ceil(c),c};var Ie={raw:D,readDataFile:M,rateLimitDelay:X},Ke={denormalize:P};var ee={};h(ee,{appKey:()=>Be,appKeyMatch:()=>De,appKeyValid:()=>je,arrayScope:()=>Q,isProvisioningApp:()=>Me});var Be=()=>Date.now().toString(36),je=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},Q=e=>{if(!e)return[];if(Array.isArray(e))return e;let t=e.replace(/[ ,;]/g,"_").split("_");return Array.isArray(t)?t:[t]},Me=e=>Q(e.scope).includes(m.provisioning.scope)||e.api==="provisioning";var te={};h(te,{allFlags:()=>Pe,checkISODateTimeValue:()=>Fe,commandFlags:()=>Le,findLongStringFlag:()=>Ue,fixDashedFlagValue:()=>We,fixValueType:()=>Ve});var Le=(e,t)=>{let r={...e};if(t)for(let s of t)delete r[s];return r},Pe=e=>({...e.flags,...e.baseFlags});var Ve=e=>{let t=e;return t==="null"?t=null:Number(t)==t?t=Number(t):t=t==="true"?!0:t==="false"?!1:t,t},Ue=(e,t)=>{let r=t.startsWith("--")?t:`--${t}`,s,n=e.findIndex(a=>a.startsWith(r)),i=!1;if(n>-1){let a=e[n];if(a.includes("=")){let p=a.split("=");s=p.length===2?p[1]:"",i=!0}else s=e[n+1];return{value:s,index:n,single:i}}else return},We=(e,t,r,s)=>{let n="____",i=t.name||r,a=t.char;if(!i&&!a)return e;let p=i?i.startsWith("--")?i:`--${i}`:void 0,_=a?t.char.startsWith("-")?a:`-${a}`:void 0,T=e.findIndex(k=>_&&k.startsWith(_)||p&&k.startsWith(p));if(T<0)return e;let f=e[T],c="",G="";if(_&&f.startsWith(_))c=f.replace(_,"").trim(),f=_;else if(p&&f.startsWith(p))c=f.replace(p,"").trim(),f=p;else return e;if(c.startsWith("=")?(c=c.slice(1),G=f+"="):c||(c=e[++T]),c.startsWith("-")||c.startsWith(n)){let k=c.startsWith(`${n}`)?c.replace(`${n}`,""):c.replace("-",`${n}-`);if(e[T]=G+k,c.startsWith(n)&&s){let E=i?i.replace("--",""):void 0,I=Object.entries(s.flags).find(([B,be])=>be===c);I&&(!E||E===I[0])&&(s.flags[I[0]]=k);let K=Object.values(s.raw).find(B=>B.type==="flag"&&B.input===c);K&&(!E||E===K.flag)&&(K.input=k)}}return e},Fe=e=>{if(!e)throw Error("Date is empty");try{let t=Date.parse(e);if(Number.isNaN(t))throw new Error("Invalid date");return new Date(t)}catch{throw new Error("Error parsing date: "+e)}};var oe={};h(oe,{center:()=>He,cleanDate:()=>Je,formatError:()=>Xe,formatOutput:()=>ie,localeDate:()=>Ye,maxLength:()=>Ge,printCSV:()=>ne,printJSON:()=>se,printObject:()=>re});import{inspect as Ne}from"node:util";var re=(e,t)=>Ne(e,{showHidden:!1,depth:null,colors:t?.color===void 0?!0:t.color,sorted:t?.sort===void 0?!1:t?.sort,maxArrayLength:1/0,breakLength:t?.width||120}),se=(e,t)=>JSON.stringify(e,null,t?.unformatted?void 0:t?.tabSize||4),ne=(e,t)=>{if(!e||e.length===0)return"";let r=Object.keys(e[0]).filter(n=>["id","type"].includes(n)?t?.fields.includes(n):!0),s=r.map(n=>n.toUpperCase().replace(/_/g," ")).join(";")+`
1
+ var xe=Object.defineProperty;var h=(e,t)=>{for(var r in t)xe(e,r,{get:t[r],enumerable:!0})};var Z={};h(Z,{Operation:()=>L,baseURL:()=>qe,execMode:()=>Ee,extractDomain:()=>Re,humanizeResource:()=>Se,isResourceCacheable:()=>Y,liveEnvironment:()=>Oe,request:()=>Ie,requestDataFile:()=>M,requestRateLimitDelay:()=>X,requestRaw:()=>D,response:()=>Ke,responseDenormalize:()=>P});var B=["in_progress","pending","completed","interrupted"],ve=["addresses","bundles","coupons","customer_addresses","customer_payment_sources","customer_subscriptions","customers","gift_cards","line_items","line_item_options","orders","price_tiers","prices","shipping_categories","sku_lists","sku_list_items","sku_options","skus","stock_items","stock_transfers","tags","tax_categories"],Te=["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"],we=["bundles","gift_cards","prices","promotions","sku_lists","sku_options","skus","stock_items"],ke=["addresses","bundles","customers","coupons","gift_cards","line_items","line_item_options","orders","returns","skus","sku_options","promotions","external_promotions","fixed_amount_promotions","fixed_price_promotions","free_gift_promotions","free_shipping_promotions","percentage_discount_promotions"],Ae=["orders","skus","sku_lists"],b={erl_oauth_limit_live:30,erl_average_limit_cachable_live:1e3,erl_average_limit_cachable_test:500,erl_burst_limit_cachable_live:250,erl_burst_limit_cachable_test:125,erl_average_limit_uncachable_live:200,erl_average_limit_uncachable_test:100,erl_burst_limit_uncachable_live:50,erl_burst_limit_uncachable_test:25},$e={api:{default_domain:"commercelayer.io",default_app_domain:"commercelayer.app",default_stg_domain:"commercelayer.co",token_expiration_mins:60*4,token_encoding_algorithm:"HS512",token_owner_types:["Customer","User"],requests_max_num_burst:b.erl_burst_limit_uncachable_live,requests_max_num_burst_cacheable:b.erl_burst_limit_cachable_live,requests_max_num_burst_test:b.erl_burst_limit_uncachable_test,requests_max_num_burst_test_cacheable:b.erl_burst_limit_cachable_test,requests_max_num_avg:b.erl_average_limit_uncachable_live,requests_max_num_avg_cacheable:b.erl_average_limit_cachable_live,requests_max_num_avg_test:b.erl_average_limit_uncachable_test,requests_max_num_avg_test_cacheable:b.erl_average_limit_cachable_test,requests_max_num_oauth:b.erl_oauth_limit_live,requests_max_secs_burst:10,requests_max_secs_oauth:60,requests_max_secs_avg:60,page_max_size:25,page_default_size:10},application:{kinds:["dashboard","user","metrics","contentful","bundles","customers","datocms","exports","external","gift_cards","imports","integration","inventory","orders","price_lists","promotions","resources","returns","sales_channel","sanity","shipments","skus","sku_lists","stock_transfers","subscriptions","tags","webapp","webhooks","zapier"],login_scopes:["market","stock_location","store"]},imports:{max_size:1e4,statuses:B,types:ve,max_queue_length:10,attachment_expiration:5},exports:{max_size:1e4,statuses:B,types:Te,max_queue_length:10,attachment_expiration:5},cleanups:{max_size:1e4,statuses:B,types:we,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:ke,tag_name_max_length:25,tag_name_pattern:/^[0-9A-Za-z_-]{1,25}$/},provisioning:{default_subdomain:"provisioning",scope:"provisioning-api",applications:["user"]},links:{default_domain:"c11r.link",linkable_resources:Ae}},m=$e;import{readFileSync as Ce}from"fs";var D=async(e,t,r)=>await(await fetch(new URL(`/api/${e.resource}`+(r?`/${r}`:""),e.baseUrl),{method:e.operation,headers:{"Content-Type":"application/vnd.api+json",Accept:"application/vnd.api+json",Authorization:`Bearer ${e.accessToken}`},body:JSON.stringify(t)}).then(n=>{if(n.ok)return n;throw new Error(n.statusText)})).json(),M=e=>{let t,r;try{t=Ce(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}},L=(r=>(r.Create="POST",r.Update="PATCH",r))(L||{});var J=(e,t)=>t.find(r=>e.id===r.id&&e.type===r.type),S=(e,t)=>{let r={id:e.id,type:e.type,...e.attributes};return e.relationships&&Object.keys(e.relationships).forEach(s=>{let n=e.relationships[s].data;n?Array.isArray(n)?r[s]=n.map(i=>S(J(i,t),t)):r[s]=S(J(n,t),t):n===null&&(r[s]=null)}),r},P=e=>{let t;e.links&&delete e.links;let r=e.data,s=e.included;return Array.isArray(r)?t=r.map(n=>S(n,s)):t=S(r,s),t};var qe=(e="core",t,r)=>`https://${(e==="core"&&t||e).toLowerCase()}.${r||m.api.default_domain}`,Re=e=>{if(e)return e.substring(e.indexOf(".")+1)},Ee=e=>e===!0||e==="live"?"live":"test",Se=e=>e.replace(/_/g," ");var ze=["bundles","imports","markets","prices","price_lists","promotions","buy_x_pay_y_promotions","external_promotions","fixed_amount_promotions","fixed_price_promotions","free_gift_promotions","free_shipping_promotions","percentage_discount_promotions","skus","sku_options","stock_items","stock_locations"],Y=(e,t)=>ze.includes(e||"")&&(t||"GET").toUpperCase()==="GET",Oe=e=>e==="live",X=e=>{let t=e?.environment||"test",r=e?.parallelRequests||1,s=Y(e?.resourceType,e?.method),n,i;t==="live"?(n=s?m.api.requests_max_num_burst_cacheable:m.api.requests_max_num_burst,i=s?m.api.requests_max_num_avg_cacheable:m.api.requests_max_num_avg):(n=s?m.api.requests_max_num_burst_test_cacheable:m.api.requests_max_num_burst_test,i=s?m.api.requests_max_num_avg_test_cacheable:m.api.requests_max_num_avg_test);let a=m.api.requests_max_secs_burst/n,p=m.api.requests_max_secs_avg/i,_=r*a,T=r*p,f=e?.totalRequests,c=0;return f&&f>0?f>n&&(f>i?c=T:c=_):c=Math.max(_,T),c=c*1e3,e?.minimumDelay&&(c=Math.max(e.minimumDelay,c)),e?.securityDelay&&(c+=e.securityDelay),c=Math.ceil(c),c};var Ie={raw:D,readDataFile:M,rateLimitDelay:X},Ke={denormalize:P};var ee={};h(ee,{appKey:()=>je,appKeyMatch:()=>De,appKeyValid:()=>Be,arrayScope:()=>Q,isProvisioningApp:()=>Me});var je=()=>Date.now().toString(36),Be=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},Q=e=>{if(!e)return[];if(Array.isArray(e))return e;let t=e.replace(/[ ,;]/g,"_").split("_");return Array.isArray(t)?t:[t]},Me=e=>Q(e.scope).includes(m.provisioning.scope)||e.api==="provisioning";var te={};h(te,{allFlags:()=>Ve,checkISODateTimeValue:()=>Ne,commandFlags:()=>Le,filterFlags:()=>Pe,findLongStringFlag:()=>Fe,fixDashedFlagValue:()=>We,fixValueType:()=>Ue});var Le=(e,t)=>{let r={...e};if(t)for(let s of t)delete r[s];return r},Pe=(e,t,r)=>{let s={};return Object.entries(e).forEach(([n,i])=>{(!t||t.includes(n))&&!r?.includes(n)&&(s[n]=i)}),s},Ve=e=>({...e.flags,...e.baseFlags}),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},Fe=(e,t)=>{let r=t.startsWith("--")?t:`--${t}`,s,n=e.findIndex(a=>a.startsWith(r)),i=!1;if(n>-1){let a=e[n];if(a.includes("=")){let p=a.split("=");s=p.length===2?p[1]:"",i=!0}else s=e[n+1];return{value:s,index:n,single:i}}else return},We=(e,t,r,s)=>{let n="____",i=t.name||r,a=t.char;if(!i&&!a)return e;let p=i?i.startsWith("--")?i:`--${i}`:void 0,_=a?t.char.startsWith("-")?a:`-${a}`:void 0,T=e.findIndex(k=>_&&k.startsWith(_)||p&&k.startsWith(p));if(T<0)return e;let f=e[T],c="",G="";if(_&&f.startsWith(_))c=f.replace(_,"").trim(),f=_;else if(p&&f.startsWith(p))c=f.replace(p,"").trim(),f=p;else return e;if(c.startsWith("=")?(c=c.slice(1),G=f+"="):c||(c=e[++T]),c.startsWith("-")||c.startsWith(n)){let k=c.startsWith(`${n}`)?c.replace(`${n}`,""):c.replace("-",`${n}-`);if(e[T]=G+k,c.startsWith(n)&&s){let E=i?i.replace("--",""):void 0,I=Object.entries(s.flags).find(([j,be])=>be===c);I&&(!E||E===I[0])&&(s.flags[I[0]]=k);let K=Object.values(s.raw).find(j=>j.type==="flag"&&j.input===c);K&&(!E||E===K.flag)&&(K.input=k)}}return e},Ne=e=>{if(!e)throw Error("Date is empty");try{let t=Date.parse(e);if(Number.isNaN(t))throw new Error("Invalid date");return new Date(t)}catch{throw new Error("Error parsing date: "+e)}};var oe={};h(oe,{center:()=>Ge,cleanDate:()=>Ye,formatError:()=>Ze,formatOutput:()=>ie,localeDate:()=>Xe,maxLength:()=>Je,printCSV:()=>ne,printJSON:()=>se,printObject:()=>re});import{inspect as He}from"node:util";var re=(e,t)=>He(e,{showHidden:!1,depth:null,colors:t?.color===void 0?!0:t.color,sorted:t?.sort===void 0?!1:t?.sort,maxArrayLength:1/0,breakLength:t?.width||120}),se=(e,t)=>JSON.stringify(e,null,t?.unformatted?void 0:t?.tabSize||4),ne=(e,t)=>{if(!e||e.length===0)return"";let r=Object.keys(e[0]).filter(n=>["id","type"].includes(n)?t?.fields.includes(n):!0),s=r.map(n=>n.toUpperCase().replace(/_/g," ")).join(";")+`
2
2
  `;return e.forEach(n=>{s+=r.map(i=>n[i]).join(";")+`
3
- `}),s},He=(e,t)=>e.padStart(e.length+Math.floor((t-e.length)/2)," ").padEnd(t," "),Ge=(e,t)=>e.reduce((r,s)=>{let n=Array.isArray(s[t])?s[t].join():s[t];return Math.max(r,String(n).length)},0),Je=e=>e?e.replace("T"," ").replace("Z","").substring(0,e.lastIndexOf(".")):"",Ye=e=>e?new Date(Date.parse(e)).toLocaleString():"",ie=(e,t,{color:r=!0}={})=>{if(!e)return"";if(typeof e=="string")return e;if(t){if(t.csv)return ne(e,t);if(t.json)return se(e,{unformatted:t.unformatted})}return re(e,{color:r})},Xe=(e,t)=>ie(e.errors||e,t);var A={};h(A,{api:()=>ht,bg:()=>_t,black:()=>at,blackBright:()=>ct,blue:()=>nt,blueBright:()=>C,bold:()=>U,cli:()=>bt,cyan:()=>pt,cyanBright:()=>$,dim:()=>dt,green:()=>rt,greenBright:()=>V,grey:()=>lt,hidden:()=>et,italic:()=>w,magenta:()=>ut,magentaBright:()=>mt,msg:()=>yt,red:()=>tt,redBright:()=>ae,reset:()=>Ze,style:()=>l,table:()=>xt,type:()=>ft,underline:()=>gt,visible:()=>Qe,white:()=>it,whiteBright:()=>ot,yellow:()=>st,yellowBright:()=>v});import o from"chalk";var Ze=o.reset,Qe=o.visible,et=o.hidden,tt=o.red,ae=o.redBright,rt=o.green,V=o.greenBright,st=o.yellow,v=o.yellowBright,nt=o.blue,C=o.blueBright,it=o.white,ot=o.whiteBright,at=o.black,ct=o.blackBright,lt=o.grey,pt=o.cyan,$=o.cyanBright,ut=o.magenta,mt=o.magentaBright,U=o.bold,dt=o.dim,gt=o.underline,w=o.italic,_t={white:o.bgWhite,whiteBright:o.bgWhiteBright,black:o.bgBlack,blackBright:o.bgBlackBright,grey:o.bgGrey,red:o.bgRed,redBright:o.bgRedBright,green:o.bgGreen,greenBright:o.bgGreenBright,yellow:o.bgYellow,yellowBright:o.bgYellowBright,blue:o.bgBlue,blueBright:o.bgBlueBright,magenta:o.bgMagenta,magentaBright:o.bgMagentaBright,cyan:o.bgCyan,cyanBright:o.bgCyanBright},l={organization:v.bold,application:v.bold,slug:v,id:U,token:C,resource:U,attribute:w,trigger:$,kind:$,live:V,test:v,execMode:e=>e==="live"?l.live:l.test,success:V,warning:v,error:ae,arg:w,flag:w,command:w,value:w,alias:$,plugin:C,title:C,path:w,datetime:$,number:v},ft={datetime:l.datetime,number:l.number,path:l.path},ht={organization:l.organization,application:l.application,slug:l.slug,id:l.id,token:l.token,resource:l.resource,attribute:l.attribute,trigger:l.trigger,kind:l.kind,live:l.live,test:l.test},yt={success:l.success,warning:l.warning,error:l.error},bt={arg:l.arg,flag:l.flag,command:l.command,value:l.value,alias:l.alias,plugin:l.plugin},xt={header:v.bold,key:C};var pe={};h(pe,{buildAssertionPayload:()=>Lt,decodeAccessToken:()=>le,generateAccessToken:()=>Kt,getAccessToken:()=>Bt,getTokenEnvironment:()=>Mt,isAccessTokenExpiring:()=>Dt,revokeAccessToken:()=>jt});import N from"jsonwebtoken";import{authenticate as F,revoke as It}from"@commercelayer/js-auth";var ce={};h(ce,{dotNotationToObject:()=>W,generateGroupUID:()=>zt,log:()=>Et,resetConsole:()=>Rt,sleep:()=>qt,specialFolder:()=>St,userAgent:()=>Ot});import{format as vt,inspect as Tt}from"util";import{sep as wt,dirname as kt}from"path";import{homedir as At}from"os";import{existsSync as $t,mkdirSync as Ct}from"fs";var qt=async e=>new Promise(t=>setTimeout(t,e)),Rt=()=>{process.stdout.write("\x1B[?25h\x1B[?7h")},Et=(e="",...t)=>{e=typeof e=="string"?e:Tt(e),process.stdout.write(vt(e,...t)+`
4
- `)},St=(e,t=!1)=>{let r=["desktop","home"],s=e.toLowerCase().split(/[\\\/]/g)[0];if(r.includes(s)){let i=At();s==="desktop"&&(i+=`${wt}Desktop`),e=e.replace(s,i)}let n=kt(e);return t&&!$t(n)&&Ct(n,{recursive:!0}),e},zt=()=>{let e=Math.trunc(Math.random()*46656),t=Math.trunc(Math.random()*46656),r=("000"+e.toString(36)).slice(-3),s=("000"+t.toString(36)).slice(-3);return r+s},Ot=e=>`${e.name.replace(/@commercelayer\/cli-plugin/,"CLI")}/${e.version}`,W=(e,t)=>{let r=t||{};return Object.entries(e).forEach(([s,n])=>{let i=s.split("."),a=i[i.length-1],p=r;i.forEach(_=>{_===a?p[_]=n:p=p[_]||(p[_]={})})}),t&&Object.assign(t,r),r};var le=e=>{let t=N.decode(e);if(t===null)throw new Error("Error decoding access token");return t},Kt=(e,t,r)=>{let n={...e,exp:Math.floor(Date.now()/1e3)+r*60,rand:Math.random()},i=m.api.token_encoding_algorithm,a=N.sign(n,t,{algorithm:i,noTimestamp:!0}),p=N.verify(a,t,{algorithms:[i]});return{accessToken:a,info:p,expMinutes:r}},Bt=async e=>{let t,r=e.scope?Array.isArray(e.scope)?e.scope.map(n=>n.trim()).join(","):e.scope:"",s={clientId:e.clientId,clientSecret:e.clientSecret,slug:e.slug,domain:e.domain,scope:r};if(e.email&&e.password?(s.username=e.email,s.password=e.password,t=await F("password",s)):e.assertion?(s.assertion=e.assertion,t=await F("urn:ietf:params:oauth:grant-type:jwt-bearer",s)):t=await F("client_credentials",s),t){if(t.errors)throw new Error(`Unable to get access token: ${t.errors[0].detail}`)}else throw new Error("Unable to get access token");return t},jt=async(e,t)=>{let r=await It({...e,token:t});if(r.errors)throw new Error(r.errors[0].detail)},Dt=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"?le(e):e).test?"test":"live";var Lt=(e,t,r)=>{let s="https://commercelayer.io/claims",n={[s]:{owner:{type:e,id:t}}};if(r&&Object.keys(r).length>0){let i=W(r);n[s].custom_claim=i}return n};var ue={};h(ue,{checkUpdate:()=>Ut});import z from"chalk";import Pt from"update-notifier-cjs";var Vt=1,Ut=e=>{let t=Pt({pkg:e,updateCheckInterval:36e5*Vt});t.update&&t.notify({isGlobal:!1,message:`-= ${z.bgWhite.black.bold(` ${e.description} `)} =-
3
+ `}),s},Ge=(e,t)=>e.padStart(e.length+Math.floor((t-e.length)/2)," ").padEnd(t," "),Je=(e,t)=>e.reduce((r,s)=>{let n=Array.isArray(s[t])?s[t].join():s[t];return Math.max(r,String(n).length)},0),Ye=e=>e?e.replace("T"," ").replace("Z","").substring(0,e.lastIndexOf(".")):"",Xe=e=>e?new Date(Date.parse(e)).toLocaleString():"",ie=(e,t,{color:r=!0}={})=>{if(!e)return"";if(typeof e=="string")return e;if(t){if(t.csv)return ne(e,t);if(t.json)return se(e,{unformatted:t.unformatted})}return re(e,{color:r})},Ze=(e,t)=>ie(e.errors||e,t);var A={};h(A,{api:()=>yt,bg:()=>ft,black:()=>ct,blackBright:()=>lt,blue:()=>it,blueBright:()=>C,bold:()=>U,cli:()=>xt,cyan:()=>ut,cyanBright:()=>$,dim:()=>gt,green:()=>st,greenBright:()=>V,grey:()=>pt,hidden:()=>tt,italic:()=>w,magenta:()=>mt,magentaBright:()=>dt,msg:()=>bt,red:()=>rt,redBright:()=>ae,reset:()=>Qe,style:()=>l,table:()=>vt,type:()=>ht,underline:()=>_t,visible:()=>et,white:()=>ot,whiteBright:()=>at,yellow:()=>nt,yellowBright:()=>v});import o from"chalk";var Qe=o.reset,et=o.visible,tt=o.hidden,rt=o.red,ae=o.redBright,st=o.green,V=o.greenBright,nt=o.yellow,v=o.yellowBright,it=o.blue,C=o.blueBright,ot=o.white,at=o.whiteBright,ct=o.black,lt=o.blackBright,pt=o.grey,ut=o.cyan,$=o.cyanBright,mt=o.magenta,dt=o.magentaBright,U=o.bold,gt=o.dim,_t=o.underline,w=o.italic,ft={white:o.bgWhite,whiteBright:o.bgWhiteBright,black:o.bgBlack,blackBright:o.bgBlackBright,grey:o.bgGrey,red:o.bgRed,redBright:o.bgRedBright,green:o.bgGreen,greenBright:o.bgGreenBright,yellow:o.bgYellow,yellowBright:o.bgYellowBright,blue:o.bgBlue,blueBright:o.bgBlueBright,magenta:o.bgMagenta,magentaBright:o.bgMagentaBright,cyan:o.bgCyan,cyanBright:o.bgCyanBright},l={organization:v.bold,application:v.bold,slug:v,id:U,token:C,resource:U,attribute:w,trigger:$,kind:$,live:V,test:v,execMode:e=>e==="live"?l.live:l.test,success:V,warning:v,error:ae,arg:w,flag:w,command:w,value:w,alias:$,plugin:C,title:C,path:w,datetime:$,number:v},ht={datetime:l.datetime,number:l.number,path:l.path},yt={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},bt={success:l.success,warning:l.warning,error:l.error},xt={arg:l.arg,flag:l.flag,command:l.command,value:l.value,alias:l.alias,plugin:l.plugin},vt={header:v.bold,key:C};var pe={};h(pe,{buildAssertionPayload:()=>Pt,decodeAccessToken:()=>le,generateAccessToken:()=>jt,getAccessToken:()=>Bt,getTokenEnvironment:()=>Lt,isAccessTokenExpiring:()=>Mt,revokeAccessToken:()=>Dt});import N from"jsonwebtoken";import{authenticate as W,revoke as Kt}from"@commercelayer/js-auth";var ce={};h(ce,{dotNotationToObject:()=>F,generateGroupUID:()=>Ot,log:()=>St,resetConsole:()=>Et,sleep:()=>Rt,specialFolder:()=>zt,userAgent:()=>It});import{format as Tt,inspect as wt}from"util";import{sep as kt,dirname as At}from"path";import{homedir as $t}from"os";import{existsSync as Ct,mkdirSync as qt}from"fs";var Rt=async e=>new Promise(t=>setTimeout(t,e)),Et=()=>{process.stdout.write("\x1B[?25h\x1B[?7h")},St=(e="",...t)=>{e=typeof e=="string"?e:wt(e),process.stdout.write(Tt(e,...t)+`
4
+ `)},zt=(e,t=!1)=>{let r=["desktop","home"],s=e.toLowerCase().split(/[\\\/]/g)[0];if(r.includes(s)){let i=$t();s==="desktop"&&(i+=`${kt}Desktop`),e=e.replace(s,i)}let n=At(e);return t&&!Ct(n)&&qt(n,{recursive:!0}),e},Ot=()=>{let e=Math.trunc(Math.random()*46656),t=Math.trunc(Math.random()*46656),r=("000"+e.toString(36)).slice(-3),s=("000"+t.toString(36)).slice(-3);return r+s},It=e=>`${e.name.replace(/@commercelayer\/cli-plugin/,"CLI")}/${e.version}`,F=(e,t)=>{let r=t||{};return Object.entries(e).forEach(([s,n])=>{let i=s.split("."),a=i[i.length-1],p=r;i.forEach(_=>{_===a?p[_]=n:p=p[_]||(p[_]={})})}),t&&Object.assign(t,r),r};var le=e=>{let t=N.decode(e);if(t===null)throw new Error("Error decoding access token");return t},jt=(e,t,r)=>{let n={...e,exp:Math.floor(Date.now()/1e3)+r*60,rand:Math.random()},i=m.api.token_encoding_algorithm,a=N.sign(n,t,{algorithm:i,noTimestamp:!0}),p=N.verify(a,t,{algorithms:[i]});return{accessToken:a,info:p,expMinutes:r}},Bt=async e=>{let t,r=e.scope?Array.isArray(e.scope)?e.scope.map(n=>n.trim()).join(","):e.scope:"",s={clientId:e.clientId,clientSecret:e.clientSecret,slug:e.slug,domain:e.domain,scope:r};if(e.email&&e.password?(s.username=e.email,s.password=e.password,t=await W("password",s)):e.assertion?(s.assertion=e.assertion,t=await W("urn:ietf:params:oauth:grant-type:jwt-bearer",s)):t=await W("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 Kt({...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"?le(e):e).test?"test":"live";var Pt=(e,t,r)=>{let s="https://commercelayer.io/claims",n={[s]:{owner:{type:e,id:t}}};if(r&&Object.keys(r).length>0){let i=F(r);n[s].custom_claim=i}return n};var ue={};h(ue,{checkUpdate:()=>Ft});import z from"chalk";import Vt from"update-notifier-cjs";var Ut=1,Ft=e=>{let t=Vt({pkg:e,updateCheckInterval:36e5*Ut});t.update&&t.notify({isGlobal:!1,message:`-= ${z.bgWhite.black.bold(` ${e.description} `)} =-
5
5
 
6
6
  New version available: ${z.dim("{currentVersion}")} -> ${z.green("{latestVersion}")}
7
- Run ${z.cyanBright("commercelayer plugins:update")} to update`})};import{CommandHelp as Jt,Help as Yt}from"@oclif/core";var de={};h(de,{camelize:()=>Gt,capitalize:()=>R,dasherize:()=>Wt,pluralize:()=>Nt,singularize:()=>Ht,symbols:()=>x,underscorize:()=>Ft});var u={uncountableWords:["equipment","information","rice","money","species","series","fish","sheep","moose","deer","news"],pluralRules:[[/(m)an$/gi,"$1en"],[/(pe)rson$/gi,"$1ople"],[/(child)$/gi,"$1ren"],[/^(ox)$/gi,"$1en"],[/(ax|test)is$/gi,"$1es"],[/(octop|vir)us$/gi,"$1i"],[/(alias|status)$/gi,"$1es"],[/(bu)s$/gi,"$1ses"],[/(buffal|tomat|potat)o$/gi,"$1oes"],[/([ti])um$/gi,"$1a"],[/sis$/gi,"ses"],[/(?:([^f])fe|([lr])f)$/gi,"$1$2ves"],[/(hive)$/gi,"$1s"],[/([^aeiouy]|qu)y$/gi,"$1ies"],[/(x|ch|ss|sh)$/gi,"$1es"],[/(matr|vert|ind)ix|ex$/gi,"$1ices"],[/([m|l])ouse$/gi,"$1ice"],[/(quiz)$/gi,"$1zes"],[/s$/gi,"s"],[/$/gi,"s"]],singularRules:[[/(m)en$/gi,"$1an"],[/(pe)ople$/gi,"$1rson"],[/(child)ren$/gi,"$1"],[/([ti])a$/gi,"$1um"],[/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/gi,"$1$2sis"],[/(hive)s$/gi,"$1"],[/(tive)s$/gi,"$1"],[/(curve)s$/gi,"$1"],[/([lr])ves$/gi,"$1f"],[/([^fo])ves$/gi,"$1fe"],[/([^aeiouy]|qu)ies$/gi,"$1y"],[/(s)eries$/gi,"$1eries"],[/(m)ovies$/gi,"$1ovie"],[/(x|ch|ss|sh)es$/gi,"$1"],[/([m|l])ice$/gi,"$1ouse"],[/(bus)es$/gi,"$1"],[/(o)es$/gi,"$1"],[/(shoe)s$/gi,"$1"],[/(cris|ax|test)es$/gi,"$1is"],[/(octop|vir)i$/gi,"$1us"],[/(alias|status)es$/gi,"$1"],[/^(ox)en/gi,"$1"],[/(vert|ind)ices$/gi,"$1ex"],[/(matr)ices$/gi,"$1ix"],[/(quiz)zes$/gi,"$1"],[/s$/gi,""]],nonTitlecasedWords:["and","or","nor","a","an","the","so","but","to","of","at","by","from","into","on","onto","off","out","in","over","with","for"],idSuffix:/(_ids|_id)$/g,underbar:/_/g,spaceOrUnderbar:/[ _]/g,uppercase:/([A-Z])/g,underbarPrefix:/^_/,applyRules:function(e,t,r,s){if(s)e=s;else if(!r.includes(e.toLowerCase())){for(let i=0;i<t.length;i++)if(e.match(t[i][0])){e=e.replace(t[i][0],t[i][1]);break}}return e},pluralize:function(e,t){return u.applyRules(e,u.pluralRules,u.uncountableWords,t)},singularize:function(e,t){return u.applyRules(e,u.singularRules,u.uncountableWords,t)},camelize:function(e,t){let r=e.split("/");for(let s=0;s<r.length;s++){let n=r[s].split("_"),i=t&&s+1===r.length?1:0;for(let a=i;a<n.length;a++)n[a]=n[a].charAt(0).toUpperCase()+n[a].substring(1);r[s]=n.join("")}if(e=r.join("::"),t){let s=e.charAt(0).toLowerCase(),n=e.slice(1);e=s+n}return e},underscore:function(e){let t=e.split("::");for(let r=0;r<t.length;r++)t[r]=t[r].replace(u.uppercase,"_$1"),t[r]=t[r].replace(u.underbarPrefix,"");return e=t.join("/").toLowerCase(),e},humanize:function(e,t){return e=e.toLowerCase(),e=e.replace(u.idSuffix,""),e=e.replace(u.underbar," "),t||(e=u.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(u.spaceOrUnderbar,"-"),e},camel2words:function(e,t){t?(e=u.camelize(e),e=u.underscore(e)):e=e.toLowerCase(),e=e.replace(u.underbar," ");let r=e.split(" ");for(let s=0;s<r.length;s++){let n=r[s].split("-");for(let i=0;i<n.length;i++)u.nonTitlecasedWords.includes(n[i].toLowerCase())||(n[i]=u.capitalize(n[i]));r[s]=n.join("-")}return e=r.join(" "),e=e.substring(0,1).toUpperCase()+e.substring(1),e},demodulize:function(e){let t=e.split("::");return e=t[t.length-1],e},tableize:function(e){return e=u.pluralize(u.underscore(e)),e},classify:function(e){return e=u.singularize(u.camelize(e)),e},foreignKey:function(e,t){return e=u.underscore(u.demodulize(e))+(t?"":"_")+"id",e},ordinalize:function(e){let t=e.split(" ");for(let r=0;r<t.length;r++){let s=parseInt(t[r]);if(Number.isNaN(s)){let n=t[r].substring(t[r].length-2),i=t[r].substring(t[r].length-1),a="th";n!=="11"&&n!=="12"&&n!=="13"&&(i==="1"?a="st":i==="2"?a="nd":i==="3"&&(a="rd")),t[r]+=a}}return e=t.join(" "),e}},q=u;var me={};h(me,{symbols:()=>x});var x={check:{small:"\u2714",bkgGreen:"\u2705",squareRoot:"\u221A"},cross:{small:"\u2718",red:"\u274C"},clock:{stopwatch:"\u23F1"},arrow:{down:"\u2193"},selection:{fisheye:"\u25C9"}};x.check.heavy=x.check.small;x.check.whiteHeavy=x.check.bkgGreen;x.cross.heavyBallot=x.cross.small;var R=e=>e&&q.capitalize(e),Wt=e=>e&&(e=e.toLocaleLowerCase(),e.replace(/[ _]/g,"-")),Ft=e=>e&&(e=e.toLocaleLowerCase(),e.replace(/[ -]/g,"_")),Nt=(e,t)=>q.pluralize(e,t),Ht=(e,t)=>q.singularize(e,t),Gt=(e,t)=>q.camelize(e,t);var y=!1,H=class extends Jt{examples(t){return y&&console.log("---------- command.examples"),super.examples(t)}},O=class extends Yt{async showHelp(t){return y&&console.log("---------- showHelp"),super.showHelp(t)}async showRootHelp(){return y&&console.log("---------- showRootHelp"),super.showRootHelp()}async showTopicHelp(t){return y&&console.log("---------- showTopicHelp"),super.showTopicHelp(t)}async showCommandHelp(t){y&&console.log("---------- showCommandHelp");let r=t.id,s=r?r.split(":").length:1,n=this.sortedTopics.filter(p=>p.name.startsWith(r+":")&&p.name.split(":").length===s+1),i=this.sortedCommands.filter(p=>p.id.startsWith(r+":")&&p.id.split(":").length===s+1),a=t.description&&this.render(t.description).split(`
7
+ Run ${z.cyanBright("commercelayer plugins:update")} to update`})};import{CommandHelp as Yt,Help as Xt}from"@oclif/core";var de={};h(de,{camelize:()=>Jt,capitalize:()=>R,dasherize:()=>Wt,pluralize:()=>Ht,singularize:()=>Gt,symbols:()=>x,underscorize:()=>Nt});var u={uncountableWords:["equipment","information","rice","money","species","series","fish","sheep","moose","deer","news"],pluralRules:[[/(m)an$/gi,"$1en"],[/(pe)rson$/gi,"$1ople"],[/(child)$/gi,"$1ren"],[/^(ox)$/gi,"$1en"],[/(ax|test)is$/gi,"$1es"],[/(octop|vir)us$/gi,"$1i"],[/(alias|status)$/gi,"$1es"],[/(bu)s$/gi,"$1ses"],[/(buffal|tomat|potat)o$/gi,"$1oes"],[/([ti])um$/gi,"$1a"],[/sis$/gi,"ses"],[/(?:([^f])fe|([lr])f)$/gi,"$1$2ves"],[/(hive)$/gi,"$1s"],[/([^aeiouy]|qu)y$/gi,"$1ies"],[/(x|ch|ss|sh)$/gi,"$1es"],[/(matr|vert|ind)ix|ex$/gi,"$1ices"],[/([m|l])ouse$/gi,"$1ice"],[/(quiz)$/gi,"$1zes"],[/s$/gi,"s"],[/$/gi,"s"]],singularRules:[[/(m)en$/gi,"$1an"],[/(pe)ople$/gi,"$1rson"],[/(child)ren$/gi,"$1"],[/([ti])a$/gi,"$1um"],[/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/gi,"$1$2sis"],[/(hive)s$/gi,"$1"],[/(tive)s$/gi,"$1"],[/(curve)s$/gi,"$1"],[/([lr])ves$/gi,"$1f"],[/([^fo])ves$/gi,"$1fe"],[/([^aeiouy]|qu)ies$/gi,"$1y"],[/(s)eries$/gi,"$1eries"],[/(m)ovies$/gi,"$1ovie"],[/(x|ch|ss|sh)es$/gi,"$1"],[/([m|l])ice$/gi,"$1ouse"],[/(bus)es$/gi,"$1"],[/(o)es$/gi,"$1"],[/(shoe)s$/gi,"$1"],[/(cris|ax|test)es$/gi,"$1is"],[/(octop|vir)i$/gi,"$1us"],[/(alias|status)es$/gi,"$1"],[/^(ox)en/gi,"$1"],[/(vert|ind)ices$/gi,"$1ex"],[/(matr)ices$/gi,"$1ix"],[/(quiz)zes$/gi,"$1"],[/s$/gi,""]],nonTitlecasedWords:["and","or","nor","a","an","the","so","but","to","of","at","by","from","into","on","onto","off","out","in","over","with","for"],idSuffix:/(_ids|_id)$/g,underbar:/_/g,spaceOrUnderbar:/[ _]/g,uppercase:/([A-Z])/g,underbarPrefix:/^_/,applyRules:function(e,t,r,s){if(s)e=s;else if(!r.includes(e.toLowerCase())){for(let i=0;i<t.length;i++)if(e.match(t[i][0])){e=e.replace(t[i][0],t[i][1]);break}}return e},pluralize:function(e,t){return u.applyRules(e,u.pluralRules,u.uncountableWords,t)},singularize:function(e,t){return u.applyRules(e,u.singularRules,u.uncountableWords,t)},camelize:function(e,t){let r=e.split("/");for(let s=0;s<r.length;s++){let n=r[s].split("_"),i=t&&s+1===r.length?1:0;for(let a=i;a<n.length;a++)n[a]=n[a].charAt(0).toUpperCase()+n[a].substring(1);r[s]=n.join("")}if(e=r.join("::"),t){let s=e.charAt(0).toLowerCase(),n=e.slice(1);e=s+n}return e},underscore:function(e){let t=e.split("::");for(let r=0;r<t.length;r++)t[r]=t[r].replace(u.uppercase,"_$1"),t[r]=t[r].replace(u.underbarPrefix,"");return e=t.join("/").toLowerCase(),e},humanize:function(e,t){return e=e.toLowerCase(),e=e.replace(u.idSuffix,""),e=e.replace(u.underbar," "),t||(e=u.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(u.spaceOrUnderbar,"-"),e},camel2words:function(e,t){t?(e=u.camelize(e),e=u.underscore(e)):e=e.toLowerCase(),e=e.replace(u.underbar," ");let r=e.split(" ");for(let s=0;s<r.length;s++){let n=r[s].split("-");for(let i=0;i<n.length;i++)u.nonTitlecasedWords.includes(n[i].toLowerCase())||(n[i]=u.capitalize(n[i]));r[s]=n.join("-")}return e=r.join(" "),e=e.substring(0,1).toUpperCase()+e.substring(1),e},demodulize:function(e){let t=e.split("::");return e=t[t.length-1],e},tableize:function(e){return e=u.pluralize(u.underscore(e)),e},classify:function(e){return e=u.singularize(u.camelize(e)),e},foreignKey:function(e,t){return e=u.underscore(u.demodulize(e))+(t?"":"_")+"id",e},ordinalize:function(e){let t=e.split(" ");for(let r=0;r<t.length;r++){let s=parseInt(t[r]);if(Number.isNaN(s)){let n=t[r].substring(t[r].length-2),i=t[r].substring(t[r].length-1),a="th";n!=="11"&&n!=="12"&&n!=="13"&&(i==="1"?a="st":i==="2"?a="nd":i==="3"&&(a="rd")),t[r]+=a}}return e=t.join(" "),e}},q=u;var me={};h(me,{symbols:()=>x});var x={check:{small:"\u2714",bkgGreen:"\u2705",squareRoot:"\u221A"},cross:{small:"\u2718",red:"\u274C"},clock:{stopwatch:"\u23F1"},arrow:{down:"\u2193"},selection:{fisheye:"\u25C9"}};x.check.heavy=x.check.small;x.check.whiteHeavy=x.check.bkgGreen;x.cross.heavyBallot=x.cross.small;var R=e=>e&&q.capitalize(e),Wt=e=>e&&(e=e.toLocaleLowerCase(),e.replace(/[ _]/g,"-")),Nt=e=>e&&(e=e.toLocaleLowerCase(),e.replace(/[ -]/g,"_")),Ht=(e,t)=>q.pluralize(e,t),Gt=(e,t)=>q.singularize(e,t),Jt=(e,t)=>q.camelize(e,t);var y=!1,H=class extends Yt{examples(t){return y&&console.log("---------- command.examples"),super.examples(t)}},O=class extends Xt{async showHelp(t){return y&&console.log("---------- showHelp"),super.showHelp(t)}async showRootHelp(){return y&&console.log("---------- showRootHelp"),super.showRootHelp()}async showTopicHelp(t){return y&&console.log("---------- showTopicHelp"),super.showTopicHelp(t)}async showCommandHelp(t){y&&console.log("---------- showCommandHelp");let r=t.id,s=r?r.split(":").length:1,n=this.sortedTopics.filter(p=>p.name.startsWith(r+":")&&p.name.split(":").length===s+1),i=this.sortedCommands.filter(p=>p.id.startsWith(r+":")&&p.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(""),n.length>0&&(console.log(this.formatTopics(n)),console.log("")),i.length>0&&(console.log(this.formatCommands(i)),console.log(""))}formatRoot(){return y&&console.log("---------- formatRoot"),super.formatRoot()}formatTopic(t){return y&&console.log("---------- formatTopic"),super.formatTopic(t)}formatTopics(t){y&&console.log("---------- formatTopics");let r=t.filter(s=>!s.hidden).map(s=>(s.description=R(s.description),s));return super.formatTopics(r)}formatCommands(t){return y&&console.log("---------- formatCommands"),super.formatCommands(t).split(`
10
10
  `).map(r=>{let s=0;return r.split(" ").map(n=>(n||"").trim()!==""&&++s===2?R(n):n).join(" ")}).join(`
11
- `)}formatCommand(t){return y&&console.log("---------- formatCommand"),super.formatCommand(t)}getCommandHelpClass(t){return y&&console.log("---------- getCommandHelpClass"),new H(t,this.config,this.opts)}};var ge={};h(ge,{download:()=>Xt});var Xt=async e=>{let r=`https://data.${m.api.default_app_domain}/schemas/`,n=`openapi${e?"_"+e.replace(/\./g,"-"):""}.json`,i=r+n;return await(await fetch(i)).json()};var ye={};h(ye,{apply:()=>er,available:()=>fe,documentation:()=>Qt,filters:()=>he,list:()=>_e});var Zt=[{predicate:"*_eq",description:"The attribute is equal to the filter value"},{predicate:"*_eq_or_null",description:"The attribute is equal to the filter value, including null values"},{predicate:"*_not_eq",description:"The attribute is not equal to the filter value"},{predicate:"*_not_eq_or_null",description:"The attribute is not equal to the filter value, including null values"},{predicate:"*_matches",description:'The attribute matches the filter value with "LIKE" operator'},{predicate:"*_does_not_match",description:'The attribute does not match the filter value with "LIKE" operator'},{predicate:"*_matches_any",description:'The attribute matches all of the filter values (comma-separated) with "LIKE" operator'},{predicate:"*_matches_all",description:'The attribute matches all of the filter values (comma-separated) with "LIKE" operator'},{predicate:"*_does_not_match_any",description:'The attribute does not match any of the filter values (comma-separated) with "LIKE" operator'},{predicate:"*_does_not_match_all",description:'The attribute matches none of the filter values (comma-separated) with "LIKE" operator'},{predicate:"*_lt",description:"The attribute is less than the filter value"},{predicate:"*_lteq",description:"The attribute is less than or equal to the filter value"},{predicate:"*_gt",description:"The attribute is greater than the filter value"},{predicate:"*_gteq",description:"The attribute is greater than or equal to the filter value"},{predicate:"*_present",description:"The attribute is not null and not empty"},{predicate:"*_blank",description:"The attribute is null or empty"},{predicate:"*_null",description:"The attribute is null"},{predicate:"*_not_null",description:"The attribute is not null"},{predicate:"*_in",description:"The attribute matches any of the filter values (comma-separated)"},{predicate:"*_in_or_null",description:"The attribute matches any of the filter values (comma-separated), including null values"},{predicate:"*_not_in",description:"The attribute matches none of the filter values (comma-separated)"},{predicate:"*_not_in_or_null",description:"The attribute matches none of the filter values (comma-separated), including null values"},{predicate:"*_lt_any",description:"The attribute is less than any of the filter values (comma-separated)"},{predicate:"*_lteq_any",description:"The attribute is less than or equal to any of the filter values (comma-separated)"},{predicate:"*_gt_any",description:"The attribute is greater than any of the filter values (comma-separated)"},{predicate:"*_gteq_any",description:"The attribute is greater than or qual to any of the filter values (comma-separated)"},{predicate:"*_lt_all",description:"The attribute is less than all of the filter values (comma-separated)"},{predicate:"*_lteq_all",description:"The attribute is less than or equal to all of the filter values (comma-separated)"},{predicate:"*_gt_all",description:"The attribute is greater than all of the filter values (comma-separated)"},{predicate:"*_gteq_all",description:"The attribute is greater or equal to all of the filter values (comma-separated)"},{predicate:"*_not_eq_all",description:"The attribute is equal to none of the filter values (comma-separated)"},{predicate:"*_start",description:"The attribute starts with the filter value (comma-separated)"},{predicate:"*_not_start",description:"The attribute does not start with the filter value (comma-separated)"},{predicate:"*_start_any",description:"The attribute starts with any of the filter values (comma-separated)"},{predicate:"*_start_all",description:"The attribute starts with all of the filter values (comma-separated)"},{predicate:"*_not_start_any",description:"The attribute does not start with any of the filter values (comma-separated)"},{predicate:"*_not_start_all",description:"The attribute starts with none of the filter values (comma-separated)"},{predicate:"*_end",description:"The attribute ends with the filter value"},{predicate:"*_not_end",description:"The attribute does not end with the filter value"},{predicate:"*_end_any",description:"The attribute ends with any of the filter values (comma-separated)"},{predicate:"*_end_all",description:"The attribute ends with all of the filter values (comma-separated)"},{predicate:"*_not_end_any",description:"The attribute does not end with any of the filter values (comma-separated)"},{predicate:"*_not_end_all",description:"The attribute ends with none of the filter values (comma-separated)"},{predicate:"*_cont",description:"The attribute contains the filter value"},{predicate:"*_not_cont",description:"The attribute does not contains the filter value"},{predicate:"*_cont_any",description:"The attribute contains any of the filter values (comma-separated)"},{predicate:"*_cont_all",description:"The attribute contains all of the filter values (comma-separated)"},{predicate:"*_not_cont_all",description:"The attribute contains none of the filter values (comma-separated)"},{predicate:"*_jcont",description:"The attribute contains a portion of the JSON used as filter value (works with object only)"},{predicate:"*_true",description:"The attribute is true"},{predicate:"*_false",description:"The attribute is false"}],Qt=m.doc.core_filtering_data,_e=()=>he().map(e=>e.predicate.replace(/^\*/g,"")),fe=e=>{let t=e.startsWith("_")?e:`_${e}`;return _e().some(r=>t.endsWith(r))},er=(e,...t)=>{if(!fe(e))throw new Error("Unknown filter: "+e);let r="";for(let s of t)r+=(r.length===0?"":"_or_")+s;return r+=e.startsWith("_")?e:`_${e}`,r},he=()=>[...Zt];export{Z as clApi,ee as clApplication,A as clColor,te as clCommand,m as clConfig,ye as clFilter,O as clHelp,oe as clOutput,ge as clSchema,me as clSymbol,de as clText,pe as clToken,ue as clUpdate,ce as clUtil};
11
+ `)}formatCommand(t){return y&&console.log("---------- formatCommand"),super.formatCommand(t)}getCommandHelpClass(t){return y&&console.log("---------- getCommandHelpClass"),new H(t,this.config,this.opts)}};var ge={};h(ge,{download:()=>Zt});var Zt=async e=>{let r=`https://data.${m.api.default_app_domain}/schemas/`,n=`openapi${e?"_"+e.replace(/\./g,"-"):""}.json`,i=r+n;return await(await fetch(i)).json()};var ye={};h(ye,{apply:()=>tr,available:()=>fe,documentation:()=>er,filters:()=>he,list:()=>_e});var Qt=[{predicate:"*_eq",description:"The attribute is equal to the filter value"},{predicate:"*_eq_or_null",description:"The attribute is equal to the filter value, including null values"},{predicate:"*_not_eq",description:"The attribute is not equal to the filter value"},{predicate:"*_not_eq_or_null",description:"The attribute is not equal to the filter value, including null values"},{predicate:"*_matches",description:'The attribute matches the filter value with "LIKE" operator'},{predicate:"*_does_not_match",description:'The attribute does not match the filter value with "LIKE" operator'},{predicate:"*_matches_any",description:'The attribute matches all of the filter values (comma-separated) with "LIKE" operator'},{predicate:"*_matches_all",description:'The attribute matches all of the filter values (comma-separated) with "LIKE" operator'},{predicate:"*_does_not_match_any",description:'The attribute does not match any of the filter values (comma-separated) with "LIKE" operator'},{predicate:"*_does_not_match_all",description:'The attribute matches none of the filter values (comma-separated) with "LIKE" operator'},{predicate:"*_lt",description:"The attribute is less than the filter value"},{predicate:"*_lteq",description:"The attribute is less than or equal to the filter value"},{predicate:"*_gt",description:"The attribute is greater than the filter value"},{predicate:"*_gteq",description:"The attribute is greater than or equal to the filter value"},{predicate:"*_present",description:"The attribute is not null and not empty"},{predicate:"*_blank",description:"The attribute is null or empty"},{predicate:"*_null",description:"The attribute is null"},{predicate:"*_not_null",description:"The attribute is not null"},{predicate:"*_in",description:"The attribute matches any of the filter values (comma-separated)"},{predicate:"*_in_or_null",description:"The attribute matches any of the filter values (comma-separated), including null values"},{predicate:"*_not_in",description:"The attribute matches none of the filter values (comma-separated)"},{predicate:"*_not_in_or_null",description:"The attribute matches none of the filter values (comma-separated), including null values"},{predicate:"*_lt_any",description:"The attribute is less than any of the filter values (comma-separated)"},{predicate:"*_lteq_any",description:"The attribute is less than or equal to any of the filter values (comma-separated)"},{predicate:"*_gt_any",description:"The attribute is greater than any of the filter values (comma-separated)"},{predicate:"*_gteq_any",description:"The attribute is greater than or qual to any of the filter values (comma-separated)"},{predicate:"*_lt_all",description:"The attribute is less than all of the filter values (comma-separated)"},{predicate:"*_lteq_all",description:"The attribute is less than or equal to all of the filter values (comma-separated)"},{predicate:"*_gt_all",description:"The attribute is greater than all of the filter values (comma-separated)"},{predicate:"*_gteq_all",description:"The attribute is greater or equal to all of the filter values (comma-separated)"},{predicate:"*_not_eq_all",description:"The attribute is equal to none of the filter values (comma-separated)"},{predicate:"*_start",description:"The attribute starts with the filter value (comma-separated)"},{predicate:"*_not_start",description:"The attribute does not start with the filter value (comma-separated)"},{predicate:"*_start_any",description:"The attribute starts with any of the filter values (comma-separated)"},{predicate:"*_start_all",description:"The attribute starts with all of the filter values (comma-separated)"},{predicate:"*_not_start_any",description:"The attribute does not start with any of the filter values (comma-separated)"},{predicate:"*_not_start_all",description:"The attribute starts with none of the filter values (comma-separated)"},{predicate:"*_end",description:"The attribute ends with the filter value"},{predicate:"*_not_end",description:"The attribute does not end with the filter value"},{predicate:"*_end_any",description:"The attribute ends with any of the filter values (comma-separated)"},{predicate:"*_end_all",description:"The attribute ends with all of the filter values (comma-separated)"},{predicate:"*_not_end_any",description:"The attribute does not end with any of the filter values (comma-separated)"},{predicate:"*_not_end_all",description:"The attribute ends with none of the filter values (comma-separated)"},{predicate:"*_cont",description:"The attribute contains the filter value"},{predicate:"*_not_cont",description:"The attribute does not contains the filter value"},{predicate:"*_cont_any",description:"The attribute contains any of the filter values (comma-separated)"},{predicate:"*_cont_all",description:"The attribute contains all of the filter values (comma-separated)"},{predicate:"*_not_cont_all",description:"The attribute contains none of the filter values (comma-separated)"},{predicate:"*_jcont",description:"The attribute contains a portion of the JSON used as filter value (works with object only)"},{predicate:"*_true",description:"The attribute is true"},{predicate:"*_false",description:"The attribute is false"}],er=m.doc.core_filtering_data,_e=()=>he().map(e=>e.predicate.replace(/^\*/g,"")),fe=e=>{let t=e.startsWith("_")?e:`_${e}`;return _e().some(r=>t.endsWith(r))},tr=(e,...t)=>{if(!fe(e))throw new Error("Unknown filter: "+e);let r="";for(let s of t)r+=(r.length===0?"":"_or_")+s;return r+=e.startsWith("_")?e:`_${e}`,r},he=()=>[...Qt];export{Z as clApi,ee as clApplication,A as clColor,te as clCommand,m as clConfig,ye as clFilter,O as clHelp,oe as clOutput,ge as clSchema,me as clSymbol,de as clText,pe as clToken,ue as clUpdate,ce as clUtil};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commercelayer/cli-core",
3
- "version": "5.6.4",
3
+ "version": "5.7.0",
4
4
  "author": "Pierluigi Viti <pierluigi@commercelayer.io>",
5
5
  "license": "MIT",
6
6
  "description": "Commerce Layer Javascript CLI core lib",