@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.
- package/lib/index.d.mts +593 -0
- package/lib/index.d.ts +593 -0
- package/lib/index.js +11 -0
- package/lib/index.mjs +11 -0
- package/package.json +21 -28
- package/lib/cjs/api.d.ts +0 -41
- package/lib/cjs/api.js +0 -107
- package/lib/cjs/application.d.ts +0 -34
- package/lib/cjs/application.js +0 -36
- package/lib/cjs/color.d.ts +0 -107
- package/lib/cjs/color.js +0 -116
- package/lib/cjs/command.d.ts +0 -21
- package/lib/cjs/command.js +0 -95
- package/lib/cjs/config.d.ts +0 -92
- package/lib/cjs/config.js +0 -182
- package/lib/cjs/filter.d.ts +0 -10
- package/lib/cjs/filter.js +0 -81
- package/lib/cjs/help.d.ts +0 -17
- package/lib/cjs/help.js +0 -103
- package/lib/cjs/index.d.ts +0 -19
- package/lib/cjs/index.js +0 -46
- package/lib/cjs/inflector.d.ts +0 -26
- package/lib/cjs/inflector.js +0 -255
- package/lib/cjs/jsonapi.d.ts +0 -2
- package/lib/cjs/jsonapi.js +0 -38
- package/lib/cjs/output.d.ts +0 -28
- package/lib/cjs/output.js +0 -83
- package/lib/cjs/raw.d.ts +0 -12
- package/lib/cjs/raw.js +0 -49
- package/lib/cjs/schema.d.ts +0 -2
- package/lib/cjs/schema.js +0 -20
- package/lib/cjs/style.d.ts +0 -14
- package/lib/cjs/style.js +0 -39
- package/lib/cjs/symbol.d.ts +0 -2
- package/lib/cjs/symbol.js +0 -28
- package/lib/cjs/text.d.ts +0 -6
- package/lib/cjs/text.js +0 -23
- package/lib/cjs/token.d.ts +0 -58
- package/lib/cjs/token.js +0 -177
- package/lib/cjs/update.d.ts +0 -7
- package/lib/cjs/update.js +0 -22
- package/lib/cjs/util.d.ts +0 -9
- package/lib/cjs/util.js +0 -59
- package/lib/esm/api.d.ts +0 -41
- package/lib/esm/api.js +0 -93
- package/lib/esm/application.d.ts +0 -34
- package/lib/esm/application.js +0 -26
- package/lib/esm/color.d.ts +0 -107
- package/lib/esm/color.js +0 -110
- package/lib/esm/command.d.ts +0 -21
- package/lib/esm/command.js +0 -90
- package/lib/esm/config.d.ts +0 -92
- package/lib/esm/config.js +0 -180
- package/lib/esm/filter.d.ts +0 -10
- package/lib/esm/filter.js +0 -71
- package/lib/esm/help.d.ts +0 -17
- package/lib/esm/help.js +0 -100
- package/lib/esm/index.d.ts +0 -19
- package/lib/esm/index.js +0 -26
- package/lib/esm/inflector.d.ts +0 -26
- package/lib/esm/inflector.js +0 -253
- package/lib/esm/jsonapi.d.ts +0 -2
- package/lib/esm/jsonapi.js +0 -42
- package/lib/esm/output.d.ts +0 -28
- package/lib/esm/output.js +0 -72
- package/lib/esm/raw.d.ts +0 -12
- package/lib/esm/raw.js +0 -42
- package/lib/esm/schema.d.ts +0 -2
- package/lib/esm/schema.js +0 -14
- package/lib/esm/style.d.ts +0 -14
- package/lib/esm/style.js +0 -19
- package/lib/esm/symbol.d.ts +0 -2
- package/lib/esm/symbol.js +0 -25
- package/lib/esm/text.d.ts +0 -6
- package/lib/esm/text.js +0 -13
- package/lib/esm/token.d.ts +0 -58
- package/lib/esm/token.js +0 -166
- package/lib/esm/update.d.ts +0 -7
- package/lib/esm/update.js +0 -16
- package/lib/esm/util.d.ts +0 -9
- package/lib/esm/util.js +0 -51
- package/lib/tsconfig.esm.tsbuildinfo +0 -1
- package/lib/tsconfig.tsbuildinfo +0 -1
package/lib/esm/help.js
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import { CommandHelp, Help } from '@oclif/core';
|
|
2
|
-
import { capitalize } from './text';
|
|
3
|
-
const PRINT_TRACE = false;
|
|
4
|
-
/*
|
|
5
|
-
const indent = (str: string, count = 1): string => {
|
|
6
|
-
return str.replace(/^(?!\s*$)/gm, ' '.repeat(count))
|
|
7
|
-
}
|
|
8
|
-
*/
|
|
9
|
-
// Command formatter class
|
|
10
|
-
class CLICommandHelp extends CommandHelp {
|
|
11
|
-
examples(examples) {
|
|
12
|
-
if (PRINT_TRACE)
|
|
13
|
-
console.log('---------- command.examples');
|
|
14
|
-
return super.examples(examples);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
// Global help formatter
|
|
18
|
-
export default class CLIBaseHelp extends Help {
|
|
19
|
-
async showHelp(args) {
|
|
20
|
-
if (PRINT_TRACE)
|
|
21
|
-
console.log('---------- showHelp');
|
|
22
|
-
return super.showHelp(args);
|
|
23
|
-
}
|
|
24
|
-
// display the root help of a CLI
|
|
25
|
-
async showRootHelp() {
|
|
26
|
-
if (PRINT_TRACE)
|
|
27
|
-
console.log('---------- showRootHelp');
|
|
28
|
-
return super.showRootHelp();
|
|
29
|
-
}
|
|
30
|
-
// display help for a topic
|
|
31
|
-
async showTopicHelp(topic) {
|
|
32
|
-
if (PRINT_TRACE)
|
|
33
|
-
console.log('---------- showTopicHelp');
|
|
34
|
-
return super.showTopicHelp(topic);
|
|
35
|
-
}
|
|
36
|
-
// display help for a command
|
|
37
|
-
async showCommandHelp(command) {
|
|
38
|
-
if (PRINT_TRACE)
|
|
39
|
-
console.log('---------- showCommandHelp');
|
|
40
|
-
const name = command.id;
|
|
41
|
-
const depth = name ? name.split(':').length : 1;
|
|
42
|
-
const subTopics = this.sortedTopics.filter((t) => t.name.startsWith(name + ':') && t.name.split(':').length === depth + 1);
|
|
43
|
-
const subCommands = this.sortedCommands.filter((c) => c.id.startsWith(name + ':') && c.id.split(':').length === depth + 1);
|
|
44
|
-
const title = command.description && this.render(command.description).split('\n')[0];
|
|
45
|
-
if (title)
|
|
46
|
-
console.log(`${capitalize(title)}\n`);
|
|
47
|
-
console.log(this.formatCommand(command));
|
|
48
|
-
console.log('');
|
|
49
|
-
if (subTopics.length > 0) {
|
|
50
|
-
console.log(this.formatTopics(subTopics));
|
|
51
|
-
console.log('');
|
|
52
|
-
}
|
|
53
|
-
if (subCommands.length > 0) {
|
|
54
|
-
console.log(this.formatCommands(subCommands));
|
|
55
|
-
console.log('');
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
// displayed for the root help
|
|
59
|
-
formatRoot() {
|
|
60
|
-
if (PRINT_TRACE)
|
|
61
|
-
console.log('---------- formatRoot');
|
|
62
|
-
return super.formatRoot();
|
|
63
|
-
}
|
|
64
|
-
// the formatting for an individual topic
|
|
65
|
-
formatTopic(topic) {
|
|
66
|
-
if (PRINT_TRACE)
|
|
67
|
-
console.log('---------- formatTopic');
|
|
68
|
-
return super.formatTopic(topic);
|
|
69
|
-
}
|
|
70
|
-
// the formatting for a list of topics
|
|
71
|
-
formatTopics(topics) {
|
|
72
|
-
if (PRINT_TRACE)
|
|
73
|
-
console.log('---------- formatTopics');
|
|
74
|
-
const fixTopics = topics.filter(t => !t.hidden).map(t => {
|
|
75
|
-
t.description = capitalize(t.description);
|
|
76
|
-
return t;
|
|
77
|
-
});
|
|
78
|
-
return super.formatTopics(fixTopics);
|
|
79
|
-
}
|
|
80
|
-
// the formatting for a list of commands
|
|
81
|
-
formatCommands(commands) {
|
|
82
|
-
if (PRINT_TRACE)
|
|
83
|
-
console.log('---------- formatCommands');
|
|
84
|
-
return super.formatCommands(commands).split('\n').map((c) => {
|
|
85
|
-
let noSpaceCount = 0;
|
|
86
|
-
return c.split(' ').map((t) => (((t || '').trim() !== '') && (++noSpaceCount === 2)) ? capitalize(t) : t).join(' ');
|
|
87
|
-
}).join('\n');
|
|
88
|
-
}
|
|
89
|
-
// the formatting for an individual command
|
|
90
|
-
formatCommand(command) {
|
|
91
|
-
if (PRINT_TRACE)
|
|
92
|
-
console.log('---------- formatCommand');
|
|
93
|
-
return super.formatCommand(command);
|
|
94
|
-
}
|
|
95
|
-
getCommandHelpClass(command) {
|
|
96
|
-
if (PRINT_TRACE)
|
|
97
|
-
console.log('---------- getCommandHelpClass');
|
|
98
|
-
return new CLICommandHelp(command, this.config, this.opts);
|
|
99
|
-
}
|
|
100
|
-
}
|
package/lib/esm/index.d.ts
DELETED
|
@@ -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/esm/index.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import * as clApi_1 from './api';
|
|
2
|
-
export { clApi_1 as clApi };
|
|
3
|
-
import * as clApplication_1 from './application';
|
|
4
|
-
export { clApplication_1 as clApplication };
|
|
5
|
-
export { default as clConfig } from './config';
|
|
6
|
-
import * as clCommand_1 from './command';
|
|
7
|
-
export { clCommand_1 as clCommand };
|
|
8
|
-
import * as clOutput_1 from './output';
|
|
9
|
-
export { clOutput_1 as clOutput };
|
|
10
|
-
import * as clColor_1 from './color';
|
|
11
|
-
export { clColor_1 as clColor };
|
|
12
|
-
import * as clToken_1 from './token';
|
|
13
|
-
export { clToken_1 as clToken };
|
|
14
|
-
import * as clUpdate_1 from './update';
|
|
15
|
-
export { clUpdate_1 as clUpdate };
|
|
16
|
-
import * as clUtil_1 from './util';
|
|
17
|
-
export { clUtil_1 as clUtil };
|
|
18
|
-
export { default as clHelp } from './help';
|
|
19
|
-
import * as clSchema_1 from './schema';
|
|
20
|
-
export { clSchema_1 as clSchema };
|
|
21
|
-
import * as clText_1 from './text';
|
|
22
|
-
export { clText_1 as clText };
|
|
23
|
-
import * as clSymbol_1 from './symbol';
|
|
24
|
-
export { clSymbol_1 as clSymbol };
|
|
25
|
-
import * as clFilter_1 from './filter';
|
|
26
|
-
export { clFilter_1 as clFilter };
|
package/lib/esm/inflector.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
declare const _Inflector: {
|
|
2
|
-
uncountableWords: string[];
|
|
3
|
-
pluralRules: (string | RegExp)[][];
|
|
4
|
-
singularRules: (string | RegExp)[][];
|
|
5
|
-
nonTitlecasedWords: string[];
|
|
6
|
-
idSuffix: RegExp;
|
|
7
|
-
underbar: RegExp;
|
|
8
|
-
spaceOrUnderbar: RegExp;
|
|
9
|
-
uppercase: RegExp;
|
|
10
|
-
underbarPrefix: RegExp;
|
|
11
|
-
applyRules: (str: string, rules: Array<Array<string | RegExp>>, skip: string[], override?: string) => string;
|
|
12
|
-
pluralize: (str: string, plural?: string) => string;
|
|
13
|
-
singularize: (str: string, singular?: string) => string;
|
|
14
|
-
camelize: (str: string, lowFirstLetter?: boolean) => string;
|
|
15
|
-
underscore: (str: string) => string;
|
|
16
|
-
humanize: (str: string, lowFirstLetter: boolean) => string;
|
|
17
|
-
capitalize: (str: string) => string;
|
|
18
|
-
dasherize: (str: string) => string;
|
|
19
|
-
camel2words: (str: string, allFirstUpper: boolean) => string;
|
|
20
|
-
demodulize: (str: string) => string;
|
|
21
|
-
tableize: (str: string) => string;
|
|
22
|
-
classify: (str: string) => string;
|
|
23
|
-
foreignKey: (str: string, dropIdUbar: boolean) => string;
|
|
24
|
-
ordinalize: (str: string) => string;
|
|
25
|
-
};
|
|
26
|
-
export default _Inflector;
|
package/lib/esm/inflector.js
DELETED
|
@@ -1,253 +0,0 @@
|
|
|
1
|
-
const _Inflector = {
|
|
2
|
-
uncountableWords: [
|
|
3
|
-
'equipment', 'information', 'rice', 'money', 'species', 'series',
|
|
4
|
-
'fish', 'sheep', 'moose', 'deer', 'news'
|
|
5
|
-
],
|
|
6
|
-
pluralRules: [
|
|
7
|
-
[/(m)an$/gi, '$1en'],
|
|
8
|
-
[/(pe)rson$/gi, '$1ople'],
|
|
9
|
-
[/(child)$/gi, '$1ren'],
|
|
10
|
-
[/^(ox)$/gi, '$1en'],
|
|
11
|
-
[/(ax|test)is$/gi, '$1es'],
|
|
12
|
-
[/(octop|vir)us$/gi, '$1i'],
|
|
13
|
-
[/(alias|status)$/gi, '$1es'],
|
|
14
|
-
[/(bu)s$/gi, '$1ses'],
|
|
15
|
-
[/(buffal|tomat|potat)o$/gi, '$1oes'],
|
|
16
|
-
[/([ti])um$/gi, '$1a'],
|
|
17
|
-
[/sis$/gi, 'ses'],
|
|
18
|
-
[/(?:([^f])fe|([lr])f)$/gi, '$1$2ves'],
|
|
19
|
-
[/(hive)$/gi, '$1s'],
|
|
20
|
-
[/([^aeiouy]|qu)y$/gi, '$1ies'],
|
|
21
|
-
[/(x|ch|ss|sh)$/gi, '$1es'],
|
|
22
|
-
[/(matr|vert|ind)ix|ex$/gi, '$1ices'],
|
|
23
|
-
[/([m|l])ouse$/gi, '$1ice'],
|
|
24
|
-
[/(quiz)$/gi, '$1zes'],
|
|
25
|
-
[/s$/gi, 's'],
|
|
26
|
-
[/$/gi, 's']
|
|
27
|
-
],
|
|
28
|
-
singularRules: [
|
|
29
|
-
[/(m)en$/gi, '$1an'],
|
|
30
|
-
[/(pe)ople$/gi, '$1rson'],
|
|
31
|
-
[/(child)ren$/gi, '$1'],
|
|
32
|
-
[/([ti])a$/gi, '$1um'],
|
|
33
|
-
[/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/gi, '$1$2sis'],
|
|
34
|
-
[/(hive)s$/gi, '$1'],
|
|
35
|
-
[/(tive)s$/gi, '$1'],
|
|
36
|
-
[/(curve)s$/gi, '$1'],
|
|
37
|
-
[/([lr])ves$/gi, '$1f'],
|
|
38
|
-
[/([^fo])ves$/gi, '$1fe'],
|
|
39
|
-
[/([^aeiouy]|qu)ies$/gi, '$1y'],
|
|
40
|
-
[/(s)eries$/gi, '$1eries'],
|
|
41
|
-
[/(m)ovies$/gi, '$1ovie'],
|
|
42
|
-
[/(x|ch|ss|sh)es$/gi, '$1'],
|
|
43
|
-
[/([m|l])ice$/gi, '$1ouse'],
|
|
44
|
-
[/(bus)es$/gi, '$1'],
|
|
45
|
-
[/(o)es$/gi, '$1'],
|
|
46
|
-
[/(shoe)s$/gi, '$1'],
|
|
47
|
-
[/(cris|ax|test)es$/gi, '$1is'],
|
|
48
|
-
[/(octop|vir)i$/gi, '$1us'],
|
|
49
|
-
[/(alias|status)es$/gi, '$1'],
|
|
50
|
-
[/^(ox)en/gi, '$1'],
|
|
51
|
-
[/(vert|ind)ices$/gi, '$1ex'],
|
|
52
|
-
[/(matr)ices$/gi, '$1ix'],
|
|
53
|
-
[/(quiz)zes$/gi, '$1'],
|
|
54
|
-
[/s$/gi, '']
|
|
55
|
-
],
|
|
56
|
-
nonTitlecasedWords: [
|
|
57
|
-
'and', 'or', 'nor', 'a', 'an', 'the', 'so', 'but', 'to', 'of', 'at',
|
|
58
|
-
'by', 'from', 'into', 'on', 'onto', 'off', 'out', 'in', 'over',
|
|
59
|
-
'with', 'for'
|
|
60
|
-
],
|
|
61
|
-
idSuffix: /(_ids|_id)$/g,
|
|
62
|
-
underbar: /_/g,
|
|
63
|
-
spaceOrUnderbar: /[ _]/g,
|
|
64
|
-
uppercase: /([A-Z])/g,
|
|
65
|
-
underbarPrefix: /^_/,
|
|
66
|
-
applyRules: function (str, rules, skip, override) {
|
|
67
|
-
if (override) {
|
|
68
|
-
str = override;
|
|
69
|
-
}
|
|
70
|
-
else {
|
|
71
|
-
const ignore = (skip.includes(str.toLowerCase()));
|
|
72
|
-
if (!ignore) {
|
|
73
|
-
for (let x = 0; x < rules.length; x++) {
|
|
74
|
-
if (str.match(rules[x][0])) {
|
|
75
|
-
str = str.replace(rules[x][0], rules[x][1]);
|
|
76
|
-
break;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
return str;
|
|
82
|
-
},
|
|
83
|
-
/*
|
|
84
|
-
Inflector.pluralize('person') -> 'people'
|
|
85
|
-
Inflector.pluralize('octopus') -> 'octopi'
|
|
86
|
-
Inflector.pluralize('Hat') -> 'Hats'
|
|
87
|
-
Inflector.pluralize('person', 'guys') -> 'guys'
|
|
88
|
-
*/
|
|
89
|
-
pluralize: function (str, plural) {
|
|
90
|
-
return _Inflector.applyRules(str, _Inflector.pluralRules, _Inflector.uncountableWords, plural);
|
|
91
|
-
},
|
|
92
|
-
/*
|
|
93
|
-
Inflector.singularize('person') -> 'person'
|
|
94
|
-
Inflector.singularize('octopi') -> 'octopus'
|
|
95
|
-
Inflector.singularize('hats') -> 'hat'
|
|
96
|
-
Inflector.singularize('guys', 'person') -> 'person'
|
|
97
|
-
*/
|
|
98
|
-
singularize: function (str, singular) {
|
|
99
|
-
return _Inflector.applyRules(str, _Inflector.singularRules, _Inflector.uncountableWords, singular);
|
|
100
|
-
},
|
|
101
|
-
/*
|
|
102
|
-
Inflector.camelize('message_properties') -> 'MessageProperties'
|
|
103
|
-
Inflector.camelize('message_properties', true) -> 'messageProperties'
|
|
104
|
-
*/
|
|
105
|
-
camelize: function (str, lowFirstLetter) {
|
|
106
|
-
// str = str.toLowerCase()
|
|
107
|
-
const strPath = str.split('/');
|
|
108
|
-
for (let i = 0; i < strPath.length; i++) {
|
|
109
|
-
const strArr = strPath[i].split('_');
|
|
110
|
-
const initX = ((lowFirstLetter && i + 1 === strPath.length) ? (1) : (0));
|
|
111
|
-
for (let x = initX; x < strArr.length; x++) {
|
|
112
|
-
strArr[x] = strArr[x].charAt(0).toUpperCase() + strArr[x].substring(1);
|
|
113
|
-
}
|
|
114
|
-
strPath[i] = strArr.join('');
|
|
115
|
-
}
|
|
116
|
-
str = strPath.join('::');
|
|
117
|
-
// fix
|
|
118
|
-
if (lowFirstLetter) {
|
|
119
|
-
const first = str.charAt(0).toLowerCase();
|
|
120
|
-
const last = str.slice(1);
|
|
121
|
-
str = first + last;
|
|
122
|
-
}
|
|
123
|
-
return str;
|
|
124
|
-
},
|
|
125
|
-
/*
|
|
126
|
-
Inflector.underscore('MessageProperties') -> 'message_properties'
|
|
127
|
-
Inflector.underscore('messageProperties') -> 'message_properties'
|
|
128
|
-
*/
|
|
129
|
-
underscore: function (str) {
|
|
130
|
-
const strPath = str.split('::');
|
|
131
|
-
for (let i = 0; i < strPath.length; i++) {
|
|
132
|
-
strPath[i] = strPath[i].replace(_Inflector.uppercase, '_$1');
|
|
133
|
-
strPath[i] = strPath[i].replace(_Inflector.underbarPrefix, '');
|
|
134
|
-
}
|
|
135
|
-
str = strPath.join('/').toLowerCase();
|
|
136
|
-
return str;
|
|
137
|
-
},
|
|
138
|
-
/*
|
|
139
|
-
Inflector.humanize('message_properties') -> 'Message properties'
|
|
140
|
-
Inflector.humanize('message_properties') -> 'message properties'
|
|
141
|
-
*/
|
|
142
|
-
humanize: function (str, lowFirstLetter) {
|
|
143
|
-
str = str.toLowerCase();
|
|
144
|
-
str = str.replace(_Inflector.idSuffix, '');
|
|
145
|
-
str = str.replace(_Inflector.underbar, ' ');
|
|
146
|
-
if (!lowFirstLetter) {
|
|
147
|
-
str = _Inflector.capitalize(str);
|
|
148
|
-
}
|
|
149
|
-
return str;
|
|
150
|
-
},
|
|
151
|
-
/*
|
|
152
|
-
Inflector.capitalize('message_properties') -> 'Message_properties'
|
|
153
|
-
Inflector.capitalize('message properties') -> 'Message properties'
|
|
154
|
-
*/
|
|
155
|
-
capitalize: function (str) {
|
|
156
|
-
str = str.toLowerCase();
|
|
157
|
-
str = str.substring(0, 1).toUpperCase() + str.substring(1);
|
|
158
|
-
return str;
|
|
159
|
-
},
|
|
160
|
-
/*
|
|
161
|
-
Inflector.dasherize('message_properties') -> 'message-properties'
|
|
162
|
-
Inflector.dasherize('message properties') -> 'message-properties'
|
|
163
|
-
*/
|
|
164
|
-
dasherize: function (str) {
|
|
165
|
-
str = str.replace(_Inflector.spaceOrUnderbar, '-');
|
|
166
|
-
return str;
|
|
167
|
-
},
|
|
168
|
-
/*
|
|
169
|
-
Inflector.camel2words('message_properties') -> 'Message Properties'
|
|
170
|
-
Inflector.camel2words('message properties') -> 'Message Properties'
|
|
171
|
-
Inflactor.camel2words('Message_propertyId', true) -> 'Message Properties Id'
|
|
172
|
-
*/
|
|
173
|
-
camel2words: function (str, allFirstUpper) {
|
|
174
|
-
// str = str.toLowerCase()
|
|
175
|
-
if (allFirstUpper) {
|
|
176
|
-
str = _Inflector.camelize(str);
|
|
177
|
-
str = _Inflector.underscore(str);
|
|
178
|
-
}
|
|
179
|
-
else {
|
|
180
|
-
str = str.toLowerCase();
|
|
181
|
-
}
|
|
182
|
-
str = str.replace(_Inflector.underbar, ' ');
|
|
183
|
-
const strArr = str.split(' ');
|
|
184
|
-
for (let x = 0; x < strArr.length; x++) {
|
|
185
|
-
const d = strArr[x].split('-');
|
|
186
|
-
for (let i = 0; i < d.length; i++) {
|
|
187
|
-
if (!_Inflector.nonTitlecasedWords.includes(d[i].toLowerCase())) {
|
|
188
|
-
d[i] = _Inflector.capitalize(d[i]);
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
strArr[x] = d.join('-');
|
|
192
|
-
}
|
|
193
|
-
str = strArr.join(' ');
|
|
194
|
-
str = str.substring(0, 1).toUpperCase() + str.substring(1);
|
|
195
|
-
return str;
|
|
196
|
-
},
|
|
197
|
-
/*
|
|
198
|
-
Inflector.demodulize('Message::Bus::Properties') -> 'Properties'
|
|
199
|
-
*/
|
|
200
|
-
demodulize: function (str) {
|
|
201
|
-
const strArr = str.split('::');
|
|
202
|
-
str = strArr[strArr.length - 1];
|
|
203
|
-
return str;
|
|
204
|
-
},
|
|
205
|
-
/*
|
|
206
|
-
Inflector.tableize('MessageBusProperty') -> 'message_bus_properties'
|
|
207
|
-
*/
|
|
208
|
-
tableize: function (str) {
|
|
209
|
-
str = _Inflector.pluralize(_Inflector.underscore(str));
|
|
210
|
-
return str;
|
|
211
|
-
},
|
|
212
|
-
/*
|
|
213
|
-
Inflector.classify('message_bus_properties') -> 'MessageBusProperty'
|
|
214
|
-
*/
|
|
215
|
-
classify: function (str) {
|
|
216
|
-
str = _Inflector.singularize(_Inflector.camelize(str));
|
|
217
|
-
return str;
|
|
218
|
-
},
|
|
219
|
-
/*
|
|
220
|
-
Inflector.foreignKey('MessageBusProperty') -> 'message_bus_property_id'
|
|
221
|
-
Inflector.foreignKey('MessageBusProperty', true) -> 'message_bus_propertyid'
|
|
222
|
-
*/
|
|
223
|
-
foreignKey: function (str, dropIdUbar) {
|
|
224
|
-
str = _Inflector.underscore(_Inflector.demodulize(str)) + (dropIdUbar ? ('') : ('_')) + 'id';
|
|
225
|
-
return str;
|
|
226
|
-
},
|
|
227
|
-
/*
|
|
228
|
-
Inflector.ordinalize('the 1 pitch') -> 'the 1st pitch'
|
|
229
|
-
*/
|
|
230
|
-
ordinalize: function (str) {
|
|
231
|
-
const strArr = str.split(' ');
|
|
232
|
-
for (let x = 0; x < strArr.length; x++) {
|
|
233
|
-
const i = parseInt(strArr[x]);
|
|
234
|
-
if (Number.isNaN(i)) {
|
|
235
|
-
const ltd = strArr[x].substring(strArr[x].length - 2);
|
|
236
|
-
const ld = strArr[x].substring(strArr[x].length - 1);
|
|
237
|
-
let suf = "th";
|
|
238
|
-
if ((ltd !== "11") && (ltd !== "12") && (ltd !== "13")) {
|
|
239
|
-
if (ld === "1")
|
|
240
|
-
suf = "st";
|
|
241
|
-
else if (ld === "2")
|
|
242
|
-
suf = "nd";
|
|
243
|
-
else if (ld === "3")
|
|
244
|
-
suf = "rd";
|
|
245
|
-
}
|
|
246
|
-
strArr[x] += suf;
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
str = strArr.join(' ');
|
|
250
|
-
return str;
|
|
251
|
-
}
|
|
252
|
-
};
|
|
253
|
-
export default _Inflector;
|
package/lib/esm/jsonapi.d.ts
DELETED
package/lib/esm/jsonapi.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-unsafe-argument */
|
|
2
|
-
const findIncluded = (rel, included) => {
|
|
3
|
-
return included.find(inc => {
|
|
4
|
-
return (rel.id === inc.id) && (rel.type === inc.type);
|
|
5
|
-
});
|
|
6
|
-
};
|
|
7
|
-
const denormalizeResource = (res, included) => {
|
|
8
|
-
const resource = Object.assign({ id: res.id, type: res.type }, res.attributes);
|
|
9
|
-
if (res.relationships)
|
|
10
|
-
Object.keys(res.relationships).forEach(key => {
|
|
11
|
-
const rel = res.relationships[key].data;
|
|
12
|
-
if (rel) {
|
|
13
|
-
if (Array.isArray(rel))
|
|
14
|
-
resource[key] = rel.map(r => denormalizeResource(findIncluded(r, included), included));
|
|
15
|
-
else
|
|
16
|
-
resource[key] = denormalizeResource(findIncluded(rel, included), included);
|
|
17
|
-
}
|
|
18
|
-
else if (rel === null)
|
|
19
|
-
resource[key] = null;
|
|
20
|
-
});
|
|
21
|
-
return resource;
|
|
22
|
-
};
|
|
23
|
-
const denormalize = (response) => {
|
|
24
|
-
let denormalizedResponse;
|
|
25
|
-
if (response.links)
|
|
26
|
-
delete response.links;
|
|
27
|
-
const data = response.data;
|
|
28
|
-
const included = response.included;
|
|
29
|
-
if (Array.isArray(data))
|
|
30
|
-
denormalizedResponse = data.map(res => denormalizeResource(res, included));
|
|
31
|
-
else
|
|
32
|
-
denormalizedResponse = denormalizeResource(data, included);
|
|
33
|
-
return denormalizedResponse;
|
|
34
|
-
};
|
|
35
|
-
/*
|
|
36
|
-
const includedResource = (rel: { id: any; type: any }, included: any[]) => {
|
|
37
|
-
return included.find(inc => {
|
|
38
|
-
return (rel.id === inc.id) && (rel.type === inc.type)
|
|
39
|
-
})
|
|
40
|
-
}
|
|
41
|
-
*/
|
|
42
|
-
export { denormalize };
|
package/lib/esm/output.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/** Print a formatted object */
|
|
2
|
-
declare const printObject: (obj: any, options?: {
|
|
3
|
-
color?: boolean;
|
|
4
|
-
sort?: boolean;
|
|
5
|
-
width?: number;
|
|
6
|
-
}) => string;
|
|
7
|
-
/** Print object in JSON format */
|
|
8
|
-
declare const printJSON: (obj: any, options?: {
|
|
9
|
-
unformatted?: boolean;
|
|
10
|
-
tabSize?: number;
|
|
11
|
-
}) => string;
|
|
12
|
-
/** Print object in CSV format */
|
|
13
|
-
declare const printCSV: (obj: object[], flags?: any) => string;
|
|
14
|
-
/** Center a string in the given width space */
|
|
15
|
-
declare const center: (str: string, width: number) => string;
|
|
16
|
-
/** Compute longest string in a list of strings */
|
|
17
|
-
declare const maxLength: (values: any[], field: string) => number;
|
|
18
|
-
/** Clean ISO string date */
|
|
19
|
-
declare const cleanDate: (date: string) => string;
|
|
20
|
-
/** Localized string date */
|
|
21
|
-
declare const localeDate: (date: string) => string;
|
|
22
|
-
/** Format aoutput */
|
|
23
|
-
declare const formatOutput: (output: any, flags?: any, { color }?: {
|
|
24
|
-
color?: boolean | undefined;
|
|
25
|
-
}) => string;
|
|
26
|
-
/** Format error message */
|
|
27
|
-
declare const formatError: (error: any, flags?: any) => string;
|
|
28
|
-
export { printObject, printJSON, printCSV, center, maxLength, cleanDate, localeDate, formatOutput, formatError };
|
package/lib/esm/output.js
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-unsafe-argument */
|
|
2
|
-
import { inspect } from 'util';
|
|
3
|
-
/** Print a formatted object */
|
|
4
|
-
const printObject = (obj, options) => {
|
|
5
|
-
return inspect(obj, {
|
|
6
|
-
showHidden: false,
|
|
7
|
-
depth: null,
|
|
8
|
-
colors: ((options === null || options === void 0 ? void 0 : options.color) === undefined) ? true : options.color,
|
|
9
|
-
sorted: ((options === null || options === void 0 ? void 0 : options.sort) === undefined) ? false : options === null || options === void 0 ? void 0 : options.sort,
|
|
10
|
-
maxArrayLength: Infinity,
|
|
11
|
-
breakLength: (options === null || options === void 0 ? void 0 : options.width) || 120,
|
|
12
|
-
});
|
|
13
|
-
};
|
|
14
|
-
/** Print object in JSON format */
|
|
15
|
-
const printJSON = (obj, options) => {
|
|
16
|
-
return JSON.stringify(obj, null, (((options === null || options === void 0 ? void 0 : options.unformatted) || false) ? undefined : ((options === null || options === void 0 ? void 0 : options.tabSize) || 4)));
|
|
17
|
-
};
|
|
18
|
-
/** Print object in CSV format */
|
|
19
|
-
const printCSV = (obj, flags) => {
|
|
20
|
-
if (!obj || (obj.length === 0))
|
|
21
|
-
return '';
|
|
22
|
-
const fields = Object.keys(obj[0]).filter(f => {
|
|
23
|
-
if (['id', 'type'].includes(f))
|
|
24
|
-
return flags === null || flags === void 0 ? void 0 : flags.fields.includes(f);
|
|
25
|
-
return true;
|
|
26
|
-
});
|
|
27
|
-
let csv = fields.map(f => f.toUpperCase().replace(/_/g, ' ')).join(';') + '\n';
|
|
28
|
-
obj.forEach((o) => {
|
|
29
|
-
csv += fields.map(f => o[f]).join(';') + '\n';
|
|
30
|
-
});
|
|
31
|
-
return csv;
|
|
32
|
-
};
|
|
33
|
-
/** Center a string in the given width space */
|
|
34
|
-
const center = (str, width) => {
|
|
35
|
-
return str.padStart(str.length + Math.floor((width - str.length) / 2), ' ').padEnd(width, ' ');
|
|
36
|
-
};
|
|
37
|
-
/** Compute longest string in a list of strings */
|
|
38
|
-
const maxLength = (values, field) => {
|
|
39
|
-
return values.reduce((ml, v) => {
|
|
40
|
-
const f = Array.isArray(v[field]) ? v[field].join() : v[field];
|
|
41
|
-
return Math.max(ml, String(f).length);
|
|
42
|
-
}, 0);
|
|
43
|
-
};
|
|
44
|
-
/** Clean ISO string date */
|
|
45
|
-
const cleanDate = (date) => {
|
|
46
|
-
return date.replace('T', ' ').replace('Z', '').substring(0, date.lastIndexOf('.'));
|
|
47
|
-
};
|
|
48
|
-
/** Localized string date */
|
|
49
|
-
const localeDate = (date) => {
|
|
50
|
-
if (!date)
|
|
51
|
-
return '';
|
|
52
|
-
return new Date(Date.parse(date)).toLocaleString();
|
|
53
|
-
};
|
|
54
|
-
/** Format aoutput */
|
|
55
|
-
const formatOutput = (output, flags, { color = true } = {}) => {
|
|
56
|
-
if (!output)
|
|
57
|
-
return '';
|
|
58
|
-
if (typeof output === 'string')
|
|
59
|
-
return output;
|
|
60
|
-
if (flags) {
|
|
61
|
-
if (flags.csv)
|
|
62
|
-
return printCSV(output, flags);
|
|
63
|
-
if (flags.json)
|
|
64
|
-
return printJSON(output, { unformatted: flags.unformatted });
|
|
65
|
-
}
|
|
66
|
-
return printObject(output, { color });
|
|
67
|
-
};
|
|
68
|
-
/** Format error message */
|
|
69
|
-
const formatError = (error, flags) => {
|
|
70
|
-
return formatOutput(error.errors || error, flags);
|
|
71
|
-
};
|
|
72
|
-
export { printObject, printJSON, printCSV, center, maxLength, cleanDate, localeDate, formatOutput, formatError };
|
package/lib/esm/raw.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
declare const rawRequest: (config: {
|
|
2
|
-
baseUrl: string;
|
|
3
|
-
resource: string;
|
|
4
|
-
accessToken: string;
|
|
5
|
-
operation: Operation;
|
|
6
|
-
}, data: any, id?: string) => Promise<any>;
|
|
7
|
-
declare const readDataFile: (file: string) => any;
|
|
8
|
-
declare enum Operation {
|
|
9
|
-
Create = "POST",
|
|
10
|
-
Update = "PATCH"
|
|
11
|
-
}
|
|
12
|
-
export { readDataFile, rawRequest, Operation };
|
package/lib/esm/raw.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import axios from 'axios';
|
|
2
|
-
import { readFileSync } from 'fs';
|
|
3
|
-
import { clColor } from '.';
|
|
4
|
-
const rawRequest = async (config, data, id) => {
|
|
5
|
-
return await axios.request({
|
|
6
|
-
method: config.operation,
|
|
7
|
-
baseURL: config.baseUrl,
|
|
8
|
-
url: `/api/${config.resource}` + (id ? `/${id}` : ''),
|
|
9
|
-
headers: {
|
|
10
|
-
'Content-Type': 'application/vnd.api+json',
|
|
11
|
-
Accept: 'application/vnd.api+json',
|
|
12
|
-
Authorization: `Bearer ${config.accessToken}`,
|
|
13
|
-
},
|
|
14
|
-
data,
|
|
15
|
-
}).then(res => {
|
|
16
|
-
return res.data;
|
|
17
|
-
});
|
|
18
|
-
};
|
|
19
|
-
const readDataFile = (file) => {
|
|
20
|
-
let dataFile;
|
|
21
|
-
let dataJson;
|
|
22
|
-
try {
|
|
23
|
-
dataFile = readFileSync(file, 'utf-8');
|
|
24
|
-
}
|
|
25
|
-
catch (error) {
|
|
26
|
-
throw new Error(`Unable to find or open the data file ${clColor.msg.error(file)}`);
|
|
27
|
-
}
|
|
28
|
-
try {
|
|
29
|
-
dataJson = JSON.parse(dataFile);
|
|
30
|
-
}
|
|
31
|
-
catch (error) {
|
|
32
|
-
throw new Error(`Unable to parse the data file ${clColor.msg.error(file)}: invalid JSON format`);
|
|
33
|
-
}
|
|
34
|
-
const data = dataJson.data ? dataJson : { data: dataJson };
|
|
35
|
-
return data;
|
|
36
|
-
};
|
|
37
|
-
var Operation;
|
|
38
|
-
(function (Operation) {
|
|
39
|
-
Operation["Create"] = "POST";
|
|
40
|
-
Operation["Update"] = "PATCH";
|
|
41
|
-
})(Operation || (Operation = {}));
|
|
42
|
-
export { readDataFile, rawRequest, Operation };
|
package/lib/esm/schema.d.ts
DELETED
package/lib/esm/schema.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import axios from 'axios';
|
|
2
|
-
import clConfig from './config';
|
|
3
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4
|
-
const downloadSchema = async (version) => {
|
|
5
|
-
const domain = clConfig.api.default_app_domain;
|
|
6
|
-
const baseUrl = `https://data.${domain}/schemas/`;
|
|
7
|
-
const schemaVersion = version ? ('_' + version.replace(/\./g, '-')) : '';
|
|
8
|
-
const fileName = `openapi${schemaVersion}.json`;
|
|
9
|
-
const schemaUrl = baseUrl + fileName;
|
|
10
|
-
const schemaFile = await axios.get(schemaUrl);
|
|
11
|
-
const schemaData = schemaFile.data;
|
|
12
|
-
return schemaData;
|
|
13
|
-
};
|
|
14
|
-
export { downloadSchema as download };
|
package/lib/esm/style.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export declare const red: (txt: unknown) => string;
|
|
2
|
-
export declare const green: (txt: unknown) => string;
|
|
3
|
-
export declare const yellow: (txt: unknown) => string;
|
|
4
|
-
export declare const blue: (txt: unknown) => string;
|
|
5
|
-
export declare const cyan: (txt: unknown) => string;
|
|
6
|
-
export declare const magenta: (txt: unknown) => string;
|
|
7
|
-
export declare const slug: (txt: unknown) => string;
|
|
8
|
-
export declare const id: (txt: unknown) => string;
|
|
9
|
-
export declare const command: (txt: unknown) => string;
|
|
10
|
-
export declare const flag: (txt: unknown) => string;
|
|
11
|
-
export declare const error: (txt: unknown) => string;
|
|
12
|
-
export declare const success: (txt: unknown) => string;
|
|
13
|
-
export declare const warning: (txt: unknown) => string;
|
|
14
|
-
export declare const highlight: (txt: unknown) => string;
|