@opra/common 0.32.5 → 0.33.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.
- package/browser.js +95 -89
- package/cjs/document/data-type/builtin/approx-date.type.js +2 -2
- package/cjs/document/data-type/builtin/approx-datetime.type.js +2 -2
- package/cjs/document/data-type/builtin/base64.type.js +2 -2
- package/cjs/document/data-type/builtin/bigint.type.js +2 -2
- package/cjs/document/data-type/builtin/boolean.type.js +2 -2
- package/cjs/document/data-type/builtin/date.type.js +2 -2
- package/cjs/document/data-type/builtin/datetime.type.js +2 -2
- package/cjs/document/data-type/builtin/email.type.js +2 -2
- package/cjs/document/data-type/builtin/integer.type.js +2 -2
- package/cjs/document/data-type/builtin/null.type.js +2 -2
- package/cjs/document/data-type/builtin/number.type.js +2 -2
- package/cjs/document/data-type/builtin/object-id.type.js +2 -2
- package/cjs/document/data-type/builtin/string.type.js +2 -2
- package/cjs/document/data-type/builtin/time.type.js +2 -2
- package/cjs/document/data-type/builtin/url.type.js +2 -2
- package/cjs/document/data-type/builtin/uuid.type.js +2 -2
- package/cjs/document/data-type/complex-type-class.js +2 -3
- package/cjs/document/data-type/enum-type-class.js +5 -5
- package/cjs/document/data-type/field-class.js +10 -8
- package/cjs/document/data-type/simple-type-class.js +3 -4
- package/cjs/document/resource/action.js +2 -3
- package/cjs/document/resource/collection-class.js +3 -3
- package/cjs/document/resource/container-class.js +1 -1
- package/cjs/document/resource/crud-operation.js +3 -4
- package/cjs/document/resource/parameter.js +3 -4
- package/cjs/exception/index.js +2 -2
- package/cjs/exception/resource-errors/permission.error.js +21 -0
- package/cjs/exception/resource-errors/resource-conflict.error.js +1 -1
- package/cjs/exception/resource-errors/resource-not-found.error.js +2 -2
- package/cjs/exception/resource-errors/resource-not.available.error.js +24 -0
- package/cjs/exception/resource-errors/resource-not.available.js +24 -0
- package/cjs/filter/ast/terms/date-literal.js +1 -1
- package/cjs/filter/ast/terms/number-literal.js +1 -1
- package/cjs/filter/ast/terms/time-literal.js +1 -1
- package/cjs/filter/errors.js +3 -3
- package/esm/document/data-type/builtin/approx-date.type.js +3 -3
- package/esm/document/data-type/builtin/approx-datetime.type.js +2 -2
- package/esm/document/data-type/builtin/base64.type.js +2 -2
- package/esm/document/data-type/builtin/bigint.type.js +3 -3
- package/esm/document/data-type/builtin/boolean.type.js +2 -2
- package/esm/document/data-type/builtin/date.type.js +3 -3
- package/esm/document/data-type/builtin/datetime.type.js +3 -3
- package/esm/document/data-type/builtin/email.type.js +3 -3
- package/esm/document/data-type/builtin/integer.type.js +2 -2
- package/esm/document/data-type/builtin/null.type.js +2 -2
- package/esm/document/data-type/builtin/number.type.js +2 -2
- package/esm/document/data-type/builtin/object-id.type.js +3 -3
- package/esm/document/data-type/builtin/string.type.js +2 -2
- package/esm/document/data-type/builtin/time.type.js +3 -3
- package/esm/document/data-type/builtin/url.type.js +2 -2
- package/esm/document/data-type/builtin/uuid.type.js +2 -2
- package/esm/document/data-type/complex-type-class.js +1 -1
- package/esm/document/data-type/enum-type-class.js +3 -2
- package/esm/document/data-type/field-class.js +8 -5
- package/esm/document/data-type/simple-type-class.js +3 -3
- package/esm/document/resource/action.js +2 -2
- package/esm/document/resource/collection-class.js +2 -1
- package/esm/document/resource/container-class.js +2 -2
- package/esm/document/resource/crud-operation.js +1 -1
- package/esm/document/resource/parameter.js +1 -1
- package/esm/exception/index.js +2 -2
- package/esm/exception/resource-errors/permission.error.js +17 -0
- package/esm/exception/resource-errors/resource-conflict.error.js +1 -1
- package/esm/exception/resource-errors/resource-not-found.error.js +2 -2
- package/esm/exception/resource-errors/resource-not.available.error.js +20 -0
- package/esm/exception/resource-errors/resource-not.available.js +20 -0
- package/esm/filter/ast/terms/date-literal.js +2 -2
- package/esm/filter/ast/terms/number-literal.js +2 -2
- package/esm/filter/ast/terms/time-literal.js +2 -2
- package/esm/filter/errors.js +1 -1
- package/package.json +3 -3
- package/types/document/data-type/complex-type-class.d.ts +4 -4
- package/types/document/data-type/data-type.d.ts +3 -3
- package/types/document/data-type/enum-type-class.d.ts +4 -4
- package/types/document/data-type/field-class.d.ts +3 -3
- package/types/document/data-type/field.d.ts +6 -3
- package/types/document/data-type/simple-type-class.d.ts +4 -4
- package/types/document/data-type/simple-type.d.ts +7 -7
- package/types/document/resource/action.d.ts +2 -2
- package/types/document/resource/crud-operation.d.ts +3 -3
- package/types/document/resource/parameter.d.ts +6 -6
- package/types/exception/index.d.ts +2 -2
- package/types/exception/resource-errors/permission.error.d.ts +11 -0
- package/types/exception/resource-errors/resource-not.available.d.ts +8 -0
- package/types/exception/resource-errors/resource-not.available.error.d.ts +8 -0
- package/types/filter/errors.d.ts +1 -1
- package/types/helpers/object-utils.d.ts +2 -2
- package/types/schema/data-type/complex-type.interface.d.ts +1 -1
- package/types/schema/data-type/field.interface.d.ts +4 -1
- package/types/schema/data-type/mapped-type.interface.d.ts +1 -1
- package/types/schema/data-type/simple-type.interface.d.ts +3 -3
- package/types/types.d.ts +6 -14
- package/cjs/exception/common-errors/validation.error.js +0 -11
- package/esm/exception/common-errors/validation.error.js +0 -7
- package/types/exception/common-errors/validation.error.d.ts +0 -4
|
@@ -10,7 +10,7 @@ exports.StringType = StringType;
|
|
|
10
10
|
exports.StringType = StringType = tslib_1.__decorate([
|
|
11
11
|
(0, simple_type_js_1.SimpleType)({
|
|
12
12
|
description: 'A sequence of characters',
|
|
13
|
-
decoder:
|
|
14
|
-
encoder:
|
|
13
|
+
decoder: valgen_1.isString,
|
|
14
|
+
encoder: valgen_1.isString,
|
|
15
15
|
})
|
|
16
16
|
], StringType);
|
|
@@ -11,11 +11,11 @@ exports.TimeType = TimeType;
|
|
|
11
11
|
exports.TimeType = TimeType = tslib_1.__decorate([
|
|
12
12
|
(0, simple_type_js_1.SimpleType)({
|
|
13
13
|
description: 'Time string in 24h format, for example, 18:23:00',
|
|
14
|
-
decoder:
|
|
14
|
+
decoder: valgen_1.vg.isRegExp(TIME_PATTERN, {
|
|
15
15
|
formatName: 'time',
|
|
16
16
|
onFail: () => '{{label}} is not a valid time'
|
|
17
17
|
}),
|
|
18
|
-
encoder:
|
|
18
|
+
encoder: valgen_1.vg.isRegExp(TIME_PATTERN, {
|
|
19
19
|
formatName: 'time',
|
|
20
20
|
onFail: () => '{{label}} is not a valid time'
|
|
21
21
|
})
|
|
@@ -10,7 +10,7 @@ exports.UrlType = UrlType;
|
|
|
10
10
|
exports.UrlType = UrlType = tslib_1.__decorate([
|
|
11
11
|
(0, simple_type_js_1.SimpleType)({
|
|
12
12
|
description: 'A Uniform Resource Identifier Reference (RFC 3986 icon) value',
|
|
13
|
-
decoder:
|
|
14
|
-
encoder:
|
|
13
|
+
decoder: valgen_1.isURL,
|
|
14
|
+
encoder: valgen_1.isURL
|
|
15
15
|
})
|
|
16
16
|
], UrlType);
|
|
@@ -10,7 +10,7 @@ exports.UuidType = UuidType;
|
|
|
10
10
|
exports.UuidType = UuidType = tslib_1.__decorate([
|
|
11
11
|
(0, simple_type_js_1.SimpleType)({
|
|
12
12
|
description: 'A Universal Unique Identifier (UUID) value',
|
|
13
|
-
decoder:
|
|
14
|
-
encoder:
|
|
13
|
+
decoder: valgen_1.isUUID,
|
|
14
|
+
encoder: valgen_1.isUUID
|
|
15
15
|
})
|
|
16
16
|
], UuidType);
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ComplexTypeClass = void 0;
|
|
4
|
-
const
|
|
5
|
-
const vg = tslib_1.__importStar(require("valgen"));
|
|
4
|
+
const valgen_1 = require("valgen");
|
|
6
5
|
const index_js_1 = require("../../helpers/index.js");
|
|
7
6
|
const index_js_2 = require("../../i18n/index.js");
|
|
8
7
|
const index_js_3 = require("../../schema/index.js");
|
|
@@ -178,7 +177,7 @@ class ComplexTypeClass extends data_type_js_1.DataType {
|
|
|
178
177
|
partial: options?.partial
|
|
179
178
|
})
|
|
180
179
|
: this.additionalFields;
|
|
181
|
-
return vg.isObject(schema, {
|
|
180
|
+
return valgen_1.vg.isObject(schema, {
|
|
182
181
|
ctor: this.ctor,
|
|
183
182
|
additionalFields,
|
|
184
183
|
name: this.name,
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.EnumTypeClass = void 0;
|
|
4
|
-
const
|
|
5
|
-
const vg = tslib_1.__importStar(require("valgen"));
|
|
4
|
+
const valgen_1 = require("valgen");
|
|
6
5
|
const index_js_1 = require("../../helpers/index.js");
|
|
7
6
|
const index_js_2 = require("../../schema/index.js");
|
|
8
7
|
const constants_js_1 = require("../constants.js");
|
|
@@ -15,11 +14,12 @@ class EnumTypeClass extends data_type_js_1.DataType {
|
|
|
15
14
|
this.base = init.base;
|
|
16
15
|
this.ownValues = { ...init.values };
|
|
17
16
|
this.values = { ...this.base?.values, ...this.ownValues };
|
|
18
|
-
this.decode = vg.isEnum(Object.keys(this.values));
|
|
19
|
-
this.encode = vg.isEnum(Object.keys(this.values));
|
|
17
|
+
this.decode = valgen_1.vg.isEnum(Object.keys(this.values));
|
|
18
|
+
this.encode = valgen_1.vg.isEnum(Object.keys(this.values));
|
|
20
19
|
}
|
|
21
20
|
isTypeOf(t) {
|
|
22
|
-
return t[constants_js_1.DATATYPE_METADATA]
|
|
21
|
+
return t[constants_js_1.DATATYPE_METADATA] &&
|
|
22
|
+
t[constants_js_1.DATATYPE_METADATA] === this.enumObject?.[constants_js_1.DATATYPE_METADATA];
|
|
23
23
|
}
|
|
24
24
|
exportSchema() {
|
|
25
25
|
const out = super.exportSchema();
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.FieldClass = void 0;
|
|
4
|
-
const
|
|
5
|
-
const vg = tslib_1.__importStar(require("valgen"));
|
|
4
|
+
const valgen_1 = require("valgen");
|
|
6
5
|
const index_js_1 = require("../../helpers/index.js");
|
|
7
6
|
class FieldClass {
|
|
8
7
|
constructor(owner, init) {
|
|
@@ -22,7 +21,8 @@ class FieldClass {
|
|
|
22
21
|
this.translatable = init.translatable;
|
|
23
22
|
this.deprecated = init.deprecated;
|
|
24
23
|
this.examples = init.examples;
|
|
25
|
-
this.
|
|
24
|
+
this.pattern = init.pattern ?
|
|
25
|
+
(init.pattern instanceof RegExp ? init.pattern : new RegExp(init.pattern)) : undefined;
|
|
26
26
|
this.partialUpdate = init.partialUpdate;
|
|
27
27
|
}
|
|
28
28
|
exportSchema(options) {
|
|
@@ -43,23 +43,25 @@ class FieldClass {
|
|
|
43
43
|
translatable: this.translatable,
|
|
44
44
|
deprecated: this.deprecated,
|
|
45
45
|
examples: this.examples,
|
|
46
|
-
|
|
46
|
+
pattern: this.pattern ? String(this.pattern) : undefined,
|
|
47
47
|
partialUpdate: this.partialUpdate,
|
|
48
48
|
});
|
|
49
49
|
}
|
|
50
50
|
generateCodec(codec, options) {
|
|
51
51
|
if (options?.operation === 'read' && this.writeonly)
|
|
52
|
-
return
|
|
52
|
+
return valgen_1.isUndefined;
|
|
53
53
|
if (options?.operation === 'write' && this.readonly)
|
|
54
|
-
return
|
|
54
|
+
return valgen_1.isUndefined;
|
|
55
55
|
let fn = this.type.generateCodec(codec, {
|
|
56
56
|
...options,
|
|
57
57
|
designType: this.designType,
|
|
58
58
|
partial: options?.partial && (this.partialUpdate || !this.isArray)
|
|
59
59
|
});
|
|
60
|
+
if (this.pattern)
|
|
61
|
+
fn = valgen_1.vg.allOf(fn, valgen_1.vg.isRegExp(this.pattern));
|
|
60
62
|
if (this.isArray)
|
|
61
|
-
fn = vg.isArray(fn);
|
|
62
|
-
return !options?.partial && this.required ? vg.required(fn) : vg.optional(fn);
|
|
63
|
+
fn = valgen_1.vg.isArray(fn);
|
|
64
|
+
return !options?.partial && this.required ? valgen_1.vg.required(fn) : valgen_1.vg.optional(fn);
|
|
63
65
|
}
|
|
64
66
|
}
|
|
65
67
|
exports.FieldClass = FieldClass;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SimpleTypeClass = void 0;
|
|
4
|
-
const
|
|
5
|
-
const vg = tslib_1.__importStar(require("valgen"));
|
|
4
|
+
const valgen_1 = require("valgen");
|
|
6
5
|
const index_js_1 = require("../../helpers/index.js");
|
|
7
6
|
const index_js_2 = require("../../schema/index.js");
|
|
8
7
|
const data_type_js_1 = require("./data-type.js");
|
|
@@ -14,8 +13,8 @@ class SimpleTypeClass extends data_type_js_1.DataType {
|
|
|
14
13
|
super(document, init);
|
|
15
14
|
this.kind = index_js_2.OpraSchema.SimpleType.Kind;
|
|
16
15
|
this.base = init.base;
|
|
17
|
-
this.decode = init.decoder || init.base?.decode ||
|
|
18
|
-
this.encode = init.encoder || init.base?.encode ||
|
|
16
|
+
this.decode = init.decoder || init.base?.decode || valgen_1.isAny;
|
|
17
|
+
this.encode = init.encoder || init.base?.encode || valgen_1.isAny;
|
|
19
18
|
}
|
|
20
19
|
exportSchema(options) {
|
|
21
20
|
// noinspection UnnecessaryLocalVariableJS
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Action = void 0;
|
|
4
|
-
const
|
|
5
|
-
const vg = tslib_1.__importStar(require("valgen"));
|
|
4
|
+
const valgen_1 = require("valgen");
|
|
6
5
|
const data_type_js_1 = require("../data-type/data-type.js");
|
|
7
6
|
const endpoint_js_1 = require("./endpoint.js");
|
|
8
7
|
/**
|
|
@@ -15,7 +14,7 @@ class Action extends endpoint_js_1.Endpoint {
|
|
|
15
14
|
this.resource = resource;
|
|
16
15
|
this.name = name;
|
|
17
16
|
this.kind = 'action';
|
|
18
|
-
this.encodeReturning =
|
|
17
|
+
this.encodeReturning = valgen_1.isAny;
|
|
19
18
|
if (init.returnType)
|
|
20
19
|
this.returnType = init.returnType instanceof data_type_js_1.DataType
|
|
21
20
|
? init.returnType : this.resource.document.getDataType(init.returnType);
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CollectionClass = void 0;
|
|
4
|
-
const
|
|
5
|
-
const vg = tslib_1.__importStar(require("valgen"));
|
|
4
|
+
const valgen_1 = require("valgen");
|
|
6
5
|
const index_js_1 = require("../../exception/index.js");
|
|
7
6
|
const index_js_2 = require("../../filter/index.js");
|
|
8
7
|
const index_js_3 = require("../../i18n/index.js");
|
|
@@ -85,7 +84,7 @@ class CollectionClass extends crud_resource_js_1.CrudResource {
|
|
|
85
84
|
endpoint.defineParameter('distinct', { type: 'boolean', isBuiltin: true });
|
|
86
85
|
endpoint.defineParameter('count', { type: 'boolean', isBuiltin: true });
|
|
87
86
|
endpoint.returnType = this.type;
|
|
88
|
-
endpoint.encodeReturning = vg.isArray(this.type.generateCodec('encode', {
|
|
87
|
+
endpoint.encodeReturning = valgen_1.vg.isArray(this.type.generateCodec('encode', {
|
|
89
88
|
partial: true,
|
|
90
89
|
pick: endpoint.options.outputPickFields,
|
|
91
90
|
omit: endpoint.options.outputOmitFields,
|
|
@@ -122,6 +121,7 @@ class CollectionClass extends crud_resource_js_1.CrudResource {
|
|
|
122
121
|
// endpoint.defineParameter('metadata', {enum: MetadataMode, isBuiltin: true, default: 'minimal'});
|
|
123
122
|
endpoint.defineParameter('filter', { type: 'string', isBuiltin: true });
|
|
124
123
|
endpoint.decodeInput = this.type.generateCodec('decode', {
|
|
124
|
+
partial: true,
|
|
125
125
|
pick: endpoint.options.inputPickFields,
|
|
126
126
|
omit: endpoint.options.inputOmitFields,
|
|
127
127
|
operation: 'write',
|
|
@@ -44,7 +44,7 @@ class ContainerClass extends resource_js_1.Resource {
|
|
|
44
44
|
resource = this.resources.get(path);
|
|
45
45
|
if (resource || silent)
|
|
46
46
|
return resource;
|
|
47
|
-
throw new index_js_1.
|
|
47
|
+
throw new index_js_1.ResourceNotAvailableError(path);
|
|
48
48
|
}
|
|
49
49
|
getContainer(path, silent) {
|
|
50
50
|
const t = this.getResource(path);
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CrudOperation = void 0;
|
|
4
|
-
const
|
|
5
|
-
const vg = tslib_1.__importStar(require("valgen"));
|
|
4
|
+
const valgen_1 = require("valgen");
|
|
6
5
|
const data_type_js_1 = require("../data-type/data-type.js");
|
|
7
6
|
const field_js_1 = require("../data-type/field.js");
|
|
8
7
|
const endpoint_js_1 = require("./endpoint.js");
|
|
@@ -16,8 +15,8 @@ class CrudOperation extends endpoint_js_1.Endpoint {
|
|
|
16
15
|
this.resource = resource;
|
|
17
16
|
this.name = name;
|
|
18
17
|
this.kind = 'operation';
|
|
19
|
-
this.decodeInput = vg.isAny();
|
|
20
|
-
this.encodeReturning = vg.isAny();
|
|
18
|
+
this.decodeInput = valgen_1.vg.isAny();
|
|
19
|
+
this.encodeReturning = valgen_1.vg.isAny();
|
|
21
20
|
this.returnType = init.returnType instanceof data_type_js_1.DataType
|
|
22
21
|
? init.returnType : this.resource.document.getDataType(init.returnType || 'any');
|
|
23
22
|
this.encodeReturning = this.returnType.generateCodec('encode', { operation: 'read' });
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Parameter = void 0;
|
|
4
|
-
const
|
|
5
|
-
const vg = tslib_1.__importStar(require("valgen"));
|
|
4
|
+
const valgen_1 = require("valgen");
|
|
6
5
|
const index_js_1 = require("../../helpers/index.js");
|
|
7
6
|
/**
|
|
8
7
|
*
|
|
@@ -44,8 +43,8 @@ class Parameter {
|
|
|
44
43
|
generateCodec(codec, options) {
|
|
45
44
|
let fn = this.type.generateCodec(codec, options);
|
|
46
45
|
if (this.isArray)
|
|
47
|
-
fn = vg.stringSplit(',');
|
|
48
|
-
return !options?.partial && this.required ? vg.required(fn) : vg.optional(fn);
|
|
46
|
+
fn = valgen_1.vg.stringSplit(',');
|
|
47
|
+
return !options?.partial && this.required ? valgen_1.vg.required(fn) : valgen_1.vg.optional(fn);
|
|
49
48
|
}
|
|
50
49
|
}
|
|
51
50
|
exports.Parameter = Parameter;
|
package/cjs/exception/index.js
CHANGED
|
@@ -15,6 +15,6 @@ tslib_1.__exportStar(require("./http-errors/not-acceptable.error.js"), exports);
|
|
|
15
15
|
tslib_1.__exportStar(require("./http-errors/not-found.error.js"), exports);
|
|
16
16
|
tslib_1.__exportStar(require("./http-errors/unauthorized.error.js"), exports);
|
|
17
17
|
tslib_1.__exportStar(require("./http-errors/unprocessable-entity.error.js"), exports);
|
|
18
|
+
tslib_1.__exportStar(require("./resource-errors/permission.error.js"), exports);
|
|
18
19
|
tslib_1.__exportStar(require("./resource-errors/resource-conflict.error.js"), exports);
|
|
19
|
-
tslib_1.__exportStar(require("./resource-errors/resource-not
|
|
20
|
-
tslib_1.__exportStar(require("./common-errors/validation.error.js"), exports);
|
|
20
|
+
tslib_1.__exportStar(require("./resource-errors/resource-not.available.error.js"), exports);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PermissionError = void 0;
|
|
4
|
+
const index_js_1 = require("../../i18n/index.js");
|
|
5
|
+
const forbidden_error_js_1 = require("../http-errors/forbidden.error.js");
|
|
6
|
+
/**
|
|
7
|
+
* 403 Forbidden
|
|
8
|
+
* The client does not have access rights to the content; that is, it is unauthorized,
|
|
9
|
+
* so the server is refusing to give the requested resource. Unlike 401 Unauthorized,
|
|
10
|
+
* the client's identity is known to the server.
|
|
11
|
+
*/
|
|
12
|
+
class PermissionError extends forbidden_error_js_1.ForbiddenError {
|
|
13
|
+
init(issue) {
|
|
14
|
+
super.init({
|
|
15
|
+
message: (0, index_js_1.translate)('error:PERMISSION_ERROR', 'You dont have permission for this operation'),
|
|
16
|
+
code: 'PERMISSION_ERROR',
|
|
17
|
+
...issue
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.PermissionError = PermissionError;
|
|
@@ -6,7 +6,7 @@ const opra_exception_js_1 = require("../opra-exception.js");
|
|
|
6
6
|
class ResourceConflictError extends opra_exception_js_1.OpraException {
|
|
7
7
|
constructor(resource, fields, cause) {
|
|
8
8
|
super({
|
|
9
|
-
message: (0, index_js_1.translate)(`error:RESOURCE_CONFLICT`, { resource, fields }, `There is already an other {{resource}} resource with same
|
|
9
|
+
message: (0, index_js_1.translate)(`error:RESOURCE_CONFLICT`, { resource, fields }, `There is already an other {{resource}} resource with same values ({{fields}})`),
|
|
10
10
|
severity: 'error',
|
|
11
11
|
code: 'RESOURCE_CONFLICT',
|
|
12
12
|
details: {
|
|
@@ -11,9 +11,9 @@ const opra_exception_js_1 = require("../opra-exception.js");
|
|
|
11
11
|
class ResourceNotFoundError extends opra_exception_js_1.OpraException {
|
|
12
12
|
constructor(resource, keyValue, cause) {
|
|
13
13
|
super({
|
|
14
|
-
message: (0, index_js_2.translate)(`error:
|
|
14
|
+
message: (0, index_js_2.translate)(`error:RESOURCE_NOT_AVAILABLE`, `Resource "${resource}${keyValue ? '/' + keyValue : ''}" is not available or you dont have access`),
|
|
15
15
|
severity: 'error',
|
|
16
|
-
code: '
|
|
16
|
+
code: 'RESOURCE_NOT_AVAILABLE',
|
|
17
17
|
details: {
|
|
18
18
|
resource,
|
|
19
19
|
key: keyValue
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ResourceNotAvailableError = void 0;
|
|
4
|
+
const index_js_1 = require("../../http/index.js");
|
|
5
|
+
const index_js_2 = require("../../i18n/index.js");
|
|
6
|
+
const opra_exception_js_1 = require("../opra-exception.js");
|
|
7
|
+
/**
|
|
8
|
+
* The server cannot find the requested resource.
|
|
9
|
+
* This can also mean that the endpoint is valid but the resource itself does not exist.
|
|
10
|
+
*/
|
|
11
|
+
class ResourceNotAvailableError extends opra_exception_js_1.OpraException {
|
|
12
|
+
constructor(resource, keyValue, cause) {
|
|
13
|
+
super({
|
|
14
|
+
message: (0, index_js_2.translate)(`error:RESOURCE_NOT_AVAILABLE`, `Resource "${resource}${keyValue ? '/' + keyValue : ''}" is not available or you dont have access`),
|
|
15
|
+
severity: 'error',
|
|
16
|
+
code: 'RESOURCE_NOT_AVAILABLE',
|
|
17
|
+
details: {
|
|
18
|
+
resource,
|
|
19
|
+
key: keyValue
|
|
20
|
+
}
|
|
21
|
+
}, cause, index_js_1.HttpStatusCodes.UNPROCESSABLE_ENTITY);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.ResourceNotAvailableError = ResourceNotAvailableError;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ResourceNotAvailable = void 0;
|
|
4
|
+
const index_js_1 = require("../../http/index.js");
|
|
5
|
+
const index_js_2 = require("../../i18n/index.js");
|
|
6
|
+
const opra_exception_js_1 = require("../opra-exception.js");
|
|
7
|
+
/**
|
|
8
|
+
* The server cannot find the requested resource.
|
|
9
|
+
* This can also mean that the endpoint is valid but the resource itself does not exist.
|
|
10
|
+
*/
|
|
11
|
+
class ResourceNotAvailable extends opra_exception_js_1.OpraException {
|
|
12
|
+
constructor(resource, keyValue, cause) {
|
|
13
|
+
super({
|
|
14
|
+
message: (0, index_js_2.translate)(`error:RESOURCE_NOT_AVAILABLE`, `Resource "${resource}${keyValue ? '/' + keyValue : ''}" is not available or you dont have access`),
|
|
15
|
+
severity: 'error',
|
|
16
|
+
code: 'RESOURCE_NOT_AVAILABLE',
|
|
17
|
+
details: {
|
|
18
|
+
resource,
|
|
19
|
+
key: keyValue
|
|
20
|
+
}
|
|
21
|
+
}, cause, index_js_1.HttpStatusCodes.UNPROCESSABLE_ENTITY);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.ResourceNotAvailable = ResourceNotAvailable;
|
|
@@ -19,7 +19,7 @@ class DateLiteral extends literal_js_1.Literal {
|
|
|
19
19
|
this.value = value;
|
|
20
20
|
return;
|
|
21
21
|
}
|
|
22
|
-
throw new errors_js_1.
|
|
22
|
+
throw new errors_js_1.FilterValidationError(`Invalid date value "${value}"`);
|
|
23
23
|
}
|
|
24
24
|
toString() {
|
|
25
25
|
return (0, utils_js_1.quoteFilterString)(this.value);
|
|
@@ -28,7 +28,7 @@ class NumberLiteral extends literal_js_1.Literal {
|
|
|
28
28
|
catch {
|
|
29
29
|
//
|
|
30
30
|
}
|
|
31
|
-
throw new errors_js_1.
|
|
31
|
+
throw new errors_js_1.FilterValidationError(`Invalid number literal ${value}`);
|
|
32
32
|
}
|
|
33
33
|
toString() {
|
|
34
34
|
return typeof this.value === 'bigint'
|
|
@@ -20,7 +20,7 @@ class TimeLiteral extends literal_js_1.Literal {
|
|
|
20
20
|
this.value = value;
|
|
21
21
|
return;
|
|
22
22
|
}
|
|
23
|
-
throw new errors_js_1.
|
|
23
|
+
throw new errors_js_1.FilterValidationError(`Invalid time value "${value}"`);
|
|
24
24
|
}
|
|
25
25
|
toString() {
|
|
26
26
|
return (0, utils_js_1.quoteFilterString)(this.value);
|
package/cjs/filter/errors.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FilterParseError = exports.
|
|
3
|
+
exports.FilterParseError = exports.FilterValidationError = exports.SyntaxError = void 0;
|
|
4
4
|
class SyntaxError extends TypeError {
|
|
5
5
|
}
|
|
6
6
|
exports.SyntaxError = SyntaxError;
|
|
7
|
-
class
|
|
7
|
+
class FilterValidationError extends TypeError {
|
|
8
8
|
constructor(message) {
|
|
9
9
|
super(typeof message === 'string' ? message : message?.message);
|
|
10
10
|
if (typeof message === 'object')
|
|
11
11
|
Object.assign(this, message);
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
|
-
exports.
|
|
14
|
+
exports.FilterValidationError = FilterValidationError;
|
|
15
15
|
class FilterParseError extends Error {
|
|
16
16
|
constructor(message, args) {
|
|
17
17
|
super(message);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
|
-
import {
|
|
2
|
+
import { vg } from 'valgen';
|
|
3
3
|
import { SimpleType } from '../simple-type.js';
|
|
4
4
|
let ApproxDateType = class ApproxDateType {
|
|
5
5
|
};
|
|
@@ -11,8 +11,8 @@ ApproxDateType = __decorate([
|
|
|
11
11
|
'2021-04',
|
|
12
12
|
'2021',
|
|
13
13
|
],
|
|
14
|
-
decoder: isDateString({ trim: 'date' }),
|
|
15
|
-
encoder: isDateString({ trim: 'date' })
|
|
14
|
+
decoder: vg.isDateString({ trim: 'date' }),
|
|
15
|
+
encoder: vg.isDateString({ trim: 'date' })
|
|
16
16
|
})
|
|
17
17
|
], ApproxDateType);
|
|
18
18
|
export { ApproxDateType };
|
|
@@ -6,8 +6,8 @@ let Base64Type = class Base64Type {
|
|
|
6
6
|
Base64Type = __decorate([
|
|
7
7
|
SimpleType({
|
|
8
8
|
description: 'A stream of bytes, base64 encoded',
|
|
9
|
-
decoder: isBase64
|
|
10
|
-
encoder: isBase64
|
|
9
|
+
decoder: isBase64,
|
|
10
|
+
encoder: isBase64,
|
|
11
11
|
})
|
|
12
12
|
], Base64Type);
|
|
13
13
|
export { Base64Type };
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
|
-
import { isBigint, isString,
|
|
2
|
+
import { isBigint, isString, vg } from 'valgen';
|
|
3
3
|
import { SimpleType } from '../simple-type.js';
|
|
4
4
|
let BigintType = class BigintType {
|
|
5
5
|
};
|
|
6
6
|
BigintType = __decorate([
|
|
7
7
|
SimpleType({
|
|
8
8
|
description: 'BigInt number',
|
|
9
|
-
decoder: isBigint
|
|
10
|
-
encoder: pipe(isBigint
|
|
9
|
+
decoder: isBigint,
|
|
10
|
+
encoder: vg.pipe(isBigint, isString)
|
|
11
11
|
})
|
|
12
12
|
], BigintType);
|
|
13
13
|
export { BigintType };
|
|
@@ -6,8 +6,8 @@ let BooleanType = class BooleanType {
|
|
|
6
6
|
BooleanType = __decorate([
|
|
7
7
|
SimpleType({
|
|
8
8
|
description: 'Simple true/false value',
|
|
9
|
-
decoder: isBoolean
|
|
10
|
-
encoder: isBoolean
|
|
9
|
+
decoder: isBoolean,
|
|
10
|
+
encoder: isBoolean
|
|
11
11
|
})
|
|
12
12
|
], BooleanType);
|
|
13
13
|
export { BooleanType };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
|
-
import {
|
|
2
|
+
import { vg } from 'valgen';
|
|
3
3
|
import { SimpleType } from '../simple-type.js';
|
|
4
4
|
let DateType = class DateType {
|
|
5
5
|
};
|
|
@@ -7,8 +7,8 @@ DateType = __decorate([
|
|
|
7
7
|
SimpleType({
|
|
8
8
|
description: 'A date without time',
|
|
9
9
|
example: ['2021-04-18'],
|
|
10
|
-
decoder: isDate({ precision: 'date' }),
|
|
11
|
-
encoder: isDateString({ precision: 'date', trim: 'date' })
|
|
10
|
+
decoder: vg.isDate({ precision: 'date' }),
|
|
11
|
+
encoder: vg.isDateString({ precision: 'date', trim: 'date' })
|
|
12
12
|
})
|
|
13
13
|
], DateType);
|
|
14
14
|
export { DateType };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
|
-
import {
|
|
2
|
+
import { vg } from 'valgen';
|
|
3
3
|
import { SimpleType } from '../simple-type.js';
|
|
4
4
|
let DatetimeType = class DatetimeType {
|
|
5
5
|
};
|
|
@@ -11,8 +11,8 @@ DatetimeType = __decorate([
|
|
|
11
11
|
'2021-04-18 22:30:15',
|
|
12
12
|
'2021-04-18 22:30'
|
|
13
13
|
],
|
|
14
|
-
decoder: isDate({ precision: 'time' }),
|
|
15
|
-
encoder: isDateString({ precision: 'time', trim: 'time' })
|
|
14
|
+
decoder: vg.isDate({ precision: 'time' }),
|
|
15
|
+
encoder: vg.isDateString({ precision: 'time', trim: 'time' })
|
|
16
16
|
})
|
|
17
17
|
], DatetimeType);
|
|
18
18
|
export { DatetimeType };
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
|
-
import {
|
|
2
|
+
import { vg } from 'valgen';
|
|
3
3
|
import { SimpleType } from '../simple-type.js';
|
|
4
4
|
let EmailType = class EmailType {
|
|
5
5
|
};
|
|
6
6
|
EmailType = __decorate([
|
|
7
7
|
SimpleType({
|
|
8
8
|
description: 'An email value',
|
|
9
|
-
decoder: isEmail(),
|
|
10
|
-
encoder: isEmail()
|
|
9
|
+
decoder: vg.isEmail(),
|
|
10
|
+
encoder: vg.isEmail()
|
|
11
11
|
})
|
|
12
12
|
], EmailType);
|
|
13
13
|
export { EmailType };
|
|
@@ -6,8 +6,8 @@ let IntegerType = class IntegerType {
|
|
|
6
6
|
IntegerType = __decorate([
|
|
7
7
|
SimpleType({
|
|
8
8
|
description: 'An integer number',
|
|
9
|
-
decoder: isInteger
|
|
10
|
-
encoder: isInteger
|
|
9
|
+
decoder: isInteger,
|
|
10
|
+
encoder: isInteger
|
|
11
11
|
})
|
|
12
12
|
], IntegerType);
|
|
13
13
|
export { IntegerType };
|
|
@@ -6,8 +6,8 @@ let NumberType = class NumberType {
|
|
|
6
6
|
NumberType = __decorate([
|
|
7
7
|
SimpleType({
|
|
8
8
|
description: 'Both Integer as well as Floating-Point numbers',
|
|
9
|
-
decoder: isNumber
|
|
10
|
-
encoder: isNumber
|
|
9
|
+
decoder: isNumber,
|
|
10
|
+
encoder: isNumber
|
|
11
11
|
})
|
|
12
12
|
], NumberType);
|
|
13
13
|
export { NumberType };
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
|
-
import { isObjectId, isString,
|
|
2
|
+
import { isObjectId, isString, vg } from 'valgen';
|
|
3
3
|
import { SimpleType } from '../simple-type.js';
|
|
4
4
|
let ObjectIdType = class ObjectIdType {
|
|
5
5
|
};
|
|
6
6
|
ObjectIdType = __decorate([
|
|
7
7
|
SimpleType({
|
|
8
8
|
description: 'A MongoDB ObjectID value',
|
|
9
|
-
decoder: isObjectId
|
|
10
|
-
encoder: pipe(isObjectId
|
|
9
|
+
decoder: isObjectId,
|
|
10
|
+
encoder: vg.pipe(isObjectId, isString)
|
|
11
11
|
})
|
|
12
12
|
], ObjectIdType);
|
|
13
13
|
export { ObjectIdType };
|
|
@@ -6,8 +6,8 @@ let StringType = class StringType {
|
|
|
6
6
|
StringType = __decorate([
|
|
7
7
|
SimpleType({
|
|
8
8
|
description: 'A sequence of characters',
|
|
9
|
-
decoder: isString
|
|
10
|
-
encoder: isString
|
|
9
|
+
decoder: isString,
|
|
10
|
+
encoder: isString,
|
|
11
11
|
})
|
|
12
12
|
], StringType);
|
|
13
13
|
export { StringType };
|