@opra/common 1.0.0-alpha.2 → 1.0.0-alpha.3
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 +155 -78
- 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 +1 -1
- package/cjs/document/data-type/complex-type.js +2 -3
- package/cjs/document/data-type/extended-types/base64.type.js +2 -1
- package/cjs/document/data-type/extended-types/date-string.type.js +6 -3
- package/cjs/document/data-type/extended-types/date-time-string.type.js +6 -3
- package/cjs/document/data-type/extended-types/date-time.type.js +6 -3
- package/cjs/document/data-type/extended-types/date.type.js +6 -3
- package/cjs/document/data-type/extended-types/email.type.js +20 -10
- package/cjs/document/data-type/extended-types/field-path.type.js +8 -4
- package/cjs/document/data-type/extended-types/filter.type.js +6 -3
- package/cjs/document/data-type/extended-types/object-id.type.js +2 -1
- package/cjs/document/data-type/extended-types/operation-result.type.js +20 -10
- package/cjs/document/data-type/extended-types/time.type.js +6 -3
- package/cjs/document/data-type/extended-types/url.type.js +2 -1
- package/cjs/document/data-type/extended-types/uuid.type.js +4 -2
- package/cjs/document/data-type/primitive-types/any.type.js +2 -1
- package/cjs/document/data-type/primitive-types/bigint.type.js +2 -1
- package/cjs/document/data-type/primitive-types/boolean.type.js +2 -1
- package/cjs/document/data-type/primitive-types/integer.type.js +2 -1
- package/cjs/document/data-type/primitive-types/null.type.js +2 -1
- package/cjs/document/data-type/primitive-types/number.type.js +6 -3
- package/cjs/document/data-type/primitive-types/object.type.js +2 -1
- package/cjs/document/data-type/primitive-types/string.type.js +10 -5
- package/cjs/document/factory/api-document.factory.js +5 -0
- package/cjs/document/factory/data-type.factory.js +1 -1
- 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 +1 -1
- package/esm/document/data-type/complex-type.js +2 -3
- package/esm/document/data-type/extended-types/base64.type.js +3 -2
- package/esm/document/data-type/extended-types/date-string.type.js +7 -4
- package/esm/document/data-type/extended-types/date-time-string.type.js +7 -4
- package/esm/document/data-type/extended-types/date-time.type.js +7 -4
- package/esm/document/data-type/extended-types/date.type.js +7 -4
- package/esm/document/data-type/extended-types/email.type.js +21 -11
- package/esm/document/data-type/extended-types/field-path.type.js +9 -5
- package/esm/document/data-type/extended-types/filter.type.js +7 -4
- package/esm/document/data-type/extended-types/object-id.type.js +3 -2
- package/esm/document/data-type/extended-types/operation-result.type.js +21 -11
- package/esm/document/data-type/extended-types/time.type.js +7 -4
- package/esm/document/data-type/extended-types/url.type.js +3 -2
- package/esm/document/data-type/extended-types/uuid.type.js +5 -3
- package/esm/document/data-type/primitive-types/any.type.js +3 -2
- package/esm/document/data-type/primitive-types/bigint.type.js +3 -2
- package/esm/document/data-type/primitive-types/boolean.type.js +3 -2
- package/esm/document/data-type/primitive-types/integer.type.js +3 -2
- package/esm/document/data-type/primitive-types/null.type.js +3 -2
- package/esm/document/data-type/primitive-types/number.type.js +7 -4
- package/esm/document/data-type/primitive-types/object.type.js +3 -2
- package/esm/document/data-type/primitive-types/string.type.js +11 -6
- package/esm/document/factory/api-document.factory.js +4 -0
- package/esm/document/factory/data-type.factory.js +1 -1
- package/esm/document/factory/http-api.factory.js +1 -1
- package/package.json +2 -2
- package/types/document/api-document.d.ts +3 -6
- package/types/document/factory/api-document.factory.d.ts +1 -1
- package/types/schema/document.interface.d.ts +13 -1
- package/types/schema/index.d.ts +1 -0
|
@@ -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');
|
|
@@ -46,7 +46,7 @@ class ApiFieldClass extends document_element_js_1.DocumentElement {
|
|
|
46
46
|
toJSON() {
|
|
47
47
|
const typeName = this.type ? this.node.getDataTypeNameWithNs(this.type) : undefined;
|
|
48
48
|
return (0, index_js_1.omitUndefined)({
|
|
49
|
-
type:
|
|
49
|
+
type: typeName ? typeName : this.type?.toJSON(),
|
|
50
50
|
description: this.description,
|
|
51
51
|
isArray: this.isArray,
|
|
52
52
|
default: this.default,
|
|
@@ -75,9 +75,8 @@ class ComplexTypeClass extends complex_type_base_js_1.ComplexTypeBase {
|
|
|
75
75
|
});
|
|
76
76
|
if (this.additionalFields) {
|
|
77
77
|
if (this.additionalFields instanceof data_type_js_1.DataType) {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
: this.additionalFields[1].toJSON();
|
|
78
|
+
const typeName = this.node.getDataTypeNameWithNs(this.additionalFields);
|
|
79
|
+
out.additionalFields = typeName ? typeName : this.additionalFields.toJSON();
|
|
81
80
|
}
|
|
82
81
|
else
|
|
83
82
|
out.additionalFields = this.additionalFields;
|
|
@@ -21,5 +21,6 @@ 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
|
+
}),
|
|
25
|
+
tslib_1.__metadata("design:paramtypes", [Object])
|
|
25
26
|
], Base64Type);
|
|
@@ -27,12 +27,14 @@ 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)({
|
|
@@ -40,5 +42,6 @@ exports.DateStringType = DateStringType = tslib_1.__decorate([
|
|
|
40
42
|
})
|
|
41
43
|
.Example('2021-04-18', 'Full date value')
|
|
42
44
|
.Example('2021-04', 'Date value without day')
|
|
43
|
-
.Example('2021', 'Year only value')
|
|
45
|
+
.Example('2021', 'Year only value'),
|
|
46
|
+
tslib_1.__metadata("design:paramtypes", [Object])
|
|
44
47
|
], DateStringType);
|
|
@@ -27,12 +27,14 @@ 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)({
|
|
@@ -43,5 +45,6 @@ exports.DateTimeStringType = DateTimeStringType = tslib_1.__decorate([
|
|
|
43
45
|
.Example('2021-04-18 22:30', 'Date-time value')
|
|
44
46
|
.Example('2021-04-18', 'Date value')
|
|
45
47
|
.Example('2021-04', 'Date value without day')
|
|
46
|
-
.Example('2021', 'Year only value')
|
|
48
|
+
.Example('2021', 'Year only value'),
|
|
49
|
+
tslib_1.__metadata("design:paramtypes", [Object])
|
|
47
50
|
], DateTimeStringType);
|
|
@@ -41,12 +41,14 @@ 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)({
|
|
@@ -54,5 +56,6 @@ exports.DateTimeType = DateTimeType = tslib_1.__decorate([
|
|
|
54
56
|
})
|
|
55
57
|
.Example('2021-04-18T22:30:15')
|
|
56
58
|
.Example('2021-04-18 22:30:15')
|
|
57
|
-
.Example('2021-04-18 22:30')
|
|
59
|
+
.Example('2021-04-18 22:30'),
|
|
60
|
+
tslib_1.__metadata("design:paramtypes", [Object])
|
|
58
61
|
], DateTimeType);
|
|
@@ -41,15 +41,18 @@ 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
|
-
}).Example('2021-04-18', 'Full date value')
|
|
56
|
+
}).Example('2021-04-18', 'Full date value'),
|
|
57
|
+
tslib_1.__metadata("design:paramtypes", [Object])
|
|
55
58
|
], DateType);
|
|
@@ -22,59 +22,69 @@ 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
|
-
}).Example('some.body@example.com')
|
|
88
|
+
}).Example('some.body@example.com'),
|
|
89
|
+
tslib_1.__metadata("design:paramtypes", [Object])
|
|
80
90
|
], 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,20 @@ 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
|
+
}),
|
|
56
|
+
tslib_1.__metadata("design:paramtypes", [Object])
|
|
53
57
|
], FieldPathType);
|
|
@@ -36,18 +36,21 @@ 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
|
+
}),
|
|
53
|
+
tslib_1.__metadata("design:paramtypes", [Object])
|
|
51
54
|
], FilterType);
|
|
52
55
|
const decodeFilter = (dataType, rules) => {
|
|
53
56
|
return (0, valgen_1.validator)('decodeFilter', function (input, context, _this) {
|
|
@@ -21,5 +21,6 @@ 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
|
+
}),
|
|
25
|
+
tslib_1.__metadata("design:paramtypes", [Object])
|
|
25
26
|
], 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,20 @@ 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',
|
|
44
46
|
})
|
|
45
47
|
.Example('18:23:00', 'Full time value')
|
|
46
|
-
.Example('18:23:00', 'Time value without seconds')
|
|
48
|
+
.Example('18:23:00', 'Time value without seconds'),
|
|
49
|
+
tslib_1.__metadata("design:paramtypes", [Object])
|
|
47
50
|
], TimeType);
|
|
@@ -21,5 +21,6 @@ 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
|
-
}).Example('http://tempuri.org')
|
|
24
|
+
}).Example('http://tempuri.org'),
|
|
25
|
+
tslib_1.__metadata("design:paramtypes", [Object])
|
|
25
26
|
], UrlType);
|
|
@@ -21,10 +21,12 @@ 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
|
+
}),
|
|
31
|
+
tslib_1.__metadata("design:paramtypes", [Object])
|
|
30
32
|
], UuidType);
|
|
@@ -26,15 +26,18 @@ exports.NumberType = NumberType;
|
|
|
26
26
|
tslib_1.__decorate([
|
|
27
27
|
simple_type_js_1.SimpleType.Attribute({
|
|
28
28
|
description: 'Determines the minimum value',
|
|
29
|
-
})
|
|
29
|
+
}),
|
|
30
|
+
tslib_1.__metadata("design:type", Number)
|
|
30
31
|
], NumberType.prototype, "minValue", void 0);
|
|
31
32
|
tslib_1.__decorate([
|
|
32
33
|
simple_type_js_1.SimpleType.Attribute({
|
|
33
34
|
description: 'Determines the maximum value',
|
|
34
|
-
})
|
|
35
|
+
}),
|
|
36
|
+
tslib_1.__metadata("design:type", Number)
|
|
35
37
|
], NumberType.prototype, "maxValue", void 0);
|
|
36
38
|
exports.NumberType = NumberType = tslib_1.__decorate([
|
|
37
39
|
(0, simple_type_js_1.SimpleType)({
|
|
38
40
|
description: 'Both Integer as well as Floating-Point numbers',
|
|
39
|
-
})
|
|
41
|
+
}),
|
|
42
|
+
tslib_1.__metadata("design:paramtypes", [Object])
|
|
40
43
|
], NumberType);
|
|
@@ -16,7 +16,8 @@ exports.ObjectType = ObjectType = tslib_1.__decorate([
|
|
|
16
16
|
name: 'object',
|
|
17
17
|
description: 'A non modelled object',
|
|
18
18
|
additionalFields: true,
|
|
19
|
-
})
|
|
19
|
+
}),
|
|
20
|
+
tslib_1.__metadata("design:paramtypes", [Object])
|
|
20
21
|
], ObjectType);
|
|
21
22
|
const metadata = Reflect.getMetadata(constants_js_1.DATATYPE_METADATA, ObjectType);
|
|
22
23
|
metadata.ctor = Object;
|
|
@@ -34,25 +34,30 @@ exports.StringType = StringType;
|
|
|
34
34
|
tslib_1.__decorate([
|
|
35
35
|
simple_type_js_1.SimpleType.Attribute({
|
|
36
36
|
description: 'Regex pattern to be used for validation',
|
|
37
|
-
})
|
|
37
|
+
}),
|
|
38
|
+
tslib_1.__metadata("design:type", Object)
|
|
38
39
|
], StringType.prototype, "pattern", void 0);
|
|
39
40
|
tslib_1.__decorate([
|
|
40
41
|
simple_type_js_1.SimpleType.Attribute({
|
|
41
42
|
description: 'Name of the pattern',
|
|
42
|
-
})
|
|
43
|
+
}),
|
|
44
|
+
tslib_1.__metadata("design:type", String)
|
|
43
45
|
], StringType.prototype, "patternName", void 0);
|
|
44
46
|
tslib_1.__decorate([
|
|
45
47
|
simple_type_js_1.SimpleType.Attribute({
|
|
46
48
|
description: 'Minimum number of characters',
|
|
47
|
-
})
|
|
49
|
+
}),
|
|
50
|
+
tslib_1.__metadata("design:type", Number)
|
|
48
51
|
], StringType.prototype, "minLength", void 0);
|
|
49
52
|
tslib_1.__decorate([
|
|
50
53
|
simple_type_js_1.SimpleType.Attribute({
|
|
51
54
|
description: 'Minimum number of characters',
|
|
52
|
-
})
|
|
55
|
+
}),
|
|
56
|
+
tslib_1.__metadata("design:type", Number)
|
|
53
57
|
], StringType.prototype, "maxLength", void 0);
|
|
54
58
|
exports.StringType = StringType = tslib_1.__decorate([
|
|
55
59
|
(0, simple_type_js_1.SimpleType)({
|
|
56
60
|
description: 'A sequence of characters',
|
|
57
|
-
})
|
|
61
|
+
}),
|
|
62
|
+
tslib_1.__metadata("design:paramtypes", [Object])
|
|
58
63
|
], StringType);
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ApiDocumentFactory = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const node_crypto_1 = tslib_1.__importDefault(require("node:crypto"));
|
|
6
|
+
const ts_gems_1 = require("ts-gems");
|
|
4
7
|
const index_js_1 = require("../../helpers/index.js");
|
|
5
8
|
const index_js_2 = require("../../schema/index.js");
|
|
6
9
|
const api_document_js_1 = require("../api-document.js");
|
|
@@ -112,6 +115,8 @@ class ApiDocumentFactory {
|
|
|
112
115
|
context.addError(`Unknown service protocol (${init.api.protocol})`);
|
|
113
116
|
});
|
|
114
117
|
}
|
|
118
|
+
const x = document.export();
|
|
119
|
+
(0, ts_gems_1.asMutable)(document).id = node_crypto_1.default.createHash('md5').update(JSON.stringify(x)).digest('base64url');
|
|
115
120
|
}
|
|
116
121
|
/**
|
|
117
122
|
*
|
|
@@ -290,7 +290,7 @@ class DataTypeFactory {
|
|
|
290
290
|
const fieldMeta = typeof v === 'string' ? { type: v } : v;
|
|
291
291
|
if (fieldMeta.isArray && !fieldMeta.type)
|
|
292
292
|
return context.addError(`"type" must be defined explicitly for array fields`);
|
|
293
|
-
const t = await this._importDataTypeArgs(context, owner, fieldMeta.type);
|
|
293
|
+
const t = await this._importDataTypeArgs(context, owner, fieldMeta.type || 'any');
|
|
294
294
|
if (!t)
|
|
295
295
|
return;
|
|
296
296
|
initArgs.fields[k] = {
|
|
@@ -208,7 +208,7 @@ class HttpApiFactory {
|
|
|
208
208
|
});
|
|
209
209
|
}
|
|
210
210
|
if (metadata.requestBody) {
|
|
211
|
-
await context.
|
|
211
|
+
await context.enterAsync('.requestBody', async () => {
|
|
212
212
|
const requestBody = new http_request_body_js_1.HttpRequestBody(operation);
|
|
213
213
|
await this._initHttpRequestBody(context, requestBody, metadata.requestBody);
|
|
214
214
|
operation.requestBody = requestBody;
|
|
@@ -27,18 +27,29 @@ export class ApiDocument extends DocumentElement {
|
|
|
27
27
|
if (dt)
|
|
28
28
|
return this[kTypeNSMap].get(dt);
|
|
29
29
|
}
|
|
30
|
+
findDocument(id) {
|
|
31
|
+
if (this.id === id)
|
|
32
|
+
return this;
|
|
33
|
+
for (const doc of this.references.values()) {
|
|
34
|
+
if (doc.id === id)
|
|
35
|
+
return doc;
|
|
36
|
+
const d = doc.findDocument(id);
|
|
37
|
+
if (d)
|
|
38
|
+
return d;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
30
41
|
toJSON() {
|
|
31
42
|
return this.export();
|
|
32
43
|
}
|
|
33
44
|
/**
|
|
34
45
|
* Export as Opra schema definition object
|
|
35
46
|
*/
|
|
36
|
-
export(
|
|
47
|
+
export() {
|
|
37
48
|
const out = omitUndefined({
|
|
38
49
|
spec: OpraSchema.SpecVersion,
|
|
50
|
+
id: this.id,
|
|
39
51
|
url: this.url,
|
|
40
52
|
info: cloneObject(this.info, true),
|
|
41
|
-
// api: this.api ? this.api.toJSON() : undefined,
|
|
42
53
|
});
|
|
43
54
|
if (this.references.size) {
|
|
44
55
|
let i = 0;
|
|
@@ -46,16 +57,11 @@ export class ApiDocument extends DocumentElement {
|
|
|
46
57
|
for (const [ns, doc] of this.references.entries()) {
|
|
47
58
|
if (doc[BUILTIN])
|
|
48
59
|
continue;
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
else if (options?.references === 'relative-url')
|
|
56
|
-
references[ns] = `/$schema?ns=${ns}`;
|
|
57
|
-
else
|
|
58
|
-
references[ns] = doc.export(options);
|
|
60
|
+
references[ns] = {
|
|
61
|
+
id: doc.id,
|
|
62
|
+
url: doc.url,
|
|
63
|
+
info: cloneObject(doc.info, true),
|
|
64
|
+
};
|
|
59
65
|
i++;
|
|
60
66
|
}
|
|
61
67
|
if (i)
|
|
@@ -20,7 +20,7 @@ export class DataTypeMap {
|
|
|
20
20
|
}
|
|
21
21
|
get(nameOrCtor) {
|
|
22
22
|
let name = typeof nameOrCtor === 'string' ? nameOrCtor : this[kCtorMap].get(nameOrCtor);
|
|
23
|
-
if (!name) {
|
|
23
|
+
if (!name && typeof nameOrCtor === 'function') {
|
|
24
24
|
const metadata = Reflect.getMetadata(DATATYPE_METADATA, nameOrCtor);
|
|
25
25
|
name = metadata?.name;
|
|
26
26
|
}
|
|
@@ -4,7 +4,7 @@ export const DECODER = Symbol.for('opra.type.decoder');
|
|
|
4
4
|
export const ENCODER = Symbol('opra.type.encoder');
|
|
5
5
|
export const DECORATOR = Symbol.for('DECORATOR');
|
|
6
6
|
export const BUILTIN = Symbol.for('BUILTIN');
|
|
7
|
-
export const NAMESPACE_PATTERN = /([a-z$_]\w+)(
|
|
7
|
+
export const NAMESPACE_PATTERN = /([a-z$_]\w+):(.+)/i;
|
|
8
8
|
export const CLASS_NAME_PATTERN = /^[a-z][\w_]*$/i;
|
|
9
9
|
export const EXTRACT_TYPENAME_PATTERN = /^(.*)Type(\d*)$/;
|
|
10
10
|
export const kDataTypeMap = Symbol.for('kDataTypeMap');
|
|
@@ -43,7 +43,7 @@ class ApiFieldClass extends DocumentElement {
|
|
|
43
43
|
toJSON() {
|
|
44
44
|
const typeName = this.type ? this.node.getDataTypeNameWithNs(this.type) : undefined;
|
|
45
45
|
return omitUndefined({
|
|
46
|
-
type:
|
|
46
|
+
type: typeName ? typeName : this.type?.toJSON(),
|
|
47
47
|
description: this.description,
|
|
48
48
|
isArray: this.isArray,
|
|
49
49
|
default: this.default,
|