@opra/common 0.31.4 → 0.31.6
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/browser.js +9951 -9952
- package/cjs/document/data-type/complex-type-class.js +1 -1
- package/cjs/document/factory/api-document-factory.js +8 -9
- package/cjs/document/resource/action.js +3 -1
- package/cjs/exception/resource-errors/resource-not-found.error.js +4 -3
- package/esm/document/data-type/complex-type-class.js +1 -1
- package/esm/document/factory/api-document-factory.js +8 -9
- package/esm/document/resource/action.js +3 -1
- package/esm/exception/resource-errors/resource-not-found.error.js +2 -1
- package/package.json +7 -6
|
@@ -180,7 +180,7 @@ class ComplexTypeClass extends data_type_js_1.DataType {
|
|
|
180
180
|
const omitOption = (options?.omit || []).map(x => x.toLowerCase());
|
|
181
181
|
const dedupedFieldNames = (options?.overwriteFields
|
|
182
182
|
? Array.from(new Set([...this.fields.keys(), ...options?.overwriteFields.keys()]))
|
|
183
|
-
: Array.from(this.fields.keys())).map(x => x.
|
|
183
|
+
: Array.from(this.fields.keys())).map(x => x.toLowerCase());
|
|
184
184
|
for (const nameLower of dedupedFieldNames) {
|
|
185
185
|
const overwriteField = options?.overwriteFields?.get(nameLower);
|
|
186
186
|
const field = this.fields.get(nameLower);
|
|
@@ -70,19 +70,19 @@ class ApiDocumentFactory extends type_document_factory_js_1.TypeDocumentFactory
|
|
|
70
70
|
if (!source)
|
|
71
71
|
return;
|
|
72
72
|
const output = {};
|
|
73
|
-
for (const [
|
|
73
|
+
for (const [endpointName, endpointSchema] of Object.entries(source)) {
|
|
74
74
|
/* istanbul ignore next */
|
|
75
|
-
if (!
|
|
75
|
+
if (!endpointSchema)
|
|
76
76
|
continue;
|
|
77
|
-
const
|
|
77
|
+
const outputEndpoint = output[endpointName] = { ...endpointSchema };
|
|
78
78
|
let parameters;
|
|
79
79
|
// Resolve lazy type
|
|
80
|
-
if (
|
|
81
|
-
|
|
80
|
+
if (endpointSchema.returnType) {
|
|
81
|
+
outputEndpoint.returnType = await this.importDataType(endpointSchema.returnType);
|
|
82
82
|
}
|
|
83
|
-
if (
|
|
84
|
-
parameters =
|
|
85
|
-
for (const [kP, oP] of Object.entries(
|
|
83
|
+
if (endpointSchema.parameters) {
|
|
84
|
+
parameters = outputEndpoint.parameters = {};
|
|
85
|
+
for (const [kP, oP] of Object.entries(endpointSchema.parameters)) {
|
|
86
86
|
if (oP.enum) {
|
|
87
87
|
oP.type = (0, enum_type_js_1.EnumType)(oP.enum, { name: kP + 'Enum' });
|
|
88
88
|
}
|
|
@@ -92,7 +92,6 @@ class ApiDocumentFactory extends type_document_factory_js_1.TypeDocumentFactory
|
|
|
92
92
|
};
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
|
-
output[kA] = { ...oA[kA], parameters };
|
|
96
95
|
}
|
|
97
96
|
return output;
|
|
98
97
|
};
|
|
@@ -24,7 +24,9 @@ class Action extends endpoint_js_1.Endpoint {
|
|
|
24
24
|
exportSchema(options) {
|
|
25
25
|
const schema = super.exportSchema(options);
|
|
26
26
|
if (this.returnType)
|
|
27
|
-
schema.returnType = this.returnType.
|
|
27
|
+
schema.returnType = this.returnType.isAnonymous
|
|
28
|
+
? this.returnType.exportSchema(options)
|
|
29
|
+
: this.returnType.name;
|
|
28
30
|
if (this.returnMime)
|
|
29
31
|
schema.returnMime = this.returnMime;
|
|
30
32
|
return schema;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ResourceNotFoundError = void 0;
|
|
4
|
-
const index_js_1 = require("../../
|
|
4
|
+
const index_js_1 = require("../../http/index.js");
|
|
5
|
+
const index_js_2 = require("../../i18n/index.js");
|
|
5
6
|
const opra_exception_js_1 = require("../opra-exception.js");
|
|
6
7
|
/**
|
|
7
8
|
* The server cannot find the requested resource.
|
|
@@ -10,14 +11,14 @@ const opra_exception_js_1 = require("../opra-exception.js");
|
|
|
10
11
|
class ResourceNotFoundError extends opra_exception_js_1.OpraException {
|
|
11
12
|
constructor(resource, keyValue, cause) {
|
|
12
13
|
super({
|
|
13
|
-
message: (0,
|
|
14
|
+
message: (0, index_js_2.translate)(`error:RESOURCE_NOT_FOUND`, `Resource not found`),
|
|
14
15
|
severity: 'error',
|
|
15
16
|
code: 'RESOURCE_NOT_FOUND',
|
|
16
17
|
details: {
|
|
17
18
|
resource,
|
|
18
19
|
key: keyValue
|
|
19
20
|
}
|
|
20
|
-
}, cause,
|
|
21
|
+
}, cause, index_js_1.HttpStatusCodes.UNPROCESSABLE_ENTITY);
|
|
21
22
|
}
|
|
22
23
|
}
|
|
23
24
|
exports.ResourceNotFoundError = ResourceNotFoundError;
|
|
@@ -176,7 +176,7 @@ export class ComplexTypeClass extends DataType {
|
|
|
176
176
|
const omitOption = (options?.omit || []).map(x => x.toLowerCase());
|
|
177
177
|
const dedupedFieldNames = (options?.overwriteFields
|
|
178
178
|
? Array.from(new Set([...this.fields.keys(), ...options?.overwriteFields.keys()]))
|
|
179
|
-
: Array.from(this.fields.keys())).map(x => x.
|
|
179
|
+
: Array.from(this.fields.keys())).map(x => x.toLowerCase());
|
|
180
180
|
for (const nameLower of dedupedFieldNames) {
|
|
181
181
|
const overwriteField = options?.overwriteFields?.get(nameLower);
|
|
182
182
|
const field = this.fields.get(nameLower);
|
|
@@ -67,19 +67,19 @@ export class ApiDocumentFactory extends TypeDocumentFactory {
|
|
|
67
67
|
if (!source)
|
|
68
68
|
return;
|
|
69
69
|
const output = {};
|
|
70
|
-
for (const [
|
|
70
|
+
for (const [endpointName, endpointSchema] of Object.entries(source)) {
|
|
71
71
|
/* istanbul ignore next */
|
|
72
|
-
if (!
|
|
72
|
+
if (!endpointSchema)
|
|
73
73
|
continue;
|
|
74
|
-
const
|
|
74
|
+
const outputEndpoint = output[endpointName] = { ...endpointSchema };
|
|
75
75
|
let parameters;
|
|
76
76
|
// Resolve lazy type
|
|
77
|
-
if (
|
|
78
|
-
|
|
77
|
+
if (endpointSchema.returnType) {
|
|
78
|
+
outputEndpoint.returnType = await this.importDataType(endpointSchema.returnType);
|
|
79
79
|
}
|
|
80
|
-
if (
|
|
81
|
-
parameters =
|
|
82
|
-
for (const [kP, oP] of Object.entries(
|
|
80
|
+
if (endpointSchema.parameters) {
|
|
81
|
+
parameters = outputEndpoint.parameters = {};
|
|
82
|
+
for (const [kP, oP] of Object.entries(endpointSchema.parameters)) {
|
|
83
83
|
if (oP.enum) {
|
|
84
84
|
oP.type = EnumType(oP.enum, { name: kP + 'Enum' });
|
|
85
85
|
}
|
|
@@ -89,7 +89,6 @@ export class ApiDocumentFactory extends TypeDocumentFactory {
|
|
|
89
89
|
};
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
|
-
output[kA] = { ...oA[kA], parameters };
|
|
93
92
|
}
|
|
94
93
|
return output;
|
|
95
94
|
};
|
|
@@ -20,7 +20,9 @@ export class Action extends Endpoint {
|
|
|
20
20
|
exportSchema(options) {
|
|
21
21
|
const schema = super.exportSchema(options);
|
|
22
22
|
if (this.returnType)
|
|
23
|
-
schema.returnType = this.returnType.
|
|
23
|
+
schema.returnType = this.returnType.isAnonymous
|
|
24
|
+
? this.returnType.exportSchema(options)
|
|
25
|
+
: this.returnType.name;
|
|
24
26
|
if (this.returnMime)
|
|
25
27
|
schema.returnMime = this.returnMime;
|
|
26
28
|
return schema;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { HttpStatusCodes } from '../../http/index.js';
|
|
1
2
|
import { translate } from '../../i18n/index.js';
|
|
2
3
|
import { OpraException } from '../opra-exception.js';
|
|
3
4
|
/**
|
|
@@ -14,6 +15,6 @@ export class ResourceNotFoundError extends OpraException {
|
|
|
14
15
|
resource,
|
|
15
16
|
key: keyValue
|
|
16
17
|
}
|
|
17
|
-
}, cause,
|
|
18
|
+
}, cause, HttpStatusCodes.UNPROCESSABLE_ENTITY);
|
|
18
19
|
}
|
|
19
20
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opra/common",
|
|
3
|
-
"version": "0.31.
|
|
3
|
+
"version": "0.31.6",
|
|
4
4
|
"description": "Opra common package",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"license": "MIT",
|
|
@@ -26,10 +26,11 @@
|
|
|
26
26
|
"check": "madge --circular src/**",
|
|
27
27
|
"test": "jest",
|
|
28
28
|
"cover": "jest --collect-coverage",
|
|
29
|
-
"clean": "npm run clean:src && npm run clean:dist && npm run clean:cover",
|
|
30
|
-
"clean:src": "ts-cleanup -s src --all
|
|
31
|
-
"clean:
|
|
32
|
-
"clean:
|
|
29
|
+
"clean": "npm run clean:src && npm run clean:test && npm run clean:dist && npm run clean:cover",
|
|
30
|
+
"clean:src": "ts-cleanup -s src --all",
|
|
31
|
+
"clean:test": "ts-cleanup -s test --all",
|
|
32
|
+
"clean:dist": "rimraf ../../build/client",
|
|
33
|
+
"clean:cover": "rimraf ../../coverage/client",
|
|
33
34
|
"antlr4": "java -jar ./tools/antlr4-4.12.1-SNAPSHOT-complete.jar -Dlanguage=TypeScript ./src/filter/antlr/OpraFilter.g4 -visitor"
|
|
34
35
|
},
|
|
35
36
|
"dependencies": {
|
|
@@ -45,7 +46,7 @@
|
|
|
45
46
|
"putil-varhelpers": "^1.6.5",
|
|
46
47
|
"reflect-metadata": "^0.1.13",
|
|
47
48
|
"uid": "^2.0.1",
|
|
48
|
-
"valgen": "^4.2.
|
|
49
|
+
"valgen": "^4.2.3"
|
|
49
50
|
},
|
|
50
51
|
"devDependencies": {
|
|
51
52
|
"@browsery/fs": "^0.4.0",
|