@commercelayer/cli-core 6.0.0-beta.8 → 6.0.0-oclif4.2
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 +98 -96
- package/lib/index.d.ts +98 -96
- package/lib/index.js +7 -7
- package/lib/index.mjs +7 -7
- package/package.json +11 -21
package/lib/index.d.mts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { Command,
|
|
2
|
-
import
|
|
1
|
+
import { Command, Help, Interfaces, CommandHelp } from '@oclif/core';
|
|
2
|
+
import { FlagInput } from '@oclif/core/lib/interfaces/parser';
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
import { Config as Config$1 } from '@oclif/core/lib/interfaces';
|
|
3
5
|
|
|
4
6
|
declare const rawRequest: (config: {
|
|
5
7
|
baseUrl: string;
|
|
@@ -178,8 +180,8 @@ type Config = {
|
|
|
178
180
|
};
|
|
179
181
|
declare const config: Config;
|
|
180
182
|
|
|
181
|
-
declare const commandFlags: <T extends
|
|
182
|
-
declare const allFlags: (command: Command.Class) =>
|
|
183
|
+
declare const commandFlags: <T extends FlagInput>(flags: T, exclude?: Array<keyof T>) => T;
|
|
184
|
+
declare const allFlags: (command: Command.Class) => FlagInput;
|
|
183
185
|
type KeyVal = Record<string, string | number | boolean | undefined | null>;
|
|
184
186
|
type KeyValString = Record<string, string>;
|
|
185
187
|
type KeyValArray = Record<string, string[]>;
|
|
@@ -378,110 +380,110 @@ declare namespace output {
|
|
|
378
380
|
export { output_center as center, output_cleanDate as cleanDate, output_formatError as formatError, output_formatOutput as formatOutput, output_localeDate as localeDate, output_maxLength as maxLength, output_printCSV as printCSV, output_printJSON as printJSON, output_printObject as printObject };
|
|
379
381
|
}
|
|
380
382
|
|
|
381
|
-
declare const reset: chalk.
|
|
382
|
-
declare const visible: chalk.
|
|
383
|
-
declare const hidden: chalk.
|
|
384
|
-
declare const red: chalk.
|
|
385
|
-
declare const redBright: chalk.
|
|
386
|
-
declare const green: chalk.
|
|
387
|
-
declare const greenBright: chalk.
|
|
388
|
-
declare const yellow: chalk.
|
|
389
|
-
declare const yellowBright: chalk.
|
|
390
|
-
declare const blue: chalk.
|
|
391
|
-
declare const blueBright: chalk.
|
|
392
|
-
declare const white: chalk.
|
|
393
|
-
declare const whiteBright: chalk.
|
|
394
|
-
declare const black: chalk.
|
|
395
|
-
declare const blackBright: chalk.
|
|
396
|
-
declare const grey: chalk.
|
|
397
|
-
declare const cyan: chalk.
|
|
398
|
-
declare const cyanBright: chalk.
|
|
399
|
-
declare const magenta: chalk.
|
|
400
|
-
declare const magentaBright: chalk.
|
|
401
|
-
declare const bold: chalk.
|
|
402
|
-
declare const dim: chalk.
|
|
403
|
-
declare const underline: chalk.
|
|
404
|
-
declare const italic: chalk.
|
|
383
|
+
declare const reset: chalk.Chalk;
|
|
384
|
+
declare const visible: chalk.Chalk;
|
|
385
|
+
declare const hidden: chalk.Chalk;
|
|
386
|
+
declare const red: chalk.Chalk;
|
|
387
|
+
declare const redBright: chalk.Chalk;
|
|
388
|
+
declare const green: chalk.Chalk;
|
|
389
|
+
declare const greenBright: chalk.Chalk;
|
|
390
|
+
declare const yellow: chalk.Chalk;
|
|
391
|
+
declare const yellowBright: chalk.Chalk;
|
|
392
|
+
declare const blue: chalk.Chalk;
|
|
393
|
+
declare const blueBright: chalk.Chalk;
|
|
394
|
+
declare const white: chalk.Chalk;
|
|
395
|
+
declare const whiteBright: chalk.Chalk;
|
|
396
|
+
declare const black: chalk.Chalk;
|
|
397
|
+
declare const blackBright: chalk.Chalk;
|
|
398
|
+
declare const grey: chalk.Chalk;
|
|
399
|
+
declare const cyan: chalk.Chalk;
|
|
400
|
+
declare const cyanBright: chalk.Chalk;
|
|
401
|
+
declare const magenta: chalk.Chalk;
|
|
402
|
+
declare const magentaBright: chalk.Chalk;
|
|
403
|
+
declare const bold: chalk.Chalk;
|
|
404
|
+
declare const dim: chalk.Chalk;
|
|
405
|
+
declare const underline: chalk.Chalk;
|
|
406
|
+
declare const italic: chalk.Chalk;
|
|
405
407
|
declare const bg: {
|
|
406
|
-
white: chalk.
|
|
407
|
-
whiteBright: chalk.
|
|
408
|
-
black: chalk.
|
|
409
|
-
blackBright: chalk.
|
|
410
|
-
grey: chalk.
|
|
411
|
-
red: chalk.
|
|
412
|
-
redBright: chalk.
|
|
413
|
-
green: chalk.
|
|
414
|
-
greenBright: chalk.
|
|
415
|
-
yellow: chalk.
|
|
416
|
-
yellowBright: chalk.
|
|
417
|
-
blue: chalk.
|
|
418
|
-
blueBright: chalk.
|
|
419
|
-
magenta: chalk.
|
|
420
|
-
magentaBright: chalk.
|
|
421
|
-
cyan: chalk.
|
|
422
|
-
cyanBright: chalk.
|
|
408
|
+
white: chalk.Chalk;
|
|
409
|
+
whiteBright: chalk.Chalk;
|
|
410
|
+
black: chalk.Chalk;
|
|
411
|
+
blackBright: chalk.Chalk;
|
|
412
|
+
grey: chalk.Chalk;
|
|
413
|
+
red: chalk.Chalk;
|
|
414
|
+
redBright: chalk.Chalk;
|
|
415
|
+
green: chalk.Chalk;
|
|
416
|
+
greenBright: chalk.Chalk;
|
|
417
|
+
yellow: chalk.Chalk;
|
|
418
|
+
yellowBright: chalk.Chalk;
|
|
419
|
+
blue: chalk.Chalk;
|
|
420
|
+
blueBright: chalk.Chalk;
|
|
421
|
+
magenta: chalk.Chalk;
|
|
422
|
+
magentaBright: chalk.Chalk;
|
|
423
|
+
cyan: chalk.Chalk;
|
|
424
|
+
cyanBright: chalk.Chalk;
|
|
423
425
|
};
|
|
424
426
|
declare const style: {
|
|
425
|
-
organization: chalk.
|
|
426
|
-
application: chalk.
|
|
427
|
-
slug: chalk.
|
|
428
|
-
id: chalk.
|
|
429
|
-
token: chalk.
|
|
430
|
-
resource: chalk.
|
|
431
|
-
attribute: chalk.
|
|
432
|
-
trigger: chalk.
|
|
433
|
-
kind: chalk.
|
|
434
|
-
live: chalk.
|
|
435
|
-
test: chalk.
|
|
436
|
-
execMode: (mode: ApiMode) => chalk.
|
|
437
|
-
success: chalk.
|
|
438
|
-
warning: chalk.
|
|
439
|
-
error: chalk.
|
|
440
|
-
arg: chalk.
|
|
441
|
-
flag: chalk.
|
|
442
|
-
command: chalk.
|
|
443
|
-
value: chalk.
|
|
444
|
-
alias: chalk.
|
|
445
|
-
plugin: chalk.
|
|
446
|
-
title: chalk.
|
|
447
|
-
path: chalk.
|
|
448
|
-
datetime: chalk.
|
|
449
|
-
number: chalk.
|
|
427
|
+
organization: chalk.Chalk;
|
|
428
|
+
application: chalk.Chalk;
|
|
429
|
+
slug: chalk.Chalk;
|
|
430
|
+
id: chalk.Chalk;
|
|
431
|
+
token: chalk.Chalk;
|
|
432
|
+
resource: chalk.Chalk;
|
|
433
|
+
attribute: chalk.Chalk;
|
|
434
|
+
trigger: chalk.Chalk;
|
|
435
|
+
kind: chalk.Chalk;
|
|
436
|
+
live: chalk.Chalk;
|
|
437
|
+
test: chalk.Chalk;
|
|
438
|
+
execMode: (mode: ApiMode) => chalk.Chalk;
|
|
439
|
+
success: chalk.Chalk;
|
|
440
|
+
warning: chalk.Chalk;
|
|
441
|
+
error: chalk.Chalk;
|
|
442
|
+
arg: chalk.Chalk;
|
|
443
|
+
flag: chalk.Chalk;
|
|
444
|
+
command: chalk.Chalk;
|
|
445
|
+
value: chalk.Chalk;
|
|
446
|
+
alias: chalk.Chalk;
|
|
447
|
+
plugin: chalk.Chalk;
|
|
448
|
+
title: chalk.Chalk;
|
|
449
|
+
path: chalk.Chalk;
|
|
450
|
+
datetime: chalk.Chalk;
|
|
451
|
+
number: chalk.Chalk;
|
|
450
452
|
};
|
|
451
453
|
declare const type: {
|
|
452
|
-
datetime: chalk.
|
|
453
|
-
number: chalk.
|
|
454
|
-
path: chalk.
|
|
454
|
+
datetime: chalk.Chalk;
|
|
455
|
+
number: chalk.Chalk;
|
|
456
|
+
path: chalk.Chalk;
|
|
455
457
|
};
|
|
456
458
|
declare const api: {
|
|
457
|
-
organization: chalk.
|
|
458
|
-
application: chalk.
|
|
459
|
-
slug: chalk.
|
|
460
|
-
id: chalk.
|
|
461
|
-
token: chalk.
|
|
462
|
-
resource: chalk.
|
|
463
|
-
attribute: chalk.
|
|
464
|
-
trigger: chalk.
|
|
465
|
-
kind: chalk.
|
|
466
|
-
live: chalk.
|
|
467
|
-
test: chalk.
|
|
459
|
+
organization: chalk.Chalk;
|
|
460
|
+
application: chalk.Chalk;
|
|
461
|
+
slug: chalk.Chalk;
|
|
462
|
+
id: chalk.Chalk;
|
|
463
|
+
token: chalk.Chalk;
|
|
464
|
+
resource: chalk.Chalk;
|
|
465
|
+
attribute: chalk.Chalk;
|
|
466
|
+
trigger: chalk.Chalk;
|
|
467
|
+
kind: chalk.Chalk;
|
|
468
|
+
live: chalk.Chalk;
|
|
469
|
+
test: chalk.Chalk;
|
|
468
470
|
};
|
|
469
471
|
declare const msg: {
|
|
470
|
-
success: chalk.
|
|
471
|
-
warning: chalk.
|
|
472
|
-
error: chalk.
|
|
472
|
+
success: chalk.Chalk;
|
|
473
|
+
warning: chalk.Chalk;
|
|
474
|
+
error: chalk.Chalk;
|
|
473
475
|
};
|
|
474
476
|
declare const cli: {
|
|
475
|
-
arg: chalk.
|
|
476
|
-
flag: chalk.
|
|
477
|
-
command: chalk.
|
|
478
|
-
value: chalk.
|
|
479
|
-
alias: chalk.
|
|
480
|
-
plugin: chalk.
|
|
477
|
+
arg: chalk.Chalk;
|
|
478
|
+
flag: chalk.Chalk;
|
|
479
|
+
command: chalk.Chalk;
|
|
480
|
+
value: chalk.Chalk;
|
|
481
|
+
alias: chalk.Chalk;
|
|
482
|
+
plugin: chalk.Chalk;
|
|
481
483
|
};
|
|
482
484
|
declare const table: {
|
|
483
|
-
header: chalk.
|
|
484
|
-
key: chalk.
|
|
485
|
+
header: chalk.Chalk;
|
|
486
|
+
key: chalk.Chalk;
|
|
485
487
|
};
|
|
486
488
|
|
|
487
489
|
declare const color_api: typeof api;
|
|
@@ -538,7 +540,7 @@ declare const resetConsole: () => void;
|
|
|
538
540
|
declare const log: (message?: string, ...args: unknown[]) => void;
|
|
539
541
|
declare const specialFolder: (filePath: string, createIfNotExists?: boolean) => string;
|
|
540
542
|
declare const generateGroupUID: () => string;
|
|
541
|
-
declare const userAgent: (config:
|
|
543
|
+
declare const userAgent: (config: Config$1) => string;
|
|
542
544
|
declare const dotNotationToObject: (dotNot: KeyValObj, toObj?: KeyValObj) => KeyValObj;
|
|
543
545
|
|
|
544
546
|
declare const util_dotNotationToObject: typeof dotNotationToObject;
|
package/lib/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { Command,
|
|
2
|
-
import
|
|
1
|
+
import { Command, Help, Interfaces, CommandHelp } from '@oclif/core';
|
|
2
|
+
import { FlagInput } from '@oclif/core/lib/interfaces/parser';
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
import { Config as Config$1 } from '@oclif/core/lib/interfaces';
|
|
3
5
|
|
|
4
6
|
declare const rawRequest: (config: {
|
|
5
7
|
baseUrl: string;
|
|
@@ -178,8 +180,8 @@ type Config = {
|
|
|
178
180
|
};
|
|
179
181
|
declare const config: Config;
|
|
180
182
|
|
|
181
|
-
declare const commandFlags: <T extends
|
|
182
|
-
declare const allFlags: (command: Command.Class) =>
|
|
183
|
+
declare const commandFlags: <T extends FlagInput>(flags: T, exclude?: Array<keyof T>) => T;
|
|
184
|
+
declare const allFlags: (command: Command.Class) => FlagInput;
|
|
183
185
|
type KeyVal = Record<string, string | number | boolean | undefined | null>;
|
|
184
186
|
type KeyValString = Record<string, string>;
|
|
185
187
|
type KeyValArray = Record<string, string[]>;
|
|
@@ -378,110 +380,110 @@ declare namespace output {
|
|
|
378
380
|
export { output_center as center, output_cleanDate as cleanDate, output_formatError as formatError, output_formatOutput as formatOutput, output_localeDate as localeDate, output_maxLength as maxLength, output_printCSV as printCSV, output_printJSON as printJSON, output_printObject as printObject };
|
|
379
381
|
}
|
|
380
382
|
|
|
381
|
-
declare const reset: chalk.
|
|
382
|
-
declare const visible: chalk.
|
|
383
|
-
declare const hidden: chalk.
|
|
384
|
-
declare const red: chalk.
|
|
385
|
-
declare const redBright: chalk.
|
|
386
|
-
declare const green: chalk.
|
|
387
|
-
declare const greenBright: chalk.
|
|
388
|
-
declare const yellow: chalk.
|
|
389
|
-
declare const yellowBright: chalk.
|
|
390
|
-
declare const blue: chalk.
|
|
391
|
-
declare const blueBright: chalk.
|
|
392
|
-
declare const white: chalk.
|
|
393
|
-
declare const whiteBright: chalk.
|
|
394
|
-
declare const black: chalk.
|
|
395
|
-
declare const blackBright: chalk.
|
|
396
|
-
declare const grey: chalk.
|
|
397
|
-
declare const cyan: chalk.
|
|
398
|
-
declare const cyanBright: chalk.
|
|
399
|
-
declare const magenta: chalk.
|
|
400
|
-
declare const magentaBright: chalk.
|
|
401
|
-
declare const bold: chalk.
|
|
402
|
-
declare const dim: chalk.
|
|
403
|
-
declare const underline: chalk.
|
|
404
|
-
declare const italic: chalk.
|
|
383
|
+
declare const reset: chalk.Chalk;
|
|
384
|
+
declare const visible: chalk.Chalk;
|
|
385
|
+
declare const hidden: chalk.Chalk;
|
|
386
|
+
declare const red: chalk.Chalk;
|
|
387
|
+
declare const redBright: chalk.Chalk;
|
|
388
|
+
declare const green: chalk.Chalk;
|
|
389
|
+
declare const greenBright: chalk.Chalk;
|
|
390
|
+
declare const yellow: chalk.Chalk;
|
|
391
|
+
declare const yellowBright: chalk.Chalk;
|
|
392
|
+
declare const blue: chalk.Chalk;
|
|
393
|
+
declare const blueBright: chalk.Chalk;
|
|
394
|
+
declare const white: chalk.Chalk;
|
|
395
|
+
declare const whiteBright: chalk.Chalk;
|
|
396
|
+
declare const black: chalk.Chalk;
|
|
397
|
+
declare const blackBright: chalk.Chalk;
|
|
398
|
+
declare const grey: chalk.Chalk;
|
|
399
|
+
declare const cyan: chalk.Chalk;
|
|
400
|
+
declare const cyanBright: chalk.Chalk;
|
|
401
|
+
declare const magenta: chalk.Chalk;
|
|
402
|
+
declare const magentaBright: chalk.Chalk;
|
|
403
|
+
declare const bold: chalk.Chalk;
|
|
404
|
+
declare const dim: chalk.Chalk;
|
|
405
|
+
declare const underline: chalk.Chalk;
|
|
406
|
+
declare const italic: chalk.Chalk;
|
|
405
407
|
declare const bg: {
|
|
406
|
-
white: chalk.
|
|
407
|
-
whiteBright: chalk.
|
|
408
|
-
black: chalk.
|
|
409
|
-
blackBright: chalk.
|
|
410
|
-
grey: chalk.
|
|
411
|
-
red: chalk.
|
|
412
|
-
redBright: chalk.
|
|
413
|
-
green: chalk.
|
|
414
|
-
greenBright: chalk.
|
|
415
|
-
yellow: chalk.
|
|
416
|
-
yellowBright: chalk.
|
|
417
|
-
blue: chalk.
|
|
418
|
-
blueBright: chalk.
|
|
419
|
-
magenta: chalk.
|
|
420
|
-
magentaBright: chalk.
|
|
421
|
-
cyan: chalk.
|
|
422
|
-
cyanBright: chalk.
|
|
408
|
+
white: chalk.Chalk;
|
|
409
|
+
whiteBright: chalk.Chalk;
|
|
410
|
+
black: chalk.Chalk;
|
|
411
|
+
blackBright: chalk.Chalk;
|
|
412
|
+
grey: chalk.Chalk;
|
|
413
|
+
red: chalk.Chalk;
|
|
414
|
+
redBright: chalk.Chalk;
|
|
415
|
+
green: chalk.Chalk;
|
|
416
|
+
greenBright: chalk.Chalk;
|
|
417
|
+
yellow: chalk.Chalk;
|
|
418
|
+
yellowBright: chalk.Chalk;
|
|
419
|
+
blue: chalk.Chalk;
|
|
420
|
+
blueBright: chalk.Chalk;
|
|
421
|
+
magenta: chalk.Chalk;
|
|
422
|
+
magentaBright: chalk.Chalk;
|
|
423
|
+
cyan: chalk.Chalk;
|
|
424
|
+
cyanBright: chalk.Chalk;
|
|
423
425
|
};
|
|
424
426
|
declare const style: {
|
|
425
|
-
organization: chalk.
|
|
426
|
-
application: chalk.
|
|
427
|
-
slug: chalk.
|
|
428
|
-
id: chalk.
|
|
429
|
-
token: chalk.
|
|
430
|
-
resource: chalk.
|
|
431
|
-
attribute: chalk.
|
|
432
|
-
trigger: chalk.
|
|
433
|
-
kind: chalk.
|
|
434
|
-
live: chalk.
|
|
435
|
-
test: chalk.
|
|
436
|
-
execMode: (mode: ApiMode) => chalk.
|
|
437
|
-
success: chalk.
|
|
438
|
-
warning: chalk.
|
|
439
|
-
error: chalk.
|
|
440
|
-
arg: chalk.
|
|
441
|
-
flag: chalk.
|
|
442
|
-
command: chalk.
|
|
443
|
-
value: chalk.
|
|
444
|
-
alias: chalk.
|
|
445
|
-
plugin: chalk.
|
|
446
|
-
title: chalk.
|
|
447
|
-
path: chalk.
|
|
448
|
-
datetime: chalk.
|
|
449
|
-
number: chalk.
|
|
427
|
+
organization: chalk.Chalk;
|
|
428
|
+
application: chalk.Chalk;
|
|
429
|
+
slug: chalk.Chalk;
|
|
430
|
+
id: chalk.Chalk;
|
|
431
|
+
token: chalk.Chalk;
|
|
432
|
+
resource: chalk.Chalk;
|
|
433
|
+
attribute: chalk.Chalk;
|
|
434
|
+
trigger: chalk.Chalk;
|
|
435
|
+
kind: chalk.Chalk;
|
|
436
|
+
live: chalk.Chalk;
|
|
437
|
+
test: chalk.Chalk;
|
|
438
|
+
execMode: (mode: ApiMode) => chalk.Chalk;
|
|
439
|
+
success: chalk.Chalk;
|
|
440
|
+
warning: chalk.Chalk;
|
|
441
|
+
error: chalk.Chalk;
|
|
442
|
+
arg: chalk.Chalk;
|
|
443
|
+
flag: chalk.Chalk;
|
|
444
|
+
command: chalk.Chalk;
|
|
445
|
+
value: chalk.Chalk;
|
|
446
|
+
alias: chalk.Chalk;
|
|
447
|
+
plugin: chalk.Chalk;
|
|
448
|
+
title: chalk.Chalk;
|
|
449
|
+
path: chalk.Chalk;
|
|
450
|
+
datetime: chalk.Chalk;
|
|
451
|
+
number: chalk.Chalk;
|
|
450
452
|
};
|
|
451
453
|
declare const type: {
|
|
452
|
-
datetime: chalk.
|
|
453
|
-
number: chalk.
|
|
454
|
-
path: chalk.
|
|
454
|
+
datetime: chalk.Chalk;
|
|
455
|
+
number: chalk.Chalk;
|
|
456
|
+
path: chalk.Chalk;
|
|
455
457
|
};
|
|
456
458
|
declare const api: {
|
|
457
|
-
organization: chalk.
|
|
458
|
-
application: chalk.
|
|
459
|
-
slug: chalk.
|
|
460
|
-
id: chalk.
|
|
461
|
-
token: chalk.
|
|
462
|
-
resource: chalk.
|
|
463
|
-
attribute: chalk.
|
|
464
|
-
trigger: chalk.
|
|
465
|
-
kind: chalk.
|
|
466
|
-
live: chalk.
|
|
467
|
-
test: chalk.
|
|
459
|
+
organization: chalk.Chalk;
|
|
460
|
+
application: chalk.Chalk;
|
|
461
|
+
slug: chalk.Chalk;
|
|
462
|
+
id: chalk.Chalk;
|
|
463
|
+
token: chalk.Chalk;
|
|
464
|
+
resource: chalk.Chalk;
|
|
465
|
+
attribute: chalk.Chalk;
|
|
466
|
+
trigger: chalk.Chalk;
|
|
467
|
+
kind: chalk.Chalk;
|
|
468
|
+
live: chalk.Chalk;
|
|
469
|
+
test: chalk.Chalk;
|
|
468
470
|
};
|
|
469
471
|
declare const msg: {
|
|
470
|
-
success: chalk.
|
|
471
|
-
warning: chalk.
|
|
472
|
-
error: chalk.
|
|
472
|
+
success: chalk.Chalk;
|
|
473
|
+
warning: chalk.Chalk;
|
|
474
|
+
error: chalk.Chalk;
|
|
473
475
|
};
|
|
474
476
|
declare const cli: {
|
|
475
|
-
arg: chalk.
|
|
476
|
-
flag: chalk.
|
|
477
|
-
command: chalk.
|
|
478
|
-
value: chalk.
|
|
479
|
-
alias: chalk.
|
|
480
|
-
plugin: chalk.
|
|
477
|
+
arg: chalk.Chalk;
|
|
478
|
+
flag: chalk.Chalk;
|
|
479
|
+
command: chalk.Chalk;
|
|
480
|
+
value: chalk.Chalk;
|
|
481
|
+
alias: chalk.Chalk;
|
|
482
|
+
plugin: chalk.Chalk;
|
|
481
483
|
};
|
|
482
484
|
declare const table: {
|
|
483
|
-
header: chalk.
|
|
484
|
-
key: chalk.
|
|
485
|
+
header: chalk.Chalk;
|
|
486
|
+
key: chalk.Chalk;
|
|
485
487
|
};
|
|
486
488
|
|
|
487
489
|
declare const color_api: typeof api;
|
|
@@ -538,7 +540,7 @@ declare const resetConsole: () => void;
|
|
|
538
540
|
declare const log: (message?: string, ...args: unknown[]) => void;
|
|
539
541
|
declare const specialFolder: (filePath: string, createIfNotExists?: boolean) => string;
|
|
540
542
|
declare const generateGroupUID: () => string;
|
|
541
|
-
declare const userAgent: (config:
|
|
543
|
+
declare const userAgent: (config: Config$1) => string;
|
|
542
544
|
declare const dotNotationToObject: (dotNot: KeyValObj, toObj?: KeyValObj) => KeyValObj;
|
|
543
545
|
|
|
544
546
|
declare const util_dotNotationToObject: typeof dotNotationToObject;
|
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 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 n of ze(t))!Oe.call(e,n)&&n!==r&&z(e,n,{get:()=>t[n],enumerable:!(s=Se(t,n))||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:()=>le,clHelp:()=>E,clOutput:()=>Z,clSchema:()=>ce,clSymbol:()=>ie,clText:()=>oe,clToken:()=>se,clUpdate:()=>ne,clUtil:()=>re});module.exports=Ke(sr);var J={};_(J,{Operation:()=>H,baseURL:()=>Ve,execMode:()=>We,extractDomain:()=>Ue,humanizeResource:()=>Fe,isResourceCacheable:()=>ge,liveEnvironment:()=>He,request:()=>Ge,requestDataFile:()=>N,requestRateLimitDelay:()=>_e,requestRaw:()=>F,response:()=>Je,responseDenormalize:()=>G});var W=["in_progress","pending","completed","interrupted"],Be=["addresses","bundles","coupons","customer_addresses","customer_payment_sources","customer_subscriptions","customers","gift_cards","line_items","line_item_options","orders","price_tiers","prices","shipping_categories","sku_lists","sku_list_items","sku_options","skus","stock_items","stock_transfers","tags","tax_categories"],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(n=>{if(n.ok)return n;throw new Error(n.statusText)})).json(),N=e=>{let t,r;try{t=(0,me.readFileSync)(e,"utf-8")}catch{throw new Error(`Unable to find or open the data file ${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),O=(e,t)=>{let r={id:e.id,type:e.type,...e.attributes};return e.relationships&&Object.keys(e.relationships).forEach(s=>{let n=e.relationships[s].data;n?Array.isArray(n)?r[s]=n.map(i=>O(de(i,t),t)):r[s]=O(de(n,t),t):n===null&&(r[s]=null)}),r},G=e=>{let t;e.links&&delete e.links;let r=e.data,s=e.included;return Array.isArray(r)?t=r.map(n=>O(n,s)):t=O(r,s),t};var p={uncountableWords:["equipment","information","rice","money","species","series","fish","sheep","moose","deer","news"],pluralRules:[[/(m)an$/gi,"$1en"],[/(pe)rson$/gi,"$1ople"],[/(child)$/gi,"$1ren"],[/^(ox)$/gi,"$1en"],[/(ax|test)is$/gi,"$1es"],[/(octop|vir)us$/gi,"$1i"],[/(alias|status)$/gi,"$1es"],[/(bu)s$/gi,"$1ses"],[/(buffal|tomat|potat)o$/gi,"$1oes"],[/([ti])um$/gi,"$1a"],[/sis$/gi,"ses"],[/(?:([^f])fe|([lr])f)$/gi,"$1$2ves"],[/(hive)$/gi,"$1s"],[/([^aeiouy]|qu)y$/gi,"$1ies"],[/(x|ch|ss|sh)$/gi,"$1es"],[/(matr|vert|ind)ix|ex$/gi,"$1ices"],[/([m|l])ouse$/gi,"$1ice"],[/(quiz)$/gi,"$1zes"],[/s$/gi,"s"],[/$/gi,"s"]],singularRules:[[/(m)en$/gi,"$1an"],[/(pe)ople$/gi,"$1rson"],[/(child)ren$/gi,"$1"],[/([ti])a$/gi,"$1um"],[/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/gi,"$1$2sis"],[/(hive)s$/gi,"$1"],[/(tive)s$/gi,"$1"],[/(curve)s$/gi,"$1"],[/([lr])ves$/gi,"$1f"],[/([^fo])ves$/gi,"$1fe"],[/([^aeiouy]|qu)ies$/gi,"$1y"],[/(s)eries$/gi,"$1eries"],[/(m)ovies$/gi,"$1ovie"],[/(x|ch|ss|sh)es$/gi,"$1"],[/([m|l])ice$/gi,"$1ouse"],[/(bus)es$/gi,"$1"],[/(o)es$/gi,"$1"],[/(shoe)s$/gi,"$1"],[/(cris|ax|test)es$/gi,"$1is"],[/(octop|vir)i$/gi,"$1us"],[/(alias|status)es$/gi,"$1"],[/^(ox)en/gi,"$1"],[/(vert|ind)ices$/gi,"$1ex"],[/(matr)ices$/gi,"$1ix"],[/(quiz)zes$/gi,"$1"],[/s$/gi,""]],nonTitlecasedWords:["and","or","nor","a","an","the","so","but","to","of","at","by","from","into","on","onto","off","out","in","over","with","for"],idSuffix:/(_ids|_id)$/g,underbar:/_/g,spaceOrUnderbar:/[ _]/g,uppercase:/([A-Z])/g,underbarPrefix:/^_/,applyRules:function(e,t,r,s){if(s)e=s;else if(!r.includes(e.toLowerCase())){for(let i=0;i<t.length;i++)if(e.match(t[i][0])){e=e.replace(t[i][0],t[i][1]);break}}return e},pluralize:function(e,t){return p.applyRules(e,p.pluralRules,p.uncountableWords,t)},singularize:function(e,t){return p.applyRules(e,p.singularRules,p.uncountableWords,t)},camelize:function(e,t){let r=e.split("/");for(let s=0;s<r.length;s++){let n=r[s].split("_"),i=t&&s+1===r.length?1:0;for(let a=i;a<n.length;a++)n[a]=n[a].charAt(0).toUpperCase()+n[a].substring(1);r[s]=n.join("")}if(e=r.join("::"),t){let s=e.charAt(0).toLowerCase(),n=e.slice(1);e=s+n}return e},underscore:function(e){let t=e.split("::");for(let r=0;r<t.length;r++)t[r]=t[r].replace(p.uppercase,"_$1"),t[r]=t[r].replace(p.underbarPrefix,"");return e=t.join("/").toLowerCase(),e},humanize:function(e,t){return e=e.toLowerCase(),e=e.replace(p.idSuffix,""),e=e.replace(p.underbar," "),t||(e=p.capitalize(e)),e},capitalize:function(e){return e=e.toLowerCase(),e=e.substring(0,1).toUpperCase()+e.substring(1),e},dasherize:function(e){return e=e.replace(p.spaceOrUnderbar,"-"),e},camel2words:function(e,t){t?(e=p.camelize(e),e=p.underscore(e)):e=e.toLowerCase(),e=e.replace(p.underbar," ");let r=e.split(" ");for(let s=0;s<r.length;s++){let n=r[s].split("-");for(let i=0;i<n.length;i++)p.nonTitlecasedWords.includes(n[i].toLowerCase())||(n[i]=p.capitalize(n[i]));r[s]=n.join("-")}return e=r.join(" "),e=e.substring(0,1).toUpperCase()+e.substring(1),e},demodulize:function(e){let t=e.split("::");return e=t[t.length-1],e},tableize:function(e){return e=p.pluralize(p.underscore(e)),e},classify:function(e){return e=p.singularize(p.camelize(e)),e},foreignKey:function(e,t){return e=p.underscore(p.demodulize(e))+(t?"":"_")+"id",e},ordinalize:function(e){let t=e.split(" ");for(let r=0;r<t.length;r++){let s=parseInt(t[r]);if(Number.isNaN(s)){let n=t[r].substring(t[r].length-2),i=t[r].substring(t[r].length-1),a="th";n!=="11"&&n!=="12"&&n!=="13"&&(i==="1"?a="st":i==="2"?a="nd":i==="3"&&(a="rd")),t[r]+=a}}return e=t.join(" "),e}},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),n,i;t==="live"?(n=s?u.api.requests_max_num_burst_cacheable:u.api.requests_max_num_burst,i=s?u.api.requests_max_num_avg_cacheable:u.api.requests_max_num_avg):(n=s?u.api.requests_max_num_burst_test_cacheable:u.api.requests_max_num_burst_test,i=s?u.api.requests_max_num_avg_test_cacheable:u.api.requests_max_num_avg_test);let a=u.api.requests_max_secs_burst/n,m=u.api.requests_max_secs_avg/i,g=r*a,v=r*m,f=e?.totalRequests,c=0;return f&&f>0?f>n&&(f>i?c=v:c=g):c=Math.max(g,v),c=c*1e3,e?.minimumDelay&&(c=Math.max(e.minimumDelay,c)),e?.securityDelay&&(c+=e.securityDelay),c=Math.ceil(c),c};var Ge={raw:F,readDataFile:N,rateLimitDelay:_e},Je={denormalize:G};var Y={};_(Y,{appKey:()=>Ye,appKeyMatch:()=>Ze,appKeyValid:()=>Xe,arrayScope:()=>fe,isProvisioningApp:()=>Qe});var Ye=()=>Date.now().toString(36),Xe=e=>e.key!==void 0&&e.key!=="",Ze=(e,t)=>{let r=e!==void 0,s=t!==void 0;return!r&&!s||r&&s&&e.key===t.key},fe=e=>{if(!e)return[];if(Array.isArray(e))return e;let t=e.replace(/[ ,;]/g,"|").split("|");return Array.isArray(t)?t:[t]},Qe=e=>fe(e.scope).includes(u.provisioning.scope)||e.api==="provisioning";var X={};_(X,{allFlags:()=>tt,checkISODateTimeValue:()=>it,commandFlags:()=>et,findLongStringFlag:()=>st,fixDashedFlagValue:()=>nt,fixValueType:()=>rt});var et=(e,t)=>{let r={...e};if(t)for(let s of t)delete r[s];return r},tt=e=>({...e.flags,...e.baseFlags}),rt=e=>{let t=e;return t==="null"?t=null:Number(t)==t?t=Number(t):t=t==="true"?!0:t==="false"?!1:t,t},st=(e,t)=>{let r=t.startsWith("--")?t:`--${t}`,s,n=e.findIndex(a=>a.startsWith(r)),i=!1;if(n>-1){let a=e[n];if(a.includes("=")){let m=a.split("=");s=m.length===2?m[1]:"",i=!0}else s=e[n+1];return{value:s,index:n,single:i}}else return},nt=(e,t,r,s)=>{let n="____",i=t.name||r,a=t.char;if(!i&&!a)return e;let m=i?i.startsWith("--")?i:`--${i}`:void 0,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(n)){let T=c.startsWith(`${n}`)?c.replace(`${n}`,""):c.replace("-",`${n}-`);if(e[v]=pe+T,c.startsWith(n)&&s){let S=i?i.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},it=e=>{if(!e)throw Error("Date is empty");try{let t=Date.parse(e);if(Number.isNaN(t))throw new Error("Invalid date");return new Date(t)}catch{throw new Error("Error parsing date: "+e)}};var Z={};_(Z,{center:()=>ot,cleanDate:()=>ct,formatError:()=>pt,formatOutput:()=>ve,localeDate:()=>lt,maxLength:()=>at,printCSV:()=>xe,printJSON:()=>be,printObject:()=>ye});var he=require("util"),ye=(e,t)=>(0,he.inspect)(e,{showHidden:!1,depth:null,colors:t?.color===void 0?!0:t.color,sorted:t?.sort===void 0?!1:t?.sort,maxArrayLength:1/0,breakLength:t?.width||120}),be=(e,t)=>JSON.stringify(e,null,t?.unformatted?void 0:t?.tabSize||4),xe=(e,t)=>{if(!e||e.length===0)return"";let r=Object.keys(e[0]).filter(n=>["id","type"].includes(n)?t?.fields.includes(n):!0),s=r.map(n=>n.toUpperCase().replace(/_/g," ")).join(";")+`
|
|
2
|
-
`;return e.forEach(
|
|
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
|
|
4
|
-
`)},Mt=(e,t=!1)=>{let r=["desktop","home"],s=e.toLowerCase().split(/[\\\/]/g)[0];if(r.includes(s)){let
|
|
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(";")+`
|
|
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} `)} =-
|
|
5
5
|
|
|
6
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
|
|
8
|
-
`).map(r=>{let s=0;return r.split(" ").map(
|
|
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/`,
|
|
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});
|
package/lib/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
var xe=Object.defineProperty;var h=(e,t)=>{for(var r in t)xe(e,r,{get:t[r],enumerable:!0})};var Z={};h(Z,{Operation:()=>L,baseURL:()=>qe,execMode:()=>Ee,extractDomain:()=>Re,humanizeResource:()=>Se,isResourceCacheable:()=>Y,liveEnvironment:()=>Ie,request:()=>Oe,requestDataFile:()=>D,requestRateLimitDelay:()=>X,requestRaw:()=>j,response:()=>Ke,responseDenormalize:()=>P});var M=["in_progress","pending","completed","interrupted"],ve=["addresses","bundles","coupons","customer_addresses","customer_payment_sources","customer_subscriptions","customers","gift_cards","line_items","line_item_options","orders","price_tiers","prices","shipping_categories","sku_lists","sku_list_items","sku_options","skus","stock_items","stock_transfers","tags","tax_categories"],we=["addresses","authorizations","bundles","captures","coupons","customer_addresses","customer_payment_sources","customer_subscriptions","customers","gift_cards","line_items","line_item_options","orders","payment_methods","price_tiers","prices","refunds","returns","shipments","shipping_categories","shipping_methods","sku_lists","sku_list_items","sku_options","skus","stock_items","stock_transfers","tags","tax_categories","transactions","voids"],ke=["bundles","gift_cards","prices","promotions","sku_lists","sku_options","skus","stock_items"],Te=["addresses","bundles","customers","coupons","gift_cards","line_items","line_item_options","orders","returns","skus","sku_options","promotions","external_promotions","fixed_amount_promotions","fixed_price_promotions","free_gift_promotions","free_shipping_promotions","percentage_discount_promotions"],Ae=["orders","skus","sku_lists"],b={erl_oauth_limit_live:30,erl_average_limit_cachable_live:1e3,erl_average_limit_cachable_test:500,erl_burst_limit_cachable_live:250,erl_burst_limit_cachable_test:125,erl_average_limit_uncachable_live:200,erl_average_limit_uncachable_test:100,erl_burst_limit_uncachable_live:50,erl_burst_limit_uncachable_test:25},$e={api:{default_domain:"commercelayer.io",default_app_domain:"commercelayer.app",default_stg_domain:"commercelayer.co",token_expiration_mins:240,token_encoding_algorithm:"HS512",token_owner_types:["Customer","User"],requests_max_num_burst:b.erl_burst_limit_uncachable_live,requests_max_num_burst_cacheable:b.erl_burst_limit_cachable_live,requests_max_num_burst_test:b.erl_burst_limit_uncachable_test,requests_max_num_burst_test_cacheable:b.erl_burst_limit_cachable_test,requests_max_num_avg:b.erl_average_limit_uncachable_live,requests_max_num_avg_cacheable:b.erl_average_limit_cachable_live,requests_max_num_avg_test:b.erl_average_limit_uncachable_test,requests_max_num_avg_test_cacheable:b.erl_average_limit_cachable_test,requests_max_num_oauth:b.erl_oauth_limit_live,requests_max_secs_burst:10,requests_max_secs_oauth:60,requests_max_secs_avg:60,page_max_size:25,page_default_size:10},application:{kinds:["dashboard","user","metrics","contentful","bundles","customers","datocms","exports","external","gift_cards","imports","integration","inventory","orders","price_lists","promotions","resources","returns","sales_channel","sanity","shipments","skus","sku_lists","stock_transfers","subscriptions","tags","webapp","webhooks","zapier"],login_scopes:["market","stock_location","store"]},imports:{max_size:1e4,statuses:M,types:ve,max_queue_length:10,attachment_expiration:5},exports:{max_size:5e3,statuses:M,types:we,max_queue_length:10,attachment_expiration:5},cleanups:{max_size:1e4,statuses:M,types:ke,max_queue_length:10},webhooks:{retry_number:5},cli:{applications:["integration","sales_channel","user"]},doc:{core:"https://docs.commercelayer.io/core/",core_api_reference:"https://docs.commercelayer.io/developers/v/api-reference",core_how_tos:"https://docs.commercelayer.io/core/v/how-tos/",core_raste_limits:"https://docs.commercelayer.io/core/rate-limits",core_filtering_data:"https://docs.commercelayer.io/core/filtering-data#list-of-predicates",metrics:"https://docs.commercelayer.io/metrics/",metrics_api_reference:"https://docs.commercelayer.io/metrics/v/api-reference-m/",provisioning:"https://docs.commercelayer.io/provisioning/",provisioning_api_reference:"https://docs.commercelayer.io/provisioning/v/api-reference-p/",imports_resources:"https://docs.commercelayer.io/api/importing-resources#supported-resources",exports_resources:"https://docs.commercelayer.io/core/exporting-resources#supported-resources",cleanups_resources:"https://docs.commercelayer.io/core/cleaning-resources#supported-resources",webhooks_events:"https://docs.commercelayer.io/api/real-time-webhooks#supported-events",tags_resources:"https://docs.commercelayer.io/core/v/api-reference/tags#taggable-resources",links_resources:"https://docs.commercelayer.io/core/v/api-reference/links"},tags:{max_resource_tags:10,taggable_resources:Te,tag_name_max_length:25,tag_name_pattern:/^[0-9A-Za-z_-]{1,25}$/},provisioning:{default_subdomain:"provisioning",scope:"provisioning-api",applications:["user"]},metrics:{default_path:"metrics",scope:"metrics-api",applications:["integration","webapp"]},links:{default_domain:"c11r.link",linkable_resources:Ae}},u=$e;import{readFileSync as Ce}from"fs";var j=async(e,t,r)=>await(await fetch(new URL(`/api/${e.resource}`+(r?`/${r}`:""),e.baseUrl),{method:e.operation,headers:{"Content-Type":"application/vnd.api+json",Accept:"application/vnd.api+json",Authorization:`Bearer ${e.accessToken}`},body:JSON.stringify(t)}).then(n=>{if(n.ok)return n;throw new Error(n.statusText)})).json(),D=e=>{let t,r;try{t=Ce(e,"utf-8")}catch{throw new Error(`Unable to find or open the data file ${$.msg.error(e)}`)}try{r=JSON.parse(t)}catch{throw new Error(`Unable to parse the data file ${$.msg.error(e)}: invalid JSON format`)}return r.data?r:{data:r}},L=(r=>(r.Create="POST",r.Update="PATCH",r))(L||{});var J=(e,t)=>t.find(r=>e.id===r.id&&e.type===r.type),E=(e,t)=>{let r={id:e.id,type:e.type,...e.attributes};return e.relationships&&Object.keys(e.relationships).forEach(s=>{let n=e.relationships[s].data;n?Array.isArray(n)?r[s]=n.map(i=>E(J(i,t),t)):r[s]=E(J(n,t),t):n===null&&(r[s]=null)}),r},P=e=>{let t;e.links&&delete e.links;let r=e.data,s=e.included;return Array.isArray(r)?t=r.map(n=>E(n,s)):t=E(r,s),t};var p={uncountableWords:["equipment","information","rice","money","species","series","fish","sheep","moose","deer","news"],pluralRules:[[/(m)an$/gi,"$1en"],[/(pe)rson$/gi,"$1ople"],[/(child)$/gi,"$1ren"],[/^(ox)$/gi,"$1en"],[/(ax|test)is$/gi,"$1es"],[/(octop|vir)us$/gi,"$1i"],[/(alias|status)$/gi,"$1es"],[/(bu)s$/gi,"$1ses"],[/(buffal|tomat|potat)o$/gi,"$1oes"],[/([ti])um$/gi,"$1a"],[/sis$/gi,"ses"],[/(?:([^f])fe|([lr])f)$/gi,"$1$2ves"],[/(hive)$/gi,"$1s"],[/([^aeiouy]|qu)y$/gi,"$1ies"],[/(x|ch|ss|sh)$/gi,"$1es"],[/(matr|vert|ind)ix|ex$/gi,"$1ices"],[/([m|l])ouse$/gi,"$1ice"],[/(quiz)$/gi,"$1zes"],[/s$/gi,"s"],[/$/gi,"s"]],singularRules:[[/(m)en$/gi,"$1an"],[/(pe)ople$/gi,"$1rson"],[/(child)ren$/gi,"$1"],[/([ti])a$/gi,"$1um"],[/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/gi,"$1$2sis"],[/(hive)s$/gi,"$1"],[/(tive)s$/gi,"$1"],[/(curve)s$/gi,"$1"],[/([lr])ves$/gi,"$1f"],[/([^fo])ves$/gi,"$1fe"],[/([^aeiouy]|qu)ies$/gi,"$1y"],[/(s)eries$/gi,"$1eries"],[/(m)ovies$/gi,"$1ovie"],[/(x|ch|ss|sh)es$/gi,"$1"],[/([m|l])ice$/gi,"$1ouse"],[/(bus)es$/gi,"$1"],[/(o)es$/gi,"$1"],[/(shoe)s$/gi,"$1"],[/(cris|ax|test)es$/gi,"$1is"],[/(octop|vir)i$/gi,"$1us"],[/(alias|status)es$/gi,"$1"],[/^(ox)en/gi,"$1"],[/(vert|ind)ices$/gi,"$1ex"],[/(matr)ices$/gi,"$1ix"],[/(quiz)zes$/gi,"$1"],[/s$/gi,""]],nonTitlecasedWords:["and","or","nor","a","an","the","so","but","to","of","at","by","from","into","on","onto","off","out","in","over","with","for"],idSuffix:/(_ids|_id)$/g,underbar:/_/g,spaceOrUnderbar:/[ _]/g,uppercase:/([A-Z])/g,underbarPrefix:/^_/,applyRules:function(e,t,r,s){if(s)e=s;else if(!r.includes(e.toLowerCase())){for(let i=0;i<t.length;i++)if(e.match(t[i][0])){e=e.replace(t[i][0],t[i][1]);break}}return e},pluralize:function(e,t){return p.applyRules(e,p.pluralRules,p.uncountableWords,t)},singularize:function(e,t){return p.applyRules(e,p.singularRules,p.uncountableWords,t)},camelize:function(e,t){let r=e.split("/");for(let s=0;s<r.length;s++){let n=r[s].split("_"),i=t&&s+1===r.length?1:0;for(let a=i;a<n.length;a++)n[a]=n[a].charAt(0).toUpperCase()+n[a].substring(1);r[s]=n.join("")}if(e=r.join("::"),t){let s=e.charAt(0).toLowerCase(),n=e.slice(1);e=s+n}return e},underscore:function(e){let t=e.split("::");for(let r=0;r<t.length;r++)t[r]=t[r].replace(p.uppercase,"_$1"),t[r]=t[r].replace(p.underbarPrefix,"");return e=t.join("/").toLowerCase(),e},humanize:function(e,t){return e=e.toLowerCase(),e=e.replace(p.idSuffix,""),e=e.replace(p.underbar," "),t||(e=p.capitalize(e)),e},capitalize:function(e){return e=e.toLowerCase(),e=e.substring(0,1).toUpperCase()+e.substring(1),e},dasherize:function(e){return e=e.replace(p.spaceOrUnderbar,"-"),e},camel2words:function(e,t){t?(e=p.camelize(e),e=p.underscore(e)):e=e.toLowerCase(),e=e.replace(p.underbar," ");let r=e.split(" ");for(let s=0;s<r.length;s++){let n=r[s].split("-");for(let i=0;i<n.length;i++)p.nonTitlecasedWords.includes(n[i].toLowerCase())||(n[i]=p.capitalize(n[i]));r[s]=n.join("-")}return e=r.join(" "),e=e.substring(0,1).toUpperCase()+e.substring(1),e},demodulize:function(e){let t=e.split("::");return e=t[t.length-1],e},tableize:function(e){return e=p.pluralize(p.underscore(e)),e},classify:function(e){return e=p.singularize(p.camelize(e)),e},foreignKey:function(e,t){return e=p.underscore(p.demodulize(e))+(t?"":"_")+"id",e},ordinalize:function(e){let t=e.split(" ");for(let r=0;r<t.length;r++){let s=parseInt(t[r]);if(Number.isNaN(s)){let n=t[r].substring(t[r].length-2),i=t[r].substring(t[r].length-1),a="th";n!=="11"&&n!=="12"&&n!=="13"&&(i==="1"?a="st":i==="2"?a="nd":i==="3"&&(a="rd")),t[r]+=a}}return e=t.join(" "),e}},k=p;var qe=(e="core",t,r)=>`https://${(["core","metrics"].includes(e)&&t||e).toLowerCase()}.${r||u.api.default_domain}`,Re=e=>{if(e)return e.substring(e.indexOf(".")+1)},Ee=e=>e===!0||e==="live"?"live":"test",Se=(e,t)=>{let r=e.replace(/_/g," ");return t&&(r=k.singularize(r)),r};var ze=["bundles","imports","markets","prices","price_lists","promotions","buy_x_pay_y_promotions","external_promotions","fixed_amount_promotions","fixed_price_promotions","free_gift_promotions","free_shipping_promotions","percentage_discount_promotions","skus","sku_options","stock_items","stock_locations"],Y=(e,t)=>ze.includes(e||"")&&(t||"GET").toUpperCase()==="GET",Ie=e=>e==="live",X=e=>{let t=e?.environment||"test",r=e?.parallelRequests||1,s=Y(e?.resourceType,e?.method),n,i;t==="live"?(n=s?u.api.requests_max_num_burst_cacheable:u.api.requests_max_num_burst,i=s?u.api.requests_max_num_avg_cacheable:u.api.requests_max_num_avg):(n=s?u.api.requests_max_num_burst_test_cacheable:u.api.requests_max_num_burst_test,i=s?u.api.requests_max_num_avg_test_cacheable:u.api.requests_max_num_avg_test);let a=u.api.requests_max_secs_burst/n,m=u.api.requests_max_secs_avg/i,_=r*a,w=r*m,f=e?.totalRequests,c=0;return f&&f>0?f>n&&(f>i?c=w:c=_):c=Math.max(_,w),c=c*1e3,e?.minimumDelay&&(c=Math.max(e.minimumDelay,c)),e?.securityDelay&&(c+=e.securityDelay),c=Math.ceil(c),c};var Oe={raw:j,readDataFile:D,rateLimitDelay:X},Ke={denormalize:P};var ee={};h(ee,{appKey:()=>Be,appKeyMatch:()=>je,appKeyValid:()=>Me,arrayScope:()=>Q,isProvisioningApp:()=>De});var Be=()=>Date.now().toString(36),Me=e=>e.key!==void 0&&e.key!=="",je=(e,t)=>{let r=e!==void 0,s=t!==void 0;return!r&&!s||r&&s&&e.key===t.key},Q=e=>{if(!e)return[];if(Array.isArray(e))return e;let t=e.replace(/[ ,;]/g,"|").split("|");return Array.isArray(t)?t:[t]},De=e=>Q(e.scope).includes(u.provisioning.scope)||e.api==="provisioning";var te={};h(te,{allFlags:()=>Pe,checkISODateTimeValue:()=>Fe,commandFlags:()=>Le,findLongStringFlag:()=>Ue,fixDashedFlagValue:()=>We,fixValueType:()=>Ve});var Le=(e,t)=>{let r={...e};if(t)for(let s of t)delete r[s];return r},Pe=e=>({...e.flags,...e.baseFlags}),Ve=e=>{let t=e;return t==="null"?t=null:Number(t)==t?t=Number(t):t=t==="true"?!0:t==="false"?!1:t,t},Ue=(e,t)=>{let r=t.startsWith("--")?t:`--${t}`,s,n=e.findIndex(a=>a.startsWith(r)),i=!1;if(n>-1){let a=e[n];if(a.includes("=")){let m=a.split("=");s=m.length===2?m[1]:"",i=!0}else s=e[n+1];return{value:s,index:n,single:i}}else return},We=(e,t,r,s)=>{let n="____",i=t.name||r,a=t.char;if(!i&&!a)return e;let m=i?i.startsWith("--")?i:`--${i}`:void 0,_=a?t.char.startsWith("-")?a:`-${a}`:void 0,w=e.findIndex(A=>_&&A.startsWith(_)||m&&A.startsWith(m));if(w<0)return e;let f=e[w],c="",G="";if(_&&f.startsWith(_))c=f.replace(_,"").trim(),f=_;else if(m&&f.startsWith(m))c=f.replace(m,"").trim(),f=m;else return e;if(c.startsWith("=")?(c=c.slice(1),G=f+"="):c||(c=e[++w]),c.startsWith("-")||c.startsWith(n)){let A=c.startsWith(`${n}`)?c.replace(`${n}`,""):c.replace("-",`${n}-`);if(e[w]=G+A,c.startsWith(n)&&s){let R=i?i.replace("--",""):void 0,O=Object.entries(s.flags).find(([B,be])=>be===c);O&&(!R||R===O[0])&&(s.flags[O[0]]=A);let K=Object.values(s.raw).find(B=>B.type==="flag"&&B.input===c);K&&(!R||R===K.flag)&&(K.input=A)}}return e},Fe=e=>{if(!e)throw Error("Date is empty");try{let t=Date.parse(e);if(Number.isNaN(t))throw new Error("Invalid date");return new Date(t)}catch{throw new Error("Error parsing date: "+e)}};var oe={};h(oe,{center:()=>He,cleanDate:()=>Je,formatError:()=>Xe,formatOutput:()=>ie,localeDate:()=>Ye,maxLength:()=>Ge,printCSV:()=>ne,printJSON:()=>se,printObject:()=>re});import{inspect as Ne}from"util";var re=(e,t)=>Ne(e,{showHidden:!1,depth:null,colors:t?.color===void 0?!0:t.color,sorted:t?.sort===void 0?!1:t?.sort,maxArrayLength:1/0,breakLength:t?.width||120}),se=(e,t)=>JSON.stringify(e,null,t?.unformatted?void 0:t?.tabSize||4),ne=(e,t)=>{if(!e||e.length===0)return"";let r=Object.keys(e[0]).filter(n=>["id","type"].includes(n)?t?.fields.includes(n):!0),s=r.map(n=>n.toUpperCase().replace(/_/g," ")).join(";")+`
|
|
2
|
-
`;return e.forEach(
|
|
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
|
|
4
|
-
`)},St=(e,t=!1)=>{let r=["desktop","home"],s=e.toLowerCase().split(/[\\\/]/g)[0];if(r.includes(s)){let
|
|
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(";")+`
|
|
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} `)} =-
|
|
5
5
|
|
|
6
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)}},
|
|
8
|
-
`).map(r=>{let s=0;return r.split(" ").map(
|
|
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/`,
|
|
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};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commercelayer/cli-core",
|
|
3
|
-
"version": "6.0.0-
|
|
3
|
+
"version": "6.0.0-oclif4.2",
|
|
4
4
|
"author": "Pierluigi Viti <pierluigi@commercelayer.io>",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "Commerce Layer Javascript CLI core lib",
|
|
@@ -8,16 +8,9 @@
|
|
|
8
8
|
"types": "lib/index.d.ts",
|
|
9
9
|
"module": "lib/index.mjs",
|
|
10
10
|
"exports": {
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
"default": "./lib/index.mjs"
|
|
15
|
-
},
|
|
16
|
-
"require": {
|
|
17
|
-
"types": "./lib/index.d.ts",
|
|
18
|
-
"default": "./lib/index.js"
|
|
19
|
-
}
|
|
20
|
-
}
|
|
11
|
+
"types": "./lib/index.d.ts",
|
|
12
|
+
"require": "./lib/index.js",
|
|
13
|
+
"import": "./lib/index.mjs"
|
|
21
14
|
},
|
|
22
15
|
"scripts": {
|
|
23
16
|
"lint": "eslint ./src --ext .ts",
|
|
@@ -32,6 +25,7 @@
|
|
|
32
25
|
},
|
|
33
26
|
"keywords": [
|
|
34
27
|
"ecommerce",
|
|
28
|
+
"jamstack",
|
|
35
29
|
"commercelayer"
|
|
36
30
|
],
|
|
37
31
|
"files": [
|
|
@@ -44,16 +38,15 @@
|
|
|
44
38
|
"@babel/preset-env": "^7.29.2",
|
|
45
39
|
"@babel/preset-typescript": "^7.28.5",
|
|
46
40
|
"@commercelayer/eslint-config-ts": "^2.6.0",
|
|
47
|
-
"@oclif/core": "^4.0.18",
|
|
48
41
|
"@semantic-release/changelog": "^6.0.3",
|
|
49
42
|
"@semantic-release/git": "^10.0.1",
|
|
50
|
-
"@types/jest": "^
|
|
43
|
+
"@types/jest": "^29.5.14",
|
|
51
44
|
"@types/jsonwebtoken": "^9.0.10",
|
|
52
45
|
"@types/node": "^24.12.0",
|
|
53
46
|
"@typescript-eslint/eslint-plugin": "^7.18.0",
|
|
54
|
-
"dotenv": "^
|
|
47
|
+
"dotenv": "^16.6.1",
|
|
55
48
|
"eslint": "^8.57.1",
|
|
56
|
-
"jest": "^
|
|
49
|
+
"jest": "^29.7.0",
|
|
57
50
|
"oclif": "^4.22.92",
|
|
58
51
|
"semantic-release": "^25.0.3",
|
|
59
52
|
"tsup": "^8.5.1",
|
|
@@ -61,15 +54,12 @@
|
|
|
61
54
|
"typescript": "^5.9.3"
|
|
62
55
|
},
|
|
63
56
|
"dependencies": {
|
|
64
|
-
"@commercelayer/js-auth": "^7.
|
|
65
|
-
"@oclif/core": "^4.
|
|
66
|
-
"chalk": "^
|
|
57
|
+
"@commercelayer/js-auth": "^6.7.2",
|
|
58
|
+
"@oclif/core": "^4.10.0",
|
|
59
|
+
"chalk": "^4.1.2",
|
|
67
60
|
"jsonwebtoken": "^9.0.3",
|
|
68
61
|
"update-notifier-cjs": "^5.1.7"
|
|
69
62
|
},
|
|
70
|
-
"peerDependencies": {
|
|
71
|
-
"@oclif/core": "^4"
|
|
72
|
-
},
|
|
73
63
|
"repository": "github:commercelayer/commercelayer-cli-core",
|
|
74
64
|
"publishConfig": {
|
|
75
65
|
"access": "public"
|