@opra/common 1.17.7 → 1.19.0
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/index.cjs +5 -5
- package/browser/index.mjs +5 -5
- package/cjs/document/data-type/api-field.js +11 -5
- package/cjs/document/data-type/complex-type-base.js +2 -0
- package/cjs/document/data-type/extended-types/base64.type.js +16 -3
- package/cjs/document/data-type/extended-types/date-time-tz.type.js +71 -0
- package/cjs/document/data-type/extended-types/date-time.type.js +13 -9
- package/cjs/document/data-type/extended-types/date.type.js +14 -9
- package/cjs/document/data-type/extended-types/index.js +2 -2
- package/cjs/document/data-type/extended-types/partial-date.type.js +85 -0
- package/cjs/document/data-type/simple-type.js +4 -0
- package/cjs/document/decorators/api-field-decorator.js +1 -0
- package/cjs/document/factory/api-document.factory.js +5 -25
- package/cjs/document/factory/data-type.factory.js +1 -0
- package/cjs/filter/filter-rules.js +1 -1
- package/esm/document/data-type/api-field.js +11 -5
- package/esm/document/data-type/complex-type-base.js +2 -0
- package/esm/document/data-type/extended-types/base64.type.js +17 -4
- package/esm/document/data-type/extended-types/date-time-tz.type.js +68 -0
- package/esm/document/data-type/extended-types/date-time.type.js +13 -9
- package/esm/document/data-type/extended-types/date.type.js +14 -9
- package/esm/document/data-type/extended-types/index.js +2 -2
- package/esm/document/data-type/extended-types/partial-date.type.js +82 -0
- package/esm/document/data-type/simple-type.js +4 -0
- package/esm/document/decorators/api-field-decorator.js +1 -0
- package/esm/document/factory/api-document.factory.js +4 -25
- package/esm/document/factory/data-type.factory.js +1 -0
- package/esm/filter/filter-rules.js +1 -1
- package/package.json +3 -3
- package/types/document/data-type/api-field.d.ts +8 -0
- package/types/document/data-type/data-type.d.ts +1 -1
- package/types/document/data-type/extended-types/base64.type.d.ts +2 -1
- package/types/document/data-type/extended-types/{date-string.type.d.ts → date-time-tz.type.d.ts} +2 -2
- package/types/document/data-type/extended-types/date-time.type.d.ts +1 -0
- package/types/document/data-type/extended-types/date.type.d.ts +1 -0
- package/types/document/data-type/extended-types/index.d.ts +2 -2
- package/types/document/data-type/extended-types/{date-time-string.type.d.ts → partial-date.type.d.ts} +2 -2
- package/types/document/data-type/simple-type.d.ts +3 -1
- package/types/document/factory/data-type.factory.d.ts +1 -0
- package/cjs/document/data-type/extended-types/date-string.type.js +0 -52
- package/cjs/document/data-type/extended-types/date-time-string.type.js +0 -55
- package/esm/document/data-type/extended-types/date-string.type.js +0 -49
- package/esm/document/data-type/extended-types/date-time-string.type.js +0 -52
|
@@ -2,30 +2,33 @@ import { __decorate, __metadata } from "tslib";
|
|
|
2
2
|
import { isDateString, toString, vg } from 'valgen';
|
|
3
3
|
import { DECODER, ENCODER } from '../../constants.js';
|
|
4
4
|
import { SimpleType } from '../simple-type.js';
|
|
5
|
+
const _isDateString = vg.isDateString({
|
|
6
|
+
precisionMin: 'day',
|
|
7
|
+
trim: 'day',
|
|
8
|
+
coerce: true,
|
|
9
|
+
});
|
|
5
10
|
let DateType = class DateType {
|
|
6
11
|
constructor(attributes) {
|
|
7
12
|
if (attributes)
|
|
8
13
|
Object.assign(this, attributes);
|
|
9
14
|
}
|
|
10
15
|
[DECODER](properties) {
|
|
11
|
-
const fn = vg.isDate({
|
|
16
|
+
const fn = vg.isDate({
|
|
17
|
+
trim: 'day',
|
|
18
|
+
coerce: properties?.convertToNative,
|
|
19
|
+
});
|
|
12
20
|
const x = [];
|
|
13
21
|
if (properties.minValue != null) {
|
|
14
|
-
|
|
22
|
+
_isDateString(properties.minValue);
|
|
15
23
|
x.push(toString, vg.isGte(properties.minValue));
|
|
16
24
|
}
|
|
17
25
|
if (properties.maxValue != null) {
|
|
18
|
-
|
|
26
|
+
_isDateString(properties.maxValue);
|
|
19
27
|
x.push(toString, vg.isLte(properties.maxValue));
|
|
20
28
|
}
|
|
21
29
|
return x.length > 0 ? vg.pipe([fn, ...x], { returnIndex: 0 }) : fn;
|
|
22
30
|
}
|
|
23
31
|
[ENCODER](properties) {
|
|
24
|
-
const fn = vg.isDateString({
|
|
25
|
-
precision: 'date',
|
|
26
|
-
trim: 'date',
|
|
27
|
-
coerce: true,
|
|
28
|
-
});
|
|
29
32
|
const x = [];
|
|
30
33
|
if (properties.minValue != null) {
|
|
31
34
|
isDateString(properties.minValue);
|
|
@@ -35,7 +38,9 @@ let DateType = class DateType {
|
|
|
35
38
|
isDateString(properties.maxValue);
|
|
36
39
|
x.push(vg.isLte(properties.maxValue));
|
|
37
40
|
}
|
|
38
|
-
return x.length > 0
|
|
41
|
+
return x.length > 0
|
|
42
|
+
? vg.pipe([_isDateString, ...x], { returnIndex: 0 })
|
|
43
|
+
: _isDateString;
|
|
39
44
|
}
|
|
40
45
|
};
|
|
41
46
|
__decorate([
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
export * from './base64.type.js';
|
|
2
2
|
export * from './date.type.js';
|
|
3
|
-
export * from './date-string.type.js';
|
|
4
3
|
export * from './date-time.type.js';
|
|
5
|
-
export * from './date-time-
|
|
4
|
+
export * from './date-time-tz.type.js';
|
|
6
5
|
export * from './email.type.js';
|
|
7
6
|
export * from './field-path.type.js';
|
|
8
7
|
export * from './filter.type.js';
|
|
9
8
|
export * from './object-id.type.js';
|
|
10
9
|
export * from './operation-result.type.js';
|
|
10
|
+
export * from './partial-date.type.js';
|
|
11
11
|
export * from './time.type.js';
|
|
12
12
|
export * from './url.type.js';
|
|
13
13
|
export * from './uuid.type.js';
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
|
2
|
+
import { isDateString, toString, validator, vg } from 'valgen';
|
|
3
|
+
import { DECODER, ENCODER } from '../../constants.js';
|
|
4
|
+
import { SimpleType } from '../simple-type.js';
|
|
5
|
+
let PartialDateType = class PartialDateType {
|
|
6
|
+
constructor(attributes) {
|
|
7
|
+
if (attributes)
|
|
8
|
+
Object.assign(this, attributes);
|
|
9
|
+
}
|
|
10
|
+
[DECODER](properties) {
|
|
11
|
+
const fn = toPartialDate;
|
|
12
|
+
const x = [];
|
|
13
|
+
if (properties.minValue != null) {
|
|
14
|
+
isDateString(properties.minValue);
|
|
15
|
+
x.push(toString, vg.isGte(properties.minValue));
|
|
16
|
+
}
|
|
17
|
+
if (properties.maxValue != null) {
|
|
18
|
+
isDateString(properties.maxValue);
|
|
19
|
+
x.push(toString, vg.isLte(properties.maxValue));
|
|
20
|
+
}
|
|
21
|
+
return x.length > 0 ? vg.pipe([fn, ...x], { returnIndex: 0 }) : fn;
|
|
22
|
+
}
|
|
23
|
+
[ENCODER](properties) {
|
|
24
|
+
const fn = toPartialDate;
|
|
25
|
+
const x = [];
|
|
26
|
+
if (properties.minValue != null) {
|
|
27
|
+
isDateString(properties.minValue);
|
|
28
|
+
x.push(vg.isGte(properties.minValue));
|
|
29
|
+
}
|
|
30
|
+
if (properties.maxValue != null) {
|
|
31
|
+
isDateString(properties.maxValue);
|
|
32
|
+
x.push(vg.isLte(properties.maxValue));
|
|
33
|
+
}
|
|
34
|
+
return x.length > 0 ? vg.pipe([fn, ...x], { returnIndex: 0 }) : fn;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
__decorate([
|
|
38
|
+
SimpleType.Attribute({
|
|
39
|
+
description: 'Minimum value',
|
|
40
|
+
}),
|
|
41
|
+
__metadata("design:type", String)
|
|
42
|
+
], PartialDateType.prototype, "minValue", void 0);
|
|
43
|
+
__decorate([
|
|
44
|
+
SimpleType.Attribute({
|
|
45
|
+
description: 'Maximum value',
|
|
46
|
+
}),
|
|
47
|
+
__metadata("design:type", String)
|
|
48
|
+
], PartialDateType.prototype, "maxValue", void 0);
|
|
49
|
+
PartialDateType = __decorate([
|
|
50
|
+
(SimpleType({
|
|
51
|
+
name: 'partialdate',
|
|
52
|
+
description: 'Specifies a point in time using a 24-hour clock notation.\rFormat: YYYY-[MM-[DD-[T?HH:[MM:[SS[.S[S[S[S]]]]]]]]][+/-ZZ:ZZ].',
|
|
53
|
+
nameMappings: {
|
|
54
|
+
js: 'string',
|
|
55
|
+
json: 'string',
|
|
56
|
+
},
|
|
57
|
+
})
|
|
58
|
+
.Example('2021-04-18T22:30:15:22+03:00')
|
|
59
|
+
.Example('2021-04-18 22:30')
|
|
60
|
+
.Example('2021-04-18')
|
|
61
|
+
.Example('2021')),
|
|
62
|
+
__metadata("design:paramtypes", [Object])
|
|
63
|
+
], PartialDateType);
|
|
64
|
+
export { PartialDateType };
|
|
65
|
+
const _isDateString = vg.isDateString({
|
|
66
|
+
precisionMin: 'year',
|
|
67
|
+
});
|
|
68
|
+
const toPartialDate = validator((input) => {
|
|
69
|
+
if (input instanceof Date) {
|
|
70
|
+
let s = _isDateString(input, { coerce: true });
|
|
71
|
+
if (s.endsWith('Z'))
|
|
72
|
+
s = s.substring(0, s.length - 1);
|
|
73
|
+
if (s.endsWith('.000'))
|
|
74
|
+
s = s.substring(0, s.length - 4);
|
|
75
|
+
if (s.endsWith(':00'))
|
|
76
|
+
s = s.substring(0, s.length - 3);
|
|
77
|
+
if (s.endsWith('00:00'))
|
|
78
|
+
s = s.substring(0, s.length - 6);
|
|
79
|
+
return s;
|
|
80
|
+
}
|
|
81
|
+
return _isDateString(input, { coerce: false });
|
|
82
|
+
});
|
|
@@ -49,6 +49,10 @@ export const SimpleType = function (...args) {
|
|
|
49
49
|
* @class SimpleType
|
|
50
50
|
*/
|
|
51
51
|
class SimpleTypeClass extends DataType {
|
|
52
|
+
extend(properties) {
|
|
53
|
+
Object.setPrototypeOf(properties, this);
|
|
54
|
+
return properties;
|
|
55
|
+
}
|
|
52
56
|
extendsFrom(baseType) {
|
|
53
57
|
if (!(baseType instanceof DataType))
|
|
54
58
|
baseType = this.node.getDataType(baseType);
|
|
@@ -16,6 +16,7 @@ export function ApiFieldDecoratorFactory(options) {
|
|
|
16
16
|
const designType = Reflect.getMetadata('design:type', target, propertyKey);
|
|
17
17
|
const elemMeta = (metadata.fields[propertyKey] = {
|
|
18
18
|
...options,
|
|
19
|
+
designType,
|
|
19
20
|
});
|
|
20
21
|
if (designType === Array) {
|
|
21
22
|
elemMeta.isArray = true;
|
|
@@ -4,8 +4,8 @@ import { ApiDocument } from '../api-document.js';
|
|
|
4
4
|
import { DocumentInitContext } from '../common/document-init-context.js';
|
|
5
5
|
import { OpraDocumentError } from '../common/opra-document-error.js';
|
|
6
6
|
import { BUILTIN, CLASS_NAME_PATTERN, kCtorMap } from '../constants.js';
|
|
7
|
-
import
|
|
8
|
-
import
|
|
7
|
+
import * as extendedTypes from '../data-type/extended-types/index.js';
|
|
8
|
+
import * as primitiveTypes from '../data-type/primitive-types/index.js';
|
|
9
9
|
import { DataTypeFactory } from './data-type.factory.js';
|
|
10
10
|
import { HttpApiFactory } from './http-api.factory.js';
|
|
11
11
|
import { RpcApiFactory } from './rpc-api.factory.js';
|
|
@@ -154,29 +154,8 @@ export class ApiDocumentFactory {
|
|
|
154
154
|
},
|
|
155
155
|
},
|
|
156
156
|
types: [
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
BigintType,
|
|
160
|
-
BooleanType,
|
|
161
|
-
IntegerType,
|
|
162
|
-
NullType,
|
|
163
|
-
NumberType,
|
|
164
|
-
ObjectType,
|
|
165
|
-
StringType,
|
|
166
|
-
// Extended types
|
|
167
|
-
Base64Type,
|
|
168
|
-
DateType,
|
|
169
|
-
DateStringType,
|
|
170
|
-
DateTimeType,
|
|
171
|
-
DateTimeStringType,
|
|
172
|
-
EmailType,
|
|
173
|
-
FieldPathType,
|
|
174
|
-
FilterType,
|
|
175
|
-
ObjectIdType,
|
|
176
|
-
OperationResult,
|
|
177
|
-
TimeType,
|
|
178
|
-
UrlType,
|
|
179
|
-
UuidType,
|
|
157
|
+
...Object.values(primitiveTypes),
|
|
158
|
+
...Object.values(extendedTypes),
|
|
180
159
|
],
|
|
181
160
|
};
|
|
182
161
|
const document = new ApiDocument();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opra/common",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.19.0",
|
|
4
4
|
"description": "Opra common package",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"license": "MIT",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"@browsery/http-parser": "^0.5.9-r4",
|
|
11
11
|
"@browsery/i18next": "^24.2.2",
|
|
12
12
|
"@browsery/type-is": "^1.6.18-r8",
|
|
13
|
-
"@jsopen/objects": "^1.6.
|
|
13
|
+
"@jsopen/objects": "^1.6.3",
|
|
14
14
|
"fast-tokenizer": "^1.7.0",
|
|
15
15
|
"object-hash": "^3.0.0",
|
|
16
16
|
"putil-promisify": "^1.10.1",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"super-fast-md5": "^1.0.3",
|
|
20
20
|
"tslib": "^2.8.1",
|
|
21
21
|
"uid": "^2.0.2",
|
|
22
|
-
"valgen": "^5.
|
|
22
|
+
"valgen": "^5.17.1"
|
|
23
23
|
},
|
|
24
24
|
"type": "module",
|
|
25
25
|
"exports": {
|
|
@@ -39,6 +39,7 @@ declare class ApiFieldClass extends DocumentElement {
|
|
|
39
39
|
readonly owner: ComplexType | MappedType | MixinType;
|
|
40
40
|
readonly origin?: ComplexType | MappedType | MixinType;
|
|
41
41
|
readonly scopePattern?: (string | RegExp)[];
|
|
42
|
+
readonly convertToNative?: boolean;
|
|
42
43
|
readonly name: string;
|
|
43
44
|
readonly type: DataType;
|
|
44
45
|
readonly description?: string;
|
|
@@ -67,7 +68,9 @@ export declare namespace ApiField {
|
|
|
67
68
|
type?: string | OpraSchema.DataType | TypeThunkAsync | EnumType.EnumObject | EnumType.EnumArray | object;
|
|
68
69
|
}, OpraSchema.Field> {
|
|
69
70
|
scopePattern?: (string | RegExp) | (string | RegExp)[];
|
|
71
|
+
convertToNative?: boolean;
|
|
70
72
|
override?: StrictOmit<Metadata, 'override' | 'type' | 'isArray' | 'isNestedEntity'>[];
|
|
73
|
+
designType?: Function;
|
|
71
74
|
}
|
|
72
75
|
interface Options extends Partial<StrictOmit<Metadata, 'override' | 'scopePattern'>> {
|
|
73
76
|
/**
|
|
@@ -78,6 +81,11 @@ export declare namespace ApiField {
|
|
|
78
81
|
* - If an array is provided, each element within the array is used as a valid scope pattern.
|
|
79
82
|
*/
|
|
80
83
|
scopePattern?: (string | RegExp) | (string | RegExp)[];
|
|
84
|
+
/**
|
|
85
|
+
* Convert values to native objects. If enabled, some simple types
|
|
86
|
+
* like "date" will be decoded as Date instances
|
|
87
|
+
*/
|
|
88
|
+
convertToNative?: boolean;
|
|
81
89
|
}
|
|
82
90
|
interface InitArguments extends Combine<{
|
|
83
91
|
name: string;
|
|
@@ -60,7 +60,7 @@ declare abstract class DataTypeClass extends DocumentElement {
|
|
|
60
60
|
readonly description?: string;
|
|
61
61
|
readonly abstract?: boolean;
|
|
62
62
|
readonly examples?: OpraSchema.DataTypeExample[];
|
|
63
|
-
abstract generateCodec(codec: 'encode' | 'decode', options?: DataType.GenerateCodecOptions): Validator;
|
|
63
|
+
abstract generateCodec(codec: 'encode' | 'decode', options?: DataType.GenerateCodecOptions, properties?: any): Validator;
|
|
64
64
|
get embedded(): any;
|
|
65
65
|
abstract extendsFrom(baseType: DataType | string | Type | object): boolean;
|
|
66
66
|
inScope(scope?: string | '*'): boolean;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { type Validator } from 'valgen';
|
|
2
2
|
import { DECODER, ENCODER } from '../../constants.js';
|
|
3
3
|
export declare class Base64Type {
|
|
4
|
+
convertToNative?: boolean;
|
|
4
5
|
constructor(attributes?: Partial<Base64Type>);
|
|
5
|
-
protected [DECODER](): Validator;
|
|
6
|
+
protected [DECODER](properties: Partial<this>): Validator;
|
|
6
7
|
protected [ENCODER](): Validator;
|
|
7
8
|
}
|
package/types/document/data-type/extended-types/{date-string.type.d.ts → date-time-tz.type.d.ts}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type Validator } from 'valgen';
|
|
2
2
|
import { DECODER, ENCODER } from '../../constants.js';
|
|
3
|
-
export declare class
|
|
4
|
-
constructor(attributes?: Partial<
|
|
3
|
+
export declare class DateTimeTypeTz {
|
|
4
|
+
constructor(attributes?: Partial<DateTimeTypeTz>);
|
|
5
5
|
protected [DECODER](properties: Partial<this>): Validator;
|
|
6
6
|
protected [ENCODER](properties: Partial<this>): Validator;
|
|
7
7
|
minValue?: string;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type Validator } from 'valgen';
|
|
2
2
|
import { DECODER, ENCODER } from '../../constants.js';
|
|
3
3
|
export declare class DateTimeType {
|
|
4
|
+
convertToNative?: boolean;
|
|
4
5
|
constructor(attributes?: Partial<DateTimeType>);
|
|
5
6
|
protected [DECODER](properties: Partial<this>): Validator;
|
|
6
7
|
protected [ENCODER](properties: Partial<this>): Validator;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type Validator } from 'valgen';
|
|
2
2
|
import { DECODER, ENCODER } from '../../constants.js';
|
|
3
3
|
export declare class DateType {
|
|
4
|
+
convertToNative?: boolean;
|
|
4
5
|
constructor(attributes?: Partial<DateType>);
|
|
5
6
|
protected [DECODER](properties: Partial<this>): Validator;
|
|
6
7
|
protected [ENCODER](properties: Partial<this>): Validator;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
export * from './base64.type.js';
|
|
2
2
|
export * from './date.type.js';
|
|
3
|
-
export * from './date-string.type.js';
|
|
4
3
|
export * from './date-time.type.js';
|
|
5
|
-
export * from './date-time-
|
|
4
|
+
export * from './date-time-tz.type.js';
|
|
6
5
|
export * from './email.type.js';
|
|
7
6
|
export * from './field-path.type.js';
|
|
8
7
|
export * from './filter.type.js';
|
|
9
8
|
export * from './object-id.type.js';
|
|
10
9
|
export * from './operation-result.type.js';
|
|
10
|
+
export * from './partial-date.type.js';
|
|
11
11
|
export * from './time.type.js';
|
|
12
12
|
export * from './url.type.js';
|
|
13
13
|
export * from './uuid.type.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type Validator } from 'valgen';
|
|
2
2
|
import { DECODER, ENCODER } from '../../constants.js';
|
|
3
|
-
export declare class
|
|
4
|
-
constructor(attributes?: Partial<
|
|
3
|
+
export declare class PartialDateType {
|
|
4
|
+
constructor(attributes?: Partial<PartialDateType>);
|
|
5
5
|
protected [DECODER](properties: Partial<this>): Validator;
|
|
6
6
|
protected [ENCODER](properties: Partial<this>): Validator;
|
|
7
7
|
minValue?: string;
|
|
@@ -3,7 +3,7 @@ import type { Combine, Type } from 'ts-gems';
|
|
|
3
3
|
import { type Validator } from 'valgen';
|
|
4
4
|
import { OpraSchema } from '../../schema/index.js';
|
|
5
5
|
import type { ApiDocument } from '../api-document.js';
|
|
6
|
-
import type { DocumentElement } from '../common/document-element';
|
|
6
|
+
import type { DocumentElement } from '../common/document-element.js';
|
|
7
7
|
import { DocumentInitContext } from '../common/document-init-context.js';
|
|
8
8
|
import { AttributeDecoratorFactory, SimpleTypeDecoratorFactory } from '../decorators/simple-type.decorator.js';
|
|
9
9
|
import { DataType } from './data-type.js';
|
|
@@ -22,6 +22,7 @@ export declare namespace SimpleType {
|
|
|
22
22
|
base?: SimpleType;
|
|
23
23
|
ctor?: Type;
|
|
24
24
|
properties?: object;
|
|
25
|
+
convertToNative?: boolean;
|
|
25
26
|
generateDecoder?: SimpleType.ValidatorGenerator;
|
|
26
27
|
generateEncoder?: SimpleType.ValidatorGenerator;
|
|
27
28
|
}, DataType.InitArguments, SimpleType.Metadata> {
|
|
@@ -71,6 +72,7 @@ declare abstract class SimpleTypeClass extends DataType {
|
|
|
71
72
|
protected _generateDecoder?: SimpleType.ValidatorGenerator;
|
|
72
73
|
protected _generateEncoder?: SimpleType.ValidatorGenerator;
|
|
73
74
|
properties?: any;
|
|
75
|
+
extend<T>(properties: Partial<T>): SimpleType & T;
|
|
74
76
|
extendsFrom(baseType: DataType | string | Type | object): boolean;
|
|
75
77
|
generateCodec<T extends Record<string, any> | object = object>(codec: 'encode' | 'decode', options?: DataType.GenerateCodecOptions | null, properties?: Partial<T>): Validator;
|
|
76
78
|
toJSON(options?: ApiDocument.ExportOptions): OpraSchema.SimpleType;
|
|
@@ -93,6 +93,7 @@ export declare class DataTypeFactory {
|
|
|
93
93
|
* @param context
|
|
94
94
|
* @param owner
|
|
95
95
|
* @param thunk
|
|
96
|
+
* @param checkCircularDeps
|
|
96
97
|
* @protected
|
|
97
98
|
*/
|
|
98
99
|
protected static _importDataTypeArgs(context: DataTypeFactory.Context, owner: DocumentElement, thunk: string | Type | OpraSchema.DataType | object, checkCircularDeps?: boolean): Promise<DataTypeFactory.DataTypeInitArguments | string | void>;
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DateStringType = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const valgen_1 = require("valgen");
|
|
6
|
-
const constants_js_1 = require("../../constants.js");
|
|
7
|
-
const simple_type_js_1 = require("../simple-type.js");
|
|
8
|
-
let DateStringType = class DateStringType {
|
|
9
|
-
constructor(attributes) {
|
|
10
|
-
if (attributes)
|
|
11
|
-
Object.assign(this, attributes);
|
|
12
|
-
}
|
|
13
|
-
[constants_js_1.DECODER](properties) {
|
|
14
|
-
const fn = valgen_1.vg.isDateString({ trim: 'date', coerce: true });
|
|
15
|
-
const x = [];
|
|
16
|
-
if (properties.minValue != null)
|
|
17
|
-
x.push(valgen_1.vg.isGte(properties.minValue));
|
|
18
|
-
if (properties.maxValue != null)
|
|
19
|
-
x.push(valgen_1.vg.isLte(properties.maxValue));
|
|
20
|
-
return x.length > 0 ? valgen_1.vg.pipe([fn, ...x], { returnIndex: 0 }) : fn;
|
|
21
|
-
}
|
|
22
|
-
[constants_js_1.ENCODER](properties) {
|
|
23
|
-
return this[constants_js_1.DECODER](properties);
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
exports.DateStringType = DateStringType;
|
|
27
|
-
tslib_1.__decorate([
|
|
28
|
-
simple_type_js_1.SimpleType.Attribute({
|
|
29
|
-
description: 'Minimum value',
|
|
30
|
-
}),
|
|
31
|
-
tslib_1.__metadata("design:type", String)
|
|
32
|
-
], DateStringType.prototype, "minValue", void 0);
|
|
33
|
-
tslib_1.__decorate([
|
|
34
|
-
simple_type_js_1.SimpleType.Attribute({
|
|
35
|
-
description: 'Maximum value',
|
|
36
|
-
}),
|
|
37
|
-
tslib_1.__metadata("design:type", String)
|
|
38
|
-
], DateStringType.prototype, "maxValue", void 0);
|
|
39
|
-
exports.DateStringType = DateStringType = tslib_1.__decorate([
|
|
40
|
-
((0, simple_type_js_1.SimpleType)({
|
|
41
|
-
name: 'datestring',
|
|
42
|
-
description: 'Date string value',
|
|
43
|
-
nameMappings: {
|
|
44
|
-
js: 'string',
|
|
45
|
-
json: 'string',
|
|
46
|
-
},
|
|
47
|
-
})
|
|
48
|
-
.Example('2021-04-18', 'Full date value')
|
|
49
|
-
.Example('2021-04', 'Date value without day')
|
|
50
|
-
.Example('2021', 'Year only value')),
|
|
51
|
-
tslib_1.__metadata("design:paramtypes", [Object])
|
|
52
|
-
], DateStringType);
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DateTimeStringType = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const valgen_1 = require("valgen");
|
|
6
|
-
const constants_js_1 = require("../../constants.js");
|
|
7
|
-
const simple_type_js_1 = require("../simple-type.js");
|
|
8
|
-
let DateTimeStringType = class DateTimeStringType {
|
|
9
|
-
constructor(attributes) {
|
|
10
|
-
if (attributes)
|
|
11
|
-
Object.assign(this, attributes);
|
|
12
|
-
}
|
|
13
|
-
[constants_js_1.DECODER](properties) {
|
|
14
|
-
const fn = valgen_1.vg.isDateString({ coerce: true });
|
|
15
|
-
const x = [];
|
|
16
|
-
if (properties.minValue != null)
|
|
17
|
-
x.push(valgen_1.vg.isGte(properties.minValue));
|
|
18
|
-
if (properties.maxValue != null)
|
|
19
|
-
x.push(valgen_1.vg.isLte(properties.maxValue));
|
|
20
|
-
return x.length > 0 ? valgen_1.vg.pipe([fn, ...x]) : fn;
|
|
21
|
-
}
|
|
22
|
-
[constants_js_1.ENCODER](properties) {
|
|
23
|
-
return this[constants_js_1.DECODER](properties);
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
exports.DateTimeStringType = DateTimeStringType;
|
|
27
|
-
tslib_1.__decorate([
|
|
28
|
-
simple_type_js_1.SimpleType.Attribute({
|
|
29
|
-
description: 'Minimum value',
|
|
30
|
-
}),
|
|
31
|
-
tslib_1.__metadata("design:type", String)
|
|
32
|
-
], DateTimeStringType.prototype, "minValue", void 0);
|
|
33
|
-
tslib_1.__decorate([
|
|
34
|
-
simple_type_js_1.SimpleType.Attribute({
|
|
35
|
-
description: 'Maximum value',
|
|
36
|
-
}),
|
|
37
|
-
tslib_1.__metadata("design:type", String)
|
|
38
|
-
], DateTimeStringType.prototype, "maxValue", void 0);
|
|
39
|
-
exports.DateTimeStringType = DateTimeStringType = tslib_1.__decorate([
|
|
40
|
-
((0, simple_type_js_1.SimpleType)({
|
|
41
|
-
name: 'datetimestring',
|
|
42
|
-
description: 'DateTime string value',
|
|
43
|
-
nameMappings: {
|
|
44
|
-
js: 'string',
|
|
45
|
-
json: 'string',
|
|
46
|
-
},
|
|
47
|
-
})
|
|
48
|
-
.Example('2021-04-18T22:30:15+01:00', 'Full date-time value with timezone')
|
|
49
|
-
.Example('2021-04-18T22:30:15', 'Full date-time value without timezone')
|
|
50
|
-
.Example('2021-04-18 22:30', 'Date-time value')
|
|
51
|
-
.Example('2021-04-18', 'Date value')
|
|
52
|
-
.Example('2021-04', 'Date value without day')
|
|
53
|
-
.Example('2021', 'Year only value')),
|
|
54
|
-
tslib_1.__metadata("design:paramtypes", [Object])
|
|
55
|
-
], DateTimeStringType);
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { __decorate, __metadata } from "tslib";
|
|
2
|
-
import { vg } from 'valgen';
|
|
3
|
-
import { DECODER, ENCODER } from '../../constants.js';
|
|
4
|
-
import { SimpleType } from '../simple-type.js';
|
|
5
|
-
let DateStringType = class DateStringType {
|
|
6
|
-
constructor(attributes) {
|
|
7
|
-
if (attributes)
|
|
8
|
-
Object.assign(this, attributes);
|
|
9
|
-
}
|
|
10
|
-
[DECODER](properties) {
|
|
11
|
-
const fn = vg.isDateString({ trim: 'date', coerce: true });
|
|
12
|
-
const x = [];
|
|
13
|
-
if (properties.minValue != null)
|
|
14
|
-
x.push(vg.isGte(properties.minValue));
|
|
15
|
-
if (properties.maxValue != null)
|
|
16
|
-
x.push(vg.isLte(properties.maxValue));
|
|
17
|
-
return x.length > 0 ? vg.pipe([fn, ...x], { returnIndex: 0 }) : fn;
|
|
18
|
-
}
|
|
19
|
-
[ENCODER](properties) {
|
|
20
|
-
return this[DECODER](properties);
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
__decorate([
|
|
24
|
-
SimpleType.Attribute({
|
|
25
|
-
description: 'Minimum value',
|
|
26
|
-
}),
|
|
27
|
-
__metadata("design:type", String)
|
|
28
|
-
], DateStringType.prototype, "minValue", void 0);
|
|
29
|
-
__decorate([
|
|
30
|
-
SimpleType.Attribute({
|
|
31
|
-
description: 'Maximum value',
|
|
32
|
-
}),
|
|
33
|
-
__metadata("design:type", String)
|
|
34
|
-
], DateStringType.prototype, "maxValue", void 0);
|
|
35
|
-
DateStringType = __decorate([
|
|
36
|
-
(SimpleType({
|
|
37
|
-
name: 'datestring',
|
|
38
|
-
description: 'Date string value',
|
|
39
|
-
nameMappings: {
|
|
40
|
-
js: 'string',
|
|
41
|
-
json: 'string',
|
|
42
|
-
},
|
|
43
|
-
})
|
|
44
|
-
.Example('2021-04-18', 'Full date value')
|
|
45
|
-
.Example('2021-04', 'Date value without day')
|
|
46
|
-
.Example('2021', 'Year only value')),
|
|
47
|
-
__metadata("design:paramtypes", [Object])
|
|
48
|
-
], DateStringType);
|
|
49
|
-
export { DateStringType };
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { __decorate, __metadata } from "tslib";
|
|
2
|
-
import { vg } from 'valgen';
|
|
3
|
-
import { DECODER, ENCODER } from '../../constants.js';
|
|
4
|
-
import { SimpleType } from '../simple-type.js';
|
|
5
|
-
let DateTimeStringType = class DateTimeStringType {
|
|
6
|
-
constructor(attributes) {
|
|
7
|
-
if (attributes)
|
|
8
|
-
Object.assign(this, attributes);
|
|
9
|
-
}
|
|
10
|
-
[DECODER](properties) {
|
|
11
|
-
const fn = vg.isDateString({ coerce: true });
|
|
12
|
-
const x = [];
|
|
13
|
-
if (properties.minValue != null)
|
|
14
|
-
x.push(vg.isGte(properties.minValue));
|
|
15
|
-
if (properties.maxValue != null)
|
|
16
|
-
x.push(vg.isLte(properties.maxValue));
|
|
17
|
-
return x.length > 0 ? vg.pipe([fn, ...x]) : fn;
|
|
18
|
-
}
|
|
19
|
-
[ENCODER](properties) {
|
|
20
|
-
return this[DECODER](properties);
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
__decorate([
|
|
24
|
-
SimpleType.Attribute({
|
|
25
|
-
description: 'Minimum value',
|
|
26
|
-
}),
|
|
27
|
-
__metadata("design:type", String)
|
|
28
|
-
], DateTimeStringType.prototype, "minValue", void 0);
|
|
29
|
-
__decorate([
|
|
30
|
-
SimpleType.Attribute({
|
|
31
|
-
description: 'Maximum value',
|
|
32
|
-
}),
|
|
33
|
-
__metadata("design:type", String)
|
|
34
|
-
], DateTimeStringType.prototype, "maxValue", void 0);
|
|
35
|
-
DateTimeStringType = __decorate([
|
|
36
|
-
(SimpleType({
|
|
37
|
-
name: 'datetimestring',
|
|
38
|
-
description: 'DateTime string value',
|
|
39
|
-
nameMappings: {
|
|
40
|
-
js: 'string',
|
|
41
|
-
json: 'string',
|
|
42
|
-
},
|
|
43
|
-
})
|
|
44
|
-
.Example('2021-04-18T22:30:15+01:00', 'Full date-time value with timezone')
|
|
45
|
-
.Example('2021-04-18T22:30:15', 'Full date-time value without timezone')
|
|
46
|
-
.Example('2021-04-18 22:30', 'Date-time value')
|
|
47
|
-
.Example('2021-04-18', 'Date value')
|
|
48
|
-
.Example('2021-04', 'Date value without day')
|
|
49
|
-
.Example('2021', 'Year only value')),
|
|
50
|
-
__metadata("design:paramtypes", [Object])
|
|
51
|
-
], DateTimeStringType);
|
|
52
|
-
export { DateTimeStringType };
|