@opra/common 1.25.1 → 1.25.3

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.
@@ -1,5 +1,5 @@
1
1
  import { type StrictOmit, type Type } from 'ts-gems';
2
- import { type IsObject, type Validator } from 'valgen';
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): IsObject.Schema;
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 DatePrecision, type Validator } from 'valgen';
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?: DatePrecision;
8
- precisionMax?: DatePrecision;
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,7 @@
1
+ import { type Validator } from 'valgen';
2
+ import { DECODER, ENCODER } from '../../constants.js';
3
+ export declare class EanType {
4
+ constructor(attributes?: Partial<EanType>);
5
+ protected [DECODER](): Validator;
6
+ protected [ENCODER](): Validator;
7
+ }
@@ -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,7 @@
1
+ import { type Validator } from 'valgen';
2
+ import { DECODER, ENCODER } from '../../constants.js';
3
+ export declare class IbanType {
4
+ constructor(attributes?: Partial<IbanType>);
5
+ protected [DECODER](): Validator;
6
+ protected [ENCODER](): Validator;
7
+ }
@@ -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,13 @@
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';
5
6
  export * from './email.type.js';
6
7
  export * from './field-path.type.js';
7
8
  export * from './filter.type.js';
9
+ export * from './iban.type.js';
10
+ export * from './ip.type.js';
8
11
  export * from './object-id.type.js';
9
12
  export * from './operation-result.type.js';
10
13
  export * from './time.type.js';
@@ -1,10 +1,13 @@
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';
5
6
  export * from './email.type.js';
6
7
  export * from './field-path.type.js';
7
8
  export * from './filter.type.js';
9
+ export * from './iban.type.js';
10
+ export * from './ip.type.js';
8
11
  export * from './object-id.type.js';
9
12
  export * from './operation-result.type.js';
10
13
  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 || 'tr-TR',
15
+ });
16
+ }
17
+ [ENCODER](properties) {
18
+ return vg.isMobilePhone({
19
+ coerce: true,
20
+ locale: properties?.locale || 'tr-TR',
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 };
@@ -0,0 +1,8 @@
1
+ import { type Validator } from 'valgen';
2
+ import { DECODER, ENCODER } from '../../constants.js';
3
+ export declare class PassportNumberType {
4
+ constructor(attributes?: Partial<PassportNumberType>);
5
+ countryCode?: string;
6
+ protected [DECODER](properties?: Partial<this>): Validator;
7
+ protected [ENCODER](properties?: Partial<this>): Validator;
8
+ }
@@ -0,0 +1,39 @@
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 PassportNumberType = class PassportNumberType {
6
+ constructor(attributes) {
7
+ if (attributes)
8
+ Object.assign(this, attributes);
9
+ }
10
+ countryCode;
11
+ [DECODER](properties) {
12
+ return vg.isPassportNumber(properties?.countryCode || 'TR', {
13
+ coerce: true,
14
+ });
15
+ }
16
+ [ENCODER](properties) {
17
+ return vg.isPassportNumber(properties?.countryCode || 'TR', {
18
+ coerce: true,
19
+ });
20
+ }
21
+ };
22
+ __decorate([
23
+ SimpleType.Attribute({
24
+ description: 'Country code',
25
+ }),
26
+ __metadata("design:type", String)
27
+ ], PassportNumberType.prototype, "countryCode", void 0);
28
+ PassportNumberType = __decorate([
29
+ SimpleType({
30
+ name: 'passportnumber',
31
+ description: 'A Passport Number',
32
+ nameMappings: {
33
+ js: 'string',
34
+ json: 'string',
35
+ },
36
+ }),
37
+ __metadata("design:paramtypes", [Object])
38
+ ], PassportNumberType);
39
+ export { PassportNumberType };
@@ -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?: 1 | 2 | 3 | 4 | 5;
5
+ version?: vg.isUUID.UUIDVersion;
6
6
  protected [DECODER](properties?: Partial<this>): Validator;
7
7
  protected [ENCODER](properties?: Partial<this>): Validator;
8
8
  }
@@ -19,7 +19,7 @@ __decorate([
19
19
  SimpleType.Attribute({
20
20
  description: 'Version of the UUID',
21
21
  }),
22
- __metadata("design:type", Number)
22
+ __metadata("design:type", Object)
23
23
  ], UuidType.prototype, "version", void 0);
24
24
  UuidType = __decorate([
25
25
  SimpleType({
@@ -0,0 +1,8 @@
1
+ import { type Validator, vg } from 'valgen';
2
+ import { DECODER, ENCODER } from '../../constants.js';
3
+ export declare class VatNumberType {
4
+ constructor(attributes?: Partial<VatNumberType>);
5
+ countryCode?: vg.isVATNumber.CountryCode;
6
+ protected [DECODER](properties?: Partial<this>): Validator;
7
+ protected [ENCODER](properties?: Partial<this>): Validator;
8
+ }
@@ -0,0 +1,39 @@
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 VatNumberType = class VatNumberType {
6
+ constructor(attributes) {
7
+ if (attributes)
8
+ Object.assign(this, attributes);
9
+ }
10
+ countryCode;
11
+ [DECODER](properties) {
12
+ return vg.isVATNumber(properties?.countryCode || 'TR', {
13
+ coerce: true,
14
+ });
15
+ }
16
+ [ENCODER](properties) {
17
+ return vg.isVATNumber(properties?.countryCode || 'TR', {
18
+ coerce: true,
19
+ });
20
+ }
21
+ };
22
+ __decorate([
23
+ SimpleType.Attribute({
24
+ description: 'Country code',
25
+ }),
26
+ __metadata("design:type", String)
27
+ ], VatNumberType.prototype, "countryCode", void 0);
28
+ VatNumberType = __decorate([
29
+ SimpleType({
30
+ name: 'vatnumber',
31
+ description: 'A VAT Number',
32
+ nameMappings: {
33
+ js: 'string',
34
+ json: 'string',
35
+ },
36
+ }),
37
+ __metadata("design:paramtypes", [Object])
38
+ ], VatNumberType);
39
+ export { VatNumberType };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opra/common",
3
- "version": "1.25.1",
3
+ "version": "1.25.3",
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.19.5"
22
+ "valgen": "^6.0.3"
23
23
  },
24
24
  "type": "module",
25
25
  "module": "./index.js",