@commercelayer/cli-core 6.0.0-oclif4.2 → 6.0.0-oclif4.4

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
@@ -1,7 +1,8 @@
1
1
  import { Command, Help, Interfaces, CommandHelp } from '@oclif/core';
2
2
  import { FlagInput } from '@oclif/core/lib/interfaces/parser';
3
3
  import chalk from 'chalk';
4
- import { Config as Config$1 } from '@oclif/core/lib/interfaces';
4
+
5
+ declare const denormalize: (response: any) => any;
5
6
 
6
7
  declare const rawRequest: (config: {
7
8
  baseUrl: string;
@@ -15,8 +16,6 @@ declare enum Operation {
15
16
  Update = "PATCH"
16
17
  }
17
18
 
18
- declare const denormalize: (response: any) => any;
19
-
20
19
  type Method = 'GET' | 'PATCH' | 'POST' | 'PUT' | 'DELETE';
21
20
 
22
21
  type ApiMode = 'test' | 'live';
@@ -75,6 +74,44 @@ declare namespace api$1 {
75
74
  export { type api$1_ApiMode as ApiMode, type api$1_ApiType as ApiType, type api$1_DelayOptions as DelayOptions, api$1_Operation as Operation, api$1_baseURL as baseURL, api$1_execMode as execMode, api$1_extractDomain as extractDomain, api$1_humanizeResource as humanizeResource, api$1_isResourceCacheable as isResourceCacheable, api$1_liveEnvironment as liveEnvironment, api$1_request as request, readDataFile as requestDataFile, api$1_requestRateLimitDelay as requestRateLimitDelay, rawRequest as requestRaw, api$1_response as response, denormalize as responseDenormalize };
76
75
  }
77
76
 
77
+ declare const commandFlags: <T extends FlagInput>(flags: T, exclude?: Array<keyof T>) => T;
78
+ declare const allFlags: (command: Command.Class) => FlagInput;
79
+ type KeyVal = Record<string, string | number | boolean | undefined | null>;
80
+ type KeyValString = Record<string, string>;
81
+ type KeyValArray = Record<string, string[]>;
82
+ type KeyValRel = Record<string, {
83
+ readonly type: string;
84
+ readonly id: string;
85
+ }>;
86
+ type KeyValObj = Record<string, any>;
87
+ type KeyValSort = Record<string, 'asc' | 'desc'>;
88
+ type ResAttributes = KeyValObj;
89
+ declare const fixValueType: (val: string) => string | number | boolean | null | undefined;
90
+ declare const findLongStringFlag: (args: string[], name: string) => {
91
+ value: string;
92
+ index: number;
93
+ single: boolean;
94
+ } | undefined;
95
+ declare const fixDashedFlagValue: (argv: string[], flag: any, name?: string, parsed?: any) => string[];
96
+ declare const checkISODateTimeValue: (value?: string) => Date;
97
+
98
+ type command_KeyVal = KeyVal;
99
+ type command_KeyValArray = KeyValArray;
100
+ type command_KeyValObj = KeyValObj;
101
+ type command_KeyValRel = KeyValRel;
102
+ type command_KeyValSort = KeyValSort;
103
+ type command_KeyValString = KeyValString;
104
+ type command_ResAttributes = ResAttributes;
105
+ declare const command_allFlags: typeof allFlags;
106
+ declare const command_checkISODateTimeValue: typeof checkISODateTimeValue;
107
+ declare const command_commandFlags: typeof commandFlags;
108
+ declare const command_findLongStringFlag: typeof findLongStringFlag;
109
+ declare const command_fixDashedFlagValue: typeof fixDashedFlagValue;
110
+ declare const command_fixValueType: typeof fixValueType;
111
+ declare namespace command {
112
+ 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 };
113
+ }
114
+
78
115
  type ApiConfig = {
79
116
  default_domain: string;
80
117
  default_app_domain: string;
@@ -180,44 +217,6 @@ type Config = {
180
217
  };
181
218
  declare const config: Config;
182
219
 
183
- declare const commandFlags: <T extends FlagInput>(flags: T, exclude?: Array<keyof T>) => T;
184
- declare const allFlags: (command: Command.Class) => FlagInput;
185
- type KeyVal = Record<string, string | number | boolean | undefined | null>;
186
- type KeyValString = Record<string, string>;
187
- type KeyValArray = Record<string, string[]>;
188
- type KeyValRel = Record<string, {
189
- readonly type: string;
190
- readonly id: string;
191
- }>;
192
- type KeyValObj = Record<string, any>;
193
- type KeyValSort = Record<string, 'asc' | 'desc'>;
194
- type ResAttributes = KeyValObj;
195
- declare const fixValueType: (val: string) => string | number | boolean | null | undefined;
196
- declare const findLongStringFlag: (args: string[], name: string) => {
197
- value: string;
198
- index: number;
199
- single: boolean;
200
- } | undefined;
201
- declare const fixDashedFlagValue: (argv: string[], flag: any, name?: string, parsed?: any) => string[];
202
- declare const checkISODateTimeValue: (value?: string) => Date;
203
-
204
- type command_KeyVal = KeyVal;
205
- type command_KeyValArray = KeyValArray;
206
- type command_KeyValObj = KeyValObj;
207
- type command_KeyValRel = KeyValRel;
208
- type command_KeyValSort = KeyValSort;
209
- type command_KeyValString = KeyValString;
210
- type command_ResAttributes = ResAttributes;
211
- declare const command_allFlags: typeof allFlags;
212
- declare const command_checkISODateTimeValue: typeof checkISODateTimeValue;
213
- declare const command_commandFlags: typeof commandFlags;
214
- declare const command_findLongStringFlag: typeof findLongStringFlag;
215
- declare const command_fixDashedFlagValue: typeof fixDashedFlagValue;
216
- declare const command_fixValueType: typeof fixValueType;
217
- declare namespace command {
218
- 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 };
219
- }
220
-
221
220
  type AuthScope = string | string[];
222
221
  type AccessToken = {
223
222
  accessToken: string;
@@ -521,37 +520,21 @@ declare namespace color {
521
520
  export { color_api as api, color_bg as bg, color_black as black, color_blackBright as blackBright, color_blue as blue, color_blueBright as blueBright, color_bold as bold, color_cli as cli, color_cyan as cyan, color_cyanBright as cyanBright, color_dim as dim, color_green as green, color_greenBright as greenBright, color_grey as grey, color_hidden as hidden, color_italic as italic, color_magenta as magenta, color_magentaBright as magentaBright, color_msg as msg, color_red as red, color_redBright as redBright, color_reset as reset, color_style as style, color_table as table, color_type as type, color_underline as underline, color_visible as visible, color_white as white, color_whiteBright as whiteBright, color_yellow as yellow, color_yellowBright as yellowBright };
522
521
  }
523
522
 
524
- interface Package {
525
- name: string;
526
- version: string;
523
+ declare const documentation: string;
524
+ interface Filter extends Record<string, unknown> {
525
+ predicate: string;
527
526
  description: string;
528
527
  }
529
- declare const checkUpdate: (pkg: Package) => void;
530
-
531
- type update_Package = Package;
532
- declare const update_checkUpdate: typeof checkUpdate;
533
- declare namespace update {
534
- export { type update_Package as Package, update_checkUpdate as checkUpdate };
535
- }
536
-
537
- /** Await ms milliseconds */
538
- declare const sleep: (ms: number) => Promise<void>;
539
- declare const resetConsole: () => void;
540
- declare const log: (message?: string, ...args: unknown[]) => void;
541
- declare const specialFolder: (filePath: string, createIfNotExists?: boolean) => string;
542
- declare const generateGroupUID: () => string;
543
- declare const userAgent: (config: Config$1) => string;
544
- declare const dotNotationToObject: (dotNot: KeyValObj, toObj?: KeyValObj) => KeyValObj;
528
+ declare const filterList: () => string[];
529
+ declare const filterAvailable: (filter: string) => boolean;
530
+ declare const applyFilter: (predicate: string, ...fields: string[]) => string;
531
+ declare const filters: () => Filter[];
545
532
 
546
- declare const util_dotNotationToObject: typeof dotNotationToObject;
547
- declare const util_generateGroupUID: typeof generateGroupUID;
548
- declare const util_log: typeof log;
549
- declare const util_resetConsole: typeof resetConsole;
550
- declare const util_sleep: typeof sleep;
551
- declare const util_specialFolder: typeof specialFolder;
552
- declare const util_userAgent: typeof userAgent;
553
- declare namespace util {
554
- export { util_dotNotationToObject as dotNotationToObject, util_generateGroupUID as generateGroupUID, util_log as log, util_resetConsole as resetConsole, util_sleep as sleep, util_specialFolder as specialFolder, util_userAgent as userAgent };
533
+ type filter_Filter = Filter;
534
+ declare const filter_documentation: typeof documentation;
535
+ declare const filter_filters: typeof filters;
536
+ declare namespace filter {
537
+ export { type filter_Filter as Filter, applyFilter as apply, filterAvailable as available, filter_documentation as documentation, filter_filters as filters, filterList as list };
555
538
  }
556
539
 
557
540
  declare class CLICommandHelp extends CommandHelp {
@@ -601,21 +584,37 @@ declare namespace text {
601
584
  export { text_camelize as camelize, text_capitalize as capitalize, text_dasherize as dasherize, text_pluralize as pluralize, text_singularize as singularize, text_symbols as symbols, text_underscorize as underscorize };
602
585
  }
603
586
 
604
- declare const documentation: string;
605
- interface Filter extends Record<string, unknown> {
606
- predicate: string;
587
+ interface Package {
588
+ name: string;
589
+ version: string;
607
590
  description: string;
608
591
  }
609
- declare const filterList: () => string[];
610
- declare const filterAvailable: (filter: string) => boolean;
611
- declare const applyFilter: (predicate: string, ...fields: string[]) => string;
612
- declare const filters: () => Filter[];
592
+ declare const checkUpdate: (pkg: Package) => void;
613
593
 
614
- type filter_Filter = Filter;
615
- declare const filter_documentation: typeof documentation;
616
- declare const filter_filters: typeof filters;
617
- declare namespace filter {
618
- export { type filter_Filter as Filter, applyFilter as apply, filterAvailable as available, filter_documentation as documentation, filter_filters as filters, filterList as list };
594
+ type update_Package = Package;
595
+ declare const update_checkUpdate: typeof checkUpdate;
596
+ declare namespace update {
597
+ export { type update_Package as Package, update_checkUpdate as checkUpdate };
598
+ }
599
+
600
+ /** Await ms milliseconds */
601
+ declare const sleep: (ms: number) => Promise<void>;
602
+ declare const resetConsole: () => void;
603
+ declare const log: (message?: string, ...args: unknown[]) => void;
604
+ declare const specialFolder: (filePath: string, createIfNotExists?: boolean) => string;
605
+ declare const generateGroupUID: () => string;
606
+ declare const userAgent: (config: Interfaces.Config) => string;
607
+ declare const dotNotationToObject: (dotNot: KeyValObj, toObj?: KeyValObj) => KeyValObj;
608
+
609
+ declare const util_dotNotationToObject: typeof dotNotationToObject;
610
+ declare const util_generateGroupUID: typeof generateGroupUID;
611
+ declare const util_log: typeof log;
612
+ declare const util_resetConsole: typeof resetConsole;
613
+ declare const util_sleep: typeof sleep;
614
+ declare const util_specialFolder: typeof specialFolder;
615
+ declare const util_userAgent: typeof userAgent;
616
+ declare namespace util {
617
+ export { util_dotNotationToObject as dotNotationToObject, util_generateGroupUID as generateGroupUID, util_log as log, util_resetConsole as resetConsole, util_sleep as sleep, util_specialFolder as specialFolder, util_userAgent as userAgent };
619
618
  }
620
619
 
621
620
  export { type AccessToken, type AccessTokenInfo, type ApiMode, type ApiType, type AppAuth, type AppInfo, type AppKey, type ApplicationKind, type AuthScope, type CustomToken, type KeyVal, type KeyValArray, type KeyValObj, type KeyValRel, type KeyValSort, type KeyValString, type Method, type OwnerType, type ResAttributes, api$1 as clApi, application as clApplication, color as clColor, command as clCommand, config as clConfig, filter as clFilter, CLIBaseHelp as clHelp, output as clOutput, schema as clSchema, symbol as clSymbol, text as clText, token as clToken, update as clUpdate, util as clUtil };
package/lib/index.d.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  import { Command, Help, Interfaces, CommandHelp } from '@oclif/core';
2
2
  import { FlagInput } from '@oclif/core/lib/interfaces/parser';
3
3
  import chalk from 'chalk';
4
- import { Config as Config$1 } from '@oclif/core/lib/interfaces';
4
+
5
+ declare const denormalize: (response: any) => any;
5
6
 
6
7
  declare const rawRequest: (config: {
7
8
  baseUrl: string;
@@ -15,8 +16,6 @@ declare enum Operation {
15
16
  Update = "PATCH"
16
17
  }
17
18
 
18
- declare const denormalize: (response: any) => any;
19
-
20
19
  type Method = 'GET' | 'PATCH' | 'POST' | 'PUT' | 'DELETE';
21
20
 
22
21
  type ApiMode = 'test' | 'live';
@@ -75,6 +74,44 @@ declare namespace api$1 {
75
74
  export { type api$1_ApiMode as ApiMode, type api$1_ApiType as ApiType, type api$1_DelayOptions as DelayOptions, api$1_Operation as Operation, api$1_baseURL as baseURL, api$1_execMode as execMode, api$1_extractDomain as extractDomain, api$1_humanizeResource as humanizeResource, api$1_isResourceCacheable as isResourceCacheable, api$1_liveEnvironment as liveEnvironment, api$1_request as request, readDataFile as requestDataFile, api$1_requestRateLimitDelay as requestRateLimitDelay, rawRequest as requestRaw, api$1_response as response, denormalize as responseDenormalize };
76
75
  }
77
76
 
77
+ declare const commandFlags: <T extends FlagInput>(flags: T, exclude?: Array<keyof T>) => T;
78
+ declare const allFlags: (command: Command.Class) => FlagInput;
79
+ type KeyVal = Record<string, string | number | boolean | undefined | null>;
80
+ type KeyValString = Record<string, string>;
81
+ type KeyValArray = Record<string, string[]>;
82
+ type KeyValRel = Record<string, {
83
+ readonly type: string;
84
+ readonly id: string;
85
+ }>;
86
+ type KeyValObj = Record<string, any>;
87
+ type KeyValSort = Record<string, 'asc' | 'desc'>;
88
+ type ResAttributes = KeyValObj;
89
+ declare const fixValueType: (val: string) => string | number | boolean | null | undefined;
90
+ declare const findLongStringFlag: (args: string[], name: string) => {
91
+ value: string;
92
+ index: number;
93
+ single: boolean;
94
+ } | undefined;
95
+ declare const fixDashedFlagValue: (argv: string[], flag: any, name?: string, parsed?: any) => string[];
96
+ declare const checkISODateTimeValue: (value?: string) => Date;
97
+
98
+ type command_KeyVal = KeyVal;
99
+ type command_KeyValArray = KeyValArray;
100
+ type command_KeyValObj = KeyValObj;
101
+ type command_KeyValRel = KeyValRel;
102
+ type command_KeyValSort = KeyValSort;
103
+ type command_KeyValString = KeyValString;
104
+ type command_ResAttributes = ResAttributes;
105
+ declare const command_allFlags: typeof allFlags;
106
+ declare const command_checkISODateTimeValue: typeof checkISODateTimeValue;
107
+ declare const command_commandFlags: typeof commandFlags;
108
+ declare const command_findLongStringFlag: typeof findLongStringFlag;
109
+ declare const command_fixDashedFlagValue: typeof fixDashedFlagValue;
110
+ declare const command_fixValueType: typeof fixValueType;
111
+ declare namespace command {
112
+ 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 };
113
+ }
114
+
78
115
  type ApiConfig = {
79
116
  default_domain: string;
80
117
  default_app_domain: string;
@@ -180,44 +217,6 @@ type Config = {
180
217
  };
181
218
  declare const config: Config;
182
219
 
183
- declare const commandFlags: <T extends FlagInput>(flags: T, exclude?: Array<keyof T>) => T;
184
- declare const allFlags: (command: Command.Class) => FlagInput;
185
- type KeyVal = Record<string, string | number | boolean | undefined | null>;
186
- type KeyValString = Record<string, string>;
187
- type KeyValArray = Record<string, string[]>;
188
- type KeyValRel = Record<string, {
189
- readonly type: string;
190
- readonly id: string;
191
- }>;
192
- type KeyValObj = Record<string, any>;
193
- type KeyValSort = Record<string, 'asc' | 'desc'>;
194
- type ResAttributes = KeyValObj;
195
- declare const fixValueType: (val: string) => string | number | boolean | null | undefined;
196
- declare const findLongStringFlag: (args: string[], name: string) => {
197
- value: string;
198
- index: number;
199
- single: boolean;
200
- } | undefined;
201
- declare const fixDashedFlagValue: (argv: string[], flag: any, name?: string, parsed?: any) => string[];
202
- declare const checkISODateTimeValue: (value?: string) => Date;
203
-
204
- type command_KeyVal = KeyVal;
205
- type command_KeyValArray = KeyValArray;
206
- type command_KeyValObj = KeyValObj;
207
- type command_KeyValRel = KeyValRel;
208
- type command_KeyValSort = KeyValSort;
209
- type command_KeyValString = KeyValString;
210
- type command_ResAttributes = ResAttributes;
211
- declare const command_allFlags: typeof allFlags;
212
- declare const command_checkISODateTimeValue: typeof checkISODateTimeValue;
213
- declare const command_commandFlags: typeof commandFlags;
214
- declare const command_findLongStringFlag: typeof findLongStringFlag;
215
- declare const command_fixDashedFlagValue: typeof fixDashedFlagValue;
216
- declare const command_fixValueType: typeof fixValueType;
217
- declare namespace command {
218
- 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 };
219
- }
220
-
221
220
  type AuthScope = string | string[];
222
221
  type AccessToken = {
223
222
  accessToken: string;
@@ -521,37 +520,21 @@ declare namespace color {
521
520
  export { color_api as api, color_bg as bg, color_black as black, color_blackBright as blackBright, color_blue as blue, color_blueBright as blueBright, color_bold as bold, color_cli as cli, color_cyan as cyan, color_cyanBright as cyanBright, color_dim as dim, color_green as green, color_greenBright as greenBright, color_grey as grey, color_hidden as hidden, color_italic as italic, color_magenta as magenta, color_magentaBright as magentaBright, color_msg as msg, color_red as red, color_redBright as redBright, color_reset as reset, color_style as style, color_table as table, color_type as type, color_underline as underline, color_visible as visible, color_white as white, color_whiteBright as whiteBright, color_yellow as yellow, color_yellowBright as yellowBright };
522
521
  }
523
522
 
524
- interface Package {
525
- name: string;
526
- version: string;
523
+ declare const documentation: string;
524
+ interface Filter extends Record<string, unknown> {
525
+ predicate: string;
527
526
  description: string;
528
527
  }
529
- declare const checkUpdate: (pkg: Package) => void;
530
-
531
- type update_Package = Package;
532
- declare const update_checkUpdate: typeof checkUpdate;
533
- declare namespace update {
534
- export { type update_Package as Package, update_checkUpdate as checkUpdate };
535
- }
536
-
537
- /** Await ms milliseconds */
538
- declare const sleep: (ms: number) => Promise<void>;
539
- declare const resetConsole: () => void;
540
- declare const log: (message?: string, ...args: unknown[]) => void;
541
- declare const specialFolder: (filePath: string, createIfNotExists?: boolean) => string;
542
- declare const generateGroupUID: () => string;
543
- declare const userAgent: (config: Config$1) => string;
544
- declare const dotNotationToObject: (dotNot: KeyValObj, toObj?: KeyValObj) => KeyValObj;
528
+ declare const filterList: () => string[];
529
+ declare const filterAvailable: (filter: string) => boolean;
530
+ declare const applyFilter: (predicate: string, ...fields: string[]) => string;
531
+ declare const filters: () => Filter[];
545
532
 
546
- declare const util_dotNotationToObject: typeof dotNotationToObject;
547
- declare const util_generateGroupUID: typeof generateGroupUID;
548
- declare const util_log: typeof log;
549
- declare const util_resetConsole: typeof resetConsole;
550
- declare const util_sleep: typeof sleep;
551
- declare const util_specialFolder: typeof specialFolder;
552
- declare const util_userAgent: typeof userAgent;
553
- declare namespace util {
554
- export { util_dotNotationToObject as dotNotationToObject, util_generateGroupUID as generateGroupUID, util_log as log, util_resetConsole as resetConsole, util_sleep as sleep, util_specialFolder as specialFolder, util_userAgent as userAgent };
533
+ type filter_Filter = Filter;
534
+ declare const filter_documentation: typeof documentation;
535
+ declare const filter_filters: typeof filters;
536
+ declare namespace filter {
537
+ export { type filter_Filter as Filter, applyFilter as apply, filterAvailable as available, filter_documentation as documentation, filter_filters as filters, filterList as list };
555
538
  }
556
539
 
557
540
  declare class CLICommandHelp extends CommandHelp {
@@ -601,21 +584,37 @@ declare namespace text {
601
584
  export { text_camelize as camelize, text_capitalize as capitalize, text_dasherize as dasherize, text_pluralize as pluralize, text_singularize as singularize, text_symbols as symbols, text_underscorize as underscorize };
602
585
  }
603
586
 
604
- declare const documentation: string;
605
- interface Filter extends Record<string, unknown> {
606
- predicate: string;
587
+ interface Package {
588
+ name: string;
589
+ version: string;
607
590
  description: string;
608
591
  }
609
- declare const filterList: () => string[];
610
- declare const filterAvailable: (filter: string) => boolean;
611
- declare const applyFilter: (predicate: string, ...fields: string[]) => string;
612
- declare const filters: () => Filter[];
592
+ declare const checkUpdate: (pkg: Package) => void;
613
593
 
614
- type filter_Filter = Filter;
615
- declare const filter_documentation: typeof documentation;
616
- declare const filter_filters: typeof filters;
617
- declare namespace filter {
618
- export { type filter_Filter as Filter, applyFilter as apply, filterAvailable as available, filter_documentation as documentation, filter_filters as filters, filterList as list };
594
+ type update_Package = Package;
595
+ declare const update_checkUpdate: typeof checkUpdate;
596
+ declare namespace update {
597
+ export { type update_Package as Package, update_checkUpdate as checkUpdate };
598
+ }
599
+
600
+ /** Await ms milliseconds */
601
+ declare const sleep: (ms: number) => Promise<void>;
602
+ declare const resetConsole: () => void;
603
+ declare const log: (message?: string, ...args: unknown[]) => void;
604
+ declare const specialFolder: (filePath: string, createIfNotExists?: boolean) => string;
605
+ declare const generateGroupUID: () => string;
606
+ declare const userAgent: (config: Interfaces.Config) => string;
607
+ declare const dotNotationToObject: (dotNot: KeyValObj, toObj?: KeyValObj) => KeyValObj;
608
+
609
+ declare const util_dotNotationToObject: typeof dotNotationToObject;
610
+ declare const util_generateGroupUID: typeof generateGroupUID;
611
+ declare const util_log: typeof log;
612
+ declare const util_resetConsole: typeof resetConsole;
613
+ declare const util_sleep: typeof sleep;
614
+ declare const util_specialFolder: typeof specialFolder;
615
+ declare const util_userAgent: typeof userAgent;
616
+ declare namespace util {
617
+ export { util_dotNotationToObject as dotNotationToObject, util_generateGroupUID as generateGroupUID, util_log as log, util_resetConsole as resetConsole, util_sleep as sleep, util_specialFolder as specialFolder, util_userAgent as userAgent };
619
618
  }
620
619
 
621
620
  export { type AccessToken, type AccessTokenInfo, type ApiMode, type ApiType, type AppAuth, type AppInfo, type AppKey, type ApplicationKind, type AuthScope, type CustomToken, type KeyVal, type KeyValArray, type KeyValObj, type KeyValRel, type KeyValSort, type KeyValString, type Method, type OwnerType, type ResAttributes, api$1 as clApi, application as clApplication, color as clColor, command as clCommand, config as clConfig, filter as clFilter, CLIBaseHelp as clHelp, output as clOutput, schema as clSchema, symbol as clSymbol, text as clText, token as clToken, update as clUpdate, util as clUtil };
package/lib/index.js CHANGED
@@ -1,9 +1,9 @@
1
- "use strict";var Ee=Object.create;var z=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)z(e,r,{get:t[r],enumerable:!0})},ue=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of ze(t))!Ie.call(e,i)&&i!==r&&z(e,i,{get:()=>t[i],enumerable:!(s=Se(t,i))||s.enumerable});return e};var O=(e,t,r)=>(r=e!=null?Ee(Oe(e)):{},ue(t||!e||!e.__esModule?z(r,"default",{value:e,enumerable:!0}):r,e)),Ke=e=>ue(z({},"__esModule",{value:!0}),e);var sr={};_(sr,{clApi:()=>J,clApplication:()=>Y,clColor:()=>A,clCommand:()=>X,clConfig:()=>u,clFilter:()=>le,clHelp:()=>E,clOutput:()=>Z,clSchema:()=>ce,clSymbol:()=>ne,clText:()=>oe,clToken:()=>se,clUpdate:()=>ie,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"],Me=["addresses","authorizations","bundles","captures","coupons","customer_addresses","customer_payment_sources","customer_subscriptions","customers","gift_cards","line_items","line_item_options","orders","payment_methods","price_tiers","prices","refunds","returns","shipments","shipping_categories","shipping_methods","sku_lists","sku_list_items","sku_options","skus","stock_items","stock_transfers","tags","tax_categories","transactions","voids"],je=["bundles","gift_cards","prices","promotions","sku_lists","sku_options","skus","stock_items"],De=["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:240,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:5e3,statuses:W,types:Me,max_queue_length:10,attachment_expiration:5},cleanups:{max_size:1e4,statuses:W,types:je,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:De,tag_name_max_length:25,tag_name_pattern:/^[0-9A-Za-z_-]{1,25}$/},provisioning:{default_subdomain:"provisioning",scope:"provisioning-api",applications:["user"]},metrics:{default_path:"metrics",scope:"metrics-api",applications:["integration","webapp"]},links:{default_domain:"c11r.link",linkable_resources:Le}},u=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(i=>{if(i.ok)return i;throw new Error(i.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 ${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}},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),I=(e,t)=>{let r={id:e.id,type:e.type,...e.attributes};return e.relationships&&Object.keys(e.relationships).forEach(s=>{let i=e.relationships[s].data;i?Array.isArray(i)?r[s]=i.map(n=>I(de(n,t),t)):r[s]=I(de(i,t),t):i===null&&(r[s]=null)}),r},G=e=>{let t;e.links&&delete e.links;let r=e.data,s=e.included;return Array.isArray(r)?t=r.map(i=>I(i,s)):t=I(r,s),t};var p={uncountableWords:["equipment","information","rice","money","species","series","fish","sheep","moose","deer","news"],pluralRules:[[/(m)an$/gi,"$1en"],[/(pe)rson$/gi,"$1ople"],[/(child)$/gi,"$1ren"],[/^(ox)$/gi,"$1en"],[/(ax|test)is$/gi,"$1es"],[/(octop|vir)us$/gi,"$1i"],[/(alias|status)$/gi,"$1es"],[/(bu)s$/gi,"$1ses"],[/(buffal|tomat|potat)o$/gi,"$1oes"],[/([ti])um$/gi,"$1a"],[/sis$/gi,"ses"],[/(?:([^f])fe|([lr])f)$/gi,"$1$2ves"],[/(hive)$/gi,"$1s"],[/([^aeiouy]|qu)y$/gi,"$1ies"],[/(x|ch|ss|sh)$/gi,"$1es"],[/(matr|vert|ind)ix|ex$/gi,"$1ices"],[/([m|l])ouse$/gi,"$1ice"],[/(quiz)$/gi,"$1zes"],[/s$/gi,"s"],[/$/gi,"s"]],singularRules:[[/(m)en$/gi,"$1an"],[/(pe)ople$/gi,"$1rson"],[/(child)ren$/gi,"$1"],[/([ti])a$/gi,"$1um"],[/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/gi,"$1$2sis"],[/(hive)s$/gi,"$1"],[/(tive)s$/gi,"$1"],[/(curve)s$/gi,"$1"],[/([lr])ves$/gi,"$1f"],[/([^fo])ves$/gi,"$1fe"],[/([^aeiouy]|qu)ies$/gi,"$1y"],[/(s)eries$/gi,"$1eries"],[/(m)ovies$/gi,"$1ovie"],[/(x|ch|ss|sh)es$/gi,"$1"],[/([m|l])ice$/gi,"$1ouse"],[/(bus)es$/gi,"$1"],[/(o)es$/gi,"$1"],[/(shoe)s$/gi,"$1"],[/(cris|ax|test)es$/gi,"$1is"],[/(octop|vir)i$/gi,"$1us"],[/(alias|status)es$/gi,"$1"],[/^(ox)en/gi,"$1"],[/(vert|ind)ices$/gi,"$1ex"],[/(matr)ices$/gi,"$1ix"],[/(quiz)zes$/gi,"$1"],[/s$/gi,""]],nonTitlecasedWords:["and","or","nor","a","an","the","so","but","to","of","at","by","from","into","on","onto","off","out","in","over","with","for"],idSuffix:/(_ids|_id)$/g,underbar:/_/g,spaceOrUnderbar:/[ _]/g,uppercase:/([A-Z])/g,underbarPrefix:/^_/,applyRules:function(e,t,r,s){if(s)e=s;else if(!r.includes(e.toLowerCase())){for(let n=0;n<t.length;n++)if(e.match(t[n][0])){e=e.replace(t[n][0],t[n][1]);break}}return e},pluralize:function(e,t){return p.applyRules(e,p.pluralRules,p.uncountableWords,t)},singularize:function(e,t){return p.applyRules(e,p.singularRules,p.uncountableWords,t)},camelize:function(e,t){let r=e.split("/");for(let s=0;s<r.length;s++){let i=r[s].split("_"),n=t&&s+1===r.length?1:0;for(let a=n;a<i.length;a++)i[a]=i[a].charAt(0).toUpperCase()+i[a].substring(1);r[s]=i.join("")}if(e=r.join("::"),t){let s=e.charAt(0).toLowerCase(),i=e.slice(1);e=s+i}return e},underscore:function(e){let t=e.split("::");for(let r=0;r<t.length;r++)t[r]=t[r].replace(p.uppercase,"_$1"),t[r]=t[r].replace(p.underbarPrefix,"");return e=t.join("/").toLowerCase(),e},humanize:function(e,t){return e=e.toLowerCase(),e=e.replace(p.idSuffix,""),e=e.replace(p.underbar," "),t||(e=p.capitalize(e)),e},capitalize:function(e){return e=e.toLowerCase(),e=e.substring(0,1).toUpperCase()+e.substring(1),e},dasherize:function(e){return e=e.replace(p.spaceOrUnderbar,"-"),e},camel2words:function(e,t){t?(e=p.camelize(e),e=p.underscore(e)):e=e.toLowerCase(),e=e.replace(p.underbar," ");let r=e.split(" ");for(let s=0;s<r.length;s++){let i=r[s].split("-");for(let n=0;n<i.length;n++)p.nonTitlecasedWords.includes(i[n].toLowerCase())||(i[n]=p.capitalize(i[n]));r[s]=i.join("-")}return e=r.join(" "),e=e.substring(0,1).toUpperCase()+e.substring(1),e},demodulize:function(e){let t=e.split("::");return e=t[t.length-1],e},tableize:function(e){return e=p.pluralize(p.underscore(e)),e},classify:function(e){return e=p.singularize(p.camelize(e)),e},foreignKey:function(e,t){return e=p.underscore(p.demodulize(e))+(t?"":"_")+"id",e},ordinalize:function(e){let t=e.split(" ");for(let r=0;r<t.length;r++){let s=parseInt(t[r]);if(Number.isNaN(s)){let i=t[r].substring(t[r].length-2),n=t[r].substring(t[r].length-1),a="th";i!=="11"&&i!=="12"&&i!=="13"&&(n==="1"?a="st":n==="2"?a="nd":n==="3"&&(a="rd")),t[r]+=a}}return e=t.join(" "),e}},w=p;var Ve=(e="core",t,r)=>`https://${(["core","metrics"].includes(e)&&t||e).toLowerCase()}.${r||u.api.default_domain}`,Ue=e=>{if(e)return e.substring(e.indexOf(".")+1)},We=e=>e===!0||e==="live"?"live":"test",Fe=(e,t)=>{let r=e.replace(/_/g," ");return t&&(r=w.singularize(r)),r};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),i,n;t==="live"?(i=s?u.api.requests_max_num_burst_cacheable:u.api.requests_max_num_burst,n=s?u.api.requests_max_num_avg_cacheable:u.api.requests_max_num_avg):(i=s?u.api.requests_max_num_burst_test_cacheable:u.api.requests_max_num_burst_test,n=s?u.api.requests_max_num_avg_test_cacheable:u.api.requests_max_num_avg_test);let a=u.api.requests_max_secs_burst/i,m=u.api.requests_max_secs_avg/n,g=r*a,v=r*m,f=e?.totalRequests,c=0;return f&&f>0?f>i&&(f>n?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(u.provisioning.scope)||e.api==="provisioning";var X={};_(X,{allFlags:()=>tt,checkISODateTimeValue:()=>nt,commandFlags:()=>et,findLongStringFlag:()=>st,fixDashedFlagValue:()=>it,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}),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,i=e.findIndex(a=>a.startsWith(r)),n=!1;if(i>-1){let a=e[i];if(a.includes("=")){let m=a.split("=");s=m.length===2?m[1]:"",n=!0}else s=e[i+1];return{value:s,index:i,single:n}}else return},it=(e,t,r,s)=>{let i="____",n=t.name||r,a=t.char;if(!n&&!a)return e;let m=n?n.startsWith("--")?n:`--${n}`:void 0,g=a?t.char.startsWith("-")?a:`-${a}`:void 0,v=e.findIndex(T=>g&&T.startsWith(g)||m&&T.startsWith(m));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(m&&f.startsWith(m))c=f.replace(m,"").trim(),f=m;else return e;if(c.startsWith("=")?(c=c.slice(1),pe=f+"="):c||(c=e[++v]),c.startsWith("-")||c.startsWith(i)){let T=c.startsWith(`${i}`)?c.replace(`${i}`,""):c.replace("-",`${i}-`);if(e[v]=pe+T,c.startsWith(i)&&s){let S=n?n.replace("--",""):void 0,P=Object.entries(s.flags).find(([U,Re])=>Re===c);P&&(!S||S===P[0])&&(s.flags[P[0]]=T);let V=Object.values(s.raw).find(U=>U.type==="flag"&&U.input===c);V&&(!S||S===V.flag)&&(V.input=T)}}return e},nt=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(i=>["id","type"].includes(i)?t?.fields.includes(i):!0),s=r.map(i=>i.toUpperCase().replace(/_/g," ")).join(";")+`
1
+ "use strict";var Ee=Object.create;var z=Object.defineProperty;var Se=Object.getOwnPropertyDescriptor;var ze=Object.getOwnPropertyNames;var Ie=Object.getPrototypeOf,Oe=Object.prototype.hasOwnProperty;var _=(e,t)=>{for(var r in t)z(e,r,{get:t[r],enumerable:!0})},ue=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of ze(t))!Oe.call(e,i)&&i!==r&&z(e,i,{get:()=>t[i],enumerable:!(s=Se(t,i))||s.enumerable});return e};var I=(e,t,r)=>(r=e!=null?Ee(Ie(e)):{},ue(t||!e||!e.__esModule?z(r,"default",{value:e,enumerable:!0}):r,e)),Ke=e=>ue(z({},"__esModule",{value:!0}),e);var sr={};_(sr,{clApi:()=>J,clApplication:()=>Y,clColor:()=>A,clCommand:()=>X,clConfig:()=>u,clFilter:()=>te,clHelp:()=>R,clOutput:()=>Z,clSchema:()=>ne,clSymbol:()=>re,clText:()=>se,clToken:()=>ce,clUpdate:()=>le,clUtil:()=>ae});module.exports=Ke(sr);var J={};_(J,{Operation:()=>G,baseURL:()=>Ve,execMode:()=>We,extractDomain:()=>Ue,humanizeResource:()=>Fe,isResourceCacheable:()=>ge,liveEnvironment:()=>He,request:()=>Ge,requestDataFile:()=>H,requestRateLimitDelay:()=>_e,requestRaw:()=>N,response:()=>Je,responseDenormalize:()=>F});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"],Me=["addresses","authorizations","bundles","captures","coupons","customer_addresses","customer_payment_sources","customer_subscriptions","customers","gift_cards","line_items","line_item_options","orders","payment_methods","price_tiers","prices","refunds","returns","shipments","shipping_categories","shipping_methods","sku_lists","sku_list_items","sku_options","skus","stock_items","stock_transfers","tags","tax_categories","transactions","voids"],je=["bundles","gift_cards","prices","promotions","sku_lists","sku_options","skus","stock_items"],De=["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:240,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:5e3,statuses:W,types:Me,max_queue_length:10,attachment_expiration:5},cleanups:{max_size:1e4,statuses:W,types:je,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:De,tag_name_max_length:25,tag_name_pattern:/^[0-9A-Za-z_-]{1,25}$/},provisioning:{default_subdomain:"provisioning",scope:"provisioning-api",applications:["user"]},metrics:{default_path:"metrics",scope:"metrics-api",applications:["integration","webapp"]},links:{default_domain:"c11r.link",linkable_resources:Le}},u=Pe;var p={uncountableWords:["equipment","information","rice","money","species","series","fish","sheep","moose","deer","news"],pluralRules:[[/(m)an$/gi,"$1en"],[/(pe)rson$/gi,"$1ople"],[/(child)$/gi,"$1ren"],[/^(ox)$/gi,"$1en"],[/(ax|test)is$/gi,"$1es"],[/(octop|vir)us$/gi,"$1i"],[/(alias|status)$/gi,"$1es"],[/(bu)s$/gi,"$1ses"],[/(buffal|tomat|potat)o$/gi,"$1oes"],[/([ti])um$/gi,"$1a"],[/sis$/gi,"ses"],[/(?:([^f])fe|([lr])f)$/gi,"$1$2ves"],[/(hive)$/gi,"$1s"],[/([^aeiouy]|qu)y$/gi,"$1ies"],[/(x|ch|ss|sh)$/gi,"$1es"],[/(matr|vert|ind)ix|ex$/gi,"$1ices"],[/([m|l])ouse$/gi,"$1ice"],[/(quiz)$/gi,"$1zes"],[/s$/gi,"s"],[/$/gi,"s"]],singularRules:[[/(m)en$/gi,"$1an"],[/(pe)ople$/gi,"$1rson"],[/(child)ren$/gi,"$1"],[/([ti])a$/gi,"$1um"],[/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/gi,"$1$2sis"],[/(hive)s$/gi,"$1"],[/(tive)s$/gi,"$1"],[/(curve)s$/gi,"$1"],[/([lr])ves$/gi,"$1f"],[/([^fo])ves$/gi,"$1fe"],[/([^aeiouy]|qu)ies$/gi,"$1y"],[/(s)eries$/gi,"$1eries"],[/(m)ovies$/gi,"$1ovie"],[/(x|ch|ss|sh)es$/gi,"$1"],[/([m|l])ice$/gi,"$1ouse"],[/(bus)es$/gi,"$1"],[/(o)es$/gi,"$1"],[/(shoe)s$/gi,"$1"],[/(cris|ax|test)es$/gi,"$1is"],[/(octop|vir)i$/gi,"$1us"],[/(alias|status)es$/gi,"$1"],[/^(ox)en/gi,"$1"],[/(vert|ind)ices$/gi,"$1ex"],[/(matr)ices$/gi,"$1ix"],[/(quiz)zes$/gi,"$1"],[/s$/gi,""]],nonTitlecasedWords:["and","or","nor","a","an","the","so","but","to","of","at","by","from","into","on","onto","off","out","in","over","with","for"],idSuffix:/(_ids|_id)$/g,underbar:/_/g,spaceOrUnderbar:/[ _]/g,uppercase:/([A-Z])/g,underbarPrefix:/^_/,applyRules:(e,t,r,s)=>{if(s)e=s;else if(!r.includes(e.toLowerCase())){for(let n=0;n<t.length;n++)if(e.match(t[n][0])){e=e.replace(t[n][0],t[n][1]);break}}return e},pluralize:(e,t)=>p.applyRules(e,p.pluralRules,p.uncountableWords,t),singularize:(e,t)=>p.applyRules(e,p.singularRules,p.uncountableWords,t),camelize:(e,t)=>{let r=e.split("/");for(let s=0;s<r.length;s++){let i=r[s].split("_"),n=t&&s+1===r.length?1:0;for(let a=n;a<i.length;a++)i[a]=i[a].charAt(0).toUpperCase()+i[a].substring(1);r[s]=i.join("")}if(e=r.join("::"),t){let s=e.charAt(0).toLowerCase(),i=e.slice(1);e=s+i}return e},underscore:e=>{let t=e.split("::");for(let r=0;r<t.length;r++)t[r]=t[r].replace(p.uppercase,"_$1"),t[r]=t[r].replace(p.underbarPrefix,"");return e=t.join("/").toLowerCase(),e},humanize:(e,t)=>(e=e.toLowerCase(),e=e.replace(p.idSuffix,""),e=e.replace(p.underbar," "),t||(e=p.capitalize(e)),e),capitalize:e=>(e=e.toLowerCase(),e=e.substring(0,1).toUpperCase()+e.substring(1),e),dasherize:e=>(e=e.replace(p.spaceOrUnderbar,"-"),e),camel2words:(e,t)=>{t?(e=p.camelize(e),e=p.underscore(e)):e=e.toLowerCase(),e=e.replace(p.underbar," ");let r=e.split(" ");for(let s=0;s<r.length;s++){let i=r[s].split("-");for(let n=0;n<i.length;n++)p.nonTitlecasedWords.includes(i[n].toLowerCase())||(i[n]=p.capitalize(i[n]));r[s]=i.join("-")}return e=r.join(" "),e=e.substring(0,1).toUpperCase()+e.substring(1),e},demodulize:e=>{let t=e.split("::");return e=t[t.length-1],e},tableize:e=>(e=p.pluralize(p.underscore(e)),e),classify:e=>(e=p.singularize(p.camelize(e)),e),foreignKey:(e,t)=>(e=p.underscore(p.demodulize(e))+(t?"":"_")+"id",e),ordinalize:e=>{let t=e.split(" ");for(let r=0;r<t.length;r++){let s=parseInt(t[r],10);if(Number.isNaN(s)){let i=t[r].substring(t[r].length-2),n=t[r].substring(t[r].length-1),a="th";i!=="11"&&i!=="12"&&i!=="13"&&(n==="1"?a="st":n==="2"?a="nd":n==="3"&&(a="rd")),t[r]+=a}}return e=t.join(" "),e}},w=p;var me=(e,t)=>t.find(r=>e.id===r.id&&e.type===r.type),O=(e,t)=>{let r={id:e.id,type:e.type,...e.attributes};return e.relationships&&Object.keys(e.relationships).forEach(s=>{let i=e.relationships[s].data;i?Array.isArray(i)?r[s]=i.map(n=>O(me(n,t),t)):r[s]=O(me(i,t),t):i===null&&(r[s]=null)}),r},F=e=>{let t;e.links&&delete e.links;let r=e.data,s=e.included;return Array.isArray(r)?t=r.map(i=>O(i,s)):t=O(r,s),t};var de=require("fs");var N=async(e,t,r)=>await(await fetch(new URL(`/api/${e.resource}`+(r?`/${r}`:""),e.baseUrl),{method:e.operation,headers:{"Content-Type":"application/vnd.api+json",Accept:"application/vnd.api+json",Authorization:`Bearer ${e.accessToken}`},body:JSON.stringify(t)}).then(i=>{if(i.ok)return i;throw new Error(i.statusText)})).json(),H=e=>{let t,r;try{t=(0,de.readFileSync)(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}},G=(r=>(r.Create="POST",r.Update="PATCH",r))(G||{});var Ve=(e="core",t,r)=>`https://${(["core","metrics"].includes(e)&&t||e).toLowerCase()}.${r||u.api.default_domain}`,Ue=e=>{if(e)return e.substring(e.indexOf(".")+1)},We=e=>e===!0||e==="live"?"live":"test",Fe=(e,t)=>{let r=e.replace(/_/g," ");return t&&(r=w.singularize(r)),r};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),i,n;t==="live"?(i=s?u.api.requests_max_num_burst_cacheable:u.api.requests_max_num_burst,n=s?u.api.requests_max_num_avg_cacheable:u.api.requests_max_num_avg):(i=s?u.api.requests_max_num_burst_test_cacheable:u.api.requests_max_num_burst_test,n=s?u.api.requests_max_num_avg_test_cacheable:u.api.requests_max_num_avg_test);let a=u.api.requests_max_secs_burst/i,m=u.api.requests_max_secs_avg/n,g=r*a,v=r*m,f=e?.totalRequests,c=0;return f&&f>0?f>i&&(f>n?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:N,readDataFile:H,rateLimitDelay:_e},Je={denormalize:F};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(u.provisioning.scope)||e.api==="provisioning";var X={};_(X,{allFlags:()=>tt,checkISODateTimeValue:()=>nt,commandFlags:()=>et,findLongStringFlag:()=>st,fixDashedFlagValue:()=>it,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}),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,i=e.findIndex(a=>a.startsWith(r)),n=!1;if(i>-1){let a=e[i];if(a.includes("=")){let m=a.split("=");s=m.length===2?m[1]:"",n=!0}else s=e[i+1];return{value:s,index:i,single:n}}else return},it=(e,t,r,s)=>{let i="____",n=t.name||r,a=t.char;if(!n&&!a)return e;let m=n?n.startsWith("--")?n:`--${n}`:void 0,g=a?t.char.startsWith("-")?a:`-${a}`:void 0,v=e.findIndex(T=>g&&T.startsWith(g)||m&&T.startsWith(m));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(m&&f.startsWith(m))c=f.replace(m,"").trim(),f=m;else return e;if(c.startsWith("=")?(c=c.slice(1),pe=f+"="):c||(c=e[++v]),c.startsWith("-")||c.startsWith(i)){let T=c.startsWith(`${i}`)?c.replace(`${i}`,""):c.replace("-",`${i}-`);if(e[v]=pe+T,c.startsWith(i)&&s){let S=n?n.replace("--",""):void 0,P=Object.entries(s.flags).find(([U,Re])=>Re===c);P&&(!S||S===P[0])&&(s.flags[P[0]]=T);let V=Object.values(s.raw).find(U=>U.type==="flag"&&U.input===c);V&&(!S||S===V.flag)&&(V.input=T)}}return e},nt=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(i=>["id","type"].includes(i)?t?.fields.includes(i):!0),s=r.map(i=>i.toUpperCase().replace(/_/g," ")).join(";")+`
2
2
  `;return e.forEach(i=>{s+=r.map(n=>i[n]).join(";")+`
3
- `}),s},ot=(e,t)=>e.padStart(e.length+Math.floor((t-e.length)/2)," ").padEnd(t," "),at=(e,t)=>e.reduce((r,s)=>{let i=Array.isArray(s[t])?s[t].join():s[t];return Math.max(r,String(i).length)},0),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 A={};_(A,{api:()=>Et,bg:()=>qt,black:()=>xt,blackBright:()=>vt,blue:()=>ht,blueBright:()=>q,bold:()=>ee,cli:()=>zt,cyan:()=>kt,cyanBright:()=>C,dim:()=>$t,green:()=>_t,greenBright:()=>Q,grey:()=>wt,hidden:()=>dt,italic:()=>k,magenta:()=>Tt,magentaBright:()=>At,msg:()=>St,red:()=>gt,redBright:()=>we,reset:()=>ut,style:()=>l,table:()=>Ot,type:()=>Rt,underline:()=>Ct,visible:()=>mt,white:()=>yt,whiteBright:()=>bt,yellow:()=>ft,yellowBright:()=>x});var o=O(require("chalk")),ut=o.default.reset,mt=o.default.visible,dt=o.default.hidden,gt=o.default.red,we=o.default.redBright,_t=o.default.green,Q=o.default.greenBright,ft=o.default.yellow,x=o.default.yellowBright,ht=o.default.blue,q=o.default.blueBright,yt=o.default.white,bt=o.default.whiteBright,xt=o.default.black,vt=o.default.blackBright,wt=o.default.grey,kt=o.default.cyan,C=o.default.cyanBright,Tt=o.default.magenta,At=o.default.magentaBright,ee=o.default.bold,$t=o.default.dim,Ct=o.default.underline,k=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:q,resource:ee,attribute:k,trigger:C,kind:C,live:Q,test:x,execMode:e=>e==="live"?l.live:l.test,success:Q,warning:x,error:we,arg:k,flag:k,command:k,value:k,alias:C,plugin:q,title:q,path:k,datetime:C,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:q};var se={};_(se,{buildAssertionPayload:()=>Ft,decodeAccessToken:()=>Te,generateAccessToken:()=>Lt,getAccessToken:()=>Pt,getTokenEnvironment:()=>Wt,isAccessTokenExpiring:()=>Ut,revokeAccessToken:()=>Vt});var j=O(require("jsonwebtoken"));var $=require("@commercelayer/js-auth");var re={};_(re,{dotNotationToObject:()=>te,generateGroupUID:()=>jt,log:()=>Bt,resetConsole:()=>Kt,sleep:()=>It,specialFolder:()=>Mt,userAgent:()=>Dt});var K=require("util"),B=require("path"),ke=require("os"),M=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,K.inspect)(e),process.stdout.write((0,K.format)(e,...t)+`
4
- `)},Mt=(e,t=!1)=>{let r=["desktop","home"],s=e.toLowerCase().split(/[\\\/]/g)[0];if(r.includes(s)){let n=(0,ke.homedir)();s==="desktop"&&(n+=`${B.sep}Desktop`),e=e.replace(s,n)}let i=(0,B.dirname)(e);return t&&!(0,M.existsSync)(i)&&(0,M.mkdirSync)(i,{recursive:!0}),e},jt=()=>{let e=Math.trunc(Math.random()*46656),t=Math.trunc(Math.random()*46656),r=("000"+e.toString(36)).slice(-3),s=("000"+t.toString(36)).slice(-3);return r+s},Dt=e=>`${e.name.replace(/@commercelayer\/cli-plugin/,"CLI")}/${e.version}`,te=(e,t)=>{let r=t||{};return Object.entries(e).forEach(([s,i])=>{let n=s.split("."),a=n[n.length-1],m=r;n.forEach(g=>{g===a?m[g]=i:m=m[g]||(m[g]={})})}),t&&Object.assign(t,r),r};var Te=e=>{let t=j.default.decode(e);if(t===null)throw new Error("Error decoding access token");return t},Lt=(e,t,r)=>{let i={...e,exp:Math.floor(Date.now()/1e3)+r*60,rand:Math.random()},n=u.api.token_encoding_algorithm,a=j.default.sign(i,t,{algorithm:n,noTimestamp:!0}),m=j.default.verify(a,t,{algorithms:[n]});return{accessToken:a,info:m,expMinutes:r}},Pt=async e=>{let t,r=e.scope?Array.isArray(e.scope)?e.scope.map(i=>i.trim()).join(","):e.scope:"",s={clientId:e.clientId,clientSecret:e.clientSecret,slug:e.slug,domain:e.domain,scope:r};if(e.email&&e.password?(s.username=e.email,s.password=e.password,t=await(0,$.authenticate)("password",s)):e.assertion?(s.assertion=e.assertion,t=await(0,$.authenticate)("urn:ietf:params:oauth:grant-type:jwt-bearer",s)):t=await(0,$.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,$.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"?Te(e):e).test?"test":"live";var Ft=(e,t,r)=>{let s="https://commercelayer.io/claims",i={[s]:{owner:{type:e,id:t}}};if(r&&Object.keys(r).length>0){let n=te(r);i[s].custom_claim=n}return i};var ie={};_(ie,{checkUpdate:()=>Ht});var R=O(require("chalk")),Ae=O(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:`-= ${R.default.bgWhite.black.bold(` ${e.description} `)} =-
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 i=Array.isArray(s[t])?s[t].join():s[t];return Math.max(r,String(i).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 A={};_(A,{api:()=>Et,bg:()=>qt,black:()=>xt,blackBright:()=>vt,blue:()=>ht,blueBright:()=>q,bold:()=>ee,cli:()=>zt,cyan:()=>kt,cyanBright:()=>C,dim:()=>$t,green:()=>_t,greenBright:()=>Q,grey:()=>wt,hidden:()=>dt,italic:()=>k,magenta:()=>Tt,magentaBright:()=>At,msg:()=>St,red:()=>gt,redBright:()=>we,reset:()=>ut,style:()=>l,table:()=>It,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,we=o.default.redBright,_t=o.default.green,Q=o.default.greenBright,ft=o.default.yellow,x=o.default.yellowBright,ht=o.default.blue,q=o.default.blueBright,yt=o.default.white,bt=o.default.whiteBright,xt=o.default.black,vt=o.default.blackBright,wt=o.default.grey,kt=o.default.cyan,C=o.default.cyanBright,Tt=o.default.magenta,At=o.default.magentaBright,ee=o.default.bold,$t=o.default.dim,Ct=o.default.underline,k=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:q,resource:ee,attribute:k,trigger:C,kind:C,live:Q,test:x,execMode:e=>e==="live"?l.live:l.test,success:Q,warning:x,error:we,arg:k,flag:k,command:k,value:k,alias:C,plugin:q,title:q,path:k,datetime:C,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},It={header:x.bold,key:q};var te={};_(te,{apply:()=>Bt,available:()=>Te,documentation:()=>Kt,filters:()=>Ae,list:()=>ke});var Ot=[{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"}],Kt=u.doc.core_filtering_data,ke=()=>Ae().map(e=>e.predicate.replace(/^\*/g,"")),Te=e=>{let t=e.startsWith("_")?e:`_${e}`;return ke().some(r=>t.endsWith(r))},Bt=(e,...t)=>{if(!Te(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},Ae=()=>[...Ot];var B=require("@oclif/core");var se={};_(se,{camelize:()=>Pt,capitalize:()=>K,dasherize:()=>Mt,pluralize:()=>Dt,singularize:()=>Lt,symbols:()=>b,underscorize:()=>jt});var re={};_(re,{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 K=e=>e&&w.capitalize(e),Mt=e=>e&&(e=e.toLocaleLowerCase(),e.replace(/[ _]/g,"-")),jt=e=>e&&(e=e.toLocaleLowerCase(),e.replace(/[ -]/g,"_")),Dt=(e,t)=>w.pluralize(e,t),Lt=(e,t)=>w.singularize(e,t),Pt=(e,t)=>w.camelize(e,t);var h=!1,ie=class extends B.CommandHelp{examples(t){return h&&console.log("---------- command.examples"),super.examples(t)}},R=class extends B.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"),await super.showCommandHelp(t)}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=K(s.description),s));return super.formatTopics(r)}formatCommands(t){return h&&console.log("---------- formatCommands"),super.formatCommands(t).split(`
4
+ `).map(r=>{let s=0;return r.split(" ").map(i=>(i||"").trim()!==""&&++s===2?K(i):i).join(" ")}).join(`
5
+ `)}formatCommand(t){return h&&console.log("---------- formatCommand"),super.formatCommand(t)}getCommandHelpClass(t){return h&&console.log("---------- getCommandHelpClass"),new ie(t,this.config,this.opts)}};var ne={};_(ne,{download:()=>Vt});var Vt=async e=>{let r=`https://data.${u.api.default_app_domain}/schemas/`,i=`openapi${e?"_"+e.replace(/\./g,"-"):""}.json`,n=r+i;return await(await fetch(n)).json()};var ce={};_(ce,{buildAssertionPayload:()=>er,decodeAccessToken:()=>Ce,generateAccessToken:()=>Jt,getAccessToken:()=>Yt,getTokenEnvironment:()=>Qt,isAccessTokenExpiring:()=>Zt,revokeAccessToken:()=>Xt});var $=require("@commercelayer/js-auth"),L=I(require("jsonwebtoken"));var ae={};_(ae,{dotNotationToObject:()=>oe,generateGroupUID:()=>Ht,log:()=>Ft,resetConsole:()=>Wt,sleep:()=>Ut,specialFolder:()=>Nt,userAgent:()=>Gt});var M=require("fs"),$e=require("os"),j=require("path"),D=require("util"),Ut=async e=>new Promise(t=>setTimeout(t,e)),Wt=()=>{process.stdout.write("\x1B[?25h\x1B[?7h")},Ft=(e="",...t)=>{e=typeof e=="string"?e:(0,D.inspect)(e),process.stdout.write((0,D.format)(e,...t)+`
6
+ `)},Nt=(e,t=!1)=>{let r=["desktop","home"],s=e.toLowerCase().split(/[\\/]/g)[0];if(r.includes(s)){let n=(0,$e.homedir)();s==="desktop"&&(n+=`${j.sep}Desktop`),e=e.replace(s,n)}let i=(0,j.dirname)(e);return t&&!(0,M.existsSync)(i)&&(0,M.mkdirSync)(i,{recursive:!0}),e},Ht=()=>{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},Gt=e=>`${e.name.replace(/@commercelayer\/cli-plugin/,"CLI")}/${e.version}`,oe=(e,t)=>{let r=t||{};return Object.entries(e).forEach(([s,i])=>{let n=s.split("."),a=n[n.length-1],m=r;n.forEach(g=>{g===a?m[g]=i:m=m[g]||(m[g]={})})}),t&&Object.assign(t,r),r};var Ce=e=>{let t=L.default.decode(e);if(t===null)throw new Error("Error decoding access token");return t},Jt=(e,t,r)=>{let i={...e,exp:Math.floor(Date.now()/1e3)+r*60,rand:Math.random()},n=u.api.token_encoding_algorithm,a=L.default.sign(i,t,{algorithm:n,noTimestamp:!0}),m=L.default.verify(a,t,{algorithms:[n]});return{accessToken:a,info:m,expMinutes:r}},Yt=async e=>{let t,r=e.scope?Array.isArray(e.scope)?e.scope.map(i=>i.trim()).join(","):e.scope:"",s={clientId:e.clientId,clientSecret:e.clientSecret,slug:e.slug,domain:e.domain,scope:r};if(e.email&&e.password?(s.username=e.email,s.password=e.password,t=await(0,$.authenticate)("password",s)):e.assertion?(s.assertion=e.assertion,t=await(0,$.authenticate)("urn:ietf:params:oauth:grant-type:jwt-bearer",s)):t=await(0,$.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},Xt=async(e,t)=>{let r=await(0,$.revoke)({...e,token:t});if(r.errors)throw new Error(r.errors[0].detail)},Zt=e=>{let r=Math.floor(Date.now()/1e3),s=Math.floor(new Date(e.expires).getTime()/1e3);return r>=s-30},Qt=e=>(typeof e=="string"?Ce(e):e).test?"test":"live";var er=(e,t,r)=>{let s="https://commercelayer.io/claims",i={[s]:{owner:{type:e,id:t}}};if(r&&Object.keys(r).length>0){let n=oe(r);i[s].custom_claim=n}return i};var le={};_(le,{checkUpdate:()=>rr});var E=I(require("chalk")),qe=I(require("update-notifier-cjs")),tr=1,rr=e=>{let t=(0,qe.default)({pkg:e,updateCheckInterval:36e5*tr});t.update&&t.notify({isGlobal:!1,message:`-= ${E.default.bgWhite.black.bold(` ${e.description} `)} =-
5
7
 
6
- New version available: ${R.default.dim("{currentVersion}")} -> ${R.default.green("{latestVersion}")}
7
- Run ${R.default.cyanBright("commercelayer plugins:update")} to update`})};var L=require("@oclif/core");var oe={};_(oe,{camelize:()=>Zt,capitalize:()=>D,dasherize:()=>Gt,pluralize:()=>Yt,singularize:()=>Xt,symbols:()=>b,underscorize:()=>Jt});var ne={};_(ne,{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 D=e=>e&&w.capitalize(e),Gt=e=>e&&(e=e.toLocaleLowerCase(),e.replace(/[ _]/g,"-")),Jt=e=>e&&(e=e.toLocaleLowerCase(),e.replace(/[ -]/g,"_")),Yt=(e,t)=>w.pluralize(e,t),Xt=(e,t)=>w.singularize(e,t),Zt=(e,t)=>w.camelize(e,t);var h=!1,ae=class extends L.CommandHelp{examples(t){return h&&console.log("---------- command.examples"),super.examples(t)}},E=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"),await super.showCommandHelp(t)}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=D(s.description),s));return super.formatTopics(r)}formatCommands(t){return h&&console.log("---------- formatCommands"),super.formatCommands(t).split(`
8
- `).map(r=>{let s=0;return r.split(" ").map(i=>(i||"").trim()!==""&&++s===2?D(i):i).join(" ")}).join(`
9
- `)}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.${u.api.default_app_domain}/schemas/`,i=`openapi${e?"_"+e.replace(/\./g,"-"):""}.json`,n=r+i;return await(await fetch(n)).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=u.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});
8
+ New version available: ${E.default.dim("{currentVersion}")} -> ${E.default.green("{latestVersion}")}
9
+ Run ${E.default.cyanBright("commercelayer plugins:update")} to update`})};0&&(module.exports={clApi,clApplication,clColor,clCommand,clConfig,clFilter,clHelp,clOutput,clSchema,clSymbol,clText,clToken,clUpdate,clUtil});
package/lib/index.mjs CHANGED
@@ -1,9 +1,9 @@
1
- var xe=Object.defineProperty;var h=(e,t)=>{for(var r in t)xe(e,r,{get:t[r],enumerable:!0})};var Z={};h(Z,{Operation:()=>L,baseURL:()=>qe,execMode:()=>Ee,extractDomain:()=>Re,humanizeResource:()=>Se,isResourceCacheable:()=>Y,liveEnvironment:()=>Oe,request:()=>Ie,requestDataFile:()=>D,requestRateLimitDelay:()=>X,requestRaw:()=>j,response:()=>Ke,responseDenormalize:()=>P});var M=["in_progress","pending","completed","interrupted"],ve=["addresses","bundles","coupons","customer_addresses","customer_payment_sources","customer_subscriptions","customers","gift_cards","line_items","line_item_options","orders","price_tiers","prices","shipping_categories","sku_lists","sku_list_items","sku_options","skus","stock_items","stock_transfers","tags","tax_categories"],we=["addresses","authorizations","bundles","captures","coupons","customer_addresses","customer_payment_sources","customer_subscriptions","customers","gift_cards","line_items","line_item_options","orders","payment_methods","price_tiers","prices","refunds","returns","shipments","shipping_categories","shipping_methods","sku_lists","sku_list_items","sku_options","skus","stock_items","stock_transfers","tags","tax_categories","transactions","voids"],ke=["bundles","gift_cards","prices","promotions","sku_lists","sku_options","skus","stock_items"],Te=["addresses","bundles","customers","coupons","gift_cards","line_items","line_item_options","orders","returns","skus","sku_options","promotions","external_promotions","fixed_amount_promotions","fixed_price_promotions","free_gift_promotions","free_shipping_promotions","percentage_discount_promotions"],Ae=["orders","skus","sku_lists"],b={erl_oauth_limit_live:30,erl_average_limit_cachable_live:1e3,erl_average_limit_cachable_test:500,erl_burst_limit_cachable_live:250,erl_burst_limit_cachable_test:125,erl_average_limit_uncachable_live:200,erl_average_limit_uncachable_test:100,erl_burst_limit_uncachable_live:50,erl_burst_limit_uncachable_test:25},$e={api:{default_domain:"commercelayer.io",default_app_domain:"commercelayer.app",default_stg_domain:"commercelayer.co",token_expiration_mins:240,token_encoding_algorithm:"HS512",token_owner_types:["Customer","User"],requests_max_num_burst:b.erl_burst_limit_uncachable_live,requests_max_num_burst_cacheable:b.erl_burst_limit_cachable_live,requests_max_num_burst_test:b.erl_burst_limit_uncachable_test,requests_max_num_burst_test_cacheable:b.erl_burst_limit_cachable_test,requests_max_num_avg:b.erl_average_limit_uncachable_live,requests_max_num_avg_cacheable:b.erl_average_limit_cachable_live,requests_max_num_avg_test:b.erl_average_limit_uncachable_test,requests_max_num_avg_test_cacheable:b.erl_average_limit_cachable_test,requests_max_num_oauth:b.erl_oauth_limit_live,requests_max_secs_burst:10,requests_max_secs_oauth:60,requests_max_secs_avg:60,page_max_size:25,page_default_size:10},application:{kinds:["dashboard","user","metrics","contentful","bundles","customers","datocms","exports","external","gift_cards","imports","integration","inventory","orders","price_lists","promotions","resources","returns","sales_channel","sanity","shipments","skus","sku_lists","stock_transfers","subscriptions","tags","webapp","webhooks","zapier"],login_scopes:["market","stock_location","store"]},imports:{max_size:1e4,statuses:M,types:ve,max_queue_length:10,attachment_expiration:5},exports:{max_size:5e3,statuses:M,types:we,max_queue_length:10,attachment_expiration:5},cleanups:{max_size:1e4,statuses:M,types:ke,max_queue_length:10},webhooks:{retry_number:5},cli:{applications:["integration","sales_channel","user"]},doc:{core:"https://docs.commercelayer.io/core/",core_api_reference:"https://docs.commercelayer.io/developers/v/api-reference",core_how_tos:"https://docs.commercelayer.io/core/v/how-tos/",core_raste_limits:"https://docs.commercelayer.io/core/rate-limits",core_filtering_data:"https://docs.commercelayer.io/core/filtering-data#list-of-predicates",metrics:"https://docs.commercelayer.io/metrics/",metrics_api_reference:"https://docs.commercelayer.io/metrics/v/api-reference-m/",provisioning:"https://docs.commercelayer.io/provisioning/",provisioning_api_reference:"https://docs.commercelayer.io/provisioning/v/api-reference-p/",imports_resources:"https://docs.commercelayer.io/api/importing-resources#supported-resources",exports_resources:"https://docs.commercelayer.io/core/exporting-resources#supported-resources",cleanups_resources:"https://docs.commercelayer.io/core/cleaning-resources#supported-resources",webhooks_events:"https://docs.commercelayer.io/api/real-time-webhooks#supported-events",tags_resources:"https://docs.commercelayer.io/core/v/api-reference/tags#taggable-resources",links_resources:"https://docs.commercelayer.io/core/v/api-reference/links"},tags:{max_resource_tags:10,taggable_resources:Te,tag_name_max_length:25,tag_name_pattern:/^[0-9A-Za-z_-]{1,25}$/},provisioning:{default_subdomain:"provisioning",scope:"provisioning-api",applications:["user"]},metrics:{default_path:"metrics",scope:"metrics-api",applications:["integration","webapp"]},links:{default_domain:"c11r.link",linkable_resources:Ae}},u=$e;import{readFileSync as Ce}from"fs";var j=async(e,t,r)=>await(await fetch(new URL(`/api/${e.resource}`+(r?`/${r}`:""),e.baseUrl),{method:e.operation,headers:{"Content-Type":"application/vnd.api+json",Accept:"application/vnd.api+json",Authorization:`Bearer ${e.accessToken}`},body:JSON.stringify(t)}).then(i=>{if(i.ok)return i;throw new Error(i.statusText)})).json(),D=e=>{let t,r;try{t=Ce(e,"utf-8")}catch{throw new Error(`Unable to find or open the data file ${$.msg.error(e)}`)}try{r=JSON.parse(t)}catch{throw new Error(`Unable to parse the data file ${$.msg.error(e)}: invalid JSON format`)}return r.data?r:{data:r}},L=(r=>(r.Create="POST",r.Update="PATCH",r))(L||{});var J=(e,t)=>t.find(r=>e.id===r.id&&e.type===r.type),E=(e,t)=>{let r={id:e.id,type:e.type,...e.attributes};return e.relationships&&Object.keys(e.relationships).forEach(s=>{let i=e.relationships[s].data;i?Array.isArray(i)?r[s]=i.map(n=>E(J(n,t),t)):r[s]=E(J(i,t),t):i===null&&(r[s]=null)}),r},P=e=>{let t;e.links&&delete e.links;let r=e.data,s=e.included;return Array.isArray(r)?t=r.map(i=>E(i,s)):t=E(r,s),t};var p={uncountableWords:["equipment","information","rice","money","species","series","fish","sheep","moose","deer","news"],pluralRules:[[/(m)an$/gi,"$1en"],[/(pe)rson$/gi,"$1ople"],[/(child)$/gi,"$1ren"],[/^(ox)$/gi,"$1en"],[/(ax|test)is$/gi,"$1es"],[/(octop|vir)us$/gi,"$1i"],[/(alias|status)$/gi,"$1es"],[/(bu)s$/gi,"$1ses"],[/(buffal|tomat|potat)o$/gi,"$1oes"],[/([ti])um$/gi,"$1a"],[/sis$/gi,"ses"],[/(?:([^f])fe|([lr])f)$/gi,"$1$2ves"],[/(hive)$/gi,"$1s"],[/([^aeiouy]|qu)y$/gi,"$1ies"],[/(x|ch|ss|sh)$/gi,"$1es"],[/(matr|vert|ind)ix|ex$/gi,"$1ices"],[/([m|l])ouse$/gi,"$1ice"],[/(quiz)$/gi,"$1zes"],[/s$/gi,"s"],[/$/gi,"s"]],singularRules:[[/(m)en$/gi,"$1an"],[/(pe)ople$/gi,"$1rson"],[/(child)ren$/gi,"$1"],[/([ti])a$/gi,"$1um"],[/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/gi,"$1$2sis"],[/(hive)s$/gi,"$1"],[/(tive)s$/gi,"$1"],[/(curve)s$/gi,"$1"],[/([lr])ves$/gi,"$1f"],[/([^fo])ves$/gi,"$1fe"],[/([^aeiouy]|qu)ies$/gi,"$1y"],[/(s)eries$/gi,"$1eries"],[/(m)ovies$/gi,"$1ovie"],[/(x|ch|ss|sh)es$/gi,"$1"],[/([m|l])ice$/gi,"$1ouse"],[/(bus)es$/gi,"$1"],[/(o)es$/gi,"$1"],[/(shoe)s$/gi,"$1"],[/(cris|ax|test)es$/gi,"$1is"],[/(octop|vir)i$/gi,"$1us"],[/(alias|status)es$/gi,"$1"],[/^(ox)en/gi,"$1"],[/(vert|ind)ices$/gi,"$1ex"],[/(matr)ices$/gi,"$1ix"],[/(quiz)zes$/gi,"$1"],[/s$/gi,""]],nonTitlecasedWords:["and","or","nor","a","an","the","so","but","to","of","at","by","from","into","on","onto","off","out","in","over","with","for"],idSuffix:/(_ids|_id)$/g,underbar:/_/g,spaceOrUnderbar:/[ _]/g,uppercase:/([A-Z])/g,underbarPrefix:/^_/,applyRules:function(e,t,r,s){if(s)e=s;else if(!r.includes(e.toLowerCase())){for(let n=0;n<t.length;n++)if(e.match(t[n][0])){e=e.replace(t[n][0],t[n][1]);break}}return e},pluralize:function(e,t){return p.applyRules(e,p.pluralRules,p.uncountableWords,t)},singularize:function(e,t){return p.applyRules(e,p.singularRules,p.uncountableWords,t)},camelize:function(e,t){let r=e.split("/");for(let s=0;s<r.length;s++){let i=r[s].split("_"),n=t&&s+1===r.length?1:0;for(let a=n;a<i.length;a++)i[a]=i[a].charAt(0).toUpperCase()+i[a].substring(1);r[s]=i.join("")}if(e=r.join("::"),t){let s=e.charAt(0).toLowerCase(),i=e.slice(1);e=s+i}return e},underscore:function(e){let t=e.split("::");for(let r=0;r<t.length;r++)t[r]=t[r].replace(p.uppercase,"_$1"),t[r]=t[r].replace(p.underbarPrefix,"");return e=t.join("/").toLowerCase(),e},humanize:function(e,t){return e=e.toLowerCase(),e=e.replace(p.idSuffix,""),e=e.replace(p.underbar," "),t||(e=p.capitalize(e)),e},capitalize:function(e){return e=e.toLowerCase(),e=e.substring(0,1).toUpperCase()+e.substring(1),e},dasherize:function(e){return e=e.replace(p.spaceOrUnderbar,"-"),e},camel2words:function(e,t){t?(e=p.camelize(e),e=p.underscore(e)):e=e.toLowerCase(),e=e.replace(p.underbar," ");let r=e.split(" ");for(let s=0;s<r.length;s++){let i=r[s].split("-");for(let n=0;n<i.length;n++)p.nonTitlecasedWords.includes(i[n].toLowerCase())||(i[n]=p.capitalize(i[n]));r[s]=i.join("-")}return e=r.join(" "),e=e.substring(0,1).toUpperCase()+e.substring(1),e},demodulize:function(e){let t=e.split("::");return e=t[t.length-1],e},tableize:function(e){return e=p.pluralize(p.underscore(e)),e},classify:function(e){return e=p.singularize(p.camelize(e)),e},foreignKey:function(e,t){return e=p.underscore(p.demodulize(e))+(t?"":"_")+"id",e},ordinalize:function(e){let t=e.split(" ");for(let r=0;r<t.length;r++){let s=parseInt(t[r]);if(Number.isNaN(s)){let i=t[r].substring(t[r].length-2),n=t[r].substring(t[r].length-1),a="th";i!=="11"&&i!=="12"&&i!=="13"&&(n==="1"?a="st":n==="2"?a="nd":n==="3"&&(a="rd")),t[r]+=a}}return e=t.join(" "),e}},k=p;var qe=(e="core",t,r)=>`https://${(["core","metrics"].includes(e)&&t||e).toLowerCase()}.${r||u.api.default_domain}`,Re=e=>{if(e)return e.substring(e.indexOf(".")+1)},Ee=e=>e===!0||e==="live"?"live":"test",Se=(e,t)=>{let r=e.replace(/_/g," ");return t&&(r=k.singularize(r)),r};var ze=["bundles","imports","markets","prices","price_lists","promotions","buy_x_pay_y_promotions","external_promotions","fixed_amount_promotions","fixed_price_promotions","free_gift_promotions","free_shipping_promotions","percentage_discount_promotions","skus","sku_options","stock_items","stock_locations"],Y=(e,t)=>ze.includes(e||"")&&(t||"GET").toUpperCase()==="GET",Oe=e=>e==="live",X=e=>{let t=e?.environment||"test",r=e?.parallelRequests||1,s=Y(e?.resourceType,e?.method),i,n;t==="live"?(i=s?u.api.requests_max_num_burst_cacheable:u.api.requests_max_num_burst,n=s?u.api.requests_max_num_avg_cacheable:u.api.requests_max_num_avg):(i=s?u.api.requests_max_num_burst_test_cacheable:u.api.requests_max_num_burst_test,n=s?u.api.requests_max_num_avg_test_cacheable:u.api.requests_max_num_avg_test);let a=u.api.requests_max_secs_burst/i,m=u.api.requests_max_secs_avg/n,_=r*a,w=r*m,f=e?.totalRequests,c=0;return f&&f>0?f>i&&(f>n?c=w:c=_):c=Math.max(_,w),c=c*1e3,e?.minimumDelay&&(c=Math.max(e.minimumDelay,c)),e?.securityDelay&&(c+=e.securityDelay),c=Math.ceil(c),c};var Ie={raw:j,readDataFile:D,rateLimitDelay:X},Ke={denormalize:P};var ee={};h(ee,{appKey:()=>Be,appKeyMatch:()=>je,appKeyValid:()=>Me,arrayScope:()=>Q,isProvisioningApp:()=>De});var Be=()=>Date.now().toString(36),Me=e=>e.key!==void 0&&e.key!=="",je=(e,t)=>{let r=e!==void 0,s=t!==void 0;return!r&&!s||r&&s&&e.key===t.key},Q=e=>{if(!e)return[];if(Array.isArray(e))return e;let t=e.replace(/[ ,;]/g,"|").split("|");return Array.isArray(t)?t:[t]},De=e=>Q(e.scope).includes(u.provisioning.scope)||e.api==="provisioning";var te={};h(te,{allFlags:()=>Pe,checkISODateTimeValue:()=>Fe,commandFlags:()=>Le,findLongStringFlag:()=>Ue,fixDashedFlagValue:()=>We,fixValueType:()=>Ve});var Le=(e,t)=>{let r={...e};if(t)for(let s of t)delete r[s];return r},Pe=e=>({...e.flags,...e.baseFlags}),Ve=e=>{let t=e;return t==="null"?t=null:Number(t)==t?t=Number(t):t=t==="true"?!0:t==="false"?!1:t,t},Ue=(e,t)=>{let r=t.startsWith("--")?t:`--${t}`,s,i=e.findIndex(a=>a.startsWith(r)),n=!1;if(i>-1){let a=e[i];if(a.includes("=")){let m=a.split("=");s=m.length===2?m[1]:"",n=!0}else s=e[i+1];return{value:s,index:i,single:n}}else return},We=(e,t,r,s)=>{let i="____",n=t.name||r,a=t.char;if(!n&&!a)return e;let m=n?n.startsWith("--")?n:`--${n}`:void 0,_=a?t.char.startsWith("-")?a:`-${a}`:void 0,w=e.findIndex(A=>_&&A.startsWith(_)||m&&A.startsWith(m));if(w<0)return e;let f=e[w],c="",G="";if(_&&f.startsWith(_))c=f.replace(_,"").trim(),f=_;else if(m&&f.startsWith(m))c=f.replace(m,"").trim(),f=m;else return e;if(c.startsWith("=")?(c=c.slice(1),G=f+"="):c||(c=e[++w]),c.startsWith("-")||c.startsWith(i)){let A=c.startsWith(`${i}`)?c.replace(`${i}`,""):c.replace("-",`${i}-`);if(e[w]=G+A,c.startsWith(i)&&s){let R=n?n.replace("--",""):void 0,I=Object.entries(s.flags).find(([B,be])=>be===c);I&&(!R||R===I[0])&&(s.flags[I[0]]=A);let K=Object.values(s.raw).find(B=>B.type==="flag"&&B.input===c);K&&(!R||R===K.flag)&&(K.input=A)}}return e},Fe=e=>{if(!e)throw Error("Date is empty");try{let t=Date.parse(e);if(Number.isNaN(t))throw new Error("Invalid date");return new Date(t)}catch{throw new Error("Error parsing date: "+e)}};var oe={};h(oe,{center:()=>He,cleanDate:()=>Je,formatError:()=>Xe,formatOutput:()=>ne,localeDate:()=>Ye,maxLength:()=>Ge,printCSV:()=>ie,printJSON:()=>se,printObject:()=>re});import{inspect as Ne}from"util";var re=(e,t)=>Ne(e,{showHidden:!1,depth:null,colors:t?.color===void 0?!0:t.color,sorted:t?.sort===void 0?!1:t?.sort,maxArrayLength:1/0,breakLength:t?.width||120}),se=(e,t)=>JSON.stringify(e,null,t?.unformatted?void 0:t?.tabSize||4),ie=(e,t)=>{if(!e||e.length===0)return"";let r=Object.keys(e[0]).filter(i=>["id","type"].includes(i)?t?.fields.includes(i):!0),s=r.map(i=>i.toUpperCase().replace(/_/g," ")).join(";")+`
1
+ var xe=Object.defineProperty;var h=(e,t)=>{for(var r in t)xe(e,r,{get:t[r],enumerable:!0})};var Z={};h(Z,{Operation:()=>P,baseURL:()=>qe,execMode:()=>Ee,extractDomain:()=>Re,humanizeResource:()=>Se,isResourceCacheable:()=>Y,liveEnvironment:()=>Ie,request:()=>Oe,requestDataFile:()=>L,requestRateLimitDelay:()=>X,requestRaw:()=>D,response:()=>Ke,responseDenormalize:()=>j});var M=["in_progress","pending","completed","interrupted"],ve=["addresses","bundles","coupons","customer_addresses","customer_payment_sources","customer_subscriptions","customers","gift_cards","line_items","line_item_options","orders","price_tiers","prices","shipping_categories","sku_lists","sku_list_items","sku_options","skus","stock_items","stock_transfers","tags","tax_categories"],we=["addresses","authorizations","bundles","captures","coupons","customer_addresses","customer_payment_sources","customer_subscriptions","customers","gift_cards","line_items","line_item_options","orders","payment_methods","price_tiers","prices","refunds","returns","shipments","shipping_categories","shipping_methods","sku_lists","sku_list_items","sku_options","skus","stock_items","stock_transfers","tags","tax_categories","transactions","voids"],ke=["bundles","gift_cards","prices","promotions","sku_lists","sku_options","skus","stock_items"],Te=["addresses","bundles","customers","coupons","gift_cards","line_items","line_item_options","orders","returns","skus","sku_options","promotions","external_promotions","fixed_amount_promotions","fixed_price_promotions","free_gift_promotions","free_shipping_promotions","percentage_discount_promotions"],Ae=["orders","skus","sku_lists"],b={erl_oauth_limit_live:30,erl_average_limit_cachable_live:1e3,erl_average_limit_cachable_test:500,erl_burst_limit_cachable_live:250,erl_burst_limit_cachable_test:125,erl_average_limit_uncachable_live:200,erl_average_limit_uncachable_test:100,erl_burst_limit_uncachable_live:50,erl_burst_limit_uncachable_test:25},$e={api:{default_domain:"commercelayer.io",default_app_domain:"commercelayer.app",default_stg_domain:"commercelayer.co",token_expiration_mins:240,token_encoding_algorithm:"HS512",token_owner_types:["Customer","User"],requests_max_num_burst:b.erl_burst_limit_uncachable_live,requests_max_num_burst_cacheable:b.erl_burst_limit_cachable_live,requests_max_num_burst_test:b.erl_burst_limit_uncachable_test,requests_max_num_burst_test_cacheable:b.erl_burst_limit_cachable_test,requests_max_num_avg:b.erl_average_limit_uncachable_live,requests_max_num_avg_cacheable:b.erl_average_limit_cachable_live,requests_max_num_avg_test:b.erl_average_limit_uncachable_test,requests_max_num_avg_test_cacheable:b.erl_average_limit_cachable_test,requests_max_num_oauth:b.erl_oauth_limit_live,requests_max_secs_burst:10,requests_max_secs_oauth:60,requests_max_secs_avg:60,page_max_size:25,page_default_size:10},application:{kinds:["dashboard","user","metrics","contentful","bundles","customers","datocms","exports","external","gift_cards","imports","integration","inventory","orders","price_lists","promotions","resources","returns","sales_channel","sanity","shipments","skus","sku_lists","stock_transfers","subscriptions","tags","webapp","webhooks","zapier"],login_scopes:["market","stock_location","store"]},imports:{max_size:1e4,statuses:M,types:ve,max_queue_length:10,attachment_expiration:5},exports:{max_size:5e3,statuses:M,types:we,max_queue_length:10,attachment_expiration:5},cleanups:{max_size:1e4,statuses:M,types:ke,max_queue_length:10},webhooks:{retry_number:5},cli:{applications:["integration","sales_channel","user"]},doc:{core:"https://docs.commercelayer.io/core/",core_api_reference:"https://docs.commercelayer.io/developers/v/api-reference",core_how_tos:"https://docs.commercelayer.io/core/v/how-tos/",core_raste_limits:"https://docs.commercelayer.io/core/rate-limits",core_filtering_data:"https://docs.commercelayer.io/core/filtering-data#list-of-predicates",metrics:"https://docs.commercelayer.io/metrics/",metrics_api_reference:"https://docs.commercelayer.io/metrics/v/api-reference-m/",provisioning:"https://docs.commercelayer.io/provisioning/",provisioning_api_reference:"https://docs.commercelayer.io/provisioning/v/api-reference-p/",imports_resources:"https://docs.commercelayer.io/api/importing-resources#supported-resources",exports_resources:"https://docs.commercelayer.io/core/exporting-resources#supported-resources",cleanups_resources:"https://docs.commercelayer.io/core/cleaning-resources#supported-resources",webhooks_events:"https://docs.commercelayer.io/api/real-time-webhooks#supported-events",tags_resources:"https://docs.commercelayer.io/core/v/api-reference/tags#taggable-resources",links_resources:"https://docs.commercelayer.io/core/v/api-reference/links"},tags:{max_resource_tags:10,taggable_resources:Te,tag_name_max_length:25,tag_name_pattern:/^[0-9A-Za-z_-]{1,25}$/},provisioning:{default_subdomain:"provisioning",scope:"provisioning-api",applications:["user"]},metrics:{default_path:"metrics",scope:"metrics-api",applications:["integration","webapp"]},links:{default_domain:"c11r.link",linkable_resources:Ae}},u=$e;var p={uncountableWords:["equipment","information","rice","money","species","series","fish","sheep","moose","deer","news"],pluralRules:[[/(m)an$/gi,"$1en"],[/(pe)rson$/gi,"$1ople"],[/(child)$/gi,"$1ren"],[/^(ox)$/gi,"$1en"],[/(ax|test)is$/gi,"$1es"],[/(octop|vir)us$/gi,"$1i"],[/(alias|status)$/gi,"$1es"],[/(bu)s$/gi,"$1ses"],[/(buffal|tomat|potat)o$/gi,"$1oes"],[/([ti])um$/gi,"$1a"],[/sis$/gi,"ses"],[/(?:([^f])fe|([lr])f)$/gi,"$1$2ves"],[/(hive)$/gi,"$1s"],[/([^aeiouy]|qu)y$/gi,"$1ies"],[/(x|ch|ss|sh)$/gi,"$1es"],[/(matr|vert|ind)ix|ex$/gi,"$1ices"],[/([m|l])ouse$/gi,"$1ice"],[/(quiz)$/gi,"$1zes"],[/s$/gi,"s"],[/$/gi,"s"]],singularRules:[[/(m)en$/gi,"$1an"],[/(pe)ople$/gi,"$1rson"],[/(child)ren$/gi,"$1"],[/([ti])a$/gi,"$1um"],[/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/gi,"$1$2sis"],[/(hive)s$/gi,"$1"],[/(tive)s$/gi,"$1"],[/(curve)s$/gi,"$1"],[/([lr])ves$/gi,"$1f"],[/([^fo])ves$/gi,"$1fe"],[/([^aeiouy]|qu)ies$/gi,"$1y"],[/(s)eries$/gi,"$1eries"],[/(m)ovies$/gi,"$1ovie"],[/(x|ch|ss|sh)es$/gi,"$1"],[/([m|l])ice$/gi,"$1ouse"],[/(bus)es$/gi,"$1"],[/(o)es$/gi,"$1"],[/(shoe)s$/gi,"$1"],[/(cris|ax|test)es$/gi,"$1is"],[/(octop|vir)i$/gi,"$1us"],[/(alias|status)es$/gi,"$1"],[/^(ox)en/gi,"$1"],[/(vert|ind)ices$/gi,"$1ex"],[/(matr)ices$/gi,"$1ix"],[/(quiz)zes$/gi,"$1"],[/s$/gi,""]],nonTitlecasedWords:["and","or","nor","a","an","the","so","but","to","of","at","by","from","into","on","onto","off","out","in","over","with","for"],idSuffix:/(_ids|_id)$/g,underbar:/_/g,spaceOrUnderbar:/[ _]/g,uppercase:/([A-Z])/g,underbarPrefix:/^_/,applyRules:(e,t,r,s)=>{if(s)e=s;else if(!r.includes(e.toLowerCase())){for(let n=0;n<t.length;n++)if(e.match(t[n][0])){e=e.replace(t[n][0],t[n][1]);break}}return e},pluralize:(e,t)=>p.applyRules(e,p.pluralRules,p.uncountableWords,t),singularize:(e,t)=>p.applyRules(e,p.singularRules,p.uncountableWords,t),camelize:(e,t)=>{let r=e.split("/");for(let s=0;s<r.length;s++){let i=r[s].split("_"),n=t&&s+1===r.length?1:0;for(let a=n;a<i.length;a++)i[a]=i[a].charAt(0).toUpperCase()+i[a].substring(1);r[s]=i.join("")}if(e=r.join("::"),t){let s=e.charAt(0).toLowerCase(),i=e.slice(1);e=s+i}return e},underscore:e=>{let t=e.split("::");for(let r=0;r<t.length;r++)t[r]=t[r].replace(p.uppercase,"_$1"),t[r]=t[r].replace(p.underbarPrefix,"");return e=t.join("/").toLowerCase(),e},humanize:(e,t)=>(e=e.toLowerCase(),e=e.replace(p.idSuffix,""),e=e.replace(p.underbar," "),t||(e=p.capitalize(e)),e),capitalize:e=>(e=e.toLowerCase(),e=e.substring(0,1).toUpperCase()+e.substring(1),e),dasherize:e=>(e=e.replace(p.spaceOrUnderbar,"-"),e),camel2words:(e,t)=>{t?(e=p.camelize(e),e=p.underscore(e)):e=e.toLowerCase(),e=e.replace(p.underbar," ");let r=e.split(" ");for(let s=0;s<r.length;s++){let i=r[s].split("-");for(let n=0;n<i.length;n++)p.nonTitlecasedWords.includes(i[n].toLowerCase())||(i[n]=p.capitalize(i[n]));r[s]=i.join("-")}return e=r.join(" "),e=e.substring(0,1).toUpperCase()+e.substring(1),e},demodulize:e=>{let t=e.split("::");return e=t[t.length-1],e},tableize:e=>(e=p.pluralize(p.underscore(e)),e),classify:e=>(e=p.singularize(p.camelize(e)),e),foreignKey:(e,t)=>(e=p.underscore(p.demodulize(e))+(t?"":"_")+"id",e),ordinalize:e=>{let t=e.split(" ");for(let r=0;r<t.length;r++){let s=parseInt(t[r],10);if(Number.isNaN(s)){let i=t[r].substring(t[r].length-2),n=t[r].substring(t[r].length-1),a="th";i!=="11"&&i!=="12"&&i!=="13"&&(n==="1"?a="st":n==="2"?a="nd":n==="3"&&(a="rd")),t[r]+=a}}return e=t.join(" "),e}},k=p;var J=(e,t)=>t.find(r=>e.id===r.id&&e.type===r.type),E=(e,t)=>{let r={id:e.id,type:e.type,...e.attributes};return e.relationships&&Object.keys(e.relationships).forEach(s=>{let i=e.relationships[s].data;i?Array.isArray(i)?r[s]=i.map(n=>E(J(n,t),t)):r[s]=E(J(i,t),t):i===null&&(r[s]=null)}),r},j=e=>{let t;e.links&&delete e.links;let r=e.data,s=e.included;return Array.isArray(r)?t=r.map(i=>E(i,s)):t=E(r,s),t};import{readFileSync as Ce}from"fs";var D=async(e,t,r)=>await(await fetch(new URL(`/api/${e.resource}`+(r?`/${r}`:""),e.baseUrl),{method:e.operation,headers:{"Content-Type":"application/vnd.api+json",Accept:"application/vnd.api+json",Authorization:`Bearer ${e.accessToken}`},body:JSON.stringify(t)}).then(i=>{if(i.ok)return i;throw new Error(i.statusText)})).json(),L=e=>{let t,r;try{t=Ce(e,"utf-8")}catch{throw new Error(`Unable to find or open the data file ${$.msg.error(e)}`)}try{r=JSON.parse(t)}catch{throw new Error(`Unable to parse the data file ${$.msg.error(e)}: invalid JSON format`)}return r.data?r:{data:r}},P=(r=>(r.Create="POST",r.Update="PATCH",r))(P||{});var qe=(e="core",t,r)=>`https://${(["core","metrics"].includes(e)&&t||e).toLowerCase()}.${r||u.api.default_domain}`,Re=e=>{if(e)return e.substring(e.indexOf(".")+1)},Ee=e=>e===!0||e==="live"?"live":"test",Se=(e,t)=>{let r=e.replace(/_/g," ");return t&&(r=k.singularize(r)),r};var ze=["bundles","imports","markets","prices","price_lists","promotions","buy_x_pay_y_promotions","external_promotions","fixed_amount_promotions","fixed_price_promotions","free_gift_promotions","free_shipping_promotions","percentage_discount_promotions","skus","sku_options","stock_items","stock_locations"],Y=(e,t)=>ze.includes(e||"")&&(t||"GET").toUpperCase()==="GET",Ie=e=>e==="live",X=e=>{let t=e?.environment||"test",r=e?.parallelRequests||1,s=Y(e?.resourceType,e?.method),i,n;t==="live"?(i=s?u.api.requests_max_num_burst_cacheable:u.api.requests_max_num_burst,n=s?u.api.requests_max_num_avg_cacheable:u.api.requests_max_num_avg):(i=s?u.api.requests_max_num_burst_test_cacheable:u.api.requests_max_num_burst_test,n=s?u.api.requests_max_num_avg_test_cacheable:u.api.requests_max_num_avg_test);let a=u.api.requests_max_secs_burst/i,m=u.api.requests_max_secs_avg/n,_=r*a,w=r*m,f=e?.totalRequests,c=0;return f&&f>0?f>i&&(f>n?c=w:c=_):c=Math.max(_,w),c=c*1e3,e?.minimumDelay&&(c=Math.max(e.minimumDelay,c)),e?.securityDelay&&(c+=e.securityDelay),c=Math.ceil(c),c};var Oe={raw:D,readDataFile:L,rateLimitDelay:X},Ke={denormalize:j};var ee={};h(ee,{appKey:()=>Be,appKeyMatch:()=>je,appKeyValid:()=>Me,arrayScope:()=>Q,isProvisioningApp:()=>De});var Be=()=>Date.now().toString(36),Me=e=>e.key!==void 0&&e.key!=="",je=(e,t)=>{let r=e!==void 0,s=t!==void 0;return!r&&!s||r&&s&&e.key===t.key},Q=e=>{if(!e)return[];if(Array.isArray(e))return e;let t=e.replace(/[ ,;]/g,"|").split("|");return Array.isArray(t)?t:[t]},De=e=>Q(e.scope).includes(u.provisioning.scope)||e.api==="provisioning";var te={};h(te,{allFlags:()=>Pe,checkISODateTimeValue:()=>Fe,commandFlags:()=>Le,findLongStringFlag:()=>Ue,fixDashedFlagValue:()=>We,fixValueType:()=>Ve});var Le=(e,t)=>{let r={...e};if(t)for(let s of t)delete r[s];return r},Pe=e=>({...e.flags,...e.baseFlags}),Ve=e=>{let t=e;return t==="null"?t=null:Number(t)==t?t=Number(t):t=t==="true"?!0:t==="false"?!1:t,t},Ue=(e,t)=>{let r=t.startsWith("--")?t:`--${t}`,s,i=e.findIndex(a=>a.startsWith(r)),n=!1;if(i>-1){let a=e[i];if(a.includes("=")){let m=a.split("=");s=m.length===2?m[1]:"",n=!0}else s=e[i+1];return{value:s,index:i,single:n}}else return},We=(e,t,r,s)=>{let i="____",n=t.name||r,a=t.char;if(!n&&!a)return e;let m=n?n.startsWith("--")?n:`--${n}`:void 0,_=a?t.char.startsWith("-")?a:`-${a}`:void 0,w=e.findIndex(A=>_&&A.startsWith(_)||m&&A.startsWith(m));if(w<0)return e;let f=e[w],c="",G="";if(_&&f.startsWith(_))c=f.replace(_,"").trim(),f=_;else if(m&&f.startsWith(m))c=f.replace(m,"").trim(),f=m;else return e;if(c.startsWith("=")?(c=c.slice(1),G=f+"="):c||(c=e[++w]),c.startsWith("-")||c.startsWith(i)){let A=c.startsWith(`${i}`)?c.replace(`${i}`,""):c.replace("-",`${i}-`);if(e[w]=G+A,c.startsWith(i)&&s){let R=n?n.replace("--",""):void 0,O=Object.entries(s.flags).find(([B,be])=>be===c);O&&(!R||R===O[0])&&(s.flags[O[0]]=A);let K=Object.values(s.raw).find(B=>B.type==="flag"&&B.input===c);K&&(!R||R===K.flag)&&(K.input=A)}}return e},Fe=e=>{if(!e)throw Error("Date is empty");try{let t=Date.parse(e);if(Number.isNaN(t))throw new Error("Invalid date");return new Date(t)}catch{throw new Error("Error parsing date: "+e)}};var oe={};h(oe,{center:()=>He,cleanDate:()=>Je,formatError:()=>Xe,formatOutput:()=>ne,localeDate:()=>Ye,maxLength:()=>Ge,printCSV:()=>ie,printJSON:()=>se,printObject:()=>re});import{inspect as Ne}from"util";var re=(e,t)=>Ne(e,{showHidden:!1,depth:null,colors:t?.color===void 0?!0:t.color,sorted:t?.sort===void 0?!1:t?.sort,maxArrayLength:1/0,breakLength:t?.width||120}),se=(e,t)=>JSON.stringify(e,null,t?.unformatted?void 0:t?.tabSize||4),ie=(e,t)=>{if(!e||e.length===0)return"";let r=Object.keys(e[0]).filter(i=>["id","type"].includes(i)?t?.fields.includes(i):!0),s=r.map(i=>i.toUpperCase().replace(/_/g," ")).join(";")+`
2
2
  `;return e.forEach(i=>{s+=r.map(n=>i[n]).join(";")+`
3
- `}),s},He=(e,t)=>e.padStart(e.length+Math.floor((t-e.length)/2)," ").padEnd(t," "),Ge=(e,t)=>e.reduce((r,s)=>{let i=Array.isArray(s[t])?s[t].join():s[t];return Math.max(r,String(i).length)},0),Je=e=>e?e.replace("T"," ").replace("Z","").substring(0,e.lastIndexOf(".")):"",Ye=e=>e?new Date(Date.parse(e)).toLocaleString():"",ne=(e,t,{color:r=!0}={})=>{if(!e)return"";if(typeof e=="string")return e;if(t){if(t.csv)return ie(e,t);if(t.json)return se(e,{unformatted:t.unformatted})}return re(e,{color:r})},Xe=(e,t)=>ne(e.errors||e,t);var $={};h($,{api:()=>ht,bg:()=>_t,black:()=>at,blackBright:()=>ct,blue:()=>it,blueBright:()=>q,bold:()=>U,cli:()=>bt,cyan:()=>pt,cyanBright:()=>C,dim:()=>dt,green:()=>rt,greenBright:()=>V,grey:()=>lt,hidden:()=>et,italic:()=>T,magenta:()=>ut,magentaBright:()=>mt,msg:()=>yt,red:()=>tt,redBright:()=>ae,reset:()=>Ze,style:()=>l,table:()=>xt,type:()=>ft,underline:()=>gt,visible:()=>Qe,white:()=>nt,whiteBright:()=>ot,yellow:()=>st,yellowBright:()=>v});import o from"chalk";var Ze=o.reset,Qe=o.visible,et=o.hidden,tt=o.red,ae=o.redBright,rt=o.green,V=o.greenBright,st=o.yellow,v=o.yellowBright,it=o.blue,q=o.blueBright,nt=o.white,ot=o.whiteBright,at=o.black,ct=o.blackBright,lt=o.grey,pt=o.cyan,C=o.cyanBright,ut=o.magenta,mt=o.magentaBright,U=o.bold,dt=o.dim,gt=o.underline,T=o.italic,_t={white:o.bgWhite,whiteBright:o.bgWhiteBright,black:o.bgBlack,blackBright:o.bgBlackBright,grey:o.bgGrey,red:o.bgRed,redBright:o.bgRedBright,green:o.bgGreen,greenBright:o.bgGreenBright,yellow:o.bgYellow,yellowBright:o.bgYellowBright,blue:o.bgBlue,blueBright:o.bgBlueBright,magenta:o.bgMagenta,magentaBright:o.bgMagentaBright,cyan:o.bgCyan,cyanBright:o.bgCyanBright},l={organization:v.bold,application:v.bold,slug:v,id:U,token:q,resource:U,attribute:T,trigger:C,kind:C,live:V,test:v,execMode:e=>e==="live"?l.live:l.test,success:V,warning:v,error:ae,arg:T,flag:T,command:T,value:T,alias:C,plugin:q,title:q,path:T,datetime:C,number:v},ft={datetime:l.datetime,number:l.number,path:l.path},ht={organization:l.organization,application:l.application,slug:l.slug,id:l.id,token:l.token,resource:l.resource,attribute:l.attribute,trigger:l.trigger,kind:l.kind,live:l.live,test:l.test},yt={success:l.success,warning:l.warning,error:l.error},bt={arg:l.arg,flag:l.flag,command:l.command,value:l.value,alias:l.alias,plugin:l.plugin},xt={header:v.bold,key:q};var pe={};h(pe,{buildAssertionPayload:()=>Lt,decodeAccessToken:()=>le,generateAccessToken:()=>Kt,getAccessToken:()=>Bt,getTokenEnvironment:()=>Dt,isAccessTokenExpiring:()=>jt,revokeAccessToken:()=>Mt});import N from"jsonwebtoken";import{authenticate as F,revoke as 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 wt}from"util";import{sep as kt,dirname as Tt}from"path";import{homedir as At}from"os";import{existsSync as $t,mkdirSync as Ct}from"fs";var qt=async e=>new Promise(t=>setTimeout(t,e)),Rt=()=>{process.stdout.write("\x1B[?25h\x1B[?7h")},Et=(e="",...t)=>{e=typeof e=="string"?e:wt(e),process.stdout.write(vt(e,...t)+`
4
- `)},St=(e,t=!1)=>{let r=["desktop","home"],s=e.toLowerCase().split(/[\\\/]/g)[0];if(r.includes(s)){let n=At();s==="desktop"&&(n+=`${kt}Desktop`),e=e.replace(s,n)}let i=Tt(e);return t&&!$t(i)&&Ct(i,{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,i])=>{let n=s.split("."),a=n[n.length-1],m=r;n.forEach(_=>{_===a?m[_]=i:m=m[_]||(m[_]={})})}),t&&Object.assign(t,r),r};var le=e=>{let t=N.decode(e);if(t===null)throw new Error("Error decoding access token");return t},Kt=(e,t,r)=>{let i={...e,exp:Math.floor(Date.now()/1e3)+r*60,rand:Math.random()},n=u.api.token_encoding_algorithm,a=N.sign(i,t,{algorithm:n,noTimestamp:!0}),m=N.verify(a,t,{algorithms:[n]});return{accessToken:a,info:m,expMinutes:r}},Bt=async e=>{let t,r=e.scope?Array.isArray(e.scope)?e.scope.map(i=>i.trim()).join(","):e.scope:"",s={clientId:e.clientId,clientSecret:e.clientSecret,slug:e.slug,domain:e.domain,scope:r};if(e.email&&e.password?(s.username=e.email,s.password=e.password,t=await F("password",s)):e.assertion?(s.assertion=e.assertion,t=await F("urn:ietf:params:oauth:grant-type:jwt-bearer",s)):t=await F("client_credentials",s),t){if(t.errors)throw new Error(`Unable to get access token: ${t.errors[0].detail}`)}else throw new Error("Unable to get access token");return t},Mt=async(e,t)=>{let r=await It({...e,token:t});if(r.errors)throw new Error(r.errors[0].detail)},jt=e=>{let r=Math.floor(Date.now()/1e3),s=Math.floor(new Date(e.expires).getTime()/1e3);return r>=s-30},Dt=e=>(typeof e=="string"?le(e):e).test?"test":"live";var Lt=(e,t,r)=>{let s="https://commercelayer.io/claims",i={[s]:{owner:{type:e,id:t}}};if(r&&Object.keys(r).length>0){let n=W(r);i[s].custom_claim=n}return i};var ue={};h(ue,{checkUpdate:()=>Ut});import S from"chalk";import Pt from"update-notifier-cjs";var Vt=1,Ut=e=>{let t=Pt({pkg:e,updateCheckInterval:36e5*Vt});t.update&&t.notify({isGlobal:!1,message:`-= ${S.bgWhite.black.bold(` ${e.description} `)} =-
3
+ `}),s},He=(e,t)=>e.padStart(e.length+Math.floor((t-e.length)/2)," ").padEnd(t," "),Ge=(e,t)=>e.reduce((r,s)=>{let i=Array.isArray(s[t])?s[t].join():s[t];return Math.max(r,String(i).length)},0),Je=e=>e?e.replace("T"," ").replace("Z","").substring(0,e.lastIndexOf(".")):"",Ye=e=>e?new Date(Date.parse(e)).toLocaleString():"",ne=(e,t,{color:r=!0}={})=>{if(!e)return"";if(typeof e=="string")return e;if(t){if(t.csv)return ie(e,t);if(t.json)return se(e,{unformatted:t.unformatted})}return re(e,{color:r})},Xe=(e,t)=>ne(e.errors||e,t);var $={};h($,{api:()=>ht,bg:()=>_t,black:()=>at,blackBright:()=>ct,blue:()=>it,blueBright:()=>q,bold:()=>U,cli:()=>bt,cyan:()=>pt,cyanBright:()=>C,dim:()=>dt,green:()=>rt,greenBright:()=>V,grey:()=>lt,hidden:()=>et,italic:()=>T,magenta:()=>ut,magentaBright:()=>mt,msg:()=>yt,red:()=>tt,redBright:()=>ae,reset:()=>Ze,style:()=>l,table:()=>xt,type:()=>ft,underline:()=>gt,visible:()=>Qe,white:()=>nt,whiteBright:()=>ot,yellow:()=>st,yellowBright:()=>v});import o from"chalk";var Ze=o.reset,Qe=o.visible,et=o.hidden,tt=o.red,ae=o.redBright,rt=o.green,V=o.greenBright,st=o.yellow,v=o.yellowBright,it=o.blue,q=o.blueBright,nt=o.white,ot=o.whiteBright,at=o.black,ct=o.blackBright,lt=o.grey,pt=o.cyan,C=o.cyanBright,ut=o.magenta,mt=o.magentaBright,U=o.bold,dt=o.dim,gt=o.underline,T=o.italic,_t={white:o.bgWhite,whiteBright:o.bgWhiteBright,black:o.bgBlack,blackBright:o.bgBlackBright,grey:o.bgGrey,red:o.bgRed,redBright:o.bgRedBright,green:o.bgGreen,greenBright:o.bgGreenBright,yellow:o.bgYellow,yellowBright:o.bgYellowBright,blue:o.bgBlue,blueBright:o.bgBlueBright,magenta:o.bgMagenta,magentaBright:o.bgMagentaBright,cyan:o.bgCyan,cyanBright:o.bgCyanBright},l={organization:v.bold,application:v.bold,slug:v,id:U,token:q,resource:U,attribute:T,trigger:C,kind:C,live:V,test:v,execMode:e=>e==="live"?l.live:l.test,success:V,warning:v,error:ae,arg:T,flag:T,command:T,value:T,alias:C,plugin:q,title:q,path:T,datetime:C,number:v},ft={datetime:l.datetime,number:l.number,path:l.path},ht={organization:l.organization,application:l.application,slug:l.slug,id:l.id,token:l.token,resource:l.resource,attribute:l.attribute,trigger:l.trigger,kind:l.kind,live:l.live,test:l.test},yt={success:l.success,warning:l.warning,error:l.error},bt={arg:l.arg,flag:l.flag,command:l.command,value:l.value,alias:l.alias,plugin:l.plugin},xt={header:v.bold,key:q};var ue={};h(ue,{apply:()=>kt,available:()=>le,documentation:()=>wt,filters:()=>pe,list:()=>ce});var vt=[{predicate:"*_eq",description:"The attribute is equal to the filter value"},{predicate:"*_eq_or_null",description:"The attribute is equal to the filter value, including null values"},{predicate:"*_not_eq",description:"The attribute is not equal to the filter value"},{predicate:"*_not_eq_or_null",description:"The attribute is not equal to the filter value, including null values"},{predicate:"*_matches",description:'The attribute matches the filter value with "LIKE" operator'},{predicate:"*_does_not_match",description:'The attribute does not match the filter value with "LIKE" operator'},{predicate:"*_matches_any",description:'The attribute matches all of the filter values (comma-separated) with "LIKE" operator'},{predicate:"*_matches_all",description:'The attribute matches all of the filter values (comma-separated) with "LIKE" operator'},{predicate:"*_does_not_match_any",description:'The attribute does not match any of the filter values (comma-separated) with "LIKE" operator'},{predicate:"*_does_not_match_all",description:'The attribute matches none of the filter values (comma-separated) with "LIKE" operator'},{predicate:"*_lt",description:"The attribute is less than the filter value"},{predicate:"*_lteq",description:"The attribute is less than or equal to the filter value"},{predicate:"*_gt",description:"The attribute is greater than the filter value"},{predicate:"*_gteq",description:"The attribute is greater than or equal to the filter value"},{predicate:"*_present",description:"The attribute is not null and not empty"},{predicate:"*_blank",description:"The attribute is null or empty"},{predicate:"*_null",description:"The attribute is null"},{predicate:"*_not_null",description:"The attribute is not null"},{predicate:"*_in",description:"The attribute matches any of the filter values (comma-separated)"},{predicate:"*_in_or_null",description:"The attribute matches any of the filter values (comma-separated), including null values"},{predicate:"*_not_in",description:"The attribute matches none of the filter values (comma-separated)"},{predicate:"*_not_in_or_null",description:"The attribute matches none of the filter values (comma-separated), including null values"},{predicate:"*_lt_any",description:"The attribute is less than any of the filter values (comma-separated)"},{predicate:"*_lteq_any",description:"The attribute is less than or equal to any of the filter values (comma-separated)"},{predicate:"*_gt_any",description:"The attribute is greater than any of the filter values (comma-separated)"},{predicate:"*_gteq_any",description:"The attribute is greater than or qual to any of the filter values (comma-separated)"},{predicate:"*_lt_all",description:"The attribute is less than all of the filter values (comma-separated)"},{predicate:"*_lteq_all",description:"The attribute is less than or equal to all of the filter values (comma-separated)"},{predicate:"*_gt_all",description:"The attribute is greater than all of the filter values (comma-separated)"},{predicate:"*_gteq_all",description:"The attribute is greater or equal to all of the filter values (comma-separated)"},{predicate:"*_not_eq_all",description:"The attribute is equal to none of the filter values (comma-separated)"},{predicate:"*_start",description:"The attribute starts with the filter value (comma-separated)"},{predicate:"*_not_start",description:"The attribute does not start with the filter value (comma-separated)"},{predicate:"*_start_any",description:"The attribute starts with any of the filter values (comma-separated)"},{predicate:"*_start_all",description:"The attribute starts with all of the filter values (comma-separated)"},{predicate:"*_not_start_any",description:"The attribute does not start with any of the filter values (comma-separated)"},{predicate:"*_not_start_all",description:"The attribute starts with none of the filter values (comma-separated)"},{predicate:"*_end",description:"The attribute ends with the filter value"},{predicate:"*_not_end",description:"The attribute does not end with the filter value"},{predicate:"*_end_any",description:"The attribute ends with any of the filter values (comma-separated)"},{predicate:"*_end_all",description:"The attribute ends with all of the filter values (comma-separated)"},{predicate:"*_not_end_any",description:"The attribute does not end with any of the filter values (comma-separated)"},{predicate:"*_not_end_all",description:"The attribute ends with none of the filter values (comma-separated)"},{predicate:"*_cont",description:"The attribute contains the filter value"},{predicate:"*_not_cont",description:"The attribute does not contains the filter value"},{predicate:"*_cont_any",description:"The attribute contains any of the filter values (comma-separated)"},{predicate:"*_cont_all",description:"The attribute contains all of the filter values (comma-separated)"},{predicate:"*_not_cont_all",description:"The attribute contains none of the filter values (comma-separated)"},{predicate:"*_jcont",description:"The attribute contains a portion of the JSON used as filter value (works with object only)"},{predicate:"*_true",description:"The attribute is true"},{predicate:"*_false",description:"The attribute is false"}],wt=u.doc.core_filtering_data,ce=()=>pe().map(e=>e.predicate.replace(/^\*/g,"")),le=e=>{let t=e.startsWith("_")?e:`_${e}`;return ce().some(r=>t.endsWith(r))},kt=(e,...t)=>{if(!le(e))throw new Error("Unknown filter: "+e);let r="";for(let s of t)r+=(r.length===0?"":"_or_")+s;return r+=e.startsWith("_")?e:`_${e}`,r},pe=()=>[...vt];import{CommandHelp as Rt,Help as Et}from"@oclif/core";var de={};h(de,{camelize:()=>qt,capitalize:()=>S,dasherize:()=>Tt,pluralize:()=>$t,singularize:()=>Ct,symbols:()=>x,underscorize:()=>At});var me={};h(me,{symbols:()=>x});var x={check:{small:"\u2714",bkgGreen:"\u2705",squareRoot:"\u221A"},cross:{small:"\u2718",red:"\u274C"},clock:{stopwatch:"\u23F1"},arrow:{down:"\u2193"},selection:{fisheye:"\u25C9"}};x.check.heavy=x.check.small;x.check.whiteHeavy=x.check.bkgGreen;x.cross.heavyBallot=x.cross.small;var S=e=>e&&k.capitalize(e),Tt=e=>e&&(e=e.toLocaleLowerCase(),e.replace(/[ _]/g,"-")),At=e=>e&&(e=e.toLocaleLowerCase(),e.replace(/[ -]/g,"_")),$t=(e,t)=>k.pluralize(e,t),Ct=(e,t)=>k.singularize(e,t),qt=(e,t)=>k.camelize(e,t);var y=!1,W=class extends Rt{examples(t){return y&&console.log("---------- command.examples"),super.examples(t)}},z=class extends Et{async showHelp(t){return y&&console.log("---------- showHelp"),super.showHelp(t)}async showRootHelp(){return y&&console.log("---------- showRootHelp"),super.showRootHelp()}async showTopicHelp(t){return y&&console.log("---------- showTopicHelp"),super.showTopicHelp(t)}async showCommandHelp(t){y&&console.log("---------- showCommandHelp"),await super.showCommandHelp(t)}formatRoot(){return y&&console.log("---------- formatRoot"),super.formatRoot()}formatTopic(t){return y&&console.log("---------- formatTopic"),super.formatTopic(t)}formatTopics(t){y&&console.log("---------- formatTopics");let r=t.filter(s=>!s.hidden).map(s=>(s.description=S(s.description),s));return super.formatTopics(r)}formatCommands(t){return y&&console.log("---------- formatCommands"),super.formatCommands(t).split(`
4
+ `).map(r=>{let s=0;return r.split(" ").map(i=>(i||"").trim()!==""&&++s===2?S(i):i).join(" ")}).join(`
5
+ `)}formatCommand(t){return y&&console.log("---------- formatCommand"),super.formatCommand(t)}getCommandHelpClass(t){return y&&console.log("---------- getCommandHelpClass"),new W(t,this.config,this.opts)}};var ge={};h(ge,{download:()=>St});var St=async e=>{let r=`https://data.${u.api.default_app_domain}/schemas/`,i=`openapi${e?"_"+e.replace(/\./g,"-"):""}.json`,n=r+i;return await(await fetch(n)).json()};var he={};h(he,{buildAssertionPayload:()=>Xt,decodeAccessToken:()=>fe,generateAccessToken:()=>Nt,getAccessToken:()=>Ht,getTokenEnvironment:()=>Yt,isAccessTokenExpiring:()=>Jt,revokeAccessToken:()=>Gt});import{authenticate as N,revoke as Ft}from"@commercelayer/js-auth";import H from"jsonwebtoken";var _e={};h(_e,{dotNotationToObject:()=>F,generateGroupUID:()=>Ut,log:()=>Pt,resetConsole:()=>Lt,sleep:()=>Dt,specialFolder:()=>Vt,userAgent:()=>Wt});import{existsSync as zt,mkdirSync as It}from"fs";import{homedir as Ot}from"os";import{dirname as Kt,sep as Bt}from"path";import{format as Mt,inspect as jt}from"util";var Dt=async e=>new Promise(t=>setTimeout(t,e)),Lt=()=>{process.stdout.write("\x1B[?25h\x1B[?7h")},Pt=(e="",...t)=>{e=typeof e=="string"?e:jt(e),process.stdout.write(Mt(e,...t)+`
6
+ `)},Vt=(e,t=!1)=>{let r=["desktop","home"],s=e.toLowerCase().split(/[\\/]/g)[0];if(r.includes(s)){let n=Ot();s==="desktop"&&(n+=`${Bt}Desktop`),e=e.replace(s,n)}let i=Kt(e);return t&&!zt(i)&&It(i,{recursive:!0}),e},Ut=()=>{let e=Math.trunc(Math.random()*46656),t=Math.trunc(Math.random()*46656),r=("000"+e.toString(36)).slice(-3),s=("000"+t.toString(36)).slice(-3);return r+s},Wt=e=>`${e.name.replace(/@commercelayer\/cli-plugin/,"CLI")}/${e.version}`,F=(e,t)=>{let r=t||{};return Object.entries(e).forEach(([s,i])=>{let n=s.split("."),a=n[n.length-1],m=r;n.forEach(_=>{_===a?m[_]=i:m=m[_]||(m[_]={})})}),t&&Object.assign(t,r),r};var fe=e=>{let t=H.decode(e);if(t===null)throw new Error("Error decoding access token");return t},Nt=(e,t,r)=>{let i={...e,exp:Math.floor(Date.now()/1e3)+r*60,rand:Math.random()},n=u.api.token_encoding_algorithm,a=H.sign(i,t,{algorithm:n,noTimestamp:!0}),m=H.verify(a,t,{algorithms:[n]});return{accessToken:a,info:m,expMinutes:r}},Ht=async e=>{let t,r=e.scope?Array.isArray(e.scope)?e.scope.map(i=>i.trim()).join(","):e.scope:"",s={clientId:e.clientId,clientSecret:e.clientSecret,slug:e.slug,domain:e.domain,scope:r};if(e.email&&e.password?(s.username=e.email,s.password=e.password,t=await N("password",s)):e.assertion?(s.assertion=e.assertion,t=await N("urn:ietf:params:oauth:grant-type:jwt-bearer",s)):t=await N("client_credentials",s),t){if(t.errors)throw new Error(`Unable to get access token: ${t.errors[0].detail}`)}else throw new Error("Unable to get access token");return t},Gt=async(e,t)=>{let r=await Ft({...e,token:t});if(r.errors)throw new Error(r.errors[0].detail)},Jt=e=>{let r=Math.floor(Date.now()/1e3),s=Math.floor(new Date(e.expires).getTime()/1e3);return r>=s-30},Yt=e=>(typeof e=="string"?fe(e):e).test?"test":"live";var Xt=(e,t,r)=>{let s="https://commercelayer.io/claims",i={[s]:{owner:{type:e,id:t}}};if(r&&Object.keys(r).length>0){let n=F(r);i[s].custom_claim=n}return i};var ye={};h(ye,{checkUpdate:()=>er});import I from"chalk";import Zt from"update-notifier-cjs";var Qt=1,er=e=>{let t=Zt({pkg:e,updateCheckInterval:36e5*Qt});t.update&&t.notify({isGlobal:!1,message:`-= ${I.bgWhite.black.bold(` ${e.description} `)} =-
5
7
 
6
- New version available: ${S.dim("{currentVersion}")} -> ${S.green("{latestVersion}")}
7
- Run ${S.cyanBright("commercelayer plugins:update")} to update`})};import{CommandHelp as Jt,Help as Yt}from"@oclif/core";var de={};h(de,{camelize:()=>Gt,capitalize:()=>z,dasherize:()=>Wt,pluralize:()=>Nt,singularize:()=>Ht,symbols:()=>x,underscorize:()=>Ft});var me={};h(me,{symbols:()=>x});var x={check:{small:"\u2714",bkgGreen:"\u2705",squareRoot:"\u221A"},cross:{small:"\u2718",red:"\u274C"},clock:{stopwatch:"\u23F1"},arrow:{down:"\u2193"},selection:{fisheye:"\u25C9"}};x.check.heavy=x.check.small;x.check.whiteHeavy=x.check.bkgGreen;x.cross.heavyBallot=x.cross.small;var z=e=>e&&k.capitalize(e),Wt=e=>e&&(e=e.toLocaleLowerCase(),e.replace(/[ _]/g,"-")),Ft=e=>e&&(e=e.toLocaleLowerCase(),e.replace(/[ -]/g,"_")),Nt=(e,t)=>k.pluralize(e,t),Ht=(e,t)=>k.singularize(e,t),Gt=(e,t)=>k.camelize(e,t);var y=!1,H=class extends Jt{examples(t){return y&&console.log("---------- command.examples"),super.examples(t)}},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"),await super.showCommandHelp(t)}formatRoot(){return y&&console.log("---------- formatRoot"),super.formatRoot()}formatTopic(t){return y&&console.log("---------- formatTopic"),super.formatTopic(t)}formatTopics(t){y&&console.log("---------- formatTopics");let r=t.filter(s=>!s.hidden).map(s=>(s.description=z(s.description),s));return super.formatTopics(r)}formatCommands(t){return y&&console.log("---------- formatCommands"),super.formatCommands(t).split(`
8
- `).map(r=>{let s=0;return r.split(" ").map(i=>(i||"").trim()!==""&&++s===2?z(i):i).join(" ")}).join(`
9
- `)}formatCommand(t){return y&&console.log("---------- formatCommand"),super.formatCommand(t)}getCommandHelpClass(t){return y&&console.log("---------- getCommandHelpClass"),new H(t,this.config,this.opts)}};var ge={};h(ge,{download:()=>Xt});var Xt=async e=>{let r=`https://data.${u.api.default_app_domain}/schemas/`,i=`openapi${e?"_"+e.replace(/\./g,"-"):""}.json`,n=r+i;return await(await fetch(n)).json()};var ye={};h(ye,{apply:()=>er,available:()=>fe,documentation:()=>Qt,filters:()=>he,list:()=>_e});var Zt=[{predicate:"*_eq",description:"The attribute is equal to the filter value"},{predicate:"*_eq_or_null",description:"The attribute is equal to the filter value, including null values"},{predicate:"*_not_eq",description:"The attribute is not equal to the filter value"},{predicate:"*_not_eq_or_null",description:"The attribute is not equal to the filter value, including null values"},{predicate:"*_matches",description:'The attribute matches the filter value with "LIKE" operator'},{predicate:"*_does_not_match",description:'The attribute does not match the filter value with "LIKE" operator'},{predicate:"*_matches_any",description:'The attribute matches all of the filter values (comma-separated) with "LIKE" operator'},{predicate:"*_matches_all",description:'The attribute matches all of the filter values (comma-separated) with "LIKE" operator'},{predicate:"*_does_not_match_any",description:'The attribute does not match any of the filter values (comma-separated) with "LIKE" operator'},{predicate:"*_does_not_match_all",description:'The attribute matches none of the filter values (comma-separated) with "LIKE" operator'},{predicate:"*_lt",description:"The attribute is less than the filter value"},{predicate:"*_lteq",description:"The attribute is less than or equal to the filter value"},{predicate:"*_gt",description:"The attribute is greater than the filter value"},{predicate:"*_gteq",description:"The attribute is greater than or equal to the filter value"},{predicate:"*_present",description:"The attribute is not null and not empty"},{predicate:"*_blank",description:"The attribute is null or empty"},{predicate:"*_null",description:"The attribute is null"},{predicate:"*_not_null",description:"The attribute is not null"},{predicate:"*_in",description:"The attribute matches any of the filter values (comma-separated)"},{predicate:"*_in_or_null",description:"The attribute matches any of the filter values (comma-separated), including null values"},{predicate:"*_not_in",description:"The attribute matches none of the filter values (comma-separated)"},{predicate:"*_not_in_or_null",description:"The attribute matches none of the filter values (comma-separated), including null values"},{predicate:"*_lt_any",description:"The attribute is less than any of the filter values (comma-separated)"},{predicate:"*_lteq_any",description:"The attribute is less than or equal to any of the filter values (comma-separated)"},{predicate:"*_gt_any",description:"The attribute is greater than any of the filter values (comma-separated)"},{predicate:"*_gteq_any",description:"The attribute is greater than or qual to any of the filter values (comma-separated)"},{predicate:"*_lt_all",description:"The attribute is less than all of the filter values (comma-separated)"},{predicate:"*_lteq_all",description:"The attribute is less than or equal to all of the filter values (comma-separated)"},{predicate:"*_gt_all",description:"The attribute is greater than all of the filter values (comma-separated)"},{predicate:"*_gteq_all",description:"The attribute is greater or equal to all of the filter values (comma-separated)"},{predicate:"*_not_eq_all",description:"The attribute is equal to none of the filter values (comma-separated)"},{predicate:"*_start",description:"The attribute starts with the filter value (comma-separated)"},{predicate:"*_not_start",description:"The attribute does not start with the filter value (comma-separated)"},{predicate:"*_start_any",description:"The attribute starts with any of the filter values (comma-separated)"},{predicate:"*_start_all",description:"The attribute starts with all of the filter values (comma-separated)"},{predicate:"*_not_start_any",description:"The attribute does not start with any of the filter values (comma-separated)"},{predicate:"*_not_start_all",description:"The attribute starts with none of the filter values (comma-separated)"},{predicate:"*_end",description:"The attribute ends with the filter value"},{predicate:"*_not_end",description:"The attribute does not end with the filter value"},{predicate:"*_end_any",description:"The attribute ends with any of the filter values (comma-separated)"},{predicate:"*_end_all",description:"The attribute ends with all of the filter values (comma-separated)"},{predicate:"*_not_end_any",description:"The attribute does not end with any of the filter values (comma-separated)"},{predicate:"*_not_end_all",description:"The attribute ends with none of the filter values (comma-separated)"},{predicate:"*_cont",description:"The attribute contains the filter value"},{predicate:"*_not_cont",description:"The attribute does not contains the filter value"},{predicate:"*_cont_any",description:"The attribute contains any of the filter values (comma-separated)"},{predicate:"*_cont_all",description:"The attribute contains all of the filter values (comma-separated)"},{predicate:"*_not_cont_all",description:"The attribute contains none of the filter values (comma-separated)"},{predicate:"*_jcont",description:"The attribute contains a portion of the JSON used as filter value (works with object only)"},{predicate:"*_true",description:"The attribute is true"},{predicate:"*_false",description:"The attribute is false"}],Qt=u.doc.core_filtering_data,_e=()=>he().map(e=>e.predicate.replace(/^\*/g,"")),fe=e=>{let t=e.startsWith("_")?e:`_${e}`;return _e().some(r=>t.endsWith(r))},er=(e,...t)=>{if(!fe(e))throw new Error("Unknown filter: "+e);let r="";for(let s of t)r+=(r.length===0?"":"_or_")+s;return r+=e.startsWith("_")?e:`_${e}`,r},he=()=>[...Zt];export{Z as clApi,ee as clApplication,$ as clColor,te as clCommand,u as clConfig,ye as clFilter,O as clHelp,oe as clOutput,ge as clSchema,me as clSymbol,de as clText,pe as clToken,ue as clUpdate,ce as clUtil};
8
+ New version available: ${I.dim("{currentVersion}")} -> ${I.green("{latestVersion}")}
9
+ Run ${I.cyanBright("commercelayer plugins:update")} to update`})};export{Z as clApi,ee as clApplication,$ as clColor,te as clCommand,u as clConfig,ue as clFilter,z as clHelp,oe as clOutput,ge as clSchema,me as clSymbol,de as clText,he as clToken,ye as clUpdate,_e as clUtil};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commercelayer/cli-core",
3
- "version": "6.0.0-oclif4.2",
3
+ "version": "6.0.0-oclif4.4",
4
4
  "author": "Pierluigi Viti <pierluigi@commercelayer.io>",
5
5
  "license": "MIT",
6
6
  "description": "Commerce Layer Javascript CLI core lib",
@@ -13,15 +13,14 @@
13
13
  "import": "./lib/index.mjs"
14
14
  },
15
15
  "scripts": {
16
- "lint": "eslint ./src --ext .ts",
17
- "lintspec": "eslint ./specs/ --ext .spec.ts",
18
- "lint:fix": "eslint src --fix",
19
16
  "build": "tsup",
20
17
  "start": "tsx src/index.ts",
21
18
  "test": "jest --passWithNoTests",
22
19
  "test-local": "tsx test/spot.ts",
23
20
  "coverage": "jest --coverage",
24
- "release": "pnpm upgrade && pnpm lint && pnpm build"
21
+ "lint": "biome check --enforce-assist=true",
22
+ "check": "biome check --enforce-assist=true --write",
23
+ "release": "pnpm upgrade && pnpm lint && pnpm build && pnpm test"
25
24
  },
26
25
  "keywords": [
27
26
  "ecommerce",
@@ -35,19 +34,17 @@
35
34
  "node": ">=20"
36
35
  },
37
36
  "devDependencies": {
37
+ "@biomejs/biome": "2.4.8",
38
38
  "@babel/preset-env": "^7.29.2",
39
39
  "@babel/preset-typescript": "^7.28.5",
40
- "@commercelayer/eslint-config-ts": "^2.6.0",
41
40
  "@semantic-release/changelog": "^6.0.3",
42
41
  "@semantic-release/git": "^10.0.1",
43
42
  "@types/jest": "^29.5.14",
44
43
  "@types/jsonwebtoken": "^9.0.10",
45
44
  "@types/node": "^24.12.0",
46
- "@typescript-eslint/eslint-plugin": "^7.18.0",
47
45
  "dotenv": "^16.6.1",
48
- "eslint": "^8.57.1",
49
- "jest": "^29.7.0",
50
- "oclif": "^4.22.92",
46
+ "jest": "^30.3.0",
47
+ "oclif": "^4.22.96",
51
48
  "semantic-release": "^25.0.3",
52
49
  "tsup": "^8.5.1",
53
50
  "tsx": "^4.21.0",
@@ -55,7 +52,7 @@
55
52
  },
56
53
  "dependencies": {
57
54
  "@commercelayer/js-auth": "^6.7.2",
58
- "@oclif/core": "^4.10.0",
55
+ "@oclif/core": "^4.10.2",
59
56
  "chalk": "^4.1.2",
60
57
  "jsonwebtoken": "^9.0.3",
61
58
  "update-notifier-cjs": "^5.1.7"