@commercelayer/cli-core 4.12.1 → 5.0.0-oclif3.10

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.
Files changed (83) hide show
  1. package/lib/index.d.mts +593 -0
  2. package/lib/index.d.ts +593 -0
  3. package/lib/index.js +11 -0
  4. package/lib/index.mjs +11 -0
  5. package/package.json +21 -28
  6. package/lib/cjs/api.d.ts +0 -41
  7. package/lib/cjs/api.js +0 -107
  8. package/lib/cjs/application.d.ts +0 -34
  9. package/lib/cjs/application.js +0 -36
  10. package/lib/cjs/color.d.ts +0 -107
  11. package/lib/cjs/color.js +0 -116
  12. package/lib/cjs/command.d.ts +0 -21
  13. package/lib/cjs/command.js +0 -95
  14. package/lib/cjs/config.d.ts +0 -92
  15. package/lib/cjs/config.js +0 -182
  16. package/lib/cjs/filter.d.ts +0 -10
  17. package/lib/cjs/filter.js +0 -81
  18. package/lib/cjs/help.d.ts +0 -17
  19. package/lib/cjs/help.js +0 -103
  20. package/lib/cjs/index.d.ts +0 -19
  21. package/lib/cjs/index.js +0 -46
  22. package/lib/cjs/inflector.d.ts +0 -26
  23. package/lib/cjs/inflector.js +0 -255
  24. package/lib/cjs/jsonapi.d.ts +0 -2
  25. package/lib/cjs/jsonapi.js +0 -38
  26. package/lib/cjs/output.d.ts +0 -28
  27. package/lib/cjs/output.js +0 -83
  28. package/lib/cjs/raw.d.ts +0 -12
  29. package/lib/cjs/raw.js +0 -49
  30. package/lib/cjs/schema.d.ts +0 -2
  31. package/lib/cjs/schema.js +0 -20
  32. package/lib/cjs/style.d.ts +0 -14
  33. package/lib/cjs/style.js +0 -39
  34. package/lib/cjs/symbol.d.ts +0 -2
  35. package/lib/cjs/symbol.js +0 -28
  36. package/lib/cjs/text.d.ts +0 -6
  37. package/lib/cjs/text.js +0 -23
  38. package/lib/cjs/token.d.ts +0 -58
  39. package/lib/cjs/token.js +0 -177
  40. package/lib/cjs/update.d.ts +0 -7
  41. package/lib/cjs/update.js +0 -22
  42. package/lib/cjs/util.d.ts +0 -9
  43. package/lib/cjs/util.js +0 -59
  44. package/lib/esm/api.d.ts +0 -41
  45. package/lib/esm/api.js +0 -93
  46. package/lib/esm/application.d.ts +0 -34
  47. package/lib/esm/application.js +0 -26
  48. package/lib/esm/color.d.ts +0 -107
  49. package/lib/esm/color.js +0 -110
  50. package/lib/esm/command.d.ts +0 -21
  51. package/lib/esm/command.js +0 -90
  52. package/lib/esm/config.d.ts +0 -92
  53. package/lib/esm/config.js +0 -180
  54. package/lib/esm/filter.d.ts +0 -10
  55. package/lib/esm/filter.js +0 -71
  56. package/lib/esm/help.d.ts +0 -17
  57. package/lib/esm/help.js +0 -100
  58. package/lib/esm/index.d.ts +0 -19
  59. package/lib/esm/index.js +0 -26
  60. package/lib/esm/inflector.d.ts +0 -26
  61. package/lib/esm/inflector.js +0 -253
  62. package/lib/esm/jsonapi.d.ts +0 -2
  63. package/lib/esm/jsonapi.js +0 -42
  64. package/lib/esm/output.d.ts +0 -28
  65. package/lib/esm/output.js +0 -72
  66. package/lib/esm/raw.d.ts +0 -12
  67. package/lib/esm/raw.js +0 -42
  68. package/lib/esm/schema.d.ts +0 -2
  69. package/lib/esm/schema.js +0 -14
  70. package/lib/esm/style.d.ts +0 -14
  71. package/lib/esm/style.js +0 -19
  72. package/lib/esm/symbol.d.ts +0 -2
  73. package/lib/esm/symbol.js +0 -25
  74. package/lib/esm/text.d.ts +0 -6
  75. package/lib/esm/text.js +0 -13
  76. package/lib/esm/token.d.ts +0 -58
  77. package/lib/esm/token.js +0 -166
  78. package/lib/esm/update.d.ts +0 -7
  79. package/lib/esm/update.js +0 -16
  80. package/lib/esm/util.d.ts +0 -9
  81. package/lib/esm/util.js +0 -51
  82. package/lib/tsconfig.esm.tsbuildinfo +0 -1
  83. package/lib/tsconfig.tsbuildinfo +0 -1
