@opra/common 1.0.0-alpha.2 → 1.0.0-alpha.4
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 +336 -136
- package/cjs/document/api-document.js +18 -12
- package/cjs/document/common/data-type-map.js +1 -1
- package/cjs/document/constants.js +1 -1
- package/cjs/document/data-type/api-field.js +5 -1
- package/cjs/document/data-type/complex-type-base.js +4 -0
- package/cjs/document/data-type/complex-type.js +4 -3
- package/cjs/document/data-type/enum-type.js +2 -0
- package/cjs/document/data-type/extended-types/base64.type.js +6 -1
- package/cjs/document/data-type/extended-types/date-string.type.js +10 -3
- package/cjs/document/data-type/extended-types/date-time-string.type.js +10 -3
- package/cjs/document/data-type/extended-types/date-time.type.js +10 -3
- package/cjs/document/data-type/extended-types/date.type.js +10 -3
- package/cjs/document/data-type/extended-types/email.type.js +24 -10
- package/cjs/document/data-type/extended-types/field-path.type.js +12 -4
- package/cjs/document/data-type/extended-types/filter.type.js +10 -3
- package/cjs/document/data-type/extended-types/object-id.type.js +6 -1
- package/cjs/document/data-type/extended-types/operation-result.type.js +20 -10
- package/cjs/document/data-type/extended-types/time.type.js +10 -3
- package/cjs/document/data-type/extended-types/url.type.js +6 -1
- package/cjs/document/data-type/extended-types/uuid.type.js +8 -2
- package/cjs/document/data-type/mapped-type.js +3 -0
- package/cjs/document/data-type/mixin-type.js +3 -0
- package/cjs/document/data-type/primitive-types/any.type.js +2 -1
- package/cjs/document/data-type/primitive-types/bigint.type.js +6 -1
- package/cjs/document/data-type/primitive-types/boolean.type.js +6 -1
- package/cjs/document/data-type/primitive-types/integer.type.js +6 -1
- package/cjs/document/data-type/primitive-types/null.type.js +6 -1
- package/cjs/document/data-type/primitive-types/number.type.js +10 -3
- package/cjs/document/data-type/primitive-types/object.type.js +2 -1
- package/cjs/document/data-type/primitive-types/string.type.js +14 -5
- package/cjs/document/data-type/simple-type.js +8 -1
- package/cjs/document/decorators/http-operation-entity.decorator.js +7 -7
- package/cjs/document/factory/api-document.factory.js +5 -0
- package/cjs/document/factory/data-type.factory.js +62 -39
- package/cjs/document/factory/http-api.factory.js +1 -1
- package/esm/document/api-document.js +18 -12
- package/esm/document/common/data-type-map.js +1 -1
- package/esm/document/constants.js +1 -1
- package/esm/document/data-type/api-field.js +5 -1
- package/esm/document/data-type/complex-type-base.js +4 -0
- package/esm/document/data-type/complex-type.js +4 -3
- package/esm/document/data-type/enum-type.js +2 -0
- package/esm/document/data-type/extended-types/base64.type.js +7 -2
- package/esm/document/data-type/extended-types/date-string.type.js +11 -4
- package/esm/document/data-type/extended-types/date-time-string.type.js +11 -4
- package/esm/document/data-type/extended-types/date-time.type.js +11 -4
- package/esm/document/data-type/extended-types/date.type.js +11 -4
- package/esm/document/data-type/extended-types/email.type.js +25 -11
- package/esm/document/data-type/extended-types/field-path.type.js +13 -5
- package/esm/document/data-type/extended-types/filter.type.js +11 -4
- package/esm/document/data-type/extended-types/object-id.type.js +7 -2
- package/esm/document/data-type/extended-types/operation-result.type.js +21 -11
- package/esm/document/data-type/extended-types/time.type.js +11 -4
- package/esm/document/data-type/extended-types/url.type.js +7 -2
- package/esm/document/data-type/extended-types/uuid.type.js +9 -3
- package/esm/document/data-type/mapped-type.js +3 -0
- package/esm/document/data-type/mixin-type.js +3 -0
- package/esm/document/data-type/primitive-types/any.type.js +3 -2
- package/esm/document/data-type/primitive-types/bigint.type.js +7 -2
- package/esm/document/data-type/primitive-types/boolean.type.js +7 -2
- package/esm/document/data-type/primitive-types/integer.type.js +7 -2
- package/esm/document/data-type/primitive-types/null.type.js +7 -2
- package/esm/document/data-type/primitive-types/number.type.js +11 -4
- package/esm/document/data-type/primitive-types/object.type.js +3 -2
- package/esm/document/data-type/primitive-types/string.type.js +15 -6
- package/esm/document/data-type/simple-type.js +8 -1
- package/esm/document/decorators/http-operation-entity.decorator.js +7 -7
- package/esm/document/factory/api-document.factory.js +4 -0
- package/esm/document/factory/data-type.factory.js +62 -39
- package/esm/document/factory/http-api.factory.js +1 -1
- package/package.json +4 -4
- package/types/document/api-document.d.ts +3 -6
- package/types/document/data-type/api-field.d.ts +2 -0
- package/types/document/data-type/complex-type.d.ts +1 -1
- package/types/document/data-type/data-type.d.ts +4 -2
- package/types/document/data-type/enum-type.d.ts +2 -2
- package/types/document/data-type/mapped-type.d.ts +2 -2
- package/types/document/data-type/mixin-type.d.ts +2 -2
- package/types/document/data-type/simple-type.d.ts +4 -2
- package/types/document/factory/api-document.factory.d.ts +1 -1
- package/types/document/factory/data-type.factory.d.ts +5 -0
- package/types/schema/data-type/simple-type.interface.d.ts +4 -0
- package/types/schema/document.interface.d.ts +13 -1
- package/types/schema/index.d.ts +1 -0
|
@@ -30,18 +30,29 @@ class ApiDocument extends document_element_js_1.DocumentElement {
|
|
|
30
30
|
if (dt)
|
|
31
31
|
return this[constants_js_1.kTypeNSMap].get(dt);
|
|
32
32
|
}
|
|
33
|
+
findDocument(id) {
|
|
34
|
+
if (this.id === id)
|
|
35
|
+
return this;
|
|
36
|
+
for (const doc of this.references.values()) {
|
|
37
|
+
if (doc.id === id)
|
|
38
|
+
return doc;
|
|
39
|
+
const d = doc.findDocument(id);
|
|
40
|
+
if (d)
|
|
41
|
+
return d;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
33
44
|
toJSON() {
|
|
34
45
|
return this.export();
|
|
35
46
|
}
|
|
36
47
|
/**
|
|
37
48
|
* Export as Opra schema definition object
|
|
38
49
|
*/
|
|
39
|
-
export(
|
|
50
|
+
export() {
|
|
40
51
|
const out = (0, index_js_1.omitUndefined)({
|
|
41
52
|
spec: index_js_2.OpraSchema.SpecVersion,
|
|
53
|
+
id: this.id,
|
|
42
54
|
url: this.url,
|
|
43
55
|
info: (0, index_js_1.cloneObject)(this.info, true),
|
|
44
|
-
// api: this.api ? this.api.toJSON() : undefined,
|
|
45
56
|
});
|
|
46
57
|
if (this.references.size) {
|
|
47
58
|
let i = 0;
|
|
@@ -49,16 +60,11 @@ class ApiDocument extends document_element_js_1.DocumentElement {
|
|
|
49
60
|
for (const [ns, doc] of this.references.entries()) {
|
|
50
61
|
if (doc[constants_js_1.BUILTIN])
|
|
51
62
|
continue;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
else if (options?.references === 'relative-url')
|
|
59
|
-
references[ns] = `/$schema?ns=${ns}`;
|
|
60
|
-
else
|
|
61
|
-
references[ns] = doc.export(options);
|
|
63
|
+
references[ns] = {
|
|
64
|
+
id: doc.id,
|
|
65
|
+
url: doc.url,
|
|
66
|
+
info: (0, index_js_1.cloneObject)(doc.info, true),
|
|
67
|
+
};
|
|
62
68
|
i++;
|
|
63
69
|
}
|
|
64
70
|
if (i)
|
|
@@ -23,7 +23,7 @@ class DataTypeMap {
|
|
|
23
23
|
}
|
|
24
24
|
get(nameOrCtor) {
|
|
25
25
|
let name = typeof nameOrCtor === 'string' ? nameOrCtor : this[kCtorMap].get(nameOrCtor);
|
|
26
|
-
if (!name) {
|
|
26
|
+
if (!name && typeof nameOrCtor === 'function') {
|
|
27
27
|
const metadata = Reflect.getMetadata(constants_js_1.DATATYPE_METADATA, nameOrCtor);
|
|
28
28
|
name = metadata?.name;
|
|
29
29
|
}
|
|
@@ -7,7 +7,7 @@ exports.DECODER = Symbol.for('opra.type.decoder');
|
|
|
7
7
|
exports.ENCODER = Symbol('opra.type.encoder');
|
|
8
8
|
exports.DECORATOR = Symbol.for('DECORATOR');
|
|
9
9
|
exports.BUILTIN = Symbol.for('BUILTIN');
|
|
10
|
-
exports.NAMESPACE_PATTERN = /([a-z$_]\w+)(
|
|
10
|
+
exports.NAMESPACE_PATTERN = /([a-z$_]\w+):(.+)/i;
|
|
11
11
|
exports.CLASS_NAME_PATTERN = /^[a-z][\w_]*$/i;
|
|
12
12
|
exports.EXTRACT_TYPENAME_PATTERN = /^(.*)Type(\d*)$/;
|
|
13
13
|
exports.kDataTypeMap = Symbol.for('kDataTypeMap');
|
|
@@ -36,6 +36,8 @@ exports.ApiField = function (...args) {
|
|
|
36
36
|
_this.exclusive = initArgs.exclusive;
|
|
37
37
|
_this.translatable = initArgs.translatable;
|
|
38
38
|
_this.deprecated = initArgs.deprecated;
|
|
39
|
+
_this.readonly = initArgs.readonly;
|
|
40
|
+
_this.writeonly = initArgs.writeonly;
|
|
39
41
|
_this.examples = initArgs.examples;
|
|
40
42
|
};
|
|
41
43
|
/**
|
|
@@ -46,7 +48,7 @@ class ApiFieldClass extends document_element_js_1.DocumentElement {
|
|
|
46
48
|
toJSON() {
|
|
47
49
|
const typeName = this.type ? this.node.getDataTypeNameWithNs(this.type) : undefined;
|
|
48
50
|
return (0, index_js_1.omitUndefined)({
|
|
49
|
-
type:
|
|
51
|
+
type: typeName ? typeName : this.type?.toJSON(),
|
|
50
52
|
description: this.description,
|
|
51
53
|
isArray: this.isArray,
|
|
52
54
|
default: this.default,
|
|
@@ -55,6 +57,8 @@ class ApiFieldClass extends document_element_js_1.DocumentElement {
|
|
|
55
57
|
exclusive: this.exclusive,
|
|
56
58
|
translatable: this.translatable,
|
|
57
59
|
deprecated: this.deprecated,
|
|
60
|
+
readonly: this.readonly,
|
|
61
|
+
writeonly: this.writeonly,
|
|
58
62
|
examples: this.examples,
|
|
59
63
|
});
|
|
60
64
|
}
|
|
@@ -146,6 +146,10 @@ class ComplexTypeBaseClass extends data_type_js_1.DataType {
|
|
|
146
146
|
// Process fields
|
|
147
147
|
let fieldName;
|
|
148
148
|
for (const field of this.fields.values()) {
|
|
149
|
+
if ((context.ignoreReadonlyFields && field.readonly) || (context.ignoreWriteonlyFields && field.writeonly)) {
|
|
150
|
+
schema[field.name] = valgen_1.vg.isUndefined({ coerce: true });
|
|
151
|
+
continue;
|
|
152
|
+
}
|
|
149
153
|
fieldName = field.name;
|
|
150
154
|
let p;
|
|
151
155
|
if (projection !== '*') {
|
|
@@ -60,6 +60,8 @@ exports.ComplexType = function (...args) {
|
|
|
60
60
|
*/
|
|
61
61
|
class ComplexTypeClass extends complex_type_base_js_1.ComplexTypeBase {
|
|
62
62
|
extendsFrom(baseType) {
|
|
63
|
+
if (!(baseType instanceof data_type_js_1.DataType))
|
|
64
|
+
baseType = this.node.getDataType(baseType);
|
|
63
65
|
if (!(baseType instanceof complex_type_base_js_1.ComplexTypeBase))
|
|
64
66
|
return false;
|
|
65
67
|
if (baseType === this)
|
|
@@ -75,9 +77,8 @@ class ComplexTypeClass extends complex_type_base_js_1.ComplexTypeBase {
|
|
|
75
77
|
});
|
|
76
78
|
if (this.additionalFields) {
|
|
77
79
|
if (this.additionalFields instanceof data_type_js_1.DataType) {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
: this.additionalFields[1].toJSON();
|
|
80
|
+
const typeName = this.node.getDataTypeNameWithNs(this.additionalFields);
|
|
81
|
+
out.additionalFields = typeName ? typeName : this.additionalFields.toJSON();
|
|
81
82
|
}
|
|
82
83
|
else
|
|
83
84
|
out.additionalFields = this.additionalFields;
|
|
@@ -38,6 +38,8 @@ exports.EnumType = function (...args) {
|
|
|
38
38
|
*/
|
|
39
39
|
class EnumTypeClass extends data_type_js_1.DataType {
|
|
40
40
|
extendsFrom(baseType) {
|
|
41
|
+
if (!(baseType instanceof data_type_js_1.DataType))
|
|
42
|
+
baseType = this.node.getDataType(baseType);
|
|
41
43
|
if (!(baseType instanceof exports.EnumType))
|
|
42
44
|
return false;
|
|
43
45
|
if (baseType === this)
|
|
@@ -21,5 +21,10 @@ exports.Base64Type = Base64Type;
|
|
|
21
21
|
exports.Base64Type = Base64Type = tslib_1.__decorate([
|
|
22
22
|
(0, simple_type_js_1.SimpleType)({
|
|
23
23
|
description: 'A stream of bytes, base64 encoded',
|
|
24
|
-
|
|
24
|
+
nameMappings: {
|
|
25
|
+
js: 'string',
|
|
26
|
+
json: 'string',
|
|
27
|
+
},
|
|
28
|
+
}),
|
|
29
|
+
tslib_1.__metadata("design:paramtypes", [Object])
|
|
25
30
|
], Base64Type);
|
|
@@ -27,18 +27,25 @@ exports.DateStringType = DateStringType;
|
|
|
27
27
|
tslib_1.__decorate([
|
|
28
28
|
simple_type_js_1.SimpleType.Attribute({
|
|
29
29
|
description: 'Minimum value',
|
|
30
|
-
})
|
|
30
|
+
}),
|
|
31
|
+
tslib_1.__metadata("design:type", String)
|
|
31
32
|
], DateStringType.prototype, "minValue", void 0);
|
|
32
33
|
tslib_1.__decorate([
|
|
33
34
|
simple_type_js_1.SimpleType.Attribute({
|
|
34
35
|
description: 'Maximum value',
|
|
35
|
-
})
|
|
36
|
+
}),
|
|
37
|
+
tslib_1.__metadata("design:type", String)
|
|
36
38
|
], DateStringType.prototype, "maxValue", void 0);
|
|
37
39
|
exports.DateStringType = DateStringType = tslib_1.__decorate([
|
|
38
40
|
(0, simple_type_js_1.SimpleType)({
|
|
39
41
|
description: 'Date string value',
|
|
42
|
+
nameMappings: {
|
|
43
|
+
js: 'string',
|
|
44
|
+
json: 'string',
|
|
45
|
+
},
|
|
40
46
|
})
|
|
41
47
|
.Example('2021-04-18', 'Full date value')
|
|
42
48
|
.Example('2021-04', 'Date value without day')
|
|
43
|
-
.Example('2021', 'Year only value')
|
|
49
|
+
.Example('2021', 'Year only value'),
|
|
50
|
+
tslib_1.__metadata("design:paramtypes", [Object])
|
|
44
51
|
], DateStringType);
|
|
@@ -27,21 +27,28 @@ exports.DateTimeStringType = DateTimeStringType;
|
|
|
27
27
|
tslib_1.__decorate([
|
|
28
28
|
simple_type_js_1.SimpleType.Attribute({
|
|
29
29
|
description: 'Minimum value',
|
|
30
|
-
})
|
|
30
|
+
}),
|
|
31
|
+
tslib_1.__metadata("design:type", String)
|
|
31
32
|
], DateTimeStringType.prototype, "minValue", void 0);
|
|
32
33
|
tslib_1.__decorate([
|
|
33
34
|
simple_type_js_1.SimpleType.Attribute({
|
|
34
35
|
description: 'Maximum value',
|
|
35
|
-
})
|
|
36
|
+
}),
|
|
37
|
+
tslib_1.__metadata("design:type", String)
|
|
36
38
|
], DateTimeStringType.prototype, "maxValue", void 0);
|
|
37
39
|
exports.DateTimeStringType = DateTimeStringType = tslib_1.__decorate([
|
|
38
40
|
(0, simple_type_js_1.SimpleType)({
|
|
39
41
|
description: 'DateTime string value',
|
|
42
|
+
nameMappings: {
|
|
43
|
+
js: 'string',
|
|
44
|
+
json: 'string',
|
|
45
|
+
},
|
|
40
46
|
})
|
|
41
47
|
.Example('2021-04-18T22:30:15+01:00', 'Full date-time value with timezone')
|
|
42
48
|
.Example('2021-04-18T22:30:15', 'Full date-time value without timezone')
|
|
43
49
|
.Example('2021-04-18 22:30', 'Date-time value')
|
|
44
50
|
.Example('2021-04-18', 'Date value')
|
|
45
51
|
.Example('2021-04', 'Date value without day')
|
|
46
|
-
.Example('2021', 'Year only value')
|
|
52
|
+
.Example('2021', 'Year only value'),
|
|
53
|
+
tslib_1.__metadata("design:paramtypes", [Object])
|
|
47
54
|
], DateTimeStringType);
|
|
@@ -41,18 +41,25 @@ exports.DateTimeType = DateTimeType;
|
|
|
41
41
|
tslib_1.__decorate([
|
|
42
42
|
simple_type_js_1.SimpleType.Attribute({
|
|
43
43
|
description: 'Minimum value',
|
|
44
|
-
})
|
|
44
|
+
}),
|
|
45
|
+
tslib_1.__metadata("design:type", String)
|
|
45
46
|
], DateTimeType.prototype, "minValue", void 0);
|
|
46
47
|
tslib_1.__decorate([
|
|
47
48
|
simple_type_js_1.SimpleType.Attribute({
|
|
48
49
|
description: 'Maximum value',
|
|
49
|
-
})
|
|
50
|
+
}),
|
|
51
|
+
tslib_1.__metadata("design:type", String)
|
|
50
52
|
], DateTimeType.prototype, "maxValue", void 0);
|
|
51
53
|
exports.DateTimeType = DateTimeType = tslib_1.__decorate([
|
|
52
54
|
(0, simple_type_js_1.SimpleType)({
|
|
53
55
|
description: 'A full datetime value',
|
|
56
|
+
nameMappings: {
|
|
57
|
+
js: 'string',
|
|
58
|
+
json: 'string',
|
|
59
|
+
},
|
|
54
60
|
})
|
|
55
61
|
.Example('2021-04-18T22:30:15')
|
|
56
62
|
.Example('2021-04-18 22:30:15')
|
|
57
|
-
.Example('2021-04-18 22:30')
|
|
63
|
+
.Example('2021-04-18 22:30'),
|
|
64
|
+
tslib_1.__metadata("design:paramtypes", [Object])
|
|
58
65
|
], DateTimeType);
|
|
@@ -41,15 +41,22 @@ exports.DateType = DateType;
|
|
|
41
41
|
tslib_1.__decorate([
|
|
42
42
|
simple_type_js_1.SimpleType.Attribute({
|
|
43
43
|
description: 'Minimum value',
|
|
44
|
-
})
|
|
44
|
+
}),
|
|
45
|
+
tslib_1.__metadata("design:type", String)
|
|
45
46
|
], DateType.prototype, "minValue", void 0);
|
|
46
47
|
tslib_1.__decorate([
|
|
47
48
|
simple_type_js_1.SimpleType.Attribute({
|
|
48
49
|
description: 'Maximum value',
|
|
49
|
-
})
|
|
50
|
+
}),
|
|
51
|
+
tslib_1.__metadata("design:type", String)
|
|
50
52
|
], DateType.prototype, "maxValue", void 0);
|
|
51
53
|
exports.DateType = DateType = tslib_1.__decorate([
|
|
52
54
|
(0, simple_type_js_1.SimpleType)({
|
|
53
55
|
description: 'A date without time',
|
|
54
|
-
|
|
56
|
+
nameMappings: {
|
|
57
|
+
js: 'Date',
|
|
58
|
+
json: 'string',
|
|
59
|
+
},
|
|
60
|
+
}).Example('2021-04-18', 'Full date value'),
|
|
61
|
+
tslib_1.__metadata("design:paramtypes", [Object])
|
|
55
62
|
], DateType);
|
|
@@ -22,59 +22,73 @@ tslib_1.__decorate([
|
|
|
22
22
|
simple_type_js_1.SimpleType.Attribute({
|
|
23
23
|
description: 'If set to `true`, the validator will also match `Display Name <email-address>',
|
|
24
24
|
default: false,
|
|
25
|
-
})
|
|
25
|
+
}),
|
|
26
|
+
tslib_1.__metadata("design:type", Boolean)
|
|
26
27
|
], EmailType.prototype, "allowDisplayName", void 0);
|
|
27
28
|
tslib_1.__decorate([
|
|
28
29
|
simple_type_js_1.SimpleType.Attribute({
|
|
29
30
|
description: 'If set to `true`, the validator will reject strings without the format `Display Name <email-address>',
|
|
30
31
|
default: false,
|
|
31
|
-
})
|
|
32
|
+
}),
|
|
33
|
+
tslib_1.__metadata("design:type", Boolean)
|
|
32
34
|
], EmailType.prototype, "requireDisplayName", void 0);
|
|
33
35
|
tslib_1.__decorate([
|
|
34
36
|
simple_type_js_1.SimpleType.Attribute({
|
|
35
37
|
description: "If set to `false`, the validator will not allow any non-English UTF8 character in email address's local part",
|
|
36
38
|
default: true,
|
|
37
|
-
})
|
|
39
|
+
}),
|
|
40
|
+
tslib_1.__metadata("design:type", Boolean)
|
|
38
41
|
], EmailType.prototype, "utf8LocalPart", void 0);
|
|
39
42
|
tslib_1.__decorate([
|
|
40
43
|
simple_type_js_1.SimpleType.Attribute({
|
|
41
44
|
description: 'If set to `true`, the validator will not check for the standard max length of an email',
|
|
42
45
|
default: false,
|
|
43
|
-
})
|
|
46
|
+
}),
|
|
47
|
+
tslib_1.__metadata("design:type", Boolean)
|
|
44
48
|
], EmailType.prototype, "ignoreMaxLength", void 0);
|
|
45
49
|
tslib_1.__decorate([
|
|
46
50
|
simple_type_js_1.SimpleType.Attribute({
|
|
47
51
|
description: 'If set to `true`, the validator will allow IP addresses in the host part',
|
|
48
52
|
default: false,
|
|
49
|
-
})
|
|
53
|
+
}),
|
|
54
|
+
tslib_1.__metadata("design:type", Boolean)
|
|
50
55
|
], EmailType.prototype, "allowIpDomain", void 0);
|
|
51
56
|
tslib_1.__decorate([
|
|
52
57
|
simple_type_js_1.SimpleType.Attribute({
|
|
53
58
|
description: 'If set to `true`, some additional validation will be enabled, ' +
|
|
54
59
|
'e.g. disallowing certain syntactically valid email addresses that are rejected by GMail.',
|
|
55
60
|
default: false,
|
|
56
|
-
})
|
|
61
|
+
}),
|
|
62
|
+
tslib_1.__metadata("design:type", Boolean)
|
|
57
63
|
], EmailType.prototype, "domainSpecificValidation", void 0);
|
|
58
64
|
tslib_1.__decorate([
|
|
59
65
|
simple_type_js_1.SimpleType.Attribute({
|
|
60
66
|
description: 'If set to an array of strings and the part of the email after the @ symbol ' +
|
|
61
67
|
' one of the strings defined in it, the validation fails.',
|
|
62
|
-
})
|
|
68
|
+
}),
|
|
69
|
+
tslib_1.__metadata("design:type", Array)
|
|
63
70
|
], EmailType.prototype, "hostBlacklist", void 0);
|
|
64
71
|
tslib_1.__decorate([
|
|
65
72
|
simple_type_js_1.SimpleType.Attribute({
|
|
66
73
|
description: 'If set to an array of strings and the part of the email after the @ symbol ' +
|
|
67
74
|
' matches none of the strings defined in it, the validation fails.',
|
|
68
|
-
})
|
|
75
|
+
}),
|
|
76
|
+
tslib_1.__metadata("design:type", Array)
|
|
69
77
|
], EmailType.prototype, "hostWhitelist", void 0);
|
|
70
78
|
tslib_1.__decorate([
|
|
71
79
|
simple_type_js_1.SimpleType.Attribute({
|
|
72
80
|
description: 'If set to a string, then the validator will reject emails that include ' +
|
|
73
81
|
' any of the characters in the string, in the name part.',
|
|
74
|
-
})
|
|
82
|
+
}),
|
|
83
|
+
tslib_1.__metadata("design:type", String)
|
|
75
84
|
], EmailType.prototype, "blacklistedChars", void 0);
|
|
76
85
|
exports.EmailType = EmailType = tslib_1.__decorate([
|
|
77
86
|
(0, simple_type_js_1.SimpleType)({
|
|
78
87
|
description: 'An email value',
|
|
79
|
-
|
|
88
|
+
nameMappings: {
|
|
89
|
+
js: 'string',
|
|
90
|
+
json: 'string',
|
|
91
|
+
},
|
|
92
|
+
}).Example('some.body@example.com'),
|
|
93
|
+
tslib_1.__metadata("design:paramtypes", [Object])
|
|
80
94
|
], EmailType);
|
|
@@ -27,8 +27,9 @@ let FieldPathType = class FieldPathType {
|
|
|
27
27
|
const dataType = properties.dataType
|
|
28
28
|
? element.node.getComplexType(properties.dataType)
|
|
29
29
|
: element.node.getComplexType('object');
|
|
30
|
+
const typeName = dataType ? element.node.getDataTypeNameWithNs(dataType) : undefined;
|
|
30
31
|
return {
|
|
31
|
-
dataType:
|
|
32
|
+
dataType: typeName ? typeName : dataType.toJSON(),
|
|
32
33
|
allowSigns: properties.allowSigns,
|
|
33
34
|
};
|
|
34
35
|
}
|
|
@@ -37,17 +38,24 @@ exports.FieldPathType = FieldPathType;
|
|
|
37
38
|
tslib_1.__decorate([
|
|
38
39
|
simple_type_js_1.SimpleType.Attribute({
|
|
39
40
|
description: 'Data type which field belong to',
|
|
40
|
-
})
|
|
41
|
+
}),
|
|
42
|
+
tslib_1.__metadata("design:type", Object)
|
|
41
43
|
], FieldPathType.prototype, "dataType", void 0);
|
|
42
44
|
tslib_1.__decorate([
|
|
43
45
|
simple_type_js_1.SimpleType.Attribute({
|
|
44
46
|
description: 'Determines if signs (+,-) are allowed. ' +
|
|
45
47
|
'If set "first" signs are allowed only beginning of the field path' +
|
|
46
48
|
'If set "each" signs are allowed at each field in the path',
|
|
47
|
-
})
|
|
49
|
+
}),
|
|
50
|
+
tslib_1.__metadata("design:type", String)
|
|
48
51
|
], FieldPathType.prototype, "allowSigns", void 0);
|
|
49
52
|
exports.FieldPathType = FieldPathType = tslib_1.__decorate([
|
|
50
53
|
(0, simple_type_js_1.SimpleType)({
|
|
51
54
|
description: 'Field path',
|
|
52
|
-
|
|
55
|
+
nameMappings: {
|
|
56
|
+
js: 'string',
|
|
57
|
+
json: 'string',
|
|
58
|
+
},
|
|
59
|
+
}),
|
|
60
|
+
tslib_1.__metadata("design:paramtypes", [Object])
|
|
53
61
|
], FieldPathType);
|
|
@@ -36,18 +36,25 @@ exports.FilterType = FilterType;
|
|
|
36
36
|
tslib_1.__decorate([
|
|
37
37
|
simple_type_js_1.SimpleType.Attribute({
|
|
38
38
|
description: 'Data type which filtering fields belong to',
|
|
39
|
-
})
|
|
39
|
+
}),
|
|
40
|
+
tslib_1.__metadata("design:type", Object)
|
|
40
41
|
], FilterType.prototype, "dataType", void 0);
|
|
41
42
|
tslib_1.__decorate([
|
|
42
43
|
simple_type_js_1.SimpleType.Attribute({
|
|
43
44
|
description: 'Stringified JSON object defines filtering rules',
|
|
44
45
|
format: 'string',
|
|
45
|
-
})
|
|
46
|
+
}),
|
|
47
|
+
tslib_1.__metadata("design:type", Object)
|
|
46
48
|
], FilterType.prototype, "rules", void 0);
|
|
47
49
|
exports.FilterType = FilterType = tslib_1.__decorate([
|
|
48
50
|
(0, simple_type_js_1.SimpleType)({
|
|
49
51
|
description: 'A query filter',
|
|
50
|
-
|
|
52
|
+
nameMappings: {
|
|
53
|
+
js: 'object',
|
|
54
|
+
json: 'string',
|
|
55
|
+
},
|
|
56
|
+
}),
|
|
57
|
+
tslib_1.__metadata("design:paramtypes", [Object])
|
|
51
58
|
], FilterType);
|
|
52
59
|
const decodeFilter = (dataType, rules) => {
|
|
53
60
|
return (0, valgen_1.validator)('decodeFilter', function (input, context, _this) {
|
|
@@ -21,5 +21,10 @@ exports.ObjectIdType = ObjectIdType;
|
|
|
21
21
|
exports.ObjectIdType = ObjectIdType = tslib_1.__decorate([
|
|
22
22
|
(0, simple_type_js_1.SimpleType)({
|
|
23
23
|
description: 'A MongoDB ObjectID value',
|
|
24
|
-
|
|
24
|
+
nameMappings: {
|
|
25
|
+
js: 'object',
|
|
26
|
+
json: 'string',
|
|
27
|
+
},
|
|
28
|
+
}),
|
|
29
|
+
tslib_1.__metadata("design:paramtypes", [Object])
|
|
25
30
|
], ObjectIdType);
|
|
@@ -12,30 +12,38 @@ let OperationResult = class OperationResult {
|
|
|
12
12
|
};
|
|
13
13
|
exports.OperationResult = OperationResult;
|
|
14
14
|
tslib_1.__decorate([
|
|
15
|
-
(0, api_field_js_1.ApiField)()
|
|
15
|
+
(0, api_field_js_1.ApiField)(),
|
|
16
|
+
tslib_1.__metadata("design:type", Number)
|
|
16
17
|
], OperationResult.prototype, "affected", void 0);
|
|
17
18
|
tslib_1.__decorate([
|
|
18
|
-
(0, api_field_js_1.ApiField)()
|
|
19
|
+
(0, api_field_js_1.ApiField)(),
|
|
20
|
+
tslib_1.__metadata("design:type", Number)
|
|
19
21
|
], OperationResult.prototype, "totalMatches", void 0);
|
|
20
22
|
tslib_1.__decorate([
|
|
21
|
-
(0, api_field_js_1.ApiField)()
|
|
23
|
+
(0, api_field_js_1.ApiField)(),
|
|
24
|
+
tslib_1.__metadata("design:type", String)
|
|
22
25
|
], OperationResult.prototype, "context", void 0);
|
|
23
26
|
tslib_1.__decorate([
|
|
24
|
-
(0, api_field_js_1.ApiField)()
|
|
27
|
+
(0, api_field_js_1.ApiField)(),
|
|
28
|
+
tslib_1.__metadata("design:type", String)
|
|
25
29
|
], OperationResult.prototype, "type", void 0);
|
|
26
30
|
tslib_1.__decorate([
|
|
27
|
-
(0, api_field_js_1.ApiField)()
|
|
31
|
+
(0, api_field_js_1.ApiField)(),
|
|
32
|
+
tslib_1.__metadata("design:type", String)
|
|
28
33
|
], OperationResult.prototype, "message", void 0);
|
|
29
34
|
tslib_1.__decorate([
|
|
30
|
-
(0, api_field_js_1.ApiField)({ type: 'any' })
|
|
35
|
+
(0, api_field_js_1.ApiField)({ type: 'any' }),
|
|
36
|
+
tslib_1.__metadata("design:type", Object)
|
|
31
37
|
], OperationResult.prototype, "payload", void 0);
|
|
32
38
|
tslib_1.__decorate([
|
|
33
|
-
(0, api_field_js_1.ApiField)({ type: 'object' })
|
|
39
|
+
(0, api_field_js_1.ApiField)({ type: 'object' }),
|
|
40
|
+
tslib_1.__metadata("design:type", Array)
|
|
34
41
|
], OperationResult.prototype, "errors", void 0);
|
|
35
42
|
exports.OperationResult = OperationResult = tslib_1.__decorate([
|
|
36
43
|
(0, complex_type_js_1.ComplexType)({
|
|
37
44
|
description: 'Operation result',
|
|
38
|
-
})
|
|
45
|
+
}),
|
|
46
|
+
tslib_1.__metadata("design:paramtypes", [Object])
|
|
39
47
|
], OperationResult);
|
|
40
48
|
(function (OperationResult) {
|
|
41
49
|
function forPayload(type) {
|
|
@@ -45,10 +53,12 @@ exports.OperationResult = OperationResult = tslib_1.__decorate([
|
|
|
45
53
|
}
|
|
46
54
|
};
|
|
47
55
|
tslib_1.__decorate([
|
|
48
|
-
(0, api_field_js_1.ApiField)({ type, required: true })
|
|
56
|
+
(0, api_field_js_1.ApiField)({ type, required: true }),
|
|
57
|
+
tslib_1.__metadata("design:type", Object)
|
|
49
58
|
], OperationResult_.prototype, "payload", void 0);
|
|
50
59
|
OperationResult_ = tslib_1.__decorate([
|
|
51
|
-
(0, complex_type_js_1.ComplexType)({ embedded: true })
|
|
60
|
+
(0, complex_type_js_1.ComplexType)({ embedded: true }),
|
|
61
|
+
tslib_1.__metadata("design:paramtypes", [Object])
|
|
52
62
|
], OperationResult_);
|
|
53
63
|
return OperationResult_;
|
|
54
64
|
}
|
|
@@ -31,17 +31,24 @@ exports.TimeType = TimeType;
|
|
|
31
31
|
tslib_1.__decorate([
|
|
32
32
|
simple_type_js_1.SimpleType.Attribute({
|
|
33
33
|
description: 'Minimum value',
|
|
34
|
-
})
|
|
34
|
+
}),
|
|
35
|
+
tslib_1.__metadata("design:type", String)
|
|
35
36
|
], TimeType.prototype, "minValue", void 0);
|
|
36
37
|
tslib_1.__decorate([
|
|
37
38
|
simple_type_js_1.SimpleType.Attribute({
|
|
38
39
|
description: 'Maximum value',
|
|
39
|
-
})
|
|
40
|
+
}),
|
|
41
|
+
tslib_1.__metadata("design:type", String)
|
|
40
42
|
], TimeType.prototype, "maxValue", void 0);
|
|
41
43
|
exports.TimeType = TimeType = tslib_1.__decorate([
|
|
42
44
|
(0, simple_type_js_1.SimpleType)({
|
|
43
45
|
description: 'Time string in 24h format',
|
|
46
|
+
nameMappings: {
|
|
47
|
+
js: 'string',
|
|
48
|
+
json: 'string',
|
|
49
|
+
},
|
|
44
50
|
})
|
|
45
51
|
.Example('18:23:00', 'Full time value')
|
|
46
|
-
.Example('18:23:00', 'Time value without seconds')
|
|
52
|
+
.Example('18:23:00', 'Time value without seconds'),
|
|
53
|
+
tslib_1.__metadata("design:paramtypes", [Object])
|
|
47
54
|
], TimeType);
|
|
@@ -21,5 +21,10 @@ exports.UrlType = UrlType;
|
|
|
21
21
|
exports.UrlType = UrlType = tslib_1.__decorate([
|
|
22
22
|
(0, simple_type_js_1.SimpleType)({
|
|
23
23
|
description: 'A Uniform Resource Identifier Reference (RFC 3986 icon) value',
|
|
24
|
-
|
|
24
|
+
nameMappings: {
|
|
25
|
+
js: 'string',
|
|
26
|
+
json: 'string',
|
|
27
|
+
},
|
|
28
|
+
}).Example('http://tempuri.org'),
|
|
29
|
+
tslib_1.__metadata("design:paramtypes", [Object])
|
|
25
30
|
], UrlType);
|
|
@@ -21,10 +21,16 @@ exports.UuidType = UuidType;
|
|
|
21
21
|
tslib_1.__decorate([
|
|
22
22
|
simple_type_js_1.SimpleType.Attribute({
|
|
23
23
|
description: 'Version of the UUID',
|
|
24
|
-
})
|
|
24
|
+
}),
|
|
25
|
+
tslib_1.__metadata("design:type", Number)
|
|
25
26
|
], UuidType.prototype, "version", void 0);
|
|
26
27
|
exports.UuidType = UuidType = tslib_1.__decorate([
|
|
27
28
|
(0, simple_type_js_1.SimpleType)({
|
|
28
29
|
description: 'A Universal Unique Identifier (UUID) value',
|
|
29
|
-
|
|
30
|
+
nameMappings: {
|
|
31
|
+
js: 'string',
|
|
32
|
+
json: 'string',
|
|
33
|
+
},
|
|
34
|
+
}),
|
|
35
|
+
tslib_1.__metadata("design:paramtypes", [Object])
|
|
30
36
|
], UuidType);
|
|
@@ -7,6 +7,7 @@ const index_js_1 = require("../../helpers/index.js");
|
|
|
7
7
|
const index_js_2 = require("../../schema/index.js");
|
|
8
8
|
const api_field_js_1 = require("./api-field.js");
|
|
9
9
|
const complex_type_base_js_1 = require("./complex-type-base.js");
|
|
10
|
+
const data_type_js_1 = require("./data-type.js");
|
|
10
11
|
const get_is_inherited_predicate_fn_js_1 = require("./utils/get-is-inherited-predicate-fn.js");
|
|
11
12
|
/**
|
|
12
13
|
* MappedType constructor
|
|
@@ -68,6 +69,8 @@ exports.MappedType = function (...args) {
|
|
|
68
69
|
*/
|
|
69
70
|
class MappedTypeClass extends complex_type_base_js_1.ComplexTypeBase {
|
|
70
71
|
extendsFrom(baseType) {
|
|
72
|
+
if (!(baseType instanceof data_type_js_1.DataType))
|
|
73
|
+
baseType = this.node.getDataType(baseType);
|
|
71
74
|
if (!(baseType instanceof complex_type_base_js_1.ComplexTypeBase))
|
|
72
75
|
return false;
|
|
73
76
|
if (baseType === this)
|
|
@@ -8,6 +8,7 @@ const index_js_2 = require("../../schema/index.js");
|
|
|
8
8
|
const constants_js_1 = require("../constants.js");
|
|
9
9
|
const api_field_js_1 = require("./api-field.js");
|
|
10
10
|
const complex_type_base_js_1 = require("./complex-type-base.js");
|
|
11
|
+
const data_type_js_1 = require("./data-type.js");
|
|
11
12
|
/**
|
|
12
13
|
* @class MixinType
|
|
13
14
|
*/
|
|
@@ -43,6 +44,8 @@ exports.MixinType = function (...args) {
|
|
|
43
44
|
*/
|
|
44
45
|
class MixinTypeClass extends complex_type_base_js_1.ComplexTypeBase {
|
|
45
46
|
extendsFrom(baseType) {
|
|
47
|
+
if (!(baseType instanceof data_type_js_1.DataType))
|
|
48
|
+
baseType = this.node.getDataType(baseType);
|
|
46
49
|
if (!(baseType instanceof complex_type_base_js_1.ComplexTypeBase))
|
|
47
50
|
return false;
|
|
48
51
|
if (baseType === this)
|
|
@@ -26,5 +26,10 @@ exports.BigintType = BigintType;
|
|
|
26
26
|
exports.BigintType = BigintType = tslib_1.__decorate([
|
|
27
27
|
(0, simple_type_js_1.SimpleType)({
|
|
28
28
|
description: 'BigInt number',
|
|
29
|
-
|
|
29
|
+
nameMappings: {
|
|
30
|
+
js: 'bigint',
|
|
31
|
+
json: 'string',
|
|
32
|
+
},
|
|
33
|
+
}),
|
|
34
|
+
tslib_1.__metadata("design:paramtypes", [Object])
|
|
30
35
|
], BigintType);
|
|
@@ -21,5 +21,10 @@ exports.BooleanType = BooleanType;
|
|
|
21
21
|
exports.BooleanType = BooleanType = tslib_1.__decorate([
|
|
22
22
|
(0, simple_type_js_1.SimpleType)({
|
|
23
23
|
description: 'Simple true/false value',
|
|
24
|
-
|
|
24
|
+
nameMappings: {
|
|
25
|
+
js: 'boolean',
|
|
26
|
+
json: 'boolean',
|
|
27
|
+
},
|
|
28
|
+
}),
|
|
29
|
+
tslib_1.__metadata("design:paramtypes", [Object])
|
|
25
30
|
], BooleanType);
|
|
@@ -26,5 +26,10 @@ exports.IntegerType = IntegerType;
|
|
|
26
26
|
exports.IntegerType = IntegerType = tslib_1.__decorate([
|
|
27
27
|
(0, simple_type_js_1.SimpleType)({
|
|
28
28
|
description: 'An integer number',
|
|
29
|
-
|
|
29
|
+
nameMappings: {
|
|
30
|
+
js: 'number',
|
|
31
|
+
json: 'number',
|
|
32
|
+
},
|
|
33
|
+
}),
|
|
34
|
+
tslib_1.__metadata("design:paramtypes", [Object])
|
|
30
35
|
], IntegerType);
|