@opra/common 1.19.0 → 1.19.2

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.
@@ -51,6 +51,7 @@ exports.ApiField = function (...args) {
51
51
  _this.convertToNative =
52
52
  initArgs.convertToNative ??
53
53
  (_this.type.kind === 'SimpleType' &&
54
+ initArgs.designType !== String &&
54
55
  typeof initArgs.designType === 'function' &&
55
56
  initArgs.designType !== Object);
56
57
  _this.override = initArgs.override;
@@ -15,34 +15,26 @@ let DateTimeTypeTz = class DateTimeTypeTz {
15
15
  Object.assign(this, attributes);
16
16
  }
17
17
  [constants_js_1.DECODER](properties) {
18
- const fn = valgen_1.vg.isDateString({
19
- coerce: true,
20
- precisionMin: 'tz',
21
- });
22
- const x = [];
18
+ const fn = _isDateString;
19
+ const x = [fn];
23
20
  if (properties.minValue != null) {
24
- _isDateString(properties.minValue);
25
- x.push(valgen_1.toString, valgen_1.vg.isGte(properties.minValue));
21
+ x.push(valgen_1.vg.isGte(fn(properties.minValue)));
26
22
  }
27
23
  if (properties.maxValue != null) {
28
- _isDateString(properties.maxValue);
29
- x.push(valgen_1.toString, valgen_1.vg.isLte(properties.maxValue));
24
+ x.push(valgen_1.vg.isLte(fn(properties.maxValue)));
30
25
  }
31
- return x.length > 0 ? valgen_1.vg.pipe([fn, ...x], { returnIndex: 0 }) : fn;
26
+ return x.length > 0 ? valgen_1.vg.pipe(x, { returnIndex: 0 }) : fn;
32
27
  }
33
28
  [constants_js_1.ENCODER](properties) {
34
- const x = [];
29
+ const fn = _isDateString;
30
+ const x = [fn];
35
31
  if (properties.minValue != null) {
36
- (0, valgen_1.isDateString)(properties.minValue);
37
- x.push(valgen_1.vg.isGte(properties.minValue));
32
+ x.push(valgen_1.vg.isGte(fn(properties.minValue)));
38
33
  }
39
34
  if (properties.maxValue != null) {
40
- (0, valgen_1.isDateString)(properties.maxValue);
41
- x.push(valgen_1.vg.isLte(properties.maxValue));
35
+ x.push(valgen_1.vg.isLte(fn(properties.maxValue)));
42
36
  }
43
- return x.length > 0
44
- ? valgen_1.vg.pipe([_isDateString, ...x], { returnIndex: 0 })
45
- : _isDateString;
37
+ return x.length > 0 ? valgen_1.vg.pipe(x, { returnIndex: 0 }) : fn;
46
38
  }
47
39
  };
48
40
  exports.DateTimeTypeTz = DateTimeTypeTz;
@@ -7,8 +7,11 @@ const constants_js_1 = require("../../constants.js");
7
7
  const simple_type_js_1 = require("../simple-type.js");
8
8
  const _isDateString = valgen_1.vg.isDateString({
9
9
  precisionMin: 'day',
10
- coerce: true,
11
10
  trim: 'tz',
11
+ coerce: true,
12
+ });
13
+ const _isDate = valgen_1.vg.isDate({
14
+ coerce: true,
12
15
  });
