@opra/common 0.31.2 → 0.31.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 +144 -106
- 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/field-class.js +2 -3
- package/cjs/document/factory/type-document-factory.js +3 -6
- package/cjs/document/resource/types/operation-result.type.js +2 -1
- package/cjs/document/type-document.js +1 -1
- 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/field-class.js +2 -3
- package/esm/document/factory/type-document-factory.js +4 -7
- package/esm/document/resource/types/operation-result.type.js +2 -1
- package/esm/document/type-document.js +1 -1
- package/package.json +5 -5
- 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
|
@@ -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();
|
|
@@ -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,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 };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import { isNumber } from 'valgen';
|
|
3
3
|
import { SimpleType } from '../simple-type.js';
|
|
4
|
-
|
|
4
|
+
let NumberType = class NumberType {
|
|
5
5
|
};
|
|
6
6
|
NumberType = __decorate([
|
|
7
7
|
SimpleType({
|
|
@@ -10,3 +10,4 @@ NumberType = __decorate([
|
|
|
10
10
|
encoder: isNumber()
|
|
11
11
|
})
|
|
12
12
|
], NumberType);
|
|
13
|
+
export { NumberType };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import { isObjectId, isString, pipe } from 'valgen';
|
|
3
3
|
import { SimpleType } from '../simple-type.js';
|
|
4
|
-
|
|
4
|
+
let ObjectIdType = class ObjectIdType {
|
|
5
5
|
};
|
|
6
6
|
ObjectIdType = __decorate([
|
|
7
7
|
SimpleType({
|
|
@@ -10,3 +10,4 @@ ObjectIdType = __decorate([
|
|
|
10
10
|
encoder: pipe(isObjectId(), isString())
|
|
11
11
|
})
|
|
12
12
|
], ObjectIdType);
|
|
13
|
+
export { ObjectIdType };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import { ComplexType } from '../complex-type.js';
|
|
3
|
-
|
|
3
|
+
let ObjectType = class ObjectType {
|
|
4
4
|
};
|
|
5
5
|
ObjectType = __decorate([
|
|
6
6
|
ComplexType({
|
|
@@ -10,3 +10,4 @@ ObjectType = __decorate([
|
|
|
10
10
|
ctor: Object
|
|
11
11
|
})
|
|
12
12
|
], ObjectType);
|
|
13
|
+
export { ObjectType };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import { isString } from 'valgen';
|
|
3
3
|
import { SimpleType } from '../simple-type.js';
|
|
4
|
-
|
|
4
|
+
let StringType = class StringType {
|
|
5
5
|
};
|
|
6
6
|
StringType = __decorate([
|
|
7
7
|
SimpleType({
|
|
@@ -10,3 +10,4 @@ StringType = __decorate([
|
|
|
10
10
|
encoder: isString(),
|
|
11
11
|
})
|
|
12
12
|
], StringType);
|
|
13
|
+
export { StringType };
|
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
|
-
import {
|
|
2
|
+
import { isMatches } from 'valgen';
|
|
3
3
|
import { SimpleType } from '../simple-type.js';
|
|
4
|
-
|
|
4
|
+
const TIME_PATTERN = /^([0-1][0-9]|2[0-4]):([0-5][0-9])(?::([0-5][0-9]))?$/;
|
|
5
|
+
let TimeType = class TimeType {
|
|
5
6
|
};
|
|
6
7
|
TimeType = __decorate([
|
|
7
8
|
SimpleType({
|
|
8
9
|
description: 'Time string in 24h format, for example, 18:23:00',
|
|
9
|
-
decoder:
|
|
10
|
-
|
|
10
|
+
decoder: isMatches(TIME_PATTERN, {
|
|
11
|
+
formatName: 'time',
|
|
11
12
|
onFail: () => '{{label}} is not a valid time'
|
|
12
13
|
}),
|
|
13
|
-
encoder:
|
|
14
|
+
encoder: isMatches(TIME_PATTERN, {
|
|
15
|
+
formatName: 'time',
|
|
14
16
|
onFail: () => '{{label}} is not a valid time'
|
|
15
17
|
})
|
|
16
18
|
})
|
|
17
19
|
], TimeType);
|
|
20
|
+
export { TimeType };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import { isUUID } from 'valgen';
|
|
3
3
|
import { SimpleType } from '../simple-type.js';
|
|
4
|
-
|
|
4
|
+
let UuidType = class UuidType {
|
|
5
5
|
};
|
|
6
6
|
UuidType = __decorate([
|
|
7
7
|
SimpleType({
|
|
@@ -10,3 +10,4 @@ UuidType = __decorate([
|
|
|
10
10
|
encoder: isUUID()
|
|
11
11
|
})
|
|
12
12
|
], UuidType);
|
|
13
|
+
export { UuidType };
|
|
@@ -5,13 +5,13 @@ export class FieldClass {
|
|
|
5
5
|
this.owner = owner;
|
|
6
6
|
this.origin = init.origin || owner;
|
|
7
7
|
this.type = init.type;
|
|
8
|
+
this.designType = init.designType;
|
|
8
9
|
this.name = init.name;
|
|
9
10
|
this.description = init.description;
|
|
10
11
|
this.isArray = init.isArray;
|
|
11
12
|
this.default = init.default;
|
|
12
13
|
this.fixed = init.fixed;
|
|
13
14
|
this.required = init.required;
|
|
14
|
-
this.nullish = init.nullish;
|
|
15
15
|
this.readonly = init.readonly;
|
|
16
16
|
this.writeonly = init.writeonly;
|
|
17
17
|
this.exclusive = init.exclusive;
|
|
@@ -31,7 +31,6 @@ export class FieldClass {
|
|
|
31
31
|
default: this.default,
|
|
32
32
|
fixed: this.fixed,
|
|
33
33
|
required: this.required,
|
|
34
|
-
nullish: this.nullish,
|
|
35
34
|
readonly: this.readonly,
|
|
36
35
|
writeonly: this.writeonly,
|
|
37
36
|
exclusive: this.exclusive,
|
|
@@ -45,7 +44,7 @@ export class FieldClass {
|
|
|
45
44
|
return vg.isUndefined();
|
|
46
45
|
if (options?.operation === 'write' && this.readonly)
|
|
47
46
|
return vg.isUndefined();
|
|
48
|
-
let fn = this.type.generateCodec(codec, options);
|
|
47
|
+
let fn = this.type.generateCodec(codec, { ...options, designType: this.designType });
|
|
49
48
|
if (this.isArray)
|
|
50
49
|
fn = vg.isArray(fn);
|
|
51
50
|
return !options?.partial && this.required ? vg.required(fn) : vg.optional(fn);
|
|
@@ -2,14 +2,12 @@ import { validator } from 'valgen';
|
|
|
2
2
|
import { cloneObject, isConstructor, resolveThunk, ResponsiveMap } from '../../helpers/index.js';
|
|
3
3
|
import { OpraSchema } from '../../schema/index.js';
|
|
4
4
|
import { DATATYPE_METADATA } from '../constants.js';
|
|
5
|
-
import { AnyType, Base64Type, BigintType, BooleanType, DateType, IntegerType, NullType, NumberType, ObjectIdType, ObjectType, StringType,
|
|
5
|
+
import { AnyType, ApproxDatetimeType, ApproxDateType, Base64Type, BigintType, BooleanType, DatetimeType, DateType, IntegerType, NullType, NumberType, ObjectIdType, ObjectType, StringType, TimeType, UuidType } from '../data-type/builtin/index.js';
|
|
6
6
|
import { ComplexType } from '../data-type/complex-type.js';
|
|
7
7
|
import { EnumType } from '../data-type/enum-type.js';
|
|
8
8
|
import { MappedType } from '../data-type/mapped-type.js';
|
|
9
9
|
import { MixinType } from '../data-type/mixin-type.js';
|
|
10
10
|
import { SimpleType } from '../data-type/simple-type.js';
|
|
11
|
-
import { MetadataMode } from '../resource/enums/metadata-mode.enum.js';
|
|
12
|
-
import { OperationResult } from '../resource/types/operation-result.type.js';
|
|
13
11
|
import { TypeDocument } from '../type-document.js';
|
|
14
12
|
/**
|
|
15
13
|
* @class TypeDocumentFactory
|
|
@@ -96,10 +94,9 @@ export class TypeDocumentFactory {
|
|
|
96
94
|
}
|
|
97
95
|
},
|
|
98
96
|
types: [AnyType, Base64Type, BigintType, BooleanType,
|
|
99
|
-
DateType,
|
|
100
|
-
|
|
101
|
-
TimeType,
|
|
102
|
-
OperationResult, MetadataMode,
|
|
97
|
+
DateType, IntegerType, NullType, NumberType, ObjectIdType,
|
|
98
|
+
ObjectType, ApproxDateType, ApproxDatetimeType,
|
|
99
|
+
StringType, DatetimeType, TimeType, UuidType
|
|
103
100
|
]
|
|
104
101
|
};
|
|
105
102
|
const factory = new TypeDocumentFactory();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import { ComplexType } from '../../data-type/complex-type.js';
|
|
3
3
|
import { ApiField } from '../../data-type/field.js';
|
|
4
|
-
|
|
4
|
+
let OperationResult = class OperationResult {
|
|
5
5
|
constructor(init) {
|
|
6
6
|
if (init)
|
|
7
7
|
Object.assign(this, init);
|
|
@@ -39,3 +39,4 @@ OperationResult = __decorate([
|
|
|
39
39
|
description: 'Operation result'
|
|
40
40
|
})
|
|
41
41
|
], OperationResult);
|
|
42
|
+
export { OperationResult };
|
|
@@ -20,7 +20,7 @@ export class TypeDocument extends DocumentBase {
|
|
|
20
20
|
this._designCtorMap.set(Number, 'number');
|
|
21
21
|
this._designCtorMap.set(Boolean, 'boolean');
|
|
22
22
|
this._designCtorMap.set(Object, 'any');
|
|
23
|
-
this._designCtorMap.set(Date, '
|
|
23
|
+
this._designCtorMap.set(Date, 'datetime');
|
|
24
24
|
this._designCtorMap.set(BigIntConstructor, 'bigint');
|
|
25
25
|
this._designCtorMap.set(ArrayBuffer, 'base64');
|
|
26
26
|
this._designCtorMap.set(SharedArrayBuffer, 'base64');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opra/common",
|
|
3
|
-
"version": "0.31.
|
|
3
|
+
"version": "0.31.4",
|
|
4
4
|
"description": "Opra common package",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"license": "MIT",
|
|
@@ -45,15 +45,15 @@
|
|
|
45
45
|
"putil-varhelpers": "^1.6.5",
|
|
46
46
|
"reflect-metadata": "^0.1.13",
|
|
47
47
|
"uid": "^2.0.1",
|
|
48
|
-
"valgen": "^4.
|
|
48
|
+
"valgen": "^4.2.2"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@browsery/fs": "^0.4.0",
|
|
52
52
|
"@browsery/stream": "^0.6.0",
|
|
53
53
|
"@browsery/util": "^0.4.0",
|
|
54
|
-
"@types/encodeurl": "^1.0.
|
|
55
|
-
"@types/
|
|
56
|
-
"@types/
|
|
54
|
+
"@types/encodeurl": "^1.0.2",
|
|
55
|
+
"@types/lodash.omit": "^4.5.9",
|
|
56
|
+
"@types/validator": "^13.11.6",
|
|
57
57
|
"path-browserify": "^1.0.1",
|
|
58
58
|
"ts-gems": "^2.5.0"
|
|
59
59
|
},
|
|
@@ -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';
|
|
@@ -30,6 +30,7 @@ export declare namespace DataType {
|
|
|
30
30
|
interface InitArguments {
|
|
31
31
|
name?: string;
|
|
32
32
|
description?: string;
|
|
33
|
+
example?: string | string[];
|
|
33
34
|
}
|
|
34
35
|
interface DecoratorOptions extends InitArguments {
|
|
35
36
|
}
|
|
@@ -45,5 +46,6 @@ export declare namespace DataType {
|
|
|
45
46
|
partial?: boolean;
|
|
46
47
|
operation?: 'read' | 'write';
|
|
47
48
|
overwriteFields?: ResponsiveMap<ApiField.InitArguments>;
|
|
49
|
+
designType?: Type;
|
|
48
50
|
}
|
|
49
51
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Type } from 'ts-gems';
|
|
1
2
|
import * as vg from 'valgen';
|
|
2
3
|
import type { OpraSchema } from '../../schema/index.js';
|
|
3
4
|
import type { ComplexType } from './complex-type.js';
|
|
@@ -8,12 +9,12 @@ export declare class FieldClass {
|
|
|
8
9
|
readonly origin?: ComplexType;
|
|
9
10
|
readonly type: DataType;
|
|
10
11
|
readonly name: string;
|
|
12
|
+
readonly designType?: Type;
|
|
11
13
|
description?: string;
|
|
12
14
|
isArray?: boolean;
|
|
13
15
|
default?: any;
|
|
14
16
|
fixed?: string | number | boolean;
|
|
15
17
|
required?: boolean;
|
|
16
|
-
nullish?: boolean;
|
|
17
18
|
readonly?: boolean;
|
|
18
19
|
writeonly?: boolean;
|
|
19
20
|
exclusive?: boolean;
|
|
@@ -28,6 +28,7 @@ export declare namespace ApiField {
|
|
|
28
28
|
interface InitArguments extends StrictOmit<OpraSchema.Field, 'type'> {
|
|
29
29
|
name: string;
|
|
30
30
|
type: DataType;
|
|
31
|
+
designType?: Type;
|
|
31
32
|
origin?: ComplexType;
|
|
32
33
|
}
|
|
33
34
|
interface DecoratorOptions extends Partial<StrictOmit<OpraSchema.Field, 'isArray' | 'type'>> {
|
|
@@ -25,10 +25,6 @@ export type Field = {
|
|
|
25
25
|
* Defines if field value required in create operation
|
|
26
26
|
*/
|
|
27
27
|
required?: boolean;
|
|
28
|
-
/**
|
|
29
|
-
* Defines if field value be nullish (undefined, null or empty)
|
|
30
|
-
*/
|
|
31
|
-
nullish?: boolean;
|
|
32
28
|
/**
|
|
33
29
|
* Defines if the field is readonly
|
|
34
30
|
*/
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TimestampType = 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 TimestampType = exports.TimestampType = class TimestampType {
|
|
8
|
-
};
|
|
9
|
-
exports.TimestampType = TimestampType = tslib_1.__decorate([
|
|
10
|
-
(0, simple_type_js_1.SimpleType)({
|
|
11
|
-
description: 'Timestamp, for example, 2021-04-18T09:12:53',
|
|
12
|
-
decoder: (0, valgen_1.isDate)({
|
|
13
|
-
format: ['YYYY-MM-DDTHH:mm:ss', 'YYYY-MM-DD HH:mm:ss', 'YYYY-MM-DD', 'YYYY']
|
|
14
|
-
}),
|
|
15
|
-
encoder: (0, valgen_1.isDateString)({ format: 'YYYY-MM-DDTHH:mm:ss' })
|
|
16
|
-
})
|
|
17
|
-
], TimestampType);
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { __decorate } from "tslib";
|
|
2
|
-
import { isDate, isDateString } from 'valgen';
|
|
3
|
-
import { SimpleType } from '../simple-type.js';
|
|
4
|
-
export let TimestampType = class TimestampType {
|
|
5
|
-
};
|
|
6
|
-
TimestampType = __decorate([
|
|
7
|
-
SimpleType({
|
|
8
|
-
description: 'Timestamp, for example, 2021-04-18T09:12:53',
|
|
9
|
-
decoder: isDate({
|
|
10
|
-
format: ['YYYY-MM-DDTHH:mm:ss', 'YYYY-MM-DD HH:mm:ss', 'YYYY-MM-DD', 'YYYY']
|
|
11
|
-
}),
|
|
12
|
-
encoder: isDateString({ format: 'YYYY-MM-DDTHH:mm:ss' })
|
|
13
|
-
})
|
|
14
|
-
], TimestampType);
|