@opra/common 0.29.1 → 0.30.1
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 +34 -2
- package/cjs/document/factory/api-document-factory.js +10 -1
- package/cjs/exception/http-errors/conflict.error.js +23 -0
- package/cjs/exception/index.js +1 -0
- package/cjs/http/opra-url-path.js +7 -1
- package/esm/document/factory/api-document-factory.js +10 -1
- package/esm/exception/http-errors/conflict.error.js +19 -0
- package/esm/exception/index.js +1 -0
- package/esm/http/opra-url-path.js +7 -1
- package/package.json +2 -2
- package/types/document/factory/api-document-factory.d.ts +0 -1
- package/types/document/resource/collection.d.ts +16 -0
- package/types/document/resource/container.d.ts +2 -0
- package/types/document/resource/singleton.d.ts +10 -0
- package/types/document/resource/storage.d.ts +8 -0
- package/types/exception/http-errors/conflict.error.d.ts +10 -0
- package/types/exception/index.d.ts +1 -0
package/browser.js
CHANGED
|
@@ -797,6 +797,24 @@ var IssueSeverity;
|
|
|
797
797
|
};
|
|
798
798
|
})(IssueSeverity || (IssueSeverity = {}));
|
|
799
799
|
|
|
800
|
+
// ../../build/common/esm/exception/http-errors/conflict.error.js
|
|
801
|
+
var ConflictError = class extends OpraException {
|
|
802
|
+
static {
|
|
803
|
+
__name(this, "ConflictError");
|
|
804
|
+
}
|
|
805
|
+
constructor() {
|
|
806
|
+
super(...arguments);
|
|
807
|
+
this.status = 409;
|
|
808
|
+
}
|
|
809
|
+
init(issue) {
|
|
810
|
+
super.init({
|
|
811
|
+
message: translate("error:CONFLICT", "Conflict"),
|
|
812
|
+
code: "CONFLICT",
|
|
813
|
+
...issue
|
|
814
|
+
});
|
|
815
|
+
}
|
|
816
|
+
};
|
|
817
|
+
|
|
800
818
|
// ../../build/common/esm/exception/resource-errors/resource-conflict.error.js
|
|
801
819
|
var ResourceConflictError = class extends OpraException {
|
|
802
820
|
static {
|
|
@@ -11149,9 +11167,13 @@ var ApiDocumentFactory = class _ApiDocumentFactory extends TypeDocumentFactory {
|
|
|
11149
11167
|
for (const [kA, oA] of Object.entries(source)) {
|
|
11150
11168
|
if (!oA)
|
|
11151
11169
|
continue;
|
|
11170
|
+
const o = output[kA] = { ...oA };
|
|
11152
11171
|
let parameters;
|
|
11172
|
+
if (oA.returnType) {
|
|
11173
|
+
o.returnType = await this.importDataType(oA.returnType);
|
|
11174
|
+
}
|
|
11153
11175
|
if (oA.parameters) {
|
|
11154
|
-
parameters = {};
|
|
11176
|
+
parameters = o.parameters = {};
|
|
11155
11177
|
for (const [kP, oP] of Object.entries(oA.parameters)) {
|
|
11156
11178
|
if (oP.enum) {
|
|
11157
11179
|
oP.type = EnumType2(oP.enum, { name: kP + "Enum" });
|
|
@@ -11233,6 +11255,9 @@ var ApiDocumentFactory = class _ApiDocumentFactory extends TypeDocumentFactory {
|
|
|
11233
11255
|
const output = {};
|
|
11234
11256
|
for (const [kA, oA] of Object.entries(source)) {
|
|
11235
11257
|
const o = output[kA] = { ...oA };
|
|
11258
|
+
if (oA.returnType) {
|
|
11259
|
+
o.returnType = await this.importDataType(oA.returnType);
|
|
11260
|
+
}
|
|
11236
11261
|
if (oA.parameters) {
|
|
11237
11262
|
const parameters = o.parameters = {};
|
|
11238
11263
|
for (const [kP, oP] of Object.entries(oA.parameters)) {
|
|
@@ -11387,8 +11412,14 @@ var OpraURLPath = class _OpraURLPath {
|
|
|
11387
11412
|
}
|
|
11388
11413
|
_resolve(items, join) {
|
|
11389
11414
|
let paths = (Array.isArray(items) ? items : [items]).map((item) => {
|
|
11390
|
-
if (typeof item === "object" && !(item instanceof _OpraURLPath || item instanceof OpraURLPathComponent))
|
|
11415
|
+
if (typeof item === "object" && !(item instanceof _OpraURLPath || item instanceof OpraURLPathComponent)) {
|
|
11391
11416
|
item = new OpraURLPathComponent(item);
|
|
11417
|
+
if (item.resource.includes("/")) {
|
|
11418
|
+
const subPath = new _OpraURLPath(item.resource);
|
|
11419
|
+
subPath[subPath.length - 1].key = item.key;
|
|
11420
|
+
return String(subPath);
|
|
11421
|
+
}
|
|
11422
|
+
}
|
|
11392
11423
|
item = String(item);
|
|
11393
11424
|
if (item.includes("?"))
|
|
11394
11425
|
item = splitString2(item, {
|
|
@@ -12036,6 +12067,7 @@ export {
|
|
|
12036
12067
|
BaseI18n,
|
|
12037
12068
|
Collection2 as Collection,
|
|
12038
12069
|
ComplexType2 as ComplexType,
|
|
12070
|
+
ConflictError,
|
|
12039
12071
|
Container2 as Container,
|
|
12040
12072
|
CrudOperation,
|
|
12041
12073
|
CrudResource,
|
|
@@ -74,9 +74,14 @@ class ApiDocumentFactory extends type_document_factory_js_1.TypeDocumentFactory
|
|
|
74
74
|
/* istanbul ignore next */
|
|
75
75
|
if (!oA)
|
|
76
76
|
continue;
|
|
77
|
+
const o = output[kA] = { ...oA };
|
|
77
78
|
let parameters;
|
|
79
|
+
// Resolve lazy type
|
|
80
|
+
if (oA.returnType) {
|
|
81
|
+
o.returnType = await this.importDataType(oA.returnType);
|
|
82
|
+
}
|
|
78
83
|
if (oA.parameters) {
|
|
79
|
-
parameters = {};
|
|
84
|
+
parameters = o.parameters = {};
|
|
80
85
|
for (const [kP, oP] of Object.entries(oA.parameters)) {
|
|
81
86
|
if (oP.enum) {
|
|
82
87
|
oP.type = (0, enum_type_js_1.EnumType)(oP.enum, { name: kP + 'Enum' });
|
|
@@ -163,6 +168,10 @@ class ApiDocumentFactory extends type_document_factory_js_1.TypeDocumentFactory
|
|
|
163
168
|
const output = {};
|
|
164
169
|
for (const [kA, oA] of Object.entries(source)) {
|
|
165
170
|
const o = output[kA] = { ...oA };
|
|
171
|
+
// Resolve lazy type
|
|
172
|
+
if (oA.returnType) {
|
|
173
|
+
o.returnType = await this.importDataType(oA.returnType);
|
|
174
|
+
}
|
|
166
175
|
if (oA.parameters) {
|
|
167
176
|
const parameters = o.parameters = {};
|
|
168
177
|
for (const [kP, oP] of Object.entries(oA.parameters)) {
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConflictError = void 0;
|
|
4
|
+
const index_js_1 = require("../../i18n/index.js");
|
|
5
|
+
const opra_exception_js_1 = require("../opra-exception.js");
|
|
6
|
+
/**
|
|
7
|
+
* 409 Conflict
|
|
8
|
+
* This response is sent when a request conflicts with the current state of the server.
|
|
9
|
+
*/
|
|
10
|
+
class ConflictError extends opra_exception_js_1.OpraException {
|
|
11
|
+
constructor() {
|
|
12
|
+
super(...arguments);
|
|
13
|
+
this.status = 409;
|
|
14
|
+
}
|
|
15
|
+
init(issue) {
|
|
16
|
+
super.init({
|
|
17
|
+
message: (0, index_js_1.translate)('error:CONFLICT', 'Conflict'),
|
|
18
|
+
code: 'CONFLICT',
|
|
19
|
+
...issue
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.ConflictError = ConflictError;
|
package/cjs/exception/index.js
CHANGED
|
@@ -6,6 +6,7 @@ tslib_1.__exportStar(require("./error-issue.js"), exports);
|
|
|
6
6
|
tslib_1.__exportStar(require("./wrap-exception.js"), exports);
|
|
7
7
|
tslib_1.__exportStar(require("./issue-severity.enum.js"), exports);
|
|
8
8
|
tslib_1.__exportStar(require("./http-errors/bad-request.error.js"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("./http-errors/conflict.error.js"), exports);
|
|
9
10
|
tslib_1.__exportStar(require("./http-errors/failed-dependency.error.js"), exports);
|
|
10
11
|
tslib_1.__exportStar(require("./http-errors/forbidden.error.js"), exports);
|
|
11
12
|
tslib_1.__exportStar(require("./http-errors/internal-server.error.js"), exports);
|
|
@@ -66,8 +66,14 @@ class OpraURLPath {
|
|
|
66
66
|
}
|
|
67
67
|
_resolve(items, join) {
|
|
68
68
|
let paths = (Array.isArray(items) ? items : [items]).map(item => {
|
|
69
|
-
if (typeof item === 'object' && !(item instanceof OpraURLPath || item instanceof OpraURLPathComponent))
|
|
69
|
+
if (typeof item === 'object' && !(item instanceof OpraURLPath || item instanceof OpraURLPathComponent)) {
|
|
70
70
|
item = new OpraURLPathComponent(item);
|
|
71
|
+
if (item.resource.includes('/')) {
|
|
72
|
+
const subPath = new OpraURLPath(item.resource);
|
|
73
|
+
subPath[subPath.length - 1].key = item.key;
|
|
74
|
+
return String(subPath);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
71
77
|
item = String(item);
|
|
72
78
|
// Remove url parts coming after path (query, hash parts)
|
|
73
79
|
if (item.includes('?'))
|
|
@@ -71,9 +71,14 @@ export class ApiDocumentFactory extends TypeDocumentFactory {
|
|
|
71
71
|
/* istanbul ignore next */
|
|
72
72
|
if (!oA)
|
|
73
73
|
continue;
|
|
74
|
+
const o = output[kA] = { ...oA };
|
|
74
75
|
let parameters;
|
|
76
|
+
// Resolve lazy type
|
|
77
|
+
if (oA.returnType) {
|
|
78
|
+
o.returnType = await this.importDataType(oA.returnType);
|
|
79
|
+
}
|
|
75
80
|
if (oA.parameters) {
|
|
76
|
-
parameters = {};
|
|
81
|
+
parameters = o.parameters = {};
|
|
77
82
|
for (const [kP, oP] of Object.entries(oA.parameters)) {
|
|
78
83
|
if (oP.enum) {
|
|
79
84
|
oP.type = EnumType(oP.enum, { name: kP + 'Enum' });
|
|
@@ -160,6 +165,10 @@ export class ApiDocumentFactory extends TypeDocumentFactory {
|
|
|
160
165
|
const output = {};
|
|
161
166
|
for (const [kA, oA] of Object.entries(source)) {
|
|
162
167
|
const o = output[kA] = { ...oA };
|
|
168
|
+
// Resolve lazy type
|
|
169
|
+
if (oA.returnType) {
|
|
170
|
+
o.returnType = await this.importDataType(oA.returnType);
|
|
171
|
+
}
|
|
163
172
|
if (oA.parameters) {
|
|
164
173
|
const parameters = o.parameters = {};
|
|
165
174
|
for (const [kP, oP] of Object.entries(oA.parameters)) {
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { translate } from '../../i18n/index.js';
|
|
2
|
+
import { OpraException } from '../opra-exception.js';
|
|
3
|
+
/**
|
|
4
|
+
* 409 Conflict
|
|
5
|
+
* This response is sent when a request conflicts with the current state of the server.
|
|
6
|
+
*/
|
|
7
|
+
export class ConflictError extends OpraException {
|
|
8
|
+
constructor() {
|
|
9
|
+
super(...arguments);
|
|
10
|
+
this.status = 409;
|
|
11
|
+
}
|
|
12
|
+
init(issue) {
|
|
13
|
+
super.init({
|
|
14
|
+
message: translate('error:CONFLICT', 'Conflict'),
|
|
15
|
+
code: 'CONFLICT',
|
|
16
|
+
...issue
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
}
|
package/esm/exception/index.js
CHANGED
|
@@ -3,6 +3,7 @@ export * from './error-issue.js';
|
|
|
3
3
|
export * from './wrap-exception.js';
|
|
4
4
|
export * from './issue-severity.enum.js';
|
|
5
5
|
export * from './http-errors/bad-request.error.js';
|
|
6
|
+
export * from './http-errors/conflict.error.js';
|
|
6
7
|
export * from './http-errors/failed-dependency.error.js';
|
|
7
8
|
export * from './http-errors/forbidden.error.js';
|
|
8
9
|
export * from './http-errors/internal-server.error.js';
|
|
@@ -62,8 +62,14 @@ export class OpraURLPath {
|
|
|
62
62
|
}
|
|
63
63
|
_resolve(items, join) {
|
|
64
64
|
let paths = (Array.isArray(items) ? items : [items]).map(item => {
|
|
65
|
-
if (typeof item === 'object' && !(item instanceof OpraURLPath || item instanceof OpraURLPathComponent))
|
|
65
|
+
if (typeof item === 'object' && !(item instanceof OpraURLPath || item instanceof OpraURLPathComponent)) {
|
|
66
66
|
item = new OpraURLPathComponent(item);
|
|
67
|
+
if (item.resource.includes('/')) {
|
|
68
|
+
const subPath = new OpraURLPath(item.resource);
|
|
69
|
+
subPath[subPath.length - 1].key = item.key;
|
|
70
|
+
return String(subPath);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
67
73
|
item = String(item);
|
|
68
74
|
// Remove url parts coming after path (query, hash parts)
|
|
69
75
|
if (item.includes('?'))
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opra/common",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.30.1",
|
|
4
4
|
"description": "Opra common package",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"license": "MIT",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"putil-varhelpers": "^1.6.5",
|
|
46
46
|
"reflect-metadata": "^0.1.13",
|
|
47
47
|
"uid": "^2.0.1",
|
|
48
|
-
"valgen": "^4.0
|
|
48
|
+
"valgen": "^4.1.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@browsery/fs": "^0.4.0",
|
|
@@ -16,7 +16,6 @@ export declare namespace ApiDocumentFactory {
|
|
|
16
16
|
interface InitArguments extends TypeDocumentFactory.InitArguments {
|
|
17
17
|
root?: RootInit;
|
|
18
18
|
}
|
|
19
|
-
type DataTypeInitializer = TypeDocumentFactory.DataTypeInitializer;
|
|
20
19
|
type ResourceInitializer = (Collection.InitArguments & {
|
|
21
20
|
kind: OpraSchema.Collection.Kind;
|
|
22
21
|
}) | (Singleton.InitArguments & {
|
|
@@ -27,20 +27,36 @@ export declare namespace Collection {
|
|
|
27
27
|
interface DecoratorOptions<T = any> extends Partial<StrictOmit<CollectionDecorator.Metadata, 'kind' | 'operations' | 'actions' | 'primaryKey'>> {
|
|
28
28
|
primaryKey?: keyof T | (keyof T)[];
|
|
29
29
|
}
|
|
30
|
+
interface Action {
|
|
31
|
+
}
|
|
30
32
|
namespace Action {
|
|
31
33
|
}
|
|
34
|
+
interface Create {
|
|
35
|
+
}
|
|
32
36
|
namespace Create {
|
|
33
37
|
}
|
|
38
|
+
interface Delete {
|
|
39
|
+
}
|
|
34
40
|
namespace Delete {
|
|
35
41
|
}
|
|
42
|
+
interface DeleteMany {
|
|
43
|
+
}
|
|
36
44
|
namespace DeleteMany {
|
|
37
45
|
}
|
|
46
|
+
interface FindMany {
|
|
47
|
+
}
|
|
38
48
|
namespace FindMany {
|
|
39
49
|
}
|
|
50
|
+
interface Get {
|
|
51
|
+
}
|
|
40
52
|
namespace Get {
|
|
41
53
|
}
|
|
54
|
+
interface Update {
|
|
55
|
+
}
|
|
42
56
|
namespace Update {
|
|
43
57
|
}
|
|
58
|
+
interface UpdateMany {
|
|
59
|
+
}
|
|
44
60
|
namespace UpdateMany {
|
|
45
61
|
}
|
|
46
62
|
}
|
|
@@ -26,14 +26,24 @@ export declare namespace Singleton {
|
|
|
26
26
|
}
|
|
27
27
|
interface DecoratorOptions extends Partial<StrictOmit<SingletonDecorator.Metadata, 'kind' | 'operations' | 'actions'>> {
|
|
28
28
|
}
|
|
29
|
+
interface Action {
|
|
30
|
+
}
|
|
29
31
|
namespace Action {
|
|
30
32
|
}
|
|
33
|
+
interface Create {
|
|
34
|
+
}
|
|
31
35
|
namespace Create {
|
|
32
36
|
}
|
|
37
|
+
interface Delete {
|
|
38
|
+
}
|
|
33
39
|
namespace Delete {
|
|
34
40
|
}
|
|
41
|
+
interface Get {
|
|
42
|
+
}
|
|
35
43
|
namespace Get {
|
|
36
44
|
}
|
|
45
|
+
interface Update {
|
|
46
|
+
}
|
|
37
47
|
namespace Update {
|
|
38
48
|
}
|
|
39
49
|
}
|
|
@@ -20,12 +20,20 @@ export declare namespace Storage {
|
|
|
20
20
|
}
|
|
21
21
|
interface DecoratorOptions extends Partial<StrictOmit<StorageDecorator.Metadata, 'kind' | 'operations' | 'actions'>> {
|
|
22
22
|
}
|
|
23
|
+
interface Action {
|
|
24
|
+
}
|
|
23
25
|
namespace Action {
|
|
24
26
|
}
|
|
27
|
+
interface Delete {
|
|
28
|
+
}
|
|
25
29
|
namespace Delete {
|
|
26
30
|
}
|
|
31
|
+
interface Get {
|
|
32
|
+
}
|
|
27
33
|
namespace Get {
|
|
28
34
|
}
|
|
35
|
+
interface Post {
|
|
36
|
+
}
|
|
29
37
|
namespace Post {
|
|
30
38
|
}
|
|
31
39
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ErrorIssue } from '../error-issue.js';
|
|
2
|
+
import { OpraException } from '../opra-exception.js';
|
|
3
|
+
/**
|
|
4
|
+
* 409 Conflict
|
|
5
|
+
* This response is sent when a request conflicts with the current state of the server.
|
|
6
|
+
*/
|
|
7
|
+
export declare class ConflictError extends OpraException {
|
|
8
|
+
status: number;
|
|
9
|
+
protected init(issue: Partial<ErrorIssue>): void;
|
|
10
|
+
}
|
|
@@ -3,6 +3,7 @@ export * from './error-issue.js';
|
|
|
3
3
|
export * from './wrap-exception.js';
|
|
4
4
|
export * from './issue-severity.enum.js';
|
|
5
5
|
export * from './http-errors/bad-request.error.js';
|
|
6
|
+
export * from './http-errors/conflict.error.js';
|
|
6
7
|
export * from './http-errors/failed-dependency.error.js';
|
|
7
8
|
export * from './http-errors/forbidden.error.js';
|
|
8
9
|
export * from './http-errors/internal-server.error.js';
|