13
16
  let DateTimeType = class DateTimeType {
14
17
  constructor(attributes) {
@@ -16,33 +19,32 @@ let DateTimeType = class DateTimeType {
16
19
  Object.assign(this, attributes);
17
20
  }
18
21
  [constants_js_1.DECODER](properties) {
19
- const fn = valgen_1.vg.isDate({
20
- coerce: properties?.convertToNative,
21
- });
22
- const x = [];
22
+ let fn;
23
+ if (properties.convertToNative) {
24
+ fn = _isDate;
25
+ }
26
+ else {
27
+ fn = _isDateString;
28
+ }
29
+ const x = [fn];
23
30
  if (properties.minValue != null) {
24
- _isDateString(properties.minValue);
25
- x.push(valgen_1.toString, valgen_1.vg.isGte(properties.minValue));
31
+ x.push(valgen_1.vg.isGte(fn(properties.minValue)));
26
32
  }
27
33
  if (properties.maxValue != null) {
28
- _isDateString(properties.maxValue);
29
- x.push(valgen_1.toString, valgen_1.vg.isLte(properties.maxValue));
34
+ x.push(valgen_1.vg.isLte(fn(properties.maxValue)));
30
35
  }
31
- return x.length > 0 ? valgen_1.vg.pipe([fn, ...x], { returnIndex: 0 }) : fn;
36
+ return x.length > 0 ? valgen_1.vg.pipe(x, { returnIndex: 0 }) : fn;
32
37
  }
33
38
  [constants_js_1.ENCODER](properties) {
34
- const x = [];
39
+ const fn = _isDateString;
40
+ const x = [fn];
35
41
  if (properties.minValue != null) {
36
- (0, valgen_1.isDateString)(properties.minValue);
37
- x.push(valgen_1.vg.isGte(properties.minValue));
42
+ x.push(valgen_1.vg.isGte(fn(properties.minValue)));
38
43
  }
39
44
  if (properties.maxValue != null) {
40
- (0, valgen_1.isDateString)(properties.maxValue);
41
- x.push(valgen_1.vg.isLte(properties.maxValue));
45
+ x.push(valgen_1.vg.isLte(fn(properties.maxValue)));
42
46
  }
43
- return x.length > 0
44
- ? valgen_1.vg.pipe([_isDateString, ...x], { returnIndex: 0 })
45
- : _isDateString;
47
+ return x.length > 0 ? valgen_1.vg.pipe(x, { returnIndex: 0 }) : fn;
46
48
  }
47
49
  };
48
50
  exports.DateTimeType = DateTimeType;
@@ -10,40 +10,42 @@ const _isDateString = valgen_1.vg.isDateString({
10
10
  trim: 'day',
11
11
  coerce: true,
12
12
  });
13
+ const _isDate = valgen_1.vg.isDate({
14
+ trim: 'day',
15
+ coerce: true,
16
+ });
13
17
  let DateType = class DateType {
14
18
  constructor(attributes) {
15
19
  if (attributes)
16
20
  Object.assign(this, attributes);
17
21
  }
18
22
  [constants_js_1.DECODER](properties) {
19
- const fn = valgen_1.vg.isDate({
20
- trim: 'day',
21
- coerce: properties?.convertToNative,
22
- });
23
- const x = [];
23
+ let fn;
24
+ if (properties.convertToNative) {
25
+ fn = _isDate;
26
+ }
27
+ else {
28
+ fn = _isDateString;
29
+ }
30
+ const x = [fn];
24
31
  if (properties.minValue != null) {
25
- _isDateString(properties.minValue);
26
- x.push(valgen_1.toString, valgen_1.vg.isGte(properties.minValue));
32
+ x.push(valgen_1.vg.isGte(fn(properties.minValue)));
27
33
  }
28
34
  if (properties.maxValue != null) {
29
- _isDateString(properties.maxValue);
30
- x.push(valgen_1.toString, valgen_1.vg.isLte(properties.maxValue));
35
+ x.push(valgen_1.vg.isLte(fn(properties.maxValue)));
31
36
  }
32
- return x.length > 0 ? valgen_1.vg.pipe([fn, ...x], { returnIndex: 0 }) : fn;
37
+ return x.length > 0 ? valgen_1.vg.pipe(x, { returnIndex: 0 }) : fn;
33
38
  }
34
39
  [constants_js_1.ENCODER](properties) {
35
- const x = [];
40
+ const fn = _isDateString;
41
+ const x = [fn];
36
42
  if (properties.minValue != null) {
37
- (0, valgen_1.isDateString)(properties.minValue);
38
- x.push(valgen_1.vg.isGte(properties.minValue));
43
+ x.push(valgen_1.vg.isGte(fn(properties.minValue)));
39
44
  }
40
45
  if (properties.maxValue != null) {
41
- (0, valgen_1.isDateString)(properties.maxValue);
42
- x.push(valgen_1.vg.isLte(properties.maxValue));
46
+ x.push(valgen_1.vg.isLte(fn(properties.maxValue)));
43
47
  }
44
- return x.length > 0
45
- ? valgen_1.vg.pipe([_isDateString, ...x], { returnIndex: 0 })
46
- : _isDateString;
48
+ return x.length > 0 ? valgen_1.vg.pipe(x, { returnIndex: 0 }) : fn;
47
49
  }
48
50
  };
49
51
  exports.DateType = DateType;
@@ -64,7 +66,7 @@ exports.DateType = DateType = tslib_1.__decorate([
64
66
  name: 'date',
65
67
  description: 'A date without time',
66
68
  nameMappings: {
67
- js: 'Date',
69
+ js: 'string',
68
70
  json: 'string',
69
71
  },
70
72
  }).Example('2021-04-18', 'Full date value')),
