@opra/cli 0.31.6 → 0.31.8
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.
|
@@ -82,7 +82,8 @@ export class ${className} {
|
|
|
82
82
|
const actionPath = resource.getFullPath() + '/' + action;
|
|
83
83
|
let params = '';
|
|
84
84
|
for (const prm of endpoint.parameters.values()) {
|
|
85
|
-
|
|
85
|
+
const paramTypeDef = await this.resolveTypeNameOrDef(tsFile, prm.type) || 'any';
|
|
86
|
+
params += `${prm.name}: ${paramTypeDef}`;
|
|
86
87
|
if (prm.isArray)
|
|
87
88
|
params += '[]';
|
|
88
89
|
params += ';\n';
|
|
@@ -231,10 +231,36 @@ exports.generateMixinTypeDefinition = generateMixinTypeDefinition;
|
|
|
231
231
|
* @param forInterface
|
|
232
232
|
*/
|
|
233
233
|
async function generateMappedTypeDefinition(file, dataType, forInterface) {
|
|
234
|
-
const
|
|
235
|
-
const
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
234
|
+
const typeDef = await this.resolveTypeNameOrDef(file, dataType.base, forInterface);
|
|
235
|
+
const pick = dataType.pick?.length ? dataType.pick : undefined;
|
|
236
|
+
const omit = !pick && dataType.omit?.length ? dataType.omit : undefined;
|
|
237
|
+
const partial = dataType.partial === true || Array.isArray(dataType.partial) && dataType.partial.length > 0
|
|
238
|
+
? dataType.partial
|
|
239
|
+
: undefined;
|
|
240
|
+
if (!(pick || omit || partial))
|
|
241
|
+
return typeDef;
|
|
242
|
+
let out = '';
|
|
243
|
+
if (partial)
|
|
244
|
+
out += 'Partial<';
|
|
245
|
+
if (pick)
|
|
246
|
+
out += 'Pick<';
|
|
247
|
+
else if (omit)
|
|
248
|
+
out += 'Omit<';
|
|
249
|
+
out += typeDef;
|
|
250
|
+
if (omit || pick)
|
|
251
|
+
out += ', ' + (omit || pick)
|
|
252
|
+
.filter(x => !!x)
|
|
253
|
+
.map(x => `'${x}'`)
|
|
254
|
+
.join(' | ') +
|
|
255
|
+
'>';
|
|
256
|
+
if (partial) {
|
|
257
|
+
if (Array.isArray(partial))
|
|
258
|
+
out += ', ' + partial
|
|
259
|
+
.filter(x => !!x)
|
|
260
|
+
.map(x => `'${x}'`)
|
|
261
|
+
.join(' | ');
|
|
262
|
+
out += '>';
|
|
263
|
+
}
|
|
264
|
+
return out;
|
|
239
265
|
}
|
|
240
266
|
exports.generateMappedTypeDefinition = generateMappedTypeDefinition;
|
|
@@ -78,7 +78,8 @@ export class ${className} {
|
|
|
78
78
|
const actionPath = resource.getFullPath() + '/' + action;
|
|
79
79
|
let params = '';
|
|
80
80
|
for (const prm of endpoint.parameters.values()) {
|
|
81
|
-
|
|
81
|
+
const paramTypeDef = await this.resolveTypeNameOrDef(tsFile, prm.type) || 'any';
|
|
82
|
+
params += `${prm.name}: ${paramTypeDef}`;
|
|
82
83
|
if (prm.isArray)
|
|
83
84
|
params += '[]';
|
|
84
85
|
params += ';\n';
|
|
@@ -220,9 +220,35 @@ export async function generateMixinTypeDefinition(file, dataType, forInterface)
|
|
|
220
220
|
* @param forInterface
|
|
221
221
|
*/
|
|
222
222
|
export async function generateMappedTypeDefinition(file, dataType, forInterface) {
|
|
223
|
-
const
|
|
224
|
-
const
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
223
|
+
const typeDef = await this.resolveTypeNameOrDef(file, dataType.base, forInterface);
|
|
224
|
+
const pick = dataType.pick?.length ? dataType.pick : undefined;
|
|
225
|
+
const omit = !pick && dataType.omit?.length ? dataType.omit : undefined;
|
|
226
|
+
const partial = dataType.partial === true || Array.isArray(dataType.partial) && dataType.partial.length > 0
|
|
227
|
+
? dataType.partial
|
|
228
|
+
: undefined;
|
|
229
|
+
if (!(pick || omit || partial))
|
|
230
|
+
return typeDef;
|
|
231
|
+
let out = '';
|
|
232
|
+
if (partial)
|
|
233
|
+
out += 'Partial<';
|
|
234
|
+
if (pick)
|
|
235
|
+
out += 'Pick<';
|
|
236
|
+
else if (omit)
|
|
237
|
+
out += 'Omit<';
|
|
238
|
+
out += typeDef;
|
|
239
|
+
if (omit || pick)
|
|
240
|
+
out += ', ' + (omit || pick)
|
|
241
|
+
.filter(x => !!x)
|
|
242
|
+
.map(x => `'${x}'`)
|
|
243
|
+
.join(' | ') +
|
|
244
|
+
'>';
|
|
245
|
+
if (partial) {
|
|
246
|
+
if (Array.isArray(partial))
|
|
247
|
+
out += ', ' + partial
|
|
248
|
+
.filter(x => !!x)
|
|
249
|
+
.map(x => `'${x}'`)
|
|
250
|
+
.join(' | ');
|
|
251
|
+
out += '>';
|
|
252
|
+
}
|
|
253
|
+
return out;
|
|
228
254
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opra/cli",
|
|
3
|
-
"version": "0.31.
|
|
3
|
+
"version": "0.31.8",
|
|
4
4
|
"description": "Opra CLI tools",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"license": "MIT",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"clean:cover": "rimraf ../../coverage/client"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@opra/client": "^0.31.
|
|
32
|
+
"@opra/client": "^0.31.8",
|
|
33
33
|
"chalk": "^5.3.0",
|
|
34
34
|
"commander": "^11.0.0",
|
|
35
35
|
"js-string-escape": "^1.0.1",
|