@opra/common 1.25.2 → 1.25.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 +4 -4
- package/document/data-type/complex-type-base.d.ts +2 -2
- package/document/data-type/extended-types/credit-card.type.d.ts +8 -0
- package/document/data-type/extended-types/credit-card.type.js +35 -0
- package/document/data-type/extended-types/date-time.type.d.ts +3 -3
- package/document/data-type/extended-types/ean.type.d.ts +7 -0
- package/document/data-type/extended-types/ean.type.js +28 -0
- package/document/data-type/extended-types/iban.type.d.ts +7 -0
- package/document/data-type/extended-types/iban.type.js +28 -0
- package/document/data-type/extended-types/index.d.ts +5 -0
- package/document/data-type/extended-types/index.js +5 -0
- package/document/data-type/extended-types/ip.type.d.ts +8 -0
- package/document/data-type/extended-types/ip.type.js +45 -0
- package/document/data-type/extended-types/mobile-phone.type.d.ts +8 -0
- package/document/data-type/extended-types/mobile-phone.type.js +41 -0
- package/document/data-type/extended-types/uuid.type.d.ts +2 -2
- package/document/data-type/extended-types/uuid.type.js +1 -1
- package/package.json +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type StrictOmit, type Type } from 'ts-gems';
|
|
2
|
-
import { type
|
|
2
|
+
import { type Validator, vg } from 'valgen';
|
|
3
3
|
import { FieldsProjection, ResponsiveMap } from '../../helpers/index.js';
|
|
4
4
|
import { OpraSchema } from '../../schema/index.js';
|
|
5
5
|
import type { DocumentElement } from '../common/document-element.js';
|
|
@@ -73,7 +73,7 @@ declare abstract class ComplexTypeBaseClass extends DataType {
|
|
|
73
73
|
*
|
|
74
74
|
*/
|
|
75
75
|
generateCodec(codec: 'encode' | 'decode', options?: DataType.GenerateCodecOptions): Validator;
|
|
76
|
-
protected _generateSchema(codec: 'encode' | 'decode', context: GenerateCodecContext):
|
|
76
|
+
protected _generateSchema(codec: 'encode' | 'decode', context: GenerateCodecContext): vg.isObject.Schema;
|
|
77
77
|
protected _generateFieldCodec(codec: 'encode' | 'decode', field: ApiField, context: GenerateCodecContext): Validator;
|
|
78
78
|
}
|
|
79
79
|
type GenerateCodecContext = StrictOmit<DataType.GenerateCodecOptions, 'projection'> & {
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type Validator, vg } from 'valgen';
|
|
2
|
+
import { DECODER, ENCODER } from '../../constants.js';
|
|
3
|
+
export declare class CreditCardType {
|
|
4
|
+
constructor(attributes?: Partial<CreditCardType>);
|
|
5
|
+
provider?: vg.isCreditCard.Provider;
|
|
6
|
+
protected [DECODER](properties?: Partial<this>): Validator;
|
|
7
|
+
protected [ENCODER](properties?: Partial<this>): Validator;
|
|
8
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
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 CreditCardType = class CreditCardType {
|
|
6
|
+
constructor(attributes) {
|
|
7
|
+
if (attributes)
|
|
8
|
+
Object.assign(this, attributes);
|
|
9
|
+
}
|
|
10
|
+
provider;
|
|
11
|
+
[DECODER](properties) {
|
|
12
|
+
return vg.isCreditCard({ coerce: true, provider: properties?.provider });
|
|
13
|
+
}
|
|
14
|
+
[ENCODER](properties) {
|
|
15
|
+
return vg.isCreditCard({ coerce: true, provider: properties?.provider });
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
__decorate([
|
|
19
|
+
SimpleType.Attribute({
|
|
20
|
+
description: 'Locale to use for validation',
|
|
21
|
+
}),
|
|
22
|
+
__metadata("design:type", Object)
|
|
23
|
+
], CreditCardType.prototype, "provider", void 0);
|
|
24
|
+
CreditCardType = __decorate([
|
|
25
|
+
SimpleType({
|
|
26
|
+
name: 'creditcard',
|
|
27
|
+
description: 'A Credit Card value',
|
|
28
|
+
nameMappings: {
|
|
29
|
+
js: 'string',
|
|
30
|
+
json: 'string',
|
|
31
|
+
},
|
|
32
|
+
}),
|
|
33
|
+
__metadata("design:paramtypes", [Object])
|
|
34
|
+
], CreditCardType);
|
|
35
|
+
export { CreditCardType };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Type } from 'ts-gems';
|
|
2
|
-
import { type
|
|
2
|
+
import { type Validator, vg } from 'valgen';
|
|
3
3
|
import { DECODER, ENCODER } from '../../constants.js';
|
|
4
4
|
export declare class DateTimeType {
|
|
5
5
|
designType?: Type;
|
|
6
6
|
constructor(attributes?: Partial<DateTimeType>);
|
|
7
|
-
precisionMin?:
|
|
8
|
-
precisionMax?:
|
|
7
|
+
precisionMin?: vg.isDateString.Precision;
|
|
8
|
+
precisionMax?: vg.isDateString.Precision;
|
|
9
9
|
protected [DECODER](properties: Partial<this>): Validator;
|
|
10
10
|
protected [ENCODER](properties: Partial<this>): Validator;
|
|
11
11
|
minValue?: string;
|
|
@@ -0,0 +1,28 @@
|
|
|
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 EanType = class EanType {
|
|
6
|
+
constructor(attributes) {
|
|
7
|
+
if (attributes)
|
|
8
|
+
Object.assign(this, attributes);
|
|
9
|
+
}
|
|
10
|
+
[DECODER]() {
|
|
11
|
+
return vg.isEAN({ coerce: true });
|
|
12
|
+
}
|
|
13
|
+
[ENCODER]() {
|
|
14
|
+
return vg.isEAN({ coerce: true });
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
EanType = __decorate([
|
|
18
|
+
SimpleType({
|
|
19
|
+
name: 'ean',
|
|
20
|
+
description: 'An EAN (European Article Number)',
|
|
21
|
+
nameMappings: {
|
|
22
|
+
js: 'string',
|
|
23
|
+
json: 'string',
|
|
24
|
+
},
|
|
25
|
+
}),
|
|
26
|
+
__metadata("design:paramtypes", [Object])
|
|
27
|
+
], EanType);
|
|
28
|
+
export { EanType };
|
|
@@ -0,0 +1,28 @@
|
|
|
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 IbanType = class IbanType {
|
|
6
|
+
constructor(attributes) {
|
|
7
|
+
if (attributes)
|
|
8
|
+
Object.assign(this, attributes);
|
|
9
|
+
}
|
|
10
|
+
[DECODER]() {
|
|
11
|
+
return vg.isIBAN({ coerce: true });
|
|
12
|
+
}
|
|
13
|
+
[ENCODER]() {
|
|
14
|
+
return vg.isIBAN({ coerce: true });
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
IbanType = __decorate([
|
|
18
|
+
SimpleType({
|
|
19
|
+
name: 'iban',
|
|
20
|
+
description: 'An IBAN (International Bank Account Number)',
|
|
21
|
+
nameMappings: {
|
|
22
|
+
js: 'string',
|
|
23
|
+
json: 'string',
|
|
24
|
+
},
|
|
25
|
+
}),
|
|
26
|
+
__metadata("design:paramtypes", [Object])
|
|
27
|
+
], IbanType);
|
|
28
|
+
export { IbanType };
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
export * from './base64.type.js';
|
|
2
|
+
export * from './credit-card.type.js';
|
|
2
3
|
export * from './date.type.js';
|
|
3
4
|
export * from './date-time.type.js';
|
|
4
5
|
export * from './date-time-tz.type.js';
|
|
6
|
+
export * from './ean.type.js';
|
|
5
7
|
export * from './email.type.js';
|
|
6
8
|
export * from './field-path.type.js';
|
|
7
9
|
export * from './filter.type.js';
|
|
10
|
+
export * from './iban.type.js';
|
|
11
|
+
export * from './ip.type.js';
|
|
12
|
+
export * from './mobile-phone.type.js';
|
|
8
13
|
export * from './object-id.type.js';
|
|
9
14
|
export * from './operation-result.type.js';
|
|
10
15
|
export * from './time.type.js';
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
export * from './base64.type.js';
|
|
2
|
+
export * from './credit-card.type.js';
|
|
2
3
|
export * from './date.type.js';
|
|
3
4
|
export * from './date-time.type.js';
|
|
4
5
|
export * from './date-time-tz.type.js';
|
|
6
|
+
export * from './ean.type.js';
|
|
5
7
|
export * from './email.type.js';
|
|
6
8
|
export * from './field-path.type.js';
|
|
7
9
|
export * from './filter.type.js';
|
|
10
|
+
export * from './iban.type.js';
|
|
11
|
+
export * from './ip.type.js';
|
|
12
|
+
export * from './mobile-phone.type.js';
|
|
8
13
|
export * from './object-id.type.js';
|
|
9
14
|
export * from './operation-result.type.js';
|
|
10
15
|
export * from './time.type.js';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type Validator, vg } from 'valgen';
|
|
2
|
+
import { DECODER, ENCODER } from '../../constants.js';
|
|
3
|
+
export declare class IpType {
|
|
4
|
+
constructor(attributes?: Partial<IpType>);
|
|
5
|
+
version?: vg.isIP.IPVersion;
|
|
6
|
+
protected [DECODER](properties?: Partial<this>): Validator;
|
|
7
|
+
protected [ENCODER](properties?: Partial<this>): Validator;
|
|
8
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
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 IpType = class IpType {
|
|
6
|
+
constructor(attributes) {
|
|
7
|
+
if (attributes)
|
|
8
|
+
Object.assign(this, attributes);
|
|
9
|
+
}
|
|
10
|
+
version;
|
|
11
|
+
[DECODER](properties) {
|
|
12
|
+
return properties?.version
|
|
13
|
+
? vg.isIP(properties?.version, { coerce: true })
|
|
14
|
+
: vg.oneOf([
|
|
15
|
+
vg.isIP('4', { coerce: true }),
|
|
16
|
+
vg.isIP('6', { coerce: true }),
|
|
17
|
+
]);
|
|
18
|
+
}
|
|
19
|
+
[ENCODER](properties) {
|
|
20
|
+
return properties?.version
|
|
21
|
+
? vg.isIP(properties?.version, { coerce: true })
|
|
22
|
+
: vg.oneOf([
|
|
23
|
+
vg.isIP('4', { coerce: true }),
|
|
24
|
+
vg.isIP('6', { coerce: true }),
|
|
25
|
+
]);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
__decorate([
|
|
29
|
+
SimpleType.Attribute({
|
|
30
|
+
description: 'IP version to use for validation',
|
|
31
|
+
}),
|
|
32
|
+
__metadata("design:type", Object)
|
|
33
|
+
], IpType.prototype, "version", void 0);
|
|
34
|
+
IpType = __decorate([
|
|
35
|
+
SimpleType({
|
|
36
|
+
name: 'ip',
|
|
37
|
+
description: 'An IP address',
|
|
38
|
+
nameMappings: {
|
|
39
|
+
js: 'string',
|
|
40
|
+
json: 'string',
|
|
41
|
+
},
|
|
42
|
+
}),
|
|
43
|
+
__metadata("design:paramtypes", [Object])
|
|
44
|
+
], IpType);
|
|
45
|
+
export { IpType };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type Validator, vg } from 'valgen';
|
|
2
|
+
import { DECODER, ENCODER } from '../../constants.js';
|
|
3
|
+
export declare class MobilePhoneType {
|
|
4
|
+
constructor(attributes?: Partial<MobilePhoneType>);
|
|
5
|
+
locale?: vg.isMobilePhone.MobilePhoneLocale;
|
|
6
|
+
protected [DECODER](properties?: Partial<this>): Validator;
|
|
7
|
+
protected [ENCODER](properties?: Partial<this>): Validator;
|
|
8
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
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 MobilePhoneType = class MobilePhoneType {
|
|
6
|
+
constructor(attributes) {
|
|
7
|
+
if (attributes)
|
|
8
|
+
Object.assign(this, attributes);
|
|
9
|
+
}
|
|
10
|
+
locale;
|
|
11
|
+
[DECODER](properties) {
|
|
12
|
+
return vg.isMobilePhone({
|
|
13
|
+
coerce: true,
|
|
14
|
+
locale: properties?.locale || 'any',
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
[ENCODER](properties) {
|
|
18
|
+
return vg.isMobilePhone({
|
|
19
|
+
coerce: true,
|
|
20
|
+
locale: properties?.locale || 'any',
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
__decorate([
|
|
25
|
+
SimpleType.Attribute({
|
|
26
|
+
description: 'Locale to use for validation',
|
|
27
|
+
}),
|
|
28
|
+
__metadata("design:type", String)
|
|
29
|
+
], MobilePhoneType.prototype, "locale", void 0);
|
|
30
|
+
MobilePhoneType = __decorate([
|
|
31
|
+
SimpleType({
|
|
32
|
+
name: 'mobilephone',
|
|
33
|
+
description: 'A Mobile Phone Number value',
|
|
34
|
+
nameMappings: {
|
|
35
|
+
js: 'string',
|
|
36
|
+
json: 'string',
|
|
37
|
+
},
|
|
38
|
+
}),
|
|
39
|
+
__metadata("design:paramtypes", [Object])
|
|
40
|
+
], MobilePhoneType);
|
|
41
|
+
export { MobilePhoneType };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { type Validator } from 'valgen';
|
|
1
|
+
import { type Validator, vg } from 'valgen';
|
|
2
2
|
import { DECODER, ENCODER } from '../../constants.js';
|
|
3
3
|
export declare class UuidType {
|
|
4
4
|
constructor(attributes?: Partial<UuidType>);
|
|
5
|
-
version?:
|
|
5
|
+
version?: vg.isUUID.UUIDVersion;
|
|
6
6
|
protected [DECODER](properties?: Partial<this>): Validator;
|
|
7
7
|
protected [ENCODER](properties?: Partial<this>): Validator;
|
|
8
8
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opra/common",
|
|
3
|
-
"version": "1.25.
|
|
3
|
+
"version": "1.25.4",
|
|
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": "^
|
|
22
|
+
"valgen": "^6.0.3"
|
|
23
23
|
},
|
|
24
24
|
"type": "module",
|
|
25
25
|
"module": "./index.js",
|