-
-
Notifications
You must be signed in to change notification settings - Fork 61
Expand file tree
/
Copy pathmap-type.ts
More file actions
47 lines (36 loc) · 970 Bytes
/
Copy pathmap-type.ts
File metadata and controls
47 lines (36 loc) · 970 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
export default (type: string, capitalize = false): string => {
if (type.includes('Dto')) {
return type;
}
if (type === 'number') {
return capitalize ? 'Int' : 'int';
}
if (['string', 'FilterString'].includes(type)) {
return capitalize ? 'String' : 'string';
}
if (type === 'Date') {
return 'Date';
}
if (type === 'string[]') {
return 'String[]';
}
if (type === 'boolean') {
return 'boolean';
}
if (type === 'ViewBlockBuilder') {
return 'Block';
}
if (['ActionsElementBuilder', 'InputElementBuilder', 'ContextElement'].includes(type)) {
return 'Element';
}
if (type.includes('Builder')) {
return type.replace('Builder', '');
}
if (type === 'TriggerObject') {
return 'TriggerObject';
}
if (type === 'T') {
return 'T'; // Means it is a generic and should be replaced when class mapped with methods
}
throw new Error(`Could not find a type to map for type '${type}.'`);
};