@opra/common 0.31.2 → 0.31.5
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 +10013 -9976
- package/cjs/document/data-type/builtin/any.type.js +2 -1
- package/cjs/document/data-type/builtin/approx-date.type.js +21 -0
- package/cjs/document/data-type/builtin/approx-datetime.type.js +24 -0
- package/cjs/document/data-type/builtin/base64.type.js +2 -1
- package/cjs/document/data-type/builtin/bigint.type.js +2 -1
- package/cjs/document/data-type/builtin/boolean.type.js +2 -1
- package/cjs/document/data-type/builtin/date.type.js +6 -11
- package/cjs/document/data-type/builtin/datetime.type.js +21 -0
- package/cjs/document/data-type/builtin/index.js +3 -1
- package/cjs/document/data-type/builtin/integer.type.js +2 -1
- package/cjs/document/data-type/builtin/null.type.js +2 -1
- package/cjs/document/data-type/builtin/number.type.js +2 -1
- package/cjs/document/data-type/builtin/object-id.type.js +2 -1
- package/cjs/document/data-type/builtin/object.type.js +2 -1
- package/cjs/document/data-type/builtin/string.type.js +2 -1
- package/cjs/document/data-type/builtin/time.type.js +7 -4
- package/cjs/document/data-type/builtin/uuid.type.js +2 -1
- package/cjs/document/data-type/complex-type-class.js +1 -1
- package/cjs/document/data-type/field-class.js +2 -3
- package/cjs/document/factory/api-document-factory.js +8 -9
- package/cjs/document/factory/type-document-factory.js +3 -6
- package/cjs/document/resource/action.js +3 -1
- package/cjs/document/resource/types/operation-result.type.js +2 -1
- package/cjs/document/type-document.js +1 -1
- package/cjs/exception/resource-errors/resource-not-found.error.js +4 -3
- package/esm/document/data-type/builtin/any.type.js +2 -1
- package/esm/document/data-type/builtin/approx-date.type.js +18 -0
- package/esm/document/data-type/builtin/approx-datetime.type.js +21 -0
- package/esm/document/data-type/builtin/base64.type.js +2 -1
- package/esm/document/data-type/builtin/bigint.type.js +2 -1
- package/esm/document/data-type/builtin/boolean.type.js +2 -1
- package/esm/document/data-type/builtin/date.type.js +6 -11
- package/esm/document/data-type/builtin/datetime.type.js +18 -0
- package/esm/document/data-type/builtin/index.js +3 -1
- package/esm/document/data-type/builtin/integer.type.js +2 -1
- package/esm/document/data-type/builtin/null.type.js +2 -1
- package/esm/document/data-type/builtin/number.type.js +2 -1
- package/esm/document/data-type/builtin/object-id.type.js +2 -1
- package/esm/document/data-type/builtin/object.type.js +2 -1
- package/esm/document/data-type/builtin/string.type.js +2 -1
- package/esm/document/data-type/builtin/time.type.js +8 -5
- package/esm/document/data-type/builtin/uuid.type.js +2 -1
- package/esm/document/data-type/complex-type-class.js +1 -1
- package/esm/document/data-type/field-class.js +2 -3
- package/esm/document/factory/api-document-factory.js +8 -9
- package/esm/document/factory/type-document-factory.js +4 -7
- package/esm/document/resource/action.js +3 -1
- package/esm/document/resource/types/operation-result.type.js +2 -1
- package/esm/document/type-document.js +1 -1
- package/esm/exception/resource-errors/resource-not-found.error.js +2 -1
- package/package.json +10 -9
- package/types/document/data-type/builtin/approx-date.type.d.ts +2 -0
- package/types/document/data-type/builtin/approx-datetime.type.d.ts +2 -0
- package/types/document/data-type/builtin/datetime.type.d.ts +2 -0
- package/types/document/data-type/builtin/index.d.ts +3 -1
- package/types/document/data-type/data-type.d.ts +2 -0
- package/types/document/data-type/field-class.d.ts +2 -1
- package/types/document/data-type/field.d.ts +1 -0
- package/types/schema/data-type/field.interface.d.ts +0 -4
- package/cjs/document/data-type/builtin/timestamp.type.js +0 -17
- package/esm/document/data-type/builtin/timestamp.type.js +0 -14
- package/types/document/data-type/builtin/timestamp.type.d.ts +0 -2
|
@@ -3,8 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.AnyType = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const simple_type_js_1 = require("../simple-type.js");
|
|
6
|
-
let AnyType =
|
|
6
|
+
let AnyType = class AnyType {
|
|
7
7
|
};
|
|
8
|
+
exports.AnyType = AnyType;
|
|
8
9
|
exports.AnyType = AnyType = tslib_1.__decorate([
|
|
9
10
|
(0, simple_type_js_1.SimpleType)({
|
|
10
11
|
description: 'Represents any value'
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ApproxDateType = 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 ApproxDateType = class ApproxDateType {
|
|
8
|
+
};
|
|
9
|
+
exports.ApproxDateType = ApproxDateType;
|
|
10
|
+
exports.ApproxDateType = ApproxDateType = tslib_1.__decorate([
|
|
11
|
+
(0, simple_type_js_1.SimpleType)({
|
|
12
|
+
description: 'An approximate date value',
|
|
13
|
+
example: [
|
|
14
|
+
'2021-04-18',
|
|
15
|
+
'2021-04',
|
|
16
|
+
'2021',
|
|
17
|
+
],
|
|
18
|
+
decoder: (0, valgen_1.isDateString)({ trim: 'date' }),
|
|
19
|
+
encoder: (0, valgen_1.isDateString)({ trim: 'date' })
|
|
20
|
+
})
|
|
21
|
+
], ApproxDateType);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ApproxDatetimeType = 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 ApproxDatetimeType = class ApproxDatetimeType {
|
|
8
|
+
};
|
|
9
|
+
exports.ApproxDatetimeType = ApproxDatetimeType;
|
|
10
|
+
exports.ApproxDatetimeType = ApproxDatetimeType = tslib_1.__decorate([
|
|
11
|
+
(0, simple_type_js_1.SimpleType)({
|
|
12
|
+
description: 'An approximate datetime value.',
|
|
13
|
+
example: [
|
|
14
|
+
'2021-04-18T22:30:15+01:00',
|
|
15
|
+
'2021-04-18T22:30:15',
|
|
16
|
+
'2021-04-18 22:30',
|
|
17
|
+
'2021-04-18',
|
|
18
|
+
'2021-04',
|
|
19
|
+
'2021',
|
|
20
|
+
],
|
|
21
|
+
decoder: (0, valgen_1.isDateString)(),
|
|
22
|
+
encoder: (0, valgen_1.isDateString)()
|
|
23
|
+
})
|
|
24
|
+
], ApproxDatetimeType);
|
|
@@ -4,8 +4,9 @@ exports.Base64Type = void 0;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const valgen_1 = require("valgen");
|
|
6
6
|
const simple_type_js_1 = require("../simple-type.js");
|
|
7
|
-
let Base64Type =
|
|
7
|
+
let Base64Type = class Base64Type {
|
|
8
8
|
};
|
|
9
|
+
exports.Base64Type = Base64Type;
|
|
9
10
|
exports.Base64Type = Base64Type = tslib_1.__decorate([
|
|
10
11
|
(0, simple_type_js_1.SimpleType)({
|
|
11
12
|
description: 'A stream of bytes, base64 encoded',
|
|
@@ -4,8 +4,9 @@ exports.BigintType = void 0;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const valgen_1 = require("valgen");
|
|
6
6
|
const simple_type_js_1 = require("../simple-type.js");
|
|
7
|
-
let BigintType =
|
|
7
|
+
let BigintType = class BigintType {
|
|
8
8
|
};
|
|
9
|
+
exports.BigintType = BigintType;
|
|
9
10
|
exports.BigintType = BigintType = tslib_1.__decorate([
|
|
10
11
|
(0, simple_type_js_1.SimpleType)({
|
|
11
12
|
description: 'BigInt number',
|
|
@@ -4,8 +4,9 @@ exports.BooleanType = void 0;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const valgen_1 = require("valgen");
|
|
6
6
|
const simple_type_js_1 = require("../simple-type.js");
|
|
7
|
-
let BooleanType =
|
|
7
|
+
let BooleanType = class BooleanType {
|
|
8
8
|
};
|
|
9
|
+
exports.BooleanType = BooleanType;
|
|
9
10
|
exports.BooleanType = BooleanType = tslib_1.__decorate([
|
|
10
11
|
(0, simple_type_js_1.SimpleType)({
|
|
11
12
|
description: 'Simple true/false value',
|
|
@@ -4,19 +4,14 @@ exports.DateType = void 0;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const valgen_1 = require("valgen");
|
|
6
6
|
const simple_type_js_1 = require("../simple-type.js");
|
|
7
|
-
let DateType =
|
|
7
|
+
let DateType = class DateType {
|
|
8
8
|
};
|
|
9
|
+
exports.DateType = DateType;
|
|
9
10
|
exports.DateType = DateType = tslib_1.__decorate([
|
|
10
11
|
(0, simple_type_js_1.SimpleType)({
|
|
11
|
-
description: '
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
'YYYY-MM-DDTHH:mm',
|
|
16
|
-
'YYYY-MM-DD HH:mm:ss',
|
|
17
|
-
'YYYY-MM-DD HH:mm'
|
|
18
|
-
]
|
|
19
|
-
}),
|
|
20
|
-
encoder: (0, valgen_1.isDateString)({ format: 'YYYY-MM-DD' })
|
|
12
|
+
description: 'A date without time',
|
|
13
|
+
example: ['2021-04-18'],
|
|
14
|
+
decoder: (0, valgen_1.isDate)({ precision: 'date' }),
|
|
15
|
+
encoder: (0, valgen_1.isDateString)({ precision: 'date', trim: 'date' })
|
|
21
16
|
})
|
|
22
17
|
], DateType);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DatetimeType = 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 DatetimeType = class DatetimeType {
|
|
8
|
+
};
|
|
9
|
+
exports.DatetimeType = DatetimeType;
|
|
10
|
+
exports.DatetimeType = DatetimeType = tslib_1.__decorate([
|
|
11
|
+
(0, simple_type_js_1.SimpleType)({
|
|
12
|
+
description: 'A full datetime value',
|
|
13
|
+
example: [
|
|
14
|
+
'2021-04-18T22:30:15',
|
|
15
|
+
'2021-04-18 22:30:15',
|
|
16
|
+
'2021-04-18 22:30'
|
|
17
|
+
],
|
|
18
|
+
decoder: (0, valgen_1.isDate)({ precision: 'time' }),
|
|
19
|
+
encoder: (0, valgen_1.isDateString)({ precision: 'time', trim: 'time' })
|
|
20
|
+
})
|
|
21
|
+
], DatetimeType);
|
|
@@ -2,10 +2,13 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
tslib_1.__exportStar(require("./any.type.js"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./approx-date.type.js"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./approx-datetime.type.js"), exports);
|
|
5
7
|
tslib_1.__exportStar(require("./base64.type.js"), exports);
|
|
6
8
|
tslib_1.__exportStar(require("./bigint.type.js"), exports);
|
|
7
9
|
tslib_1.__exportStar(require("./boolean.type.js"), exports);
|
|
8
10
|
tslib_1.__exportStar(require("./date.type.js"), exports);
|
|
11
|
+
tslib_1.__exportStar(require("./datetime.type.js"), exports);
|
|
9
12
|
tslib_1.__exportStar(require("./uuid.type.js"), exports);
|
|
10
13
|
tslib_1.__exportStar(require("./integer.type.js"), exports);
|
|
11
14
|
tslib_1.__exportStar(require("./null.type.js"), exports);
|
|
@@ -14,4 +17,3 @@ tslib_1.__exportStar(require("./object.type.js"), exports);
|
|
|
14
17
|
tslib_1.__exportStar(require("./object-id.type.js"), exports);
|
|
15
18
|
tslib_1.__exportStar(require("./string.type.js"), exports);
|
|
16
19
|
tslib_1.__exportStar(require("./time.type.js"), exports);
|
|
17
|
-
tslib_1.__exportStar(require("./timestamp.type.js"), exports);
|
|
@@ -4,8 +4,9 @@ exports.IntegerType = void 0;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const valgen_1 = require("valgen");
|
|
6
6
|
const simple_type_js_1 = require("../simple-type.js");
|
|
7
|
-
let IntegerType =
|
|
7
|
+
let IntegerType = class IntegerType {
|
|
8
8
|
};
|
|
9
|
+
exports.IntegerType = IntegerType;
|
|
9
10
|
exports.IntegerType = IntegerType = tslib_1.__decorate([
|
|
10
11
|
(0, simple_type_js_1.SimpleType)({
|
|
11
12
|
description: 'An integer number',
|
|
@@ -4,8 +4,9 @@ exports.NullType = void 0;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const valgen_1 = require("valgen");
|
|
6
6
|
const simple_type_js_1 = require("../simple-type.js");
|
|
7
|
-
let NullType =
|
|
7
|
+
let NullType = class NullType {
|
|
8
8
|
};
|
|
9
|
+
exports.NullType = NullType;
|
|
9
10
|
exports.NullType = NullType = tslib_1.__decorate([
|
|
10
11
|
(0, simple_type_js_1.SimpleType)({
|
|
11
12
|
description: 'A Null value',
|
|
@@ -4,8 +4,9 @@ exports.NumberType = void 0;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const valgen_1 = require("valgen");
|
|
6
6
|
const simple_type_js_1 = require("../simple-type.js");
|
|
7
|
-
let NumberType =
|
|
7
|
+
let NumberType = class NumberType {
|
|
8
8
|
};
|
|
9
|
+
exports.NumberType = NumberType;
|
|
9
10
|
exports.NumberType = NumberType = tslib_1.__decorate([
|
|
10
11
|
(0, simple_type_js_1.SimpleType)({
|
|
11
12
|
description: 'Both Integer as well as Floating-Point numbers',
|
|
@@ -4,8 +4,9 @@ exports.ObjectIdType = void 0;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const valgen_1 = require("valgen");
|
|
6
6
|
const simple_type_js_1 = require("../simple-type.js");
|
|
7
|
-
let ObjectIdType =
|
|
7
|
+
let ObjectIdType = class ObjectIdType {
|
|
8
8
|
};
|
|
9
|
+
exports.ObjectIdType = ObjectIdType;
|
|
9
10
|
exports.ObjectIdType = ObjectIdType = tslib_1.__decorate([
|
|
10
11
|
(0, simple_type_js_1.SimpleType)({
|
|
11
12
|
description: 'A MongoDB ObjectID value',
|
|
@@ -3,8 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ObjectType = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const complex_type_js_1 = require("../complex-type.js");
|
|
6
|
-
let ObjectType =
|
|
6
|
+
let ObjectType = class ObjectType {
|
|
7
7
|
};
|
|
8
|
+
exports.ObjectType = ObjectType;
|
|
8
9
|
exports.ObjectType = ObjectType = tslib_1.__decorate([
|
|
9
10
|
(0, complex_type_js_1.ComplexType)({
|
|
10
11
|
name: 'object',
|
|
@@ -4,8 +4,9 @@ exports.StringType = void 0;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const valgen_1 = require("valgen");
|
|
6
6
|
const simple_type_js_1 = require("../simple-type.js");
|
|
7
|
-
let StringType =
|
|
7
|
+
let StringType = class StringType {
|
|
8
8
|
};
|
|
9
|
+
exports.StringType = StringType;
|
|
9
10
|
exports.StringType = StringType = tslib_1.__decorate([
|
|
10
11
|
(0, simple_type_js_1.SimpleType)({
|
|
11
12
|
description: 'A sequence of characters',
|
|
@@ -4,16 +4,19 @@ exports.TimeType = void 0;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const valgen_1 = require("valgen");
|
|
6
6
|
const simple_type_js_1 = require("../simple-type.js");
|
|
7
|
-
|
|
7
|
+
const TIME_PATTERN = /^([0-1][0-9]|2[0-4]):([0-5][0-9])(?::([0-5][0-9]))?$/;
|
|
8
|
+
let TimeType = class TimeType {
|
|
8
9
|
};
|
|
10
|
+
exports.TimeType = TimeType;
|
|
9
11
|
exports.TimeType = TimeType = tslib_1.__decorate([
|
|
10
12
|
(0, simple_type_js_1.SimpleType)({
|
|
11
13
|
description: 'Time string in 24h format, for example, 18:23:00',
|
|
12
|
-
decoder: (0, valgen_1.
|
|
13
|
-
|
|
14
|
+
decoder: (0, valgen_1.isMatches)(TIME_PATTERN, {
|
|
15
|
+
formatName: 'time',
|
|
14
16
|
onFail: () => '{{label}} is not a valid time'
|
|
15
17
|
}),
|
|
16
|
-
encoder: (0, valgen_1.
|
|
18
|
+
encoder: (0, valgen_1.isMatches)(TIME_PATTERN, {
|
|
19
|
+
formatName: 'time',
|
|
17
20
|
onFail: () => '{{label}} is not a valid time'
|
|
18
21
|
})
|
|
19
22
|
})
|
|
@@ -4,8 +4,9 @@ exports.UuidType = void 0;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const valgen_1 = require("valgen");
|
|
6
6
|
const simple_type_js_1 = require("../simple-type.js");
|
|
7
|
-
let UuidType =
|
|
7
|
+
let UuidType = class UuidType {
|
|
8
8
|
};
|
|
9
|
+
exports.UuidType = UuidType;
|
|
9
10
|
exports.UuidType = UuidType = tslib_1.__decorate([
|
|
10
11
|
(0, simple_type_js_1.SimpleType)({
|
|
11
12
|
description: 'A Universal Unique Identifier (UUID) value',
|
|
@@ -180,7 +180,7 @@ class ComplexTypeClass extends data_type_js_1.DataType {
|
|
|
180
180
|
const omitOption = (options?.omit || []).map(x => x.toLowerCase());
|
|
181
181
|
const dedupedFieldNames = (options?.overwriteFields
|
|
182
182
|
? Array.from(new Set([...this.fields.keys(), ...options?.overwriteFields.keys()]))
|
|
183
|
-
: Array.from(this.fields.keys())).map(x => x.
|
|
183
|
+
: Array.from(this.fields.keys())).map(x => x.toLowerCase());
|
|
184
184
|
for (const nameLower of dedupedFieldNames) {
|
|
185
185
|
const overwriteField = options?.overwriteFields?.get(nameLower);
|
|
186
186
|
const field = this.fields.get(nameLower);
|
|
@@ -9,13 +9,13 @@ class FieldClass {
|
|
|
9
9
|
this.owner = owner;
|
|
10
10
|
this.origin = init.origin || owner;
|
|
11
11
|
this.type = init.type;
|
|
12
|
+
this.designType = init.designType;
|
|
12
13
|
this.name = init.name;
|
|
13
14
|
this.description = init.description;
|
|
14
15
|
this.isArray = init.isArray;
|
|
15
16
|
this.default = init.default;
|
|
16
17
|
this.fixed = init.fixed;
|
|
17
18
|
this.required = init.required;
|
|
18
|
-
this.nullish = init.nullish;
|
|
19
19
|
this.readonly = init.readonly;
|
|
20
20
|
this.writeonly = init.writeonly;
|
|
21
21
|
this.exclusive = init.exclusive;
|
|
@@ -35,7 +35,6 @@ class FieldClass {
|
|
|
35
35
|
default: this.default,
|
|
36
36
|
fixed: this.fixed,
|
|
37
37
|
required: this.required,
|
|
38
|
-
nullish: this.nullish,
|
|
39
38
|
readonly: this.readonly,
|
|
40
39
|
writeonly: this.writeonly,
|
|
41
40
|
exclusive: this.exclusive,
|
|
@@ -49,7 +48,7 @@ class FieldClass {
|
|
|
49
48
|
return vg.isUndefined();
|
|
50
49
|
if (options?.operation === 'write' && this.readonly)
|
|
51
50
|
return vg.isUndefined();
|
|
52
|
-
let fn = this.type.generateCodec(codec, options);
|
|
51
|
+
let fn = this.type.generateCodec(codec, { ...options, designType: this.designType });
|
|
53
52
|
if (this.isArray)
|
|
54
53
|
fn = vg.isArray(fn);
|
|
55
54
|
return !options?.partial && this.required ? vg.required(fn) : vg.optional(fn);
|
|
@@ -70,19 +70,19 @@ class ApiDocumentFactory extends type_document_factory_js_1.TypeDocumentFactory
|
|
|
70
70
|
if (!source)
|
|
71
71
|
return;
|
|
72
72
|
const output = {};
|
|
73
|
-
for (const [
|
|
73
|
+
for (const [endpointName, endpointSchema] of Object.entries(source)) {
|
|
74
74
|
/* istanbul ignore next */
|
|
75
|
-
if (!
|
|
75
|
+
if (!endpointSchema)
|
|
76
76
|
continue;
|
|
77
|
-
const
|
|
77
|
+
const outputEndpoint = output[endpointName] = { ...endpointSchema };
|
|
78
78
|
let parameters;
|
|
79
79
|
// Resolve lazy type
|
|
80
|
-
if (
|
|
81
|
-
|
|
80
|
+
if (endpointSchema.returnType) {
|
|
81
|
+
outputEndpoint.returnType = await this.importDataType(endpointSchema.returnType);
|
|
82
82
|
}
|
|
83
|
-
if (
|
|
84
|
-
parameters =
|
|
85
|
-
for (const [kP, oP] of Object.entries(
|
|
83
|
+
if (endpointSchema.parameters) {
|
|
84
|
+
parameters = outputEndpoint.parameters = {};
|
|
85
|
+
for (const [kP, oP] of Object.entries(endpointSchema.parameters)) {
|
|
86
86
|
if (oP.enum) {
|
|
87
87
|
oP.type = (0, enum_type_js_1.EnumType)(oP.enum, { name: kP + 'Enum' });
|
|
88
88
|
}
|
|
@@ -92,7 +92,6 @@ class ApiDocumentFactory extends type_document_factory_js_1.TypeDocumentFactory
|
|
|
92
92
|
};
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
|
-
output[kA] = { ...oA[kA], parameters };
|
|
96
95
|
}
|
|
97
96
|
return output;
|
|
98
97
|
};
|
|
@@ -11,8 +11,6 @@ const enum_type_js_1 = require("../data-type/enum-type.js");
|
|
|
11
11
|
const mapped_type_js_1 = require("../data-type/mapped-type.js");
|
|
12
12
|
const mixin_type_js_1 = require("../data-type/mixin-type.js");
|
|
13
13
|
const simple_type_js_1 = require("../data-type/simple-type.js");
|
|
14
|
-
const metadata_mode_enum_js_1 = require("../resource/enums/metadata-mode.enum.js");
|
|
15
|
-
const operation_result_type_js_1 = require("../resource/types/operation-result.type.js");
|
|
16
14
|
const type_document_js_1 = require("../type-document.js");
|
|
17
15
|
/**
|
|
18
16
|
* @class TypeDocumentFactory
|
|
@@ -99,10 +97,9 @@ class TypeDocumentFactory {
|
|
|
99
97
|
}
|
|
100
98
|
},
|
|
101
99
|
types: [index_js_3.AnyType, index_js_3.Base64Type, index_js_3.BigintType, index_js_3.BooleanType,
|
|
102
|
-
index_js_3.DateType, index_js_3.
|
|
103
|
-
index_js_3.
|
|
104
|
-
index_js_3.TimeType, index_js_3.
|
|
105
|
-
operation_result_type_js_1.OperationResult, metadata_mode_enum_js_1.MetadataMode,
|
|
100
|
+
index_js_3.DateType, index_js_3.IntegerType, index_js_3.NullType, index_js_3.NumberType, index_js_3.ObjectIdType,
|
|
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
|
|
106
103
|
]
|
|
107
104
|
};
|
|
108
105
|
const factory = new TypeDocumentFactory();
|
|
@@ -24,7 +24,9 @@ class Action extends endpoint_js_1.Endpoint {
|
|
|
24
24
|
exportSchema(options) {
|
|
25
25
|
const schema = super.exportSchema(options);
|
|
26
26
|
if (this.returnType)
|
|
27
|
-
schema.returnType = this.returnType.
|
|
27
|
+
schema.returnType = this.returnType.isAnonymous
|
|
28
|
+
? this.returnType.exportSchema(options)
|
|
29
|
+
: this.returnType.name;
|
|
28
30
|
if (this.returnMime)
|
|
29
31
|
schema.returnMime = this.returnMime;
|
|
30
32
|
return schema;
|
|
@@ -4,12 +4,13 @@ exports.OperationResult = void 0;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const complex_type_js_1 = require("../../data-type/complex-type.js");
|
|
6
6
|
const field_js_1 = require("../../data-type/field.js");
|
|
7
|
-
let OperationResult =
|
|
7
|
+
let OperationResult = class OperationResult {
|
|
8
8
|
constructor(init) {
|
|
9
9
|
if (init)
|
|
10
10
|
Object.assign(this, init);
|
|
11
11
|
}
|
|
12
12
|
};
|
|
13
|
+
exports.OperationResult = OperationResult;
|
|
13
14
|
tslib_1.__decorate([
|
|
14
15
|
(0, field_js_1.ApiField)()
|
|
15
16
|
], OperationResult.prototype, "context", void 0);
|
|
@@ -23,7 +23,7 @@ class TypeDocument extends document_base_js_1.DocumentBase {
|
|
|
23
23
|
this._designCtorMap.set(Number, 'number');
|
|
24
24
|
this._designCtorMap.set(Boolean, 'boolean');
|
|
25
25
|
this._designCtorMap.set(Object, 'any');
|
|
26
|
-
this._designCtorMap.set(Date, '
|
|
26
|
+
this._designCtorMap.set(Date, 'datetime');
|
|
27
27
|
this._designCtorMap.set(BigIntConstructor, 'bigint');
|
|
28
28
|
this._designCtorMap.set(ArrayBuffer, 'base64');
|
|
29
29
|
this._designCtorMap.set(SharedArrayBuffer, 'base64');
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ResourceNotFoundError = void 0;
|
|
4
|
-
const index_js_1 = require("../../
|
|
4
|
+
const index_js_1 = require("../../http/index.js");
|
|
5
|
+
const index_js_2 = require("../../i18n/index.js");
|
|
5
6
|
const opra_exception_js_1 = require("../opra-exception.js");
|
|
6
7
|
/**
|
|
7
8
|
* The server cannot find the requested resource.
|
|
@@ -10,14 +11,14 @@ const opra_exception_js_1 = require("../opra-exception.js");
|
|
|
10
11
|
class ResourceNotFoundError extends opra_exception_js_1.OpraException {
|
|
11
12
|
constructor(resource, keyValue, cause) {
|
|
12
13
|
super({
|
|
13
|
-
message: (0,
|
|
14
|
+
message: (0, index_js_2.translate)(`error:RESOURCE_NOT_FOUND`, `Resource not found`),
|
|
14
15
|
severity: 'error',
|
|
15
16
|
code: 'RESOURCE_NOT_FOUND',
|
|
16
17
|
details: {
|
|
17
18
|
resource,
|
|
18
19
|
key: keyValue
|
|
19
20
|
}
|
|
20
|
-
}, cause,
|
|
21
|
+
}, cause, index_js_1.HttpStatusCodes.UNPROCESSABLE_ENTITY);
|
|
21
22
|
}
|
|
22
23
|
}
|
|
23
24
|
exports.ResourceNotFoundError = ResourceNotFoundError;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import { SimpleType } from '../simple-type.js';
|
|
3
|
-
|
|
3
|
+
let AnyType = class AnyType {
|
|
4
4
|
};
|
|
5
5
|
AnyType = __decorate([
|
|
6
6
|
SimpleType({
|
|
7
7
|
description: 'Represents any value'
|
|
8
8
|
})
|
|
9
9
|
], AnyType);
|
|
10
|
+
export { AnyType };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { isDateString } from 'valgen';
|
|
3
|
+
import { SimpleType } from '../simple-type.js';
|
|
4
|
+
let ApproxDateType = class ApproxDateType {
|
|
5
|
+
};
|
|
6
|
+
ApproxDateType = __decorate([
|
|
7
|
+
SimpleType({
|
|
8
|
+
description: 'An approximate date value',
|
|
9
|
+
example: [
|
|
10
|
+
'2021-04-18',
|
|
11
|
+
'2021-04',
|
|
12
|
+
'2021',
|
|
13
|
+
],
|
|
14
|
+
decoder: isDateString({ trim: 'date' }),
|
|
15
|
+
encoder: isDateString({ trim: 'date' })
|
|
16
|
+
})
|
|
17
|
+
], ApproxDateType);
|
|
18
|
+
export { ApproxDateType };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { isDateString } from 'valgen';
|
|
3
|
+
import { SimpleType } from '../simple-type.js';
|
|
4
|
+
let ApproxDatetimeType = class ApproxDatetimeType {
|
|
5
|
+
};
|
|
6
|
+
ApproxDatetimeType = __decorate([
|
|
7
|
+
SimpleType({
|
|
8
|
+
description: 'An approximate datetime value.',
|
|
9
|
+
example: [
|
|
10
|
+
'2021-04-18T22:30:15+01:00',
|
|
11
|
+
'2021-04-18T22:30:15',
|
|
12
|
+
'2021-04-18 22:30',
|
|
13
|
+
'2021-04-18',
|
|
14
|
+
'2021-04',
|
|
15
|
+
'2021',
|
|
16
|
+
],
|
|
17
|
+
decoder: isDateString(),
|
|
18
|
+
encoder: isDateString()
|
|
19
|
+
})
|
|
20
|
+
], ApproxDatetimeType);
|
|
21
|
+
export { ApproxDatetimeType };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import { isBase64 } from 'valgen';
|
|
3
3
|
import { SimpleType } from '../simple-type.js';
|
|
4
|
-
|
|
4
|
+
let Base64Type = class Base64Type {
|
|
5
5
|
};
|
|
6
6
|
Base64Type = __decorate([
|
|
7
7
|
SimpleType({
|
|
@@ -10,3 +10,4 @@ Base64Type = __decorate([
|
|
|
10
10
|
encoder: isBase64(),
|
|
11
11
|
})
|
|
12
12
|
], Base64Type);
|
|
13
|
+
export { Base64Type };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import { isBigint, isString, pipe } 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({
|
|
@@ -10,3 +10,4 @@ BigintType = __decorate([
|
|
|
10
10
|
encoder: pipe(isBigint(), isString())
|
|
11
11
|
})
|
|
12
12
|
], BigintType);
|
|
13
|
+
export { BigintType };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import { isBoolean } from 'valgen';
|
|
3
3
|
import { SimpleType } from '../simple-type.js';
|
|
4
|
-
|
|
4
|
+
let BooleanType = class BooleanType {
|
|
5
5
|
};
|
|
6
6
|
BooleanType = __decorate([
|
|
7
7
|
SimpleType({
|
|
@@ -10,3 +10,4 @@ BooleanType = __decorate([
|
|
|
10
10
|
encoder: isBoolean()
|
|
11
11
|
})
|
|
12
12
|
], BooleanType);
|
|
13
|
+
export { BooleanType };
|
|
@@ -1,19 +1,14 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import { isDate, isDateString } from 'valgen';
|
|
3
3
|
import { SimpleType } from '../simple-type.js';
|
|
4
|
-
|
|
4
|
+
let DateType = class DateType {
|
|
5
5
|
};
|
|
6
6
|
DateType = __decorate([
|
|
7
7
|
SimpleType({
|
|
8
|
-
description: '
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
'YYYY-MM-DDTHH:mm',
|
|
13
|
-
'YYYY-MM-DD HH:mm:ss',
|
|
14
|
-
'YYYY-MM-DD HH:mm'
|
|
15
|
-
]
|
|
16
|
-
}),
|
|
17
|
-
encoder: isDateString({ format: 'YYYY-MM-DD' })
|
|
8
|
+
description: 'A date without time',
|
|
9
|
+
example: ['2021-04-18'],
|
|
10
|
+
decoder: isDate({ precision: 'date' }),
|
|
11
|
+
encoder: isDateString({ precision: 'date', trim: 'date' })
|
|
18
12
|
})
|
|
19
13
|
], DateType);
|
|
14
|
+
export { DateType };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { isDate, isDateString } from 'valgen';
|
|
3
|
+
import { SimpleType } from '../simple-type.js';
|
|
4
|
+
let DatetimeType = class DatetimeType {
|
|
5
|
+
};
|
|
6
|
+
DatetimeType = __decorate([
|
|
7
|
+
SimpleType({
|
|
8
|
+
description: 'A full datetime value',
|
|
9
|
+
example: [
|
|
10
|
+
'2021-04-18T22:30:15',
|
|
11
|
+
'2021-04-18 22:30:15',
|
|
12
|
+
'2021-04-18 22:30'
|
|
13
|
+
],
|
|
14
|
+
decoder: isDate({ precision: 'time' }),
|
|
15
|
+
encoder: isDateString({ precision: 'time', trim: 'time' })
|
|
16
|
+
})
|
|
17
|
+
], DatetimeType);
|
|
18
|
+
export { DatetimeType };
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
export * from './any.type.js';
|
|
2
|
+
export * from './approx-date.type.js';
|
|
3
|
+
export * from './approx-datetime.type.js';
|
|
2
4
|
export * from './base64.type.js';
|
|
3
5
|
export * from './bigint.type.js';
|
|
4
6
|
export * from './boolean.type.js';
|
|
5
7
|
export * from './date.type.js';
|
|
8
|
+
export * from './datetime.type.js';
|
|
6
9
|
export * from './uuid.type.js';
|
|
7
10
|
export * from './integer.type.js';
|
|
8
11
|
export * from './null.type.js';
|
|
@@ -11,4 +14,3 @@ export * from './object.type.js';
|
|
|
11
14
|
export * from './object-id.type.js';
|
|
12
15
|
export * from './string.type.js';
|
|
13
16
|
export * from './time.type.js';
|
|
14
|
-
export * from './timestamp.type.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import { isInteger } from 'valgen';
|
|
3
3
|
import { SimpleType } from '../simple-type.js';
|
|
4
|
-
|
|
4
|
+
let IntegerType = class IntegerType {
|
|
5
5
|
};
|
|
6
6
|
IntegerType = __decorate([
|
|
7
7
|
SimpleType({
|
|
@@ -10,3 +10,4 @@ IntegerType = __decorate([
|
|
|
10
10
|
encoder: isInteger()
|
|
11
11
|
})
|
|
12
12
|
], IntegerType);
|
|
13
|
+
export { IntegerType };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import { isNull } from 'valgen';
|
|
3
3
|
import { SimpleType } from '../simple-type.js';
|
|
4
|
-
|
|
4
|
+
let NullType = class NullType {
|
|
5
5
|
};
|
|
6
6
|
NullType = __decorate([
|
|
7
7
|
SimpleType({
|
|
@@ -10,3 +10,4 @@ NullType = __decorate([
|
|
|
10
10
|
encoder: isNull()
|
|
11
11
|
})
|
|
12
12
|
], NullType);
|
|
13
|
+
export { NullType };
|