@opra/cli 0.18.5 → 0.19.0
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.
|
@@ -17,7 +17,8 @@ async function processTypes(targetDir = '') {
|
|
|
17
17
|
const typesTs = this.addFile(node_path_1.default.join(targetDir, 'types.ts'));
|
|
18
18
|
for (const dataType of document.types.values()) {
|
|
19
19
|
const expFile = await this.generateTypeFile(dataType, targetDir);
|
|
20
|
-
|
|
20
|
+
if (expFile)
|
|
21
|
+
typesTs.addExportFile(expFile.filename);
|
|
21
22
|
}
|
|
22
23
|
}
|
|
23
24
|
exports.processTypes = processTypes;
|
|
@@ -28,6 +29,8 @@ exports.processTypes = processTypes;
|
|
|
28
29
|
*/
|
|
29
30
|
async function generateTypeFile(dataType, targetDir = '') {
|
|
30
31
|
const typeName = dataType.name;
|
|
32
|
+
if (typeName === 'any')
|
|
33
|
+
return;
|
|
31
34
|
if (!typeName)
|
|
32
35
|
throw new TypeError(`DataType has no name`);
|
|
33
36
|
let filePath;
|
|
@@ -74,6 +77,8 @@ async function resolveTypeNameOrDef(file, dataType, forInterface) {
|
|
|
74
77
|
if (internalTypeNames.includes(dataType.name))
|
|
75
78
|
return dataType.name;
|
|
76
79
|
const f = await this.generateTypeFile(dataType);
|
|
80
|
+
if (!f)
|
|
81
|
+
return '';
|
|
77
82
|
file.addImportFile(f.filename, [dataType.name]);
|
|
78
83
|
return dataType.name;
|
|
79
84
|
}
|
|
@@ -87,7 +92,7 @@ async function resolveTypeNameOrDef(file, dataType, forInterface) {
|
|
|
87
92
|
return this.generateUnionTypeDefinition(file, dataType, forInterface);
|
|
88
93
|
if (dataType instanceof common_1.MappedType)
|
|
89
94
|
return this.generateMappedTypeDefinition(file, dataType, forInterface);
|
|
90
|
-
return '
|
|
95
|
+
return '';
|
|
91
96
|
}
|
|
92
97
|
exports.resolveTypeNameOrDef = resolveTypeNameOrDef;
|
|
93
98
|
/**
|
|
@@ -138,16 +143,16 @@ exports.generateComplexTypeDefinition = generateComplexTypeDefinition;
|
|
|
138
143
|
* @param dataType
|
|
139
144
|
*/
|
|
140
145
|
async function generateSimpleTypeDefinition(file, dataType) {
|
|
141
|
-
if (dataType.
|
|
146
|
+
if (dataType.extendsFrom('boolean'))
|
|
142
147
|
return 'boolean';
|
|
143
|
-
if (dataType.
|
|
148
|
+
if (dataType.extendsFrom('string'))
|
|
144
149
|
return 'string';
|
|
145
|
-
if (dataType.
|
|
150
|
+
if (dataType.extendsFrom('number') || dataType.extendsFrom('integer'))
|
|
146
151
|
return 'number';
|
|
147
|
-
if (dataType.
|
|
152
|
+
if (dataType.extendsFrom('timestamp') || dataType.extendsFrom('date'))
|
|
148
153
|
return 'Date';
|
|
149
154
|
if (dataType.extendsFrom('bigint'))
|
|
150
|
-
return '
|
|
155
|
+
return 'bigint';
|
|
151
156
|
if (dataType.extendsFrom('object'))
|
|
152
157
|
return 'object';
|
|
153
158
|
return 'any';
|
|
@@ -13,7 +13,8 @@ export async function processTypes(targetDir = '') {
|
|
|
13
13
|
const typesTs = this.addFile(path.join(targetDir, 'types.ts'));
|
|
14
14
|
for (const dataType of document.types.values()) {
|
|
15
15
|
const expFile = await this.generateTypeFile(dataType, targetDir);
|
|
16
|
-
|
|
16
|
+
if (expFile)
|
|
17
|
+
typesTs.addExportFile(expFile.filename);
|
|
17
18
|
}
|
|
18
19
|
}
|
|
19
20
|
/**
|
|
@@ -23,6 +24,8 @@ export async function processTypes(targetDir = '') {
|
|
|
23
24
|
*/
|
|
24
25
|
export async function generateTypeFile(dataType, targetDir = '') {
|
|
25
26
|
const typeName = dataType.name;
|
|
27
|
+
if (typeName === 'any')
|
|
28
|
+
return;
|
|
26
29
|
if (!typeName)
|
|
27
30
|
throw new TypeError(`DataType has no name`);
|
|
28
31
|
let filePath;
|
|
@@ -68,6 +71,8 @@ export async function resolveTypeNameOrDef(file, dataType, forInterface) {
|
|
|
68
71
|
if (internalTypeNames.includes(dataType.name))
|
|
69
72
|
return dataType.name;
|
|
70
73
|
const f = await this.generateTypeFile(dataType);
|
|
74
|
+
if (!f)
|
|
75
|
+
return '';
|
|
71
76
|
file.addImportFile(f.filename, [dataType.name]);
|
|
72
77
|
return dataType.name;
|
|
73
78
|
}
|
|
@@ -81,7 +86,7 @@ export async function resolveTypeNameOrDef(file, dataType, forInterface) {
|
|
|
81
86
|
return this.generateUnionTypeDefinition(file, dataType, forInterface);
|
|
82
87
|
if (dataType instanceof MappedType)
|
|
83
88
|
return this.generateMappedTypeDefinition(file, dataType, forInterface);
|
|
84
|
-
return '
|
|
89
|
+
return '';
|
|
85
90
|
}
|
|
86
91
|
/**
|
|
87
92
|
*
|
|
@@ -130,16 +135,16 @@ export async function generateComplexTypeDefinition(file, dataType, forInterface
|
|
|
130
135
|
* @param dataType
|
|
131
136
|
*/
|
|
132
137
|
export async function generateSimpleTypeDefinition(file, dataType) {
|
|
133
|
-
if (dataType.
|
|
138
|
+
if (dataType.extendsFrom('boolean'))
|
|
134
139
|
return 'boolean';
|
|
135
|
-
if (dataType.
|
|
140
|
+
if (dataType.extendsFrom('string'))
|
|
136
141
|
return 'string';
|
|
137
|
-
if (dataType.
|
|
142
|
+
if (dataType.extendsFrom('number') || dataType.extendsFrom('integer'))
|
|
138
143
|
return 'number';
|
|
139
|
-
if (dataType.
|
|
144
|
+
if (dataType.extendsFrom('timestamp') || dataType.extendsFrom('date'))
|
|
140
145
|
return 'Date';
|
|
141
146
|
if (dataType.extendsFrom('bigint'))
|
|
142
|
-
return '
|
|
147
|
+
return 'bigint';
|
|
143
148
|
if (dataType.extendsFrom('object'))
|
|
144
149
|
return 'object';
|
|
145
150
|
return 'any';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opra/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.0",
|
|
4
4
|
"description": "Opra CLI tools",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"license": "MIT",
|
|
@@ -28,9 +28,9 @@
|
|
|
28
28
|
"clean:cover": "rimraf ../../coverage/client"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@opra/client": "^0.
|
|
31
|
+
"@opra/client": "^0.19.0",
|
|
32
32
|
"chalk": "^5.2.0",
|
|
33
|
-
"commander": "^
|
|
33
|
+
"commander": "^11.0.0",
|
|
34
34
|
"js-string-escape": "^1.0.1",
|
|
35
35
|
"putil-flattentext": "^2.1.1",
|
|
36
36
|
"putil-varhelpers": "^1.6.5"
|
|
@@ -64,4 +64,4 @@
|
|
|
64
64
|
"tool",
|
|
65
65
|
"oprimp"
|
|
66
66
|
]
|
|
67
|
-
}
|
|
67
|
+
}
|
|
@@ -11,7 +11,7 @@ export declare function processTypes(this: ApiExporter, targetDir?: string): Pro
|
|
|
11
11
|
* @param dataType
|
|
12
12
|
* @param targetDir
|
|
13
13
|
*/
|
|
14
|
-
export declare function generateTypeFile(this: ApiExporter, dataType: DataType, targetDir?: string): Promise<TsFile>;
|
|
14
|
+
export declare function generateTypeFile(this: ApiExporter, dataType: DataType, targetDir?: string): Promise<TsFile | undefined>;
|
|
15
15
|
/**
|
|
16
16
|
*
|
|
17
17
|
* @param file
|