@opra/cli 1.22.9 → 1.23.2

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/package.json CHANGED
@@ -1,21 +1,22 @@
1
1
  {
2
2
  "name": "@opra/cli",
3
- "version": "1.22.9",
3
+ "version": "1.23.2",
4
4
  "description": "Opra CLI tools",
5
5
  "author": "Panates",
6
6
  "license": "MIT",
7
7
  "dependencies": {
8
8
  "@browsery/type-is": "^2.0.1",
9
+ "@jsopen/objects": "^2.1.1",
9
10
  "ansi-colors": "^4.1.3",
10
- "commander": "^14.0.2",
11
+ "commander": "^14.0.3",
11
12
  "js-string-escape": "^1.0.1",
12
13
  "putil-flattentext": "^2.1.1",
13
14
  "putil-varhelpers": "^1.7.0",
14
15
  "tslib": "^2.8.1"
15
16
  },
16
17
  "peerDependencies": {
17
- "@opra/client": "^1.22.9",
18
- "@opra/common": "^1.22.9"
18
+ "@opra/client": "^1.23.2",
19
+ "@opra/common": "^1.23.2"
19
20
  },
20
21
  "type": "module",
21
22
  "module": "./index.js",
@@ -1,4 +1,5 @@
1
1
  import path from 'node:path';
2
+ import { updateErrorMessage } from '@jsopen/objects';
2
3
  import { ArrayType, ComplexType, EnumType, MappedType, MixinType, OperationResult, SimpleType, UnionType, } from '@opra/common';
3
4
  import { CodeBlock } from '../../code-block.js';
4
5
  import { wrapJSDocString } from '../utils/string-utils.js';
@@ -71,7 +72,7 @@ export async function generateDataType(dataType, intent, currentFile) {
71
72
  return { kind: 'embedded', code: codeBlock.toString() };
72
73
  }
73
74
  catch (e) {
74
- e.message = `(${dataType.name}) ` + e.message;
75
+ updateErrorMessage(e, `(${dataType.name}) ` + e.message);
75
76
  throw e;
76
77
  }
77
78
  }
@@ -1,6 +1,6 @@
1
1
  import path from 'node:path';
2
2
  import typeIs from '@browsery/type-is';
3
- import { ComplexType, HttpController, MimeTypes, } from '@opra/common';
3
+ import { ComplexType, HttpController, MimeTypes, OperationResult, } from '@opra/common';
4
4
  import { camelCase, pascalCase } from 'putil-varhelpers';
5
5
  import { CodeBlock } from '../../code-block.js';
6
6
  import { locateNamedType } from '../utils/locate-named-type.js';
@@ -270,6 +270,9 @@ constructor(client: OpraHttpClient) {`;
270
270
  }
271
271
  if (typeDef) {
272
272
  if (typeDef !== 'OperationResult') {
273
+ const isArray = typeDef.endsWith('[]');
274
+ if (isArray)
275
+ typeDef = typeDef.substring(0, typeDef.length - 2);
273
276
  if (resp.partial) {
274
277
  file.addImport('ts-gems', ['PartialDTO']);
275
278
  typeDef = `PartialDTO<${typeDef}>`;
@@ -278,12 +281,16 @@ constructor(client: OpraHttpClient) {`;
278
281
  file.addImport('ts-gems', ['DTO']);
279
282
  typeDef = `DTO<${typeDef}>`;
280
283
  }
284
+ if (isArray)
285
+ typeDef += '[]';
281
286
  }
282
287
  }
283
288
  if (typeDef && resp.isArray)
284
289
  typeDef += '[]';
285
290
  if (resp.contentType &&
286
- typeIs.is(String(resp.contentType), [MimeTypes.opra_response_json])) {
291
+ typeIs.is(String(resp.contentType), [MimeTypes.opra_response_json]) &&
292
+ !(resp.type instanceof ComplexType &&
293
+ resp.type.base?.ctor === OperationResult)) {
287
294
  file.addImport('@opra/common', ['OperationResult']);
288
295
  typeDef = typeDef ? `OperationResult<${typeDef}>` : 'OperationResult';
289
296
  }