@@ -1,95 +0,0 @@
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;
@@ -1,92 +0,0 @@
1
- type ApiConfig = {
2
- default_domain: string;
3
- default_app_domain: string;
4
- default_stg_domain: string;
5
- token_expiration_mins: number;
6
- token_encoding_algorithm: string;
7
- requests_max_num_burst: number;
8
- requests_max_num_burst_cacheable: number;
9
- requests_max_num_burst_test: number;
10
- requests_max_num_burst_test_cacheable: number;
11
- requests_max_secs_burst: number;
12
- requests_max_num_avg: number;
13
- requests_max_num_avg_cacheable: number;
14
- requests_max_num_avg_test: number;
15
- requests_max_num_avg_test_cacheable: number;
16
- requests_max_secs_avg: number;
17
- requests_max_num_oauth: number;
18
- requests_max_secs_oauth: number;
19
- page_max_size: number;
20
- page_default_size: number;
21
- };
22
- type ApplicationConfig = {
23
- kinds: readonly string[];
24
- login_scopes: readonly string[];
25
- };
26
- type ImportsConfig = {
27
- max_size: number;
28
- statuses: readonly string[];
29
- types: readonly string[];
30
- max_queue_length: number;
31
- attachment_expiration: number;
32
- };
33
- type ExportsConfig = {
34
- max_size: number;
35
- statuses: readonly string[];
36
- types: readonly string[];
37
- max_queue_length: number;
38
- attachment_expiration: number;
39
- };
40
- type CleanupsConfig = {
41
- max_size: number;
42
- statuses: readonly string[];
43
- types: readonly string[];
44
- max_queue_length: number;
45
- };
46
- type WebhooksConfig = {
47
- retry_number: number;
48
- };
49
- type CliConfig = {
50
- applications: readonly string[];
51
- };
52
- type DocConfig = {
53
- core: string;
54
- core_api_reference: string;
55
- core_how_tos: string;
56
- core_raste_limits: string;
57
- core_filtering_data: string;
58
- metrics: string;
59
- metrics_api_reference: string;
60
- provisioning: string;
61
- provisioning_api_reference: string;
62
- imports_resources: string;
63
- exports_resources: string;
64
- cleanups_resources: string;
65
- webhooks_events: string;
66
- tags_resources: string;
67
- };
68
- type TagsConfig = {
69
- max_resource_tags: number;
70
- taggable_resources: readonly string[];
71
- tag_name_max_length: number;
72
- tag_name_pattern: RegExp;
73
- };
74
- type ProvisioningConfig = {
75
- default_subdomain: string;
76
- scope: string;
77
- applications: readonly string[];
78
- };
79
- type Config = {
80
- api: ApiConfig;
81
- application: ApplicationConfig;
82
- imports: ImportsConfig;
83
- exports: ExportsConfig;
84
- cleanups: CleanupsConfig;
85
- webhooks: WebhooksConfig;
86
- cli: CliConfig;
87
- doc: DocConfig;
88
- tags: TagsConfig;
89
- provisioning: ProvisioningConfig;
90
- };
91
- declare const config: Config;
92
- export default config;
package/lib/cjs/config.js DELETED
@@ -1,182 +0,0 @@
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;
@@ -1,10 +0,0 @@
1
- declare const documentation: string;
2
- interface Filter extends Record<string, unknown> {
3
- predicate: string;
4
- description: string;
5
- }
6
- declare const filterList: () => string[];
7
- declare const filterAvailable: (filter: string) => boolean;
8
- declare const applyFilter: (predicate: string, ...fields: string[]) => string;
9
- declare const filters: () => Filter[];
10
- export { type Filter, documentation, filterAvailable as available, filterList as list, applyFilter as apply, filters };
package/lib/cjs/filter.js DELETED
@@ -1,81 +0,0 @@
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.filters = exports.apply = exports.list = exports.available = exports.documentation = void 0;
7
- const config_1 = __importDefault(require("./config"));
8
- const FILTERS = [
9
- { predicate: '*_eq', description: 'The attribute is equal to the filter value' },
10
- { predicate: '*_not_eq', description: 'The attribute is not equal to the filter value' },
11
- { predicate: '*_matches', description: 'The attribute matches the filter value with "LIKE" operator' },
12
- { predicate: '*_does_not_match', description: 'The attribute does not match the filter value with "LIKE" operator' },
13
- { predicate: '*_matches_any', description: 'The attribute matches all of the filter values (comma-separated) with "LIKE" operator' },
14
- { predicate: '*_matches_all', description: 'The attribute matches all of the filter values (comma-separated) with "LIKE" operator' },
15
- { predicate: '*_does_not_match_any', description: 'The attribute does not match any of the filter values (comma-separated) with "LIKE" operator' },
16
- { predicate: '*_does_not_match_all', description: 'The attribute matches none of the filter values (comma-separated) with "LIKE" operator' },
17
- { predicate: '*_lt', description: 'The attribute is less than the filter value' },
18
- { predicate: '*_lteq', description: 'The attribute is less than or equal to the filter value' },
19
- { predicate: '*_gt', description: 'The attribute is greater than the filter value' },
20
- { predicate: '*_gteq', description: 'The attribute is greater than or equal to the filter value' },
21
- { predicate: '*_present', description: 'The attribute is not null and not empty' },
22
- { predicate: '*_blank', description: 'The attribute is null or empty' },
23
- { predicate: '*_null', description: 'The attribute is null' },
24
- { predicate: '*_not_null', description: 'The attribute is not null' },
25
- { predicate: '*_in', description: 'The attribute matches any of the filter values (comma-separated)' },
26
- { predicate: '*_not_in', description: 'The attribute matches none of the filter values (comma-separated)' },
27
- { predicate: '*_lt_any', description: 'The attribute is less than any of the filter values (comma-separated)' },
28
- { predicate: '*_lteq_any', description: 'The attribute is less than or equal to any of the filter values (comma-separated)' },
29
- { predicate: '*_gt_any', description: 'The attribute is greater than any of the filter values (comma-separated)' },
30
- { predicate: '*_gteq_any', description: 'The attribute is greater than or qual to any of the filter values (comma-separated)' },
31
- { predicate: '*_lt_all', description: 'The attribute is less than all of the filter values (comma-separated)' },
32
- { predicate: '*_lteq_all', description: 'The attribute is less than or equal to all of the filter values (comma-separated)' },
33
- { predicate: '*_gt_all', description: 'The attribute is greater than all of the filter values (comma-separated)' },
34
- { predicate: '*_gteq_all', description: 'The attribute is greater or equal to all of the filter values (comma-separated)' },
35
- { predicate: '*_not_eq_all', description: 'The attribute is equal to none of the filter values (comma-separated)' },
36
- { predicate: '*_start', description: 'The attribute starts with the filter value (comma-separated)' },
37
- { predicate: '*_not_start', description: 'The attribute does not start with the filter value (comma-separated)' },
38
- { predicate: '*_start_any', description: 'The attribute starts with any of the filter values (comma-separated)' },
39
- { predicate: '*_start_all', description: 'The attribute starts with all of the filter values (comma-separated)' },
40
- { predicate: '*_not_start_any', description: 'The attribute does not start with any of the filter values (comma-separated)' },
41
- { predicate: '*_not_start_all', description: 'The attribute starts with none of the filter values (comma-separated)' },
42
- { predicate: '*_end', description: 'The attribute ends with the filter value' },
43
- { predicate: '*_not_end', description: 'The attribute does not end with the filter value' },
44
- { predicate: '*_end_any', description: 'The attribute ends with any of the filter values (comma-separated)' },
45
- { predicate: '*_end_all', description: 'The attribute ends with all of the filter values (comma-separated)' },
46
- { predicate: '*_not_end_any', description: 'The attribute does not end with any of the filter values (comma-separated)' },
47
- { predicate: '*_not_end_all', description: 'The attribute ends with none of the filter values (comma-separated)' },
48
- { predicate: '*_cont', description: 'The attribute contains the filter value' },
49
- { predicate: '*_not_cont', description: 'The attribute does not contains the filter value' },
50
- { predicate: '*_cont_any', description: 'The attribute contains any of the filter values (comma-separated)' },
51
- { predicate: '*_cont_all', description: 'The attribute contains all of the filter values (comma-separated)' },
52
- { predicate: '*_not_cont_all', description: 'The attribute contains none of the filter values (comma-separated)' },
53
- { predicate: '*_jcont', description: 'The attribute contains a portion of the JSON used as filter value (works with object only)' },
54
- { predicate: '*_true', description: 'The attribute is true' },
55
- { predicate: '*_false', description: 'The attribute is false' },
56
- ];
57
- const documentation = config_1.default.doc.core_filtering_data;
58
- exports.documentation = documentation;
59
- const filterList = () => {
60
- return filters().map(f => f.predicate.replace(/^\*/g, ''));
61
- };
62
- exports.list = filterList;
63
- const filterAvailable = (filter) => {
64
- const filter_ = filter.startsWith('_') ? filter : `_${filter}`;
65
- return filterList().some(f => filter_.endsWith(f));
66
- };
67
- exports.available = filterAvailable;
68
- const applyFilter = (predicate, ...fields) => {
69
- if (!filterAvailable(predicate))
70
- throw new Error('Unknown filter: ' + predicate);
71
- let out = '';
72
- for (const f of fields)
73
- out += (out.length === 0 ? '' : '_or_') + f;
74
- out += predicate.startsWith('_') ? predicate : `_${predicate}`;
75
- return out;
76
- };
77
- exports.apply = applyFilter;
78
- const filters = () => {
79
- return [...FILTERS];
80
- };
81
- exports.filters = filters;
package/lib/cjs/help.d.ts DELETED
@@ -1,17 +0,0 @@
1
- import { type Command, CommandHelp, Help, type Interfaces } from '@oclif/core';
2
- declare class CLICommandHelp extends CommandHelp {
3
- examples(examples: Command.Example[] | undefined | string): string | undefined;
4
- }
5
- export default class CLIBaseHelp extends Help {
6
- showHelp(args: string[]): Promise<void>;
7
- showRootHelp(): Promise<void>;
8
- showTopicHelp(topic: Interfaces.Topic): Promise<void>;
9
- showCommandHelp(command: Command.Cached): Promise<void>;
10
- formatRoot(): string;
11
- formatTopic(topic: Interfaces.Topic): string;
12
- formatTopics(topics: Interfaces.Topic[]): string;
13
- formatCommands(commands: Command.Cached[]): string;
14
- formatCommand(command: Command.Cached): string;
15
- getCommandHelpClass(command: Command.Cached): CLICommandHelp;
16
- }
17
- export {};
package/lib/cjs/help.js DELETED
@@ -1,103 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const core_1 = require("@oclif/core");
4
- const text_1 = require("./text");
5
- const PRINT_TRACE = false;
6
- /*
7
- const indent = (str: string, count = 1): string => {
8
- return str.replace(/^(?!\s*$)/gm, ' '.repeat(count))
9
- }
10
- */
11
- // Command formatter class
12
- class CLICommandHelp extends core_1.CommandHelp {
13
- examples(examples) {
14
- if (PRINT_TRACE)
15
- console.log('---------- command.examples');
16
- return super.examples(examples);
17
- }
18
- }
19
- // Global help formatter
20
- class CLIBaseHelp extends core_1.Help {
21
- async showHelp(args) {
22
- if (PRINT_TRACE)
23
- console.log('---------- showHelp');
24
- return super.showHelp(args);
25
- }
26
- // display the root help of a CLI
27
- async showRootHelp() {
28
- if (PRINT_TRACE)
29
- console.log('---------- showRootHelp');
30
- return super.showRootHelp();
31
- }
32
- // display help for a topic
33
- async showTopicHelp(topic) {
34
- if (PRINT_TRACE)
35
- console.log('---------- showTopicHelp');
36
- return super.showTopicHelp(topic);
37
- }
38
- // display help for a command
39
- async showCommandHelp(command) {
40
- if (PRINT_TRACE)
41
- console.log('---------- showCommandHelp');
42
- const name = command.id;
43
- const depth = name ? name.split(':').length : 1;
44
- const subTopics = this.sortedTopics.filter((t) => t.name.startsWith(name + ':') && t.name.split(':').length === depth + 1);
45
- const subCommands = this.sortedCommands.filter((c) => c.id.startsWith(name + ':') && c.id.split(':').length === depth + 1);
46
- const title = command.description && this.render(command.description).split('\n')[0];
47
- if (title)
48
- console.log(`${(0, text_1.capitalize)(title)}\n`);
49
- console.log(this.formatCommand(command));
50
- console.log('');
51
- if (subTopics.length > 0) {
52
- console.log(this.formatTopics(subTopics));
53
- console.log('');
54
- }
55
- if (subCommands.length > 0) {
56
- console.log(this.formatCommands(subCommands));
57
- console.log('');
58
- }
59
- }
60
- // displayed for the root help
61
- formatRoot() {
62
- if (PRINT_TRACE)
63
- console.log('---------- formatRoot');
64
- return super.formatRoot();
65
- }
66
- // the formatting for an individual topic
67
- formatTopic(topic) {
68
- if (PRINT_TRACE)
69
- console.log('---------- formatTopic');
70
- return super.formatTopic(topic);
71
- }
72
- // the formatting for a list of topics
73
- formatTopics(topics) {
74
- if (PRINT_TRACE)
75
- console.log('---------- formatTopics');
76
- const fixTopics = topics.filter(t => !t.hidden).map(t => {
77
- t.description = (0, text_1.capitalize)(t.description);
78
- return t;
79
- });
80
- return super.formatTopics(fixTopics);
81
- }
82
- // the formatting for a list of commands
83
- formatCommands(commands) {
84
- if (PRINT_TRACE)
85
- console.log('---------- formatCommands');
86
- return super.formatCommands(commands).split('\n').map((c) => {
87
- let noSpaceCount = 0;
88
- return c.split(' ').map((t) => (((t || '').trim() !== '') && (++noSpaceCount === 2)) ? (0, text_1.capitalize)(t) : t).join(' ');
89
- }).join('\n');
90
- }
91
- // the formatting for an individual command
92
- formatCommand(command) {
93
- if (PRINT_TRACE)
94
- console.log('---------- formatCommand');
95
- return super.formatCommand(command);
96
- }
97
- getCommandHelpClass(command) {
98
- if (PRINT_TRACE)
99
- console.log('---------- getCommandHelpClass');
100
- return new CLICommandHelp(command, this.config, this.opts);
101
- }
102
- }
103
- exports.default = CLIBaseHelp;
@@ -1,19 +0,0 @@
1
- export * as clApi from './api';
2
- export * as clApplication from './application';
3
- export { default as clConfig } from './config';
4
- export * as clCommand from './command';
5
- export * as clOutput from './output';
6
- export * as clColor from './color';
7
- export * as clToken from './token';
8
- export * as clUpdate from './update';
9
- export * as clUtil from './util';
10
- export { default as clHelp } from './help';
11
- export * as clSchema from './schema';
12
- export * as clText from './text';
13
- export * as clSymbol from './symbol';
14
- export * as clFilter from './filter';
15
- /** Types **/
16
- export type { ApiMode, ApiType } from './api';
17
- export type { AppKey, AppAuth, AppInfo } from './application';
18
- export type { AccessTokenInfo, AccessToken, CustomToken, AuthScope } from './token';
19
- export type { KeyVal, KeyValString, KeyValArray, KeyValObj, KeyValRel, KeyValSort, ResAttributes } from './command';
package/lib/cjs/index.js DELETED
@@ -1,46 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.clFilter = exports.clSymbol = exports.clText = exports.clSchema = exports.clHelp = exports.clUtil = exports.clUpdate = exports.clToken = exports.clColor = exports.clOutput = exports.clCommand = exports.clConfig = exports.clApplication = exports.clApi = void 0;
30
- exports.clApi = __importStar(require("./api"));
31
- exports.clApplication = __importStar(require("./application"));
32
- var config_1 = require("./config");
33
- Object.defineProperty(exports, "clConfig", { enumerable: true, get: function () { return __importDefault(config_1).default; } });
34
- exports.clCommand = __importStar(require("./command"));
35
- exports.clOutput = __importStar(require("./output"));
36
- // export * as style from './style'
37
- exports.clColor = __importStar(require("./color"));
38
- exports.clToken = __importStar(require("./token"));
39
- exports.clUpdate = __importStar(require("./update"));
40
- exports.clUtil = __importStar(require("./util"));
41
- var help_1 = require("./help");
42
- Object.defineProperty(exports, "clHelp", { enumerable: true, get: function () { return __importDefault(help_1).default; } });
43
- exports.clSchema = __importStar(require("./schema"));
44
- exports.clText = __importStar(require("./text"));
45
- exports.clSymbol = __importStar(require("./symbol"));
46
- exports.clFilter = __importStar(require("./filter"));