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