@opra/common 0.31.11 → 0.31.12
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 +45 -11
- package/cjs/document/data-type/builtin/email.type.js +16 -0
- package/cjs/document/data-type/builtin/index.js +3 -1
- package/cjs/document/data-type/builtin/url.type.js +16 -0
- package/cjs/document/data-type/field-class.js +2 -0
- package/cjs/document/factory/type-document-factory.js +2 -2
- package/cjs/exception/opra-exception.js +3 -2
- package/esm/document/data-type/builtin/email.type.js +13 -0
- package/esm/document/data-type/builtin/index.js +3 -1
- package/esm/document/data-type/builtin/url.type.js +13 -0
- package/esm/document/data-type/field-class.js +2 -0
- package/esm/document/factory/type-document-factory.js +3 -3
- package/esm/exception/opra-exception.js +3 -2
- package/package.json +3 -3
- package/types/document/data-type/builtin/email.type.d.ts +2 -0
- package/types/document/data-type/builtin/index.d.ts +3 -1
- package/types/document/data-type/builtin/url.type.d.ts +2 -0
- package/types/document/data-type/field-class.d.ts +1 -0
- package/types/schema/data-type/field.interface.d.ts +4 -0
package/browser.js
CHANGED
|
@@ -509,7 +509,6 @@ var i18n = I18n.createInstance();
|
|
|
509
509
|
i18n.init().catch(() => void 0);
|
|
510
510
|
|
|
511
511
|
// ../../build/common/esm/exception/opra-exception.js
|
|
512
|
-
var inDevelopment = (process.env.NODE_ENV || "").startsWith("dev");
|
|
513
512
|
var OpraException = class extends Error {
|
|
514
513
|
static {
|
|
515
514
|
__name(this, "OpraException");
|
|
@@ -542,13 +541,14 @@ var OpraException = class extends Error {
|
|
|
542
541
|
return i18n.deep(this.message);
|
|
543
542
|
}
|
|
544
543
|
toJSON() {
|
|
544
|
+
const env = process.env.NODE_ENV;
|
|
545
545
|
return omitUndefined({
|
|
546
546
|
message: this.message,
|
|
547
547
|
severity: this.severity,
|
|
548
548
|
system: this.system,
|
|
549
549
|
code: this.code,
|
|
550
550
|
details: this.details,
|
|
551
|
-
stack:
|
|
551
|
+
stack: env === "dev" || env === "development" || env === "test" ? this.stack?.split("\n") : void 0
|
|
552
552
|
}, true);
|
|
553
553
|
}
|
|
554
554
|
init(issue) {
|
|
@@ -2144,6 +2144,7 @@ var FieldClass = class {
|
|
|
2144
2144
|
this.readonly = init.readonly;
|
|
2145
2145
|
this.writeonly = init.writeonly;
|
|
2146
2146
|
this.exclusive = init.exclusive;
|
|
2147
|
+
this.translatable = init.translatable;
|
|
2147
2148
|
this.deprecated = init.deprecated;
|
|
2148
2149
|
this.examples = init.examples;
|
|
2149
2150
|
this.format = init.format;
|
|
@@ -2160,6 +2161,7 @@ var FieldClass = class {
|
|
|
2160
2161
|
readonly: this.readonly,
|
|
2161
2162
|
writeonly: this.writeonly,
|
|
2162
2163
|
exclusive: this.exclusive,
|
|
2164
|
+
translatable: this.translatable,
|
|
2163
2165
|
deprecated: this.deprecated,
|
|
2164
2166
|
examples: this.examples,
|
|
2165
2167
|
format: this.format
|
|
@@ -2943,20 +2945,20 @@ DatetimeType = __decorate([
|
|
|
2943
2945
|
})
|
|
2944
2946
|
], DatetimeType);
|
|
2945
2947
|
|
|
2946
|
-
// ../../build/common/esm/document/data-type/builtin/
|
|
2947
|
-
import {
|
|
2948
|
-
var
|
|
2948
|
+
// ../../build/common/esm/document/data-type/builtin/email.type.js
|
|
2949
|
+
import { isEmail } from "valgen";
|
|
2950
|
+
var EmailType = class EmailType2 {
|
|
2949
2951
|
static {
|
|
2950
|
-
__name(this, "
|
|
2952
|
+
__name(this, "EmailType");
|
|
2951
2953
|
}
|
|
2952
2954
|
};
|
|
2953
|
-
|
|
2955
|
+
EmailType = __decorate([
|
|
2954
2956
|
SimpleType2({
|
|
2955
|
-
description: "
|
|
2956
|
-
decoder:
|
|
2957
|
-
encoder:
|
|
2957
|
+
description: "An email value",
|
|
2958
|
+
decoder: isEmail(),
|
|
2959
|
+
encoder: isEmail()
|
|
2958
2960
|
})
|
|
2959
|
-
],
|
|
2961
|
+
], EmailType);
|
|
2960
2962
|
|
|
2961
2963
|
// ../../build/common/esm/document/data-type/builtin/integer.type.js
|
|
2962
2964
|
import { isInteger } from "valgen";
|
|
@@ -3070,6 +3072,36 @@ TimeType = __decorate([
|
|
|
3070
3072
|
})
|
|
3071
3073
|
], TimeType);
|
|
3072
3074
|
|
|
3075
|
+
// ../../build/common/esm/document/data-type/builtin/url.type.js
|
|
3076
|
+
import { isURL as isURL2 } from "valgen";
|
|
3077
|
+
var UrlType = class UrlType2 {
|
|
3078
|
+
static {
|
|
3079
|
+
__name(this, "UrlType");
|
|
3080
|
+
}
|
|
3081
|
+
};
|
|
3082
|
+
UrlType = __decorate([
|
|
3083
|
+
SimpleType2({
|
|
3084
|
+
description: "A Uniform Resource Identifier Reference (RFC 3986 icon) value",
|
|
3085
|
+
decoder: isURL2(),
|
|
3086
|
+
encoder: isURL2()
|
|
3087
|
+
})
|
|
3088
|
+
], UrlType);
|
|
3089
|
+
|
|
3090
|
+
// ../../build/common/esm/document/data-type/builtin/uuid.type.js
|
|
3091
|
+
import { isUUID } from "valgen";
|
|
3092
|
+
var UuidType = class UuidType2 {
|
|
3093
|
+
static {
|
|
3094
|
+
__name(this, "UuidType");
|
|
3095
|
+
}
|
|
3096
|
+
};
|
|
3097
|
+
UuidType = __decorate([
|
|
3098
|
+
SimpleType2({
|
|
3099
|
+
description: "A Universal Unique Identifier (UUID) value",
|
|
3100
|
+
decoder: isUUID(),
|
|
3101
|
+
encoder: isUUID()
|
|
3102
|
+
})
|
|
3103
|
+
], UuidType);
|
|
3104
|
+
|
|
3073
3105
|
// ../../build/common/esm/document/data-type/mapped-type.js
|
|
3074
3106
|
import "reflect-metadata";
|
|
3075
3107
|
import merge8 from "putil-merge";
|
|
@@ -3343,6 +3375,7 @@ var TypeDocumentFactory = class _TypeDocumentFactory {
|
|
|
3343
3375
|
BigintType,
|
|
3344
3376
|
BooleanType,
|
|
3345
3377
|
DateType,
|
|
3378
|
+
EmailType,
|
|
3346
3379
|
IntegerType,
|
|
3347
3380
|
NullType,
|
|
3348
3381
|
NumberType,
|
|
@@ -3353,6 +3386,7 @@ var TypeDocumentFactory = class _TypeDocumentFactory {
|
|
|
3353
3386
|
StringType,
|
|
3354
3387
|
DatetimeType,
|
|
3355
3388
|
TimeType,
|
|
3389
|
+
UrlType,
|
|
3356
3390
|
UuidType
|
|
3357
3391
|
]
|
|
3358
3392
|
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EmailType = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const valgen_1 = require("valgen");
|
|
6
|
+
const simple_type_js_1 = require("../simple-type.js");
|
|
7
|
+
let EmailType = class EmailType {
|
|
8
|
+
};
|
|
9
|
+
exports.EmailType = EmailType;
|
|
10
|
+
exports.EmailType = EmailType = tslib_1.__decorate([
|
|
11
|
+
(0, simple_type_js_1.SimpleType)({
|
|
12
|
+
description: 'An email value',
|
|
13
|
+
decoder: (0, valgen_1.isEmail)(),
|
|
14
|
+
encoder: (0, valgen_1.isEmail)()
|
|
15
|
+
})
|
|
16
|
+
], EmailType);
|
|
@@ -9,7 +9,7 @@ tslib_1.__exportStar(require("./bigint.type.js"), exports);
|
|
|
9
9
|
tslib_1.__exportStar(require("./boolean.type.js"), exports);
|
|
10
10
|
tslib_1.__exportStar(require("./date.type.js"), exports);
|
|
11
11
|
tslib_1.__exportStar(require("./datetime.type.js"), exports);
|
|
12
|
-
tslib_1.__exportStar(require("./
|
|
12
|
+
tslib_1.__exportStar(require("./email.type.js"), exports);
|
|
13
13
|
tslib_1.__exportStar(require("./integer.type.js"), exports);
|
|
14
14
|
tslib_1.__exportStar(require("./null.type.js"), exports);
|
|
15
15
|
tslib_1.__exportStar(require("./number.type.js"), exports);
|
|
@@ -17,3 +17,5 @@ tslib_1.__exportStar(require("./object.type.js"), exports);
|
|
|
17
17
|
tslib_1.__exportStar(require("./object-id.type.js"), exports);
|
|
18
18
|
tslib_1.__exportStar(require("./string.type.js"), exports);
|
|
19
19
|
tslib_1.__exportStar(require("./time.type.js"), exports);
|
|
20
|
+
tslib_1.__exportStar(require("./url.type.js"), exports);
|
|
21
|
+
tslib_1.__exportStar(require("./uuid.type.js"), exports);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UrlType = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const valgen_1 = require("valgen");
|
|
6
|
+
const simple_type_js_1 = require("../simple-type.js");
|
|
7
|
+
let UrlType = class UrlType {
|
|
8
|
+
};
|
|
9
|
+
exports.UrlType = UrlType;
|
|
10
|
+
exports.UrlType = UrlType = tslib_1.__decorate([
|
|
11
|
+
(0, simple_type_js_1.SimpleType)({
|
|
12
|
+
description: 'A Uniform Resource Identifier Reference (RFC 3986 icon) value',
|
|
13
|
+
decoder: (0, valgen_1.isURL)(),
|
|
14
|
+
encoder: (0, valgen_1.isURL)()
|
|
15
|
+
})
|
|
16
|
+
], UrlType);
|
|
@@ -19,6 +19,7 @@ class FieldClass {
|
|
|
19
19
|
this.readonly = init.readonly;
|
|
20
20
|
this.writeonly = init.writeonly;
|
|
21
21
|
this.exclusive = init.exclusive;
|
|
22
|
+
this.translatable = init.translatable;
|
|
22
23
|
this.deprecated = init.deprecated;
|
|
23
24
|
this.examples = init.examples;
|
|
24
25
|
this.format = init.format;
|
|
@@ -38,6 +39,7 @@ class FieldClass {
|
|
|
38
39
|
readonly: this.readonly,
|
|
39
40
|
writeonly: this.writeonly,
|
|
40
41
|
exclusive: this.exclusive,
|
|
42
|
+
translatable: this.translatable,
|
|
41
43
|
deprecated: this.deprecated,
|
|
42
44
|
examples: this.examples,
|
|
43
45
|
format: this.format,
|
|
@@ -97,9 +97,9 @@ class TypeDocumentFactory {
|
|
|
97
97
|
}
|
|
98
98
|
},
|
|
99
99
|
types: [index_js_3.AnyType, index_js_3.Base64Type, index_js_3.BigintType, index_js_3.BooleanType,
|
|
100
|
-
index_js_3.DateType, index_js_3.IntegerType, index_js_3.NullType, index_js_3.NumberType, index_js_3.ObjectIdType,
|
|
100
|
+
index_js_3.DateType, index_js_3.EmailType, index_js_3.IntegerType, index_js_3.NullType, index_js_3.NumberType, index_js_3.ObjectIdType,
|
|
101
101
|
index_js_3.ObjectType, index_js_3.ApproxDateType, index_js_3.ApproxDatetimeType,
|
|
102
|
-
index_js_3.StringType, index_js_3.DatetimeType, index_js_3.TimeType, index_js_3.UuidType
|
|
102
|
+
index_js_3.StringType, index_js_3.DatetimeType, index_js_3.TimeType, index_js_3.UrlType, index_js_3.UuidType
|
|
103
103
|
]
|
|
104
104
|
};
|
|
105
105
|
const factory = new TypeDocumentFactory();
|
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.OpraException = void 0;
|
|
4
4
|
const index_js_1 = require("../helpers/index.js");
|
|
5
5
|
const index_js_2 = require("../i18n/index.js");
|
|
6
|
-
const inDevelopment = (process.env.NODE_ENV || '').startsWith('dev');
|
|
7
6
|
/**
|
|
8
7
|
* Defines the base Opra exception, which is handled by the default Exceptions Handler.
|
|
9
8
|
*/
|
|
@@ -37,13 +36,15 @@ class OpraException extends Error {
|
|
|
37
36
|
return index_js_2.i18n.deep(this.message);
|
|
38
37
|
}
|
|
39
38
|
toJSON() {
|
|
39
|
+
const env = process.env.NODE_ENV;
|
|
40
40
|
return (0, index_js_1.omitUndefined)({
|
|
41
41
|
message: this.message,
|
|
42
42
|
severity: this.severity,
|
|
43
43
|
system: this.system,
|
|
44
44
|
code: this.code,
|
|
45
45
|
details: this.details,
|
|
46
|
-
stack:
|
|
46
|
+
stack: env === 'dev' || env === 'development' || env === 'test'
|
|
47
|
+
? this.stack?.split('\n') : undefined
|
|
47
48
|
}, true);
|
|
48
49
|
}
|
|
49
50
|
init(issue) {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { isEmail } from 'valgen';
|
|
3
|
+
import { SimpleType } from '../simple-type.js';
|
|
4
|
+
let EmailType = class EmailType {
|
|
5
|
+
};
|
|
6
|
+
EmailType = __decorate([
|
|
7
|
+
SimpleType({
|
|
8
|
+
description: 'An email value',
|
|
9
|
+
decoder: isEmail(),
|
|
10
|
+
encoder: isEmail()
|
|
11
|
+
})
|
|
12
|
+
], EmailType);
|
|
13
|
+
export { EmailType };
|
|
@@ -6,7 +6,7 @@ export * from './bigint.type.js';
|
|
|
6
6
|
export * from './boolean.type.js';
|
|
7
7
|
export * from './date.type.js';
|
|
8
8
|
export * from './datetime.type.js';
|
|
9
|
-
export * from './
|
|
9
|
+
export * from './email.type.js';
|
|
10
10
|
export * from './integer.type.js';
|
|
11
11
|
export * from './null.type.js';
|
|
12
12
|
export * from './number.type.js';
|
|
@@ -14,3 +14,5 @@ export * from './object.type.js';
|
|
|
14
14
|
export * from './object-id.type.js';
|
|
15
15
|
export * from './string.type.js';
|
|
16
16
|
export * from './time.type.js';
|
|
17
|
+
export * from './url.type.js';
|
|
18
|
+
export * from './uuid.type.js';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { isURL } from 'valgen';
|
|
3
|
+
import { SimpleType } from '../simple-type.js';
|
|
4
|
+
let UrlType = class UrlType {
|
|
5
|
+
};
|
|
6
|
+
UrlType = __decorate([
|
|
7
|
+
SimpleType({
|
|
8
|
+
description: 'A Uniform Resource Identifier Reference (RFC 3986 icon) value',
|
|
9
|
+
decoder: isURL(),
|
|
10
|
+
encoder: isURL()
|
|
11
|
+
})
|
|
12
|
+
], UrlType);
|
|
13
|
+
export { UrlType };
|
|
@@ -15,6 +15,7 @@ export class FieldClass {
|
|
|
15
15
|
this.readonly = init.readonly;
|
|
16
16
|
this.writeonly = init.writeonly;
|
|
17
17
|
this.exclusive = init.exclusive;
|
|
18
|
+
this.translatable = init.translatable;
|
|
18
19
|
this.deprecated = init.deprecated;
|
|
19
20
|
this.examples = init.examples;
|
|
20
21
|
this.format = init.format;
|
|
@@ -34,6 +35,7 @@ export class FieldClass {
|
|
|
34
35
|
readonly: this.readonly,
|
|
35
36
|
writeonly: this.writeonly,
|
|
36
37
|
exclusive: this.exclusive,
|
|
38
|
+
translatable: this.translatable,
|
|
37
39
|
deprecated: this.deprecated,
|
|
38
40
|
examples: this.examples,
|
|
39
41
|
format: this.format,
|
|
@@ -2,7 +2,7 @@ import { validator } from 'valgen';
|
|
|
2
2
|
import { cloneObject, isConstructor, resolveThunk, ResponsiveMap } from '../../helpers/index.js';
|
|
3
3
|
import { OpraSchema } from '../../schema/index.js';
|
|
4
4
|
import { DATATYPE_METADATA } from '../constants.js';
|
|
5
|
-
import { AnyType, ApproxDatetimeType, ApproxDateType, Base64Type, BigintType, BooleanType, DatetimeType, DateType, IntegerType, NullType, NumberType, ObjectIdType, ObjectType, StringType, TimeType, UuidType } from '../data-type/builtin/index.js';
|
|
5
|
+
import { AnyType, ApproxDatetimeType, ApproxDateType, Base64Type, BigintType, BooleanType, DatetimeType, DateType, EmailType, IntegerType, NullType, NumberType, ObjectIdType, ObjectType, StringType, TimeType, UrlType, UuidType } from '../data-type/builtin/index.js';
|
|
6
6
|
import { ComplexType } from '../data-type/complex-type.js';
|
|
7
7
|
import { EnumType } from '../data-type/enum-type.js';
|
|
8
8
|
import { MappedType } from '../data-type/mapped-type.js';
|
|
@@ -94,9 +94,9 @@ export class TypeDocumentFactory {
|
|
|
94
94
|
}
|
|
95
95
|
},
|
|
96
96
|
types: [AnyType, Base64Type, BigintType, BooleanType,
|
|
97
|
-
DateType, IntegerType, NullType, NumberType, ObjectIdType,
|
|
97
|
+
DateType, EmailType, IntegerType, NullType, NumberType, ObjectIdType,
|
|
98
98
|
ObjectType, ApproxDateType, ApproxDatetimeType,
|
|
99
|
-
StringType, DatetimeType, TimeType, UuidType
|
|
99
|
+
StringType, DatetimeType, TimeType, UrlType, UuidType
|
|
100
100
|
]
|
|
101
101
|
};
|
|
102
102
|
const factory = new TypeDocumentFactory();
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { omitUndefined } from '../helpers/index.js';
|
|
2
2
|
import { i18n } from '../i18n/index.js';
|
|
3
|
-
const inDevelopment = (process.env.NODE_ENV || '').startsWith('dev');
|
|
4
3
|
/**
|
|
5
4
|
* Defines the base Opra exception, which is handled by the default Exceptions Handler.
|
|
6
5
|
*/
|
|
@@ -34,13 +33,15 @@ export class OpraException extends Error {
|
|
|
34
33
|
return i18n.deep(this.message);
|
|
35
34
|
}
|
|
36
35
|
toJSON() {
|
|
36
|
+
const env = process.env.NODE_ENV;
|
|
37
37
|
return omitUndefined({
|
|
38
38
|
message: this.message,
|
|
39
39
|
severity: this.severity,
|
|
40
40
|
system: this.system,
|
|
41
41
|
code: this.code,
|
|
42
42
|
details: this.details,
|
|
43
|
-
stack:
|
|
43
|
+
stack: env === 'dev' || env === 'development' || env === 'test'
|
|
44
|
+
? this.stack?.split('\n') : undefined
|
|
44
45
|
}, true);
|
|
45
46
|
}
|
|
46
47
|
init(issue) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opra/common",
|
|
3
|
-
"version": "0.31.
|
|
3
|
+
"version": "0.31.12",
|
|
4
4
|
"description": "Opra common package",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"license": "MIT",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"putil-varhelpers": "^1.6.5",
|
|
47
47
|
"reflect-metadata": "^0.1.13",
|
|
48
48
|
"uid": "^2.0.1",
|
|
49
|
-
"valgen": "^4.2.
|
|
49
|
+
"valgen": "^4.2.5"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@browsery/fs": "^0.4.0",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"@browsery/util": "^0.4.0",
|
|
55
55
|
"@types/encodeurl": "^1.0.2",
|
|
56
56
|
"@types/lodash.omit": "^4.5.9",
|
|
57
|
-
"@types/validator": "^13.11.
|
|
57
|
+
"@types/validator": "^13.11.7",
|
|
58
58
|
"path-browserify": "^1.0.1",
|
|
59
59
|
"ts-gems": "^2.5.0"
|
|
60
60
|
},
|
|
@@ -6,7 +6,7 @@ export * from './bigint.type.js';
|
|
|
6
6
|
export * from './boolean.type.js';
|
|
7
7
|
export * from './date.type.js';
|
|
8
8
|
export * from './datetime.type.js';
|
|
9
|
-
export * from './
|
|
9
|
+
export * from './email.type.js';
|
|
10
10
|
export * from './integer.type.js';
|
|
11
11
|
export * from './null.type.js';
|
|
12
12
|
export * from './number.type.js';
|
|
@@ -14,3 +14,5 @@ export * from './object.type.js';
|
|
|
14
14
|
export * from './object-id.type.js';
|
|
15
15
|
export * from './string.type.js';
|
|
16
16
|
export * from './time.type.js';
|
|
17
|
+
export * from './url.type.js';
|
|
18
|
+
export * from './uuid.type.js';
|
|
@@ -38,6 +38,10 @@ export type Field = {
|
|
|
38
38
|
* The client side should include the Field name in the "include" query parameter.
|
|
39
39
|
*/
|
|
40
40
|
exclusive?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* If true, this Field is a candidate for translations
|
|
43
|
+
*/
|
|
44
|
+
translatable?: boolean;
|
|
41
45
|
/**
|
|
42
46
|
* Defines example values for the field
|
|
43
47
|
*/
|