@@ -48,6 +48,7 @@ export const ApiField = function (...args) {
48
48
  _this.convertToNative =
49
49
  initArgs.convertToNative ??
50
50
  (_this.type.kind === 'SimpleType' &&
51
+ initArgs.designType !== String &&
51
52
  typeof initArgs.designType === 'function' &&
52
53
  initArgs.designType !== Object);
53
54
  _this.override = initArgs.override;
@@ -1,5 +1,5 @@
1
1
  import { __decorate, __metadata } from "tslib";
2
- import { isDateString, toString, vg } from 'valgen';
2
+ import { vg } from 'valgen';
3
3
  import { DECODER, ENCODER } from '../../constants.js';
4
4
  import { SimpleType } from '../simple-type.js';
5
5
  const _isDateString = vg.isDateString({
@@ -12,34 +12,26 @@ let DateTimeTypeTz = class DateTimeTypeTz {
12
12
  Object.assign(this, attributes);
13
13
  }
14
14
  [DECODER](properties) {
15
- const fn = vg.isDateString({
16
- coerce: true,
17
- precisionMin: 'tz',
18
- });
19
- const x = [];
15
+ const fn = _isDateString;
16
+ const x = [fn];
20
17
  if (properties.minValue != null) {
21
- _isDateString(properties.minValue);
22
- x.push(toString, vg.isGte(properties.minValue));
18
+ x.push(vg.isGte(fn(properties.minValue)));
23
19
  }
24
20
  if (properties.maxValue != null) {
25
- _isDateString(properties.maxValue);
26
- x.push(toString, vg.isLte(properties.maxValue));
21
+ x.push(vg.isLte(fn(properties.maxValue)));
27
22
  }
28
- return x.length > 0 ? vg.pipe([fn, ...x], { returnIndex: 0 }) : fn;
23
+ return x.length > 0 ? vg.pipe(x, { returnIndex: 0 }) : fn;
29
24
  }
30
25
  [ENCODER](properties) {
31
- const x = [];
26
+ const fn = _isDateString;
27
+ const x = [fn];
32
28
  if (properties.minValue != null) {
33
- isDateString(properties.minValue);
34
- x.push(vg.isGte(properties.minValue));
29
+ x.push(vg.isGte(fn(properties.minValue)));
35
30
  }
36
31
  if (properties.maxValue != null) {
37
- isDateString(properties.maxValue);
38
- x.push(vg.isLte(properties.maxValue));
32
+ x.push(vg.isLte(fn(properties.maxValue)));
39
33
  }
40
- return x.length > 0
41
- ? vg.pipe([_isDateString, ...x], { returnIndex: 0 })
42
- : _isDateString;
34
+ return x.length > 0 ? vg.pipe(x, { returnIndex: 0 }) : fn;
43
35
  }
44
36
  };
45
37
  __decorate([
@@ -1,11 +1,14 @@
1
1
  import { __decorate, __metadata } from "tslib";
2
- import { isDateString, toString, vg } from 'valgen';
2
+ import { vg } from 'valgen';
3
3
  import { DECODER, ENCODER } from '../../constants.js';
4
4
  import { SimpleType } from '../simple-type.js';
5
5
  const _isDateString = vg.isDateString({
6
6
  precisionMin: 'day',
7
- coerce: true,
8
7
  trim: 'tz',
8
+ coerce: true,
9
+ });
10
+ const _isDate = vg.isDate({
11
+ coerce: true,
9
12
  });
10
13
  let DateTimeType = class DateTimeType {
11
14
  constructor(attributes) {
@@ -13,33 +16,32 @@ let DateTimeType = class DateTimeType {
13
16
  Object.assign(this, attributes);
14
17
  }
15
18
  [DECODER](properties) {
16
- const fn = vg.isDate({
17
- coerce: properties?.convertToNative,
18
- });
19
- const x = [];
19
+ let fn;
20
+ if (properties.convertToNative) {
21
+ fn = _isDate;
22
+ }
23
+ else {
24
+ fn = _isDateString;
25
+ }
26
+ const x = [fn];
20
27
  if (properties.minValue != null) {
21
- _isDateString(properties.minValue);
22
- x.push(toString, vg.isGte(properties.minValue));
28
+ x.push(vg.isGte(fn(properties.minValue)));
23
29
  }
24
30
  if (properties.maxValue != null) {
25
- _isDateString(properties.maxValue);
26
- x.push(toString, vg.isLte(properties.maxValue));
31
+ x.push(vg.isLte(fn(properties.maxValue)));
27
32
  }
28
- return x.length > 0 ? vg.pipe([fn, ...x], { returnIndex: 0 }) : fn;
33
+ return x.length > 0 ? vg.pipe(x, { returnIndex: 0 }) : fn;
29
34
  }
30
35
  [ENCODER](properties) {
31
- const x = [];
36
+ const fn = _isDateString;
37
+ const x = [fn];
32
38
  if (properties.minValue != null) {
33
- isDateString(properties.minValue);
34
- x.push(vg.isGte(properties.minValue));
39
+ x.push(vg.isGte(fn(properties.minValue)));
35
40
  }
36
41
  if (properties.maxValue != null) {
37
- isDateString(properties.maxValue);
38
- x.push(vg.isLte(properties.maxValue));
42
+ x.push(vg.isLte(fn(properties.maxValue)));
39
43
  }
40
- return x.length > 0
41
- ? vg.pipe([_isDateString, ...x], { returnIndex: 0 })
42
- : _isDateString;
44
+ return x.length > 0 ? vg.pipe(x, { returnIndex: 0 }) : fn;
43
45
  }
44
46
  };
45
47
  __decorate([
@@ -1,5 +1,5 @@
1
1
  import { __decorate, __metadata } from "tslib";
2
- import { isDateString, toString, vg } from 'valgen';
2
+ import { vg } from 'valgen';
3
3
  import { DECODER, ENCODER } from '../../constants.js';
4
4
  import { SimpleType } from '../simple-type.js';
5
5
  const _isDateString = vg.isDateString({
@@ -7,40 +7,42 @@ const _isDateString = vg.isDateString({
7
7
  trim: 'day',
8
8
  coerce: true,
9
9
  });
10
+ const _isDate = vg.isDate({
11
+ trim: 'day',
12
+ coerce: true,
13
+ });
10
14
  let DateType = class DateType {
11
15
  constructor(attributes) {
12
16
  if (attributes)
13
17
  Object.assign(this, attributes);
14
18
  }
15
19
  [DECODER](properties) {
16
- const fn = vg.isDate({
17
- trim: 'day',
18
- coerce: properties?.convertToNative,
19
- });
20
- const x = [];
20
+ let fn;
21
+ if (properties.convertToNative) {
22
+ fn = _isDate;
23
+ }
24
+ else {
25
+ fn = _isDateString;
26
+ }
27
+ const x = [fn];
21
28
  if (properties.minValue != null) {
22
- _isDateString(properties.minValue);
23
- x.push(toString, vg.isGte(properties.minValue));
29
+ x.push(vg.isGte(fn(properties.minValue)));
24
30
  }
25
31
  if (properties.maxValue != null) {
26
- _isDateString(properties.maxValue);
27
- x.push(toString, vg.isLte(properties.maxValue));
32
+ x.push(vg.isLte(fn(properties.maxValue)));
28
33
  }
29
- return x.length > 0 ? vg.pipe([fn, ...x], { returnIndex: 0 }) : fn;
34
+ return x.length > 0 ? vg.pipe(x, { returnIndex: 0 }) : fn;
30
35
  }
31
36
  [ENCODER](properties) {
32
- const x = [];
37
+ const fn = _isDateString;
38
+ const x = [fn];
33
39
  if (properties.minValue != null) {
34
- isDateString(properties.minValue);
35
- x.push(vg.isGte(properties.minValue));
40
+ x.push(vg.isGte(fn(properties.minValue)));
36
41
  }
37
42
  if (properties.maxValue != null) {
38
- isDateString(properties.maxValue);
39
- x.push(vg.isLte(properties.maxValue));
43
+ x.push(vg.isLte(fn(properties.maxValue)));
40
44
  }
41
- return x.length > 0
42
- ? vg.pipe([_isDateString, ...x], { returnIndex: 0 })
43
- : _isDateString;
45
+ return x.length > 0 ? vg.pipe(x, { returnIndex: 0 }) : fn;
44
46
  }
45
47
  };
46
48
  __decorate([
@@ -60,7 +62,7 @@ DateType = __decorate([
60
62
  name: 'date',
61
63
  description: 'A date without time',
62
64
  nameMappings: {
63
- js: 'Date',
65
+ js: 'string',
64
66
  json: 'string',
65
67
  },
66
68
  }).Example('2021-04-18', 'Full date value')),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opra/common",
3
- "version": "1.19.0",
3
+ "version": "1.19.2",
4
4
  "description": "Opra common package",
5
5
  "author": "Panates",
6
6
  "license": "MIT",
@@ -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.17.1"
22
+ "valgen": "^5.17.2"
23
23
  },
24
24
  "type": "module",
25
25
  "exports": {