@commercelayer/cli-core 4.12.0 → 4.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/api.js +107 -1
- package/lib/cjs/application.js +36 -1
- package/lib/cjs/color.js +116 -1
- package/lib/cjs/command.js +95 -1
- package/lib/cjs/config.js +182 -1
- package/lib/cjs/filter.js +81 -1
- package/lib/cjs/help.js +103 -5
- package/lib/cjs/index.js +46 -1
- package/lib/cjs/inflector.js +255 -1
- package/lib/cjs/jsonapi.js +38 -1
- package/lib/cjs/output.js +83 -3
- package/lib/cjs/raw.js +49 -1
- package/lib/cjs/schema.js +20 -1
- package/lib/cjs/style.js +39 -1
- package/lib/cjs/symbol.js +28 -1
- package/lib/cjs/text.js +23 -1
- package/lib/cjs/token.js +177 -1
- package/lib/cjs/update.js +22 -4
- package/lib/cjs/util.js +59 -2
- package/lib/esm/api.js +93 -1
- package/lib/esm/application.js +26 -1
- package/lib/esm/color.js +110 -1
- package/lib/esm/command.js +90 -1
- package/lib/esm/config.js +180 -1
- package/lib/esm/filter.js +71 -1
- package/lib/esm/help.js +100 -5
- package/lib/esm/index.js +26 -1
- package/lib/esm/inflector.js +253 -1
- package/lib/esm/jsonapi.js +42 -1
- package/lib/esm/output.js +72 -3
- package/lib/esm/raw.js +42 -1
- package/lib/esm/schema.js +14 -1
- package/lib/esm/style.js +19 -1
- package/lib/esm/symbol.js +25 -1
- package/lib/esm/text.js +13 -1
- package/lib/esm/token.js +166 -1
- package/lib/esm/update.js +16 -4
- package/lib/esm/util.js +51 -2
- package/lib/tsconfig.esm.tsbuildinfo +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +16 -17
package/lib/cjs/api.js
CHANGED
|
@@ -1 +1,107 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.response = exports.request = exports.responseDenormalize = exports.Operation = exports.requestDataFile = exports.requestRaw = exports.requestRateLimitDelay = exports.liveEnvironment = exports.isResourceCacheable = exports.humanizeResource = exports.execMode = exports.extractDomain = exports.baseURL = void 0;
|
|
7
|
+
const config_1 = __importDefault(require("./config"));
|
|
8
|
+
const raw_1 = require("./raw");
|
|
9
|
+
Object.defineProperty(exports, "requestRaw", { enumerable: true, get: function () { return raw_1.rawRequest; } });
|
|
10
|
+
Object.defineProperty(exports, "requestDataFile", { enumerable: true, get: function () { return raw_1.readDataFile; } });
|
|
11
|
+
Object.defineProperty(exports, "Operation", { enumerable: true, get: function () { return raw_1.Operation; } });
|
|
12
|
+
const jsonapi_1 = require("./jsonapi");
|
|
13
|
+
Object.defineProperty(exports, "responseDenormalize", { enumerable: true, get: function () { return jsonapi_1.denormalize; } });
|
|
14
|
+
/** Build base URL */
|
|
15
|
+
const baseURL = (slug, domain, provisioning) => {
|
|
16
|
+
const subdomain = provisioning ? 'provisioning' : (slug || '');
|
|
17
|
+
return `https://${subdomain.toLowerCase()}.${domain || config_1.default.api.default_domain}`;
|
|
18
|
+
};
|
|
19
|
+
exports.baseURL = baseURL;
|
|
20
|
+
/** Extract domain name from URL */
|
|
21
|
+
const extractDomain = (baseUrl) => {
|
|
22
|
+
if (!baseUrl)
|
|
23
|
+
return undefined;
|
|
24
|
+
return baseUrl.substring(baseUrl.indexOf('.') + 1);
|
|
25
|
+
};
|
|
26
|
+
exports.extractDomain = extractDomain;
|
|
27
|
+
/** Decode API execution mode */
|
|
28
|
+
const execMode = (liveFlag) => {
|
|
29
|
+
return ((liveFlag === true) || (liveFlag === 'live')) ? 'live' : 'test';
|
|
30
|
+
};
|
|
31
|
+
exports.execMode = execMode;
|
|
32
|
+
const humanizeResource = (type) => {
|
|
33
|
+
return type.replace(/_/g, ' ');
|
|
34
|
+
};
|
|
35
|
+
exports.humanizeResource = humanizeResource;
|
|
36
|
+
const CACHEABLE_RESOURCES = [
|
|
37
|
+
'bundles',
|
|
38
|
+
'imports',
|
|
39
|
+
'markets',
|
|
40
|
+
'prices',
|
|
41
|
+
'price_lists',
|
|
42
|
+
'promotions',
|
|
43
|
+
'external_promotions',
|
|
44
|
+
'fixed_amount_promotions',
|
|
45
|
+
'fixed_price_promotions',
|
|
46
|
+
'free_gift_promotions',
|
|
47
|
+
'free_shipping_promotions',
|
|
48
|
+
'percentage_discount_promotions',
|
|
49
|
+
'skus',
|
|
50
|
+
'sku_options',
|
|
51
|
+
'stock_items',
|
|
52
|
+
'stock_locations'
|
|
53
|
+
];
|
|
54
|
+
const isResourceCacheable = (resource, method) => {
|
|
55
|
+
return CACHEABLE_RESOURCES.includes(resource || '') && ((method || 'get').toLowerCase() === 'get');
|
|
56
|
+
};
|
|
57
|
+
exports.isResourceCacheable = isResourceCacheable;
|
|
58
|
+
const liveEnvironment = (env) => {
|
|
59
|
+
return (env === 'live');
|
|
60
|
+
};
|
|
61
|
+
exports.liveEnvironment = liveEnvironment;
|
|
62
|
+
const requestRateLimitDelay = (options) => {
|
|
63
|
+
const env = (options === null || options === void 0 ? void 0 : options.environment) || 'test';
|
|
64
|
+
const parallelRequests = (options === null || options === void 0 ? void 0 : options.parallelRequests) || 1;
|
|
65
|
+
const resourceCacheable = (0, exports.isResourceCacheable)(options === null || options === void 0 ? void 0 : options.resourceType, options === null || options === void 0 ? void 0 : options.method);
|
|
66
|
+
let requestsMaxNumBurst = resourceCacheable ? config_1.default.api.requests_max_num_burst_cacheable : config_1.default.api.requests_max_num_burst;
|
|
67
|
+
let requestsMaxNumAvg = resourceCacheable ? config_1.default.api.requests_max_num_avg_cacheable : config_1.default.api.requests_max_num_avg;
|
|
68
|
+
// Test env allows half number of requests than live
|
|
69
|
+
if (env !== 'live') {
|
|
70
|
+
requestsMaxNumBurst = resourceCacheable ? config_1.default.api.requests_max_num_burst_test_cacheable : config_1.default.api.requests_max_num_burst_test;
|
|
71
|
+
requestsMaxNumAvg = resourceCacheable ? config_1.default.api.requests_max_num_avg_test_cacheable : config_1.default.api.requests_max_num_avg_test;
|
|
72
|
+
}
|
|
73
|
+
const unitDelayBurst = config_1.default.api.requests_max_secs_burst / requestsMaxNumBurst;
|
|
74
|
+
const unitDelayAvg = config_1.default.api.requests_max_secs_avg / requestsMaxNumAvg;
|
|
75
|
+
const delayBurst = parallelRequests * unitDelayBurst;
|
|
76
|
+
const delayAvg = parallelRequests * unitDelayAvg;
|
|
77
|
+
// If the total number of requests is known the delay can be optimized
|
|
78
|
+
const totalRequests = options === null || options === void 0 ? void 0 : options.totalRequests;
|
|
79
|
+
let delay = 0;
|
|
80
|
+
if (totalRequests) {
|
|
81
|
+
if (totalRequests > requestsMaxNumBurst) {
|
|
82
|
+
if (totalRequests > requestsMaxNumAvg)
|
|
83
|
+
delay = delayAvg;
|
|
84
|
+
else
|
|
85
|
+
delay = delayBurst;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
else
|
|
89
|
+
delay = Math.max(delayBurst, delayAvg);
|
|
90
|
+
// Msec delay
|
|
91
|
+
delay = delay * 1000;
|
|
92
|
+
if (options === null || options === void 0 ? void 0 : options.minimumDelay)
|
|
93
|
+
delay = Math.max(options.minimumDelay, delay);
|
|
94
|
+
if (options === null || options === void 0 ? void 0 : options.securityDelay)
|
|
95
|
+
delay += options.securityDelay;
|
|
96
|
+
delay = Math.ceil(delay);
|
|
97
|
+
return delay;
|
|
98
|
+
};
|
|
99
|
+
exports.requestRateLimitDelay = requestRateLimitDelay;
|
|
100
|
+
exports.request = {
|
|
101
|
+
raw: raw_1.rawRequest,
|
|
102
|
+
readDataFile: raw_1.readDataFile,
|
|
103
|
+
rateLimitDelay: exports.requestRateLimitDelay
|
|
104
|
+
};
|
|
105
|
+
exports.response = {
|
|
106
|
+
denormalize: jsonapi_1.denormalize
|
|
107
|
+
};
|
package/lib/cjs/application.js
CHANGED
|
@@ -1 +1,36 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.isProvisioningApp = exports.arrayScope = exports.appKeyMatch = exports.appKeyValid = exports.appKey = void 0;
|
|
7
|
+
const config_1 = __importDefault(require("./config"));
|
|
8
|
+
/** Build application key */
|
|
9
|
+
const appKey = () => {
|
|
10
|
+
return Date.now().toString(36);
|
|
11
|
+
};
|
|
12
|
+
exports.appKey = appKey;
|
|
13
|
+
/** Check application key */
|
|
14
|
+
const appKeyValid = (appKey) => {
|
|
15
|
+
return (appKey.key !== undefined) && (appKey.key !== '');
|
|
16
|
+
};
|
|
17
|
+
exports.appKeyValid = appKeyValid;
|
|
18
|
+
/** Check if two application keys are equal */
|
|
19
|
+
const appKeyMatch = (app1, app2) => {
|
|
20
|
+
const a1 = app1 !== undefined;
|
|
21
|
+
const a2 = app2 !== undefined;
|
|
22
|
+
return (!a1 && !a2) || (a1 && a2 && (app1.key === app2.key));
|
|
23
|
+
};
|
|
24
|
+
exports.appKeyMatch = appKeyMatch;
|
|
25
|
+
const arrayScope = (scope) => {
|
|
26
|
+
if (!scope)
|
|
27
|
+
return [];
|
|
28
|
+
else
|
|
29
|
+
return Array.isArray(scope) ? scope : [scope];
|
|
30
|
+
};
|
|
31
|
+
exports.arrayScope = arrayScope;
|
|
32
|
+
const isProvisioningApp = (app) => {
|
|
33
|
+
const scope = arrayScope(app.scope);
|
|
34
|
+
return scope.includes(config_1.default.provisioning.scope) || (app.api === 'provisioning');
|
|
35
|
+
};
|
|
36
|
+
exports.isProvisioningApp = isProvisioningApp;
|
package/lib/cjs/color.js
CHANGED
|
@@ -1 +1,116 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.table = exports.cli = exports.msg = exports.api = exports.type = exports.style = exports.bg = exports.italic = exports.underline = exports.dim = exports.bold = exports.magentaBright = exports.magenta = exports.cyanBright = exports.cyan = exports.grey = exports.blackBright = exports.black = exports.whiteBright = exports.white = exports.blueBright = exports.blue = exports.yellowBright = exports.yellow = exports.greenBright = exports.green = exports.redBright = exports.red = exports.hidden = exports.visible = exports.reset = void 0;
|
|
7
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
+
exports.reset = chalk_1.default.reset;
|
|
9
|
+
exports.visible = chalk_1.default.visible;
|
|
10
|
+
exports.hidden = chalk_1.default.hidden;
|
|
11
|
+
exports.red = chalk_1.default.red;
|
|
12
|
+
exports.redBright = chalk_1.default.redBright;
|
|
13
|
+
exports.green = chalk_1.default.green;
|
|
14
|
+
exports.greenBright = chalk_1.default.greenBright;
|
|
15
|
+
exports.yellow = chalk_1.default.yellow;
|
|
16
|
+
exports.yellowBright = chalk_1.default.yellowBright;
|
|
17
|
+
exports.blue = chalk_1.default.blue;
|
|
18
|
+
exports.blueBright = chalk_1.default.blueBright;
|
|
19
|
+
exports.white = chalk_1.default.white;
|
|
20
|
+
exports.whiteBright = chalk_1.default.whiteBright;
|
|
21
|
+
exports.black = chalk_1.default.black;
|
|
22
|
+
exports.blackBright = chalk_1.default.blackBright;
|
|
23
|
+
exports.grey = chalk_1.default.grey;
|
|
24
|
+
exports.cyan = chalk_1.default.cyan;
|
|
25
|
+
exports.cyanBright = chalk_1.default.cyanBright;
|
|
26
|
+
exports.magenta = chalk_1.default.magenta;
|
|
27
|
+
exports.magentaBright = chalk_1.default.magentaBright;
|
|
28
|
+
exports.bold = chalk_1.default.bold;
|
|
29
|
+
exports.dim = chalk_1.default.dim;
|
|
30
|
+
exports.underline = chalk_1.default.underline;
|
|
31
|
+
exports.italic = chalk_1.default.italic;
|
|
32
|
+
exports.bg = {
|
|
33
|
+
white: chalk_1.default.bgWhite,
|
|
34
|
+
whiteBright: chalk_1.default.bgWhiteBright,
|
|
35
|
+
black: chalk_1.default.bgBlack,
|
|
36
|
+
blackBright: chalk_1.default.bgBlackBright,
|
|
37
|
+
grey: chalk_1.default.bgGrey,
|
|
38
|
+
red: chalk_1.default.bgRed,
|
|
39
|
+
redBright: chalk_1.default.bgRedBright,
|
|
40
|
+
green: chalk_1.default.bgGreen,
|
|
41
|
+
greenBright: chalk_1.default.bgGreenBright,
|
|
42
|
+
yellow: chalk_1.default.bgYellow,
|
|
43
|
+
yellowBright: chalk_1.default.bgYellowBright,
|
|
44
|
+
blue: chalk_1.default.bgBlue,
|
|
45
|
+
blueBright: chalk_1.default.bgBlueBright,
|
|
46
|
+
magenta: chalk_1.default.bgMagenta,
|
|
47
|
+
magentaBright: chalk_1.default.bgMagentaBright,
|
|
48
|
+
cyan: chalk_1.default.bgCyan,
|
|
49
|
+
cyanBright: chalk_1.default.bgCyanBright
|
|
50
|
+
};
|
|
51
|
+
exports.style = {
|
|
52
|
+
organization: exports.yellowBright.bold,
|
|
53
|
+
application: exports.yellowBright.bold,
|
|
54
|
+
slug: exports.yellowBright,
|
|
55
|
+
id: exports.bold,
|
|
56
|
+
token: exports.blueBright,
|
|
57
|
+
resource: exports.bold,
|
|
58
|
+
attribute: exports.italic,
|
|
59
|
+
trigger: exports.cyanBright,
|
|
60
|
+
kind: exports.cyanBright,
|
|
61
|
+
live: exports.greenBright,
|
|
62
|
+
test: exports.yellowBright,
|
|
63
|
+
execMode: (mode) => { return (mode === 'live') ? exports.style.live : exports.style.test; },
|
|
64
|
+
success: exports.greenBright,
|
|
65
|
+
warning: exports.yellowBright,
|
|
66
|
+
error: exports.redBright,
|
|
67
|
+
arg: exports.italic,
|
|
68
|
+
flag: exports.italic,
|
|
69
|
+
command: exports.italic,
|
|
70
|
+
value: exports.italic,
|
|
71
|
+
alias: exports.cyanBright,
|
|
72
|
+
plugin: exports.blueBright,
|
|
73
|
+
title: exports.blueBright,
|
|
74
|
+
path: exports.italic,
|
|
75
|
+
datetime: exports.cyanBright,
|
|
76
|
+
number: exports.yellowBright,
|
|
77
|
+
};
|
|
78
|
+
/* Aliases */
|
|
79
|
+
exports.type = {
|
|
80
|
+
datetime: exports.style.datetime,
|
|
81
|
+
number: exports.style.number,
|
|
82
|
+
path: exports.style.path
|
|
83
|
+
};
|
|
84
|
+
/* Aliases */
|
|
85
|
+
exports.api = {
|
|
86
|
+
organization: exports.style.organization,
|
|
87
|
+
application: exports.style.application,
|
|
88
|
+
slug: exports.style.slug,
|
|
89
|
+
id: exports.style.id,
|
|
90
|
+
token: exports.style.token,
|
|
91
|
+
resource: exports.style.resource,
|
|
92
|
+
attribute: exports.style.attribute,
|
|
93
|
+
trigger: exports.style.trigger,
|
|
94
|
+
kind: exports.style.kind,
|
|
95
|
+
live: exports.style.live,
|
|
96
|
+
test: exports.style.test,
|
|
97
|
+
};
|
|
98
|
+
/* Aliases */
|
|
99
|
+
exports.msg = {
|
|
100
|
+
success: exports.style.success,
|
|
101
|
+
warning: exports.style.warning,
|
|
102
|
+
error: exports.style.error,
|
|
103
|
+
};
|
|
104
|
+
/* Aliases */
|
|
105
|
+
exports.cli = {
|
|
106
|
+
arg: exports.style.arg,
|
|
107
|
+
flag: exports.style.flag,
|
|
108
|
+
command: exports.style.command,
|
|
109
|
+
value: exports.style.value,
|
|
110
|
+
alias: exports.style.alias,
|
|
111
|
+
plugin: exports.style.plugin
|
|
112
|
+
};
|
|
113
|
+
exports.table = {
|
|
114
|
+
header: exports.yellowBright.bold,
|
|
115
|
+
key: exports.blueBright
|
|
116
|
+
};
|
package/lib/cjs/command.js
CHANGED
|
@@ -1 +1,95 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-unsafe-argument */
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.fixDashedFlagValue = exports.findLongStringFlag = exports.fixValueType = exports.commandFlags = void 0;
|
|
5
|
+
/** Copy command flags excluding a subset */
|
|
6
|
+
const commandFlags = (flags, exclude) => {
|
|
7
|
+
const filteredFlags = Object.assign({}, flags);
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
|
9
|
+
if (exclude)
|
|
10
|
+
for (const e of exclude)
|
|
11
|
+
delete filteredFlags[e];
|
|
12
|
+
return filteredFlags;
|
|
13
|
+
};
|
|
14
|
+
exports.commandFlags = commandFlags;
|
|
15
|
+
const fixValueType = (val) => {
|
|
16
|
+
let v = val;
|
|
17
|
+
if (v === 'null')
|
|
18
|
+
v = null; // null check
|
|
19
|
+
else
|
|
20
|
+
// eslint-disable-next-line eqeqeq
|
|
21
|
+
if (Number(v) == v)
|
|
22
|
+
v = Number(v); // number check
|
|
23
|
+
else
|
|
24
|
+
v = (v === 'true') ? true : (v === 'false') ? false : v; // boolean check
|
|
25
|
+
return v;
|
|
26
|
+
};
|
|
27
|
+
exports.fixValueType = fixValueType;
|
|
28
|
+
const findLongStringFlag = (args, name) => {
|
|
29
|
+
const flag = name.startsWith('--') ? name : `--${name}`;
|
|
30
|
+
let value;
|
|
31
|
+
const index = args.findIndex(arg => arg.startsWith(flag));
|
|
32
|
+
let single = false;
|
|
33
|
+
if (index > -1) {
|
|
34
|
+
const val = args[index];
|
|
35
|
+
if (val.includes('=')) {
|
|
36
|
+
const vals = val.split('=');
|
|
37
|
+
value = (vals.length === 2) ? vals[1] : '';
|
|
38
|
+
single = true;
|
|
39
|
+
}
|
|
40
|
+
else
|
|
41
|
+
value = args[index + 1];
|
|
42
|
+
return { value, index, single };
|
|
43
|
+
}
|
|
44
|
+
else
|
|
45
|
+
return undefined;
|
|
46
|
+
};
|
|
47
|
+
exports.findLongStringFlag = findLongStringFlag;
|
|
48
|
+
const fixDashedFlagValue = (argv, flag, name, parsed) => {
|
|
49
|
+
const TEMP_PREFIX = '____';
|
|
50
|
+
const name_ = flag.name || name;
|
|
51
|
+
const char_ = flag.char;
|
|
52
|
+
if (!name_ && !char_)
|
|
53
|
+
return argv;
|
|
54
|
+
const n = name_ ? (name_.startsWith('--') ? name_ : `--${name_}`) : undefined;
|
|
55
|
+
const c = char_ ? (flag.char.startsWith('-') ? char_ : `-${char_}`) : undefined;
|
|
56
|
+
let cidIdx = argv.findIndex(a => {
|
|
57
|
+
return ((c && a.startsWith(c)) || (n && a.startsWith(n)));
|
|
58
|
+
});
|
|
59
|
+
if (cidIdx < 0)
|
|
60
|
+
return argv;
|
|
61
|
+
let flagKey = argv[cidIdx];
|
|
62
|
+
let flagValue = '';
|
|
63
|
+
let prefix = '';
|
|
64
|
+
if (c && flagKey.startsWith(c)) {
|
|
65
|
+
flagValue = flagKey.replace(c, '').trim();
|
|
66
|
+
flagKey = c;
|
|
67
|
+
}
|
|
68
|
+
else if (n && flagKey.startsWith(n)) {
|
|
69
|
+
flagValue = flagKey.replace(n, '').trim();
|
|
70
|
+
flagKey = n;
|
|
71
|
+
}
|
|
72
|
+
else
|
|
73
|
+
return argv;
|
|
74
|
+
if (flagValue.startsWith('=')) {
|
|
75
|
+
flagValue = flagValue.slice(1);
|
|
76
|
+
prefix = flagKey + '=';
|
|
77
|
+
}
|
|
78
|
+
else if (!flagValue)
|
|
79
|
+
flagValue = argv[++cidIdx];
|
|
80
|
+
if (flagValue.startsWith('-') || flagValue.startsWith(TEMP_PREFIX)) {
|
|
81
|
+
const val = flagValue.startsWith(`${TEMP_PREFIX}`) ? flagValue.replace(`${TEMP_PREFIX}`, '') : flagValue.replace('-', `${TEMP_PREFIX}-`);
|
|
82
|
+
argv[cidIdx] = prefix + val;
|
|
83
|
+
if (flagValue.startsWith(TEMP_PREFIX) && parsed) {
|
|
84
|
+
const nameKey = name_ ? name_.replace('--', '') : undefined;
|
|
85
|
+
const parsedFlag = Object.entries(parsed.flags).find(([k, v]) => v === flagValue);
|
|
86
|
+
if (parsedFlag && (!nameKey || nameKey === parsedFlag[0]))
|
|
87
|
+
parsed.flags[parsedFlag[0]] = val;
|
|
88
|
+
const parsedRawFlag = Object.values(parsed.raw).find((f) => (f.type === 'flag') && (f.input === flagValue));
|
|
89
|
+
if (parsedRawFlag && (!nameKey || nameKey === parsedRawFlag.flag))
|
|
90
|
+
parsedRawFlag.input = val;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return argv;
|
|
94
|
+
};
|
|
95
|
+
exports.fixDashedFlagValue = fixDashedFlagValue;
|
package/lib/cjs/config.js
CHANGED
|
@@ -1 +1,182 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const JOB_STATUSES = [
|
|
4
|
+
'in_progress',
|
|
5
|
+
'pending',
|
|
6
|
+
'completed',
|
|
7
|
+
'interrupted'
|
|
8
|
+
];
|
|
9
|
+
const IMPORT_RESOURCE_TYPES = [
|
|
10
|
+
'addresses',
|
|
11
|
+
'bundles',
|
|
12
|
+
'coupons',
|
|
13
|
+
'customer_addresses',
|
|
14
|
+
'customer_payment_sources',
|
|
15
|
+
'customer_subscriptions',
|
|
16
|
+
'customers',
|
|
17
|
+
'gift_cards',
|
|
18
|
+
'line_items',
|
|
19
|
+
'line_item_options',
|
|
20
|
+
'orders',
|
|
21
|
+
'price_tiers',
|
|
22
|
+
'prices',
|
|
23
|
+
'shipping_categories',
|
|
24
|
+
'sku_lists',
|
|
25
|
+
'sku_list_items',
|
|
26
|
+
'sku_options',
|
|
27
|
+
'skus',
|
|
28
|
+
'stock_items',
|
|
29
|
+
'tags',
|
|
30
|
+
'tax_categories'
|
|
31
|
+
];
|
|
32
|
+
const EXPORT_RESOURCE_TYPES = [
|
|
33
|
+
'addresses',
|
|
34
|
+
'authorizations',
|
|
35
|
+
'bundles',
|
|
36
|
+
'captures',
|
|
37
|
+
'coupons',
|
|
38
|
+
'customer_addresses',
|
|
39
|
+
'customer_subscriptions',
|
|
40
|
+
'customers',
|
|
41
|
+
'gift_cards',
|
|
42
|
+
'line_items',
|
|
43
|
+
'orders',
|
|
44
|
+
'payment_methods',
|
|
45
|
+
'price_tiers',
|
|
46
|
+
'prices',
|
|
47
|
+
'refunds',
|
|
48
|
+
'shipments',
|
|
49
|
+
'shipping_categories',
|
|
50
|
+
'shipping_methods',
|
|
51
|
+
'sku_lists',
|
|
52
|
+
'sku_list_items',
|
|
53
|
+
'sku_options',
|
|
54
|
+
'skus',
|
|
55
|
+
'stock_items',
|
|
56
|
+
'tags',
|
|
57
|
+
'tax_categories',
|
|
58
|
+
'transactions',
|
|
59
|
+
'voids'
|
|
60
|
+
];
|
|
61
|
+
const CLEANUP_RESOURCE_TYPES = [
|
|
62
|
+
'bundles',
|
|
63
|
+
'gift_cards',
|
|
64
|
+
'prices',
|
|
65
|
+
'promotions',
|
|
66
|
+
'sku_lists',
|
|
67
|
+
'sku_options',
|
|
68
|
+
'skus',
|
|
69
|
+
'stock_items'
|
|
70
|
+
];
|
|
71
|
+
const TAG_RESOURCE_TYPES = [
|
|
72
|
+
'addresses',
|
|
73
|
+
'bundles',
|
|
74
|
+
'customers',
|
|
75
|
+
'coupons',
|
|
76
|
+
'gift_cards',
|
|
77
|
+
'line_items',
|
|
78
|
+
'line_item_options',
|
|
79
|
+
'orders',
|
|
80
|
+
'returns',
|
|
81
|
+
'skus',
|
|
82
|
+
'sku_options',
|
|
83
|
+
'promotions',
|
|
84
|
+
'external_promotions',
|
|
85
|
+
'fixed_amount_promotions',
|
|
86
|
+
'fixed_price_promotions',
|
|
87
|
+
'free_gift_promotions',
|
|
88
|
+
'free_shipping_promotions',
|
|
89
|
+
'percentage_discount_promotions'
|
|
90
|
+
];
|
|
91
|
+
const RATE_LIMIT = {
|
|
92
|
+
erl_oauth_limit_live: 30,
|
|
93
|
+
erl_burst_limit_uncachable_live: 50,
|
|
94
|
+
erl_burst_limit_uncachable_test: 25,
|
|
95
|
+
erl_burst_limit_cachable_live: 250,
|
|
96
|
+
erl_burst_limit_cachable_test: 125,
|
|
97
|
+
erl_average_limit_uncachable_live: 200,
|
|
98
|
+
erl_average_limit_uncachable_test: 100,
|
|
99
|
+
erl_average_limit_cachable_live: 1000,
|
|
100
|
+
erl_average_limit_cachable_test: 500
|
|
101
|
+
};
|
|
102
|
+
const config = {
|
|
103
|
+
api: {
|
|
104
|
+
default_domain: 'commercelayer.io',
|
|
105
|
+
default_app_domain: 'commercelayer.app',
|
|
106
|
+
default_stg_domain: 'commercelayer.co',
|
|
107
|
+
token_expiration_mins: 60 * 4, // 4 hours (14400 secs)
|
|
108
|
+
token_encoding_algorithm: 'HS512',
|
|
109
|
+
requests_max_num_burst: RATE_LIMIT.erl_burst_limit_uncachable_live, // 50
|
|
110
|
+
requests_max_num_burst_cacheable: RATE_LIMIT.erl_burst_limit_cachable_live, // 250
|
|
111
|
+
requests_max_num_burst_test: RATE_LIMIT.erl_burst_limit_uncachable_test, // 25
|
|
112
|
+
requests_max_num_burst_test_cacheable: RATE_LIMIT.erl_burst_limit_cachable_test, // 125
|
|
113
|
+
requests_max_num_avg: RATE_LIMIT.erl_average_limit_uncachable_live, // 200
|
|
114
|
+
requests_max_num_avg_cacheable: RATE_LIMIT.erl_average_limit_cachable_live, // 1000
|
|
115
|
+
requests_max_num_avg_test: RATE_LIMIT.erl_average_limit_uncachable_test, // 100
|
|
116
|
+
requests_max_num_avg_test_cacheable: RATE_LIMIT.erl_average_limit_cachable_test, // 500
|
|
117
|
+
requests_max_num_oauth: RATE_LIMIT.erl_oauth_limit_live, // 30
|
|
118
|
+
requests_max_secs_burst: 10,
|
|
119
|
+
requests_max_secs_oauth: 60,
|
|
120
|
+
requests_max_secs_avg: 60,
|
|
121
|
+
page_max_size: 25,
|
|
122
|
+
page_default_size: 10,
|
|
123
|
+
},
|
|
124
|
+
application: {
|
|
125
|
+
kinds: ['integration', 'sales_channel', 'webapp', 'user'],
|
|
126
|
+
login_scopes: ['market', 'stock_location'],
|
|
127
|
+
},
|
|
128
|
+
imports: {
|
|
129
|
+
max_size: 5000,
|
|
130
|
+
statuses: JOB_STATUSES,
|
|
131
|
+
types: IMPORT_RESOURCE_TYPES,
|
|
132
|
+
max_queue_length: 10,
|
|
133
|
+
attachment_expiration: 5
|
|
134
|
+
},
|
|
135
|
+
exports: {
|
|
136
|
+
max_size: 10000,
|
|
137
|
+
statuses: JOB_STATUSES,
|
|
138
|
+
types: EXPORT_RESOURCE_TYPES,
|
|
139
|
+
max_queue_length: 10,
|
|
140
|
+
attachment_expiration: 5
|
|
141
|
+
},
|
|
142
|
+
cleanups: {
|
|
143
|
+
max_size: 10000,
|
|
144
|
+
statuses: JOB_STATUSES,
|
|
145
|
+
types: CLEANUP_RESOURCE_TYPES,
|
|
146
|
+
max_queue_length: 10
|
|
147
|
+
},
|
|
148
|
+
webhooks: {
|
|
149
|
+
retry_number: 5,
|
|
150
|
+
},
|
|
151
|
+
cli: {
|
|
152
|
+
applications: ['integration', 'sales_channel', 'user'],
|
|
153
|
+
},
|
|
154
|
+
doc: {
|
|
155
|
+
core: 'https://docs.commercelayer.io/core/',
|
|
156
|
+
core_api_reference: 'https://docs.commercelayer.io/developers/v/api-reference',
|
|
157
|
+
core_how_tos: 'https://docs.commercelayer.io/core/v/how-tos/',
|
|
158
|
+
core_raste_limits: 'https://docs.commercelayer.io/core/rate-limits',
|
|
159
|
+
core_filtering_data: 'https://docs.commercelayer.io/core/filtering-data#list-of-predicates',
|
|
160
|
+
metrics: 'https://docs.commercelayer.io/metrics/',
|
|
161
|
+
metrics_api_reference: 'https://docs.commercelayer.io/metrics/v/api-reference-m/',
|
|
162
|
+
provisioning: 'https://docs.commercelayer.io/provisioning/',
|
|
163
|
+
provisioning_api_reference: 'https://docs.commercelayer.io/provisioning/v/api-reference-p/',
|
|
164
|
+
imports_resources: 'https://docs.commercelayer.io/api/importing-resources#supported-resources',
|
|
165
|
+
exports_resources: 'https://docs.commercelayer.io/core/exporting-resources#supported-resources',
|
|
166
|
+
cleanups_resources: 'https://docs.commercelayer.io/core/cleaning-resources#supported-resources',
|
|
167
|
+
webhooks_events: 'https://docs.commercelayer.io/api/real-time-webhooks#supported-events',
|
|
168
|
+
tags_resources: 'https://docs.commercelayer.io/core/v/api-reference/tags#taggable-resources'
|
|
169
|
+
},
|
|
170
|
+
tags: {
|
|
171
|
+
max_resource_tags: 10,
|
|
172
|
+
taggable_resources: TAG_RESOURCE_TYPES,
|
|
173
|
+
tag_name_max_length: 25,
|
|
174
|
+
tag_name_pattern: /^[0-9A-Za-z_-]{1,25}$/
|
|
175
|
+
},
|
|
176
|
+
provisioning: {
|
|
177
|
+
default_subdomain: 'provisioning',
|
|
178
|
+
scope: 'provisioning-api',
|
|
179
|
+
applications: ['user']
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
exports.default = config;
|